Skip to content

Commit 7b68045

Browse files
committed
🐛 app: route cross-chain rpc through alchemy
1 parent 003024c commit 7b68045

4 files changed

Lines changed: 25 additions & 3 deletions

File tree

.changeset/calm-foxes-route.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@exactly/mobile": patch
3+
---
4+
5+
🐛 route cross-chain rpc through alchemy

src/utils/deployedOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function deployedOptions(address: Address | undefined, chainId: n
1212
address !== undefined && chainId !== undefined
1313
? async () => !!(await getBytecode(exaConfig, { address, chainId }))
1414
: skipToken,
15-
staleTime: (query) => (query.state.data ? Infinity : 0),
15+
staleTime: (query) => (query.state.data === undefined ? 0 : Infinity),
1616
gcTime: Infinity,
1717
});
1818
}

src/utils/wagmi/exa.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import AsyncStorage from "@react-native-async-storage/async-storage";
33
import * as chains from "viem/chains";
44
import { createConfig, createStorage, custom, http } from "wagmi";
55

6+
import alchemyAPIKey from "@exactly/common/alchemyAPIKey";
67
import chain from "@exactly/common/generated/chain";
78

9+
import alchemyChainById from "../alchemyChains";
810
import alchemyConnector from "../alchemyConnector";
911
import publicClient from "../publicClient";
1012

@@ -13,7 +15,15 @@ const others = Object.values(chains).filter((c) => c.id !== chain.id);
1315
export default createConfig({
1416
chains: [chain, ...others],
1517
connectors: [alchemyConnector],
16-
transports: { ...Object.fromEntries(others.map((c) => [c.id, http()])), [chain.id]: custom(publicClient) },
18+
transports: {
19+
...Object.fromEntries(
20+
others.map((c) => [
21+
c.id,
22+
http(alchemyChainById.get(c.id)?.rpcUrls.alchemy?.http[0]?.concat(`/${alchemyAPIKey}`)),
23+
]),
24+
),
25+
[chain.id]: custom(publicClient),
26+
},
1727
storage: createStorage({ key: `wagmi.exa.${chain.id}`, storage: AsyncStorage }),
1828
multiInjectedProviderDiscovery: false,
1929
});

src/utils/wagmi/owner.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@ import { http } from "viem";
66
import * as chains from "viem/chains";
77
import { createConfig, createStorage, custom, injected } from "wagmi";
88

9+
import alchemyAPIKey from "@exactly/common/alchemyAPIKey";
910
import chain from "@exactly/common/generated/chain";
1011

12+
import alchemyChainById from "../alchemyChains";
1113
import publicClient from "../publicClient";
1214

1315
const config = createConfig({
1416
chains: [chain, ...Object.values(chains)],
1517
connectors: [miniAppConnector(), injected()],
1618
transports: {
17-
...Object.fromEntries(Object.values(chains).map((c) => [c.id, http()])),
19+
...Object.fromEntries(
20+
Object.values(chains).map((c) => [
21+
c.id,
22+
http(alchemyChainById.get(c.id)?.rpcUrls.alchemy?.http[0]?.concat(`/${alchemyAPIKey}`)),
23+
]),
24+
),
1825
[chain.id]: custom(publicClient),
1926
},
2027
storage: createStorage({ key: `wagmi.owner.${chain.id}`, storage: AsyncStorage }),

0 commit comments

Comments
 (0)