diff --git a/.changeset/chubby-flowers-learn.md b/.changeset/chubby-flowers-learn.md new file mode 100644 index 0000000000..ef5c441dd7 --- /dev/null +++ b/.changeset/chubby-flowers-learn.md @@ -0,0 +1,5 @@ +--- +"@exactly/mobile": patch +--- + +🐛 route owner rpc through alchemy diff --git a/src/utils/alchemyChains.ts b/src/utils/alchemyChains.ts new file mode 100644 index 0000000000..ff65072674 --- /dev/null +++ b/src/utils/alchemyChains.ts @@ -0,0 +1,9 @@ +import * as accountKitInfra from "@account-kit/infra"; + +import type { Chain } from "viem"; + +export default new Map( + Object.values(accountKitInfra) + .filter((c): c is Chain => typeof c === "object" && "id" in c && typeof c.id === "number") + .map((c) => [c.id, c]), +); diff --git a/src/utils/wagmi/owner.ts b/src/utils/wagmi/owner.ts index ccc13f1a79..ba1d16d2d3 100644 --- a/src/utils/wagmi/owner.ts +++ b/src/utils/wagmi/owner.ts @@ -6,15 +6,22 @@ import { http } from "viem"; import * as chains from "viem/chains"; import { createConfig, createStorage, custom, injected } from "wagmi"; +import alchemyAPIKey from "@exactly/common/alchemyAPIKey"; import chain from "@exactly/common/generated/chain"; +import alchemyChainById from "../alchemyChains"; import publicClient from "../publicClient"; const config = createConfig({ chains: [chain, ...Object.values(chains)], connectors: [miniAppConnector(), injected()], transports: { - ...Object.fromEntries(Object.values(chains).map((c) => [c.id, http()])), + ...Object.fromEntries( + Object.values(chains).map((c) => [ + c.id, + http(alchemyChainById.get(c.id)?.rpcUrls.alchemy?.http[0]?.concat(`/${alchemyAPIKey}`)), + ]), + ), [chain.id]: custom(publicClient), }, storage: createStorage({ key: "wagmi.owner", storage: AsyncStorage }),