diff --git a/CHANGELOG.md b/CHANGELOG.md index d849445..f521188 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # Changelog +## [1.3.0] - 2023-10-12 +### New +- Added latest zeroDev wallet Factory(0x5de4839a76cf55d0c90e2061ef4386d962E15ae3) and simpleAccount wallet factory(0x9406Cc6185a346906296840746125a0E44976454) +- Updated network config to include bundler urls deployed + ## [1.2.11] - 2023-09-20 ### Breaking Changes - Removed paymaster initialisation from sdk init place and added to estimate step to specify how each userOp is submitted rather than global paymaster initialisation diff --git a/examples/12-paymaster.ts b/examples/13-paymaster.ts similarity index 100% rename from examples/12-paymaster.ts rename to examples/13-paymaster.ts diff --git a/examples/14-zeroDev-address.ts b/examples/14-zeroDev-address.ts new file mode 100644 index 0000000..09ddd4e --- /dev/null +++ b/examples/14-zeroDev-address.ts @@ -0,0 +1,18 @@ +import { Factory, PrimeSdk } from '../src'; +import * as dotenv from 'dotenv'; + +dotenv.config(); + + +async function main() { + // initializating sdk... + const primeSdk = new PrimeSdk({ privateKey: process.env.WALLET_PRIVATE_KEY }, { chainId: Number(process.env.CHAIN_ID), projectKey: '', factoryWallet: Factory.ZERO_DEV }) + + // get ZeroDev address... + const address: string = await primeSdk.getCounterFactualAddress(); + console.log('\x1b[33m%s\x1b[0m', `ZeroDev address: ${address}`); +} + +main() + .catch(console.error) + .finally(() => process.exit()); diff --git a/examples/15-simpleAccount-address.ts b/examples/15-simpleAccount-address.ts new file mode 100644 index 0000000..6685135 --- /dev/null +++ b/examples/15-simpleAccount-address.ts @@ -0,0 +1,18 @@ +import { Factory, PrimeSdk } from '../src'; +import * as dotenv from 'dotenv'; + +dotenv.config(); + + +async function main() { + // initializating sdk... + const primeSdk = new PrimeSdk({ privateKey: process.env.WALLET_PRIVATE_KEY }, { chainId: Number(process.env.CHAIN_ID), projectKey: '', factoryWallet: Factory.SIMPLE_ACCOUNT }) + + // get SimpleAccount address... + const address: string = await primeSdk.getCounterFactualAddress(); + console.log('\x1b[33m%s\x1b[0m', `SimpleAccount address: ${address}`); +} + +main() + .catch(console.error) + .finally(() => process.exit()); diff --git a/package-lock.json b/package-lock.json index ca22432..4b8c444 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@etherspot/prime-sdk", - "version": "1.2.11", + "version": "1.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@etherspot/prime-sdk", - "version": "1.2.11", + "version": "1.3.0", "license": "MIT", "dependencies": { "@apollo/client": "3.4.0", diff --git a/package.json b/package.json index a8a926e..af174dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@etherspot/prime-sdk", - "version": "1.2.11", + "version": "1.3.0", "description": "Etherspot Prime (Account Abstraction) SDK", "keywords": [ "ether", @@ -32,6 +32,9 @@ "10-advance-routes-lifi": "./node_modules/.bin/ts-node ./examples/10-advance-routes-lifi", "11-cross-chain-quotes": "./node_modules/.bin/ts-node ./examples/11-cross-chain-quotes", "12-add-guardians": "./node_modules/.bin/ts-node ./examples/12-add-guardians", + "13-paymaster": "./node_modules/.bin/ts-node ./examples/13-paymaster", + "14-zeroDev-address": "./node_modules/.bin/ts-node ./examples/14-zeroDev-address", + "15-simpleAccount-address": "./node_modules/.bin/ts-node ./examples/15-simpleAccount-address", "format": "prettier --write \"{src,test,examples}/**/*.ts\"", "lint": "eslint \"{src,test}/**/*.ts\"", "lint-fix": "npm run lint -- --fix", diff --git a/src/sdk/base/EtherspotWalletAPI.ts b/src/sdk/base/EtherspotWalletAPI.ts index 3a1dd0c..0888df7 100644 --- a/src/sdk/base/EtherspotWalletAPI.ts +++ b/src/sdk/base/EtherspotWalletAPI.ts @@ -1,4 +1,4 @@ -import { BigNumber, BigNumberish } from 'ethers'; +import { BigNumber, BigNumberish, Contract } from 'ethers'; import { EtherspotWallet, EtherspotWallet__factory, @@ -45,7 +45,7 @@ export class EtherspotWalletAPI extends BaseAccountAPI { this.index = params.index ?? 0; } - async _getAccountContract(): Promise { + async _getAccountContract(): Promise { if (this.accountContract == null) { this.accountContract = EtherspotWallet__factory.connect(await this.getAccountAddress(), this.provider); } @@ -57,16 +57,14 @@ export class EtherspotWalletAPI extends BaseAccountAPI { * this value holds the "factory" address, followed by this account's information */ async getAccountInitCode(): Promise { - if (this.factory == null) { - if (this.factoryAddress != null && this.factoryAddress !== '') { - this.factory = EtherspotWalletFactory__factory.connect(this.factoryAddress, this.provider); - } else { - throw new Error('no factory to get initCode'); - } + if (this.factoryAddress != null && this.factoryAddress !== '') { + this.factory = EtherspotWalletFactory__factory.connect(this.factoryAddress, this.provider); + } else { + throw new Error('no factory to get initCode'); } return hexConcat([ - this.factory.address, + this.factoryAddress, this.factory.interface.encodeFunctionData('createAccount', [ this.services.walletService.walletAddress, this.index, @@ -75,11 +73,11 @@ export class EtherspotWalletAPI extends BaseAccountAPI { } async getCounterFactualAddress(): Promise { - this.factory = EtherspotWalletFactory__factory.connect(this.factoryAddress, this.provider); - this.accountAddress = await this.factory.getAddress( - this.services.walletService.walletAddress, - this.index, - ); + this.factory = EtherspotWalletFactory__factory.connect(this.factoryAddress, this.provider); + this.accountAddress = await this.factory.getAddress( + this.services.walletService.walletAddress, + this.index, + ); return this.accountAddress; } @@ -89,7 +87,7 @@ export class EtherspotWalletAPI extends BaseAccountAPI { return BigNumber.from(0); } const accountContract = await this._getAccountContract(); - return await accountContract.getNonce(); + return accountContract.getNonce(); } /** @@ -104,14 +102,10 @@ export class EtherspotWalletAPI extends BaseAccountAPI { } async signUserOpHash(userOpHash: string): Promise { - return await this.services.walletService.signMessage(arrayify(userOpHash)); + const signature = await this.services.walletService.signMessage(arrayify(userOpHash)); + return signature; } - // async updateEntryPoint(newEntryPoint: string) { - // const accountContract = await this._getAccountContract(); - // return accountContract.updateEntryPoint(newEntryPoint); - // } - get epView() { return this.entryPointView; } diff --git a/src/sdk/base/SimpleAccountWalletAPI.ts b/src/sdk/base/SimpleAccountWalletAPI.ts new file mode 100644 index 0000000..c0cf0df --- /dev/null +++ b/src/sdk/base/SimpleAccountWalletAPI.ts @@ -0,0 +1,118 @@ +import { BigNumber, BigNumberish, Contract, ethers } from 'ethers'; +import { + EntryPoint__factory, +} from '../contracts'; +import { arrayify, hexConcat } from 'ethers/lib/utils'; +import { BaseApiParams, BaseAccountAPI } from './BaseAccountAPI'; +import { SimpleAccountAbi } from '../contracts/SimpleAccount/SimpleAccountAbi'; +import { SimpleAccountFactoryAbi } from '../contracts/SimpleAccount/SimpleAccountFactoryAbi'; + +/** + * constructor params, added no top of base params: + * @param owner the signer object for the account owner + * @param factoryAddress address of contract "factory" to deploy new contracts (not needed if account already deployed) + * @param index nonce value used when creating multiple accounts for the same owner + */ +export interface SimpleAccountApiParams extends BaseApiParams { + factoryAddress?: string; + index?: number; +} + +/** + * An implementation of the BaseAccountAPI using the SimpleAccountWallet contract. + * - contract deployer gets "entrypoint", "owner" addresses and "index" nonce + * - owner signs requests using normal "Ethereum Signed Message" (ether's signer.signMessage()) + * - nonce method is "nonce()" + * - execute method is "execFromEntryPoint()" + */ +export class SimpleAccountAPI extends BaseAccountAPI { + factoryAddress?: string; + index: number; + accountAddress?: string; + + /** + * our account contract. + * should support the "execFromEntryPoint" and "nonce" methods + */ + accountContract?: Contract; + + factory?: Contract; + + constructor(params: SimpleAccountApiParams) { + super(params); + this.factoryAddress = params.factoryAddress; + this.index = params.index ?? 0; + } + + async _getAccountContract(): Promise { + this.accountContract = new ethers.Contract(this.accountAddress, SimpleAccountAbi, this.provider); + return this.accountContract; + } + + /** + * return the value to put into the "initCode" field, if the account is not yet deployed. + * this value holds the "factory" address, followed by this account's information + */ + async getAccountInitCode(): Promise { + this.factory = new ethers.Contract(this.factoryAddress, SimpleAccountFactoryAbi, this.provider); + + return hexConcat([ + this.factoryAddress, + this.factory.interface.encodeFunctionData('createAccount', [ + this.services.walletService.walletAddress, + this.index, + ]), + ]); + } + + async getCounterFactualAddress(): Promise { + try { + const initCode = await this.getAccountInitCode(); + const entryPoint = EntryPoint__factory.connect(this.entryPointAddress, this.provider); + await entryPoint.callStatic.getSenderAddress(initCode); + + throw new Error("getSenderAddress: unexpected result"); + } catch (error: any) { + const addr = error?.errorArgs?.sender; + if (!addr) throw error; + if (addr === ethers.constants.AddressZero) throw new Error('Unsupported chain_id'); + this.accountContract = new ethers.Contract(addr, SimpleAccountAbi, this.provider); + this.accountAddress = addr; + } + return this.accountAddress; + } + + async getNonce(): Promise { + console.log('checking nonce...'); + if (await this.checkAccountPhantom()) { + return BigNumber.from(0); + } + const accountContract = await this._getAccountContract(); + return accountContract.getNonce(); + } + + /** + * encode a method call from entryPoint to our contract + * @param target + * @param value + * @param data + */ + async encodeExecute(target: string, value: BigNumberish, data: string): Promise { + const accountContract = await this._getAccountContract(); + return accountContract.interface.encodeFunctionData('execute', [target, value, data]); + } + + async signUserOpHash(userOpHash: string): Promise { + const signature = await this.services.walletService.signMessage(arrayify(userOpHash)); + return signature; + } + + get epView() { + return this.entryPointView; + } + + async encodeBatch(targets: string[], values: BigNumberish[], datas: string[]): Promise { + const accountContract = await this._getAccountContract(); + return accountContract.interface.encodeFunctionData('executeBatch', [targets, datas]); + } +} diff --git a/src/sdk/base/ZeroDevWalletAPI.ts b/src/sdk/base/ZeroDevWalletAPI.ts new file mode 100644 index 0000000..64fb108 --- /dev/null +++ b/src/sdk/base/ZeroDevWalletAPI.ts @@ -0,0 +1,175 @@ +import { BigNumber, BigNumberish, Contract, ethers } from 'ethers'; +import { + EntryPoint__factory, + IEntryPoint__factory, +} from '../contracts'; +import { arrayify, hexConcat } from 'ethers/lib/utils'; +import { BaseApiParams, BaseAccountAPI } from './BaseAccountAPI'; +import { KernelAccountAbi } from '../contracts/zeroDevKernal/KernalAccountAbi'; +import { MultiSendAbi } from '../contracts/zeroDevKernal/MultiSendAbi'; +import { Safe } from '../network/constants'; +import { KernelFactoryAbi } from '../contracts/zeroDevKernal/KernalFactoryAbi'; + +/** + * For Interacting with safe contract + */ +enum Operation { + Call, + DelegateCall, +} + +/** + * constructor params, added no top of base params: + * @param owner the signer object for the account owner + * @param factoryAddress address of contract "factory" to deploy new contracts (not needed if account already deployed) + * @param index nonce value used when creating multiple accounts for the same owner + */ +export interface ZeroDevWalletApiParams extends BaseApiParams { + factoryAddress?: string; + index?: number; +} + +/** + * An implementation of the BaseAccountAPI using the EtherspotWallet contract. + * - contract deployer gets "entrypoint", "owner" addresses and "index" nonce + * - owner signs requests using normal "Ethereum Signed Message" (ether's signer.signMessage()) + * - nonce method is "nonce()" + * - execute method is "execFromEntryPoint()" + */ +export class ZeroDevWalletAPI extends BaseAccountAPI { + factoryAddress?: string; + index: number; + accountAddress?: string; + + /** + * our account contract. + * should support the "execFromEntryPoint" and "nonce" methods + */ + accountContract?: Contract; + + factory?: Contract; + + multisend: Contract; + + constructor(params: ZeroDevWalletApiParams) { + super(params); + this.factoryAddress = params.factoryAddress; + this.index = params.index ?? 0; + } + + async _getAccountContract(): Promise { + this.accountContract = new ethers.Contract(this.accountAddress, KernelAccountAbi, this.provider); + return this.accountContract; + } + + protected async getKernelFactoryInitCode(): Promise { + try { + const KernalFactoryInterface = new ethers.utils.Interface(KernelFactoryAbi) + return KernalFactoryInterface.encodeFunctionData('createAccount', [ + "0xf048AD83CB2dfd6037A43902a2A5Be04e53cd2Eb", // Kernel Implementation Address + new ethers.utils.Interface(KernelAccountAbi).encodeFunctionData( + "initialize", + ["0xd9AB5096a832b9ce79914329DAEE236f8Eea0390", this.services.walletService.walletAddress], // Kernel Validation Address + ), + this.index, + ], + ); + } catch (err: any) { + throw new Error("Factory Code generation failed"); + } + } + + /** + * return the value to put into the "initCode" field, if the account is not yet deployed. + * this value holds the "factory" address, followed by this account's information + */ + async getAccountInitCode(): Promise { + + this.factory = new ethers.Contract(this.factoryAddress, KernelFactoryAbi, this.provider); + return hexConcat([ + this.factoryAddress, await this.getKernelFactoryInitCode() + ]); + } + + async getCounterFactualAddress(): Promise { + try { + const initCode = await this.getAccountInitCode(); + const entryPoint = EntryPoint__factory.connect(this.entryPointAddress, this.provider); + await entryPoint.callStatic.getSenderAddress(initCode); + + throw new Error("getSenderAddress: unexpected result"); + } catch (error: any) { + const addr = error?.errorArgs?.sender; + if (!addr) throw error; + if (addr === ethers.constants.AddressZero) throw new Error('Unsupported chain_id'); + const chain = await this.provider.getNetwork().then((n) => n.chainId); + const ms = Safe.MultiSend[chain.toString()]; + if (!ms) + throw new Error( + `Multisend contract not deployed on network: ${chain.toString()}` + ); + this.multisend = new ethers.Contract(ms, MultiSendAbi, this.provider); + this.accountContract = new ethers.Contract(addr, KernelAccountAbi, this.provider); + this.accountAddress = addr; + } + return this.accountAddress; + } + + async getNonce(): Promise { + console.log('checking nonce...'); + if (await this.checkAccountPhantom()) { + return BigNumber.from(0); + } + const entryPoint = IEntryPoint__factory.connect(this.entryPointAddress, this.provider); + return await entryPoint.getNonce(this.accountAddress, 0); + } + + async signUserOpHash(userOpHash: string): Promise { + const signature = await this.services.walletService.signMessage(arrayify(userOpHash)); + return ethers.utils.hexConcat([ + "0x00000000", + signature, + ]); + } + + get epView() { + return this.entryPointView; + } + + /** + * encode a method call from entryPoint to our contract + * @param target + * @param value + * @param data + */ + async encodeExecute(target: string, value: BigNumberish, data: string): Promise { + const accountContract = await this._getAccountContract(); + return accountContract.interface.encodeFunctionData('execute', [target, value, data]); + } + + async encodeBatch(targets: string[], values: BigNumberish[], datas: string[]): Promise { + const accountContract = await this._getAccountContract(); + const data = this.multisend.interface.encodeFunctionData("multiSend", [ + ethers.utils.hexConcat( + targets.map((c, index) => + ethers.utils.solidityPack( + ["uint8", "address", "uint256", "uint256", "bytes"], + [ + Operation.Call, + c, + values[index], + ethers.utils.hexDataLength(datas[index]), + datas[index], + ] + ) + ) + ), + ]); + return accountContract.interface.encodeFunctionData('execute', [ + this.multisend.address, + ethers.constants.Zero, + data, + Operation.DelegateCall, + ]) + } +} diff --git a/src/sdk/contracts/SimpleAccount/SimpleAccountAbi.ts b/src/sdk/contracts/SimpleAccount/SimpleAccountAbi.ts new file mode 100644 index 0000000..36e6d84 --- /dev/null +++ b/src/sdk/contracts/SimpleAccount/SimpleAccountAbi.ts @@ -0,0 +1,524 @@ +export const SimpleAccountAbi = [ + { + inputs: [ + { + internalType: "contract IEntryPoint", + name: "anEntryPoint", + type: "address", + }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "previousAdmin", + type: "address", + }, + { + indexed: false, + internalType: "address", + name: "newAdmin", + type: "address", + }, + ], + name: "AdminChanged", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "beacon", + type: "address", + }, + ], + name: "BeaconUpgraded", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint8", + name: "version", + type: "uint8", + }, + ], + name: "Initialized", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "contract IEntryPoint", + name: "entryPoint", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "owner", + type: "address", + }, + ], + name: "SimpleAccountInitialized", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "implementation", + type: "address", + }, + ], + name: "Upgraded", + type: "event", + }, + { + inputs: [], + name: "addDeposit", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [], + name: "entryPoint", + outputs: [ + { + internalType: "contract IEntryPoint", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "dest", + type: "address", + }, + { + internalType: "uint256", + name: "value", + type: "uint256", + }, + { + internalType: "bytes", + name: "func", + type: "bytes", + }, + ], + name: "execute", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address[]", + name: "dest", + type: "address[]", + }, + { + internalType: "bytes[]", + name: "func", + type: "bytes[]", + }, + ], + name: "executeBatch", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "getDeposit", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getNonce", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "anOwner", + type: "address", + }, + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + { + internalType: "address", + name: "", + type: "address", + }, + { + internalType: "uint256[]", + name: "", + type: "uint256[]", + }, + { + internalType: "uint256[]", + name: "", + type: "uint256[]", + }, + { + internalType: "bytes", + name: "", + type: "bytes", + }, + ], + name: "onERC1155BatchReceived", + outputs: [ + { + internalType: "bytes4", + name: "", + type: "bytes4", + }, + ], + stateMutability: "pure", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + { + internalType: "address", + name: "", + type: "address", + }, + { + internalType: "uint256", + name: "", + type: "uint256", + }, + { + internalType: "uint256", + name: "", + type: "uint256", + }, + { + internalType: "bytes", + name: "", + type: "bytes", + }, + ], + name: "onERC1155Received", + outputs: [ + { + internalType: "bytes4", + name: "", + type: "bytes4", + }, + ], + stateMutability: "pure", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + { + internalType: "address", + name: "", + type: "address", + }, + { + internalType: "uint256", + name: "", + type: "uint256", + }, + { + internalType: "bytes", + name: "", + type: "bytes", + }, + ], + name: "onERC721Received", + outputs: [ + { + internalType: "bytes4", + name: "", + type: "bytes4", + }, + ], + stateMutability: "pure", + type: "function", + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "proxiableUUID", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes4", + name: "interfaceId", + type: "bytes4", + }, + ], + name: "supportsInterface", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + { + internalType: "address", + name: "", + type: "address", + }, + { + internalType: "address", + name: "", + type: "address", + }, + { + internalType: "uint256", + name: "", + type: "uint256", + }, + { + internalType: "bytes", + name: "", + type: "bytes", + }, + { + internalType: "bytes", + name: "", + type: "bytes", + }, + ], + name: "tokensReceived", + outputs: [], + stateMutability: "pure", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address", + }, + ], + name: "upgradeTo", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address", + }, + { + internalType: "bytes", + name: "data", + type: "bytes", + }, + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + components: [ + { + internalType: "address", + name: "sender", + type: "address", + }, + { + internalType: "uint256", + name: "nonce", + type: "uint256", + }, + { + internalType: "bytes", + name: "initCode", + type: "bytes", + }, + { + internalType: "bytes", + name: "callData", + type: "bytes", + }, + { + internalType: "uint256", + name: "callGasLimit", + type: "uint256", + }, + { + internalType: "uint256", + name: "verificationGasLimit", + type: "uint256", + }, + { + internalType: "uint256", + name: "preVerificationGas", + type: "uint256", + }, + { + internalType: "uint256", + name: "maxFeePerGas", + type: "uint256", + }, + { + internalType: "uint256", + name: "maxPriorityFeePerGas", + type: "uint256", + }, + { + internalType: "bytes", + name: "paymasterAndData", + type: "bytes", + }, + { + internalType: "bytes", + name: "signature", + type: "bytes", + }, + ], + internalType: "struct UserOperation", + name: "userOp", + type: "tuple", + }, + { + internalType: "bytes32", + name: "userOpHash", + type: "bytes32", + }, + { + internalType: "uint256", + name: "missingAccountFunds", + type: "uint256", + }, + ], + name: "validateUserOp", + outputs: [ + { + internalType: "uint256", + name: "validationData", + type: "uint256", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address payable", + name: "withdrawAddress", + type: "address", + }, + { + internalType: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "withdrawDepositTo", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + stateMutability: "payable", + type: "receive", + }, + ] as const; \ No newline at end of file diff --git a/src/sdk/contracts/SimpleAccount/SimpleAccountFactoryAbi.ts b/src/sdk/contracts/SimpleAccount/SimpleAccountFactoryAbi.ts new file mode 100644 index 0000000..c37d836 --- /dev/null +++ b/src/sdk/contracts/SimpleAccount/SimpleAccountFactoryAbi.ts @@ -0,0 +1,74 @@ +export const SimpleAccountFactoryAbi = [ + { + inputs: [ + { + internalType: "contract IEntryPoint", + name: "_entryPoint", + type: "address", + }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [], + name: "accountImplementation", + outputs: [ + { + internalType: "contract SimpleAccount", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address", + }, + { + internalType: "uint256", + name: "salt", + type: "uint256", + }, + ], + name: "createAccount", + outputs: [ + { + internalType: "contract SimpleAccount", + name: "ret", + type: "address", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address", + }, + { + internalType: "uint256", + name: "salt", + type: "uint256", + }, + ], + name: "getAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + ] as const; \ No newline at end of file diff --git a/src/sdk/contracts/zeroDevKernal/ECDSAKernelFactoryAbi.ts b/src/sdk/contracts/zeroDevKernal/ECDSAKernelFactoryAbi.ts new file mode 100644 index 0000000..91160b8 --- /dev/null +++ b/src/sdk/contracts/zeroDevKernal/ECDSAKernelFactoryAbi.ts @@ -0,0 +1,110 @@ +export const ECDSAKernelFactoryAbi = [ + { + inputs: [ + { + internalType: "contract KernelFactory", + name: "_singletonFactory", + type: "address", + }, + { + internalType: "contract ECDSAValidator", + name: "_validator", + type: "address", + }, + { + internalType: "contract IEntryPoint", + name: "_entryPoint", + type: "address", + }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [ + { + internalType: "address", + name: "_owner", + type: "address", + }, + { + internalType: "uint256", + name: "_index", + type: "uint256", + }, + ], + name: "createAccount", + outputs: [ + { + internalType: "contract EIP1967Proxy", + name: "proxy", + type: "address", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "entryPoint", + outputs: [ + { + internalType: "contract IEntryPoint", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_owner", + type: "address", + }, + { + internalType: "uint256", + name: "_index", + type: "uint256", + }, + ], + name: "getAccountAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "singletonFactory", + outputs: [ + { + internalType: "contract KernelFactory", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "validator", + outputs: [ + { + internalType: "contract ECDSAValidator", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + ] as const; \ No newline at end of file diff --git a/src/sdk/contracts/zeroDevKernal/KernalAccountAbi.ts b/src/sdk/contracts/zeroDevKernal/KernalAccountAbi.ts new file mode 100644 index 0000000..905d4d7 --- /dev/null +++ b/src/sdk/contracts/zeroDevKernal/KernalAccountAbi.ts @@ -0,0 +1,579 @@ +export const KernelAccountAbi = [ + { + "inputs": [ + { + "internalType": "contract IEntryPoint", + "name": "_entryPoint", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldValidator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newValidator", + "type": "address" + } + ], + "name": "DefaultValidatorChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + }, + { + "indexed": true, + "internalType": "address", + "name": "executor", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "validator", + "type": "address" + } + ], + "name": "ExecutionChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_disableFlag", + "type": "bytes4" + } + ], + "name": "disableMode", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "entryPoint", + "outputs": [ + { + "internalType": "contract IEntryPoint", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + }, + { + "internalType": "enum Operation", + "name": "operation", + "type": "uint8" + } + ], + "name": "execute", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getDefaultValidator", + "outputs": [ + { + "internalType": "contract IKernelValidator", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getDisabledMode", + "outputs": [ + { + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_selector", + "type": "bytes4" + } + ], + "name": "getExecution", + "outputs": [ + { + "components": [ + { + "internalType": "uint48", + "name": "validUntil", + "type": "uint48" + }, + { + "internalType": "uint48", + "name": "validAfter", + "type": "uint48" + }, + { + "internalType": "address", + "name": "executor", + "type": "address" + }, + { + "internalType": "contract IKernelValidator", + "name": "validator", + "type": "address" + } + ], + "internalType": "struct ExecutionDetail", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLastDisabledTime", + "outputs": [ + { + "internalType": "uint48", + "name": "", + "type": "uint48" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint192", + "name": "key", + "type": "uint192" + } + ], + "name": "getNonce", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getNonce", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IKernelValidator", + "name": "_defaultValidator", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "hash", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "name": "isValidSignature", + "outputs": [ + { + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "onERC1155BatchReceived", + "outputs": [ + { + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "onERC1155Received", + "outputs": [ + { + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "onERC721Received", + "outputs": [ + { + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IKernelValidator", + "name": "_defaultValidator", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "setDefaultValidator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_selector", + "type": "bytes4" + }, + { + "internalType": "address", + "name": "_executor", + "type": "address" + }, + { + "internalType": "contract IKernelValidator", + "name": "_validator", + "type": "address" + }, + { + "internalType": "uint48", + "name": "_validUntil", + "type": "uint48" + }, + { + "internalType": "uint48", + "name": "_validAfter", + "type": "uint48" + }, + { + "internalType": "bytes", + "name": "_enableData", + "type": "bytes" + } + ], + "name": "setExecution", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "initCode", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "callGasLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "verificationGasLimit", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "preVerificationGas", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxFeePerGas", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxPriorityFeePerGas", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "paymasterAndData", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct UserOperation", + "name": "userOp", + "type": "tuple" + }, + { + "internalType": "bytes32", + "name": "userOpHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "missingAccountFunds", + "type": "uint256" + } + ], + "name": "validateUserOp", + "outputs": [ + { + "internalType": "uint256", + "name": "validationData", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +] as const; \ No newline at end of file diff --git a/src/sdk/contracts/zeroDevKernal/KernalFactoryAbi.ts b/src/sdk/contracts/zeroDevKernal/KernalFactoryAbi.ts new file mode 100644 index 0000000..497362e --- /dev/null +++ b/src/sdk/contracts/zeroDevKernal/KernalFactoryAbi.ts @@ -0,0 +1,380 @@ +export const KernelFactoryAbi = [ + { + inputs: [ + { + internalType: "address", + name: "_owner", + type: "address", + }, + { + internalType: "contract IEntryPoint", + name: "_entryPoint", + type: "address", + }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [], + name: "DeploymentFailed", + type: "error", + }, + { + inputs: [], + name: "NewOwnerIsZeroAddress", + type: "error", + }, + { + inputs: [], + name: "NoHandoverRequest", + type: "error", + }, + { + inputs: [], + name: "SaltDoesNotStartWithCaller", + type: "error", + }, + { + inputs: [], + name: "Unauthorized", + type: "error", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "proxy", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "implementation", + type: "address", + }, + ], + name: "Deployed", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "pendingOwner", + type: "address", + }, + ], + name: "OwnershipHandoverCanceled", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "pendingOwner", + type: "address", + }, + ], + name: "OwnershipHandoverRequested", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "oldOwner", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address", + }, + ], + name: "OwnershipTransferred", + type: "event", + }, + { + inputs: [ + { + internalType: "uint32", + name: "unstakeDelaySec", + type: "uint32", + }, + ], + name: "addStake", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [], + name: "cancelOwnershipHandover", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "pendingOwner", + type: "address", + }, + ], + name: "completeOwnershipHandover", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_implementation", + type: "address", + }, + { + internalType: "bytes", + name: "_data", + type: "bytes", + }, + { + internalType: "uint256", + name: "_index", + type: "uint256", + }, + ], + name: "createAccount", + outputs: [ + { + internalType: "address", + name: "proxy", + type: "address", + }, + ], + stateMutability: "payable", + type: "function", + }, + { + inputs: [], + name: "entryPoint", + outputs: [ + { + internalType: "contract IEntryPoint", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes", + name: "_data", + type: "bytes", + }, + { + internalType: "uint256", + name: "_index", + type: "uint256", + }, + ], + name: "getAccountAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "initCodeHash", + outputs: [ + { + internalType: "bytes32", + name: "result", + type: "bytes32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + name: "isAllowedImplementation", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "result", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "pendingOwner", + type: "address", + }, + ], + name: "ownershipHandoverExpiresAt", + outputs: [ + { + internalType: "uint256", + name: "result", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "ownershipHandoverValidFor", + outputs: [ + { + internalType: "uint64", + name: "", + type: "uint64", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "bytes32", + name: "salt", + type: "bytes32", + }, + ], + name: "predictDeterministicAddress", + outputs: [ + { + internalType: "address", + name: "predicted", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [], + name: "requestOwnershipHandover", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [ + { + internalType: "contract IEntryPoint", + name: "_entryPoint", + type: "address", + }, + ], + name: "setEntryPoint", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_implementation", + type: "address", + }, + { + internalType: "bool", + name: "_allow", + type: "bool", + }, + ], + name: "setImplementation", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "newOwner", + type: "address", + }, + ], + name: "transferOwnership", + outputs: [], + stateMutability: "payable", + type: "function", + }, + { + inputs: [], + name: "unlockStake", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address payable", + name: "withdrawAddress", + type: "address", + }, + ], + name: "withdrawStake", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, +] as const; \ No newline at end of file diff --git a/src/sdk/contracts/zeroDevKernal/MultiSendAbi.ts b/src/sdk/contracts/zeroDevKernal/MultiSendAbi.ts new file mode 100644 index 0000000..04c872a --- /dev/null +++ b/src/sdk/contracts/zeroDevKernal/MultiSendAbi.ts @@ -0,0 +1,20 @@ +export const MultiSendAbi = [ + { + inputs: [], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [ + { + internalType: "bytes", + name: "transactions", + type: "bytes", + }, + ], + name: "multiSend", + outputs: [], + stateMutability: "payable", + type: "function", + }, + ] as const; \ No newline at end of file diff --git a/src/sdk/interfaces.ts b/src/sdk/interfaces.ts index 9bde4a9..970abfa 100644 --- a/src/sdk/interfaces.ts +++ b/src/sdk/interfaces.ts @@ -7,6 +7,12 @@ export interface PaymasterApi { context?: any; } +export enum Factory { + ZERO_DEV = 'zeroDev', + ETHERSPOT = 'etherspot', + SIMPLE_ACCOUNT = 'simpleAccount' +} + export interface SdkOptions { chainId: number; stateStorage?: StateStorage; @@ -16,4 +22,5 @@ export interface SdkOptions { rpcProviderUrl?: string; graphqlEndpoint?: string; projectKey: string; + factoryWallet?: Factory; } diff --git a/src/sdk/network/constants.ts b/src/sdk/network/constants.ts index 6aea886..f801b94 100644 --- a/src/sdk/network/constants.ts +++ b/src/sdk/network/constants.ts @@ -73,7 +73,11 @@ export const Networks: { bundler: 'https://goerli-bundler.etherspot.io', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '0x5de4839a76cf55d0c90e2061ef4386d962E15ae3', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: 'qa-etherspot.pillarproject.io', }, @@ -82,7 +86,11 @@ export const Networks: { bundler: 'https://mumbai-bundler.etherspot.io', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '0xD49a72cb78C44c6bfbf0d471581B7635cF62E81e', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: 'qa-etherspot.pillarproject.io', }, @@ -91,7 +99,11 @@ export const Networks: { bundler: 'https://basegoerli-bundler.etherspot.io', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '0xD49a72cb78C44c6bfbf0d471581B7635cF62E81e', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: 'qa-etherspot.pillarproject.io', }, @@ -100,7 +112,11 @@ export const Networks: { bundler: 'https://sepolia-bundler.etherspot.io', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '0xD49a72cb78C44c6bfbf0d471581B7635cF62E81e', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: '', }, @@ -109,7 +125,11 @@ export const Networks: { bundler: 'https://optimism-bundler.etherspot.io', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '0xD49a72cb78C44c6bfbf0d471581B7635cF62E81e', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: 'etherspot.pillarproject.io', }, @@ -118,7 +138,11 @@ export const Networks: { bundler: 'https://polygon-bundler.etherspot.io', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '0xD49a72cb78C44c6bfbf0d471581B7635cF62E81e', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: 'etherspot.pillarproject.io', }, @@ -127,7 +151,11 @@ export const Networks: { bundler: 'https://arbitrum-bundler.etherspot.io', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '0xD49a72cb78C44c6bfbf0d471581B7635cF62E81e', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: 'etherspot.pillarproject.io', }, @@ -136,7 +164,11 @@ export const Networks: { bundler: 'https://ethereum-bundler.etherspot.io/', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '0xD49a72cb78C44c6bfbf0d471581B7635cF62E81e', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: 'etherspot.pillarproject.io', }, @@ -145,7 +177,11 @@ export const Networks: { bundler: 'https://arbitrumgoerli-bundler.etherspot.io', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '0xD49a72cb78C44c6bfbf0d471581B7635cF62E81e', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: 'qa-etherspot.pillarproject.io', }, @@ -154,7 +190,11 @@ export const Networks: { bundler: '', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '0xD49a72cb78C44c6bfbf0d471581B7635cF62E81e', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: 'qa-etherspot.pillarproject.io', }, @@ -163,7 +203,11 @@ export const Networks: { bundler: 'https://fuse-bundler.etherspot.io', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: '', }, @@ -172,16 +216,24 @@ export const Networks: { bundler: '', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: '', }, [100]: { chainId: 100, - bundler: '', + bundler: 'https://gnosis-bundler.etherspot.io/', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '0xD49a72cb78C44c6bfbf0d471581B7635cF62E81e', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: 'etherspot.pillarproject.io', }, @@ -190,7 +242,11 @@ export const Networks: { bundler: '', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: '', }, @@ -199,7 +255,11 @@ export const Networks: { bundler: 'https://optimismgoerli-bundler.etherspot.io/', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '0xD49a72cb78C44c6bfbf0d471581B7635cF62E81e', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: 'qa-etherspot.pillarproject.io', }, @@ -208,7 +268,11 @@ export const Networks: { bundler: '', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: '', }, @@ -217,7 +281,11 @@ export const Networks: { bundler: '', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: '', }, @@ -226,7 +294,11 @@ export const Networks: { bundler: 'https://mantle-bundler.etherspot.io/', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: '', }, @@ -235,34 +307,50 @@ export const Networks: { bundler: 'https://mantletestnet-bundler.etherspot.io/', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: '', }, [43114]: { chainId: 43114, - bundler: '', + bundler: 'https://avalanche-bundler.etherspot.io/', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E' + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '0xD49a72cb78C44c6bfbf0d471581B7635cF62E81e', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: 'etherspot.pillarproject.io' }, [8453]: { chainId: 8453, - bundler: '', + bundler: 'https://base-bundler.etherspot.io/', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E' + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '0xD49a72cb78C44c6bfbf0d471581B7635cF62E81e', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: '' }, [56]: { chainId: 56, - bundler: '', + bundler: 'https://bnb-bundler.etherspot.io/', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E' + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '0xD49a72cb78C44c6bfbf0d471581B7635cF62E81e', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: 'etherspot.pillarproject.io' }, @@ -271,7 +359,11 @@ export const Networks: { bundler: '', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E' + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: 'qa-etherspot.pillarproject.io' }, @@ -280,16 +372,24 @@ export const Networks: { bundler: '', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E' + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '0xD49a72cb78C44c6bfbf0d471581B7635cF62E81e', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: 'qa-etherspot.pillarproject.io' }, [59144]: { chainId: 59144, - bundler: '', + bundler: 'https://linea-bundler.etherspot.io/', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E' + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: '' }, @@ -298,12 +398,145 @@ export const Networks: { bundler: '', contracts: { entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789', - walletFactory: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E' + walletFactory: { + etherspot: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E', + zeroDev: '', + simpleAccount: '0x9406Cc6185a346906296840746125a0E44976454', + } }, graphqlEndpoint: '' }, }; +interface ISafeConstant { + MultiSend: Record; +} + +export const Safe: ISafeConstant = { + // From https://github.com/safe-global/safe-deployments/blob/main/src/assets/v1.3.0/multi_send.json + MultiSend: { + "1": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "3": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "4": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "5": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "10": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "11": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "12": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "18": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "25": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "28": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "39": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "40": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "41": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "42": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "50": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "51": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "56": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "61": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "63": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "69": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "82": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "83": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "97": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "100": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "106": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "108": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "111": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "122": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "123": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "137": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "246": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "250": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "288": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "300": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "321": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "322": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "336": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "338": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "420": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "588": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "592": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "595": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "599": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "686": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "787": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "1001": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "1008": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "1088": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "1101": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "1111": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "1112": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "1115": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "1116": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "1284": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "1285": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "1287": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "1294": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "1807": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "1984": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "2001": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "2002": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "2008": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "2019": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "2020": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "2221": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "2222": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "3737": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "4002": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "4689": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "4918": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "4919": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "5001": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "7341": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "7700": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "8217": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "9000": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "9001": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "9728": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "10000": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "10001": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "10200": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "11235": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "11437": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "12357": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "23294": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "42161": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "42170": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "42220": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "43113": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "43114": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "43288": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "44787": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "45000": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "47805": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "54211": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "56288": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "59140": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "71401": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "71402": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "73799": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "80001": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "84531": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "200101": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "200202": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "333999": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "421611": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "421613": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "534353": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "11155111": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "245022926": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "1313161554": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "1313161555": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "1666600000": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "1666700000": "0x998739BFdAAdde7C933B942a68053933098f9EDa", + "11297108099": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + "11297108109": "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761", + }, +}; + +export const KERNEL_IMPL_ADDRESS = "0xf048AD83CB2dfd6037A43902a2A5Be04e53cd2Eb"; +export const KERNEL_VALIDATOR_ADDRESS = "0xd9AB5096a832b9ce79914329DAEE236f8Eea0390"; + export const CHAIN_ID_TO_NETWORK_NAME: { [key: number]: NetworkNames } = Object.entries( NETWORK_NAME_TO_CHAIN_ID, ).reduce( diff --git a/src/sdk/network/interfaces.ts b/src/sdk/network/interfaces.ts index 3acf11c..e852528 100644 --- a/src/sdk/network/interfaces.ts +++ b/src/sdk/network/interfaces.ts @@ -10,7 +10,11 @@ export interface NetworkConfig { bundler: string; contracts: { entryPoint: string; - walletFactory: string; + walletFactory: { + etherspot: string; + zeroDev: string; + simpleAccount: string; + }; }; graphqlEndpoint?: string; }; diff --git a/src/sdk/sdk.ts b/src/sdk/sdk.ts index 12a2f24..fd20430 100644 --- a/src/sdk/sdk.ts +++ b/src/sdk/sdk.ts @@ -7,7 +7,7 @@ import { WalletConnect2WalletProvider, WalletProviderLike } from './wallet'; -import { PaymasterApi, SdkOptions } from './interfaces'; +import { Factory, PaymasterApi, SdkOptions } from './interfaces'; import { Network } from "./network"; import { BatchUserOpsRequest, Exception, getGasFee, onRampApiKey, openUrl, UserOpsRequest } from "./common"; import { BigNumber, ethers, providers } from 'ethers'; @@ -17,6 +17,8 @@ import { EtherspotWalletAPI, HttpRpcClient, VerifyingPaymasterAPI } from './base import { TransactionDetailsForUserOp, TransactionGasInfoForUserOp } from './base/TransactionDetailsForUserOp'; import { CreateSessionDto, OnRamperDto, GetAccountBalancesDto, GetAdvanceRoutesLiFiDto, GetExchangeCrossChainQuoteDto, GetExchangeOffersDto, GetNftListDto, GetStepTransactionsLiFiDto, GetTransactionDto, SignMessageDto, validateDto } from './dto'; import { AccountBalances, AdvanceRoutesLiFi, BridgingQuotes, ExchangeOffer, NftList, StepTransactions, Transaction, Session } from './'; +import { ZeroDevWalletAPI } from './base/ZeroDevWalletAPI'; +import { SimpleAccountAPI } from './base/SimpleAccountWalletAPI'; /** * Prime-Sdk @@ -25,9 +27,10 @@ import { AccountBalances, AdvanceRoutesLiFi, BridgingQuotes, ExchangeOffer, NftL */ export class PrimeSdk { - private etherspotWallet: EtherspotWalletAPI; + private etherspotWallet: EtherspotWalletAPI | ZeroDevWalletAPI | SimpleAccountAPI; private bundler: HttpRpcClient; private chainId: number; + private factoryUsed: Factory; private userOpsBatch: BatchUserOpsRequest = { to: [], data: [], value: [] }; @@ -54,6 +57,7 @@ export class PrimeSdk { optionsLike.graphqlEndpoint = networkConfig.graphqlEndpoint; } + const factoryUsed = optionsLike.factoryWallet ?? Factory.ETHERSPOT; let provider; @@ -61,14 +65,34 @@ export class PrimeSdk { provider = new providers.JsonRpcProvider(rpcProviderUrl); } else provider = new providers.JsonRpcProvider(optionsLike.bundlerRpcUrl); - this.etherspotWallet = new EtherspotWalletAPI({ - provider, - walletProvider: walletConnectProvider ?? walletProvider, - optionsLike, - entryPointAddress: Networks[chainId].contracts.entryPoint, - factoryAddress: Networks[chainId].contracts.walletFactory, - }) - + if (Networks[chainId].contracts.walletFactory[factoryUsed] == '') throw new Exception('The selected factory is not deployed in the selected chain_id') + + if (factoryUsed === Factory.ZERO_DEV) { + this.etherspotWallet = new ZeroDevWalletAPI({ + provider, + walletProvider: walletConnectProvider ?? walletProvider, + optionsLike, + entryPointAddress: Networks[chainId].contracts.entryPoint, + factoryAddress: Networks[chainId].contracts.walletFactory[factoryUsed], + }) + } else if (factoryUsed === Factory.SIMPLE_ACCOUNT) { + this.etherspotWallet = new SimpleAccountAPI({ + provider, + walletProvider: walletConnectProvider ?? walletProvider, + optionsLike, + entryPointAddress: Networks[chainId].contracts.entryPoint, + factoryAddress: Networks[chainId].contracts.walletFactory[factoryUsed], + }) + } + else { + this.etherspotWallet = new EtherspotWalletAPI({ + provider, + walletProvider: walletConnectProvider ?? walletProvider, + optionsLike, + entryPointAddress: Networks[chainId].contracts.entryPoint, + factoryAddress: Networks[chainId].contracts.walletFactory[factoryUsed], + }) + } this.bundler = new HttpRpcClient(optionsLike.bundlerRpcUrl, Networks[chainId].contracts.entryPoint, Networks[chainId].chainId); } @@ -153,6 +177,13 @@ export class PrimeSdk { maxPriorityFeePerGas: 1, }); + /** + * Dummy signature used only in the case of zeroDev factory contract + */ + if (this.factoryUsed === Factory.ZERO_DEV) { + partialtx.signature = "0x00000000870fe151d548a1c527c3804866fab30abf28ed17b79d5fc5149f19ca0819fefc3c57f3da4fdf9b10fab3f2f3dca536467ae44943b9dbb8433efe7760ddd72aaa1c" + } + const bundlerGasEstimate = await this.bundler.getVerificationGasInfo(partialtx); // if user has specified the gas prices then use them