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

feat: viem migration #34

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open

feat: viem migration #34

wants to merge 27 commits into from

Conversation

kanthgithub
Copy link
Contributor

@kanthgithub kanthgithub commented Aug 19, 2024

Migrate etherspot-modular-sdk from ethers to viem

Description

  • viem dependency added to package.json
  • ModularSDK, EtherSpotWalletAPI and dependant typescript classes are refactored to
    • use viem account, PublicClient, WalletClient
    • remove references and injection of privateKey to SDK initialisation
    • create custom types for BigNumber, UserOpsStructs
    • remove typechain references of the etherspot-module-contracts
    • add ABI constants for all functions of modular-contracts being used in SDK

Manual Testing

Test Strategy:
Key functions of the Modular Smartcontracts:

  1. getCounterFactualAddress
  2. install module
  3. list modules
  4. uninstall modules
  5. native and erc20 transfer via UserOps to a recipient
  6. Smart Wallet creation for a new EOA account

Example scripts in the directory: are used to test above set of scenarios
The SDK function path will cove most of the migrated set of functions while testing above list of scenarios

Test Networks

Scenarios are tested on Sepolia and Amoy

Test Proofs

Transfer ERC20 tokens

  1. Transfer ERC20 tokens via SessionKey on master (ethers library version)
➜  etherspot-modular-sdk git:(master) npx ts-node examples/03-transfer-erc20-session-key.ts
sessionKey SDK initialized
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
transactions:  {
  to: [ '0x76da12a46190528ce9780eb169fc90c18a8c2a77' ],
  data: [
    '0xa9059cbb000000000000000000000000de79f0ef8a1268dad0df02a8e527819a3cd99d400000000000000000000000000000000000000000000000000de0b6b3a7640000'
  ],
  value: [ BigNumber { _hex: '0x00', _isBigNumber: true } ]
}
erc20SessionKeyValidator 0x22A55192a663591586241D42E603221eac49ed09 as BigNumber is: 197792415163321831208326099012399626805989469449
Nonce: 15670729612648503866102855607894354141231806096137367614290888274976245284908
Estimate UserOp: {
  "sender": "0x073e3E3B8dD87ccF711688185F49713e5CCC1174",
  "nonce": "0x22a55192a663591586241d42e603221eac49ed0900000000000000000000002c",
  "factoryData": "0x",
  "callData": "0xe9ae5c5301000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000076da12a46190528ce9780eb169fc90c18a8c2a77000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000de79f0ef8a1268dad0df02a8e527819a3cd99d400000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000",
  "callGasLimit": "0x1b9de",
  "verificationGasLimit": "0xda47",
  "maxFeePerGas": "0x737be7600",
  "maxPriorityFeePerGas": "0x737be7600",
  "paymasterData": "0x",
  "preVerificationGas": "0xa474",
  "signature": "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"
}
sessionKey: 0xd3F27A6e279f1AFF7780B907c496FBB5bA81f179
etherspot-modular-sdk -> Signed UserOp: 0xfa2e9f0b45b14c729c6dbb7e3020c01d99ebef89f05ced2f9e7f846381dc7c581a71339ae028c5a7bafb284880de0cdc12ef5d37719a5a34dc95e459aef5aca51c
Signed UserOp: {
  "sender": "0x073e3E3B8dD87ccF711688185F49713e5CCC1174",
  "nonce": "0x22a55192a663591586241d42e603221eac49ed0900000000000000000000002c",
  "factoryData": "0x",
  "callData": "0xe9ae5c5301000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000076da12a46190528ce9780eb169fc90c18a8c2a77000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000de79f0ef8a1268dad0df02a8e527819a3cd99d400000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000",
  "callGasLimit": "0x1b9de",
  "verificationGasLimit": "0xda47",
  "preVerificationGas": "0xa474",
  "maxFeePerGas": "0x737be7600",
  "maxPriorityFeePerGas": "0x737be7600",
  "paymasterData": "0x",
  "signature": "0xfa2e9f0b45b14c729c6dbb7e3020c01d99ebef89f05ced2f9e7f846381dc7c581a71339ae028c5a7bafb284880de0cdc12ef5d37719a5a34dc95e459aef5aca51c"
}
UserOpNonce is: 15670729612648503866102855607894354141231806096137367614290888274976245284908
UserOpHash from Signed UserOp: 0x041ba2f0ae83f64175356e1180ecb3f3373821f4baaff3098bbe101bb691f23c
UserOpHash: 0x041ba2f0ae83f64175356e1180ecb3f3373821f4baaff3098bbe101bb691f23c
Waiting for transaction...
Transaction Receipt:  null
  1. Transfer ERC20 tokens via SessionKey on current branch in PR (viem library version)
➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ nvm use v18.17.1 
Now using node v18.17.1 (npm v9.6.7)
➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/sessionkeys/transfer-erc20-session-key.ts
sessionKey SDK initialized
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
transactions:  {
  to: [ '0x76da12a46190528ce9780eb169fc90c18a8c2a77' ],
  data: [
    '0xa9059cbb000000000000000000000000de79f0ef8a1268dad0df02a8e527819a3cd99d40000000000000000000000000000000000000000000000000000000e8d4a51000'
  ],
  value: [ BigNumber { _hex: '0x00', _isBigNumber: true } ]
}
erc20SessionKeyValidator 0x22A55192a663591586241D42E603221eac49ed09 as BigNumber is: 197792415163321831208326099012399626805989469449
nonceKey: 0x22A55192a663591586241D42E603221eac49ed09
isAddressIndicator: true
Nonce: 15670729612648503866102855607894354141231806096137367614290888274976245284907
Estimate UserOp: {
  "sender": "0x073e3E3B8dD87ccF711688185F49713e5CCC1174",
  "nonce": "0x22a55192a663591586241d42e603221eac49ed0900000000000000000000002b",
  "factoryData": "0x",
  "callData": "0xe9ae5c5301000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000076da12a46190528ce9780eb169fc90c18a8c2a77000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000de79f0ef8a1268dad0df02a8e527819a3cd99d40000000000000000000000000000000000000000000000000000000e8d4a5100000000000000000000000000000000000000000000000000000000000",
  "callGasLimit": "0x",
  "verificationGasLimit": "0x",
  "maxFeePerGas": "0xc005e376f",
  "maxPriorityFeePerGas": "0xc005e376f",
  "paymasterData": "0x",
  "preVerificationGas": "0x",
  "signature": "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"
}
sessionKey: 0xe38A2E53d15008b5f9920c31658bA440EF1f09a1
etherspot-modular-sdk -> Signed UserOp: 0xc7b80c2b3e0f6d262bf16ce74e3e3ff4bbba381b6e7fe7831a1eaa2d3a3e58d95945ce04c20920e2098da01ada6e27c7941ff7018ad52f80287fc476babbe34c1c
Signed UserOp: {
  "sender": "0x073e3E3B8dD87ccF711688185F49713e5CCC1174",
  "nonce": "0x22a55192a663591586241d42e603221eac49ed0900000000000000000000002b",
  "factoryData": "0x",
  "callData": "0xe9ae5c5301000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000076da12a46190528ce9780eb169fc90c18a8c2a77000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000de79f0ef8a1268dad0df02a8e527819a3cd99d40000000000000000000000000000000000000000000000000000000e8d4a5100000000000000000000000000000000000000000000000000000000000",
  "callGasLimit": "0x1b9bf",
  "verificationGasLimit": "0xda47",
  "preVerificationGas": "0xa474",
  "maxFeePerGas": "0xc005e376f",
  "maxPriorityFeePerGas": "0xc005e376f",
  "paymasterData": "0x",
  "signature": "0xc7b80c2b3e0f6d262bf16ce74e3e3ff4bbba381b6e7fe7831a1eaa2d3a3e58d95945ce04c20920e2098da01ada6e27c7941ff7018ad52f80287fc476babbe34c1c"
}
UserOpNonce is: 15670729612648503866102855607894354141231806096137367614290888274976245284907
UserOpHash from Signed UserOp: 0xa6a45d1015cf96cd78b50b49963f02acb88af33a889312a318e93b7f0257a44a
UserOpHash: 0xa6a45d1015cf96cd78b50b49963f02acb88af33a889312a318e93b7f0257a44a
Waiting for transaction...
Transaction Receipt:  null

get Counterfactual Address

➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/basics/get-counterfactual-address.ts
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174

get Gas Fees

➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/basics/get-gas-fees.ts
gasFees is: {"maxFeePerGas":"0x9502f9000","maxPriorityFeePerGas":"0x9502f9000"}

get Nonce

➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/basics/get-nonce.ts
nonceKey: 0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143
isAddressIndicator: true
nonce is: 63444984684045084841432712757840239866553663653566892880549259113021522837556

Transfer ERC20

➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/basics/transfer-erc20.ts
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
transactions:  {
  to: [ '0x76da12a46190528ce9780eb169fc90c18a8c2a77' ],
  data: [
    '0xa9059cbb00000000000000000000000080a1874e1046b1cc5defdf4d3153838b72ff94ac000000000000000000000000000000000000000000000000016345785d8a0000'
  ],
  value: [ BigNumber { _hex: '0x00', _isBigNumber: true } ]
}
nonceKey: 0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143
isAddressIndicator: true
Estimate UserOp: {
  "sender": "0x073e3E3B8dD87ccF711688185F49713e5CCC1174",
  "nonce": "0x8c4496ba340afe5ac4148cfea9ccbbcd54093143000000000000000000000034",
  "factoryData": "0x",
  "callData": "0xe9ae5c5301000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000076da12a46190528ce9780eb169fc90c18a8c2a77000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb00000000000000000000000080a1874e1046b1cc5defdf4d3153838b72ff94ac000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000000000000",
  "callGasLimit": "0x",
  "verificationGasLimit": "0x",
  "maxFeePerGas": "0x9502f9000",
  "maxPriorityFeePerGas": "0x9502f9000",
  "paymasterData": "0x",
  "preVerificationGas": "0x",
  "signature": "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"
}
UserOpHash: 0x456bfb89e8e7ce9a17b3059b113ec27cd6fccf8c2a2429ac6ae86f3a113c18b4
Waiting for transaction...

Transfer Funds

➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/basics/transfer-funds.ts
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
transactions:  {
  to: [ '0x80a1874E1046B1cc5deFdf4D3153838B72fF94Ac' ],
  data: [ '0x' ],
  value: [ 100000000000n ]
}
balances:  0.404601784321734266
nonceKey: 0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143
isAddressIndicator: true
Estimate UserOp: {
  "sender": "0x073e3E3B8dD87ccF711688185F49713e5CCC1174",
  "nonce": "0x8c4496ba340afe5ac4148cfea9ccbbcd54093143000000000000000000000035",
  "factoryData": "0x",
  "callData": "0xe9ae5c530100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000080a1874e1046b1cc5defdf4d3153838b72ff94ac000000000000000000000000000000000000000000000000000000174876e80000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000",
  "callGasLimit": "0x",
  "verificationGasLimit": "0x",
  "maxFeePerGas": "0x9502f9000",
  "maxPriorityFeePerGas": "0x9502f9000",
  "paymasterData": "0x",
  "preVerificationGas": "0x",
  "signature": "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"
}
UserOpHash: 0xd7624dbfe7aa5b48eb4c790723a3236077c900e658a13f507ccfd72a3c62065b
Waiting for transaction...

List Modules

➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/modules/list-modules.ts
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
moduleInfo: {"validators":["0x22A55192a663591586241D42E603221eac49ed09","0xF4CDE8B11500ca9Ea108c5838DD26Ff1a4257a0c","0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143"],"executors":[],"hook":"0x0000000000000000000000000000000000000000","fallbacks":[]}

Uninstall Module

  • List of Modules printed in console before Uninstallation of 0xF4CDE8B11500ca9Ea108c5838DD26Ff1a4257a0c
  • module removed is 0xF4CDE8B11500ca9Ea108c5838DD26Ff1a4257a0c
  • List of Modules printed in console after Uninstallation of 0xF4CDE8B11500ca9Ea108c5838DD26Ff1a4257a0c
➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/modules/list-modules.ts    
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
moduleInfo: {"validators":["0xF4CDE8B11500ca9Ea108c5838DD26Ff1a4257a0c","0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143"],"executors":[],"hook":"0x0000000000000000000000000000000000000000","fallbacks":[]}

➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/modules/uninstall-module.ts
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
deinitData: 0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000
nonceKey: 0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143
isAddressIndicator: true
UserOpHash: 0x4b172c423af59cb5389832712b8dd56ceeee06a7b800bd3cef9bc38a65e0c873
Waiting for transaction...
^C%                                                                                                              
➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ 
➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/modules/list-modules.ts    
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
moduleInfo: {"validators":["0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143"],"executors":[],"hook":"0x0000000000000000000000000000000000000000","fallbacks":[]}

Install Module

  • List of Modules printed in console before installation of 0x22A55192a663591586241D42E603221eac49ed09
➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/modules/list-modules.ts
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
moduleInfo: {"validators":["0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143"],"executors":[],"hook":"0x0000000000000000000000000000000000000000","fallbacks":[]}
  • module installed is 0x22A55192a663591586241D42E603221eac49ed09
➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/modules/install-module.ts
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
nonceKey: 0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143
isAddressIndicator: true
UserOpHash: 0x381e0fe3bba6744413c57fb7daad1b8f57429eedf2c714345b96483aad411dc0
Waiting for transaction...
  • List of Modules printed in console after installation of 0x22A55192a663591586241D42E603221eac49ed09
➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/modules/list-modules.ts  
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
moduleInfo: {"validators":["0x22A55192a663591586241D42E603221eac49ed09","0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143"],"executors":[],"hook":"0x0000000000000000000000000000000000000000","fallbacks":[]}
  • module installed is 0xF4CDE8B11500ca9Ea108c5838DD26Ff1a4257a0c
➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/modules/install-module.ts
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
nonceKey: 0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143
isAddressIndicator: true
UserOpHash: 0x5455acf01f16de965c49b3bee3ba81bafa9c47f266545f093385e91ad41fc039
Waiting for transaction...
  • List of Modules printed in console after installation of 0xF4CDE8B11500ca9Ea108c5838DD26Ff1a4257a0c
➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/modules/list-modules.ts  
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
moduleInfo: {"validators":["0xF4CDE8B11500ca9Ea108c5838DD26Ff1a4257a0c","0x22A55192a663591586241D42E603221eac49ed09","0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143"],"executors":[],"hook":"0x0000000000000000000000000000000000000000","fallbacks":[]}

Enable SessionKey

  • Enable SessionKey on Installed ERC20SessionKeyValidator
➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/sessionkeys/enable-sessionkey-module.ts
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
nonceKey: 0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143
isAddressIndicator: true
UserOpHash:  0x05172b599c156137dd097749db846e81d545588dee01753858aee74203857fd3
SessionKey:  0xa2d5Fd2DE86221EEFB616325ff976EF85E7a64aB
Waiting for transaction...
Transaction Receipt:  null
AssociatedSessionKeys:  [ '0xa2d5Fd2DE86221EEFB616325ff976EF85E7a64aB' ]

Rotate SessionKey

  • Rotating the SessionKey created in previous step of enableSessionKey
➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/sessionkeys/rotate-sessionkey-module.ts
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
nonceKey: 0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143
isAddressIndicator: true
UserOpHash:  0xb983ff7e51cf07f249bc68cc37669a4e96a0bbb8dbdb3a4672adf6961599534c
SessionKey:  0x476595CD5ed26D40Fd299F266350e5E85A7DF0D3
Waiting for transaction...
Transaction Receipt:  null
AssociatedSessionKeys:  [ '0x476595CD5ed26D40Fd299F266350e5E85A7DF0D3' ]
  • List of associated Sessionkeys after rotation of existing sessionKey
➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/sessionkeys/get-associated-session-keys.ts
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
AssociatedSessionKeys:  [ '0x476595CD5ed26D40Fd299F266350e5E85A7DF0D3' ]

Disable SessionKey

➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/sessionkeys/disable-sessionkey-module.ts
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
nonceKey: 0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143
isAddressIndicator: true
UserOpHash:  0xf0e5c2a90b2de5d41e94d5da84798de99c9ac4998212aab986200fb1a670f45d
SessionKey:  0x476595CD5ed26D40Fd299F266350e5E85A7DF0D3
Waiting for transaction...
AssociatedSessionKeys:  [ ]

Enable new SessionKey & Token Transfer via new SessionKey

➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/sessionkeys/enable-sessionkey-module.ts
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
nonceKey: 0x8c4496Ba340aFe5ac4148cfEA9ccbBCD54093143
isAddressIndicator: true
UserOpHash:  0xf341a7f8e86c2e34fa8273ef7450e23faab08e57e3620f0b677b395e4ab9bc7a
SessionKey:  0xe9236220Bf79ff43Ae79fc8e1FbcB390C0C80e6F
Waiting for transaction...
Transaction Receipt:  null
AssociatedSessionKeys:  [ '0xe9236220Bf79ff43Ae79fc8e1FbcB390C0C80e6F' ]
➜  etherspot-modular-sdk git:(feature/viem-migration) ✗ tsx examples/sessionkeys/transfer-erc20-session-key.ts

sessionKey SDK initialized
EtherspotWallet address: 0x073e3E3B8dD87ccF711688185F49713e5CCC1174
transactions:  {
  to: [ '0x76da12a46190528ce9780eb169fc90c18a8c2a77' ],
  data: [
    '0xa9059cbb000000000000000000000000de79f0ef8a1268dad0df02a8e527819a3cd99d40000000000000000000000000000000000000000000000000000000e8d4a51000'
  ],
  value: [ BigNumber { _hex: '0x00', _isBigNumber: true } ]
}
erc20SessionKeyValidator 0x22A55192a663591586241D42E603221eac49ed09 as BigNumber is: 197792415163321831208326099012399626805989469449
nonceKey: 0x22A55192a663591586241D42E603221eac49ed09
isAddressIndicator: true
Nonce: 15670729612648503866102855607894354141231806096137367614290888274976245284909
Estimate UserOp: {
  "sender": "0x073e3E3B8dD87ccF711688185F49713e5CCC1174",
  "nonce": "0x22a55192a663591586241d42e603221eac49ed0900000000000000000000002d",
  "factoryData": "0x",
  "callData": "0xe9ae5c5301000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000076da12a46190528ce9780eb169fc90c18a8c2a77000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000de79f0ef8a1268dad0df02a8e527819a3cd99d40000000000000000000000000000000000000000000000000000000e8d4a5100000000000000000000000000000000000000000000000000000000000",
  "callGasLimit": "0x",
  "verificationGasLimit": "0x",
  "maxFeePerGas": "0xb91f1ec69",
  "maxPriorityFeePerGas": "0xb91f1ec69",
  "paymasterData": "0x",
  "preVerificationGas": "0x",
  "signature": "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"
}
sessionKey: 0xe9236220Bf79ff43Ae79fc8e1FbcB390C0C80e6F
etherspot-modular-sdk -> Signed UserOp: 0x82cb689ac8d52bdeb3435dbb3fbee3a16bc5ad4a30e7435badf1f2340d263eeb4589acaadf9ddf67ca8605a282aa01254812d0b016603511db3a9c061eb161661b
Signed UserOp: {
  "sender": "0x073e3E3B8dD87ccF711688185F49713e5CCC1174",
  "nonce": "0x22a55192a663591586241d42e603221eac49ed0900000000000000000000002d",
  "factoryData": "0x",
  "callData": "0xe9ae5c5301000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000076da12a46190528ce9780eb169fc90c18a8c2a77000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000de79f0ef8a1268dad0df02a8e527819a3cd99d40000000000000000000000000000000000000000000000000000000e8d4a5100000000000000000000000000000000000000000000000000000000000",
  "callGasLimit": "0x1b9bf",
  "verificationGasLimit": "0xda47",
  "preVerificationGas": "0xa474",
  "maxFeePerGas": "0xb91f1ec69",
  "maxPriorityFeePerGas": "0xb91f1ec69",
  "paymasterData": "0x",
  "signature": "0x82cb689ac8d52bdeb3435dbb3fbee3a16bc5ad4a30e7435badf1f2340d263eeb4589acaadf9ddf67ca8605a282aa01254812d0b016603511db3a9c061eb161661b"
}
UserOpNonce is: 15670729612648503866102855607894354141231806096137367614290888274976245284909
UserOpHash from Signed UserOp: 0x095fb53db0b7d68ca762b09e3a17d9b5cd8b1d23b98f226559e45d739587bc25
UserOpHash: 0x095fb53db0b7d68ca762b09e3a17d9b5cd8b1d23b98f226559e45d739587bc25
Waiting for transaction...
Transaction Receipt:  null

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Documentation Update
  • Code style update (formatting, renaming)
  • Refactoring
  • Build related changes

@kanthgithub kanthgithub self-assigned this Aug 19, 2024
@kanthgithub kanthgithub added the enhancement New feature or request label Aug 19, 2024
@kanthgithub kanthgithub marked this pull request as ready for review August 19, 2024 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants