Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/lib/components/GetQuote.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@
inputTokens,
outputTokens = $bindable(),
account,
mainnet
mainnet,
useProductionApi
}: {
exclusiveFor: string;
useExclusiveForQuoteRequest?: boolean;
inputTokens: AppTokenContext[];
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 {
Expand Down
37 changes: 29 additions & 8 deletions src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
bsc,
katana,
megaeth,
optimism
optimism,
arcTestnet
} from "viem/chains";

export const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000" as const;
Expand Down Expand Up @@ -41,10 +42,11 @@ export const POLYMER_ORACLE: Partial<Record<number, `0x${string}`>> = {
[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;
Expand All @@ -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) => {
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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;

Expand Down
5 changes: 3 additions & 2 deletions src/lib/libraries/intentFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,15 @@ export class IntentFactory {

constructor(options: {
mainnet: boolean;
useProductionApi?: boolean | null;
walletClient: WC;
preHook?: (chainId: number) => Promise<any>;
postHook?: () => Promise<any>;
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;
Expand Down
2 changes: 2 additions & 0 deletions src/lib/screens/IssueIntent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
const intentFactory = $derived(
new IntentFactory({
mainnet: store.mainnet,
useProductionApi: store.useProductionApi,
walletClient: store.walletClient,
preHook,
postHook: postHookScroll,
Expand Down Expand Up @@ -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}
Expand Down
44 changes: 32 additions & 12 deletions src/lib/screens/ManageDeposit.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,38 @@
>
<div class="space-y-2">
<SectionCard compact>
<div class="flex items-center justify-between gap-2">
<h2 class="text-sm font-medium text-gray-700">Network</h2>
<SegmentedControl
testIdPrefix="network"
size="sm"
options={[
{ label: "Testnet", value: "testnet" },
{ label: "Mainnet", value: "mainnet" }
]}
value={store.mainnet ? "mainnet" : "testnet"}
onChange={(v) => (store.mainnet = v === "mainnet")}
/>
<div class="flex flex-col gap-2">
<div class="flex items-center justify-between gap-2">
<h2 class="text-sm font-medium text-gray-700">Network</h2>
<SegmentedControl
testIdPrefix="network"
size="sm"
options={[
{ label: "Testnet", value: "testnet" },
{ label: "Mainnet", value: "mainnet" }
]}
value={store.mainnet ? "mainnet" : "testnet"}
onChange={(v) => (store.mainnet = v === "mainnet")}
/>
</div>
<div class="flex items-center justify-between gap-2">
<h2 class="text-sm font-medium text-gray-700">Intent API</h2>
<SegmentedControl
testIdPrefix="api-env"
size="sm"
options={[
{ label: "Default", value: "auto" },
{ label: "Staging", value: "staging" },
{ label: "Production", value: "production" }
]}
value={store.useProductionApi === null
? "auto"
: store.useProductionApi
? "production"
: "staging"}
onChange={(v) => (store.useProductionApi = v === "auto" ? null : v === "production")}
/>
</div>
</div>
</SectionCard>
<SectionCard compact>
Expand Down
1 change: 1 addition & 0 deletions src/lib/state.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function generateUUID(): string {

class Store {
mainnet = $state<boolean>(true);
useProductionApi = $state<boolean | null>(null);
orders = $state<OrderContainer[]>([]);

async loadOrdersFromDb() {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
});
});

const intentApi = $derived(new IntentApi(store.mainnet));
const intentApi = $derived(new IntentApi(store.useProductionApi ?? store.mainnet));

let disconnectWs: (() => void) | undefined;

Expand Down
Loading