@aa-sdk/core 4.15.0 → 4.15.2

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.
@@ -55,8 +55,6 @@ export const default7702GasEstimator = (gasEstimator) => async (struct, params)
55
55
  s: zeroHash,
56
56
  yParity: "0x0",
57
57
  };
58
- const estimatedUO = await gasEstimator_(struct, params);
59
- estimatedUO.eip7702Auth = undefined; // Strip out the auth after estimation.
60
- return estimatedUO;
58
+ return gasEstimator_(struct, params);
61
59
  };
62
60
  //# sourceMappingURL=7702gasEstimator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"7702gasEstimator.js","sourceRoot":"","sources":["../../../../src/middleware/defaults/7702gasEstimator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAG/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAGlC,CAAC,YAAiC,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;IAC9D,MAAM,aAAa,GAAG,YAAY,IAAI,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEzE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;IACxD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAC3C,IAAI,UAAU,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;IACJ,CAAC;IAED,MAAM,qBAAqB,GAAG,MAAM,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAEvE,+FAA+F;IAE9F,MAAuC,CAAC,WAAW,GAAG;QACrD,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,qBAAqB;QAC9B,CAAC,EAAE,QAAQ,EAAE,mBAAmB;QAChC,CAAC,EAAE,QAAQ;QACX,OAAO,EAAE,KAAK;KACf,CAAC;IAEF,MAAM,WAAW,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAExD,WAAW,CAAC,WAAW,GAAG,SAAS,CAAC,CAAC,uCAAuC;IAE5E,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC","sourcesContent":["import { zeroHash } from \"viem\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport type { UserOperationStruct } from \"../../types.js\";\nimport type { ClientMiddlewareFn } from \"../types\";\nimport { defaultGasEstimator } from \"./gasEstimator.js\";\n\n/**\n * A middleware function to estimate the gas usage of a user operation when using an EIP-7702 delegated account. Has an optional custom gas estimator.\n * This function is only compatible with accounts using EntryPoint v0.7.0, and the account must have an implementation address defined in `getImplementationAddress()`.\n *\n * @example\n * ```ts twoslash\n * import {\n * default7702GasEstimator,\n * default7702UserOpSigner,\n * createSmartAccountClient,\n * type SmartAccountClient,\n * } from \"@aa-sdk/core\";\n * import {\n * createModularAccountV2,\n * type CreateModularAccountV2ClientParams,\n * } from \"@account-kit/smart-contracts\";\n *\n * async function createSMA7702AccountClient(\n * config: CreateModularAccountV2ClientParams\n * ): Promise<SmartAccountClient> {\n * const sma7702Account = await createModularAccountV2({ ...config, mode: \"7702\" });\n *\n * return createSmartAccountClient({\n * account: sma7702Account,\n * gasEstimator: default7702GasEstimator(config.gasEstimator),\n * signUserOperation: default7702UserOpSigner(config.signUserOperation),\n * ...config,\n * });\n * }\n * ```\n *\n * @param {ClientMiddlewareFn} [gasEstimator] Optional custom gas estimator function\n * @returns {Function} A function that takes user operation struct and parameters, estimates gas usage, and returns the user operation with gas limits.\n */\nexport const default7702GasEstimator: (\n gasEstimator?: ClientMiddlewareFn\n) => ClientMiddlewareFn =\n (gasEstimator?: ClientMiddlewareFn) => async (struct, params) => {\n const gasEstimator_ = gasEstimator ?? defaultGasEstimator(params.client);\n\n const account = params.account ?? params.client.account;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n const entryPoint = account.getEntryPoint();\n if (entryPoint.version !== \"0.7.0\") {\n throw new Error(\n \"This middleware is only compatible with EntryPoint v0.7.0\"\n );\n }\n\n const implementationAddress = await account.getImplementationAddress();\n\n // Note: does not omit the delegation from estimation if the account is already 7702 delegated.\n\n (struct as UserOperationStruct<\"0.7.0\">).eip7702Auth = {\n chainId: \"0x0\",\n nonce: \"0x0\",\n address: implementationAddress,\n r: zeroHash, // aka `bytes32(0)`\n s: zeroHash,\n yParity: \"0x0\",\n };\n\n const estimatedUO = await gasEstimator_(struct, params);\n\n estimatedUO.eip7702Auth = undefined; // Strip out the auth after estimation.\n\n return estimatedUO;\n };\n"]}
1
+ {"version":3,"file":"7702gasEstimator.js","sourceRoot":"","sources":["../../../../src/middleware/defaults/7702gasEstimator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAG/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAGlC,CAAC,YAAiC,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;IAC9D,MAAM,aAAa,GAAG,YAAY,IAAI,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEzE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;IACxD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAC3C,IAAI,UAAU,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;IACJ,CAAC;IAED,MAAM,qBAAqB,GAAG,MAAM,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAEvE,+FAA+F;IAE9F,MAAuC,CAAC,WAAW,GAAG;QACrD,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,qBAAqB;QAC9B,CAAC,EAAE,QAAQ,EAAE,mBAAmB;QAChC,CAAC,EAAE,QAAQ;QACX,OAAO,EAAE,KAAK;KACf,CAAC;IAEF,OAAO,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACvC,CAAC,CAAC","sourcesContent":["import { zeroHash } from \"viem\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport type { UserOperationStruct } from \"../../types.js\";\nimport type { ClientMiddlewareFn } from \"../types\";\nimport { defaultGasEstimator } from \"./gasEstimator.js\";\n\n/**\n * A middleware function to estimate the gas usage of a user operation when using an EIP-7702 delegated account. Has an optional custom gas estimator.\n * This function is only compatible with accounts using EntryPoint v0.7.0, and the account must have an implementation address defined in `getImplementationAddress()`.\n *\n * @example\n * ```ts twoslash\n * import {\n * default7702GasEstimator,\n * default7702UserOpSigner,\n * createSmartAccountClient,\n * type SmartAccountClient,\n * } from \"@aa-sdk/core\";\n * import {\n * createModularAccountV2,\n * type CreateModularAccountV2ClientParams,\n * } from \"@account-kit/smart-contracts\";\n *\n * async function createSMA7702AccountClient(\n * config: CreateModularAccountV2ClientParams\n * ): Promise<SmartAccountClient> {\n * const sma7702Account = await createModularAccountV2({ ...config, mode: \"7702\" });\n *\n * return createSmartAccountClient({\n * account: sma7702Account,\n * gasEstimator: default7702GasEstimator(config.gasEstimator),\n * signUserOperation: default7702UserOpSigner(config.signUserOperation),\n * ...config,\n * });\n * }\n * ```\n *\n * @param {ClientMiddlewareFn} [gasEstimator] Optional custom gas estimator function\n * @returns {Function} A function that takes user operation struct and parameters, estimates gas usage, and returns the user operation with gas limits.\n */\nexport const default7702GasEstimator: (\n gasEstimator?: ClientMiddlewareFn\n) => ClientMiddlewareFn =\n (gasEstimator?: ClientMiddlewareFn) => async (struct, params) => {\n const gasEstimator_ = gasEstimator ?? defaultGasEstimator(params.client);\n\n const account = params.account ?? params.client.account;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n const entryPoint = account.getEntryPoint();\n if (entryPoint.version !== \"0.7.0\") {\n throw new Error(\n \"This middleware is only compatible with EntryPoint v0.7.0\"\n );\n }\n\n const implementationAddress = await account.getImplementationAddress();\n\n // Note: does not omit the delegation from estimation if the account is already 7702 delegated.\n\n (struct as UserOperationStruct<\"0.7.0\">).eip7702Auth = {\n chainId: \"0x0\",\n nonce: \"0x0\",\n address: implementationAddress,\n r: zeroHash, // aka `bytes32(0)`\n s: zeroHash,\n yParity: \"0x0\",\n };\n\n return gasEstimator_(struct, params);\n };\n"]}
@@ -40,7 +40,11 @@ import { defaultUserOpSigner } from "./userOpSigner.js";
40
40
  */
41
41
  export const default7702UserOpSigner = (userOpSigner) => async (struct, params) => {
42
42
  const userOpSigner_ = userOpSigner ?? defaultUserOpSigner;
43
- const uo = await userOpSigner_(struct, params);
43
+ const uo = await userOpSigner_({
44
+ ...struct,
45
+ // Strip out the dummy eip7702 fields.
46
+ eip7702Auth: undefined,
47
+ }, params);
44
48
  const account = params.account ?? params.client.account;
45
49
  const { client } = params;
46
50
  if (!account || !isSmartAccountWithSigner(account)) {
@@ -1 +1 @@
1
- {"version":3,"file":"7702signer.js","sourceRoot":"","sources":["../../../../src/middleware/defaults/7702signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;A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AG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEvD,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC;QACtD,iHAAiH;QACjH,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC;QAC3D,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC;QACnD,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE;QACxB,eAAe,EAAE,WAAW;QAC5B,KAAK,EAAE,YAAY;KACpB,CAAC,CAAC;IAEH,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,aAAa,CAAC;IAE/B,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,aAAa,CAAC,CAAC,GAAG,GAAG,CAAC;IAE/D,OAAO;QACL,GAAG,EAAE;QACL,WAAW,EAAE;YACX,kEAAkE;YAClE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC;YAC1B,OAAO,EAAE,WAAW;YACpB,CAAC;YACD,CAAC;YACD,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;SACxB;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { toHex } from \"viem\";\nimport { isSmartAccountWithSigner } from \"../../account/smartContractAccount.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { ChainNotFoundError } from \"../../errors/client.js\";\nimport type { ClientMiddlewareFn } from \"../types\";\nimport { defaultUserOpSigner } from \"./userOpSigner.js\";\n\n/**\n * Provides a default middleware function for signing user operations with a client account when using EIP-7702 delegated accounts.\n * If the signer doesn't support `signAuthorization`, then this just runs the provided `signUserOperation` middleware.\n * This function is only compatible with accounts using EntryPoint v0.7.0, and the account must have an implementation address defined in `getImplementationAddress()`.\n *\n * @example\n * ```ts twoslash\n * import {\n * default7702GasEstimator,\n * default7702UserOpSigner,\n * createSmartAccountClient,\n * type SmartAccountClient,\n * } from \"@aa-sdk/core\";\n * import {\n * createModularAccountV2,\n * type CreateModularAccountV2ClientParams,\n * } from \"@account-kit/smart-contracts\";\n *\n * async function createSMA7702AccountClient(\n * config: CreateModularAccountV2ClientParams\n * ): Promise<SmartAccountClient> {\n * const sma7702Account = await createModularAccountV2({ ...config, mode: \"7702\" });\n *\n * return createSmartAccountClient({\n * account: sma7702Account,\n * gasEstimator: default7702GasEstimator(config.gasEstimator),\n * signUserOperation: default7702UserOpSigner(config.signUserOperation),\n * ...config,\n * });\n * }\n * ```\n *\n * @param {ClientMiddlewareFn} [userOpSigner] Optional user operation signer function\n * @returns {Function} A middleware function that signs EIP-7702 authorization tuples if necessary, and also uses the provided or default user operation signer to generate the user op signature.\n */\nexport const default7702UserOpSigner: (\n userOpSigner?: ClientMiddlewareFn\n) => ClientMiddlewareFn =\n (userOpSigner?: ClientMiddlewareFn) => async (struct, params) => {\n const userOpSigner_ = userOpSigner ?? defaultUserOpSigner;\n\n const uo = await userOpSigner_(struct, params);\n\n const account = params.account ?? params.client.account;\n const { client } = params;\n\n if (!account || !isSmartAccountWithSigner(account)) {\n throw new AccountNotFoundError();\n }\n\n const signer = account.getSigner();\n\n if (!signer.signAuthorization) {\n return uo;\n }\n\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const code = (await client.getCode({ address: account.address })) ?? \"0x\";\n\n const implAddress = await account.getImplementationAddress();\n\n const expectedCode = \"0xef0100\" + implAddress.slice(2);\n\n if (code.toLowerCase() === expectedCode.toLowerCase()) {\n // If the delegation already matches the expected, then we don't need to sign and include an authorization tuple.\n return uo;\n }\n\n const accountNonce = await params.client.getTransactionCount({\n address: account.address,\n });\n\n const authSignature = await signer.signAuthorization({\n chainId: client.chain.id,\n contractAddress: implAddress,\n nonce: accountNonce,\n });\n\n const { r, s } = authSignature;\n\n const yParity = authSignature.yParity ?? authSignature.v - 27n;\n\n return {\n ...uo,\n eip7702Auth: {\n // deepHexlify doesn't encode number(0) correctly, it returns \"0x\"\n chainId: toHex(client.chain.id),\n nonce: toHex(accountNonce),\n address: implAddress,\n r,\n s,\n yParity: toHex(yParity),\n },\n };\n };\n"]}
1
+ {"version":3,"file":"7702signer.js","sourceRoot":"","sources":["../../../../src/middleware/defaults/7702signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAGlC,CAAC,YAAiC,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;IAC9D,MAAM,aAAa,GAAG,YAAY,IAAI,mBAAmB,CAAC;IAE1D,MAAM,EAAE,GAAG,MAAM,aAAa,CAC5B;QACE,GAAG,MAAM;QACT,sCAAsC;QACtC,WAAW,EAAE,SAAS;KACvB,EACD,MAAM,CACP,CAAC;IAEF,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;IACxD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAE1B,IAAI,CAAC,OAAO,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC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,CAAC;YACD,CAAC;YACD,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;SACxB;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { toHex } from \"viem\";\nimport { isSmartAccountWithSigner } from \"../../account/smartContractAccount.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { ChainNotFoundError } from \"../../errors/client.js\";\nimport type { ClientMiddlewareFn } from \"../types\";\nimport { defaultUserOpSigner } from \"./userOpSigner.js\";\n\n/**\n * Provides a default middleware function for signing user operations with a client account when using EIP-7702 delegated accounts.\n * If the signer doesn't support `signAuthorization`, then this just runs the provided `signUserOperation` middleware.\n * This function is only compatible with accounts using EntryPoint v0.7.0, and the account must have an implementation address defined in `getImplementationAddress()`.\n *\n * @example\n * ```ts twoslash\n * import {\n * default7702GasEstimator,\n * default7702UserOpSigner,\n * createSmartAccountClient,\n * type SmartAccountClient,\n * } from \"@aa-sdk/core\";\n * import {\n * createModularAccountV2,\n * type CreateModularAccountV2ClientParams,\n * } from \"@account-kit/smart-contracts\";\n *\n * async function createSMA7702AccountClient(\n * config: CreateModularAccountV2ClientParams\n * ): Promise<SmartAccountClient> {\n * const sma7702Account = await createModularAccountV2({ ...config, mode: \"7702\" });\n *\n * return createSmartAccountClient({\n * account: sma7702Account,\n * gasEstimator: default7702GasEstimator(config.gasEstimator),\n * signUserOperation: default7702UserOpSigner(config.signUserOperation),\n * ...config,\n * });\n * }\n * ```\n *\n * @param {ClientMiddlewareFn} [userOpSigner] Optional user operation signer function\n * @returns {Function} A middleware function that signs EIP-7702 authorization tuples if necessary, and also uses the provided or default user operation signer to generate the user op signature.\n */\nexport const default7702UserOpSigner: (\n userOpSigner?: ClientMiddlewareFn\n) => ClientMiddlewareFn =\n (userOpSigner?: ClientMiddlewareFn) => async (struct, params) => {\n const userOpSigner_ = userOpSigner ?? defaultUserOpSigner;\n\n const uo = await userOpSigner_(\n {\n ...struct,\n // Strip out the dummy eip7702 fields.\n eip7702Auth: undefined,\n },\n params\n );\n\n const account = params.account ?? params.client.account;\n const { client } = params;\n\n if (!account || !isSmartAccountWithSigner(account)) {\n throw new AccountNotFoundError();\n }\n\n const signer = account.getSigner();\n\n if (!signer.signAuthorization) {\n return uo;\n }\n\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const code = (await client.getCode({ address: account.address })) ?? \"0x\";\n\n const implAddress = await account.getImplementationAddress();\n\n const expectedCode = \"0xef0100\" + implAddress.slice(2);\n\n if (code.toLowerCase() === expectedCode.toLowerCase()) {\n // If the delegation already matches the expected, then we don't need to sign and include an authorization tuple.\n return uo;\n }\n\n const accountNonce = await params.client.getTransactionCount({\n address: account.address,\n });\n\n const authSignature = await signer.signAuthorization({\n chainId: client.chain.id,\n contractAddress: implAddress,\n nonce: accountNonce,\n });\n\n const { r, s } = authSignature;\n\n const yParity = authSignature.yParity ?? authSignature.v - 27n;\n\n return {\n ...uo,\n eip7702Auth: {\n // deepHexlify doesn't encode number(0) correctly, it returns \"0x\"\n chainId: toHex(client.chain.id),\n nonce: toHex(accountNonce),\n address: implAddress,\n r,\n s,\n yParity: toHex(yParity),\n },\n };\n };\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "4.15.0";
1
+ export declare const VERSION = "4.15.2";
@@ -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.15.0";
3
+ export const VERSION = "4.15.2";
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,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
+ {"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.2\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"7702gasEstimator.d.ts","sourceRoot":"","sources":["../../../../src/middleware/defaults/7702gasEstimator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,uBAAuB,EAAE,CACpC,YAAY,CAAC,EAAE,kBAAkB,KAC9B,kBAkCF,CAAC"}
1
+ {"version":3,"file":"7702gasEstimator.d.ts","sourceRoot":"","sources":["../../../../src/middleware/defaults/7702gasEstimator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,uBAAuB,EAAE,CACpC,YAAY,CAAC,EAAE,kBAAkB,KAC9B,kBA8BF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"7702signer.d.ts","sourceRoot":"","sources":["../../../../src/middleware/defaults/7702signer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,uBAAuB,EAAE,CACpC,YAAY,CAAC,EAAE,kBAAkB,KAC9B,kBA4DF,CAAC"}
1
+ {"version":3,"file":"7702signer.d.ts","sourceRoot":"","sources":["../../../../src/middleware/defaults/7702signer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,uBAAuB,EAAE,CACpC,YAAY,CAAC,EAAE,kBAAkB,KAC9B,kBAmEF,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "4.15.0";
1
+ export declare const VERSION = "4.15.2";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aa-sdk/core",
3
3
  "license": "MIT",
4
- "version": "4.15.0",
4
+ "version": "4.15.2",
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": "9561e51d921c231e51e2f859b3f5c93f47b6ffd0"
68
+ "gitHead": "c69762a97a77be62706accec8b9af908c836ccd5"
69
69
  }
@@ -69,9 +69,5 @@ export const default7702GasEstimator: (
69
69
  yParity: "0x0",
70
70
  };
71
71
 
72
- const estimatedUO = await gasEstimator_(struct, params);
73
-
74
- estimatedUO.eip7702Auth = undefined; // Strip out the auth after estimation.
75
-
76
- return estimatedUO;
72
+ return gasEstimator_(struct, params);
77
73
  };
@@ -46,7 +46,14 @@ export const default7702UserOpSigner: (
46
46
  (userOpSigner?: ClientMiddlewareFn) => async (struct, params) => {
47
47
  const userOpSigner_ = userOpSigner ?? defaultUserOpSigner;
48
48
 
49
- const uo = await userOpSigner_(struct, params);
49
+ const uo = await userOpSigner_(
50
+ {
51
+ ...struct,
52
+ // Strip out the dummy eip7702 fields.
53
+ eip7702Auth: undefined,
54
+ },
55
+ params
56
+ );
50
57
 
51
58
  const account = params.account ?? params.client.account;
52
59
  const { client } = params;
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.15.0";
3
+ export const VERSION = "4.15.2";