Skip to content

Commit

Permalink
add base-sepolia/sepolia support to the erc20 transfer code
Browse files Browse the repository at this point in the history
  • Loading branch information
mmv08 committed May 22, 2024
1 parent f278fd7 commit d1d1835
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
12 changes: 9 additions & 3 deletions examples/4337-gas-metering/pimlico/pimlico.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ const sponsoredUserOperation: UserOperation = {
callGasLimit: 0n, // All Gas Values will be filled by Estimation Response Data.
verificationGasLimit: 0n,
preVerificationGas: 0n,
maxFeePerGas: 0n,
maxPriorityFeePerGas: 0n,
maxFeePerGas: 1n,
maxPriorityFeePerGas: 1n,
paymaster: erc20PaymasterAddress,
paymasterVerificationGasLimit: 0n,
paymasterPostOpGasLimit: 0n,
Expand Down Expand Up @@ -253,7 +253,13 @@ if (usePaymaster) {
}

// Sign the User Operation.
sponsoredUserOperation.signature = await signUserOperation(sponsoredUserOperation, signer, chainID, ENTRYPOINT_ADDRESS_V07, chainAddresses.SAFE_4337_MODULE_ADDRESS)
sponsoredUserOperation.signature = await signUserOperation(
sponsoredUserOperation,
signer,
chainID,
ENTRYPOINT_ADDRESS_V07,
chainAddresses.SAFE_4337_MODULE_ADDRESS,
)

// Submit the User Operation.
await submitUserOperationPimlico(sponsoredUserOperation, bundlerClient, ENTRYPOINT_ADDRESS_V07, chain)
20 changes: 7 additions & 13 deletions examples/4337-gas-metering/utils/erc20.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dotenv from 'dotenv'
import { HttpTransport, http, Address, encodeFunctionData, createWalletClient, PrivateKeyAccount, PublicClient } from 'viem'
import { baseSepolia, goerli, polygonMumbai, sepolia } from 'viem/chains'
import { baseSepolia, goerli, sepolia } from 'viem/chains'
import {
ERC20_TOKEN_APPROVE_ABI,
ERC20_TOKEN_BALANCE_OF_ABI,
Expand Down Expand Up @@ -71,16 +71,10 @@ export const mintERC20Token = async (
) => {
let walletClient
if (paymaster == 'pimlico') {
if (chain == 'goerli') {
walletClient = createWalletClient({
account: signer,
chain: goerli,
transport: http(pimlicoRPCURL),
})
} else if (chain == 'mumbai') {
if (chain == 'sepolia') {
walletClient = createWalletClient({
account: signer,
chain: polygonMumbai,
chain: sepolia,
transport: http(pimlicoRPCURL),
})
} else if (chain == 'base-sepolia') {
Expand Down Expand Up @@ -148,16 +142,16 @@ export const transferERC20Token = async (
) => {
let walletClient
if (paymaster == 'pimlico') {
if (chain == 'goerli') {
if (chain == 'sepolia') {
walletClient = createWalletClient({
account: signer,
chain: goerli,
chain: sepolia,
transport: http(pimlicoRPCURL),
})
} else if (chain == 'mumbai') {
} else if (chain == 'base-sepolia') {
walletClient = createWalletClient({
account: signer,
chain: polygonMumbai,
chain: baseSepolia,
transport: http(pimlicoRPCURL),
})
} else {
Expand Down
8 changes: 4 additions & 4 deletions examples/4337-gas-metering/utils/safe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const getGelatoCallData = async ({
}: {
safe: Address
owner: PrivateKeyAccount
publicClient: PublicClient<Transport<"http">, typeof sepolia | typeof baseSepolia>
publicClient: PublicClient<Transport<'http'>, typeof sepolia | typeof baseSepolia>
txType: string
erc20TokenAddress: Address
erc721TokenAddress: Address
Expand Down Expand Up @@ -188,7 +188,7 @@ const getGelatoInitializerCode = async ({
erc721TokenAddress,
}: {
owner: Address
client: PublicClient<Transport<"http">, typeof sepolia | typeof baseSepolia>
client: PublicClient<Transport<'http'>, typeof sepolia | typeof baseSepolia>
txType: string
safeModuleSetupAddress: Address
safe4337ModuleAddress: Address
Expand Down Expand Up @@ -253,7 +253,7 @@ export const prepareForGelatoTx = async ({
}: {
signer: PrivateKeyAccount
chain: string
publicClient: PublicClient<Transport<"http">, typeof sepolia | typeof baseSepolia>
publicClient: PublicClient<Transport<'http'>, typeof sepolia | typeof baseSepolia>
txType: string
senderAddress: Address
erc20TokenAddress: Address
Expand Down Expand Up @@ -355,7 +355,7 @@ export const getGelatoAccountInitCode = async ({
erc721TokenAddress,
}: {
owner: Address
client: PublicClient<Transport<"http">, typeof sepolia | typeof baseSepolia>
client: PublicClient<Transport<'http'>, typeof sepolia | typeof baseSepolia>
txType: string
safeModuleSetupAddress: Address
safe4337ModuleAddress: Address
Expand Down

0 comments on commit d1d1835

Please sign in to comment.