Skip to content

Commit

Permalink
feat: Support Arb Mainnet for Demo App (#18)
Browse files Browse the repository at this point in the history
* feat: integrate sdk + nft contract for onboarding

* feat: fix signing, add local storage wrapper, and fix up smaller ui issues

* tmp
  • Loading branch information
rthomare authored Jun 7, 2023
1 parent a67970a commit 6df907c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 7 deletions.
11 changes: 9 additions & 2 deletions examples/alchemy-daapp/src/configs/clientConfigs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Chain, polygon, polygonMumbai, sepolia } from "viem/chains";
import { Chain, polygon, polygonMumbai, sepolia, arbitrum } from "viem/chains";

export interface DAAppConfiguration {
nftContractAddress: `0x${string}`;
Expand All @@ -13,7 +13,7 @@ export const daappConfigurations: Record<number, DAAppConfiguration> = {
[polygon.id]: {
nftContractAddress: "0xb7b9424ef3d1b9086b7e53276c4aad68a1dd971c",
simpleAccountFactoryAddress: "0x15Ba39375ee2Ab563E8873C8390be6f2E2F50232",
gasManagerPolicyId: "f0f6fb99-28b0-4e9e-a40d-201ceb1f2b3b",
gasManagerPolicyId: "b888d426-485d-4a0e-be81-7c94ced3d4b1",
rpcUrl: `/api/rpc/proxy?chainId=${polygon.id}`,
chain: polygon,
},
Expand All @@ -31,4 +31,11 @@ export const daappConfigurations: Record<number, DAAppConfiguration> = {
rpcUrl: `/api/rpc/proxy?chainId=${sepolia.id}`,
chain: sepolia,
},
[arbitrum.id]: {
nftContractAddress: "0xb7b9424ef3d1b9086b7e53276c4aad68a1dd971c",
simpleAccountFactoryAddress: "0x15Ba39375ee2Ab563E8873C8390be6f2E2F50232",
gasManagerPolicyId: "04a10add-f2d6-4f53-93ef-50feec3d7309",
rpcUrl: `/api/rpc/proxy?chainId=${arbitrum.id}`,
chain: arbitrum,
},
};
3 changes: 2 additions & 1 deletion examples/alchemy-daapp/src/configs/serverConfigs.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { polygon, polygonMumbai, sepolia } from "viem/chains";
import { arbitrum, polygon, polygonMumbai, sepolia } from "viem/chains";
import { env } from "~/env.mjs";

// TODO: Replace with your own api urls per chain.
const API_URLs: Record<number, string> = {
[polygonMumbai.id]: env.MUMBAI_ALCHEMY_API_URL,
[sepolia.id]: env.SEPOLIA_ALCHEMY_API_URL,
[polygon.id]: env.POLYGON_ALCHEMY_API_URL,
[arbitrum.id]: env.ARB_ALCHEMY_API_URL,
};

export function getApiUrl(chainId: number | string) {
Expand Down
2 changes: 2 additions & 0 deletions examples/alchemy-daapp/src/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const env = createEnv({
MUMBAI_ALCHEMY_API_URL: z.string().url(),
SEPOLIA_ALCHEMY_API_URL: z.string().url(),
POLYGON_ALCHEMY_API_URL: z.string().url(),
ARB_ALCHEMY_API_URL: z.string().url(),
},

/**
Expand All @@ -27,6 +28,7 @@ export const env = createEnv({
runtimeEnv: {
NODE_ENV: process.env.NODE_ENV,
POLYGON_ALCHEMY_API_URL: process.env.POLYGON_ALCHEMY_API_URL,
ARB_ALCHEMY_API_URL: process.env.ARB_ALCHEMY_API_URL,
MUMBAI_ALCHEMY_API_URL: process.env.MUMBAI_ALCHEMY_API_URL,
SEPOLIA_ALCHEMY_API_URL: process.env.SEPOLIA_ALCHEMY_API_URL,
},
Expand Down
6 changes: 6 additions & 0 deletions examples/contracts/DAAppNFT/migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ Transaction hash: 0x59b65a2bd7a730efbea86376c986efcc2cd65c076f39a47cea84a6d4246c
Deployer: 0x15a411507e901f26965f0ebcd3155834b058a6b2
Deployed to: 0xb7b9424ef3d1b9086b7e53276c4aad68a1dd971c
Transaction hash: 0xdc73899cf183cf852605c7a7473c0b110554155d5f4cc03452c11a4ce0d4ff33

# Arbitrum Mainnet

Deployer: 0x15a411507e901f26965f0ebcd3155834b058a6b2
Deployed to: 0xb7b9424ef3d1b9086b7e53276c4aad68a1dd971c
Transaction hash: 0x4ca9a016935f5634d009e4580ea0dc9c4b3edf0d8
18 changes: 14 additions & 4 deletions packages/core/src/middleware/alchemy-paymaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,20 @@ export const alchemyPaymasterAndDataMiddleware = (
config: AlchemyPaymasterConfig
): Parameters<ISmartAccountProvider["withPaymasterMiddleware"]>["0"] => ({
dummyPaymasterDataMiddleware: async (_struct: UserOperationStruct) => {
return {
paymasterAndData:
"0xc03aac639bb21233e0139381970328db8bceeb67fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c",
};
switch (config.provider.chain.id) {
case 1:
case 137:
case 42161:
return {
paymasterAndData:
"0x4Fd9098af9ddcB41DA48A1d78F91F1398965addcfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c",
};
default:
return {
paymasterAndData:
"0xc03aac639bb21233e0139381970328db8bceeb67fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c",
};
}
},
paymasterDataMiddleware: async (struct: UserOperationStruct) => {
const { paymasterAndData } = await (
Expand Down

0 comments on commit 6df907c

Please sign in to comment.