@cordystackx/cordy_minikit 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -68,7 +68,7 @@ The current 3.0.0 API is:
68
68
  - `cordy.balance()`
69
69
  - `cordy.swap(amount, from, to)`
70
70
 
71
- `cordy.jwt_confirm()` remains available as a deprecated compatibility alias for `cordy.jwt_verify()`. Legacy controller helpers remain available for compatibility, but new integrations should use the `cordy.*` API.
71
+ Use `cordy.jwt_verify()` to check the app's session. Legacy controller helpers remain available for compatibility, but new integrations should use the `cordy.*` API.
72
72
 
73
73
  ## Experimental API
74
74
 
@@ -15,14 +15,11 @@ export type JwtDisconnectResult = {
15
15
  };
16
16
  /** Ask the app server whether the current browser session is authenticated. */
17
17
  export declare function jwt_verify(options?: JwtSessionRequestOptions): Promise<JwtSessionResult>;
18
- /** @deprecated Use jwt_verify instead. */
19
- export declare const jwt_confirm: typeof jwt_verify;
20
18
  /** Ask the app server to revoke and clear the current HttpOnly session cookie. */
21
19
  export declare function jwt_disconnect(options?: JwtSessionRequestOptions): Promise<JwtDisconnectResult>;
22
20
  export declare const cordy: {
23
21
  configure: typeof configureCordyAssets;
24
22
  jwt_verify: typeof jwt_verify;
25
- jwt_confirm: typeof jwt_verify;
26
23
  jwt_disconnect: typeof jwt_disconnect;
27
24
  balance: typeof cordy_balance;
28
25
  transfer: typeof cordy_transfer;
@@ -1 +1 @@
1
- {"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../client/jwt.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE3G,MAAM,MAAM,gBAAgB,GAAG;IAC7B,aAAa,EAAE,OAAO,CAAC;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,wBAA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AoB3B;AAED,kFAAkF;AAClF,wBAAsB,cAAc,CAClC,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,mBAAmB,CAAC,CA+C9B;AAED,eAAO,MAAM,KAAK;;;;;;;;CAQjB,CAAC"}
@@ -20,8 +20,6 @@ export async function jwt_verify(options = {}) {
20
20
  }
21
21
  return { authenticated: true };
22
22
  }
23
- /** @deprecated Use jwt_verify instead. */
24
- export const jwt_confirm = jwt_verify;
25
23
  /** Ask the app server to revoke and clear the current HttpOnly session cookie. */
26
24
  export async function jwt_disconnect(options = {}) {
27
25
  let status;
@@ -75,7 +73,6 @@ export async function jwt_disconnect(options = {}) {
75
73
  export const cordy = {
76
74
  configure: configureCordyAssets,
77
75
  jwt_verify,
78
- jwt_confirm,
79
76
  jwt_disconnect,
80
77
  balance: cordy_balance,
81
78
  transfer: cordy_transfer,
@@ -0,0 +1,52 @@
1
+ /** Public app configuration provided to ProvidersClientWrapper as JSON. */
2
+ export type EvmAssetConfig = {
3
+ symbol: string;
4
+ /** Defaults to the first configured EVM network when omitted. */
5
+ chainId?: number;
6
+ type?: "native" | "erc20";
7
+ contractAddress?: string;
8
+ decimals?: number;
9
+ rpcUrl?: string;
10
+ };
11
+ export type EvmNetworkConfig = {
12
+ chainId: number;
13
+ name: string;
14
+ nativeCurrency: {
15
+ name: string;
16
+ symbol: string;
17
+ decimals: number;
18
+ };
19
+ rpcUrl: string;
20
+ blockExplorerUrl?: string;
21
+ swapRouterAddress?: string;
22
+ wrappedNativeTokenAddress?: string;
23
+ };
24
+ export type StellarAssetConfig = {
25
+ symbol: string;
26
+ type: "native";
27
+ networkPassphrase?: string;
28
+ } | {
29
+ symbol: string;
30
+ type: "credit";
31
+ code: string;
32
+ issuer: string;
33
+ networkPassphrase?: string;
34
+ };
35
+ export type StellarNetworkConfig = {
36
+ horizonUrl: string;
37
+ networkPassphrase: string;
38
+ /** Optional Soroban contract ID used by app-specific contract integrations. */
39
+ contractId?: string;
40
+ };
41
+ export type CordyAssetsConfig = {
42
+ walletConnectProjectId?: string;
43
+ networks?: EvmNetworkConfig[];
44
+ evm?: EvmAssetConfig[];
45
+ stellarNetwork?: StellarNetworkConfig;
46
+ stellar?: StellarAssetConfig[];
47
+ };
48
+ export declare function setCordyRuntimeConfig(config: CordyAssetsConfig): void;
49
+ export declare function getCordyRuntimeConfig(): CordyAssetsConfig | undefined;
50
+ export declare function isEvmConfigReady(): boolean;
51
+ export declare function isStellarConfigReady(): boolean;
52
+ //# sourceMappingURL=runtimeConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeConfig.d.ts","sourceRoot":"","sources":["../../client/runtimeConfig.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC1B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9D;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjG,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC9B,GAAG,CAAC,EAAE,cAAc,EAAE,CAAC;IACvB,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAChC,CAAC;AAIF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAErE;AAED,wBAAgB,qBAAqB,IAAI,iBAAiB,GAAG,SAAS,CAErE;AAED,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAED,wBAAgB,oBAAoB,IAAI,OAAO,CAM9C"}
@@ -0,0 +1,15 @@
1
+ let activeConfig;
2
+ export function setCordyRuntimeConfig(config) {
3
+ activeConfig = config;
4
+ }
5
+ export function getCordyRuntimeConfig() {
6
+ return activeConfig;
7
+ }
8
+ export function isEvmConfigReady() {
9
+ return Boolean(activeConfig?.networks?.length && activeConfig.evm?.length);
10
+ }
11
+ export function isStellarConfigReady() {
12
+ return Boolean(activeConfig?.stellarNetwork?.horizonUrl &&
13
+ activeConfig.stellarNetwork.networkPassphrase &&
14
+ activeConfig.stellar?.length);
15
+ }
@@ -1,44 +1,5 @@
1
- export type EvmAssetConfig = {
2
- symbol: string;
3
- /** Defaults to NEXT_PUBLIC_CHAIN_ID when omitted. */
4
- chainId?: number;
5
- type?: "native" | "erc20";
6
- contractAddress?: string;
7
- decimals?: number;
8
- rpcUrl?: string;
9
- };
10
- export type EvmNetworkConfig = {
11
- chainId: number;
12
- name: string;
13
- nativeCurrency: {
14
- name: string;
15
- symbol: string;
16
- decimals: number;
17
- };
18
- rpcUrl: string;
19
- blockExplorerUrl?: string;
20
- /** Uniswap V2-compatible router used by cordy.swap(). */
21
- swapRouterAddress?: string;
22
- /** Wrapped native asset required to swap the chain's native currency. */
23
- wrappedNativeTokenAddress?: string;
24
- };
25
- export type StellarAssetConfig = {
26
- symbol: string;
27
- type: "native";
28
- networkPassphrase?: string;
29
- } | {
30
- symbol: string;
31
- type: "credit";
32
- code: string;
33
- issuer: string;
34
- networkPassphrase?: string;
35
- };
36
- /** JSON registry supplied by the application developer. */
37
- export type CordyAssetsConfig = {
38
- networks?: EvmNetworkConfig[];
39
- evm?: EvmAssetConfig[];
40
- stellar?: StellarAssetConfig[];
41
- };
1
+ import type { CordyAssetsConfig } from "./runtimeConfig";
2
+ export type { CordyAssetsConfig, EvmAssetConfig, EvmNetworkConfig, StellarAssetConfig, StellarNetworkConfig } from "./runtimeConfig";
42
3
  export type CordyTransferOptions = {
43
4
  /** Asset symbol from the configured JSON registry. */
44
5
  asset?: string;
@@ -52,7 +13,7 @@ export type CordyTransferResult = {
52
13
  error?: string;
53
14
  };
54
15
  export type CordyBalanceOptions = {
55
- /** Asset symbol from the configured JSON registry. Defaults to the EVM env token or Stellar XLM. */
16
+ /** Asset symbol from the configured JSON registry. Defaults to the first configured EVM token or Stellar XLM. */
56
17
  asset?: string;
57
18
  };
58
19
  export type CordyBalanceResult = {
@@ -1 +1 @@
1
- {"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../../client/transfer.ts"],"names":[],"mappings":"AAeA,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,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AM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAsBF,wBAAgB,oBAAoB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,iBAAiB,CAAA;CAAE,GAAG,IAAI,CAcpF;AA8MD,6FAA6F;AAC7F,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,IAAI,EAAE,eAAe,EACrB,EAAE,EAAE,eAAe,EACnB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,iBAAiB,CAAC,CAM5B;AAyHD,gFAAgF;AAChF,wBAAsB,aAAa,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAYlG;AA0MD,yEAAyE;AACzE,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAU5G;AAED,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,OAAO,EAAE;IAAE,MAAM,EAAE,iBAAiB,CAAA;CAAE,GAAG,IAAI,CAE5E;AAED,2EAA2E;AAC3E,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,mBAAmB,CAAC,CAa9B"}
@@ -1,15 +1,14 @@
1
1
  "use client";
2
- import { Asset, BASE_FEE, Horizon, Memo, Networks, Operation, StrKey, TransactionBuilder } from "@stellar/stellar-sdk";
2
+ import { Asset, BASE_FEE, Horizon, Memo, Operation, StrKey, TransactionBuilder } from "@stellar/stellar-sdk";
3
3
  import { getNetworkDetails, requestAccess, signTransaction as freighterSignTransaction } from "@stellar/freighter-api";
4
4
  import { BrowserProvider, Contract, formatUnits, isAddress, JsonRpcProvider, parseUnits } from "ethers";
5
5
  import { getActiveWagmiConfig } from "../config/walletConfig";
6
6
  import { readTokenBalance } from "../controllers/Get_Balance";
7
7
  import loadStellarBalance from "../controllers/loadStellarBalance";
8
8
  import tokenAbi from "../config/ERC20_ABI.json";
9
+ import { setCordyRuntimeConfig } from "./runtimeConfig";
9
10
  const ACTIVE_WALLET_SESSION_KEY = "cordy_minikit_active_wallet_session";
10
11
  const STELLAR_WALLET_STORAGE_KEY = "cordy_minikit_stellar_wallet";
11
- const stellarRpc = process.env.NEXT_PUBLIC_STELLAR_HORIZON || "https://horizon-testnet.stellar.org";
12
- const stellarNetwork = process.env.NEXT_PUBLIC_STELLAR_NETWORK_PASSPHRASE || Networks.TESTNET;
13
12
  // First test route: BOT Chain Testnet <-> Ethereum Sepolia, USDT only.
14
13
  const BOT_TESTNET_CHAIN_ID = 968;
15
14
  const SEPOLIA_CHAIN_ID = 11155111;
@@ -38,7 +37,20 @@ export function configureCordyAssets({ assets }) {
38
37
  networks: (assets.networks ?? []).map((network) => ({ ...network, nativeCurrency: { ...network.nativeCurrency } })),
39
38
  evm: (assets.evm ?? []).map((asset) => ({ ...asset })),
40
39
  stellar: (assets.stellar ?? []).map((asset) => ({ ...asset })),
40
+ walletConnectProjectId: assets.walletConnectProjectId,
41
+ stellarNetwork: assets.stellarNetwork ? { ...assets.stellarNetwork } : undefined,
41
42
  };
43
+ setCordyRuntimeConfig(configuredAssets);
44
+ }
45
+ function requireStellarNetwork() {
46
+ const network = configuredAssets?.stellarNetwork;
47
+ if (!network?.horizonUrl || !network.networkPassphrase || !configuredAssets?.stellar?.length) {
48
+ throw new Error("Stellar is not configured. Add stellarNetwork and Stellar assets to the JSON passed to ProvidersClientWrapper.");
49
+ }
50
+ return network;
51
+ }
52
+ function getDefaultEvmChainId() {
53
+ return configuredAssets?.networks?.[0]?.chainId;
42
54
  }
43
55
  function normalizedAmount(amount) {
44
56
  const value = String(amount).trim();
@@ -48,19 +60,21 @@ function normalizedAmount(amount) {
48
60
  return value;
49
61
  }
50
62
  function resolveEvmAsset(requestedSymbol, chainId, networkName) {
51
- if (!requestedSymbol)
63
+ const defaultChainId = getDefaultEvmChainId();
64
+ const chainAssets = configuredAssets?.evm?.filter((asset) => (asset.chainId ?? defaultChainId) === chainId) ?? [];
65
+ const symbol = requestedSymbol || chainAssets.find((asset) => asset.contractAddress)?.symbol || chainAssets[0]?.symbol;
66
+ if (!symbol)
52
67
  return undefined;
53
- const sameSymbol = (configuredAssets?.evm ?? []).filter((asset) => asset.symbol.toLowerCase() === requestedSymbol.toLowerCase());
54
- const configuredChainId = Number(process.env.NEXT_PUBLIC_CHAIN_ID);
55
- const matchingNetwork = sameSymbol.find((asset) => (asset.chainId ?? configuredChainId) === chainId);
68
+ const sameSymbol = (configuredAssets?.evm ?? []).filter((asset) => asset.symbol.toLowerCase() === symbol.toLowerCase());
69
+ const matchingNetwork = sameSymbol.find((asset) => (asset.chainId ?? defaultChainId) === chainId);
56
70
  if (sameSymbol.length > 0 && !matchingNetwork) {
57
- const chainIds = [...new Set(sameSymbol.map((asset) => asset.chainId ?? configuredChainId))].join(", ");
58
- throw new Error(`${requestedSymbol} is configured for chain ID ${chainIds}, but the connected wallet is on ${networkName} (chain ID ${chainId}). Switch networks or add an asset entry for this chain.`);
71
+ const chainIds = [...new Set(sameSymbol.map((asset) => asset.chainId ?? defaultChainId))].join(", ");
72
+ throw new Error(`${symbol} is configured for chain ID ${chainIds}, but the connected wallet is on ${networkName} (chain ID ${chainId}). Switch networks or add an asset entry for this chain.`);
59
73
  }
60
74
  return matchingNetwork;
61
75
  }
62
76
  function resolveConfiguredEvmSwapAsset(symbol, chainId) {
63
- const configuredChainId = Number(process.env.NEXT_PUBLIC_CHAIN_ID);
77
+ const configuredChainId = getDefaultEvmChainId();
64
78
  const matches = (configuredAssets?.evm ?? []).filter((asset) => asset.symbol.toLowerCase() === symbol.toLowerCase() &&
65
79
  (asset.chainId ?? configuredChainId) === chainId);
66
80
  if (matches.length > 1) {
@@ -68,23 +82,7 @@ function resolveConfiguredEvmSwapAsset(symbol, chainId) {
68
82
  }
69
83
  if (matches.length === 1)
70
84
  return matches[0];
71
- const envTokenSymbol = process.env.NEXT_PUBLIC_TOKEN_SYMBOL?.trim();
72
- const envTokenAddress = process.env.NEXT_PUBLIC_TOKENADDRESS?.trim();
73
- const envChainId = Number(process.env.NEXT_PUBLIC_CHAIN_ID);
74
- if (envTokenSymbol?.toLowerCase() === symbol.toLowerCase() &&
75
- envTokenAddress &&
76
- Number.isSafeInteger(envChainId) &&
77
- envChainId === chainId) {
78
- if (!isAddress(envTokenAddress))
79
- throw new Error("NEXT_PUBLIC_TOKENADDRESS is not a valid EVM token address.");
80
- return {
81
- symbol: envTokenSymbol,
82
- chainId,
83
- contractAddress: envTokenAddress,
84
- rpcUrl: process.env.NEXT_PUBLIC_RPC_ENDPOINT,
85
- };
86
- }
87
- throw new Error(`${symbol} is not configured for EVM chain ID ${chainId}. Add it to the assets JSON or configure it with NEXT_PUBLIC_TOKEN_SYMBOL and NEXT_PUBLIC_TOKENADDRESS for this chain.`);
85
+ throw new Error(`${symbol} is not configured for EVM chain ID ${chainId}. Add it to the assets JSON.`);
88
86
  }
89
87
  function resolveConfiguredStellarSwapAsset(symbol, networkPassphrase) {
90
88
  const matches = (configuredAssets?.stellar ?? []).filter((asset) => asset.symbol.toLowerCase() === symbol.toLowerCase() &&
@@ -107,24 +105,14 @@ const ERC20_SWAP_ABI = [
107
105
  "function allowance(address owner,address spender) view returns (uint256)",
108
106
  "function decimals() view returns (uint8)",
109
107
  ];
110
- function resolveEvmSwapNetworkConfig(chainId, fallbackName) {
108
+ function resolveEvmSwapNetworkConfig(chainId) {
111
109
  const registered = configuredAssets?.networks?.find((network) => network.chainId === chainId);
112
110
  if (registered)
113
111
  return registered;
114
- const envChainId = Number(process.env.NEXT_PUBLIC_CHAIN_ID);
115
- const rpcUrl = process.env.NEXT_PUBLIC_RPC_ENDPOINT;
116
- if (!rpcUrl || !Number.isSafeInteger(envChainId) || envChainId !== chainId)
117
- return undefined;
118
- return {
119
- chainId,
120
- name: process.env.NEXT_PUBLIC_CHAIN_NAME || fallbackName,
121
- rpcUrl,
122
- swapRouterAddress: process.env.NEXT_PUBLIC_SWAP_ROUTER_ADDRESS,
123
- wrappedNativeTokenAddress: process.env.NEXT_PUBLIC_WRAPPED_NATIVE_TOKEN_ADDRESS,
124
- };
112
+ return undefined;
125
113
  }
126
114
  async function getEvmReadProvider(walletProvider, chainId, networkName, assetRpcUrl) {
127
- const rpcUrl = assetRpcUrl || configuredAssets?.networks?.find((network) => network.chainId === chainId)?.rpcUrl || process.env.NEXT_PUBLIC_RPC_ENDPOINT;
115
+ const rpcUrl = assetRpcUrl || configuredAssets?.networks?.find((network) => network.chainId === chainId)?.rpcUrl;
128
116
  if (!rpcUrl)
129
117
  return walletProvider;
130
118
  const rpcProvider = new JsonRpcProvider(rpcUrl);
@@ -133,8 +121,6 @@ async function getEvmReadProvider(walletProvider, chainId, networkName, assetRpc
133
121
  rpcNetwork = await rpcProvider.getNetwork();
134
122
  }
135
123
  catch {
136
- if (!assetRpcUrl && !configuredAssets?.networks?.some((network) => network.rpcUrl === rpcUrl))
137
- return walletProvider;
138
124
  throw new Error(`Could not reach the configured EVM RPC endpoint for ${networkName}. Check its URL and availability.`);
139
125
  }
140
126
  if (Number(rpcNetwork.chainId) !== chainId) {
@@ -262,10 +248,9 @@ async function transferEvm(amount, recipient, requestedSymbol) {
262
248
  const chain = await provider.getNetwork();
263
249
  const chainId = Number(chain.chainId);
264
250
  const tokenConfig = resolveEvmAsset(requestedSymbol, chainId, chain.name);
265
- const fallbackAddress = process.env.NEXT_PUBLIC_TOKENADDRESS || "";
266
- const contractAddress = tokenConfig?.contractAddress || fallbackAddress;
251
+ const contractAddress = tokenConfig?.contractAddress || "";
267
252
  if (!contractAddress) {
268
- throw new Error(`No ${requestedSymbol || "default"} EVM token configured. Add it to the asset JSON or set NEXT_PUBLIC_TOKENADDRESS.`);
253
+ throw new Error(`No ${requestedSymbol || "default"} EVM token configured. Add it to the asset JSON.`);
269
254
  }
270
255
  if (!isAddress(contractAddress))
271
256
  throw new Error("The configured EVM token contract address is invalid.");
@@ -318,9 +303,9 @@ async function readEvmBalance(requestedSymbol) {
318
303
  asset: tokenConfig.symbol,
319
304
  };
320
305
  }
321
- const contractAddress = tokenConfig?.contractAddress || process.env.NEXT_PUBLIC_TOKENADDRESS || "";
306
+ const contractAddress = tokenConfig?.contractAddress || "";
322
307
  if (!contractAddress) {
323
- throw new Error(`No ${requestedSymbol || "default"} EVM token configured. Add it to the asset JSON or set NEXT_PUBLIC_TOKENADDRESS.`);
308
+ throw new Error(`No ${requestedSymbol || "default"} EVM token configured. Add it to the asset JSON.`);
324
309
  }
325
310
  if (!isAddress(contractAddress))
326
311
  throw new Error("The configured EVM token contract address is invalid.");
@@ -346,6 +331,7 @@ async function readEvmBalance(requestedSymbol) {
346
331
  }
347
332
  async function readStellarBalance(requestedSymbol) {
348
333
  const symbol = requestedSymbol || "XLM";
334
+ const stellarConfig = requireStellarNetwork();
349
335
  const access = await requestAccess();
350
336
  const address = access.address;
351
337
  if (!address)
@@ -353,8 +339,8 @@ async function readStellarBalance(requestedSymbol) {
353
339
  const balance = await loadStellarBalance(address, {
354
340
  assetSymbol: symbol,
355
341
  assets: configuredAssets?.stellar,
356
- horizonUrl: stellarRpc,
357
- networkPassphrase: stellarNetwork,
342
+ horizonUrl: stellarConfig.horizonUrl,
343
+ networkPassphrase: stellarConfig.networkPassphrase,
358
344
  });
359
345
  return {
360
346
  success: true,
@@ -379,6 +365,7 @@ export async function cordy_balance(options = {}) {
379
365
  }
380
366
  }
381
367
  async function transferStellar(amount, recipient, requestedSymbol, memo) {
368
+ const stellarConfig = requireStellarNetwork();
382
369
  if (!StrKey.isValidEd25519PublicKey(recipient))
383
370
  throw new Error("Recipient must be a valid Stellar public address.");
384
371
  if (!/^\d+(\.\d{1,7})?$/.test(amount))
@@ -389,9 +376,9 @@ async function transferStellar(amount, recipient, requestedSymbol, memo) {
389
376
  if (!sourceAddress)
390
377
  throw new Error("Could not access the connected Stellar wallet.");
391
378
  const networkDetails = await getNetworkDetails();
392
- const networkPassphrase = networkDetails.networkPassphrase || stellarNetwork;
393
- if (networkDetails.networkPassphrase && networkDetails.networkPassphrase !== stellarNetwork) {
394
- throw new Error(`Stellar network mismatch. Expected ${stellarNetwork}, got ${networkDetails.networkPassphrase}.`);
379
+ const networkPassphrase = networkDetails.networkPassphrase || stellarConfig.networkPassphrase;
380
+ if (networkDetails.networkPassphrase && networkDetails.networkPassphrase !== stellarConfig.networkPassphrase) {
381
+ throw new Error(`Stellar network mismatch. Expected ${stellarConfig.networkPassphrase}, got ${networkDetails.networkPassphrase}.`);
395
382
  }
396
383
  const candidates = (configuredAssets?.stellar ?? []).filter((asset) => asset.symbol.toLowerCase() === symbol.toLowerCase() &&
397
384
  (!asset.networkPassphrase || asset.networkPassphrase === networkPassphrase));
@@ -404,7 +391,7 @@ async function transferStellar(amount, recipient, requestedSymbol, memo) {
404
391
  const stellarAsset = assetConfig.type === "native"
405
392
  ? Asset.native()
406
393
  : new Asset(assetConfig.code, assetConfig.issuer);
407
- const server = new Horizon.Server(stellarRpc);
394
+ const server = new Horizon.Server(stellarConfig.horizonUrl);
408
395
  const sourceAccount = await server.loadAccount(sourceAddress);
409
396
  const assetBalance = assetConfig.type === "native"
410
397
  ? sourceAccount.balances.find((item) => item.asset_type === "native")
@@ -451,21 +438,21 @@ async function swapEvm(amount, fromSymbol, toSymbol) {
451
438
  const provider = new BrowserProvider(rawProvider);
452
439
  const chain = await provider.getNetwork();
453
440
  const chainId = Number(chain.chainId);
454
- const networkConfig = resolveEvmSwapNetworkConfig(chainId, chain.name);
441
+ const networkConfig = resolveEvmSwapNetworkConfig(chainId);
455
442
  const networkName = networkConfig?.name || chain.name;
456
443
  const fromAsset = resolveConfiguredEvmSwapAsset(fromSymbol, chainId);
457
444
  const toAsset = resolveConfiguredEvmSwapAsset(toSymbol, chainId);
458
445
  if (fromSymbol.toLowerCase() === toSymbol.toLowerCase())
459
446
  throw new Error("Choose two different assets to swap.");
460
447
  if (!networkConfig?.swapRouterAddress || !isAddress(networkConfig.swapRouterAddress)) {
461
- throw new Error(`No valid Uniswap V2-compatible swap router is configured for ${networkName} (chain ID ${chainId}). Set NEXT_PUBLIC_SWAP_ROUTER_ADDRESS or add the network to assets JSON.`);
448
+ throw new Error(`No valid Uniswap V2-compatible swap router is configured for ${networkName} (chain ID ${chainId}). Add swapRouterAddress to its network entry in assets JSON.`);
462
449
  }
463
450
  const isNative = (asset) => asset.type === "native" || !asset.contractAddress;
464
451
  const fromNative = isNative(fromAsset);
465
452
  const toNative = isNative(toAsset);
466
453
  const wrappedNative = networkConfig.wrappedNativeTokenAddress;
467
454
  if ((fromNative || toNative) && (!wrappedNative || !isAddress(wrappedNative))) {
468
- throw new Error(`Set NEXT_PUBLIC_WRAPPED_NATIVE_TOKEN_ADDRESS or configure wrappedNativeTokenAddress for ${networkName} to swap its native currency.`);
455
+ throw new Error(`Configure wrappedNativeTokenAddress for ${networkName} in assets JSON to swap its native currency.`);
469
456
  }
470
457
  const fromAddress = fromNative ? wrappedNative : fromAsset.contractAddress;
471
458
  const toAddress = toNative ? wrappedNative : toAsset.contractAddress;
@@ -525,6 +512,7 @@ function stellarAssetFromConfig(asset) {
525
512
  return asset.type === "native" ? Asset.native() : new Asset(asset.code, asset.issuer);
526
513
  }
527
514
  async function swapStellar(amount, fromSymbol, toSymbol) {
515
+ const stellarConfig = requireStellarNetwork();
528
516
  if (fromSymbol.toLowerCase() === toSymbol.toLowerCase())
529
517
  throw new Error("Choose two different assets to swap.");
530
518
  if (!/^\d+(\.\d{1,7})?$/.test(amount))
@@ -534,14 +522,14 @@ async function swapStellar(amount, fromSymbol, toSymbol) {
534
522
  if (!source)
535
523
  throw new Error("Could not access the connected Stellar wallet.");
536
524
  const networkDetails = await getNetworkDetails();
537
- const passphrase = networkDetails.networkPassphrase || stellarNetwork;
538
- if (passphrase !== stellarNetwork)
539
- throw new Error(`Stellar network mismatch. Expected ${stellarNetwork}, got ${passphrase}.`);
525
+ const passphrase = networkDetails.networkPassphrase || stellarConfig.networkPassphrase;
526
+ if (passphrase !== stellarConfig.networkPassphrase)
527
+ throw new Error(`Stellar network mismatch. Expected ${stellarConfig.networkPassphrase}, got ${passphrase}.`);
540
528
  const fromAsset = resolveConfiguredStellarSwapAsset(fromSymbol, passphrase);
541
529
  const toAsset = resolveConfiguredStellarSwapAsset(toSymbol, passphrase);
542
530
  const stellarFrom = stellarAssetFromConfig(fromAsset);
543
531
  const stellarTo = stellarAssetFromConfig(toAsset);
544
- const server = new Horizon.Server(stellarRpc);
532
+ const server = new Horizon.Server(stellarConfig.horizonUrl);
545
533
  const sourceAccount = await server.loadAccount(source);
546
534
  const paths = await server.strictSendPaths(stellarFrom, amount, [stellarTo]).call();
547
535
  const route = paths.records[0];
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { cordy, jwt_confirm, jwt_verify, jwt_disconnect } from "./client/jwt";
1
+ export { cordy, jwt_verify, jwt_disconnect } from "./client/jwt";
2
2
  export type { JwtDisconnectResult, JwtSessionRequestOptions, JwtSessionResult } from "./client/jwt";
3
3
  export { configureCordyAssets, cordy_configure, cordy_bridge, cordy_swap, cordy_transfer } from "./client/transfer";
4
4
  export type { CordyAssetsConfig, CordyBridgeResult, CordyBridgeSide, CordyTransferOptions, CordyTransferResult, CordySwapResult, EvmAssetConfig, EvmNetworkConfig, StellarAssetConfig } from "./client/transfer";
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9E,YAAY,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEpG,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACpH,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,eAAe,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACjE,YAAY,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEpG,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACpH,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,eAAe,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/client.js CHANGED
@@ -1,2 +1,2 @@
1
- export { cordy, jwt_confirm, jwt_verify, jwt_disconnect } from "./client/jwt";
1
+ export { cordy, jwt_verify, jwt_disconnect } from "./client/jwt";
2
2
  export { configureCordyAssets, cordy_configure, cordy_bridge, cordy_swap, cordy_transfer } from "./client/transfer";
@@ -26,8 +26,8 @@ export default function ProvidersClientWrapper({ children, assets, }) {
26
26
  : {}),
27
27
  }),
28
28
  ]));
29
- return getConfig(customChains);
30
- }, [assets?.networks]);
29
+ return getConfig(customChains, { walletConnectProjectId: assets?.walletConnectProjectId });
30
+ }, [assets?.networks, assets?.walletConnectProjectId]);
31
31
  useEffect(() => {
32
32
  if (assets)
33
33
  configureCordyAssets({ assets });
@@ -1,6 +1,8 @@
1
1
  import { createConfig } from 'wagmi';
2
2
  import type { Chain } from 'wagmi/chains';
3
- export default function getConfig(customChains?: Record<string, Chain>): ReturnType<typeof createConfig>;
3
+ export default function getConfig(customChains?: Record<string, Chain>, options?: {
4
+ walletConnectProjectId?: string;
5
+ }): ReturnType<typeof createConfig>;
4
6
  export declare const config: ReturnType<typeof createConfig>;
5
7
  export declare function setActiveWagmiConfig(nextConfig: ReturnType<typeof createConfig>): void;
6
8
  export declare function getActiveWagmiConfig(): ReturnType<typeof createConfig>;
@@ -1 +1 @@
1
- {"version":3,"file":"walletConfig.d.ts","sourceRoot":"","sources":["../../config/walletConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,YAAY,EAAE,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAgC1C,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,YAAY,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CA2B3G;AAED,eAAO,MAAM,MAAM,EAAE,UAAU,CAAC,OAAO,YAAY,CAGN,CAAC;AAI9C,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,GAAG,IAAI,CAEtF;AAED,wBAAgB,oBAAoB,IAAI,UAAU,CAAC,OAAO,YAAY,CAAC,CAEtE;AAED,wBAAgB,0BAA0B,IAAI,OAAO,CAEpD"}
1
+ {"version":3,"file":"walletConfig.d.ts","sourceRoot":"","sources":["../../config/walletConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,YAAY,EAAE,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1C,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,YAAY,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,EACxC,OAAO,GAAE;IAAE,sBAAsB,CAAC,EAAE,MAAM,CAAA;CAAO,GAChD,UAAU,CAAC,OAAO,YAAY,CAAC,CA2BjC;AAED,eAAO,MAAM,MAAM,EAAE,UAAU,CAAC,OAAO,YAAY,CAGN,CAAC;AAI9C,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,GAAG,IAAI,CAEtF;AAED,wBAAgB,oBAAoB,IAAI,UAAU,CAAC,OAAO,YAAY,CAAC,CAEtE;AAED,wBAAgB,0BAA0B,IAAI,OAAO,CAEpD"}
@@ -1,35 +1,9 @@
1
1
  import { http, createConfig } from 'wagmi';
2
2
  import { mainnet, base, sepolia } from 'wagmi/chains';
3
3
  import { walletConnect, metaMask, coinbaseWallet } from 'wagmi/connectors';
4
- import { defineChain } from 'viem';
5
- const projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID;
6
- const hasConfiguredEvmEnvironment = Boolean(process.env.NEXT_PUBLIC_RPC_ENDPOINT &&
7
- process.env.NEXT_PUBLIC_CHAIN_ID &&
8
- process.env.NEXT_PUBLIC_TOKENADDRESS);
9
- const configuredChainId = Number(process.env.NEXT_PUBLIC_CHAIN_ID || mainnet.id);
10
- if (!Number.isSafeInteger(configuredChainId) || configuredChainId <= 0) {
11
- throw new Error('NEXT_PUBLIC_CHAIN_ID must be a positive integer.');
12
- }
13
- const configuredRpcEndpoint = process.env.NEXT_PUBLIC_RPC_ENDPOINT
14
- || mainnet.rpcUrls.default.http[0];
15
- const configuredChain = defineChain({
16
- id: configuredChainId,
17
- name: process.env.NEXT_PUBLIC_CHAIN_NAME || mainnet.name,
18
- nativeCurrency: process.env.NEXT_PUBLIC_CHAIN_ID
19
- ? { name: 'Configured native token', symbol: 'NATIVE', decimals: 18 }
20
- : mainnet.nativeCurrency,
21
- rpcUrls: {
22
- default: { http: [configuredRpcEndpoint] },
23
- },
24
- blockExplorers: {
25
- default: {
26
- name: process.env.NEXT_PUBLIC_CHAIN_NAME ? `${process.env.NEXT_PUBLIC_CHAIN_NAME} Explorer` : mainnet.blockExplorers.default.name,
27
- url: process.env.NEXT_PUBLIC_BLOCK_EXPLORER_URL || mainnet.blockExplorers.default.url,
28
- },
29
- },
30
- });
31
- export default function getConfig(customChains = {}) {
32
- const uniqueChains = [...Object.values(customChains), configuredChain, mainnet, base, sepolia]
4
+ import { isEvmConfigReady } from '../client/runtimeConfig';
5
+ export default function getConfig(customChains = {}, options = {}) {
6
+ const uniqueChains = [...Object.values(customChains), mainnet, base, sepolia]
33
7
  .filter((chain, index, chains) => chains.findIndex((candidate) => candidate.id === chain.id) === index);
34
8
  const [firstChain, ...otherChains] = uniqueChains;
35
9
  if (!firstChain)
@@ -45,7 +19,7 @@ export default function getConfig(customChains = {}) {
45
19
  chains: allChains,
46
20
  connectors: [
47
21
  metaMask(),
48
- walletConnect({ projectId }),
22
+ ...(options.walletConnectProjectId ? [walletConnect({ projectId: options.walletConnectProjectId })] : []),
49
23
  coinbaseWallet({
50
24
  appName: "cordy_minikit",
51
25
  }),
@@ -64,5 +38,5 @@ export function getActiveWagmiConfig() {
64
38
  return activeWagmiConfig;
65
39
  }
66
40
  export function isEvmEnvironmentConfigured() {
67
- return hasConfiguredEvmEnvironment;
41
+ return isEvmConfigReady();
68
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Get_Balance.d.ts","sourceRoot":"","sources":["../../controllers/Get_Balance.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqD,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAG1F,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,gBAAgB,CAAC,EAAE,QAAQ,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAA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C;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,4EAA4E;AAC5E,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,kBAAkB,CAAC,CAyF7B;AAED,0FAA0F;AAC1F,wBAA8B,eAAe,CAC3C,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAQ9C"}
@@ -1,9 +1,14 @@
1
1
  import { Contract, formatUnits, isAddress, JsonRpcProvider } from "ethers";
2
2
  import ERC20_ABI from "../config/ERC20_ABI.json";
3
+ import { getCordyRuntimeConfig } from "../client/runtimeConfig";
3
4
  /** Shared ERC-20 balance reader used by wallet status and the Cordy API. */
4
5
  export async function readTokenBalance(address, options = {}) {
5
- const tokenAddress = options.tokenAddress || process.env.NEXT_PUBLIC_TOKENADDRESS;
6
- const rpcUrl = options.rpcUrl || process.env.NEXT_PUBLIC_RPC_ENDPOINT;
6
+ const assets = getCordyRuntimeConfig();
7
+ const configuredChainId = options.expectedChainId ?? assets?.networks?.[0]?.chainId;
8
+ const chainAssets = assets?.evm?.filter((asset) => (asset.chainId ?? assets.networks?.[0]?.chainId) === configuredChainId) ?? [];
9
+ const defaultAsset = chainAssets.find((asset) => asset.contractAddress) || chainAssets[0];
10
+ const tokenAddress = options.tokenAddress || defaultAsset?.contractAddress;
11
+ const rpcUrl = options.rpcUrl || defaultAsset?.rpcUrl || assets?.networks?.find((network) => network.chainId === configuredChainId)?.rpcUrl;
7
12
  const provider = options.provider || (rpcUrl ? new JsonRpcProvider(rpcUrl) : undefined);
8
13
  if (!tokenAddress)
9
14
  throw new Error("No EVM token address is configured.");
@@ -21,7 +21,7 @@ export default function StellarWalletButton({ onConnect, onStatusChange, }) {
21
21
  onStatusChange?.({ isPending: true });
22
22
  try {
23
23
  if (!isStellarEnvironmentConfigured()) {
24
- throw new Error("Stellar environment is not configured. Set NEXT_PUBLIC_STELLAR_HORIZON, NEXT_PUBLIC_STELLAR_CONTRACT_ID, and NEXT_PUBLIC_STELLAR_NETWORK_PASSPHRASE.");
24
+ throw new Error("Stellar is not configured. Add stellarNetwork and Stellar assets to the JSON passed to ProvidersClientWrapper.");
25
25
  }
26
26
  const connection = await isConnected();
27
27
  if (!connection.isConnected) {
@@ -1 +1 @@
1
- {"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../controllers/Transactions.tsx"],"names":[],"mappings":"AAWA,KAAK,6BAA6B,GAAG;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,8EAA8E;AAC9E,wBAA8B,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,oBAqD1E;AAED,2FAA2F;AAC3F,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,6BAAkC,oBAoF5C"}
1
+ {"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../controllers/Transactions.tsx"],"names":[],"mappings":"AAOA,KAAK,6BAA6B,GAAG;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,8EAA8E;AAC9E,wBAA8B,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,oBA4D1E;AAED,2FAA2F;AAC3F,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,6BAAkC,oBAyF5C"}