@aa-sdk/core 4.0.0-alpha.1 → 4.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/account/smartContractAccount.d.ts +9 -3
- package/dist/cjs/account/smartContractAccount.js +11 -6
- package/dist/cjs/account/smartContractAccount.js.map +1 -1
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
- package/dist/cjs/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
- package/dist/cjs/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
- package/dist/cjs/actions/smartAccount/internal/initUserOperation.js.map +1 -1
- package/dist/cjs/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
- package/dist/cjs/actions/smartAccount/internal/sendUserOperation.js.map +1 -1
- package/dist/cjs/actions/smartAccount/sendUserOperation.js.map +1 -1
- package/dist/cjs/client/bundlerClient.js.map +1 -1
- package/dist/cjs/client/decorators/bundlerClient.js.map +1 -1
- package/dist/cjs/client/isSmartAccountClient.js.map +1 -1
- package/dist/cjs/client/types.d.ts +2 -7
- package/dist/cjs/client/types.js.map +1 -1
- package/dist/cjs/ens/utils.d.ts +1 -1
- package/dist/cjs/ens/utils.js +3 -3
- package/dist/cjs/ens/utils.js.map +1 -1
- package/dist/cjs/errors/account.js.map +1 -1
- package/dist/cjs/errors/client.js.map +1 -1
- package/dist/cjs/errors/entrypoint.js.map +1 -1
- package/dist/cjs/errors/signer.js.map +1 -1
- package/dist/cjs/errors/transaction.js.map +1 -1
- package/dist/cjs/errors/useroperation.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -6
- package/dist/cjs/index.js +38 -64
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/logger.js.map +1 -1
- package/dist/cjs/middleware/actions.js +2 -18
- package/dist/cjs/middleware/actions.js.map +1 -1
- package/dist/cjs/middleware/defaults/gasEstimator.js +4 -2
- package/dist/cjs/middleware/defaults/gasEstimator.js.map +1 -1
- package/dist/cjs/middleware/erc7677middleware.d.ts +40 -0
- package/dist/cjs/middleware/erc7677middleware.js +77 -0
- package/dist/cjs/middleware/erc7677middleware.js.map +1 -0
- package/dist/cjs/middleware/noopMiddleware.d.ts +2 -1
- package/dist/cjs/middleware/noopMiddleware.js.map +1 -1
- package/dist/cjs/middleware/types.d.ts +3 -2
- package/dist/cjs/middleware/types.js.map +1 -1
- package/dist/cjs/signer/local-account.d.ts +44 -44
- package/dist/cjs/signer/local-account.js.map +1 -1
- package/dist/cjs/signer/wallet-client.d.ts +44 -44
- package/dist/cjs/signer/wallet-client.js.map +1 -1
- package/dist/cjs/transport/split.js.map +1 -1
- package/dist/cjs/utils/bigint.js.map +1 -1
- package/dist/cjs/utils/bytes.js.map +1 -1
- package/dist/cjs/utils/defaults.d.ts +2 -4
- package/dist/cjs/utils/defaults.js +5 -45
- package/dist/cjs/utils/defaults.js.map +1 -1
- package/dist/cjs/utils/index.d.ts +0 -3
- package/dist/cjs/utils/index.js +1 -25
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/types.js.map +1 -1
- package/dist/cjs/utils/userop.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/account/smartContractAccount.d.ts +9 -3
- package/dist/esm/account/smartContractAccount.js +6 -1
- package/dist/esm/account/smartContractAccount.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
- package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
- package/dist/esm/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/initUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/sendUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendUserOperation.js.map +1 -1
- package/dist/esm/client/bundlerClient.js.map +1 -1
- package/dist/esm/client/decorators/bundlerClient.js.map +1 -1
- package/dist/esm/client/isSmartAccountClient.js.map +1 -1
- package/dist/esm/client/types.d.ts +2 -7
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/ens/utils.d.ts +1 -1
- package/dist/esm/ens/utils.js +1 -1
- package/dist/esm/ens/utils.js.map +1 -1
- package/dist/esm/errors/account.js.map +1 -1
- package/dist/esm/errors/client.js.map +1 -1
- package/dist/esm/errors/entrypoint.js.map +1 -1
- package/dist/esm/errors/signer.js.map +1 -1
- package/dist/esm/errors/transaction.js.map +1 -1
- package/dist/esm/errors/useroperation.js.map +1 -1
- package/dist/esm/index.d.ts +3 -6
- package/dist/esm/index.js +2 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/logger.js.map +1 -1
- package/dist/esm/middleware/actions.js +3 -18
- package/dist/esm/middleware/actions.js.map +1 -1
- package/dist/esm/middleware/defaults/gasEstimator.js +4 -2
- package/dist/esm/middleware/defaults/gasEstimator.js.map +1 -1
- package/dist/esm/middleware/erc7677middleware.d.ts +40 -0
- package/dist/esm/middleware/erc7677middleware.js +73 -0
- package/dist/esm/middleware/erc7677middleware.js.map +1 -0
- package/dist/esm/middleware/noopMiddleware.d.ts +2 -1
- package/dist/esm/middleware/noopMiddleware.js.map +1 -1
- package/dist/esm/middleware/types.d.ts +3 -2
- package/dist/esm/middleware/types.js.map +1 -1
- package/dist/esm/signer/local-account.d.ts +44 -44
- package/dist/esm/signer/local-account.js.map +1 -1
- package/dist/esm/signer/wallet-client.d.ts +44 -44
- package/dist/esm/signer/wallet-client.js.map +1 -1
- package/dist/esm/transport/split.js.map +1 -1
- package/dist/esm/utils/bigint.js.map +1 -1
- package/dist/esm/utils/bytes.js.map +1 -1
- package/dist/esm/utils/defaults.d.ts +2 -4
- package/dist/esm/utils/defaults.js +1 -40
- package/dist/esm/utils/defaults.js.map +1 -1
- package/dist/esm/utils/index.d.ts +0 -3
- package/dist/esm/utils/index.js +0 -11
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/types.js.map +1 -1
- package/dist/esm/utils/userop.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/account/smartContractAccount.d.ts +17 -11
- package/dist/types/account/smartContractAccount.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/buildUserOperationFromTx.d.ts +33 -33
- package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts +43 -59
- package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/checkGasSponsorshipEligibility.d.ts +18 -18
- package/dist/types/actions/smartAccount/estimateUserOperationGas.d.ts +3 -3
- package/dist/types/actions/smartAccount/internal/initUserOperation.d.ts +3 -4
- package/dist/types/actions/smartAccount/internal/initUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/internal/runMiddlewareStack.d.ts +0 -14
- package/dist/types/actions/smartAccount/internal/runMiddlewareStack.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/internal/sendUserOperation.d.ts +0 -7
- package/dist/types/actions/smartAccount/internal/sendUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/sendUserOperation.d.ts +17 -3
- package/dist/types/actions/smartAccount/sendUserOperation.d.ts.map +1 -1
- package/dist/types/client/bundlerClient.d.ts +2 -2
- package/dist/types/client/decorators/bundlerClient.d.ts +8 -8
- package/dist/types/client/isSmartAccountClient.d.ts +4 -4
- package/dist/types/client/types.d.ts +2 -7
- package/dist/types/client/types.d.ts.map +1 -1
- package/dist/types/ens/utils.d.ts +1 -1
- package/dist/types/ens/utils.d.ts.map +1 -1
- package/dist/types/errors/account.d.ts +53 -4
- package/dist/types/errors/account.d.ts.map +1 -1
- package/dist/types/errors/client.d.ts +15 -0
- package/dist/types/errors/client.d.ts.map +1 -1
- package/dist/types/errors/entrypoint.d.ts +12 -0
- package/dist/types/errors/entrypoint.d.ts.map +1 -1
- package/dist/types/errors/signer.d.ts +5 -0
- package/dist/types/errors/signer.d.ts.map +1 -1
- package/dist/types/errors/transaction.d.ts +8 -1
- package/dist/types/errors/transaction.d.ts.map +1 -1
- package/dist/types/errors/useroperation.d.ts +5 -5
- package/dist/types/errors/useroperation.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logger.d.ts +88 -0
- package/dist/types/logger.d.ts.map +1 -1
- package/dist/types/middleware/actions.d.ts +3 -3
- package/dist/types/middleware/actions.d.ts.map +1 -1
- package/dist/types/middleware/defaults/gasEstimator.d.ts +2 -2
- package/dist/types/middleware/defaults/gasEstimator.d.ts.map +1 -1
- package/dist/types/middleware/erc7677middleware.d.ts +62 -0
- package/dist/types/middleware/erc7677middleware.d.ts.map +1 -0
- package/dist/types/middleware/noopMiddleware.d.ts +4 -4
- package/dist/types/middleware/noopMiddleware.d.ts.map +1 -1
- package/dist/types/middleware/types.d.ts +3 -2
- package/dist/types/middleware/types.d.ts.map +1 -1
- package/dist/types/signer/local-account.d.ts +137 -45
- package/dist/types/signer/local-account.d.ts.map +1 -1
- package/dist/types/signer/wallet-client.d.ts +133 -44
- package/dist/types/signer/wallet-client.d.ts.map +1 -1
- package/dist/types/transport/split.d.ts +2 -2
- package/dist/types/utils/bigint.d.ts +14 -14
- package/dist/types/utils/bigint.d.ts.map +1 -1
- package/dist/types/utils/bytes.d.ts +5 -5
- package/dist/types/utils/defaults.d.ts +2 -12
- package/dist/types/utils/defaults.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +12 -22
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/types.d.ts +2 -2
- package/dist/types/utils/userop.d.ts +33 -33
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/account/smartContractAccount.ts +19 -13
- package/src/actions/smartAccount/buildUserOperationFromTx.ts +35 -35
- package/src/actions/smartAccount/buildUserOperationFromTxs.ts +44 -60
- package/src/actions/smartAccount/checkGasSponsorshipEligibility.ts +19 -19
- package/src/actions/smartAccount/estimateUserOperationGas.ts +3 -3
- package/src/actions/smartAccount/internal/initUserOperation.ts +3 -4
- package/src/actions/smartAccount/internal/runMiddlewareStack.ts +0 -22
- package/src/actions/smartAccount/internal/sendUserOperation.ts +0 -7
- package/src/actions/smartAccount/sendUserOperation.ts +17 -3
- package/src/client/bundlerClient.ts +2 -2
- package/src/client/decorators/bundlerClient.ts +8 -8
- package/src/client/isSmartAccountClient.ts +4 -4
- package/src/client/types.ts +2 -15
- package/src/ens/utils.ts +1 -2
- package/src/errors/account.ts +64 -4
- package/src/errors/client.ts +18 -0
- package/src/errors/entrypoint.ts +12 -0
- package/src/errors/signer.ts +6 -0
- package/src/errors/transaction.ts +10 -1
- package/src/errors/useroperation.ts +5 -6
- package/src/index.ts +2 -31
- package/src/logger.ts +88 -0
- package/src/middleware/actions.ts +6 -27
- package/src/middleware/defaults/gasEstimator.ts +9 -5
- package/src/middleware/erc7677middleware.ts +201 -0
- package/src/middleware/noopMiddleware.ts +6 -4
- package/src/middleware/types.ts +16 -7
- package/src/signer/local-account.ts +94 -2
- package/src/signer/wallet-client.ts +89 -0
- package/src/transport/split.ts +2 -2
- package/src/utils/bigint.ts +15 -15
- package/src/utils/bytes.ts +5 -5
- package/src/utils/defaults.ts +3 -76
- package/src/utils/index.ts +12 -35
- package/src/utils/types.ts +2 -2
- package/src/utils/userop.ts +33 -33
- package/src/version.ts +1 -1
- package/dist/cjs/account/base.d.ts +0 -49
- package/dist/cjs/account/base.js +0 -257
- package/dist/cjs/account/base.js.map +0 -1
- package/dist/cjs/account/schema.d.ts +0 -100
- package/dist/cjs/account/schema.js +0 -43
- package/dist/cjs/account/schema.js.map +0 -1
- package/dist/cjs/account/simple.d.ts +0 -14
- package/dist/cjs/account/simple.js +0 -119
- package/dist/cjs/account/simple.js.map +0 -1
- package/dist/cjs/account/types.d.ts +0 -30
- package/dist/cjs/account/types.js +0 -3
- package/dist/cjs/account/types.js.map +0 -1
- package/dist/cjs/chains/index.d.ts +0 -20
- package/dist/cjs/chains/index.js +0 -169
- package/dist/cjs/chains/index.js.map +0 -1
- package/dist/esm/account/base.d.ts +0 -49
- package/dist/esm/account/base.js +0 -253
- package/dist/esm/account/base.js.map +0 -1
- package/dist/esm/account/schema.d.ts +0 -100
- package/dist/esm/account/schema.js +0 -35
- package/dist/esm/account/schema.js.map +0 -1
- package/dist/esm/account/simple.d.ts +0 -14
- package/dist/esm/account/simple.js +0 -115
- package/dist/esm/account/simple.js.map +0 -1
- package/dist/esm/account/types.d.ts +0 -30
- package/dist/esm/account/types.js +0 -2
- package/dist/esm/account/types.js.map +0 -1
- package/dist/esm/chains/index.d.ts +0 -20
- package/dist/esm/chains/index.js +0 -166
- package/dist/esm/chains/index.js.map +0 -1
- package/dist/types/account/base.d.ts +0 -128
- package/dist/types/account/base.d.ts.map +0 -1
- package/dist/types/account/schema.d.ts +0 -101
- package/dist/types/account/schema.d.ts.map +0 -1
- package/dist/types/account/simple.d.ts +0 -15
- package/dist/types/account/simple.d.ts.map +0 -1
- package/dist/types/account/types.d.ts +0 -144
- package/dist/types/account/types.d.ts.map +0 -1
- package/dist/types/chains/index.d.ts +0 -21
- package/dist/types/chains/index.d.ts.map +0 -1
- package/src/account/base.ts +0 -415
- package/src/account/schema.ts +0 -51
- package/src/account/simple.ts +0 -221
- package/src/account/types.ts +0 -184
- package/src/chains/index.ts +0 -194
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simple.js","sourceRoot":"","sources":["../../../src/account/simple.ts"],"names":[],"mappings":";;;AACA,+BAQc;AACd,2EAAqE;AACrE,2EAAqE;AACrE,mFAA6E;AAC7E,iEAAiE;AACjE,qDAGgC;AAMhC,qDAAiE;AAG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AC;QAC9D,cAAc,EAAE,YAAY,CAAC,cAAc;KAC5C,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,IAAI;QACP,SAAS,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE;KAC3C,CAAC;AACJ,CAAC;AAzDD,4DAyDC","sourcesContent":["import type { Address } from \"abitype\";\nimport {\n concatHex,\n encodeFunctionData,\n isHex,\n type Chain,\n type FallbackTransport,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { SimpleAccountAbi_v6 } from \"../abis/SimpleAccountAbi_v6.js\";\nimport { SimpleAccountAbi_v7 } from \"../abis/SimpleAccountAbi_v7.js\";\nimport { SimpleAccountFactoryAbi } from \"../abis/SimpleAccountFactoryAbi.js\";\nimport { createBundlerClient } from \"../client/bundlerClient.js\";\nimport {\n defaultEntryPointVersion,\n getEntryPoint,\n} from \"../entrypoint/index.js\";\nimport type {\n DefaultEntryPointVersion,\n EntryPointParameter,\n EntryPointVersion,\n} from \"../entrypoint/types.js\";\nimport { AccountRequiresOwnerError } from \"../errors/account.js\";\nimport type { SmartAccountSigner } from \"../signer/types.js\";\nimport type { BatchUserOperationCallData } from \"../types.js\";\nimport { getDefaultSimpleAccountFactoryAddress } from \"../utils/defaults.js\";\nimport { BaseSmartContractAccount } from \"./base.js\";\nimport { SimpleSmartAccountParamsSchema } from \"./schema.js\";\nimport {\n toSmartContractAccount,\n type SmartContractAccountWithSigner,\n type ToSmartContractAccountParams,\n} from \"./smartContractAccount.js\";\nimport type { SimpleSmartAccountParams } from \"./types.js\";\n\nclass SimpleSmartContractAccount<\n TTransport extends Transport | FallbackTransport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> extends BaseSmartContractAccount<TTransport, TSigner> {\n protected index: bigint;\n protected entryPointVersion: EntryPointVersion;\n\n constructor(params: SimpleSmartAccountParams<TTransport, TSigner>) {\n SimpleSmartAccountParamsSchema().parse(params);\n\n // This is a hack for now, we should kill the SimpleSmart Account when we kill Base Account\n const client = createBundlerClient({\n transport: params.transport as TTransport,\n chain: params.chain,\n });\n\n // @ts-expect-error zod custom type not recognized as required params for signers\n super({ ...params, rpcClient: client });\n this.signer = params.signer as TSigner;\n this.index = params.salt ?? 0n;\n this.entryPointVersion =\n params.entryPointVersion ?? defaultEntryPointVersion;\n }\n\n getDummySignature(): `0x${string}` {\n return \"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\n }\n\n async encodeExecute(\n target: Hex,\n value: bigint,\n data: Hex\n ): Promise<`0x${string}`> {\n return encodeFunctionData({\n abi:\n this.entryPointVersion === \"0.6.0\"\n ? SimpleAccountAbi_v6\n : SimpleAccountAbi_v7,\n functionName: \"execute\",\n args: [target, value, data],\n });\n }\n\n override async encodeBatchExecute(\n txs: BatchUserOperationCallData\n ): Promise<`0x${string}`> {\n const [targets, datas] = txs.reduce(\n (accum, curr) => {\n accum[0].push(curr.target);\n accum[1].push(curr.data);\n\n return accum;\n },\n [[], []] as [Address[], Hex[]]\n );\n\n return encodeFunctionData({\n abi:\n this.entryPointVersion === \"0.6.0\"\n ? SimpleAccountAbi_v6\n : SimpleAccountAbi_v7,\n functionName: \"executeBatch\",\n args: [targets, datas],\n });\n }\n\n signMessage(msg: Uint8Array | string): Promise<`0x${string}`> {\n return this.signer.signMessage(\n typeof msg === \"string\" && !isHex(msg) ? msg : { raw: msg }\n );\n }\n\n public async getAccountInitCode(): Promise<`0x${string}`> {\n return concatHex([\n this.factoryAddress,\n encodeFunctionData({\n abi: SimpleAccountFactoryAbi,\n functionName: \"createAccount\",\n args: [await this.signer.getAddress(), this.index],\n }),\n ]);\n }\n}\n\nexport type SimpleSmartAccount<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = SmartContractAccountWithSigner<\n \"SimpleAccount\",\n TSigner,\n TEntryPointVersion\n>;\n\nexport type CreateSimpleAccountParams<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion\n> = Pick<\n ToSmartContractAccountParams<\n \"SimpleAccount\",\n TTransport,\n Chain,\n TEntryPointVersion\n >,\n \"chain\" | \"transport\"\n> & {\n signer: TSigner;\n salt?: bigint;\n accountAddress?: Address;\n factoryAddress?: Address;\n initCode?: Hex;\n} & EntryPointParameter<TEntryPointVersion, Chain>;\n\nexport async function createSimpleSmartAccount<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion\n>(\n config: CreateSimpleAccountParams<TTransport, TSigner, TEntryPointVersion>\n): Promise<SimpleSmartAccount<TSigner, TEntryPointVersion>>;\n\n/**\n * Creates a simple smart account using the provided parameters, including chain, entry point, factory address, and additional parameters. This function also ensures that a signer is provided.\n *\n * @param {CreateSimpleAccountParams} config The parameters for creating a simple smart account\n * @returns {Promise<SimpleSmartAccount>} A promise that resolves to a `SimpleSmartAccount` object containing the created account information and methods\n */\nexport async function createSimpleSmartAccount({\n chain,\n entryPoint = getEntryPoint(chain),\n factoryAddress = getDefaultSimpleAccountFactoryAddress(\n chain,\n entryPoint.version\n ),\n ...params\n}: CreateSimpleAccountParams): Promise<SimpleSmartAccount> {\n if (!params.signer) throw new AccountRequiresOwnerError(\"SimpleAccount\");\n const simpleAccount = new SimpleSmartContractAccount(\n SimpleSmartAccountParamsSchema().parse({\n chain,\n entryPointAddress: entryPoint.address,\n factoryAddress,\n ...params,\n })\n );\n\n const parsedParams = SimpleSmartAccountParamsSchema().parse({\n chain,\n entryPointAddress: entryPoint.address,\n entryPointVersion: entryPoint.version,\n factoryAddress,\n ...params,\n });\n\n const base = await toSmartContractAccount({\n source: \"SimpleAccount\",\n transport: params.transport,\n chain,\n encodeBatchExecute: simpleAccount.encodeBatchExecute.bind(simpleAccount),\n encodeExecute: (tx) =>\n simpleAccount.encodeExecute.bind(simpleAccount)(\n tx.target,\n tx.value ?? 0n,\n tx.data\n ),\n entryPoint,\n getAccountInitCode: async () => {\n if (parsedParams.initCode) return parsedParams.initCode as Hex;\n return simpleAccount.getAccountInitCode();\n },\n getDummySignature: simpleAccount.getDummySignature.bind(simpleAccount),\n signMessage: ({ message }) =>\n simpleAccount.signMessage(\n typeof message === \"string\" ? message : message.raw\n ),\n // @ts-expect-error these types still represent the same thing, but they are just a little off in there definitions\n signTypedData: simpleAccount.signTypedData.bind(simpleAccount),\n accountAddress: parsedParams.accountAddress,\n });\n\n return {\n ...base,\n getSigner: () => simpleAccount.getSigner(),\n };\n}\n"]}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Address } from "abitype";
|
|
2
|
-
import type { Hash, Hex, HttpTransport, Transport } from "viem";
|
|
3
|
-
import type { SignTypedDataParameters } from "viem/accounts";
|
|
4
|
-
import type { z } from "zod";
|
|
5
|
-
import type { BundlerClient } from "../client/bundlerClient";
|
|
6
|
-
import type { SmartAccountSigner } from "../signer/types";
|
|
7
|
-
import type { BatchUserOperationCallData } from "../types";
|
|
8
|
-
import type { SimpleSmartAccountParamsSchema, createBaseSmartAccountParamsSchema } from "./schema";
|
|
9
|
-
export type SignTypedDataParams = Omit<SignTypedDataParameters, "privateKey">;
|
|
10
|
-
export type BaseSmartAccountParams<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner> = z.input<ReturnType<typeof createBaseSmartAccountParamsSchema<TTransport, TSigner>>>;
|
|
11
|
-
export type SimpleSmartAccountParams<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner> = z.input<ReturnType<typeof SimpleSmartAccountParamsSchema<TTransport, TSigner>>>;
|
|
12
|
-
export interface ISmartContractAccount<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner> {
|
|
13
|
-
readonly rpcProvider: BundlerClient<TTransport> | BundlerClient<HttpTransport>;
|
|
14
|
-
getInitCode(): Promise<Hex>;
|
|
15
|
-
getDummySignature(): Hex | Promise<Hex>;
|
|
16
|
-
encodeExecute(target: string, value: bigint, data: string): Promise<Hex>;
|
|
17
|
-
encodeBatchExecute(txs: BatchUserOperationCallData): Promise<Hex>;
|
|
18
|
-
getNonce(): Promise<bigint>;
|
|
19
|
-
signUserOperationHash(uoHash: Hash): Promise<Hash>;
|
|
20
|
-
signMessage(msg: string | Uint8Array | Hex): Promise<Hex>;
|
|
21
|
-
signTypedData(params: SignTypedDataParams): Promise<Hash>;
|
|
22
|
-
signMessageWith6492(msg: string | Uint8Array | Hex): Promise<Hex>;
|
|
23
|
-
signTypedDataWith6492(params: SignTypedDataParams): Promise<Hash>;
|
|
24
|
-
getAddress(): Promise<Address>;
|
|
25
|
-
getSigner(): TSigner;
|
|
26
|
-
getFactoryAddress(): Address;
|
|
27
|
-
getEntryPointAddress(): Address;
|
|
28
|
-
extend: <R>(extendFn: (self: this) => R) => this & R;
|
|
29
|
-
encodeUpgradeToAndCall: (upgradeToImplAddress: Address, upgradeToInitData: Hex) => Promise<Hex>;
|
|
30
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/account/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Address } from \"abitype\";\nimport type { Hash, Hex, HttpTransport, Transport } from \"viem\";\nimport type { SignTypedDataParameters } from \"viem/accounts\";\nimport type { z } from \"zod\";\nimport type { BundlerClient } from \"../client/bundlerClient\";\nimport type { SmartAccountSigner } from \"../signer/types\";\nimport type { BatchUserOperationCallData } from \"../types\";\nimport type {\n SimpleSmartAccountParamsSchema,\n createBaseSmartAccountParamsSchema,\n} from \"./schema\";\n\n/** @deprecated */\nexport type SignTypedDataParams = Omit<SignTypedDataParameters, \"privateKey\">;\n\n/**\n * @deprecated don't use base smart account anymore, migrate to using toSmartContractAccount instead\n */\nexport type BaseSmartAccountParams<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = z.input<\n ReturnType<typeof createBaseSmartAccountParamsSchema<TTransport, TSigner>>\n>;\n\nexport type SimpleSmartAccountParams<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = z.input<\n ReturnType<typeof SimpleSmartAccountParamsSchema<TTransport, TSigner>>\n>;\n\n/**\n * @deprecated use `toSmartContractAccount` instead for creating instances of smart accounts\n */\nexport interface ISmartContractAccount<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> {\n /**\n * The RPC provider the account uses to make RPC calls\n */\n readonly rpcProvider:\n | BundlerClient<TTransport>\n | BundlerClient<HttpTransport>;\n\n /**\n * @returns the init code for the account\n */\n getInitCode(): Promise<Hex>;\n\n /**\n * This is useful for estimating gas costs. It should return a signature that doesn't cause the account to revert\n * when validation is run during estimation.\n *\n * @returns a dummy signature that doesn't cause the account to revert during estimation\n */\n getDummySignature(): Hex | Promise<Hex>;\n\n /**\n * Encodes a call to the account's execute function.\n *\n * @param target - the address receiving the call data\n * @param value - optionally the amount of native token to send\n * @param data - the call data or \"0x\" if empty\n */\n encodeExecute(target: string, value: bigint, data: string): Promise<Hex>;\n\n /**\n * Encodes a batch of transactions to the account's batch execute function.\n * NOTE: not all accounts support batching.\n *\n * @param txs - An Array of objects containing the target, value, and data for each transaction\n * @returns the encoded callData for a UserOperation\n */\n encodeBatchExecute(txs: BatchUserOperationCallData): Promise<Hex>;\n\n /**\n * @returns the nonce of the account\n */\n getNonce(): Promise<bigint>;\n\n /**\n * If your account handles 1271 signatures of personal_sign differently\n * than it does UserOperations, you can implement two different approaches to signing\n *\n * @param uoHash -- The hash of the UserOperation to sign\n * @returns the signature of the UserOperation\n */\n signUserOperationHash(uoHash: Hash): Promise<Hash>;\n\n /**\n * Returns a signed and prefixed message.\n *\n * @param msg - the message to sign\n * @returns the signature of the message\n */\n signMessage(msg: string | Uint8Array | Hex): Promise<Hex>;\n\n /**\n * Signs a typed data object as per ERC-712\n *\n * @param params - {@link SignTypedDataParams}\n * @returns the signed hash for the message passed\n */\n signTypedData(params: SignTypedDataParams): Promise<Hash>;\n\n /**\n * If the account is not deployed, it will sign the message and then wrap it in 6492 format\n *\n * @param msg - the message to sign\n * @returns ths signature wrapped in 6492 format\n */\n signMessageWith6492(msg: string | Uint8Array | Hex): Promise<Hex>;\n\n /**\n * If the account is not deployed, it will sign the typed data blob and then wrap it in 6492 format\n *\n * @param params - {@link SignTypedDataParams}\n * @returns the signed hash for the params passed in wrapped in 6492 format\n */\n signTypedDataWith6492(params: SignTypedDataParams): Promise<Hash>;\n\n /**\n * @returns the address of the account\n */\n getAddress(): Promise<Address>;\n\n /**\n * @returns the current account signer instance that the smart account client\n * operations are being signed with.\n *\n * The signer is expected to be the owner or one of the owners of the account\n * for the signatures to be valid for the acting account.\n */\n getSigner(): TSigner;\n\n /**\n * The factory address of the smart account created by the factory\n *\n * @returns the address of the factory contract for the smart account\n */\n getFactoryAddress(): Address;\n\n /**\n * The entrypoint address is the address ERC 4337 entrypoint singleton contract\n * that this smart account and the connected bundler client use\n *\n * @returns the address of the entry point contract for the smart account\n */\n getEntryPointAddress(): Address;\n\n /**\n * Allows you to add additional functionality and utility methods to this account\n * via a decorator pattern.\n *\n * NOTE: this method does not allow you to override existing methods on the account.\n *\n * @example\n * ```ts\n * const account = new BaseSmartCobntractAccount(...).extend((account) => ({\n * readAccountState: async (...args) => {\n * return this.rpcProvider.readContract({\n * address: await this.getAddress(),\n * abi: ThisContractsAbi\n * args: args\n * });\n * }\n * }));\n *\n * account.debugSendUserOperation(...);\n * ```\n *\n * @param extendFn -- this function gives you access to the created account instance and returns an object\n * with the extension methods\n * @returns -- the account with the extension methods added\n */\n extend: <R>(extendFn: (self: this) => R) => this & R;\n\n encodeUpgradeToAndCall: (\n upgradeToImplAddress: Address,\n upgradeToInitData: Hex\n ) => Promise<Hex>;\n}\n"]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type Chain } from "viem";
|
|
2
|
-
export declare const arbitrum: Chain;
|
|
3
|
-
export declare const arbitrumGoerli: Chain;
|
|
4
|
-
export declare const arbitrumSepolia: Chain;
|
|
5
|
-
export declare const goerli: Chain;
|
|
6
|
-
export declare const mainnet: Chain;
|
|
7
|
-
export declare const optimism: Chain;
|
|
8
|
-
export declare const optimismGoerli: Chain;
|
|
9
|
-
export declare const optimismSepolia: Chain;
|
|
10
|
-
export declare const sepolia: Chain;
|
|
11
|
-
export declare const base: Chain;
|
|
12
|
-
export declare const baseGoerli: Chain;
|
|
13
|
-
export declare const baseSepolia: Chain;
|
|
14
|
-
export declare const polygonMumbai: Chain;
|
|
15
|
-
export declare const polygonAmoy: Chain;
|
|
16
|
-
export declare const polygon: Chain;
|
|
17
|
-
export declare const fraxtal: Chain;
|
|
18
|
-
export declare const fraxtalSepolia: Chain;
|
|
19
|
-
export declare const zora: Chain;
|
|
20
|
-
export declare const zoraSepolia: Chain;
|
package/dist/cjs/chains/index.js
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.zoraSepolia = exports.zora = exports.fraxtalSepolia = exports.fraxtal = exports.polygon = exports.polygonAmoy = exports.polygonMumbai = exports.baseSepolia = exports.baseGoerli = exports.base = exports.sepolia = exports.optimismSepolia = exports.optimismGoerli = exports.optimism = exports.mainnet = exports.goerli = exports.arbitrumSepolia = exports.arbitrumGoerli = exports.arbitrum = void 0;
|
|
4
|
-
const viem_1 = require("viem");
|
|
5
|
-
const chains_1 = require("viem/chains");
|
|
6
|
-
exports.arbitrum = {
|
|
7
|
-
...chains_1.arbitrum,
|
|
8
|
-
rpcUrls: {
|
|
9
|
-
...chains_1.arbitrum.rpcUrls,
|
|
10
|
-
alchemy: {
|
|
11
|
-
http: ["https://arb-mainnet.g.alchemy.com/v2"],
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
exports.arbitrumGoerli = {
|
|
16
|
-
...chains_1.arbitrumGoerli,
|
|
17
|
-
rpcUrls: {
|
|
18
|
-
...chains_1.arbitrumGoerli.rpcUrls,
|
|
19
|
-
alchemy: {
|
|
20
|
-
http: ["https://arb-goerli.g.alchemy.com/v2"],
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
exports.arbitrumSepolia = {
|
|
25
|
-
...chains_1.arbitrumSepolia,
|
|
26
|
-
rpcUrls: {
|
|
27
|
-
...chains_1.arbitrumSepolia.rpcUrls,
|
|
28
|
-
alchemy: {
|
|
29
|
-
http: ["https://arb-sepolia.g.alchemy.com/v2"],
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
exports.goerli = {
|
|
34
|
-
...chains_1.goerli,
|
|
35
|
-
rpcUrls: {
|
|
36
|
-
...chains_1.goerli.rpcUrls,
|
|
37
|
-
alchemy: {
|
|
38
|
-
http: ["https://eth-goerli.g.alchemy.com/v2"],
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
exports.mainnet = {
|
|
43
|
-
...chains_1.mainnet,
|
|
44
|
-
rpcUrls: {
|
|
45
|
-
...chains_1.mainnet.rpcUrls,
|
|
46
|
-
alchemy: {
|
|
47
|
-
http: ["https://eth-mainnet.g.alchemy.com/v2"],
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
exports.optimism = {
|
|
52
|
-
...chains_1.optimism,
|
|
53
|
-
rpcUrls: {
|
|
54
|
-
...chains_1.optimism.rpcUrls,
|
|
55
|
-
alchemy: {
|
|
56
|
-
http: ["https://opt-mainnet.g.alchemy.com/v2"],
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
exports.optimismGoerli = {
|
|
61
|
-
...chains_1.optimismGoerli,
|
|
62
|
-
rpcUrls: {
|
|
63
|
-
...chains_1.optimismGoerli.rpcUrls,
|
|
64
|
-
alchemy: {
|
|
65
|
-
http: ["https://opt-goerli.g.alchemy.com/v2"],
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
exports.optimismSepolia = {
|
|
70
|
-
...chains_1.optimismSepolia,
|
|
71
|
-
rpcUrls: {
|
|
72
|
-
...chains_1.optimismSepolia.rpcUrls,
|
|
73
|
-
alchemy: {
|
|
74
|
-
http: ["https://opt-sepolia.g.alchemy.com/v2"],
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
exports.sepolia = {
|
|
79
|
-
...chains_1.sepolia,
|
|
80
|
-
rpcUrls: {
|
|
81
|
-
...chains_1.sepolia.rpcUrls,
|
|
82
|
-
alchemy: {
|
|
83
|
-
http: ["https://eth-sepolia.g.alchemy.com/v2"],
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
exports.base = {
|
|
88
|
-
...chains_1.base,
|
|
89
|
-
rpcUrls: {
|
|
90
|
-
...chains_1.base.rpcUrls,
|
|
91
|
-
alchemy: {
|
|
92
|
-
http: ["https://base-mainnet.g.alchemy.com/v2"],
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
exports.baseGoerli = {
|
|
97
|
-
...chains_1.baseGoerli,
|
|
98
|
-
rpcUrls: {
|
|
99
|
-
...chains_1.baseGoerli.rpcUrls,
|
|
100
|
-
alchemy: {
|
|
101
|
-
http: ["https://base-goerli.g.alchemy.com/v2"],
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
exports.baseSepolia = {
|
|
106
|
-
...chains_1.baseSepolia,
|
|
107
|
-
rpcUrls: {
|
|
108
|
-
...chains_1.baseSepolia.rpcUrls,
|
|
109
|
-
alchemy: {
|
|
110
|
-
http: ["https://base-sepolia.g.alchemy.com/v2"],
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
exports.polygonMumbai = {
|
|
115
|
-
...chains_1.polygonMumbai,
|
|
116
|
-
rpcUrls: {
|
|
117
|
-
...chains_1.polygonMumbai.rpcUrls,
|
|
118
|
-
alchemy: {
|
|
119
|
-
http: ["https://polygon-mumbai.g.alchemy.com/v2"],
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
exports.polygonAmoy = {
|
|
124
|
-
...chains_1.polygonAmoy,
|
|
125
|
-
rpcUrls: {
|
|
126
|
-
...chains_1.polygonAmoy.rpcUrls,
|
|
127
|
-
alchemy: {
|
|
128
|
-
http: ["https://polygon-amoy.g.alchemy.com/v2"],
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
exports.polygon = {
|
|
133
|
-
...chains_1.polygon,
|
|
134
|
-
rpcUrls: {
|
|
135
|
-
...chains_1.polygon.rpcUrls,
|
|
136
|
-
alchemy: {
|
|
137
|
-
http: ["https://polygon-mainnet.g.alchemy.com/v2"],
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
exports.fraxtal = {
|
|
142
|
-
...chains_1.fraxtal,
|
|
143
|
-
rpcUrls: {
|
|
144
|
-
...chains_1.fraxtal.rpcUrls,
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
|
-
exports.fraxtalSepolia = (0, viem_1.defineChain)({
|
|
148
|
-
id: 2523,
|
|
149
|
-
name: "Fraxtal Sepolia",
|
|
150
|
-
nativeCurrency: { name: "Frax Ether", symbol: "frxETH", decimals: 18 },
|
|
151
|
-
rpcUrls: {
|
|
152
|
-
default: {
|
|
153
|
-
http: ["https://rpc.testnet-sepolia.frax.com"],
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
});
|
|
157
|
-
exports.zora = {
|
|
158
|
-
...chains_1.zora,
|
|
159
|
-
rpcUrls: {
|
|
160
|
-
...chains_1.zora.rpcUrls,
|
|
161
|
-
},
|
|
162
|
-
};
|
|
163
|
-
exports.zoraSepolia = {
|
|
164
|
-
...chains_1.zoraSepolia,
|
|
165
|
-
rpcUrls: {
|
|
166
|
-
...chains_1.zoraSepolia.rpcUrls,
|
|
167
|
-
},
|
|
168
|
-
};
|
|
169
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/chains/index.ts"],"names":[],"mappings":";;;AAAA,+BAA+C;AAC/C,wCAmBqB;AAER,QAAA,QAAQ,GAAU;IAC7B,GAAG,iBAAG;IACN,OAAO,EAAE;QACP,GAAG,iBAAG,CAAC,OAAO;QACd,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,sCAAsC,CAAC;SAC/C;KACF;CACF,CAAC;AAEW,QAAA,cAAc,GAAU;IACnC,GAAG,uBAAI;IACP,OAAO,EAAE;QACP,GAAG,uBAAI,CAAC,OAAO;QACf,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,qCAAqC,CAAC;SAC9C;KACF;CACF,CAAC;AAEW,QAAA,eAAe,GAAU;IACpC,GAAG,wBAAI;IACP,OAAO,EAAE;QACP,GAAG,wBAAI,CAAC,OAAO;QACf,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,sCAAsC,CAAC;SAC/C;KACF;CACF,CAAC;AACW,QAAA,MAAM,GAAU;IAC3B,GAAG,eAAG;IACN,OAAO,EAAE;QACP,GAAG,eAAG,CAAC,OAAO;QACd,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,qCAAqC,CAAC;SAC9C;KACF;CACF,CAAC;AACW,QAAA,OAAO,GAAU;IAC5B,GAAG,gBAAK;IACR,OAAO,EAAE;QACP,GAAG,gBAAK,CAAC,OAAO;QAChB,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,sCAAsC,CAAC;SAC/C;KACF;CACF,CAAC;AACW,QAAA,QAAQ,GAAU;IAC7B,GAAG,iBAAG;IACN,OAAO,EAAE;QACP,GAAG,iBAAG,CAAC,OAAO;QACd,OAAO,E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W,QAAA,WAAW,GAAU;IAChC,GAAG,oBAAI;IACP,OAAO,EAAE;QACP,GAAG,oBAAI,CAAC,OAAO;QACf,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,uCAAuC,CAAC;SAChD;KACF;CACF,CAAC;AAEW,QAAA,OAAO,GAAU;IAC5B,GAAG,gBAAG;IACN,OAAO,EAAE;QACP,GAAG,gBAAG,CAAC,OAAO;QACd,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,0CAA0C,CAAC;SACnD;KACF;CACF,CAAC;AAEW,QAAA,OAAO,GAAU;IAC5B,GAAG,gBAAK;IACR,OAAO,EAAE;QACP,GAAG,gBAAK,CAAC,OAAO;KACjB;CACF,CAAC;AAEW,QAAA,cAAc,GAAU,IAAA,kBAAW,EAAC;IAC/C,EAAE,EAAE,IAAI;IACR,IAAI,EAAE,iBAAiB;IACvB,cAAc,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE;IACtE,OAAO,EAAE;QACP,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,sCAAsC,CAAC;SAC/C;KACF;CACF,CAAC,CAAC;AAEU,QAAA,IAAI,GAAU;IACzB,GAAG,aAAK;IACR,OAAO,EAAE;QACP,GAAG,aAAK,CAAC,OAAO;KACjB;CACF,CAAC;AAEW,QAAA,WAAW,GAAU;IAChC,GAAG,oBAAM;IACT,OAAO,EAAE;QACP,GAAG,oBAAM,CAAC,OAAO;KAClB;CACF,CAAC","sourcesContent":["import { defineChain, type Chain } from \"viem\";\nimport {\n arbitrum as vab,\n arbitrumGoerli as vabg,\n arbitrumSepolia as vabs,\n base as vbase,\n baseGoerli as vbaseg,\n baseSepolia as vbases,\n goerli as vgo,\n mainnet as vmain,\n optimism as vop,\n optimismGoerli as vopg,\n optimismSepolia as vops,\n polygon as vpg,\n polygonMumbai as vpgm,\n polygonAmoy as vpga,\n sepolia as vsep,\n fraxtal as vfrax,\n zora as vzora,\n zoraSepolia as vzoras,\n} from \"viem/chains\";\n\nexport const arbitrum: Chain = {\n ...vab,\n rpcUrls: {\n ...vab.rpcUrls,\n alchemy: {\n http: [\"https://arb-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const arbitrumGoerli: Chain = {\n ...vabg,\n rpcUrls: {\n ...vabg.rpcUrls,\n alchemy: {\n http: [\"https://arb-goerli.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const arbitrumSepolia: Chain = {\n ...vabs,\n rpcUrls: {\n ...vabs.rpcUrls,\n alchemy: {\n http: [\"https://arb-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const goerli: Chain = {\n ...vgo,\n rpcUrls: {\n ...vgo.rpcUrls,\n alchemy: {\n http: [\"https://eth-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const mainnet: Chain = {\n ...vmain,\n rpcUrls: {\n ...vmain.rpcUrls,\n alchemy: {\n http: [\"https://eth-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimism: Chain = {\n ...vop,\n rpcUrls: {\n ...vop.rpcUrls,\n alchemy: {\n http: [\"https://opt-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimismGoerli: Chain = {\n ...vopg,\n rpcUrls: {\n ...vopg.rpcUrls,\n alchemy: {\n http: [\"https://opt-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimismSepolia: Chain = {\n ...vops,\n rpcUrls: {\n ...vops.rpcUrls,\n alchemy: {\n http: [\"https://opt-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const sepolia: Chain = {\n ...vsep,\n rpcUrls: {\n ...vsep.rpcUrls,\n alchemy: {\n http: [\"https://eth-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const base: Chain = {\n ...vbase,\n rpcUrls: {\n ...vbase.rpcUrls,\n alchemy: {\n http: [\"https://base-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const baseGoerli: Chain = {\n ...vbaseg,\n rpcUrls: {\n ...vbaseg.rpcUrls,\n alchemy: {\n http: [\"https://base-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const baseSepolia: Chain = {\n ...vbases,\n rpcUrls: {\n ...vbases.rpcUrls,\n alchemy: {\n http: [\"https://base-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygonMumbai: Chain = {\n ...vpgm,\n rpcUrls: {\n ...vpgm.rpcUrls,\n alchemy: {\n http: [\"https://polygon-mumbai.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygonAmoy: Chain = {\n ...vpga,\n rpcUrls: {\n ...vpga.rpcUrls,\n alchemy: {\n http: [\"https://polygon-amoy.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygon: Chain = {\n ...vpg,\n rpcUrls: {\n ...vpg.rpcUrls,\n alchemy: {\n http: [\"https://polygon-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const fraxtal: Chain = {\n ...vfrax,\n rpcUrls: {\n ...vfrax.rpcUrls,\n },\n};\n\nexport const fraxtalSepolia: Chain = defineChain({\n id: 2523,\n name: \"Fraxtal Sepolia\",\n nativeCurrency: { name: \"Frax Ether\", symbol: \"frxETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://rpc.testnet-sepolia.frax.com\"],\n },\n },\n});\n\nexport const zora: Chain = {\n ...vzora,\n rpcUrls: {\n ...vzora.rpcUrls,\n },\n};\n\nexport const zoraSepolia: Chain = {\n ...vzoras,\n rpcUrls: {\n ...vzoras.rpcUrls,\n },\n};\n"]}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { Address } from "abitype";
|
|
2
|
-
import { type GetContractReturnType, type Hash, type Hex, type HttpTransport, type PublicClient, type Transport } from "viem";
|
|
3
|
-
import { EntryPointAbi_v6 as EntryPointAbi } from "../abis/EntryPointAbi_v6.js";
|
|
4
|
-
import { type BundlerClient } from "../client/bundlerClient.js";
|
|
5
|
-
import type { SmartAccountSigner } from "../signer/types.js";
|
|
6
|
-
import type { BatchUserOperationCallData, NullAddress } from "../types.js";
|
|
7
|
-
import type { BaseSmartAccountParams, ISmartContractAccount, SignTypedDataParams } from "./types.js";
|
|
8
|
-
export declare enum DeploymentState {
|
|
9
|
-
UNDEFINED = "0x0",
|
|
10
|
-
NOT_DEPLOYED = "0x1",
|
|
11
|
-
DEPLOYED = "0x2"
|
|
12
|
-
}
|
|
13
|
-
export declare abstract class BaseSmartContractAccount<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner> implements ISmartContractAccount<TTransport, TSigner> {
|
|
14
|
-
protected factoryAddress: Address;
|
|
15
|
-
protected deploymentState: DeploymentState;
|
|
16
|
-
protected accountAddress?: Address;
|
|
17
|
-
protected accountInitCode?: Hex;
|
|
18
|
-
protected signer: TSigner;
|
|
19
|
-
protected entryPoint: GetContractReturnType<typeof EntryPointAbi, PublicClient>;
|
|
20
|
-
protected entryPointAddress: Address;
|
|
21
|
-
readonly rpcProvider: BundlerClient<TTransport> | BundlerClient<HttpTransport>;
|
|
22
|
-
constructor(params_: BaseSmartAccountParams<TTransport, TSigner>);
|
|
23
|
-
abstract getDummySignature(): Hex | Promise<Hex>;
|
|
24
|
-
abstract encodeExecute(target: string, value: bigint, data: string): Promise<Hash>;
|
|
25
|
-
abstract signMessage(msg: string | Uint8Array): Promise<Hash>;
|
|
26
|
-
protected abstract getAccountInitCode(): Promise<Hash>;
|
|
27
|
-
signUserOperationHash(uoHash: Hash): Promise<Hash>;
|
|
28
|
-
signTypedData(_params: SignTypedDataParams): Promise<`0x${string}`>;
|
|
29
|
-
signMessageWith6492(msg: string | Uint8Array): Promise<`0x${string}`>;
|
|
30
|
-
signTypedDataWith6492(params: SignTypedDataParams): Promise<`0x${string}`>;
|
|
31
|
-
encodeBatchExecute(_txs: BatchUserOperationCallData): Promise<`0x${string}`>;
|
|
32
|
-
encodeUpgradeToAndCall: (_upgradeToImplAddress: Address, _upgradeToInitData: Hex) => Promise<Hex>;
|
|
33
|
-
getNonce(): Promise<bigint>;
|
|
34
|
-
getInitCode(): Promise<Hex>;
|
|
35
|
-
getAddress(): Promise<Address>;
|
|
36
|
-
extend: <R>(fn: (self: this) => R) => this & R;
|
|
37
|
-
getSigner(): TSigner;
|
|
38
|
-
getFactoryAddress(): Address;
|
|
39
|
-
getEntryPointAddress(): Address;
|
|
40
|
-
isAccountDeployed(): Promise<boolean>;
|
|
41
|
-
getDeploymentState(): Promise<DeploymentState>;
|
|
42
|
-
protected parseFactoryAddressFromAccountInitCode(): Promise<[
|
|
43
|
-
Address,
|
|
44
|
-
Hex
|
|
45
|
-
]>;
|
|
46
|
-
protected getImplementationAddress(): Promise<NullAddress | Address>;
|
|
47
|
-
private _getAccountInitCode;
|
|
48
|
-
private create6492Signature;
|
|
49
|
-
}
|
package/dist/esm/account/base.js
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { getContract, http, trim, } from "viem";
|
|
2
|
-
import { EntryPointAbi_v6 as EntryPointAbi } from "../abis/EntryPointAbi_v6.js";
|
|
3
|
-
import { createBundlerClient, } from "../client/bundlerClient.js";
|
|
4
|
-
import { getEntryPoint } from "../entrypoint/index.js";
|
|
5
|
-
import { BatchExecutionNotSupportedError, FailedToGetStorageSlotError, GetCounterFactualAddressError, UpgradeToAndCallNotSupportedError, } from "../errors/account.js";
|
|
6
|
-
import { InvalidRpcUrlError } from "../errors/client.js";
|
|
7
|
-
import { Logger } from "../logger.js";
|
|
8
|
-
import { wrapSignatureWith6492 } from "../signer/utils.js";
|
|
9
|
-
import { createBaseSmartAccountParamsSchema } from "./schema.js";
|
|
10
|
-
export var DeploymentState;
|
|
11
|
-
(function (DeploymentState) {
|
|
12
|
-
DeploymentState["UNDEFINED"] = "0x0";
|
|
13
|
-
DeploymentState["NOT_DEPLOYED"] = "0x1";
|
|
14
|
-
DeploymentState["DEPLOYED"] = "0x2";
|
|
15
|
-
})(DeploymentState || (DeploymentState = {}));
|
|
16
|
-
export class BaseSmartContractAccount {
|
|
17
|
-
constructor(params_) {
|
|
18
|
-
Object.defineProperty(this, "factoryAddress", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
configurable: true,
|
|
21
|
-
writable: true,
|
|
22
|
-
value: void 0
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(this, "deploymentState", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
configurable: true,
|
|
27
|
-
writable: true,
|
|
28
|
-
value: DeploymentState.UNDEFINED
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(this, "accountAddress", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
configurable: true,
|
|
33
|
-
writable: true,
|
|
34
|
-
value: void 0
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(this, "accountInitCode", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
configurable: true,
|
|
39
|
-
writable: true,
|
|
40
|
-
value: void 0
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(this, "signer", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
configurable: true,
|
|
45
|
-
writable: true,
|
|
46
|
-
value: void 0
|
|
47
|
-
});
|
|
48
|
-
Object.defineProperty(this, "entryPoint", {
|
|
49
|
-
enumerable: true,
|
|
50
|
-
configurable: true,
|
|
51
|
-
writable: true,
|
|
52
|
-
value: void 0
|
|
53
|
-
});
|
|
54
|
-
Object.defineProperty(this, "entryPointAddress", {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
configurable: true,
|
|
57
|
-
writable: true,
|
|
58
|
-
value: void 0
|
|
59
|
-
});
|
|
60
|
-
Object.defineProperty(this, "rpcProvider", {
|
|
61
|
-
enumerable: true,
|
|
62
|
-
configurable: true,
|
|
63
|
-
writable: true,
|
|
64
|
-
value: void 0
|
|
65
|
-
});
|
|
66
|
-
Object.defineProperty(this, "encodeUpgradeToAndCall", {
|
|
67
|
-
enumerable: true,
|
|
68
|
-
configurable: true,
|
|
69
|
-
writable: true,
|
|
70
|
-
value: async (_upgradeToImplAddress, _upgradeToInitData) => {
|
|
71
|
-
throw new UpgradeToAndCallNotSupportedError("BaseAccount");
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
Object.defineProperty(this, "extend", {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
configurable: true,
|
|
77
|
-
writable: true,
|
|
78
|
-
value: (fn) => {
|
|
79
|
-
const extended = fn(this);
|
|
80
|
-
for (const key in this) {
|
|
81
|
-
delete extended[key];
|
|
82
|
-
}
|
|
83
|
-
return Object.assign(this, extended);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
const params = createBaseSmartAccountParamsSchema().parse(params_);
|
|
87
|
-
this.entryPointAddress =
|
|
88
|
-
params.entryPointAddress ?? getEntryPoint(params.chain).address;
|
|
89
|
-
const rpcUrl = typeof params.rpcClient === "string"
|
|
90
|
-
? params.rpcClient
|
|
91
|
-
: params.rpcClient.transport.type === "http"
|
|
92
|
-
? params.rpcClient.transport.url || params.chain.rpcUrls.default.http[0]
|
|
93
|
-
: undefined;
|
|
94
|
-
const fetchOptions = typeof params.rpcClient === "string"
|
|
95
|
-
? undefined
|
|
96
|
-
: params.rpcClient.transport.type === "http"
|
|
97
|
-
? params.rpcClient.transport.fetchOptions
|
|
98
|
-
: undefined;
|
|
99
|
-
this.rpcProvider = rpcUrl
|
|
100
|
-
? createBundlerClient({
|
|
101
|
-
chain: params.chain,
|
|
102
|
-
transport: http(rpcUrl, {
|
|
103
|
-
fetchOptions: {
|
|
104
|
-
...fetchOptions,
|
|
105
|
-
headers: {
|
|
106
|
-
...fetchOptions?.headers,
|
|
107
|
-
...(rpcUrl.toLowerCase().indexOf("alchemy") > -1
|
|
108
|
-
? {
|
|
109
|
-
"Alchemy-Aa-Sdk-Signer": params.signer?.signerType || "unknown",
|
|
110
|
-
"Alchemy-Aa-Sdk-Factory-Address": params.factoryAddress,
|
|
111
|
-
}
|
|
112
|
-
: undefined),
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
}),
|
|
116
|
-
})
|
|
117
|
-
: params.rpcClient;
|
|
118
|
-
this.accountAddress = params.accountAddress;
|
|
119
|
-
this.factoryAddress = params.factoryAddress;
|
|
120
|
-
this.signer = params.signer;
|
|
121
|
-
this.accountInitCode = params.initCode;
|
|
122
|
-
this.entryPoint = getContract({
|
|
123
|
-
address: this.entryPointAddress,
|
|
124
|
-
abi: EntryPointAbi,
|
|
125
|
-
client: this.rpcProvider,
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
async signUserOperationHash(uoHash) {
|
|
129
|
-
return this.signMessage(uoHash);
|
|
130
|
-
}
|
|
131
|
-
async signTypedData(_params) {
|
|
132
|
-
throw new Error("signTypedData not supported");
|
|
133
|
-
}
|
|
134
|
-
async signMessageWith6492(msg) {
|
|
135
|
-
const [isDeployed, signature] = await Promise.all([
|
|
136
|
-
this.isAccountDeployed(),
|
|
137
|
-
this.signMessage(msg),
|
|
138
|
-
]);
|
|
139
|
-
return this.create6492Signature(isDeployed, signature);
|
|
140
|
-
}
|
|
141
|
-
async signTypedDataWith6492(params) {
|
|
142
|
-
const [isDeployed, signature] = await Promise.all([
|
|
143
|
-
this.isAccountDeployed(),
|
|
144
|
-
this.signTypedData(params),
|
|
145
|
-
]);
|
|
146
|
-
return this.create6492Signature(isDeployed, signature);
|
|
147
|
-
}
|
|
148
|
-
async encodeBatchExecute(_txs) {
|
|
149
|
-
throw new BatchExecutionNotSupportedError("BaseAccount");
|
|
150
|
-
}
|
|
151
|
-
async getNonce() {
|
|
152
|
-
if (!(await this.isAccountDeployed())) {
|
|
153
|
-
return 0n;
|
|
154
|
-
}
|
|
155
|
-
const address = await this.getAddress();
|
|
156
|
-
return this.entryPoint.read.getNonce([address, BigInt(0)]);
|
|
157
|
-
}
|
|
158
|
-
async getInitCode() {
|
|
159
|
-
if (this.deploymentState === DeploymentState.DEPLOYED) {
|
|
160
|
-
return "0x";
|
|
161
|
-
}
|
|
162
|
-
const contractCode = await this.rpcProvider.getBytecode({
|
|
163
|
-
address: await this.getAddress(),
|
|
164
|
-
});
|
|
165
|
-
if ((contractCode?.length ?? 0) > 2) {
|
|
166
|
-
this.deploymentState = DeploymentState.DEPLOYED;
|
|
167
|
-
return "0x";
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
this.deploymentState = DeploymentState.NOT_DEPLOYED;
|
|
171
|
-
}
|
|
172
|
-
return this._getAccountInitCode();
|
|
173
|
-
}
|
|
174
|
-
async getAddress() {
|
|
175
|
-
if (!this.accountAddress) {
|
|
176
|
-
const initCode = await this._getAccountInitCode();
|
|
177
|
-
Logger.verbose("[BaseSmartContractAccount](getAddress) initCode: ", initCode);
|
|
178
|
-
try {
|
|
179
|
-
await this.entryPoint.simulate.getSenderAddress([initCode]);
|
|
180
|
-
}
|
|
181
|
-
catch (err) {
|
|
182
|
-
Logger.verbose("[BaseSmartContractAccount](getAddress) getSenderAddress err: ", err);
|
|
183
|
-
if (err.cause?.data?.errorName === "SenderAddressResult") {
|
|
184
|
-
this.accountAddress = err.cause.data.args[0];
|
|
185
|
-
Logger.verbose("[BaseSmartContractAccount](getAddress) entryPoint.getSenderAddress result:", this.accountAddress);
|
|
186
|
-
return this.accountAddress;
|
|
187
|
-
}
|
|
188
|
-
if (err.details === "Invalid URL") {
|
|
189
|
-
throw new InvalidRpcUrlError();
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
throw new GetCounterFactualAddressError();
|
|
193
|
-
}
|
|
194
|
-
return this.accountAddress;
|
|
195
|
-
}
|
|
196
|
-
getSigner() {
|
|
197
|
-
return this.signer;
|
|
198
|
-
}
|
|
199
|
-
getFactoryAddress() {
|
|
200
|
-
return this.factoryAddress;
|
|
201
|
-
}
|
|
202
|
-
getEntryPointAddress() {
|
|
203
|
-
return this.entryPointAddress;
|
|
204
|
-
}
|
|
205
|
-
async isAccountDeployed() {
|
|
206
|
-
return (await this.getDeploymentState()) === DeploymentState.DEPLOYED;
|
|
207
|
-
}
|
|
208
|
-
async getDeploymentState() {
|
|
209
|
-
if (this.deploymentState === DeploymentState.UNDEFINED) {
|
|
210
|
-
const initCode = await this.getInitCode();
|
|
211
|
-
return initCode === "0x"
|
|
212
|
-
? DeploymentState.DEPLOYED
|
|
213
|
-
: DeploymentState.NOT_DEPLOYED;
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
return this.deploymentState;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
async parseFactoryAddressFromAccountInitCode() {
|
|
220
|
-
const initCode = await this._getAccountInitCode();
|
|
221
|
-
const factoryAddress = `0x${initCode.substring(2, 42)}`;
|
|
222
|
-
const factoryCalldata = `0x${initCode.substring(42)}`;
|
|
223
|
-
return [factoryAddress, factoryCalldata];
|
|
224
|
-
}
|
|
225
|
-
async getImplementationAddress() {
|
|
226
|
-
const accountAddress = await this.getAddress();
|
|
227
|
-
const storage = await this.rpcProvider.getStorageAt({
|
|
228
|
-
address: accountAddress,
|
|
229
|
-
slot: "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc",
|
|
230
|
-
});
|
|
231
|
-
if (storage == null) {
|
|
232
|
-
throw new FailedToGetStorageSlotError("0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc", "Proxy Implementation Address");
|
|
233
|
-
}
|
|
234
|
-
return trim(storage);
|
|
235
|
-
}
|
|
236
|
-
async _getAccountInitCode() {
|
|
237
|
-
return this.accountInitCode ?? this.getAccountInitCode();
|
|
238
|
-
}
|
|
239
|
-
async create6492Signature(isDeployed, signature) {
|
|
240
|
-
if (isDeployed) {
|
|
241
|
-
return signature;
|
|
242
|
-
}
|
|
243
|
-
const [factoryAddress, factoryCalldata] = await this.parseFactoryAddressFromAccountInitCode();
|
|
244
|
-
Logger.verbose(`[BaseSmartContractAccount](create6492Signature)\
|
|
245
|
-
factoryAddress: ${factoryAddress}, factoryCalldata: ${factoryCalldata}`);
|
|
246
|
-
return wrapSignatureWith6492({
|
|
247
|
-
factoryAddress,
|
|
248
|
-
factoryCalldata,
|
|
249
|
-
signature,
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
//# sourceMappingURL=base.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/account/base.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,IAAI,EACJ,IAAI,GAOL,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,gBAAgB,IAAI,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EACL,mBAAmB,GAEpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EACL,+BAA+B,EAC/B,2BAA2B,EAC3B,6BAA6B,EAC7B,iCAAiC,GAClC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAE,kCAAkC,EAAE,MAAM,aAAa,CAAC;AAOjE,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,uCAAoB,CAAA;IACpB,mCAAgB,CAAA;AAClB,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AAKD,MAAM,OAAgB,wBAAwB;IAmB5C,YAAY,OAAoD;QAdtD;;;;;WAAwB;QACxB;;;;mBAAmC,eAAe,CAAC,SAAS;WAAC;QAC7D;;;;;WAAyB;QACzB;;;;;WAAsB;QACtB;;;;;WAAgB;QAChB;;;;;WAGR;QACQ;;;;;WAA2B;QAC5B;;;;;WAEwB;QAuLjC;;;;mBAAyB,KAAK,EAC5B,qBAA8B,EAC9B,kBAAuB,EACT,EAAE;gBAChB,MAAM,IAAI,iCAAiC,CAAC,aAAa,CAAC,CAA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ACvB,CAAC;IAEO,KAAK,CAAC,mBAAmB;QAC/B,OAAO,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAC3D,CAAC;IAEO,KAAK,CAAC,mBAAmB,CAC/B,UAAmB,EACnB,SAAe;QAEf,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,CAAC,cAAc,EAAE,eAAe,CAAC,GACrC,MAAM,IAAI,CAAC,sCAAsC,EAAE,CAAC;QAEtD,MAAM,CAAC,OAAO,CACZ;0BACoB,cAAc,sBAAsB,eAAe,EAAE,CAC1E,CAAC;QAEF,OAAO,qBAAqB,CAAC;YAC3B,cAAc;YACd,eAAe;YACf,SAAS;SACV,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type { Address } from \"abitype\";\nimport {\n getContract,\n http,\n trim,\n type GetContractReturnType,\n type Hash,\n type Hex,\n type HttpTransport,\n type PublicClient,\n type Transport,\n} from \"viem\";\nimport { EntryPointAbi_v6 as EntryPointAbi } from \"../abis/EntryPointAbi_v6.js\";\nimport {\n createBundlerClient,\n type BundlerClient,\n} from \"../client/bundlerClient.js\";\nimport { getEntryPoint } from \"../entrypoint/index.js\";\nimport {\n BatchExecutionNotSupportedError,\n FailedToGetStorageSlotError,\n GetCounterFactualAddressError,\n UpgradeToAndCallNotSupportedError,\n} from \"../errors/account.js\";\nimport { InvalidRpcUrlError } from \"../errors/client.js\";\nimport { Logger } from \"../logger.js\";\nimport type { SmartAccountSigner } from \"../signer/types.js\";\nimport { wrapSignatureWith6492 } from \"../signer/utils.js\";\nimport type { BatchUserOperationCallData, NullAddress } from \"../types.js\";\nimport { createBaseSmartAccountParamsSchema } from \"./schema.js\";\nimport type {\n BaseSmartAccountParams,\n ISmartContractAccount,\n SignTypedDataParams,\n} from \"./types.js\";\n\nexport enum DeploymentState {\n UNDEFINED = \"0x0\",\n NOT_DEPLOYED = \"0x1\",\n DEPLOYED = \"0x2\",\n}\n\n/**\n * @deprecated use `toSmartContractAccount` instead for creating SmartAccountInstances\n */\nexport abstract class BaseSmartContractAccount<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> implements ISmartContractAccount<TTransport, TSigner>\n{\n protected factoryAddress: Address;\n protected deploymentState: DeploymentState = DeploymentState.UNDEFINED;\n protected accountAddress?: Address;\n protected accountInitCode?: Hex;\n protected signer: TSigner;\n protected entryPoint: GetContractReturnType<\n typeof EntryPointAbi,\n PublicClient\n >;\n protected entryPointAddress: Address;\n readonly rpcProvider:\n | BundlerClient<TTransport>\n | BundlerClient<HttpTransport>;\n\n constructor(params_: BaseSmartAccountParams<TTransport, TSigner>) {\n const params = createBaseSmartAccountParamsSchema<\n TTransport,\n TSigner\n >().parse(params_);\n\n this.entryPointAddress =\n params.entryPointAddress ?? getEntryPoint(params.chain).address;\n\n const rpcUrl =\n typeof params.rpcClient === \"string\"\n ? params.rpcClient\n : params.rpcClient.transport.type === \"http\"\n ? (\n params.rpcClient.transport as ReturnType<HttpTransport>[\"config\"] &\n ReturnType<HttpTransport>[\"value\"]\n ).url || params.chain.rpcUrls.default.http[0]\n : undefined;\n\n const fetchOptions =\n typeof params.rpcClient === \"string\"\n ? undefined\n : params.rpcClient.transport.type === \"http\"\n ? (\n params.rpcClient.transport as ReturnType<HttpTransport>[\"config\"] &\n ReturnType<HttpTransport>[\"value\"]\n ).fetchOptions\n : undefined;\n\n this.rpcProvider = rpcUrl\n ? createBundlerClient({\n chain: params.chain,\n transport: http(rpcUrl, {\n fetchOptions: {\n ...fetchOptions,\n headers: {\n ...fetchOptions?.headers,\n ...(rpcUrl.toLowerCase().indexOf(\"alchemy\") > -1\n ? {\n \"Alchemy-Aa-Sdk-Signer\":\n params.signer?.signerType || \"unknown\",\n \"Alchemy-Aa-Sdk-Factory-Address\": params.factoryAddress,\n }\n : undefined),\n },\n },\n }),\n })\n : (params.rpcClient as BundlerClient<TTransport>);\n\n this.accountAddress = params.accountAddress;\n this.factoryAddress = params.factoryAddress;\n this.signer = params.signer as TSigner;\n this.accountInitCode = params.initCode as Hex;\n\n this.entryPoint = getContract({\n address: this.entryPointAddress,\n abi: EntryPointAbi,\n client: this.rpcProvider as PublicClient,\n });\n }\n\n //#region abstract-methods\n\n /**\n * This method should return a signature that will not `revert` during validation.\n * It does not have to pass validation, just not cause the contract to revert.\n * This is required for gas estimation so that the gas estimate are accurate.\n *\n */\n abstract getDummySignature(): Hex | Promise<Hex>;\n\n /**\n * this method should return the abi encoded function data for a call to your contract's `execute` method\n *\n * @param target -- equivalent to `to` in a normal transaction\n * @param value -- equivalent to `value` in a normal transaction\n * @param data -- equivalent to `data` in a normal transaction\n * @returns abi encoded function data for a call to your contract's `execute` method\n */\n abstract encodeExecute(\n target: string,\n value: bigint,\n data: string\n ): Promise<Hash>;\n\n /**\n * this should return an ERC-191 compliant message and is used to sign UO Hashes\n *\n * @param msg -- the message to sign\n */\n abstract signMessage(msg: string | Uint8Array): Promise<Hash>;\n\n /**\n * this should return the init code that will be used to create an account if one does not exist.\n * This is the concatenation of the account's factory address and the abi encoded function data of the account factory's `createAccount` method.\n * https://github.com/eth-infinitism/account-abstraction/blob/abff2aca61a8f0934e533d0d352978055fddbd96/contracts/core/SenderCreator.sol#L12\n */\n protected abstract getAccountInitCode(): Promise<Hash>;\n\n //#endregion abstract-methods\n\n //#region optional-methods\n\n /**\n * If your account handles 1271 signatures of personal_sign differently\n * than it does UserOperations, you can implement two different approaches to signing\n *\n * @param uoHash -- The hash of the UserOperation to sign\n * @returns the signature of the UserOperation\n */\n async signUserOperationHash(uoHash: Hash): Promise<Hash> {\n return this.signMessage(uoHash);\n }\n\n /**\n * If your contract supports signing and verifying typed data,\n * you should implement this method.\n *\n * @param _params -- Typed Data params to sign\n */\n async signTypedData(_params: SignTypedDataParams): Promise<`0x${string}`> {\n throw new Error(\"signTypedData not supported\");\n }\n\n /**\n * This method should wrap the result of `signMessage` as per\n * [EIP-6492](https://eips.ethereum.org/EIPS/eip-6492)\n *\n * @param msg -- the message to sign\n * @returns the signature wrapped in 6492 format\n */\n async signMessageWith6492(msg: string | Uint8Array): Promise<`0x${string}`> {\n const [isDeployed, signature] = await Promise.all([\n this.isAccountDeployed(),\n this.signMessage(msg),\n ]);\n\n return this.create6492Signature(isDeployed, signature);\n }\n\n /**\n * Similar to the signMessageWith6492 method above,\n * this method should wrap the result of `signTypedData` as per\n * [EIP-6492](https://eips.ethereum.org/EIPS/eip-6492)\n *\n * @param params -- Typed Data params to sign\n * @returns the signature wrapped in 6492 format\n */\n async signTypedDataWith6492(\n params: SignTypedDataParams\n ): Promise<`0x${string}`> {\n const [isDeployed, signature] = await Promise.all([\n this.isAccountDeployed(),\n this.signTypedData(params),\n ]);\n\n return this.create6492Signature(isDeployed, signature);\n }\n\n /**\n * Not all contracts support batch execution.\n * If your contract does, this method should encode a list of\n * transactions into the call data that will be passed to your\n * contract's batch execution method.\n *\n * @param _txs -- the transactions to batch execute\n */\n async encodeBatchExecute(\n _txs: BatchUserOperationCallData\n ): Promise<`0x${string}`> {\n throw new BatchExecutionNotSupportedError(\"BaseAccount\");\n }\n\n /**\n * If your contract supports UUPS, you can implement this method which can be\n * used to upgrade the implementation of the account.\n *\n * @param _upgradeToImplAddress -- the implementation address of the contract you want to upgrade to\n * @param _upgradeToInitData -- the initialization data required by that account\n */\n encodeUpgradeToAndCall = async (\n _upgradeToImplAddress: Address,\n _upgradeToInitData: Hex\n ): Promise<Hex> => {\n throw new UpgradeToAndCallNotSupportedError(\"BaseAccount\");\n };\n //#endregion optional-methods\n\n // Extra implementations\n async getNonce(): Promise<bigint> {\n if (!(await this.isAccountDeployed())) {\n return 0n;\n }\n const address = await this.getAddress();\n return this.entryPoint.read.getNonce([address, BigInt(0)]);\n }\n\n async getInitCode(): Promise<Hex> {\n if (this.deploymentState === DeploymentState.DEPLOYED) {\n return \"0x\";\n }\n\n const contractCode = await this.rpcProvider.getBytecode({\n address: await this.getAddress(),\n });\n\n if ((contractCode?.length ?? 0) > 2) {\n this.deploymentState = DeploymentState.DEPLOYED;\n return \"0x\";\n } else {\n this.deploymentState = DeploymentState.NOT_DEPLOYED;\n }\n\n return this._getAccountInitCode();\n }\n\n async getAddress(): Promise<Address> {\n if (!this.accountAddress) {\n const initCode = await this._getAccountInitCode();\n Logger.verbose(\n \"[BaseSmartContractAccount](getAddress) initCode: \",\n initCode\n );\n try {\n await this.entryPoint.simulate.getSenderAddress([initCode]);\n } catch (err: any) {\n Logger.verbose(\n \"[BaseSmartContractAccount](getAddress) getSenderAddress err: \",\n err\n );\n\n if (err.cause?.data?.errorName === \"SenderAddressResult\") {\n this.accountAddress = err.cause.data.args[0] as Address;\n Logger.verbose(\n \"[BaseSmartContractAccount](getAddress) entryPoint.getSenderAddress result:\",\n this.accountAddress\n );\n return this.accountAddress;\n }\n\n if (err.details === \"Invalid URL\") {\n throw new InvalidRpcUrlError();\n }\n }\n\n throw new GetCounterFactualAddressError();\n }\n\n return this.accountAddress;\n }\n\n extend = <R>(fn: (self: this) => R): this & R => {\n const extended = fn(this) as any;\n // this should make it so extensions can't overwrite the base methods\n for (const key in this) {\n delete extended[key];\n }\n return Object.assign(this, extended);\n };\n\n getSigner(): TSigner {\n return this.signer;\n }\n\n getFactoryAddress(): Address {\n return this.factoryAddress;\n }\n\n getEntryPointAddress(): Address {\n return this.entryPointAddress;\n }\n\n async isAccountDeployed(): Promise<boolean> {\n return (await this.getDeploymentState()) === DeploymentState.DEPLOYED;\n }\n\n async getDeploymentState(): Promise<DeploymentState> {\n if (this.deploymentState === DeploymentState.UNDEFINED) {\n const initCode = await this.getInitCode();\n return initCode === \"0x\"\n ? DeploymentState.DEPLOYED\n : DeploymentState.NOT_DEPLOYED;\n } else {\n return this.deploymentState;\n }\n }\n\n /**\n * https://eips.ethereum.org/EIPS/eip-4337#first-time-account-creation\n * The initCode field (if non-zero length) is parsed as a 20-byte address,\n * followed by calldata to pass to this address.\n * The factory address is the first 40 char after the 0x, and the callData is the rest.\n *\n * @returns [factoryAddress, factoryCalldata]\n */\n protected async parseFactoryAddressFromAccountInitCode(): Promise<\n [Address, Hex]\n > {\n const initCode = await this._getAccountInitCode();\n const factoryAddress: Address = `0x${initCode.substring(2, 42)}`;\n const factoryCalldata: Hex = `0x${initCode.substring(42)}`;\n return [factoryAddress, factoryCalldata];\n }\n\n protected async getImplementationAddress(): Promise<NullAddress | Address> {\n const accountAddress = await this.getAddress();\n\n const storage = await this.rpcProvider.getStorageAt({\n address: accountAddress,\n // This is the default slot for the implementation address for Proxies\n slot: \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\",\n });\n\n if (storage == null) {\n throw new FailedToGetStorageSlotError(\n \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\",\n \"Proxy Implementation Address\"\n );\n }\n\n return trim(storage);\n }\n\n private async _getAccountInitCode(): Promise<Hash> {\n return this.accountInitCode ?? this.getAccountInitCode();\n }\n\n private async create6492Signature(\n isDeployed: boolean,\n signature: Hash\n ): Promise<Hash> {\n if (isDeployed) {\n return signature;\n }\n\n const [factoryAddress, factoryCalldata] =\n await this.parseFactoryAddressFromAccountInitCode();\n\n Logger.verbose(\n `[BaseSmartContractAccount](create6492Signature)\\\n factoryAddress: ${factoryAddress}, factoryCalldata: ${factoryCalldata}`\n );\n\n return wrapSignatureWith6492({\n factoryAddress,\n factoryCalldata,\n signature,\n });\n }\n}\n"]}
|