-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathappKeys.ts
More file actions
60 lines (54 loc) · 2.22 KB
/
Copy pathappKeys.ts
File metadata and controls
60 lines (54 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import Constants from "expo-constants";
import { logger } from "@/utils/logger";
export interface AppExtraConfig {
authServerBaseUrl?: string;
redirectUri?: string;
apiBaseUrl?: string;
alchemyApiKey?: string;
pimlicoApiKey?: string;
gasManagerPolicyId?: string;
chainId?: string;
chainRpcUrl?: string;
usdcAddress?: string;
stripePublishableKey?: string;
stripeMerchantIdentifier?: string;
walletConnectProjectId?: string;
externalWalletCallback?: string;
}
const extra =
(Constants.expoConfig?.extra as AppExtraConfig | undefined) ??
((Constants as any).manifest?.extra as AppExtraConfig | undefined) ??
((Constants as any).manifest2?.extra?.expoClient?.extra as
| AppExtraConfig
| undefined);
logger.debug("[KOKIO CONFIG DEBUG]", {
extraKeys: Object.keys(extra ?? {}),
apiBaseUrl: extra?.apiBaseUrl,
authServerBaseUrl: extra?.authServerBaseUrl,
stripePublishableKeySet: Boolean(extra?.stripePublishableKey),
walletConnectProjectIdSet: Boolean(extra?.walletConnectProjectId),
});
export const Config = {
AUTH_SERVER_BASE_URL: extra?.authServerBaseUrl,
REDIRECT_URI: extra?.redirectUri,
API_BASE_URL: extra?.apiBaseUrl,
ALCHEMY_API_KEY: extra?.alchemyApiKey,
PIMLICO_API_KEY: extra?.pimlicoApiKey,
GAS_MANAGER_POLICY_ID: extra?.gasManagerPolicyId,
CHAIN_ID: extra?.chainId ? Number(extra.chainId) : undefined,
CHAIN_RPC_URL: extra?.chainRpcUrl,
USDC_ADDRESS: extra?.usdcAddress,
STRIPE_PUBLISHABLE_KEY: extra?.stripePublishableKey,
STRIPE_MERCHANT_IDENTIFIER: extra?.stripeMerchantIdentifier,
WALLETCONNECT_PROJECT_ID: extra?.walletConnectProjectId,
EXTERNAL_WALLET_CALLBACK: extra?.externalWalletCallback,
validateSecrets: () => {
if (!extra?.authServerBaseUrl) logger.error('CONFIG_MISSING_AUTH_SERVER_BASE_URL');
if (!extra?.redirectUri) logger.error('CONFIG_MISSING_REDIRECT_URI');
if (!extra?.apiBaseUrl) logger.error('CONFIG_MISSING_API_BASE_URL');
if (!extra?.stripePublishableKey) logger.error('CONFIG_MISSING_STRIPE_PUBLISHABLE_KEY');
if (!extra?.stripeMerchantIdentifier) logger.warn('CONFIG_MISSING_STRIPE_MERCHANT_IDENTIFIER');
if (!extra?.walletConnectProjectId) logger.warn('CONFIG_MISSING_WALLETCONNECT_PROJECT_ID');
},
};
Config.validateSecrets();