diff --git a/src/lib/components/GetQuote.svelte b/src/lib/components/GetQuote.svelte index d304356..3bb606c 100644 --- a/src/lib/components/GetQuote.svelte +++ b/src/lib/components/GetQuote.svelte @@ -10,7 +10,8 @@ inputTokens, outputTokens = $bindable(), account, - mainnet + mainnet, + useProductionApi }: { exclusiveFor: string; useExclusiveForQuoteRequest?: boolean; @@ -18,12 +19,13 @@ outputTokens: AppTokenContext[]; account: () => `0x${string}`; mainnet: boolean; + useProductionApi: boolean | null; } = $props(); const toRawAddress = (value: string): `0x${string}` | undefined => isAddress(value, { strict: false }) ? (value as `0x${string}`) : undefined; - const intentApi = $derived(new IntentApi(mainnet)); + const intentApi = $derived(new IntentApi(useProductionApi ?? mainnet)); async function getQuoteAndSet() { try { diff --git a/src/lib/config.ts b/src/lib/config.ts index 7495ebc..122936a 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -11,7 +11,8 @@ import { bsc, katana, megaeth, - optimism + optimism, + arcTestnet } from "viem/chains"; export const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000" as const; @@ -41,10 +42,11 @@ export const POLYMER_ORACLE: Partial> = { [polygon.id]: "0x0000003E06000007A224AeE90052fA6bb46d43C9", [bsc.id]: "0x0000003E06000007A224AeE90052fA6bb46d43C9", // testnet - [sepolia.id]: "0x00d5b500ECa100F7cdeDC800eC631Aca00BaAC00", - [baseSepolia.id]: "0x00d5b500ECa100F7cdeDC800eC631Aca00BaAC00", - [arbitrumSepolia.id]: "0x00d5b500ECa100F7cdeDC800eC631Aca00BaAC00", - [optimismSepolia.id]: "0x00d5b500ECa100F7cdeDC800eC631Aca00BaAC00" + [sepolia.id]: "0xe15b438C6267B0011aDa1e40fD8757Aa8Fe1E5a0", + [baseSepolia.id]: "0xe15b438C6267B0011aDa1e40fD8757Aa8Fe1E5a0", + [arbitrumSepolia.id]: "0xe15b438C6267B0011aDa1e40fD8757Aa8Fe1E5a0", + [optimismSepolia.id]: "0xe15b438C6267B0011aDa1e40fD8757Aa8Fe1E5a0", + [arcTestnet.id]: "0xe15b438C6267B0011aDa1e40fD8757Aa8Fe1E5a0" }; export type availableAllocators = typeof ALWAYS_OK_ALLOCATOR | typeof POLYMER_ALLOCATOR; @@ -64,14 +66,22 @@ export const chainMap = { katana, megaeth, bsc, - polygon + polygon, + arcTestnet } as const; type ChainName = keyof typeof chainMap; export const chains = Object.keys(chainMap) as ChainName[]; export const chainList = (mainnet: boolean) => { if (mainnet == true) { return ["ethereum", "base", "arbitrum", "megaeth", "katana", "polygon", "bsc"] as ChainName[]; - } else return ["sepolia", "optimismSepolia", "baseSepolia", "arbitrumSepolia"] as ChainName[]; + } else + return [ + "sepolia", + "optimismSepolia", + "baseSepolia", + "arbitrumSepolia", + "arcTestnet" + ] as ChainName[]; }; export const chainIdList = (mainnet: boolean) => { @@ -281,6 +291,12 @@ export const coinList = (mainnet: boolean) => { name: "weth", chainId: arbitrumSepolia.id, decimals: 18 + }, + { + address: `0x3600000000000000000000000000000000000000`, + name: "usdc", + chainId: arcTestnet.id, + decimals: 6 } ] as const; }; @@ -323,7 +339,8 @@ export const polymerChainIds = { megaeth: megaeth.id, katana: katana.id, bsc: bsc.id, - polygon: polygon.id + polygon: polygon.id, + arcTestnet: arcTestnet.id } as const; export type Verifier = "wormhole" | "polymer"; @@ -490,6 +507,10 @@ export const clients = { http("https://optimism-sepolia-rpc.publicnode.com"), ...optimismSepolia.rpcUrls.default.http.map((v) => http(v)) ]) + }), + arcTestnet: createPublicClient({ + chain: arcTestnet, + transport: fallback([...arcTestnet.rpcUrls.default.http.map((v) => http(v))]) }) } as const; diff --git a/src/lib/libraries/intentFactory.ts b/src/lib/libraries/intentFactory.ts index 5e9ccf2..2e7f194 100644 --- a/src/lib/libraries/intentFactory.ts +++ b/src/lib/libraries/intentFactory.ts @@ -111,14 +111,15 @@ export class IntentFactory { constructor(options: { mainnet: boolean; + useProductionApi?: boolean | null; walletClient: WC; preHook?: (chainId: number) => Promise; postHook?: () => Promise; ordersPointer?: OrderContainer[]; }) { - const { mainnet, walletClient, preHook, postHook, ordersPointer } = options; + const { mainnet, useProductionApi, walletClient, preHook, postHook, ordersPointer } = options; this.mainnet = mainnet; - this.intentApi = new IntentApi(mainnet); + this.intentApi = new IntentApi(useProductionApi ?? mainnet); this.walletClient = walletClient; this.preHook = preHook; diff --git a/src/lib/screens/IssueIntent.svelte b/src/lib/screens/IssueIntent.svelte index 105c6a1..96f0914 100644 --- a/src/lib/screens/IssueIntent.svelte +++ b/src/lib/screens/IssueIntent.svelte @@ -67,6 +67,7 @@ const intentFactory = $derived( new IntentFactory({ mainnet: store.mainnet, + useProductionApi: store.useProductionApi, walletClient: store.walletClient, preHook, postHook: postHookScroll, @@ -222,6 +223,7 @@ bind:exclusiveFor={store.exclusiveFor} useExclusiveForQuoteRequest={store.useExclusiveForQuoteRequest} mainnet={store.mainnet} + useProductionApi={store.useProductionApi} inputTokens={store.inputTokens} bind:outputTokens={store.outputTokens} {account} diff --git a/src/lib/screens/ManageDeposit.svelte b/src/lib/screens/ManageDeposit.svelte index 1e59847..d639ab4 100644 --- a/src/lib/screens/ManageDeposit.svelte +++ b/src/lib/screens/ManageDeposit.svelte @@ -69,18 +69,38 @@ >
-
-

Network

- (store.mainnet = v === "mainnet")} - /> +
+
+

Network

+ (store.mainnet = v === "mainnet")} + /> +
+
+

Intent API

+ (store.useProductionApi = v === "auto" ? null : v === "production")} + /> +
diff --git a/src/lib/state.svelte.ts b/src/lib/state.svelte.ts index fa84279..e6ce9ba 100644 --- a/src/lib/state.svelte.ts +++ b/src/lib/state.svelte.ts @@ -46,6 +46,7 @@ function generateUUID(): string { class Store { mainnet = $state(true); + useProductionApi = $state(null); orders = $state([]); async loadOrdersFromDb() { diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 3b6bdc1..ac2492e 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -36,7 +36,7 @@ }); }); - const intentApi = $derived(new IntentApi(store.mainnet)); + const intentApi = $derived(new IntentApi(store.useProductionApi ?? store.mainnet)); let disconnectWs: (() => void) | undefined;