@aa-sdk/core 4.13.1-alpha.0 → 4.15.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"smartAccountClient.js","sourceRoot":"","sources":["../../../src/client/smartAccountClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,GAUP,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,OAAO,EAAE,mBAAmB,EAAsB,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAGN,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,yBAAyB,GAE1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AA4G3D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAAgC;IAEhC,MAAM,EACJ,GAAG,GAAG,SAAS,EACf,IAAI,GAAG,kBAAkB,EACzB,SAAS,EACT,IAAI,GAAG,oBAAoB,EAC3B,GAAG,MAAM,EACV,GAAG,MAAM,CAAC;IAEX,MAAM,MAAM,GAAuB,mBAAmB,CAAC;QACrD,GAAG,MAAM;QACT,GAAG;QACH,IAAI;QACJ,2EAA2E;QAC3E,iFAAiF;QACjF,wEAAwE;QACxE,IAAI,EAAE,oBAAoB;QAC1B,gCAAgC;QAChC,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;YAClB,MAAM,YAAY,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;YAErC,OAAO,MAAM,CAAC;gBACZ,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE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AAI,EAAE,CAAC;AAC7B,CAAC;AAgCD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,oCAAoC,CAClD,MAEC;IAED,OAAO,wBAAwB,CAAC;QAC9B,GAAG,MAAM;QACT,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK;QAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;KACjC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n custom,\n type Chain,\n type Client,\n type ClientConfig,\n type CustomTransport,\n type FormattedTransactionRequest,\n type PublicActions,\n type PublicRpcSchema,\n type RpcSchema,\n type Transport,\n} from \"viem\";\nimport { z } from \"zod\";\nimport type { SmartContractAccount } from \"../account/smartContractAccount.js\";\nimport type { UserOperationContext } from \"../actions/smartAccount/types.js\";\nimport { AccountNotFoundError } from \"../errors/account.js\";\nimport { ChainNotFoundError } from \"../errors/client.js\";\nimport { middlewareActions } from \"../middleware/actions.js\";\nimport type { ClientMiddleware } from \"../middleware/types.js\";\nimport type { Prettify } from \"../utils/index.js\";\nimport { createBundlerClient, type BundlerClient } from \"./bundlerClient.js\";\nimport {\n type BundlerActions,\n type BundlerRpcSchema,\n} from \"./decorators/bundlerClient.js\";\nimport {\n smartAccountClientActions,\n type BaseSmartAccountClientActions,\n} from \"./decorators/smartAccountClient.js\";\nimport { SmartAccountClientOptsSchema } from \"./schema.js\";\nimport type { ClientMiddlewareConfig } from \"./types.js\";\n\ntype SmartAccountClientOpts = z.output<typeof SmartAccountClientOptsSchema>;\n\nexport type SmartAccountClientConfig<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n Pick<\n ClientConfig<transport, chain, account>,\n | \"cacheTime\"\n | \"chain\"\n | \"key\"\n | \"name\"\n | \"pollingInterval\"\n | \"transport\"\n | \"type\"\n > & {\n account?: account;\n opts?: z.input<typeof SmartAccountClientOptsSchema>;\n } & ClientMiddlewareConfig<context>\n>;\n\nexport type SmartAccountClientRpcSchema = [\n ...BundlerRpcSchema,\n ...PublicRpcSchema\n];\n\n//#region SmartAccountClientActions\nexport type SmartAccountClientActions<\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = BaseSmartAccountClientActions<chain, account, context> &\n BundlerActions &\n PublicActions;\n//#endregion SmartAccountClientActions\n\n//#region SmartAccountClient\nexport type SmartAccountClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n actions extends Record<string, unknown> = Record<string, unknown>,\n rpcSchema extends RpcSchema = SmartAccountClientRpcSchema,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n Client<\n transport,\n chain,\n account,\n rpcSchema,\n actions & SmartAccountClientActions<chain, account, context>\n >\n>;\n//#endregion SmartAccountClient\n\nexport type BaseSmartAccountClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n Client<\n transport,\n chain,\n account,\n [...BundlerRpcSchema, ...PublicRpcSchema],\n {\n middleware: ClientMiddleware<context>;\n } & SmartAccountClientOpts &\n BundlerActions &\n PublicActions\n >\n>;\n\nexport function createSmartAccountClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n config: SmartAccountClientConfig<TTransport, TChain, TAccount, TContext>\n): SmartAccountClient<TTransport, TChain, TAccount>;\n\n/**\n * Creates a smart account client using the provided configuration. This client handles various Ethereum transactions and message signing operations.\n *\n * @example\n * ```ts\n * import { createSmartAccountClient, toSmartContractAccount } from \"@aa-sdk/core\";\n * import { http } from \"viem\";\n * import { sepolia } from \"viem/chains\";\n *\n * const client = createSmartAccountClient({\n * chain: sepolia,\n * transport: http(\"RPC_URL\"),\n * // optionally hoist the account\n * account: toSmartContractAccount(...),\n * });\n * ```\n *\n * @param {SmartAccountClientConfig} config The configuration for creating the smart account client\n * @returns {SmartAccountClient} A smart account client capable of handling transactions, message signing, and other operations on a smart account\n */\nexport function createSmartAccountClient(\n config: SmartAccountClientConfig\n): SmartAccountClient {\n const {\n key = \"account\",\n name = \"account provider\",\n transport,\n type = \"SmartAccountClient\",\n ...params\n } = config;\n\n const client: SmartAccountClient = createBundlerClient({\n ...params,\n key,\n name,\n // we start out with this because the base methods for a SmartAccountClient\n // require a smart account client, but once we have completed building everything\n // we want to override this value with the one passed in by the extender\n type: \"SmartAccountClient\",\n // TODO: this needs to be tested\n transport: (opts) => {\n const rpcTransport = transport(opts);\n\n return custom({\n async request({ method, params }) {\n switch (method) {\n case \"eth_accounts\": {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n\n return [client.account.address];\n }\n case \"eth_sendTransaction\":\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n const [tx] = params as [FormattedTransactionRequest];\n return client.sendTransaction({\n ...tx,\n account: client.account,\n chain: client.chain,\n });\n case \"eth_sign\":\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n const [address, data] = params!;\n if (address !== client.account.address) {\n throw new Error(\n \"cannot sign for address that is not the current account\"\n );\n }\n return client.signMessage(data);\n case \"personal_sign\": {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n const [data, address] = params!;\n if (address !== client.account.address) {\n throw new Error(\n \"cannot sign for address that is not the current account\"\n );\n }\n return client.signMessage(data);\n }\n case \"eth_signTypedData_v4\": {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n const [address, dataParams] = params!;\n if (address !== client.account.address) {\n throw new Error(\n \"cannot sign for address that is not the current account\"\n );\n }\n return client.signTypedData(dataParams);\n }\n case \"eth_chainId\":\n if (!opts.chain) {\n throw new ChainNotFoundError();\n }\n\n return opts.chain.id;\n default:\n // TODO: there's probably a number of methods we just don't support, will need to test most of them out\n // first let's get something working though\n return rpcTransport.request({ method, params });\n }\n },\n })(opts);\n },\n })\n .extend(() => ({\n ...SmartAccountClientOptsSchema.parse(config.opts ?? {}),\n }))\n .extend(middlewareActions(config))\n .extend(smartAccountClientActions);\n\n return { ...client, type };\n}\n\nexport function createSmartAccountClientFromExisting<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TClient extends BundlerClient<TTransport> = BundlerClient<TTransport>,\n TActions extends SmartAccountClientActions<\n TChain,\n TAccount,\n TContext\n > = SmartAccountClientActions<TChain, TAccount>,\n TRpcSchema extends SmartAccountClientRpcSchema = SmartAccountClientRpcSchema,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n config: Omit<\n SmartAccountClientConfig<Transport, TChain, TAccount, TContext>,\n \"transport\" | \"chain\"\n > & { client: TClient }\n): SmartAccountClient<\n CustomTransport,\n TChain,\n TAccount,\n TActions,\n TRpcSchema,\n TContext\n>;\n\n/**\n * Creates a smart account client using an existing client and specific configuration. This function can be used to reuse a pre-existing BundlerClient while customizing other aspects of the smart account.\n *\n * @example\n * ```ts\n * import {\n * createBundlerClient,\n * createSmartAccountClientFromExisting,\n * toSmartContractAccount\n * } from \"@aa-sdk/core\";\n *\n * const bundlerClient = createBundlerClient(...);\n * const client = createSmartAccountClientFromExisting({\n * client,\n * account: toSmartContractAccount(...),\n * })\n * ```\n *\n * @param {Omit<SmartAccountClientConfig, \"transport\" | \"chain\"> & {client: BundlerClient}} config the configuration object which includes the client\n * @returns {SmartAccountClient} A smart account client created from the existing BundlerClient\n */\nexport function createSmartAccountClientFromExisting(\n config: Omit<SmartAccountClientConfig, \"transport\" | \"chain\"> & {\n client: BundlerClient;\n }\n): SmartAccountClient {\n return createSmartAccountClient({\n ...config,\n chain: config.client.chain,\n transport: custom(config.client),\n });\n}\n"]}
1
+ {"version":3,"file":"smartAccountClient.js","sourceRoot":"","sources":["../../../src/client/smartAccountClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,GAUP,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,OAAO,EAAE,mBAAmB,EAAsB,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAGN,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,yBAAyB,GAE1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AA4G3D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAAgC;IAEhC,MAAM,EACJ,GAAG,GAAG,SAAS,EACf,IAAI,GAAG,kBAAkB,EACzB,SAAS,EACT,IAAI,GAAG,oBAAoB,EAC3B,GAAG,MAAM,EACV,GAAG,MAAM,CAAC;IAEX,MAAM,MAAM,GAAuB,mBAAmB,CAAC;QACrD,GAAG,MAAM;QACT,GAAG;QACH,IAAI;QACJ,2EAA2E;QAC3E,iFAAiF;QACjF,wEAAwE;QACxE,IAAI,EAAE,oBAAoB;QAC1B,gCAAgC;QAChC,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;YAClB,MAAM,YAAY,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;YAErC,OAAO,MAAM,CAAC;gBACZ,KAAK,CAAC,OAA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IAErC,OAAO,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC;AAC7B,CAAC;AAgCD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,oCAAoC,CAClD,MAEC;IAED,OAAO,wBAAwB,CAAC;QAC9B,GAAG,MAAM;QACT,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK;QAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;KACjC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n custom,\n type Chain,\n type Client,\n type ClientConfig,\n type CustomTransport,\n type FormattedTransactionRequest,\n type PublicActions,\n type PublicRpcSchema,\n type RpcSchema,\n type Transport,\n} from \"viem\";\nimport { z } from \"zod\";\nimport type { SmartContractAccount } from \"../account/smartContractAccount.js\";\nimport type { UserOperationContext } from \"../actions/smartAccount/types.js\";\nimport { AccountNotFoundError } from \"../errors/account.js\";\nimport { ChainNotFoundError } from \"../errors/client.js\";\nimport { middlewareActions } from \"../middleware/actions.js\";\nimport type { ClientMiddleware } from \"../middleware/types.js\";\nimport type { Prettify } from \"../utils/index.js\";\nimport { createBundlerClient, type BundlerClient } from \"./bundlerClient.js\";\nimport {\n type BundlerActions,\n type BundlerRpcSchema,\n} from \"./decorators/bundlerClient.js\";\nimport {\n smartAccountClientActions,\n type BaseSmartAccountClientActions,\n} from \"./decorators/smartAccountClient.js\";\nimport { SmartAccountClientOptsSchema } from \"./schema.js\";\nimport type { ClientMiddlewareConfig } from \"./types.js\";\n\ntype SmartAccountClientOpts = z.output<typeof SmartAccountClientOptsSchema>;\n\nexport type SmartAccountClientConfig<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n Pick<\n ClientConfig<transport, chain, account>,\n | \"cacheTime\"\n | \"chain\"\n | \"key\"\n | \"name\"\n | \"pollingInterval\"\n | \"transport\"\n | \"type\"\n > & {\n account?: account;\n opts?: z.input<typeof SmartAccountClientOptsSchema>;\n } & ClientMiddlewareConfig<context>\n>;\n\nexport type SmartAccountClientRpcSchema = [\n ...BundlerRpcSchema,\n ...PublicRpcSchema\n];\n\n// [!region SmartAccountClientActions]\nexport type SmartAccountClientActions<\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = BaseSmartAccountClientActions<chain, account, context> &\n BundlerActions &\n PublicActions;\n// [!endregion SmartAccountClientActions]\n\n// [!region SmartAccountClient]\nexport type SmartAccountClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n actions extends Record<string, unknown> = Record<string, unknown>,\n rpcSchema extends RpcSchema = SmartAccountClientRpcSchema,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n Client<\n transport,\n chain,\n account,\n rpcSchema,\n actions & SmartAccountClientActions<chain, account, context>\n >\n>;\n// [!endregion SmartAccountClient]\n\nexport type BaseSmartAccountClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n Client<\n transport,\n chain,\n account,\n [...BundlerRpcSchema, ...PublicRpcSchema],\n {\n middleware: ClientMiddleware<context>;\n } & SmartAccountClientOpts &\n BundlerActions &\n PublicActions\n >\n>;\n\nexport function createSmartAccountClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n config: SmartAccountClientConfig<TTransport, TChain, TAccount, TContext>\n): SmartAccountClient<TTransport, TChain, TAccount>;\n\n/**\n * Creates a smart account client using the provided configuration. This client handles various Ethereum transactions and message signing operations.\n *\n * @example\n * ```ts\n * import { createSmartAccountClient, toSmartContractAccount } from \"@aa-sdk/core\";\n * import { http } from \"viem\";\n * import { sepolia } from \"viem/chains\";\n *\n * const client = createSmartAccountClient({\n * chain: sepolia,\n * transport: http(\"RPC_URL\"),\n * // optionally hoist the account\n * account: toSmartContractAccount(...),\n * });\n * ```\n *\n * @param {SmartAccountClientConfig} config The configuration for creating the smart account client\n * @returns {SmartAccountClient} A smart account client capable of handling transactions, message signing, and other operations on a smart account\n */\nexport function createSmartAccountClient(\n config: SmartAccountClientConfig\n): SmartAccountClient {\n const {\n key = \"account\",\n name = \"account provider\",\n transport,\n type = \"SmartAccountClient\",\n ...params\n } = config;\n\n const client: SmartAccountClient = createBundlerClient({\n ...params,\n key,\n name,\n // we start out with this because the base methods for a SmartAccountClient\n // require a smart account client, but once we have completed building everything\n // we want to override this value with the one passed in by the extender\n type: \"SmartAccountClient\",\n // TODO: this needs to be tested\n transport: (opts) => {\n const rpcTransport = transport(opts);\n\n return custom({\n async request({ method, params }) {\n switch (method) {\n case \"eth_accounts\": {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n\n return [client.account.address];\n }\n case \"eth_sendTransaction\":\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n const [tx] = params as [FormattedTransactionRequest];\n return client.sendTransaction({\n ...tx,\n account: client.account,\n chain: client.chain,\n });\n case \"eth_sign\":\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n const [address, data] = params!;\n if (address !== client.account.address) {\n throw new Error(\n \"cannot sign for address that is not the current account\"\n );\n }\n return client.signMessage(data);\n case \"personal_sign\": {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n const [data, address] = params!;\n if (address !== client.account.address) {\n throw new Error(\n \"cannot sign for address that is not the current account\"\n );\n }\n return client.signMessage(data);\n }\n case \"eth_signTypedData_v4\": {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n const [address, dataParams] = params!;\n if (address !== client.account.address) {\n throw new Error(\n \"cannot sign for address that is not the current account\"\n );\n }\n return client.signTypedData(dataParams);\n }\n case \"eth_chainId\":\n if (!opts.chain) {\n throw new ChainNotFoundError();\n }\n\n return opts.chain.id;\n default:\n // TODO: there's probably a number of methods we just don't support, will need to test most of them out\n // first let's get something working though\n return rpcTransport.request({ method, params });\n }\n },\n })(opts);\n },\n })\n .extend(() => ({\n ...SmartAccountClientOptsSchema.parse(config.opts ?? {}),\n }))\n .extend(middlewareActions(config))\n .extend(smartAccountClientActions);\n\n return { ...client, type };\n}\n\nexport function createSmartAccountClientFromExisting<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TClient extends BundlerClient<TTransport> = BundlerClient<TTransport>,\n TActions extends SmartAccountClientActions<\n TChain,\n TAccount,\n TContext\n > = SmartAccountClientActions<TChain, TAccount>,\n TRpcSchema extends SmartAccountClientRpcSchema = SmartAccountClientRpcSchema,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n config: Omit<\n SmartAccountClientConfig<Transport, TChain, TAccount, TContext>,\n \"transport\" | \"chain\"\n > & { client: TClient }\n): SmartAccountClient<\n CustomTransport,\n TChain,\n TAccount,\n TActions,\n TRpcSchema,\n TContext\n>;\n\n/**\n * Creates a smart account client using an existing client and specific configuration. This function can be used to reuse a pre-existing BundlerClient while customizing other aspects of the smart account.\n *\n * @example\n * ```ts\n * import {\n * createBundlerClient,\n * createSmartAccountClientFromExisting,\n * toSmartContractAccount\n * } from \"@aa-sdk/core\";\n *\n * const bundlerClient = createBundlerClient(...);\n * const client = createSmartAccountClientFromExisting({\n * client,\n * account: toSmartContractAccount(...),\n * })\n * ```\n *\n * @param {Omit<SmartAccountClientConfig, \"transport\" | \"chain\"> & {client: BundlerClient}} config the configuration object which includes the client\n * @returns {SmartAccountClient} A smart account client created from the existing BundlerClient\n */\nexport function createSmartAccountClientFromExisting(\n config: Omit<SmartAccountClientConfig, \"transport\" | \"chain\"> & {\n client: BundlerClient;\n }\n): SmartAccountClient {\n return createSmartAccountClient({\n ...config,\n chain: config.client.chain,\n transport: custom(config.client),\n });\n}\n"]}
@@ -4,21 +4,21 @@ const packUserOperation = (request) => {
4
4
  const initCode = request.factory && request.factoryData
5
5
  ? concat([request.factory, request.factoryData])
6
6
  : "0x";
7
- const accountGasLimits = packAccountGasLimits((({ verificationGasLimit, callGasLimit }) => ({
8
- verificationGasLimit,
9
- callGasLimit,
10
- }))(request));
11
- const gasFees = packAccountGasLimits((({ maxPriorityFeePerGas, maxFeePerGas }) => ({
12
- maxPriorityFeePerGas,
13
- maxFeePerGas,
14
- }))(request));
7
+ const accountGasLimits = packAccountGasLimits({
8
+ verificationGasLimit: request.verificationGasLimit,
9
+ callGasLimit: request.callGasLimit,
10
+ });
11
+ const gasFees = packAccountGasLimits({
12
+ maxPriorityFeePerGas: request.maxPriorityFeePerGas,
13
+ maxFeePerGas: request.maxFeePerGas,
14
+ });
15
15
  const paymasterAndData = request.paymaster && isAddress(request.paymaster)
16
- ? packPaymasterData((({ paymaster, paymasterVerificationGasLimit, paymasterPostOpGasLimit, paymasterData, }) => ({
17
- paymaster,
18
- paymasterVerificationGasLimit,
19
- paymasterPostOpGasLimit,
20
- paymasterData,
21
- }))(request))
16
+ ? packPaymasterData({
17
+ paymaster: request.paymaster,
18
+ paymasterVerificationGasLimit: request.paymasterVerificationGasLimit,
19
+ paymasterPostOpGasLimit: request.paymasterPostOpGasLimit,
20
+ paymasterData: request.paymasterData,
21
+ })
22
22
  : "0x";
23
23
  return encodeAbiParameters([
24
24
  { type: "address" },
@@ -1 +1 @@
1
- {"version":3,"file":"0.7.js","sourceRoot":"","sources":["../../../src/entrypoint/0.7.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,mBAAmB,EAC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C,EAChC,SAAS,EACT,6BAA6B,EAC7B,uBAAuB,EACvB,aAAa,GAOd;IACC,IACE,CAAC,SAAS;QACV,CAAC,6BAA6B;QAC9B,CAAC,uBAAuB;QACxB,CAAC,aAAa,EACd,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,MAAM,CAAC;QACZ,SAAS;QACT,GAAG,CAAC,6BAA6B,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QAChD,GAAG,CAAC,uBAAuB,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QAC1C,aAAa;KACd,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,gBAAwB;IAI7D,OAAO;QACL,oBAAoB,EAAE,QAAQ,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QACjE,YAAY,EAAE,QAAQ,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;KACvD,CAAC;AACJ,CAAC","sourcesContent":["import {\n concat,\n encodeAbiParameters,\n hexToBigInt,\n isAddress,\n keccak256,\n pad,\n type Address,\n type Chain,\n type Hash,\n type Hex,\n} from \"viem\";\nimport { EntryPointAbi_v7 } from \"../abis/EntryPointAbi_v7.js\";\nimport type {\n UserOperationRequest,\n UserOperationRequest_v7,\n} from \"../types.js\";\nimport type { SupportedEntryPoint } from \"./types.js\";\n\nconst packUserOperation = (request: UserOperationRequest<\"0.7.0\">): Hex => {\n const initCode =\n request.factory && request.factoryData\n ? concat([request.factory, request.factoryData])\n : \"0x\";\n const accountGasLimits = packAccountGasLimits(\n (({ verificationGasLimit, callGasLimit }) => ({\n verificationGasLimit,\n callGasLimit,\n }))(request)\n );\n\n const gasFees = packAccountGasLimits(\n (({ maxPriorityFeePerGas, maxFeePerGas }) => ({\n maxPriorityFeePerGas,\n maxFeePerGas,\n }))(request)\n );\n\n const paymasterAndData =\n request.paymaster && isAddress(request.paymaster)\n ? packPaymasterData(\n (({\n paymaster,\n paymasterVerificationGasLimit,\n paymasterPostOpGasLimit,\n paymasterData,\n }) => ({\n paymaster,\n paymasterVerificationGasLimit,\n paymasterPostOpGasLimit,\n paymasterData,\n }))(request)\n )\n : \"0x\";\n\n return encodeAbiParameters(\n [\n { type: \"address\" },\n { type: \"uint256\" },\n { type: \"bytes32\" },\n { type: \"bytes32\" },\n { type: \"bytes32\" },\n { type: \"uint256\" },\n { type: \"bytes32\" },\n { type: \"bytes32\" },\n ],\n [\n request.sender as Address,\n hexToBigInt(request.nonce),\n keccak256(initCode),\n keccak256(request.callData),\n accountGasLimits,\n hexToBigInt(request.preVerificationGas),\n gasFees,\n keccak256(paymasterAndData),\n ]\n );\n};\n\nexport default {\n version: \"0.7.0\",\n\n address: {\n default: \"0x0000000071727De22E5E9d8BAf0edAc6f37da032\",\n },\n\n abi: EntryPointAbi_v7,\n\n getUserOperationHash: (\n request: UserOperationRequest<\"0.7.0\">,\n entryPointAddress: Address,\n chainId: number\n ): Hash => {\n const encoded = encodeAbiParameters(\n [{ type: \"bytes32\" }, { type: \"address\" }, { type: \"uint256\" }],\n [\n keccak256(packUserOperation(request)),\n entryPointAddress,\n BigInt(chainId),\n ]\n );\n\n return keccak256(encoded);\n },\n\n packUserOperation,\n} satisfies SupportedEntryPoint<\"0.7.0\", Chain, typeof EntryPointAbi_v7>;\n\nexport function packAccountGasLimits(\n data:\n | Pick<UserOperationRequest_v7, \"verificationGasLimit\" | \"callGasLimit\">\n | Pick<UserOperationRequest_v7, \"maxPriorityFeePerGas\" | \"maxFeePerGas\">\n): Hex {\n return concat(Object.values(data).map((v) => pad(v, { size: 16 })));\n}\n\nexport function packPaymasterData({\n paymaster,\n paymasterVerificationGasLimit,\n paymasterPostOpGasLimit,\n paymasterData,\n}: Pick<\n UserOperationRequest_v7,\n | \"paymaster\"\n | \"paymasterVerificationGasLimit\"\n | \"paymasterPostOpGasLimit\"\n | \"paymasterData\"\n>): Hex {\n if (\n !paymaster ||\n !paymasterVerificationGasLimit ||\n !paymasterPostOpGasLimit ||\n !paymasterData\n ) {\n return \"0x\";\n }\n return concat([\n paymaster,\n pad(paymasterVerificationGasLimit, { size: 16 }),\n pad(paymasterPostOpGasLimit, { size: 16 }),\n paymasterData,\n ]);\n}\n\nexport function unpackAccountGasLimits(accountGasLimits: string): {\n verificationGasLimit: number;\n callGasLimit: number;\n} {\n return {\n verificationGasLimit: parseInt(accountGasLimits.slice(2, 34), 16),\n callGasLimit: parseInt(accountGasLimits.slice(34), 16),\n };\n}\n"]}
1
+ {"version":3,"file":"0.7.js","sourceRoot":"","sources":["../../../src/entrypoint/0.7.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,mBAAmB,EACnB,WAAW,EACX,SAAS,EACT,SAAS,EACT,GAAG,GAKJ,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAO/D,MAAM,iBAAiB,GAAG,CAAC,OAAsC,EAAO,EAAE;IACxE,MAAM,QAAQ,GACZ,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,WAAW;QACpC,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;QAChD,CAAC,CAAC,IAAI,CAAC;IACX,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;QAC5C,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;QAClD,YAAY,EAAE,OAAO,CAAC,YAAY;KACnC,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,oBAAoB,CAAC;QACnC,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;QAClD,YAAY,EAAE,OAAO,CAAC,YAAY;KACnC,CAAC,CAAC;IAEH,MAAM,gBAAgB,GACpB,OAAO,CAAC,SAAS,IAAI,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC;QAC/C,CAAC,CAAC,iBAAiB,CAAC;YACh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AC;SAChB,CACF,CAAC;QAEF,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAED,iBAAiB;CACqD,CAAC;AAEzE,MAAM,UAAU,oBAAoB,CAClC,IAE0E;IAE1E,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,EAChC,SAAS,EACT,6BAA6B,EAC7B,uBAAuB,EACvB,aAAa,GAOd;IACC,IACE,CAAC,SAAS;QACV,CAAC,6BAA6B;QAC9B,CAAC,uBAAuB;QACxB,CAAC,aAAa,EACd,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,MAAM,CAAC;QACZ,SAAS;QACT,GAAG,CAAC,6BAA6B,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QAChD,GAAG,CAAC,uBAAuB,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QAC1C,aAAa;KACd,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,gBAAwB;IAI7D,OAAO;QACL,oBAAoB,EAAE,QAAQ,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QACjE,YAAY,EAAE,QAAQ,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;KACvD,CAAC;AACJ,CAAC","sourcesContent":["import {\n concat,\n encodeAbiParameters,\n hexToBigInt,\n isAddress,\n keccak256,\n pad,\n type Address,\n type Chain,\n type Hash,\n type Hex,\n} from \"viem\";\nimport { EntryPointAbi_v7 } from \"../abis/EntryPointAbi_v7.js\";\nimport type {\n UserOperationRequest,\n UserOperationRequest_v7,\n} from \"../types.js\";\nimport type { SupportedEntryPoint } from \"./types.js\";\n\nconst packUserOperation = (request: UserOperationRequest<\"0.7.0\">): Hex => {\n const initCode =\n request.factory && request.factoryData\n ? concat([request.factory, request.factoryData])\n : \"0x\";\n const accountGasLimits = packAccountGasLimits({\n verificationGasLimit: request.verificationGasLimit,\n callGasLimit: request.callGasLimit,\n });\n\n const gasFees = packAccountGasLimits({\n maxPriorityFeePerGas: request.maxPriorityFeePerGas,\n maxFeePerGas: request.maxFeePerGas,\n });\n\n const paymasterAndData =\n request.paymaster && isAddress(request.paymaster)\n ? packPaymasterData({\n paymaster: request.paymaster,\n paymasterVerificationGasLimit: request.paymasterVerificationGasLimit,\n paymasterPostOpGasLimit: request.paymasterPostOpGasLimit,\n paymasterData: request.paymasterData,\n })\n : \"0x\";\n\n return encodeAbiParameters(\n [\n { type: \"address\" },\n { type: \"uint256\" },\n { type: \"bytes32\" },\n { type: \"bytes32\" },\n { type: \"bytes32\" },\n { type: \"uint256\" },\n { type: \"bytes32\" },\n { type: \"bytes32\" },\n ],\n [\n request.sender as Address,\n hexToBigInt(request.nonce),\n keccak256(initCode),\n keccak256(request.callData),\n accountGasLimits,\n hexToBigInt(request.preVerificationGas),\n gasFees,\n keccak256(paymasterAndData),\n ]\n );\n};\n\nexport default {\n version: \"0.7.0\",\n\n address: {\n default: \"0x0000000071727De22E5E9d8BAf0edAc6f37da032\",\n },\n\n abi: EntryPointAbi_v7,\n\n getUserOperationHash: (\n request: UserOperationRequest<\"0.7.0\">,\n entryPointAddress: Address,\n chainId: number\n ): Hash => {\n const encoded = encodeAbiParameters(\n [{ type: \"bytes32\" }, { type: \"address\" }, { type: \"uint256\" }],\n [\n keccak256(packUserOperation(request)),\n entryPointAddress,\n BigInt(chainId),\n ]\n );\n\n return keccak256(encoded);\n },\n\n packUserOperation,\n} satisfies SupportedEntryPoint<\"0.7.0\", Chain, typeof EntryPointAbi_v7>;\n\nexport function packAccountGasLimits(\n data:\n | Pick<UserOperationRequest_v7, \"verificationGasLimit\" | \"callGasLimit\">\n | Pick<UserOperationRequest_v7, \"maxPriorityFeePerGas\" | \"maxFeePerGas\">\n): Hex {\n return concat(Object.values(data).map((v) => pad(v, { size: 16 })));\n}\n\nexport function packPaymasterData({\n paymaster,\n paymasterVerificationGasLimit,\n paymasterPostOpGasLimit,\n paymasterData,\n}: Pick<\n UserOperationRequest_v7,\n | \"paymaster\"\n | \"paymasterVerificationGasLimit\"\n | \"paymasterPostOpGasLimit\"\n | \"paymasterData\"\n>): Hex {\n if (\n !paymaster ||\n !paymasterVerificationGasLimit ||\n !paymasterPostOpGasLimit ||\n !paymasterData\n ) {\n return \"0x\";\n }\n return concat([\n paymaster,\n pad(paymasterVerificationGasLimit, { size: 16 }),\n pad(paymasterPostOpGasLimit, { size: 16 }),\n paymasterData,\n ]);\n}\n\nexport function unpackAccountGasLimits(accountGasLimits: string): {\n verificationGasLimit: number;\n callGasLimit: number;\n} {\n return {\n verificationGasLimit: parseInt(accountGasLimits.slice(2, 34), 16),\n callGasLimit: parseInt(accountGasLimits.slice(34), 16),\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { bytesToHex, getAddress, } from "viem";
1
+ import { getAddress, } from "viem";
2
2
  import { InvalidSignerTypeError } from "../errors/signer.js";
3
3
  /**
4
4
  * Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, and sign typed data.
@@ -94,15 +94,7 @@ export class WalletClientSigner {
94
94
  writable: true,
95
95
  value: async (message) => {
96
96
  const account = this.inner.account ?? (await this.getAddress());
97
- // Seems Wallet Connect only supports signing string messages.
98
- return this.inner.signMessage({
99
- message: typeof message === "string"
100
- ? message
101
- : typeof message.raw === "string"
102
- ? message.raw
103
- : bytesToHex(message.raw),
104
- account,
105
- });
97
+ return this.inner.signMessage({ message, account });
106
98
  }
107
99
  });
108
100
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"wallet-client.js","sourceRoot":"","sources":["../../../src/signer/wallet-client.ts"],"names":[],"mappings":"A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G;oBACb,OAAO;oBACP,GAAG,SAAS;iBACuD,CAAC;gBAEtE,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAqB,MAAM,CAAC,CAAC;YAC9D,CAAC;WAAC;QA9GA,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;QACpB,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,sBAAsB,CAAC,UAAU,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CA0GF","sourcesContent":["import {\n bytesToHex,\n getAddress,\n type Hex,\n type SignableMessage,\n type TypedData,\n type TypedDataDefinition,\n type WalletClient,\n} from \"viem\";\nimport type { Account } from \"viem/accounts\";\nimport type { SignTypedDataParameters } from \"viem/actions\";\nimport { InvalidSignerTypeError } from \"../errors/signer.js\";\nimport type { SmartAccountSigner } from \"./types\";\n\n/**\n * Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, and sign typed data.\n */\nexport class WalletClientSigner implements SmartAccountSigner<WalletClient> {\n signerType: string;\n inner: WalletClient;\n\n /**\n * Initializes a signer with a given wallet client and signer type.\n *\n * @example\n * ```ts\n * import { WalletClientSigner } from \"@aa-sdk/core\";\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum!)\n * });\n *\n * const signer = new WalletClientSigner(client, 'wallet');\n * ```\n *\n * @param {WalletClient} client The wallet client to interact with\n * @param {string} signerType The type of signer; must be a valid signer type, otherwise an error will be thrown\n * @throws {InvalidSignerTypeError} If the signer type is invalid\n */\n constructor(client: WalletClient, signerType: string) {\n this.inner = client;\n if (!signerType) {\n throw new InvalidSignerTypeError(signerType);\n }\n this.signerType = signerType;\n }\n\n /**\n * Asynchronously retrieves addresses from the inner object and returns the first address after applying the `getAddress` function.\n *\n * @example\n * ```ts\n * import { WalletClientSigner } from \"@aa-sdk/core\";\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum!)\n * });\n *\n * const signer = new WalletClientSigner(client, 'wallet');\n * console.log(await signer.getAddress());\n * ```\n *\n * @returns {Promise<string>} A promise that resolves to the first address after being processed by the `getAddress` function.\n */\n getAddress: () => Promise<`0x${string}`> = async () => {\n let addresses = await this.inner.getAddresses();\n return getAddress(addresses[0]);\n };\n\n /**\n * Signs a message using the account's signing method.\n *\n * @example\n * ```ts\n * import { WalletClientSigner } from \"@aa-sdk/core\";\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum!)\n * });\n *\n * const signer = new WalletClientSigner(client, 'wallet');\n * console.log(await signer.signMessage(\"hello\"));\n * ```\n *\n * @param {string} message the message string that needs to be signed\n * @returns {Promise<string>} a promise that resolves to the signed message\n */\n readonly signMessage: (message: SignableMessage) => Promise<`0x${string}`> =\n async (message) => {\n const account = this.inner.account ?? (await this.getAddress());\n\n // Seems Wallet Connect only supports signing string messages.\n return this.inner.signMessage({\n message:\n typeof message === \"string\"\n ? message\n : typeof message.raw === \"string\"\n ? message.raw\n : bytesToHex(message.raw),\n account,\n });\n };\n\n /**\n * Signs the provided typed data using the account's private key.\n *\n * @example\n * ```ts\n * import { WalletClientSigner } from \"@aa-sdk/core\";\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum!)\n * });\n *\n * const signer = new WalletClientSigner(client, 'wallet');\n * console.log(await signer.signTypedData({\n * types: {\n * \"Message\": [{ name: \"content\", type: \"string\" }]\n * },\n * primaryType: \"Message\",\n * message: { content: \"Hello\" },\n * }));\n * ```\n *\n * @param {TypedDataDefinition<TTypedData, TPrimaryType>} typedData The typed data to be signed\n * @returns {Promise<Hex>} A promise that resolves to a hex string representing the signed data\n */\n signTypedData = async <\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | \"EIP712Domain\" | string = string\n >(\n typedData: TypedDataDefinition<TTypedData, TPrimaryType>\n ): Promise<Hex> => {\n const account = this.inner.account ?? (await this.getAddress());\n\n const params = {\n account,\n ...typedData,\n } as SignTypedDataParameters<TTypedData, string, Account | undefined>;\n\n return this.inner.signTypedData<TTypedData, string>(params);\n };\n}\n"]}
1
+ {"version":3,"file":"wallet-client.js","sourceRoot":"","sources":["../../../src/signer/wallet-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,GAMX,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAG7D;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAI7B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAAY,MAAoB,EAAE,UAAkB;QAxBpD;;;;;WAAmB;QACnB;;;;;WAAoB;QA+BpB;;;;;;;;;;;;;;;;;;;WAmBG;QACH;;;;mBAA2C,KAAK,IAAI,EAAE;gBACpD,IAAI,SAAS,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;gBAChD,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YAClC,CAAC;WAAC;QAEF;;;;;;;;;;;;;;;;;;;;WAoBG;QACM;;;;mBACP,KAAK,EAAE,OAAO,EAAE,EAAE;gBAChB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;gBAEhE,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;YACtD,CAAC;WAAC;QAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;WA0BG;QACH;;;;mBAAgB,KAAK,EAInB,SAAwD,EAC1C,EAAE;gBAChB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;gBAEhE,MAAM,MAAM,GAAG;oBACb,OAAO;oBACP,GAAG,SAAS;iBACuD,CAAC;gBAEtE,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAqB,MAAM,CAAC,CAAC;YAC9D,CAAC;WAAC;QArGA,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;QACpB,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,sBAAsB,CAAC,UAAU,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CAiGF","sourcesContent":["import {\n getAddress,\n type Hex,\n type SignableMessage,\n type TypedData,\n type TypedDataDefinition,\n type WalletClient,\n} from \"viem\";\nimport type { Account } from \"viem/accounts\";\nimport type { SignTypedDataParameters } from \"viem/actions\";\nimport { InvalidSignerTypeError } from \"../errors/signer.js\";\nimport type { SmartAccountSigner } from \"./types\";\n\n/**\n * Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, and sign typed data.\n */\nexport class WalletClientSigner implements SmartAccountSigner<WalletClient> {\n signerType: string;\n inner: WalletClient;\n\n /**\n * Initializes a signer with a given wallet client and signer type.\n *\n * @example\n * ```ts\n * import { WalletClientSigner } from \"@aa-sdk/core\";\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum!)\n * });\n *\n * const signer = new WalletClientSigner(client, 'wallet');\n * ```\n *\n * @param {WalletClient} client The wallet client to interact with\n * @param {string} signerType The type of signer; must be a valid signer type, otherwise an error will be thrown\n * @throws {InvalidSignerTypeError} If the signer type is invalid\n */\n constructor(client: WalletClient, signerType: string) {\n this.inner = client;\n if (!signerType) {\n throw new InvalidSignerTypeError(signerType);\n }\n this.signerType = signerType;\n }\n\n /**\n * Asynchronously retrieves addresses from the inner object and returns the first address after applying the `getAddress` function.\n *\n * @example\n * ```ts\n * import { WalletClientSigner } from \"@aa-sdk/core\";\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum!)\n * });\n *\n * const signer = new WalletClientSigner(client, 'wallet');\n * console.log(await signer.getAddress());\n * ```\n *\n * @returns {Promise<string>} A promise that resolves to the first address after being processed by the `getAddress` function.\n */\n getAddress: () => Promise<`0x${string}`> = async () => {\n let addresses = await this.inner.getAddresses();\n return getAddress(addresses[0]);\n };\n\n /**\n * Signs a message using the account's signing method.\n *\n * @example\n * ```ts\n * import { WalletClientSigner } from \"@aa-sdk/core\";\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum!)\n * });\n *\n * const signer = new WalletClientSigner(client, 'wallet');\n * console.log(await signer.signMessage(\"hello\"));\n * ```\n *\n * @param {string} message the message string that needs to be signed\n * @returns {Promise<string>} a promise that resolves to the signed message\n */\n readonly signMessage: (message: SignableMessage) => Promise<`0x${string}`> =\n async (message) => {\n const account = this.inner.account ?? (await this.getAddress());\n\n return this.inner.signMessage({ message, account });\n };\n\n /**\n * Signs the provided typed data using the account's private key.\n *\n * @example\n * ```ts\n * import { WalletClientSigner } from \"@aa-sdk/core\";\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum!)\n * });\n *\n * const signer = new WalletClientSigner(client, 'wallet');\n * console.log(await signer.signTypedData({\n * types: {\n * \"Message\": [{ name: \"content\", type: \"string\" }]\n * },\n * primaryType: \"Message\",\n * message: { content: \"Hello\" },\n * }));\n * ```\n *\n * @param {TypedDataDefinition<TTypedData, TPrimaryType>} typedData The typed data to be signed\n * @returns {Promise<Hex>} A promise that resolves to a hex string representing the signed data\n */\n signTypedData = async <\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | \"EIP712Domain\" | string = string\n >(\n typedData: TypedDataDefinition<TTypedData, TPrimaryType>\n ): Promise<Hex> => {\n const account = this.inner.account ?? (await this.getAddress());\n\n const params = {\n account,\n ...typedData,\n } as SignTypedDataParameters<TTypedData, string, Account | undefined>;\n\n return this.inner.signTypedData<TTypedData, string>(params);\n };\n}\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "4.13.1-alpha.0";
1
+ export declare const VERSION = "4.15.0";
@@ -1,4 +1,4 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "4.13.1-alpha.0";
3
+ export const VERSION = "4.15.0";
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.13.1-alpha.0\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.15.0\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"0.7.d.ts","sourceRoot":"","sources":["../../../src/entrypoint/0.7.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,OAAO,EAEZ,KAAK,IAAI,EACT,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EACV,oBAAoB,EACpB,uBAAuB,EACxB,MA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,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC,CAKtE;IAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6HAKV,QAAQ,GAAG,CAAC,CASb;CACH"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "4.13.1-alpha.0";
1
+ export declare const VERSION = "4.15.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,mBAAmB,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aa-sdk/core",
3
3
  "license": "MIT",
4
- "version": "4.13.1-alpha.0",
4
+ "version": "4.15.0",
5
5
  "description": "viem based SDK that enables interactions with ERC-4337 Smart Accounts. ABIs are based off the definitions generated in @account-abstraction/contracts",
6
6
  "author": "Alchemy",
7
7
  "type": "module",
@@ -65,5 +65,5 @@
65
65
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
66
66
  },
67
67
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
68
- "gitHead": "d026b488ed279f04424c57b745efb19b8d344056"
68
+ "gitHead": "9561e51d921c231e51e2f859b3f5c93f47b6ffd0"
69
69
  }
@@ -62,7 +62,7 @@ export type SmartAccountClientRpcSchema = [
62
62
  ...PublicRpcSchema
63
63
  ];
64
64
 
65
- //#region SmartAccountClientActions
65
+ // [!region SmartAccountClientActions]
66
66
  export type SmartAccountClientActions<
67
67
  chain extends Chain | undefined = Chain | undefined,
68
68
  account extends SmartContractAccount | undefined =
@@ -74,9 +74,9 @@ export type SmartAccountClientActions<
74
74
  > = BaseSmartAccountClientActions<chain, account, context> &
75
75
  BundlerActions &
76
76
  PublicActions;
77
- //#endregion SmartAccountClientActions
77
+ // [!endregion SmartAccountClientActions]
78
78
 
79
- //#region SmartAccountClient
79
+ // [!region SmartAccountClient]
80
80
  export type SmartAccountClient<
81
81
  transport extends Transport = Transport,
82
82
  chain extends Chain | undefined = Chain | undefined,
@@ -97,7 +97,7 @@ export type SmartAccountClient<
97
97
  actions & SmartAccountClientActions<chain, account, context>
98
98
  >
99
99
  >;
100
- //#endregion SmartAccountClient
100
+ // [!endregion SmartAccountClient]
101
101
 
102
102
  export type BaseSmartAccountClient<
103
103
  transport extends Transport = Transport,
@@ -22,35 +22,24 @@ const packUserOperation = (request: UserOperationRequest<"0.7.0">): Hex => {
22
22
  request.factory && request.factoryData
23
23
  ? concat([request.factory, request.factoryData])
24
24
  : "0x";
25
- const accountGasLimits = packAccountGasLimits(
26
- (({ verificationGasLimit, callGasLimit }) => ({
27
- verificationGasLimit,
28
- callGasLimit,
29
- }))(request)
30
- );
25
+ const accountGasLimits = packAccountGasLimits({
26
+ verificationGasLimit: request.verificationGasLimit,
27
+ callGasLimit: request.callGasLimit,
28
+ });
31
29
 
32
- const gasFees = packAccountGasLimits(
33
- (({ maxPriorityFeePerGas, maxFeePerGas }) => ({
34
- maxPriorityFeePerGas,
35
- maxFeePerGas,
36
- }))(request)
37
- );
30
+ const gasFees = packAccountGasLimits({
31
+ maxPriorityFeePerGas: request.maxPriorityFeePerGas,
32
+ maxFeePerGas: request.maxFeePerGas,
33
+ });
38
34
 
39
35
  const paymasterAndData =
40
36
  request.paymaster && isAddress(request.paymaster)
41
- ? packPaymasterData(
42
- (({
43
- paymaster,
44
- paymasterVerificationGasLimit,
45
- paymasterPostOpGasLimit,
46
- paymasterData,
47
- }) => ({
48
- paymaster,
49
- paymasterVerificationGasLimit,
50
- paymasterPostOpGasLimit,
51
- paymasterData,
52
- }))(request)
53
- )
37
+ ? packPaymasterData({
38
+ paymaster: request.paymaster,
39
+ paymasterVerificationGasLimit: request.paymasterVerificationGasLimit,
40
+ paymasterPostOpGasLimit: request.paymasterPostOpGasLimit,
41
+ paymasterData: request.paymasterData,
42
+ })
54
43
  : "0x";
55
44
 
56
45
  return encodeAbiParameters(
@@ -1,5 +1,4 @@
1
1
  import {
2
- bytesToHex,
3
2
  getAddress,
4
3
  type Hex,
5
4
  type SignableMessage,
@@ -98,16 +97,7 @@ export class WalletClientSigner implements SmartAccountSigner<WalletClient> {
98
97
  async (message) => {
99
98
  const account = this.inner.account ?? (await this.getAddress());
100
99
 
101
- // Seems Wallet Connect only supports signing string messages.
102
- return this.inner.signMessage({
103
- message:
104
- typeof message === "string"
105
- ? message
106
- : typeof message.raw === "string"
107
- ? message.raw
108
- : bytesToHex(message.raw),
109
- account,
110
- });
100
+ return this.inner.signMessage({ message, account });
111
101
  };
112
102
 
113
103
  /**
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "4.13.1-alpha.0";
3
+ export const VERSION = "4.15.0";