@aa-sdk/core 4.41.0 → 4.43.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.
@@ -201,9 +201,6 @@ export async function toSmartContractAccount(params) {
201
201
  };
202
202
  const getNonce_ = getNonce ??
203
203
  (async (nonceKey = 0n) => {
204
- if (!(await isAccountDeployed())) {
205
- return 0n;
206
- }
207
204
  return entryPointContract.read.getNonce([
208
205
  accountAddress_,
209
206
  nonceKey,
@@ -1 +1 @@
1
- {"version":3,"file":"smartContractAccount.js","sourceRoot":"","sources":["../../../src/account/smartContractAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,UAAU,GAWX,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAMjE,OAAO,EACL,+BAA+B,EAC/B,2BAA2B,EAC3B,6BAA6B,EAC7B,gCAAgC,EAChC,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAU3D,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,uCAAoB,CAAA;IACpB,mCAAgB,CAAA;AAClB,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AAmDD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,OAA6B,EACc,EAAE;IAC7C,OAAO,WAAW,IAAI,OAAO,CAAC;AAChC,CAAC,CAAC;AA6DF,4CAA4C;AAE5C;;;;;;;;;;;;GAYG;AACH,MA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B;QAC7C,iBAAiB;QACjB,cAAc;QACd,kBAAkB,EAChB,kBAAkB;YAClB,CAAC,GAAG,EAAE;gBACJ,MAAM,IAAI,+BAA+B,CAAC,MAAM,CAAC,CAAC;YACpD,CAAC,CAAC;QACJ,aAAa;QACb,iBAAiB;QACjB,WAAW;QACX,sBAAsB,EAAE,uBAAuB;QAC/C,aAAa,EAAE,GAAG,EAAE,CAAC,UAAU;QAC/B,iBAAiB;QACjB,eAAe,EAAE,SAAS;QAC1B,mBAAmB;QACnB,qBAAqB;QACrB,wBAAwB,EAAE,yBAAyB;QACnD,WAAW;QACX,UAAU;KACX,CAAC;AACJ,CAAC","sourcesContent":["import {\n getContract,\n hexToBytes,\n type Address,\n type Chain,\n type CustomSource,\n type Hex,\n type LocalAccount,\n type PublicClient,\n type SignableMessage,\n type Transport,\n type TypedData,\n type TypedDataDefinition,\n} from \"viem\";\nimport { toAccount } from \"viem/accounts\";\nimport { createBundlerClient } from \"../client/bundlerClient.js\";\nimport type {\n EntryPointDef,\n EntryPointRegistryBase,\n EntryPointVersion,\n} from \"../entrypoint/types.js\";\nimport {\n BatchExecutionNotSupportedError,\n FailedToGetStorageSlotError,\n GetCounterFactualAddressError,\n SignTransactionNotSupportedError,\n UpgradesNotSupportedError,\n} from \"../errors/account.js\";\nimport { InvalidRpcUrlError } from \"../errors/client.js\";\nimport { InvalidEntryPointError } from \"../errors/entrypoint.js\";\nimport { Logger } from \"../logger.js\";\nimport type { SmartAccountSigner } from \"../signer/types.js\";\nimport { wrapSignatureWith6492 } from \"../signer/utils.js\";\nimport type { NullAddress } from \"../types.js\";\nimport type { IsUndefined, Never } from \"../utils/types.js\";\n\nexport type AccountOp = {\n target: Address;\n value?: bigint;\n data: Hex | \"0x\";\n};\n\nexport enum DeploymentState {\n UNDEFINED = \"0x0\",\n NOT_DEPLOYED = \"0x1\",\n DEPLOYED = \"0x2\",\n}\n\nexport type SignatureRequest =\n | {\n type: \"personal_sign\";\n data: SignableMessage;\n }\n | {\n type: \"eth_signTypedData_v4\";\n data: TypedDataDefinition;\n };\n\nexport type SigningMethods = {\n prepareSign: (request: SignatureRequest) => Promise<SignatureRequest>;\n formatSign: (signature: Hex) => Promise<Hex>;\n};\n\nexport type GetEntryPointFromAccount<\n TAccount extends SmartContractAccount | undefined,\n TAccountOverride extends SmartContractAccount = SmartContractAccount,\n> =\n GetAccountParameter<TAccount, TAccountOverride> extends SmartContractAccount<\n string,\n infer TEntryPointVersion\n >\n ? TEntryPointVersion\n : EntryPointVersion;\n\nexport type GetAccountParameter<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TAccountOverride extends SmartContractAccount = SmartContractAccount,\n> =\n IsUndefined<TAccount> extends true\n ? { account: TAccountOverride }\n : { account?: TAccountOverride };\n\nexport type UpgradeToAndCallParams = {\n upgradeToAddress: Address;\n upgradeToInitData: Hex;\n};\n\nexport type SmartContractAccountWithSigner<\n Name extends string = string,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion,\n> = SmartContractAccount<Name, TEntryPointVersion> & {\n getSigner: () => TSigner;\n};\n\n/**\n * Determines if the given SmartContractAccount has a signer associated with it.\n *\n * @example\n * ```ts\n * import { toSmartContractAccount } from \"@aa-sdk/core\";\n *\n * const account = await toSmartContractAccount(...);\n *\n * console.log(isSmartAccountWithSigner(account)); // false: the base account does not have a publicly accessible signer\n * ```\n *\n * @param {SmartContractAccount} account The account to check.\n * @returns {boolean} true if the account has a signer, otherwise false.\n */\nexport const isSmartAccountWithSigner = (\n account: SmartContractAccount,\n): account is SmartContractAccountWithSigner => {\n return \"getSigner\" in account;\n};\n\n// [!region SmartContractAccount]\nexport type SmartContractAccount<\n Name extends string = string,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion,\n> = LocalAccount<Name> & {\n source: Name;\n getDummySignature: () => Hex | Promise<Hex>;\n encodeExecute: (tx: AccountOp) => Promise<Hex>;\n encodeBatchExecute: (txs: AccountOp[]) => Promise<Hex>;\n signUserOperationHash: (uoHash: Hex) => Promise<Hex>;\n signMessageWith6492: (params: { message: SignableMessage }) => Promise<Hex>;\n signTypedDataWith6492: <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | \"EIP712Domain\" = keyof typedData,\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>,\n ) => Promise<Hex>;\n encodeUpgradeToAndCall: (params: UpgradeToAndCallParams) => Promise<Hex>;\n getAccountNonce(nonceKey?: bigint): Promise<bigint>;\n getInitCode: () => Promise<Hex>;\n isAccountDeployed: () => Promise<boolean>;\n getFactoryAddress: () => Promise<Address>;\n getFactoryData: () => Promise<Hex>;\n getEntryPoint: () => EntryPointDef<TEntryPointVersion>;\n getImplementationAddress: () => Promise<NullAddress | Address>;\n} & SigningMethods;\n// [!endregion SmartContractAccount]\n\nexport interface AccountEntryPointRegistry<Name extends string = string>\n extends EntryPointRegistryBase<\n SmartContractAccount<Name, EntryPointVersion>\n > {\n \"0.6.0\": SmartContractAccount<Name, \"0.6.0\">;\n \"0.7.0\": SmartContractAccount<Name, \"0.7.0\">;\n}\n\n// [!region ToSmartContractAccountParams]\nexport type ToSmartContractAccountParams<\n Name extends string = string,\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion,\n> = {\n source: Name;\n transport: TTransport;\n chain: TChain;\n entryPoint: EntryPointDef<TEntryPointVersion, TChain>;\n accountAddress?: Address;\n getAccountInitCode: () => Promise<Hex>;\n getDummySignature: () => Hex | Promise<Hex>;\n encodeExecute: (tx: AccountOp) => Promise<Hex>;\n encodeBatchExecute?: (txs: AccountOp[]) => Promise<Hex>;\n getNonce?: (nonceKey?: bigint) => Promise<bigint>;\n // if not provided, will default to just using signMessage over the Hex\n signUserOperationHash?: (uoHash: Hex) => Promise<Hex>;\n encodeUpgradeToAndCall?: (params: UpgradeToAndCallParams) => Promise<Hex>;\n getImplementationAddress?: () => Promise<NullAddress | Address>;\n} & Omit<CustomSource, \"signTransaction\" | \"address\"> &\n (SigningMethods | Never<SigningMethods>);\n// [!endregion ToSmartContractAccountParams]\n\n/**\n * Parses the factory address and factory calldata from the provided account initialization code (initCode).\n *\n * @example\n * ```ts\n * import { parseFactoryAddressFromAccountInitCode } from \"@aa-sdk/core\";\n *\n * const [address, calldata] = parseFactoryAddressFromAccountInitCode(\"0xAddressCalldata\");\n * ```\n *\n * @param {Hex} initCode The initialization code from which to parse the factory address and calldata\n * @returns {[Address, Hex]} A tuple containing the parsed factory address and factory calldata\n */\nexport const parseFactoryAddressFromAccountInitCode = (\n initCode: Hex,\n): [Address, Hex] => {\n const factoryAddress: Address = `0x${initCode.substring(2, 42)}`;\n const factoryCalldata: Hex = `0x${initCode.substring(42)}`;\n return [factoryAddress, factoryCalldata];\n};\n\nexport type GetAccountAddressParams = {\n client: PublicClient;\n entryPoint: EntryPointDef;\n accountAddress?: Address;\n getAccountInitCode: () => Promise<Hex>;\n};\n\n/**\n * Retrieves the account address. Uses a provided `accountAddress` if available; otherwise, it computes the address using the entry point contract and the initial code.\n *\n * @example\n * ```ts\n * import { getEntryPoint, getAccountAddress } from \"@aa-sdk/core\";\n *\n * const accountAddress = await getAccountAddress({\n * client,\n * entryPoint: getEntryPoint(chain),\n * getAccountInitCode: async () => \"0x{factoryAddress}{factoryCallData}\",\n * });\n * ```\n *\n * @param {GetAccountAddressParams} params The configuration object\n * @param {PublicClient} params.client A public client instance to interact with the blockchain\n * @param {EntryPointDef} params.entryPoint The entry point definition which includes the address and ABI\n * @param {Address} params.accountAddress Optional existing account address\n * @param {() => Promise<Hex>} params.getAccountInitCode A function that returns a Promise resolving to a Hex string representing the initial code of the account\n * @returns {Promise<Address>} A promise that resolves to the account address\n */\nexport const getAccountAddress = async ({\n client,\n entryPoint,\n accountAddress,\n getAccountInitCode,\n}: GetAccountAddressParams) => {\n if (accountAddress) return accountAddress;\n\n const entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n const initCode = await getAccountInitCode();\n Logger.verbose(\"[BaseSmartContractAccount](getAddress) initCode: \", initCode);\n\n try {\n await entryPointContract.simulate.getSenderAddress([initCode]);\n } catch (err: any) {\n Logger.verbose(\n \"[BaseSmartContractAccount](getAddress) getSenderAddress err: \",\n err,\n );\n if (err.cause?.data?.errorName === \"SenderAddressResult\") {\n Logger.verbose(\n \"[BaseSmartContractAccount](getAddress) entryPoint.getSenderAddress result:\",\n err.cause.data.args[0],\n );\n\n return err.cause.data.args[0] as Address;\n }\n\n if (err.details === \"Invalid URL\") {\n throw new InvalidRpcUrlError();\n }\n }\n\n throw new GetCounterFactualAddressError();\n};\n\n// [!region toSmartContractAccount]\nexport async function toSmartContractAccount<\n Name extends string = string,\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion,\n>({\n transport,\n chain,\n entryPoint,\n source,\n accountAddress,\n getAccountInitCode,\n getNonce,\n signMessage,\n signTypedData,\n encodeBatchExecute,\n encodeExecute,\n getDummySignature,\n signUserOperationHash,\n encodeUpgradeToAndCall,\n}: ToSmartContractAccountParams<\n Name,\n TTransport,\n TChain,\n TEntryPointVersion\n>): Promise<SmartContractAccount<Name, TEntryPointVersion>>;\n// [!endregion toSmartContractAccount]\n\n/**\n * Converts an account to a smart contract account and sets up various account-related methods using the provided parameters like transport, chain, entry point, and other utilities.\n *\n * @example\n * ```ts\n * import { http, type SignableMessage } from \"viem\";\n * import { sepolia } from \"viem/chains\";\n *\n * const myAccount = await toSmartContractAccount({\n * /// REQUIRED PARAMS ///\n * source: \"MyAccount\",\n * transport: http(\"RPC_URL\"),\n * chain: sepolia,\n * // The EntryPointDef that your account is com\"patible with\n * entryPoint: getEntryPoint(sepolia, { version: \"0.6.0\" }),\n * // This should return a concatenation of your `factoryAddress` and the `callData` for your factory's create account method\n * getAccountInitCode: async () => \"0x{factoryAddress}{callData}\",\n * // an invalid signature that doesn't cause your account to revert during validation\n * getDummySignature: () => \"0x1234...\",\n * // given a UO in the form of {target, data, value} should output the calldata for calling your contract's execution method\n * encodeExecute: async (uo) => \"0xcalldata\",\n * signMessage: async ({ message }: { message: SignableMessage }) => \"0x...\",\n * signTypedData: async (typedData) => \"0x000\",\n *\n * /// OPTIONAL PARAMS ///\n * // if you already know your account's address, pass that in here to avoid generating a new counterfactual\n * accountAddress: \"0xaddressoverride\",\n * // if your account supports batching, this should take an array of UOs and return the calldata for calling your contract's batchExecute method\n * encodeBatchExecute: async (uos) => \"0x...\",\n * // if your contract expects a different signing scheme than the default signMessage scheme, you can override that here\n * signUserOperationHash: async (hash) => \"0x...\",\n * // allows you to define the calldata for upgrading your account\n * encodeUpgradeToAndCall: async (params) => \"0x...\",\n * });\n * ```\n *\n * @param {ToSmartContractAccountParams} params the parameters required for converting to a smart contract account\n * @param {Transport} params.transport the transport mechanism used for communication\n * @param {Chain} params.chain the blockchain chain used in the account\n * @param {EntryPoint} params.entryPoint the entry point of the smart contract\n * @param {string} params.source the source identifier for the account\n * @param {Address} [params.accountAddress] the address of the account\n * @param {() => Promise<Hex>} params.getAccountInitCode a function to get the initial state code of the account\n * @param {(message: { message: SignableMessage }) => Promise<Hex>} params.signMessage a function to sign a message\n * @param {(typedDataDefinition: TypedDataDefinition<typedData, primaryType>) => Promise<Hex>} params.signTypedData a function to sign typed data\n * @param {(transactions: Transaction[]) => Hex} [params.encodeBatchExecute] a function to encode batch transactions\n * @param {(tx: Transaction) => Hex} params.encodeExecute a function to encode a single transaction\n * @param {() => Promise<Hex>} params.getDummySignature a function to get a dummy signature\n * @param {(uoHash: Hex) => Promise<Hex>} [params.signUserOperationHash] a function to sign user operations\n * @param {(implementationAddress: Address, implementationCallData: Hex) => Hex} [params.encodeUpgradeToAndCall] a function to encode upgrade call\n * @returns {Promise<SmartContractAccount>} a promise that resolves to a SmartContractAccount object with methods and properties for interacting with the smart contract account\n */\nexport async function toSmartContractAccount(\n params: ToSmartContractAccountParams,\n): Promise<SmartContractAccount> {\n const {\n transport,\n chain,\n entryPoint,\n source,\n accountAddress,\n getAccountInitCode,\n signMessage,\n signTypedData,\n encodeExecute,\n encodeBatchExecute,\n getNonce,\n getDummySignature,\n signUserOperationHash,\n encodeUpgradeToAndCall,\n getImplementationAddress,\n prepareSign: prepareSign_,\n formatSign: formatSign_,\n } = params;\n\n const client = createBundlerClient({\n // we set the retry count to 0 so that viem doesn't retry during\n // getting the address. That call always reverts and without this\n // viem will retry 3 times, making this call very slow\n transport: (opts) => transport({ ...opts, chain, retryCount: 0 }),\n chain,\n });\n\n const entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n const accountAddress_ = await getAccountAddress({\n client,\n entryPoint: entryPoint,\n accountAddress,\n getAccountInitCode,\n });\n\n let deploymentState = DeploymentState.UNDEFINED;\n\n const getInitCode = async () => {\n if (deploymentState === DeploymentState.DEPLOYED) {\n return \"0x\";\n }\n const contractCode = await client.getCode({\n address: accountAddress_,\n });\n\n if ((contractCode?.length ?? 0) > 2) {\n deploymentState = DeploymentState.DEPLOYED;\n return \"0x\";\n } else {\n deploymentState = DeploymentState.NOT_DEPLOYED;\n }\n\n return getAccountInitCode();\n };\n\n const signUserOperationHash_ =\n signUserOperationHash ??\n (async (uoHash: Hex) => {\n return signMessage({ message: { raw: hexToBytes(uoHash) } });\n });\n\n const getFactoryAddress = async (): Promise<Address> =>\n parseFactoryAddressFromAccountInitCode(await getAccountInitCode())[0];\n\n const getFactoryData = async (): Promise<Hex> =>\n parseFactoryAddressFromAccountInitCode(await getAccountInitCode())[1];\n\n const encodeUpgradeToAndCall_ =\n encodeUpgradeToAndCall ??\n (() => {\n throw new UpgradesNotSupportedError(source);\n });\n\n const isAccountDeployed = async () => {\n const initCode = await getInitCode();\n return initCode === \"0x\";\n };\n\n const getNonce_ =\n getNonce ??\n (async (nonceKey = 0n): Promise<bigint> => {\n if (!(await isAccountDeployed())) {\n return 0n;\n }\n\n return entryPointContract.read.getNonce([\n accountAddress_,\n nonceKey,\n ]) as Promise<bigint>;\n });\n\n const account = toAccount({\n address: accountAddress_,\n signMessage,\n signTypedData,\n signTransaction: () => {\n throw new SignTransactionNotSupportedError();\n },\n });\n\n const create6492Signature = async (isDeployed: boolean, signature: Hex) => {\n if (isDeployed) {\n return signature;\n }\n\n const [factoryAddress, factoryCalldata] =\n parseFactoryAddressFromAccountInitCode(await getAccountInitCode());\n\n return wrapSignatureWith6492({\n factoryAddress,\n factoryCalldata,\n signature,\n });\n };\n\n const signMessageWith6492 = async (message: { message: SignableMessage }) => {\n const [isDeployed, signature] = await Promise.all([\n isAccountDeployed(),\n account.signMessage(message),\n ]);\n\n return create6492Signature(isDeployed, signature);\n };\n\n const signTypedDataWith6492 = async <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | \"EIP712Domain\" = keyof typedData,\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>,\n ): Promise<Hex> => {\n const [isDeployed, signature] = await Promise.all([\n isAccountDeployed(),\n account.signTypedData(typedDataDefinition),\n ]);\n\n return create6492Signature(isDeployed, signature);\n };\n\n const getImplementationAddress_ =\n getImplementationAddress ??\n (async () => {\n const storage = await client.getStorageAt({\n address: account.address,\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 // The storage slot contains a full bytes32, but we want only the last 20 bytes.\n // So, slice off the leading `0x` and the first 12 bytes (24 characters), leaving the last 20 bytes, then prefix with `0x`.\n return `0x${storage.slice(26)}`;\n });\n\n if (entryPoint.version !== \"0.6.0\" && entryPoint.version !== \"0.7.0\") {\n throw new InvalidEntryPointError(chain, entryPoint.version);\n }\n\n if ((prepareSign_ && !formatSign_) || (!prepareSign_ && formatSign_)) {\n throw new Error(\n \"Must implement both prepareSign and formatSign or neither\",\n );\n }\n\n const prepareSign =\n prepareSign_ ??\n (() => {\n throw new Error(\"prepareSign not implemented\");\n });\n\n const formatSign =\n formatSign_ ??\n (() => {\n throw new Error(\"formatSign not implemented\");\n });\n\n return {\n ...account,\n source,\n // TODO: I think this should probably be signUserOperation instead\n // and allow for generating the UO hash based on the EP version\n signUserOperationHash: signUserOperationHash_,\n getFactoryAddress,\n getFactoryData,\n encodeBatchExecute:\n encodeBatchExecute ??\n (() => {\n throw new BatchExecutionNotSupportedError(source);\n }),\n encodeExecute,\n getDummySignature,\n getInitCode,\n encodeUpgradeToAndCall: encodeUpgradeToAndCall_,\n getEntryPoint: () => entryPoint,\n isAccountDeployed,\n getAccountNonce: getNonce_,\n signMessageWith6492,\n signTypedDataWith6492,\n getImplementationAddress: getImplementationAddress_,\n prepareSign,\n formatSign,\n };\n}\n"]}
1
+ {"version":3,"file":"smartContractAccount.js","sourceRoot":"","sources":["../../../src/account/smartContractAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,UAAU,GAWX,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAMjE,OAAO,EACL,+BAA+B,EAC/B,2BAA2B,EAC3B,6BAA6B,EAC7B,gCAAgC,EAChC,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAU3D,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,uCAAoB,CAAA;IACpB,mCAAgB,C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AAC,4BAA4B,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;IAEL,OAAO;QACL,GAAG,OAAO;QACV,MAAM;QACN,kEAAkE;QAClE,+DAA+D;QAC/D,qBAAqB,EAAE,sBAAsB;QAC7C,iBAAiB;QACjB,cAAc;QACd,kBAAkB,EAChB,kBAAkB;YAClB,CAAC,GAAG,EAAE;gBACJ,MAAM,IAAI,+BAA+B,CAAC,MAAM,CAAC,CAAC;YACpD,CAAC,CAAC;QACJ,aAAa;QACb,iBAAiB;QACjB,WAAW;QACX,sBAAsB,EAAE,uBAAuB;QAC/C,aAAa,EAAE,GAAG,EAAE,CAAC,UAAU;QAC/B,iBAAiB;QACjB,eAAe,EAAE,SAAS;QAC1B,mBAAmB;QACnB,qBAAqB;QACrB,wBAAwB,EAAE,yBAAyB;QACnD,WAAW;QACX,UAAU;KACX,CAAC;AACJ,CAAC","sourcesContent":["import {\n getContract,\n hexToBytes,\n type Address,\n type Chain,\n type CustomSource,\n type Hex,\n type LocalAccount,\n type PublicClient,\n type SignableMessage,\n type Transport,\n type TypedData,\n type TypedDataDefinition,\n} from \"viem\";\nimport { toAccount } from \"viem/accounts\";\nimport { createBundlerClient } from \"../client/bundlerClient.js\";\nimport type {\n EntryPointDef,\n EntryPointRegistryBase,\n EntryPointVersion,\n} from \"../entrypoint/types.js\";\nimport {\n BatchExecutionNotSupportedError,\n FailedToGetStorageSlotError,\n GetCounterFactualAddressError,\n SignTransactionNotSupportedError,\n UpgradesNotSupportedError,\n} from \"../errors/account.js\";\nimport { InvalidRpcUrlError } from \"../errors/client.js\";\nimport { InvalidEntryPointError } from \"../errors/entrypoint.js\";\nimport { Logger } from \"../logger.js\";\nimport type { SmartAccountSigner } from \"../signer/types.js\";\nimport { wrapSignatureWith6492 } from \"../signer/utils.js\";\nimport type { NullAddress } from \"../types.js\";\nimport type { IsUndefined, Never } from \"../utils/types.js\";\n\nexport type AccountOp = {\n target: Address;\n value?: bigint;\n data: Hex | \"0x\";\n};\n\nexport enum DeploymentState {\n UNDEFINED = \"0x0\",\n NOT_DEPLOYED = \"0x1\",\n DEPLOYED = \"0x2\",\n}\n\nexport type SignatureRequest =\n | {\n type: \"personal_sign\";\n data: SignableMessage;\n }\n | {\n type: \"eth_signTypedData_v4\";\n data: TypedDataDefinition;\n };\n\nexport type SigningMethods = {\n prepareSign: (request: SignatureRequest) => Promise<SignatureRequest>;\n formatSign: (signature: Hex) => Promise<Hex>;\n};\n\nexport type GetEntryPointFromAccount<\n TAccount extends SmartContractAccount | undefined,\n TAccountOverride extends SmartContractAccount = SmartContractAccount,\n> =\n GetAccountParameter<TAccount, TAccountOverride> extends SmartContractAccount<\n string,\n infer TEntryPointVersion\n >\n ? TEntryPointVersion\n : EntryPointVersion;\n\nexport type GetAccountParameter<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TAccountOverride extends SmartContractAccount = SmartContractAccount,\n> =\n IsUndefined<TAccount> extends true\n ? { account: TAccountOverride }\n : { account?: TAccountOverride };\n\nexport type UpgradeToAndCallParams = {\n upgradeToAddress: Address;\n upgradeToInitData: Hex;\n};\n\nexport type SmartContractAccountWithSigner<\n Name extends string = string,\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion,\n> = SmartContractAccount<Name, TEntryPointVersion> & {\n getSigner: () => TSigner;\n};\n\n/**\n * Determines if the given SmartContractAccount has a signer associated with it.\n *\n * @example\n * ```ts\n * import { toSmartContractAccount } from \"@aa-sdk/core\";\n *\n * const account = await toSmartContractAccount(...);\n *\n * console.log(isSmartAccountWithSigner(account)); // false: the base account does not have a publicly accessible signer\n * ```\n *\n * @param {SmartContractAccount} account The account to check.\n * @returns {boolean} true if the account has a signer, otherwise false.\n */\nexport const isSmartAccountWithSigner = (\n account: SmartContractAccount,\n): account is SmartContractAccountWithSigner => {\n return \"getSigner\" in account;\n};\n\n// [!region SmartContractAccount]\nexport type SmartContractAccount<\n Name extends string = string,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion,\n> = LocalAccount<Name> & {\n source: Name;\n getDummySignature: () => Hex | Promise<Hex>;\n encodeExecute: (tx: AccountOp) => Promise<Hex>;\n encodeBatchExecute: (txs: AccountOp[]) => Promise<Hex>;\n signUserOperationHash: (uoHash: Hex) => Promise<Hex>;\n signMessageWith6492: (params: { message: SignableMessage }) => Promise<Hex>;\n signTypedDataWith6492: <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | \"EIP712Domain\" = keyof typedData,\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>,\n ) => Promise<Hex>;\n encodeUpgradeToAndCall: (params: UpgradeToAndCallParams) => Promise<Hex>;\n getAccountNonce(nonceKey?: bigint): Promise<bigint>;\n getInitCode: () => Promise<Hex>;\n isAccountDeployed: () => Promise<boolean>;\n getFactoryAddress: () => Promise<Address>;\n getFactoryData: () => Promise<Hex>;\n getEntryPoint: () => EntryPointDef<TEntryPointVersion>;\n getImplementationAddress: () => Promise<NullAddress | Address>;\n} & SigningMethods;\n// [!endregion SmartContractAccount]\n\nexport interface AccountEntryPointRegistry<Name extends string = string>\n extends EntryPointRegistryBase<\n SmartContractAccount<Name, EntryPointVersion>\n > {\n \"0.6.0\": SmartContractAccount<Name, \"0.6.0\">;\n \"0.7.0\": SmartContractAccount<Name, \"0.7.0\">;\n}\n\n// [!region ToSmartContractAccountParams]\nexport type ToSmartContractAccountParams<\n Name extends string = string,\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion,\n> = {\n source: Name;\n transport: TTransport;\n chain: TChain;\n entryPoint: EntryPointDef<TEntryPointVersion, TChain>;\n accountAddress?: Address;\n getAccountInitCode: () => Promise<Hex>;\n getDummySignature: () => Hex | Promise<Hex>;\n encodeExecute: (tx: AccountOp) => Promise<Hex>;\n encodeBatchExecute?: (txs: AccountOp[]) => Promise<Hex>;\n getNonce?: (nonceKey?: bigint) => Promise<bigint>;\n // if not provided, will default to just using signMessage over the Hex\n signUserOperationHash?: (uoHash: Hex) => Promise<Hex>;\n encodeUpgradeToAndCall?: (params: UpgradeToAndCallParams) => Promise<Hex>;\n getImplementationAddress?: () => Promise<NullAddress | Address>;\n} & Omit<CustomSource, \"signTransaction\" | \"address\"> &\n (SigningMethods | Never<SigningMethods>);\n// [!endregion ToSmartContractAccountParams]\n\n/**\n * Parses the factory address and factory calldata from the provided account initialization code (initCode).\n *\n * @example\n * ```ts\n * import { parseFactoryAddressFromAccountInitCode } from \"@aa-sdk/core\";\n *\n * const [address, calldata] = parseFactoryAddressFromAccountInitCode(\"0xAddressCalldata\");\n * ```\n *\n * @param {Hex} initCode The initialization code from which to parse the factory address and calldata\n * @returns {[Address, Hex]} A tuple containing the parsed factory address and factory calldata\n */\nexport const parseFactoryAddressFromAccountInitCode = (\n initCode: Hex,\n): [Address, Hex] => {\n const factoryAddress: Address = `0x${initCode.substring(2, 42)}`;\n const factoryCalldata: Hex = `0x${initCode.substring(42)}`;\n return [factoryAddress, factoryCalldata];\n};\n\nexport type GetAccountAddressParams = {\n client: PublicClient;\n entryPoint: EntryPointDef;\n accountAddress?: Address;\n getAccountInitCode: () => Promise<Hex>;\n};\n\n/**\n * Retrieves the account address. Uses a provided `accountAddress` if available; otherwise, it computes the address using the entry point contract and the initial code.\n *\n * @example\n * ```ts\n * import { getEntryPoint, getAccountAddress } from \"@aa-sdk/core\";\n *\n * const accountAddress = await getAccountAddress({\n * client,\n * entryPoint: getEntryPoint(chain),\n * getAccountInitCode: async () => \"0x{factoryAddress}{factoryCallData}\",\n * });\n * ```\n *\n * @param {GetAccountAddressParams} params The configuration object\n * @param {PublicClient} params.client A public client instance to interact with the blockchain\n * @param {EntryPointDef} params.entryPoint The entry point definition which includes the address and ABI\n * @param {Address} params.accountAddress Optional existing account address\n * @param {() => Promise<Hex>} params.getAccountInitCode A function that returns a Promise resolving to a Hex string representing the initial code of the account\n * @returns {Promise<Address>} A promise that resolves to the account address\n */\nexport const getAccountAddress = async ({\n client,\n entryPoint,\n accountAddress,\n getAccountInitCode,\n}: GetAccountAddressParams) => {\n if (accountAddress) return accountAddress;\n\n const entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n const initCode = await getAccountInitCode();\n Logger.verbose(\"[BaseSmartContractAccount](getAddress) initCode: \", initCode);\n\n try {\n await entryPointContract.simulate.getSenderAddress([initCode]);\n } catch (err: any) {\n Logger.verbose(\n \"[BaseSmartContractAccount](getAddress) getSenderAddress err: \",\n err,\n );\n if (err.cause?.data?.errorName === \"SenderAddressResult\") {\n Logger.verbose(\n \"[BaseSmartContractAccount](getAddress) entryPoint.getSenderAddress result:\",\n err.cause.data.args[0],\n );\n\n return err.cause.data.args[0] as Address;\n }\n\n if (err.details === \"Invalid URL\") {\n throw new InvalidRpcUrlError();\n }\n }\n\n throw new GetCounterFactualAddressError();\n};\n\n// [!region toSmartContractAccount]\nexport async function toSmartContractAccount<\n Name extends string = string,\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion,\n>({\n transport,\n chain,\n entryPoint,\n source,\n accountAddress,\n getAccountInitCode,\n getNonce,\n signMessage,\n signTypedData,\n encodeBatchExecute,\n encodeExecute,\n getDummySignature,\n signUserOperationHash,\n encodeUpgradeToAndCall,\n}: ToSmartContractAccountParams<\n Name,\n TTransport,\n TChain,\n TEntryPointVersion\n>): Promise<SmartContractAccount<Name, TEntryPointVersion>>;\n// [!endregion toSmartContractAccount]\n\n/**\n * Converts an account to a smart contract account and sets up various account-related methods using the provided parameters like transport, chain, entry point, and other utilities.\n *\n * @example\n * ```ts\n * import { http, type SignableMessage } from \"viem\";\n * import { sepolia } from \"viem/chains\";\n *\n * const myAccount = await toSmartContractAccount({\n * /// REQUIRED PARAMS ///\n * source: \"MyAccount\",\n * transport: http(\"RPC_URL\"),\n * chain: sepolia,\n * // The EntryPointDef that your account is com\"patible with\n * entryPoint: getEntryPoint(sepolia, { version: \"0.6.0\" }),\n * // This should return a concatenation of your `factoryAddress` and the `callData` for your factory's create account method\n * getAccountInitCode: async () => \"0x{factoryAddress}{callData}\",\n * // an invalid signature that doesn't cause your account to revert during validation\n * getDummySignature: () => \"0x1234...\",\n * // given a UO in the form of {target, data, value} should output the calldata for calling your contract's execution method\n * encodeExecute: async (uo) => \"0xcalldata\",\n * signMessage: async ({ message }: { message: SignableMessage }) => \"0x...\",\n * signTypedData: async (typedData) => \"0x000\",\n *\n * /// OPTIONAL PARAMS ///\n * // if you already know your account's address, pass that in here to avoid generating a new counterfactual\n * accountAddress: \"0xaddressoverride\",\n * // if your account supports batching, this should take an array of UOs and return the calldata for calling your contract's batchExecute method\n * encodeBatchExecute: async (uos) => \"0x...\",\n * // if your contract expects a different signing scheme than the default signMessage scheme, you can override that here\n * signUserOperationHash: async (hash) => \"0x...\",\n * // allows you to define the calldata for upgrading your account\n * encodeUpgradeToAndCall: async (params) => \"0x...\",\n * });\n * ```\n *\n * @param {ToSmartContractAccountParams} params the parameters required for converting to a smart contract account\n * @param {Transport} params.transport the transport mechanism used for communication\n * @param {Chain} params.chain the blockchain chain used in the account\n * @param {EntryPoint} params.entryPoint the entry point of the smart contract\n * @param {string} params.source the source identifier for the account\n * @param {Address} [params.accountAddress] the address of the account\n * @param {() => Promise<Hex>} params.getAccountInitCode a function to get the initial state code of the account\n * @param {(message: { message: SignableMessage }) => Promise<Hex>} params.signMessage a function to sign a message\n * @param {(typedDataDefinition: TypedDataDefinition<typedData, primaryType>) => Promise<Hex>} params.signTypedData a function to sign typed data\n * @param {(transactions: Transaction[]) => Hex} [params.encodeBatchExecute] a function to encode batch transactions\n * @param {(tx: Transaction) => Hex} params.encodeExecute a function to encode a single transaction\n * @param {() => Promise<Hex>} params.getDummySignature a function to get a dummy signature\n * @param {(uoHash: Hex) => Promise<Hex>} [params.signUserOperationHash] a function to sign user operations\n * @param {(implementationAddress: Address, implementationCallData: Hex) => Hex} [params.encodeUpgradeToAndCall] a function to encode upgrade call\n * @returns {Promise<SmartContractAccount>} a promise that resolves to a SmartContractAccount object with methods and properties for interacting with the smart contract account\n */\nexport async function toSmartContractAccount(\n params: ToSmartContractAccountParams,\n): Promise<SmartContractAccount> {\n const {\n transport,\n chain,\n entryPoint,\n source,\n accountAddress,\n getAccountInitCode,\n signMessage,\n signTypedData,\n encodeExecute,\n encodeBatchExecute,\n getNonce,\n getDummySignature,\n signUserOperationHash,\n encodeUpgradeToAndCall,\n getImplementationAddress,\n prepareSign: prepareSign_,\n formatSign: formatSign_,\n } = params;\n\n const client = createBundlerClient({\n // we set the retry count to 0 so that viem doesn't retry during\n // getting the address. That call always reverts and without this\n // viem will retry 3 times, making this call very slow\n transport: (opts) => transport({ ...opts, chain, retryCount: 0 }),\n chain,\n });\n\n const entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n const accountAddress_ = await getAccountAddress({\n client,\n entryPoint: entryPoint,\n accountAddress,\n getAccountInitCode,\n });\n\n let deploymentState = DeploymentState.UNDEFINED;\n\n const getInitCode = async () => {\n if (deploymentState === DeploymentState.DEPLOYED) {\n return \"0x\";\n }\n const contractCode = await client.getCode({\n address: accountAddress_,\n });\n\n if ((contractCode?.length ?? 0) > 2) {\n deploymentState = DeploymentState.DEPLOYED;\n return \"0x\";\n } else {\n deploymentState = DeploymentState.NOT_DEPLOYED;\n }\n\n return getAccountInitCode();\n };\n\n const signUserOperationHash_ =\n signUserOperationHash ??\n (async (uoHash: Hex) => {\n return signMessage({ message: { raw: hexToBytes(uoHash) } });\n });\n\n const getFactoryAddress = async (): Promise<Address> =>\n parseFactoryAddressFromAccountInitCode(await getAccountInitCode())[0];\n\n const getFactoryData = async (): Promise<Hex> =>\n parseFactoryAddressFromAccountInitCode(await getAccountInitCode())[1];\n\n const encodeUpgradeToAndCall_ =\n encodeUpgradeToAndCall ??\n (() => {\n throw new UpgradesNotSupportedError(source);\n });\n\n const isAccountDeployed = async () => {\n const initCode = await getInitCode();\n return initCode === \"0x\";\n };\n\n const getNonce_ =\n getNonce ??\n (async (nonceKey = 0n): Promise<bigint> => {\n return entryPointContract.read.getNonce([\n accountAddress_,\n nonceKey,\n ]) as Promise<bigint>;\n });\n\n const account = toAccount({\n address: accountAddress_,\n signMessage,\n signTypedData,\n signTransaction: () => {\n throw new SignTransactionNotSupportedError();\n },\n });\n\n const create6492Signature = async (isDeployed: boolean, signature: Hex) => {\n if (isDeployed) {\n return signature;\n }\n\n const [factoryAddress, factoryCalldata] =\n parseFactoryAddressFromAccountInitCode(await getAccountInitCode());\n\n return wrapSignatureWith6492({\n factoryAddress,\n factoryCalldata,\n signature,\n });\n };\n\n const signMessageWith6492 = async (message: { message: SignableMessage }) => {\n const [isDeployed, signature] = await Promise.all([\n isAccountDeployed(),\n account.signMessage(message),\n ]);\n\n return create6492Signature(isDeployed, signature);\n };\n\n const signTypedDataWith6492 = async <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | \"EIP712Domain\" = keyof typedData,\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>,\n ): Promise<Hex> => {\n const [isDeployed, signature] = await Promise.all([\n isAccountDeployed(),\n account.signTypedData(typedDataDefinition),\n ]);\n\n return create6492Signature(isDeployed, signature);\n };\n\n const getImplementationAddress_ =\n getImplementationAddress ??\n (async () => {\n const storage = await client.getStorageAt({\n address: account.address,\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 // The storage slot contains a full bytes32, but we want only the last 20 bytes.\n // So, slice off the leading `0x` and the first 12 bytes (24 characters), leaving the last 20 bytes, then prefix with `0x`.\n return `0x${storage.slice(26)}`;\n });\n\n if (entryPoint.version !== \"0.6.0\" && entryPoint.version !== \"0.7.0\") {\n throw new InvalidEntryPointError(chain, entryPoint.version);\n }\n\n if ((prepareSign_ && !formatSign_) || (!prepareSign_ && formatSign_)) {\n throw new Error(\n \"Must implement both prepareSign and formatSign or neither\",\n );\n }\n\n const prepareSign =\n prepareSign_ ??\n (() => {\n throw new Error(\"prepareSign not implemented\");\n });\n\n const formatSign =\n formatSign_ ??\n (() => {\n throw new Error(\"formatSign not implemented\");\n });\n\n return {\n ...account,\n source,\n // TODO: I think this should probably be signUserOperation instead\n // and allow for generating the UO hash based on the EP version\n signUserOperationHash: signUserOperationHash_,\n getFactoryAddress,\n getFactoryData,\n encodeBatchExecute:\n encodeBatchExecute ??\n (() => {\n throw new BatchExecutionNotSupportedError(source);\n }),\n encodeExecute,\n getDummySignature,\n getInitCode,\n encodeUpgradeToAndCall: encodeUpgradeToAndCall_,\n getEntryPoint: () => entryPoint,\n isAccountDeployed,\n getAccountNonce: getNonce_,\n signMessageWith6492,\n signTypedDataWith6492,\n getImplementationAddress: getImplementationAddress_,\n prepareSign,\n formatSign,\n };\n}\n"]}
@@ -43,6 +43,7 @@ export { LogLevel, Logger } from "./logger.js";
43
43
  export { middlewareActions } from "./middleware/actions.js";
44
44
  export { default7702UserOpSigner } from "./middleware/defaults/7702signer.js";
45
45
  export { default7702GasEstimator } from "./middleware/defaults/7702gasEstimator.js";
46
+ export { webauthnGasEstimator } from "./middleware/defaults/webauthnGasEstimator.js";
46
47
  export { defaultFeeEstimator } from "./middleware/defaults/feeEstimator.js";
47
48
  export { defaultGasEstimator } from "./middleware/defaults/gasEstimator.js";
48
49
  export { defaultPaymasterAndData } from "./middleware/defaults/paymasterAndData.js";
package/dist/esm/index.js CHANGED
@@ -33,6 +33,7 @@ export { LogLevel, Logger } from "./logger.js";
33
33
  export { middlewareActions } from "./middleware/actions.js";
34
34
  export { default7702UserOpSigner } from "./middleware/defaults/7702signer.js";
35
35
  export { default7702GasEstimator } from "./middleware/defaults/7702gasEstimator.js";
36
+ export { webauthnGasEstimator } from "./middleware/defaults/webauthnGasEstimator.js";
36
37
  export { defaultFeeEstimator } from "./middleware/defaults/feeEstimator.js";
37
38
  export { defaultGasEstimator } from "./middleware/defaults/gasEstimator.js";
38
39
  export { defaultPaymasterAndData } from "./middleware/defaults/paymasterAndData.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAE5E,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,sCAAsC,EACtC,sBAAsB,GACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAC;AAC9F,OAAO,EAAE,yBAAyB,EAAE,MAAM,qDAAqD,CAAC;AAChG,OAAO,EAAE,8BAA8B,EAAE,MAAM,0DAA0D,CAAC;AAC1G,OAAO,EAAE,2BAA2B,EAAE,MAAM,uDAAuD,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAEhF,OAAO,EAAE,+BAA+B,EAAE,MAAM,4DAA4D,CAAC;AAE7G,OAAO,EACL,mBAAmB,EACnB,+BAA+B,GAChC,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE,OA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HttpTransport } from \"viem\";\n\nexport { EntryPointAbi_v6 } from \"./abis/EntryPointAbi_v6.js\";\nexport { EntryPointAbi_v7 } from \"./abis/EntryPointAbi_v7.js\";\nexport { SimpleAccountAbi_v6 } from \"./abis/SimpleAccountAbi_v6.js\";\nexport { SimpleAccountAbi_v7 } from \"./abis/SimpleAccountAbi_v7.js\";\nexport { SimpleAccountFactoryAbi } from \"./abis/SimpleAccountFactoryAbi.js\";\nexport type * from \"./account/smartContractAccount.js\";\nexport {\n getAccountAddress,\n isSmartAccountWithSigner,\n parseFactoryAddressFromAccountInitCode,\n toSmartContractAccount,\n} from \"./account/smartContractAccount.js\";\nexport { buildUserOperation } from \"./actions/smartAccount/buildUserOperation.js\";\nexport { buildUserOperationFromTx } from \"./actions/smartAccount/buildUserOperationFromTx.js\";\nexport { buildUserOperationFromTxs } from \"./actions/smartAccount/buildUserOperationFromTxs.js\";\nexport { checkGasSponsorshipEligibility } from \"./actions/smartAccount/checkGasSponsorshipEligibility.js\";\nexport { dropAndReplaceUserOperation } from \"./actions/smartAccount/dropAndReplaceUserOperation.js\";\nexport { sendTransaction } from \"./actions/smartAccount/sendTransaction.js\";\nexport { sendTransactions } from \"./actions/smartAccount/sendTransactions.js\";\nexport { sendUserOperation } from \"./actions/smartAccount/sendUserOperation.js\";\nexport type * from \"./actions/smartAccount/types.js\";\nexport { waitForUserOperationTransaction } from \"./actions/smartAccount/waitForUserOperationTransacation.js\";\nexport type * from \"./client/bundlerClient.js\";\nexport {\n createBundlerClient,\n createBundlerClientFromExisting,\n} from \"./client/bundlerClient.js\";\nexport type * from \"./client/decorators/bundlerClient.js\";\nexport { bundlerActions } from \"./client/decorators/bundlerClient.js\";\nexport type * from \"./client/decorators/smartAccountClient.js\";\nexport { smartAccountClientActions } from \"./client/decorators/smartAccountClient.js\";\nexport { isSmartAccountClient } from \"./client/isSmartAccountClient.js\";\nexport {\n ConnectionConfigSchema,\n SmartAccountClientOptsSchema,\n} from \"./client/schema.js\";\nexport type * from \"./client/smartAccountClient.js\";\nexport {\n createSmartAccountClient,\n createSmartAccountClientFromExisting,\n} from \"./client/smartAccountClient.js\";\nexport type * from \"./client/types.js\";\nexport {\n convertChainIdToCoinType,\n convertCoinTypeToChain,\n convertCoinTypeToChainId,\n} from \"./ens/utils.js\";\nexport {\n defaultEntryPointVersion,\n entryPointRegistry,\n getEntryPoint,\n isEntryPointVersion,\n} from \"./entrypoint/index.js\";\nexport type * from \"./entrypoint/types.js\";\nexport {\n AccountNotFoundError,\n AccountRequiresOwnerError,\n BatchExecutionNotSupportedError,\n DefaultFactoryNotDefinedError,\n FailedToGetStorageSlotError,\n GetCounterFactualAddressError,\n IncorrectAccountType,\n SignTransactionNotSupportedError,\n SmartAccountWithSignerRequiredError,\n UpgradeToAndCallNotSupportedError,\n UpgradesNotSupportedError,\n} from \"./errors/account.js\";\nexport { BaseError } from \"./errors/base.js\";\nexport {\n ChainNotFoundError,\n IncompatibleClientError,\n InvalidRpcUrlError,\n InvalidEntityIdError,\n InvalidNonceKeyError,\n EntityIdOverrideError,\n InvalidModularAccountV2Mode,\n InvalidDeferredActionNonce,\n} from \"./errors/client.js\";\nexport {\n EntryPointNotFoundError,\n InvalidEntryPointError,\n} from \"./errors/entrypoint.js\";\nexport { InvalidSignerTypeError } from \"./errors/signer.js\";\nexport {\n FailedToFindTransactionError,\n TransactionMissingToParamError,\n} from \"./errors/transaction.js\";\nexport {\n InvalidUserOperationError,\n WaitForUserOperationError,\n} from \"./errors/useroperation.js\";\nexport * from \"./client/addBreadcrumb.js\";\nexport { LogLevel, Logger } from \"./logger.js\";\nexport { middlewareActions } from \"./middleware/actions.js\";\nexport { default7702UserOpSigner } from \"./middleware/defaults/7702signer.js\";\nexport { default7702GasEstimator } from \"./middleware/defaults/7702gasEstimator.js\";\nexport { defaultFeeEstimator } from \"./middleware/defaults/feeEstimator.js\";\nexport { defaultGasEstimator } from \"./middleware/defaults/gasEstimator.js\";\nexport { defaultPaymasterAndData } from \"./middleware/defaults/paymasterAndData.js\";\nexport { defaultUserOpSigner } from \"./middleware/defaults/userOpSigner.js\";\nexport type * from \"./middleware/erc7677middleware.js\";\nexport { erc7677Middleware } from \"./middleware/erc7677middleware.js\";\nexport { noopMiddleware } from \"./middleware/noopMiddleware.js\";\nexport type * from \"./middleware/types.js\";\nexport { LocalAccountSigner } from \"./signer/local-account.js\";\nexport { SignerSchema, isSigner } from \"./signer/schema.js\";\nexport type {\n SmartAccountAuthenticator,\n SmartAccountSigner,\n AuthorizationRequest,\n} from \"./signer/types.js\";\nexport { wrapSignatureWith6492 } from \"./signer/utils.js\";\nexport { WalletClientSigner } from \"./signer/wallet-client.js\";\nexport { split, type SplitTransportParams } from \"./transport/split.js\";\nexport type * from \"./types.js\";\nexport type * from \"./utils/index.js\";\nexport {\n TraceHeader,\n TRACE_HEADER_NAME,\n TRACE_HEADER_STATE,\n} from \"./utils/traceHeader.js\";\nexport {\n BigNumberishRangeSchema,\n BigNumberishSchema,\n ChainSchema,\n HexSchema,\n MultiplierSchema,\n allEqual,\n applyUserOpFeeOption,\n applyUserOpOverride,\n applyUserOpOverrideOrFeeOption,\n asyncPipe,\n bigIntMax,\n bigIntMultiply,\n bypassPaymasterAndData,\n bypassPaymasterAndDataEmptyHex,\n concatPaymasterAndData,\n deepHexlify,\n filterUndefined,\n getDefaultUserOperationFeeOptions,\n isBigNumberish,\n isMultiplier,\n isValidRequest,\n parsePaymasterAndData,\n pick,\n resolveProperties,\n takeBytes,\n toRecord,\n} from \"./utils/index.js\";\nexport { getUserOperationError } from \"./actions/smartAccount/getUserOperationError.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,mB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AE,MAAM,gCAAgC,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAM5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAA6B,MAAM,sBAAsB,CAAC;AAGxE,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,EACnB,8BAA8B,EAC9B,SAAS,EACT,SAAS,EACT,cAAc,EACd,sBAAsB,EACtB,8BAA8B,EAC9B,sBAAsB,EACtB,WAAW,EACX,eAAe,EACf,iCAAiC,EACjC,cAAc,EACd,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,IAAI,EACJ,iBAAiB,EACjB,SAAS,EACT,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAC","sourcesContent":["export type { Abi } from \"abitype\";\nexport type { Address, HttpTransport } from \"viem\";\n\nexport { EntryPointAbi_v6 } from \"./abis/EntryPointAbi_v6.js\";\nexport { EntryPointAbi_v7 } from \"./abis/EntryPointAbi_v7.js\";\nexport { SimpleAccountAbi_v6 } from \"./abis/SimpleAccountAbi_v6.js\";\nexport { SimpleAccountAbi_v7 } from \"./abis/SimpleAccountAbi_v7.js\";\nexport { SimpleAccountFactoryAbi } from \"./abis/SimpleAccountFactoryAbi.js\";\nexport type * from \"./account/smartContractAccount.js\";\nexport {\n getAccountAddress,\n isSmartAccountWithSigner,\n parseFactoryAddressFromAccountInitCode,\n toSmartContractAccount,\n} from \"./account/smartContractAccount.js\";\nexport { buildUserOperation } from \"./actions/smartAccount/buildUserOperation.js\";\nexport { buildUserOperationFromTx } from \"./actions/smartAccount/buildUserOperationFromTx.js\";\nexport { buildUserOperationFromTxs } from \"./actions/smartAccount/buildUserOperationFromTxs.js\";\nexport { checkGasSponsorshipEligibility } from \"./actions/smartAccount/checkGasSponsorshipEligibility.js\";\nexport { dropAndReplaceUserOperation } from \"./actions/smartAccount/dropAndReplaceUserOperation.js\";\nexport { sendTransaction } from \"./actions/smartAccount/sendTransaction.js\";\nexport { sendTransactions } from \"./actions/smartAccount/sendTransactions.js\";\nexport { sendUserOperation } from \"./actions/smartAccount/sendUserOperation.js\";\nexport type * from \"./actions/smartAccount/types.js\";\nexport { waitForUserOperationTransaction } from \"./actions/smartAccount/waitForUserOperationTransacation.js\";\nexport type * from \"./client/bundlerClient.js\";\nexport {\n createBundlerClient,\n createBundlerClientFromExisting,\n} from \"./client/bundlerClient.js\";\nexport type * from \"./client/decorators/bundlerClient.js\";\nexport { bundlerActions } from \"./client/decorators/bundlerClient.js\";\nexport type * from \"./client/decorators/smartAccountClient.js\";\nexport { smartAccountClientActions } from \"./client/decorators/smartAccountClient.js\";\nexport { isSmartAccountClient } from \"./client/isSmartAccountClient.js\";\nexport {\n ConnectionConfigSchema,\n SmartAccountClientOptsSchema,\n} from \"./client/schema.js\";\nexport type * from \"./client/smartAccountClient.js\";\nexport {\n createSmartAccountClient,\n createSmartAccountClientFromExisting,\n} from \"./client/smartAccountClient.js\";\nexport type * from \"./client/types.js\";\nexport {\n convertChainIdToCoinType,\n convertCoinTypeToChain,\n convertCoinTypeToChainId,\n} from \"./ens/utils.js\";\nexport {\n defaultEntryPointVersion,\n entryPointRegistry,\n getEntryPoint,\n isEntryPointVersion,\n} from \"./entrypoint/index.js\";\nexport type * from \"./entrypoint/types.js\";\nexport {\n AccountNotFoundError,\n AccountRequiresOwnerError,\n BatchExecutionNotSupportedError,\n DefaultFactoryNotDefinedError,\n FailedToGetStorageSlotError,\n GetCounterFactualAddressError,\n IncorrectAccountType,\n SignTransactionNotSupportedError,\n SmartAccountWithSignerRequiredError,\n UpgradeToAndCallNotSupportedError,\n UpgradesNotSupportedError,\n} from \"./errors/account.js\";\nexport { BaseError } from \"./errors/base.js\";\nexport {\n ChainNotFoundError,\n IncompatibleClientError,\n InvalidRpcUrlError,\n InvalidEntityIdError,\n InvalidNonceKeyError,\n EntityIdOverrideError,\n InvalidModularAccountV2Mode,\n InvalidDeferredActionNonce,\n} from \"./errors/client.js\";\nexport {\n EntryPointNotFoundError,\n InvalidEntryPointError,\n} from \"./errors/entrypoint.js\";\nexport { InvalidSignerTypeError } from \"./errors/signer.js\";\nexport {\n FailedToFindTransactionError,\n TransactionMissingToParamError,\n} from \"./errors/transaction.js\";\nexport {\n InvalidUserOperationError,\n WaitForUserOperationError,\n} from \"./errors/useroperation.js\";\nexport * from \"./client/addBreadcrumb.js\";\nexport { LogLevel, Logger } from \"./logger.js\";\nexport { middlewareActions } from \"./middleware/actions.js\";\nexport { default7702UserOpSigner } from \"./middleware/defaults/7702signer.js\";\nexport { default7702GasEstimator } from \"./middleware/defaults/7702gasEstimator.js\";\nexport { webauthnGasEstimator } from \"./middleware/defaults/webauthnGasEstimator.js\";\nexport { defaultFeeEstimator } from \"./middleware/defaults/feeEstimator.js\";\nexport { defaultGasEstimator } from \"./middleware/defaults/gasEstimator.js\";\nexport { defaultPaymasterAndData } from \"./middleware/defaults/paymasterAndData.js\";\nexport { defaultUserOpSigner } from \"./middleware/defaults/userOpSigner.js\";\nexport type * from \"./middleware/erc7677middleware.js\";\nexport { erc7677Middleware } from \"./middleware/erc7677middleware.js\";\nexport { noopMiddleware } from \"./middleware/noopMiddleware.js\";\nexport type * from \"./middleware/types.js\";\nexport { LocalAccountSigner } from \"./signer/local-account.js\";\nexport { SignerSchema, isSigner } from \"./signer/schema.js\";\nexport type {\n SmartAccountAuthenticator,\n SmartAccountSigner,\n AuthorizationRequest,\n} from \"./signer/types.js\";\nexport { wrapSignatureWith6492 } from \"./signer/utils.js\";\nexport { WalletClientSigner } from \"./signer/wallet-client.js\";\nexport { split, type SplitTransportParams } from \"./transport/split.js\";\nexport type * from \"./types.js\";\nexport type * from \"./utils/index.js\";\nexport {\n TraceHeader,\n TRACE_HEADER_NAME,\n TRACE_HEADER_STATE,\n} from \"./utils/traceHeader.js\";\nexport {\n BigNumberishRangeSchema,\n BigNumberishSchema,\n ChainSchema,\n HexSchema,\n MultiplierSchema,\n allEqual,\n applyUserOpFeeOption,\n applyUserOpOverride,\n applyUserOpOverrideOrFeeOption,\n asyncPipe,\n bigIntMax,\n bigIntMultiply,\n bypassPaymasterAndData,\n bypassPaymasterAndDataEmptyHex,\n concatPaymasterAndData,\n deepHexlify,\n filterUndefined,\n getDefaultUserOperationFeeOptions,\n isBigNumberish,\n isMultiplier,\n isValidRequest,\n parsePaymasterAndData,\n pick,\n resolveProperties,\n takeBytes,\n toRecord,\n} from \"./utils/index.js\";\nexport { getUserOperationError } from \"./actions/smartAccount/getUserOperationError.js\";\n"]}
@@ -0,0 +1,40 @@
1
+ import type { ClientMiddlewareFn } from "../types";
2
+ export declare const rip7212CheckBytecode = "0x60806040526040517f532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25815260056020820152600160408201527f4a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e560608201527f3e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0608082015260208160a0836101005afa503d5f823e3d81f3fe";
3
+ /**
4
+ * A middleware function to estimate the gas usage of a user operation when using a Modular Account V2 WebAuthn account. Has an optional custom gas estimator.
5
+ * This function is only compatible with accounts using EntryPoint v0.7.0, and the account must have an implementation address defined in `getImplementationAddress()`.
6
+ *
7
+ * @example
8
+ * ```ts twoslash
9
+ * import {
10
+ * webauthnGasEstimator,
11
+ * createSmartAccountClient,
12
+ * type SmartAccountClient,
13
+ * } from "@aa-sdk/core";
14
+ * import {
15
+ * createModularAccountV2,
16
+ * type CreateModularAccountV2ClientParams,
17
+ * } from "@account-kit/smart-contracts";
18
+ *
19
+ * const credential = {
20
+ * id: "credential-id",
21
+ * publicKey: "0x...",
22
+ * }
23
+ *
24
+ * async function createWebauthnAccountClient(
25
+ * config: CreateModularAccountV2ClientParams
26
+ * ): Promise<SmartAccountClient> {
27
+ * const webauthnAccount = await createModularAccountV2({ ...config, mode: "webauthn", credential });
28
+ *
29
+ * return createSmartAccountClient({
30
+ * account: webAuthnAccount,
31
+ * gasEstimator: webauthnGasEstimator(config.gasEstimator),
32
+ * ...config,
33
+ * });
34
+ * }
35
+ * ```
36
+ *
37
+ * @param {ClientMiddlewareFn} [gasEstimator] Optional custom gas estimator function
38
+ * @returns {ClientMiddlewareFn} A function that takes user operation struct and parameters, estimates gas usage, and returns the user operation with gas limits.
39
+ */
40
+ export declare const webauthnGasEstimator: (gasEstimator?: ClientMiddlewareFn) => ClientMiddlewareFn;
@@ -0,0 +1,69 @@
1
+ import { AccountNotFoundError } from "../../errors/account.js";
2
+ import { defaultGasEstimator } from "./gasEstimator.js";
3
+ import {} from "viem";
4
+ export const rip7212CheckBytecode = "0x60806040526040517f532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25815260056020820152600160408201527f4a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e560608201527f3e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0608082015260208160a0836101005afa503d5f823e3d81f3fe";
5
+ /**
6
+ * A middleware function to estimate the gas usage of a user operation when using a Modular Account V2 WebAuthn account. Has an optional custom gas estimator.
7
+ * This function is only compatible with accounts using EntryPoint v0.7.0, and the account must have an implementation address defined in `getImplementationAddress()`.
8
+ *
9
+ * @example
10
+ * ```ts twoslash
11
+ * import {
12
+ * webauthnGasEstimator,
13
+ * createSmartAccountClient,
14
+ * type SmartAccountClient,
15
+ * } from "@aa-sdk/core";
16
+ * import {
17
+ * createModularAccountV2,
18
+ * type CreateModularAccountV2ClientParams,
19
+ * } from "@account-kit/smart-contracts";
20
+ *
21
+ * const credential = {
22
+ * id: "credential-id",
23
+ * publicKey: "0x...",
24
+ * }
25
+ *
26
+ * async function createWebauthnAccountClient(
27
+ * config: CreateModularAccountV2ClientParams
28
+ * ): Promise<SmartAccountClient> {
29
+ * const webauthnAccount = await createModularAccountV2({ ...config, mode: "webauthn", credential });
30
+ *
31
+ * return createSmartAccountClient({
32
+ * account: webAuthnAccount,
33
+ * gasEstimator: webauthnGasEstimator(config.gasEstimator),
34
+ * ...config,
35
+ * });
36
+ * }
37
+ * ```
38
+ *
39
+ * @param {ClientMiddlewareFn} [gasEstimator] Optional custom gas estimator function
40
+ * @returns {ClientMiddlewareFn} A function that takes user operation struct and parameters, estimates gas usage, and returns the user operation with gas limits.
41
+ */
42
+ export const webauthnGasEstimator = (gasEstimator) => async (struct, params) => {
43
+ const gasEstimator_ = gasEstimator ?? defaultGasEstimator(params.client);
44
+ const account = params.account ?? params.client.account;
45
+ if (!account) {
46
+ throw new AccountNotFoundError();
47
+ }
48
+ const entryPoint = account.getEntryPoint();
49
+ if (entryPoint.version !== "0.7.0") {
50
+ throw new Error("This middleware is only compatible with EntryPoint v0.7.0");
51
+ }
52
+ const uo = await gasEstimator_(struct, params);
53
+ const pvg = uo.verificationGasLimit instanceof Promise
54
+ ? await uo.verificationGasLimit
55
+ : (uo?.verificationGasLimit ?? 0n);
56
+ if (!pvg) {
57
+ throw new Error("WebauthnGasEstimator: verificationGasLimit is 0 or not defined");
58
+ }
59
+ // perform eth call read check to see if the chain has 7212
60
+ const { data } = await params.client.call({ data: rip7212CheckBytecode });
61
+ const chainHas7212 = data ? BigInt(data) === 1n : false;
62
+ // TODO: iterate numbers. Aim to have ~1000 gas buffer to account for longer authenticatorDatas and clientDataJSONs
63
+ return {
64
+ ...uo,
65
+ verificationGasLimit: BigInt(typeof pvg === "string" ? BigInt(pvg) : pvg) +
66
+ (chainHas7212 ? 10000n : 300000n),
67
+ };
68
+ };
69
+ //# sourceMappingURL=webauthnGasEstimator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webauthnGasEstimator.js","sourceRoot":"","sources":["../../../../src/middleware/defaults/webauthnGasEstimator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAY,MAAM,MAAM,CAAC;AAEhC,MAAM,CAAC,MAAM,oBAAoB,GAC/B,sTAAsT,CAAC;AAEzT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAG/B,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,EAAE,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE/C,MAAM,GAAG,GACP,EAAE,CAAC,oBAAoB,YAAY,OAAO;QACxC,CAAC,CAAC,MAAM,EAAE,CAAC,oBAAoB;QAC/B,CAAC,CAAC,CAAC,EAAE,EAAE,oBAAoB,IAAI,EAAE,CAAC,CAAC;IAEvC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;IACJ,CAAC;IAED,2DAA2D;IAC3D,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,CAAC,CAAC;IAE1E,MAAM,YAAY,GAAY,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IAEjE,mHAAmH;IACnH,OAAO;QACL,GAAG,EAAE;QACL,oBAAoB,EAClB,MAAM,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;YACnD,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;KACpC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { AccountNotFoundError } from \"../../errors/account.js\";\nimport type { ClientMiddlewareFn } from \"../types\";\nimport { defaultGasEstimator } from \"./gasEstimator.js\";\nimport { type Hex } from \"viem\";\n\nexport const rip7212CheckBytecode =\n \"0x60806040526040517f532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25815260056020820152600160408201527f4a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e560608201527f3e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0608082015260208160a0836101005afa503d5f823e3d81f3fe\";\n\n/**\n * A middleware function to estimate the gas usage of a user operation when using a Modular Account V2 WebAuthn 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 * webauthnGasEstimator,\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 * const credential = {\n * id: \"credential-id\",\n * publicKey: \"0x...\",\n * }\n *\n * async function createWebauthnAccountClient(\n * config: CreateModularAccountV2ClientParams\n * ): Promise<SmartAccountClient> {\n * const webauthnAccount = await createModularAccountV2({ ...config, mode: \"webauthn\", credential });\n *\n * return createSmartAccountClient({\n * account: webAuthnAccount,\n * gasEstimator: webauthnGasEstimator(config.gasEstimator),\n * ...config,\n * });\n * }\n * ```\n *\n * @param {ClientMiddlewareFn} [gasEstimator] Optional custom gas estimator function\n * @returns {ClientMiddlewareFn} A function that takes user operation struct and parameters, estimates gas usage, and returns the user operation with gas limits.\n */\nexport const webauthnGasEstimator: (\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 uo = await gasEstimator_(struct, params);\n\n const pvg: bigint | number | Hex | undefined =\n uo.verificationGasLimit instanceof Promise\n ? await uo.verificationGasLimit\n : (uo?.verificationGasLimit ?? 0n);\n\n if (!pvg) {\n throw new Error(\n \"WebauthnGasEstimator: verificationGasLimit is 0 or not defined\",\n );\n }\n\n // perform eth call read check to see if the chain has 7212\n const { data } = await params.client.call({ data: rip7212CheckBytecode });\n\n const chainHas7212: boolean = data ? BigInt(data) === 1n : false;\n\n // TODO: iterate numbers. Aim to have ~1000 gas buffer to account for longer authenticatorDatas and clientDataJSONs\n return {\n ...uo,\n verificationGasLimit:\n BigInt(typeof pvg === \"string\" ? BigInt(pvg) : pvg) +\n (chainHas7212 ? 10000n : 300000n),\n };\n };\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "4.41.0";
1
+ export declare const VERSION = "4.43.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.41.0";
3
+ export const VERSION = "4.43.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,QAAQ,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.41.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.43.0\";\n"]}
@@ -43,6 +43,7 @@ export { LogLevel, Logger } from "./logger.js";
43
43
  export { middlewareActions } from "./middleware/actions.js";
44
44
  export { default7702UserOpSigner } from "./middleware/defaults/7702signer.js";
45
45
  export { default7702GasEstimator } from "./middleware/defaults/7702gasEstimator.js";
46
+ export { webauthnGasEstimator } from "./middleware/defaults/webauthnGasEstimator.js";
46
47
  export { defaultFeeEstimator } from "./middleware/defaults/feeEstimator.js";
47
48
  export { defaultGasEstimator } from "./middleware/defaults/gasEstimator.js";
48
49
  export { defaultPaymasterAndData } from "./middleware/defaults/paymasterAndData.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AACnC,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;A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iBAAiB,EACjB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,EACnB,8BAA8B,EAC9B,SAAS,EACT,SAAS,EACT,cAAc,EACd,sBAAsB,EACtB,8BAA8B,EAC9B,sBAAsB,EACtB,WAAW,EACX,eAAe,EACf,iCAAiC,EACjC,cAAc,EACd,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,IAAI,EACJ,iBAAiB,EACjB,SAAS,EACT,QAAQ,GACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAC"}
@@ -0,0 +1,41 @@
1
+ import type { ClientMiddlewareFn } from "../types";
2
+ export declare const rip7212CheckBytecode = "0x60806040526040517f532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25815260056020820152600160408201527f4a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e560608201527f3e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0608082015260208160a0836101005afa503d5f823e3d81f3fe";
3
+ /**
4
+ * A middleware function to estimate the gas usage of a user operation when using a Modular Account V2 WebAuthn account. Has an optional custom gas estimator.
5
+ * This function is only compatible with accounts using EntryPoint v0.7.0, and the account must have an implementation address defined in `getImplementationAddress()`.
6
+ *
7
+ * @example
8
+ * ```ts twoslash
9
+ * import {
10
+ * webauthnGasEstimator,
11
+ * createSmartAccountClient,
12
+ * type SmartAccountClient,
13
+ * } from "@aa-sdk/core";
14
+ * import {
15
+ * createModularAccountV2,
16
+ * type CreateModularAccountV2ClientParams,
17
+ * } from "@account-kit/smart-contracts";
18
+ *
19
+ * const credential = {
20
+ * id: "credential-id",
21
+ * publicKey: "0x...",
22
+ * }
23
+ *
24
+ * async function createWebauthnAccountClient(
25
+ * config: CreateModularAccountV2ClientParams
26
+ * ): Promise<SmartAccountClient> {
27
+ * const webauthnAccount = await createModularAccountV2({ ...config, mode: "webauthn", credential });
28
+ *
29
+ * return createSmartAccountClient({
30
+ * account: webAuthnAccount,
31
+ * gasEstimator: webauthnGasEstimator(config.gasEstimator),
32
+ * ...config,
33
+ * });
34
+ * }
35
+ * ```
36
+ *
37
+ * @param {ClientMiddlewareFn} [gasEstimator] Optional custom gas estimator function
38
+ * @returns {ClientMiddlewareFn} A function that takes user operation struct and parameters, estimates gas usage, and returns the user operation with gas limits.
39
+ */
40
+ export declare const webauthnGasEstimator: (gasEstimator?: ClientMiddlewareFn) => ClientMiddlewareFn;
41
+ //# sourceMappingURL=webauthnGasEstimator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webauthnGasEstimator.d.ts","sourceRoot":"","sources":["../../../../src/middleware/defaults/webauthnGasEstimator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAInD,eAAO,MAAM,oBAAoB,yTACuR,CAAC;AAEzT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,oBAAoB,EAAE,CACjC,YAAY,CAAC,EAAE,kBAAkB,KAC9B,kBAyCF,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "4.41.0";
1
+ export declare const VERSION = "4.43.0";
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.41.0",
4
+ "version": "4.43.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",
@@ -62,5 +62,5 @@
62
62
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
63
63
  },
64
64
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
65
- "gitHead": "db374bb77b5961b3d2c5c883e9e77f861df92f59"
65
+ "gitHead": "1b261f2370eceb90871476f95a235d6f889a4e9a"
66
66
  }
@@ -438,10 +438,6 @@ export async function toSmartContractAccount(
438
438
  const getNonce_ =
439
439
  getNonce ??
440
440
  (async (nonceKey = 0n): Promise<bigint> => {
441
- if (!(await isAccountDeployed())) {
442
- return 0n;
443
- }
444
-
445
441
  return entryPointContract.read.getNonce([
446
442
  accountAddress_,
447
443
  nonceKey,
package/src/index.ts CHANGED
@@ -97,6 +97,7 @@ export { LogLevel, Logger } from "./logger.js";
97
97
  export { middlewareActions } from "./middleware/actions.js";
98
98
  export { default7702UserOpSigner } from "./middleware/defaults/7702signer.js";
99
99
  export { default7702GasEstimator } from "./middleware/defaults/7702gasEstimator.js";
100
+ export { webauthnGasEstimator } from "./middleware/defaults/webauthnGasEstimator.js";
100
101
  export { defaultFeeEstimator } from "./middleware/defaults/feeEstimator.js";
101
102
  export { defaultGasEstimator } from "./middleware/defaults/gasEstimator.js";
102
103
  export { defaultPaymasterAndData } from "./middleware/defaults/paymasterAndData.js";
@@ -0,0 +1,89 @@
1
+ import { AccountNotFoundError } from "../../errors/account.js";
2
+ import type { ClientMiddlewareFn } from "../types";
3
+ import { defaultGasEstimator } from "./gasEstimator.js";
4
+ import { type Hex } from "viem";
5
+
6
+ export const rip7212CheckBytecode =
7
+ "0x60806040526040517f532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25815260056020820152600160408201527f4a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e560608201527f3e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0608082015260208160a0836101005afa503d5f823e3d81f3fe";
8
+
9
+ /**
10
+ * A middleware function to estimate the gas usage of a user operation when using a Modular Account V2 WebAuthn account. Has an optional custom gas estimator.
11
+ * This function is only compatible with accounts using EntryPoint v0.7.0, and the account must have an implementation address defined in `getImplementationAddress()`.
12
+ *
13
+ * @example
14
+ * ```ts twoslash
15
+ * import {
16
+ * webauthnGasEstimator,
17
+ * createSmartAccountClient,
18
+ * type SmartAccountClient,
19
+ * } from "@aa-sdk/core";
20
+ * import {
21
+ * createModularAccountV2,
22
+ * type CreateModularAccountV2ClientParams,
23
+ * } from "@account-kit/smart-contracts";
24
+ *
25
+ * const credential = {
26
+ * id: "credential-id",
27
+ * publicKey: "0x...",
28
+ * }
29
+ *
30
+ * async function createWebauthnAccountClient(
31
+ * config: CreateModularAccountV2ClientParams
32
+ * ): Promise<SmartAccountClient> {
33
+ * const webauthnAccount = await createModularAccountV2({ ...config, mode: "webauthn", credential });
34
+ *
35
+ * return createSmartAccountClient({
36
+ * account: webAuthnAccount,
37
+ * gasEstimator: webauthnGasEstimator(config.gasEstimator),
38
+ * ...config,
39
+ * });
40
+ * }
41
+ * ```
42
+ *
43
+ * @param {ClientMiddlewareFn} [gasEstimator] Optional custom gas estimator function
44
+ * @returns {ClientMiddlewareFn} A function that takes user operation struct and parameters, estimates gas usage, and returns the user operation with gas limits.
45
+ */
46
+ export const webauthnGasEstimator: (
47
+ gasEstimator?: ClientMiddlewareFn,
48
+ ) => ClientMiddlewareFn =
49
+ (gasEstimator?: ClientMiddlewareFn) => async (struct, params) => {
50
+ const gasEstimator_ = gasEstimator ?? defaultGasEstimator(params.client);
51
+
52
+ const account = params.account ?? params.client.account;
53
+ if (!account) {
54
+ throw new AccountNotFoundError();
55
+ }
56
+
57
+ const entryPoint = account.getEntryPoint();
58
+ if (entryPoint.version !== "0.7.0") {
59
+ throw new Error(
60
+ "This middleware is only compatible with EntryPoint v0.7.0",
61
+ );
62
+ }
63
+
64
+ const uo = await gasEstimator_(struct, params);
65
+
66
+ const pvg: bigint | number | Hex | undefined =
67
+ uo.verificationGasLimit instanceof Promise
68
+ ? await uo.verificationGasLimit
69
+ : (uo?.verificationGasLimit ?? 0n);
70
+
71
+ if (!pvg) {
72
+ throw new Error(
73
+ "WebauthnGasEstimator: verificationGasLimit is 0 or not defined",
74
+ );
75
+ }
76
+
77
+ // perform eth call read check to see if the chain has 7212
78
+ const { data } = await params.client.call({ data: rip7212CheckBytecode });
79
+
80
+ const chainHas7212: boolean = data ? BigInt(data) === 1n : false;
81
+
82
+ // TODO: iterate numbers. Aim to have ~1000 gas buffer to account for longer authenticatorDatas and clientDataJSONs
83
+ return {
84
+ ...uo,
85
+ verificationGasLimit:
86
+ BigInt(typeof pvg === "string" ? BigInt(pvg) : pvg) +
87
+ (chainHas7212 ? 10000n : 300000n),
88
+ };
89
+ };
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.41.0";
3
+ export const VERSION = "4.43.0";