Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gelato using execTransaction for gas metering #326

Merged
merged 17 commits into from
Mar 19, 2024
Merged
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
16 changes: 8 additions & 8 deletions examples/4337-gas-metering/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,16 @@ ALCHEMY_ERC20_TOKEN_CONTRACT = "0x255de08fb52fde17a3aab145de8e2ffb7fd0310f"
ALCHEMY_ERC721_TOKEN_CONTRACT = "0x16bc5fba06f3f5875e915c0ba6963377eb6651e1"

# Gelato Values
GELATO_CHAIN = "sepolia"
GELATO_CHAIN_ID = "11155111"
GELATO_RPC_URL = "https://rpc.ankr.com/eth_sepolia"
GELATO_API_KEY = "" # Sponsor API Key
GELATO_GAS_POLICY = ""
GELATO_ENTRYPOINT_ADDRESS = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
GELATO_CHAIN = "base-sepolia" # "base-sepolia" or "sepolia"
GELATO_CHAIN_ID = "84532" # "84532" or "11155111"
GELATO_RPC_URL = "https://rpc.ankr.com/base_sepolia" # "https://rpc.ankr.com/base_sepolia" or "https://rpc.ankr.com/eth_sepolia"
GELATO_API_KEY = "" # Sponsor API Key: https://app.gelato.network/relay?networkGroup=testnets
GELATO_MULTISEND_ADDRESS = "0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526" # https://github.com/safe-global/safe-deployments/blob/main/src/assets/v1.4.1/multi_send.json
# Make sure all nonce are unique for it to deploy account when run initially.
GELATO_NONCE = "3"
# Gelato Token Operation Values (Based on the chain selected, these values should also change accordingly.)
GELATO_ERC20_TOKEN_CONTRACT = "0x255de08fb52fde17a3aab145de8e2ffb7fd0310f"
GELATO_ERC721_TOKEN_CONTRACT = "0x16bc5fba06f3f5875e915c0ba6963377eb6651e1"
GELATO_ERC20_TOKEN_CONTRACT = "0x0b3ff6382bd1a8a74f23d39b4d131a08cea2502a"
GELATO_ERC721_TOKEN_CONTRACT = "0xf13eca34092D27cbF91cD377eFB261704C687a05"

# Safe Values
SAFE_VERSION = "1.4.1"
Expand All @@ -55,3 +53,5 @@ SAFE_VERSION = "1.4.1"
# ERC721 Token Sepolia: https://sepolia.etherscan.io/token/0x16bc5fba06f3f5875e915c0ba6963377eb6651e1
# ERC20 Token Mumbai: https://mumbai.polygonscan.com/address/0x255de08fb52fde17a3aab145de8e2ffb7fd0310f
# ERC721 Token Mumbai: https://mumbai.polygonscan.com/address/0x16bc5fba06f3f5875e915c0ba6963377eb6651e1
# ERC20 Token Base Sepolia: https://sepolia.basescan.org/address/0x0b3ff6382bd1a8a74f23d39b4d131a08cea2502a
# ERC721 Token Base Sepolia: https://sepolia.basescan.org/address/0xf13eca34092D27cbF91cD377eFB261704C687a05
28 changes: 8 additions & 20 deletions examples/4337-gas-metering/README.md

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions examples/4337-gas-metering/alchemy/alchemy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import { PublicClient, Hash, Transport, createPublicClient, formatEther, http, parseEther, zeroAddress } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { goerli, sepolia } from 'viem/chains'
import { SAFE_ADDRESSES_MAP, getAccountAddress, getAccountInitCode } from '../utils/safe'
import { getAccountAddress, getAccountInitCode } from '../utils/safe'
import { SAFE_ADDRESSES_MAP } from '../utils/address'
import {
UserOperation,
signUserOperation,
Expand Down Expand Up @@ -58,7 +59,7 @@
throw new Error('TX Type Argument Invalid')
}

const safeAddresses = (SAFE_ADDRESSES_MAP as Record<string, Record<string, any>>)[safeVersion]

Check warning on line 62 in examples/4337-gas-metering/alchemy/alchemy.ts

View workflow job for this annotation

GitHub Actions / checks

Unexpected any. Specify a different type
let chainAddresses
if (safeAddresses) {
chainAddresses = safeAddresses[chainID]
Expand Down Expand Up @@ -115,7 +116,7 @@
console.log('\nInit Code Created.')

const senderAddress = await getAccountAddress({
client: publicClient,
publicClient: publicClient,
owner: signer.address,
addModuleLibAddress: chainAddresses.ADD_MODULES_LIB_ADDRESS,
safe4337ModuleAddress: chainAddresses.SAFE_4337_MODULE_ADDRESS,
Expand Down
Loading
Loading