@aa-sdk/core 4.7.0 → 4.9.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.
- package/dist/esm/account/smartContractAccount.js +4 -2
- package/dist/esm/account/smartContractAccount.js.map +1 -1
- package/dist/esm/errors/client.d.ts +34 -0
- package/dist/esm/errors/client.js +55 -0
- package/dist/esm/errors/client.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/index.d.ts +4 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/account/smartContractAccount.d.ts.map +1 -1
- package/dist/types/errors/client.d.ts +34 -0
- package/dist/types/errors/client.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -2
- package/src/account/smartContractAccount.ts +3 -2
- package/src/errors/client.ts +50 -0
- package/src/index.ts +3 -0
- package/src/utils/index.ts +5 -0
- package/src/version.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getContract, hexToBytes,
|
|
1
|
+
import { getContract, hexToBytes, } from "viem";
|
|
2
2
|
import { toAccount } from "viem/accounts";
|
|
3
3
|
import { createBundlerClient } from "../client/bundlerClient.js";
|
|
4
4
|
import { BatchExecutionNotSupportedError, FailedToGetStorageSlotError, GetCounterFactualAddressError, SignTransactionNotSupportedError, UpgradesNotSupportedError, } from "../errors/account.js";
|
|
@@ -250,7 +250,9 @@ export async function toSmartContractAccount(params) {
|
|
|
250
250
|
if (storage == null) {
|
|
251
251
|
throw new FailedToGetStorageSlotError("0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc", "Proxy Implementation Address");
|
|
252
252
|
}
|
|
253
|
-
|
|
253
|
+
// The storage slot contains a full bytes32, but we want only the last 20 bytes.
|
|
254
|
+
// So, slice off the leading `0x` and the first 12 bytes (24 characters), leaving the last 20 bytes, then prefix with `0x`.
|
|
255
|
+
return `0x${storage.slice(26)}`;
|
|
254
256
|
};
|
|
255
257
|
if (entryPoint.version !== "0.6.0" && entryPoint.version !== "0.7.0") {
|
|
256
258
|
throw new InvalidEntryPointError(chain, entryPoint.version);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartContractAccount.js","sourceRoot":"","sources":["../../../src/account/smartContractAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,UAAU,EACV,IAAI,GAWL,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;AAkCD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,OAA6B,EACc,EAAE;IAC7C,OAAO,WAAW,IAAI,OAAO,CAAC;AAChC,CAAC,CAAC;AA0DF,4CAA4C;AAE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AAC,CAAC;IAEF,MAAM,wBAAwB,GAAG,KAAK,IAAoC,EAAE;QAC1E,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC;YACxC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,sEAAsE;YACtE,IAAI,EAAE,oEAAoE;SAC3E,CAAC,CAAC;QAEH,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,2BAA2B,CACnC,oEAAoE,EACpE,8BAA8B,CAC/B,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC;IAEF,IAAI,UAAU,CAAC,OAAO,KAAK,OAAO,IAAI,UAAU,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;QACrE,MAAM,IAAI,sBAAsB,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED,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,QAAQ;QACzB,mBAAmB;QACnB,qBAAqB;QACrB,wBAAwB;KACzB,CAAC;AACJ,CAAC","sourcesContent":["import {\n getContract,\n hexToBytes,\n trim,\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 } 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 GetEntryPointFromAccount<\n TAccount extends SmartContractAccount | undefined,\n TAccountOverride extends SmartContractAccount = SmartContractAccount\n> = GetAccountParameter<\n TAccount,\n TAccountOverride\n> extends SmartContractAccount<string, infer TEntryPointVersion>\n ? TEntryPointVersion\n : EntryPointVersion;\n\nexport type GetAccountParameter<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TAccountOverride extends SmartContractAccount = SmartContractAccount\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};\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 // 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} & Omit<CustomSource, \"signTransaction\" | \"address\">;\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 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 encodeBatchExecute,\n encodeExecute,\n getDummySignature,\n signUserOperationHash,\n encodeUpgradeToAndCall,\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 = 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 = async (): Promise<NullAddress | Address> => {\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 return trim(storage);\n };\n\n if (entryPoint.version !== \"0.6.0\" && entryPoint.version !== \"0.7.0\") {\n throw new InvalidEntryPointError(chain, entryPoint.version);\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,\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,CAAA;AAClB,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AAkCD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,OAA6B,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ex,\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 } 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 GetEntryPointFromAccount<\n TAccount extends SmartContractAccount | undefined,\n TAccountOverride extends SmartContractAccount = SmartContractAccount\n> = GetAccountParameter<\n TAccount,\n TAccountOverride\n> extends SmartContractAccount<string, infer TEntryPointVersion>\n ? TEntryPointVersion\n : EntryPointVersion;\n\nexport type GetAccountParameter<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TAccountOverride extends SmartContractAccount = SmartContractAccount\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};\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 // 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} & Omit<CustomSource, \"signTransaction\" | \"address\">;\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 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 encodeBatchExecute,\n encodeExecute,\n getDummySignature,\n signUserOperationHash,\n encodeUpgradeToAndCall,\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 = 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 = async (): Promise<NullAddress | Address> => {\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 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,\n };\n}\n"]}
|
|
@@ -36,3 +36,37 @@ export declare class ChainNotFoundError extends BaseError {
|
|
|
36
36
|
*/
|
|
37
37
|
constructor();
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Error class denoting that the provided entity id is invalid because it's too large.
|
|
41
|
+
*/
|
|
42
|
+
export declare class InvalidEntityIdError extends BaseError {
|
|
43
|
+
name: string;
|
|
44
|
+
/**
|
|
45
|
+
* Initializes a new instance of the error message with a default message indicating that the entity id is invalid because it's too large.
|
|
46
|
+
*
|
|
47
|
+
* @param {number} entityId the invalid entityId used
|
|
48
|
+
*/
|
|
49
|
+
constructor(entityId: number);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Error class denoting that the nonce key is invalid because its too large.
|
|
53
|
+
*/
|
|
54
|
+
export declare class InvalidNonceKeyError extends BaseError {
|
|
55
|
+
name: string;
|
|
56
|
+
/**
|
|
57
|
+
* Initializes a new instance of the error message with a default message indicating that the nonce key is invalid.
|
|
58
|
+
*
|
|
59
|
+
* @param {bigint} nonceKey the invalid nonceKey used
|
|
60
|
+
*/
|
|
61
|
+
constructor(nonceKey: bigint);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Error class denoting that the provided entity id is invalid because it's overriding the native entity id.
|
|
65
|
+
*/
|
|
66
|
+
export declare class EntityIdOverrideError extends BaseError {
|
|
67
|
+
name: string;
|
|
68
|
+
/**
|
|
69
|
+
* Initializes a new instance of the error message with a default message indicating that the nonce key is invalid.
|
|
70
|
+
*/
|
|
71
|
+
constructor();
|
|
72
|
+
}
|
|
@@ -59,4 +59,59 @@ export class ChainNotFoundError extends BaseError {
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Error class denoting that the provided entity id is invalid because it's too large.
|
|
64
|
+
*/
|
|
65
|
+
export class InvalidEntityIdError extends BaseError {
|
|
66
|
+
/**
|
|
67
|
+
* Initializes a new instance of the error message with a default message indicating that the entity id is invalid because it's too large.
|
|
68
|
+
*
|
|
69
|
+
* @param {number} entityId the invalid entityId used
|
|
70
|
+
*/
|
|
71
|
+
constructor(entityId) {
|
|
72
|
+
super(`Entity ID used is ${entityId}, but must be less than or equal to uint32.max`);
|
|
73
|
+
Object.defineProperty(this, "name", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
configurable: true,
|
|
76
|
+
writable: true,
|
|
77
|
+
value: "InvalidEntityIdError"
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Error class denoting that the nonce key is invalid because its too large.
|
|
83
|
+
*/
|
|
84
|
+
export class InvalidNonceKeyError extends BaseError {
|
|
85
|
+
/**
|
|
86
|
+
* Initializes a new instance of the error message with a default message indicating that the nonce key is invalid.
|
|
87
|
+
*
|
|
88
|
+
* @param {bigint} nonceKey the invalid nonceKey used
|
|
89
|
+
*/
|
|
90
|
+
constructor(nonceKey) {
|
|
91
|
+
super(`Nonce key is ${nonceKey} but has to be less than or equal to 2**152`);
|
|
92
|
+
Object.defineProperty(this, "name", {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
configurable: true,
|
|
95
|
+
writable: true,
|
|
96
|
+
value: "InvalidNonceKeyError"
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Error class denoting that the provided entity id is invalid because it's overriding the native entity id.
|
|
102
|
+
*/
|
|
103
|
+
export class EntityIdOverrideError extends BaseError {
|
|
104
|
+
/**
|
|
105
|
+
* Initializes a new instance of the error message with a default message indicating that the nonce key is invalid.
|
|
106
|
+
*/
|
|
107
|
+
constructor() {
|
|
108
|
+
super(`EntityId of 0 is reserved for the owner and cannot be used`);
|
|
109
|
+
Object.defineProperty(this, "name", {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
configurable: true,
|
|
112
|
+
writable: true,
|
|
113
|
+
value: "EntityIdOverrideError"
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
62
117
|
//# sourceMappingURL=client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/errors/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,SAAS;IAGpD;;;;;;OAMG;IACH,YAAY,cAAsB,EAAE,MAAc,EAAE,MAAc;QAChE,KAAK,CACH;YACE,mBAAmB,MAAM,CAAC,IAAI,cAAc,cAAc,GAAG;YAC7D,qEAAqE,MAAM,IAAI;SAChF,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;QAfK;;;;mBAAO,yBAAyB;WAAC;IAgB1C,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAG/C;;;;OAIG;IACH,YAAY,MAAe;QACzB,KAAK,CAAC,mBAAmB,MAAM,EAAE,CAAC,CAAC;QAR5B;;;;mBAAO,oBAAoB;WAAC;IASrC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAG/C;;OAEG;IACH;QACE,KAAK,CAAC,iCAAiC,CAAC,CAAC;QANlC;;;;mBAAO,oBAAoB;WAAC;IAOrC,CAAC;CACF","sourcesContent":["import type { Client } from \"viem\";\nimport { BaseError } from \"./base.js\";\n\n/**\n * Represents an error thrown when a client is not compatible with the expected client type for a specific method. The error message provides guidance on how to create a compatible client.\n */\nexport class IncompatibleClientError extends BaseError {\n override name = \"IncompatibleClientError\";\n\n /**\n * Throws an error when the client type does not match the expected client type.\n *\n * @param {string} expectedClient The expected type of the client.\n * @param {string} method The method that was called.\n * @param {Client} client The client instance.\n */\n constructor(expectedClient: string, method: string, client: Client) {\n super(\n [\n `Client of type (${client.type}) is not a ${expectedClient}.`,\n `Create one with \\`createSmartAccountClient\\` first before using \\`${method}\\``,\n ].join(\"\\n\")\n );\n }\n}\n\n/**\n * Represents an error that occurs when an invalid RPC URL is provided. This class extends the `BaseError` class and includes the invalid URL in the error message.\n */\nexport class InvalidRpcUrlError extends BaseError {\n override name = \"InvalidRpcUrlError\";\n\n /**\n * Creates an instance of an error with a message indicating an invalid RPC URL.\n *\n * @param {string} [rpcUrl] The invalid RPC URL that caused the error\n */\n constructor(rpcUrl?: string) {\n super(`Invalid RPC URL ${rpcUrl}`);\n }\n}\n\n/**\n * Error class representing a \"Chain Not Found\" error, typically thrown when no chain is supplied to the client.\n */\nexport class ChainNotFoundError extends BaseError {\n override name = \"ChainNotFoundError\";\n\n /**\n * Initializes a new instance of the error message with a default message indicating that no chain was supplied to the client.\n */\n constructor() {\n super(\"No chain supplied to the client\");\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/errors/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS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";\nimport { BaseError } from \"./base.js\";\n\n/**\n * Represents an error thrown when a client is not compatible with the expected client type for a specific method. The error message provides guidance on how to create a compatible client.\n */\nexport class IncompatibleClientError extends BaseError {\n override name = \"IncompatibleClientError\";\n\n /**\n * Throws an error when the client type does not match the expected client type.\n *\n * @param {string} expectedClient The expected type of the client.\n * @param {string} method The method that was called.\n * @param {Client} client The client instance.\n */\n constructor(expectedClient: string, method: string, client: Client) {\n super(\n [\n `Client of type (${client.type}) is not a ${expectedClient}.`,\n `Create one with \\`createSmartAccountClient\\` first before using \\`${method}\\``,\n ].join(\"\\n\")\n );\n }\n}\n\n/**\n * Represents an error that occurs when an invalid RPC URL is provided. This class extends the `BaseError` class and includes the invalid URL in the error message.\n */\nexport class InvalidRpcUrlError extends BaseError {\n override name = \"InvalidRpcUrlError\";\n\n /**\n * Creates an instance of an error with a message indicating an invalid RPC URL.\n *\n * @param {string} [rpcUrl] The invalid RPC URL that caused the error\n */\n constructor(rpcUrl?: string) {\n super(`Invalid RPC URL ${rpcUrl}`);\n }\n}\n\n/**\n * Error class representing a \"Chain Not Found\" error, typically thrown when no chain is supplied to the client.\n */\nexport class ChainNotFoundError extends BaseError {\n override name = \"ChainNotFoundError\";\n\n /**\n * Initializes a new instance of the error message with a default message indicating that no chain was supplied to the client.\n */\n constructor() {\n super(\"No chain supplied to the client\");\n }\n}\n\n/**\n * Error class denoting that the provided entity id is invalid because it's too large.\n */\nexport class InvalidEntityIdError extends BaseError {\n override name = \"InvalidEntityIdError\";\n\n /**\n * Initializes a new instance of the error message with a default message indicating that the entity id is invalid because it's too large.\n *\n * @param {number} entityId the invalid entityId used\n */\n constructor(entityId: number) {\n super(\n `Entity ID used is ${entityId}, but must be less than or equal to uint32.max`\n );\n }\n}\n\n/**\n * Error class denoting that the nonce key is invalid because its too large.\n */\nexport class InvalidNonceKeyError extends BaseError {\n override name = \"InvalidNonceKeyError\";\n\n /**\n * Initializes a new instance of the error message with a default message indicating that the nonce key is invalid.\n *\n * @param {bigint} nonceKey the invalid nonceKey used\n */\n constructor(nonceKey: bigint) {\n super(\n `Nonce key is ${nonceKey} but has to be less than or equal to 2**152`\n );\n }\n}\n\n/**\n * Error class denoting that the provided entity id is invalid because it's overriding the native entity id.\n */\nexport class EntityIdOverrideError extends BaseError {\n override name = \"EntityIdOverrideError\";\n\n /**\n * Initializes a new instance of the error message with a default message indicating that the nonce key is invalid.\n */\n constructor() {\n super(`EntityId of 0 is reserved for the owner and cannot be used`);\n }\n}\n"]}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export { defaultEntryPointVersion, entryPointRegistry, getEntryPoint, isEntryPoi
|
|
|
33
33
|
export type * from "./entrypoint/types.js";
|
|
34
34
|
export { AccountNotFoundError, AccountRequiresOwnerError, BatchExecutionNotSupportedError, DefaultFactoryNotDefinedError, FailedToGetStorageSlotError, GetCounterFactualAddressError, IncorrectAccountType, SignTransactionNotSupportedError, SmartAccountWithSignerRequiredError, UpgradeToAndCallNotSupportedError, UpgradesNotSupportedError, } from "./errors/account.js";
|
|
35
35
|
export { BaseError } from "./errors/base.js";
|
|
36
|
-
export { ChainNotFoundError, IncompatibleClientError, InvalidRpcUrlError, } from "./errors/client.js";
|
|
36
|
+
export { ChainNotFoundError, IncompatibleClientError, InvalidRpcUrlError, InvalidEntityIdError, InvalidNonceKeyError, EntityIdOverrideError, } from "./errors/client.js";
|
|
37
37
|
export { EntryPointNotFoundError, InvalidEntryPointError, } from "./errors/entrypoint.js";
|
|
38
38
|
export { InvalidSignerTypeError } from "./errors/signer.js";
|
|
39
39
|
export { FailedToFindTransactionError, TransactionMissingToParamError, } from "./errors/transaction.js";
|
package/dist/esm/index.js
CHANGED
|
@@ -23,7 +23,7 @@ export { convertChainIdToCoinType, convertCoinTypeToChain, convertCoinTypeToChai
|
|
|
23
23
|
export { defaultEntryPointVersion, entryPointRegistry, getEntryPoint, isEntryPointVersion, } from "./entrypoint/index.js";
|
|
24
24
|
export { AccountNotFoundError, AccountRequiresOwnerError, BatchExecutionNotSupportedError, DefaultFactoryNotDefinedError, FailedToGetStorageSlotError, GetCounterFactualAddressError, IncorrectAccountType, SignTransactionNotSupportedError, SmartAccountWithSignerRequiredError, UpgradeToAndCallNotSupportedError, UpgradesNotSupportedError, } from "./errors/account.js";
|
|
25
25
|
export { BaseError } from "./errors/base.js";
|
|
26
|
-
export { ChainNotFoundError, IncompatibleClientError, InvalidRpcUrlError, } from "./errors/client.js";
|
|
26
|
+
export { ChainNotFoundError, IncompatibleClientError, InvalidRpcUrlError, InvalidEntityIdError, InvalidNonceKeyError, EntityIdOverrideError, } from "./errors/client.js";
|
|
27
27
|
export { EntryPointNotFoundError, InvalidEntryPointError, } from "./errors/entrypoint.js";
|
|
28
28
|
export { InvalidSignerTypeError } from "./errors/signer.js";
|
|
29
29
|
export { FailedToFindTransactionError, TransactionMissingToParamError, } from "./errors/transaction.js";
|
package/dist/esm/index.js.map
CHANGED
|
@@ -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,MAA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,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAK5D,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,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","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} 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 { LogLevel, Logger } from \"./logger.js\";\nexport { middlewareActions } from \"./middleware/actions.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} 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 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\";\n"]}
|
|
@@ -10,6 +10,10 @@ export declare const asyncPipe: <S, O, F>(...fns: ((s: S, o?: O | undefined, f?:
|
|
|
10
10
|
export type Deferrable<T> = {
|
|
11
11
|
[K in keyof T]: PromiseOrValue<T[K]>;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Used to ensure type doesn't extend another, for use in & chaining of properties
|
|
15
|
+
*/
|
|
16
|
+
export type NotType<A, B> = A extends B ? never : unknown;
|
|
13
17
|
/**
|
|
14
18
|
* Await all of the properties of a Deferrable object
|
|
15
19
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAI7B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GACpB,CAAU,GAAG,GAA2C,EAAE,EAAE,CAC5D,KAAK,EAAE,CAAI,EAAE,CAAK,EAAE,CAAK,EAAE,EAAE;IAC3B,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACrB,MAAM,GAAG,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAI7B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GACpB,CAAU,GAAG,GAA2C,EAAE,EAAE,CAC5D,KAAK,EAAE,CAAI,EAAE,CAAK,EAAE,CAAK,EAAE,EAAE;IAC3B,IAAI,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.js\";\nimport type { RecordableKeys } from \"./types.js\";\n\n/**\n * Utility function that allows for piping a series of async functions together\n *\n * @param {((s: S, o?: O, f?: F) => Promise<S>)[]} fns - functions to pipe\n * @returns {S} result of the pipe\n */\nexport const asyncPipe =\n <S, O, F>(...fns: ((s: S, o?: O, f?: F) => Promise<S>)[]) =>\n async (s: S, o?: O, f?: F) => {\n let result = s;\n for (const fn of fns) {\n result = await fn(result, o, f);\n }\n return result;\n };\n\n// based on @ethersproject/properties, but pulled in here to minize the dependency on ethers\nexport type Deferrable<T> = {\n [K in keyof T]: PromiseOrValue<T[K]>;\n};\n\n/**\n * Used to ensure type doesn't extend another, for use in & chaining of properties\n */\nexport type NotType<A, B> = A extends B ? never : unknown;\n\n/**\n * Await all of the properties of a Deferrable object\n *\n * @param {Deferrable<T>} object - a Deferrable object\n * @returns {Promise<T>} the object with its properties resolved\n */\nexport async function resolveProperties<T>(object: Deferrable<T>): Promise<T> {\n const promises = Object.keys(object).map((key) => {\n const value = object[key as keyof Deferrable<T>];\n return Promise.resolve(value).then((v) => ({ key: key, value: v }));\n });\n\n const results = await Promise.all(promises);\n\n return filterUndefined<T>(\n results.reduce((accum, curr) => {\n accum[curr.key as keyof T] = curr.value;\n return accum;\n }, {} as T)\n );\n}\n\n/**\n * Recursively converts all values in an object to hex strings\n *\n * @param {any} obj - obj to deep hexlify\n * @returns {any} object with all of its values hexlified\n */\nexport function deepHexlify(obj: any): any {\n if (typeof obj === \"function\") {\n return undefined;\n }\n if (obj == null || typeof obj === \"string\" || typeof obj === \"boolean\") {\n return obj;\n } else if (typeof obj === \"bigint\") {\n return toHex(obj);\n } else if (obj._isBigNumber != null || typeof obj !== \"object\") {\n return toHex(obj).replace(/^0x0/, \"0x\");\n }\n if (Array.isArray(obj)) {\n return obj.map((member) => deepHexlify(member));\n }\n return Object.keys(obj).reduce(\n (set, key) => ({\n ...set,\n [key]: deepHexlify(obj[key]),\n }),\n {}\n );\n}\n\n/**\n * Filters out properties with undefined or null values from the provided object.\n *\n * @example\n * ```ts\n * import { filterUndefined } from \"@aa-sdk/core\";\n *\n * const result = filterUndefined({\n * foo: undefined,\n * bar: null,\n * baz: \"baz\",\n * }); // { baz: \"baz\" }\n * ```\n *\n * @param {T} obj the object from which to remove properties with undefined or null values\n * @returns {T} the object with undefined or null properties removed\n */\nexport function filterUndefined<T>(obj: T): T {\n for (const key in obj) {\n if (obj[key] == null) {\n delete obj[key];\n }\n }\n return obj as T;\n}\n\n/**\n * Picks the specified keys from an object and returns a new object containing only those key-value pairs.\n *\n * @example\n * ```ts\n * import { pick } from \"@aa-sdk/core\";\n *\n * const picked = pick({\n * foo: \"foo\",\n * bar: \"bar\",\n * }, [\"foo\"]); // { foo: \"foo\" }\n * ```\n *\n * @param {Record<string, unknown>} obj The object from which to pick keys\n * @param {string|string[]} keys A single key or an array of keys to pick from the object\n * @returns {Record<string, unknown>} A new object containing only the picked key-value pairs\n */\nexport function pick(obj: Record<string, unknown>, keys: string | string[]) {\n return Object.keys(obj)\n .filter((k) => keys.includes(k))\n .reduce((res, k) => Object.assign(res, { [k]: obj[k] }), {});\n}\n\n/**\n * Utility method for checking if the passed in values are all equal (strictly)\n *\n * @param {...any[]} params - values to check\n * @returns {boolean} a boolean indicating if all values are the same\n * @throws if no values are passed in\n */\nexport const allEqual = (...params: any[]): boolean => {\n if (params.length === 0) {\n throw new Error(\"no values passed in\");\n }\n return params.every((v) => v === params[0]);\n};\n\n/**\n * Utility method for checking the condition and return the value if condition holds true, undefined if not.\n *\n * @param {Promise<boolean>} condition - condition to check\n * @param {() => Promise<T>} value - value to return when condition holds true\n * @returns {Promise<T | undefined>} the value if condition holds true, undefined if not\n */\nexport const conditionalReturn = <T>(\n condition: Promise<boolean>,\n value: () => Promise<T>\n): Promise<T | undefined> => condition.then((t) => (t ? value() : undefined));\n\n/**\n * Converts an array of objects into a record (object) where each key is determined by the specified selector and the value is determined by the provided function.\n *\n * @example\n * ```ts\n * import { toRecord } from \"@aa-sdk/core\";\n * import { sepolia, mainnet } from \"viem/chains\";\n *\n * const addressesByChain = toRecord(\n * [sepolia, mainnet],\n * \"id\",\n * () => \"0x...\"\n * ); // { [sepolia.id]: \"0x...\", [mainnet.id]: \"0x...\" }\n * ```\n *\n * @param {T[]} array The array of objects to convert to a record\n * @param {K} selector The key used to select the property that will become the record's key\n * @param {(item: T) => V} fn The function that transforms each item in the array into the record's value\n * @returns {Record<T[K], V>} The resulting record object\n */\nexport const toRecord = <\n T extends { [K in RecordableKeys<T>]: string | number | symbol },\n K extends RecordableKeys<T>,\n V\n>(\n array: T[],\n selector: K,\n fn: (item: T) => V\n): Record<T[K], V> =>\n array.reduce((acc, item) => {\n acc[item[selector]] = fn(item);\n return acc;\n }, {} as Record<T[K], V>);\n\nexport * from \"./bigint.js\";\nexport * from \"./bytes.js\";\nexport * from \"./defaults.js\";\nexport * from \"./schema.js\";\nexport type * from \"./types.js\";\nexport * from \"./userop.js\";\n"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.9.0";
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -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,OAAO,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.9.0\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartContractAccount.d.ts","sourceRoot":"","sources":["../../../src/account/smartContractAccount.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"smartContractAccount.d.ts","sourceRoot":"","sources":["../../../src/account/smartContractAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,KAAK,GAAG,EACR,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,mBAAmB,EACzB,MAAM,MAAM,CAAC;AAGd,OAAO,KAAK,EACV,aAAa,EACb,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAWhC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC;CAClB,CAAC;AAEF,oBAAY,eAAe;IACzB,SAAS,QAAQ;IACjB,YAAY,QAAQ;IACpB,QAAQ,QAAQ;CACjB;AAED,MAAM,MAAM,wBAAwB,CAClC,QAAQ,SAAS,oBAAoB,GAAG,SAAS,EACjD,gBAAgB,SAAS,oBAAoB,GAAG,oBAAoB,IAClE,mBAAmB,CACrB,QAAQ,EACR,gBAAgB,CACjB,SAAS,oBAAoB,CAAC,MAAM,EAAE,MAAM,kBAAkB,CAAC,GAC5D,kBAAkB,GAClB,iBAAiB,CAAC;AAEtB,MAAM,MAAM,mBAAmB,CAC7B,QAAQ,SAAS,oBAAoB,GAAG,SAAS,GAC7C,oBAAoB,GACpB,SAAS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,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,KAAK,EAC5B,kBAAkB,SAAS,iBAAiB,GAAG,iBAAiB,EAChE,EACA,SAAS,EACT,KAAK,EACL,UAAU,EACV,MAAM,EACN,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,GACvB,EAAE,4BAA4B,CAC7B,IAAI,EACJ,UAAU,EACV,MAAM,EACN,kBAAkB,CACnB,GAAG,OAAO,CAAC,oBAAoB,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC"}
|
|
@@ -36,4 +36,38 @@ export declare class ChainNotFoundError extends BaseError {
|
|
|
36
36
|
*/
|
|
37
37
|
constructor();
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Error class denoting that the provided entity id is invalid because it's too large.
|
|
41
|
+
*/
|
|
42
|
+
export declare class InvalidEntityIdError extends BaseError {
|
|
43
|
+
name: string;
|
|
44
|
+
/**
|
|
45
|
+
* Initializes a new instance of the error message with a default message indicating that the entity id is invalid because it's too large.
|
|
46
|
+
*
|
|
47
|
+
* @param {number} entityId the invalid entityId used
|
|
48
|
+
*/
|
|
49
|
+
constructor(entityId: number);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Error class denoting that the nonce key is invalid because its too large.
|
|
53
|
+
*/
|
|
54
|
+
export declare class InvalidNonceKeyError extends BaseError {
|
|
55
|
+
name: string;
|
|
56
|
+
/**
|
|
57
|
+
* Initializes a new instance of the error message with a default message indicating that the nonce key is invalid.
|
|
58
|
+
*
|
|
59
|
+
* @param {bigint} nonceKey the invalid nonceKey used
|
|
60
|
+
*/
|
|
61
|
+
constructor(nonceKey: bigint);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Error class denoting that the provided entity id is invalid because it's overriding the native entity id.
|
|
65
|
+
*/
|
|
66
|
+
export declare class EntityIdOverrideError extends BaseError {
|
|
67
|
+
name: string;
|
|
68
|
+
/**
|
|
69
|
+
* Initializes a new instance of the error message with a default message indicating that the nonce key is invalid.
|
|
70
|
+
*/
|
|
71
|
+
constructor();
|
|
72
|
+
}
|
|
39
73
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/errors/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,SAAS;IAC3C,IAAI,SAA6B;IAE1C;;;;;;OAMG;gBACS,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAQnE;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,SAAS;IACtC,IAAI,SAAwB;IAErC;;;;OAIG;gBACS,MAAM,CAAC,EAAE,MAAM;CAG5B;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,SAAS;IACtC,IAAI,SAAwB;IAErC;;OAEG;;CAIJ"}
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/errors/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,SAAS;IAC3C,IAAI,SAA6B;IAE1C;;;;;;OAMG;gBACS,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAQnE;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,SAAS;IACtC,IAAI,SAAwB;IAErC;;;;OAIG;gBACS,MAAM,CAAC,EAAE,MAAM;CAG5B;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,SAAS;IACtC,IAAI,SAAwB;IAErC;;OAEG;;CAIJ;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;IACxC,IAAI,SAA0B;IAEvC;;;;OAIG;gBACS,QAAQ,EAAE,MAAM;CAK7B;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;IACxC,IAAI,SAA0B;IAEvC;;;;OAIG;gBACS,QAAQ,EAAE,MAAM;CAK7B;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,SAAS;IACzC,IAAI,SAA2B;IAExC;;OAEG;;CAIJ"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export { defaultEntryPointVersion, entryPointRegistry, getEntryPoint, isEntryPoi
|
|
|
33
33
|
export type * from "./entrypoint/types.js";
|
|
34
34
|
export { AccountNotFoundError, AccountRequiresOwnerError, BatchExecutionNotSupportedError, DefaultFactoryNotDefinedError, FailedToGetStorageSlotError, GetCounterFactualAddressError, IncorrectAccountType, SignTransactionNotSupportedError, SmartAccountWithSignerRequiredError, UpgradeToAndCallNotSupportedError, UpgradesNotSupportedError, } from "./errors/account.js";
|
|
35
35
|
export { BaseError } from "./errors/base.js";
|
|
36
|
-
export { ChainNotFoundError, IncompatibleClientError, InvalidRpcUrlError, } from "./errors/client.js";
|
|
36
|
+
export { ChainNotFoundError, IncompatibleClientError, InvalidRpcUrlError, InvalidEntityIdError, InvalidNonceKeyError, EntityIdOverrideError, } from "./errors/client.js";
|
|
37
37
|
export { EntryPointNotFoundError, InvalidEntryPointError, } from "./errors/entrypoint.js";
|
|
38
38
|
export { InvalidSignerTypeError } from "./errors/signer.js";
|
|
39
39
|
export { FailedToFindTransactionError, TransactionMissingToParamError, } from "./errors/transaction.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,GAAG,EAAE,MAAM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AAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC5D,YAAY,EACV,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACxE,mBAAmB,YAAY,CAAC;AAChC,mBAAmB,kBAAkB,CAAC;AACtC,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"}
|
|
@@ -10,6 +10,10 @@ export declare const asyncPipe: <S, O, F>(...fns: ((s: S, o?: O | undefined, f?:
|
|
|
10
10
|
export type Deferrable<T> = {
|
|
11
11
|
[K in keyof T]: PromiseOrValue<T[K]>;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Used to ensure type doesn't extend another, for use in & chaining of properties
|
|
15
|
+
*/
|
|
16
|
+
export type NotType<A, B> = A extends B ? never : unknown;
|
|
13
17
|
/**
|
|
14
18
|
* Await all of the properties of a Deferrable object
|
|
15
19
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AACA,O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AAC;AAChC,cAAc,aAAa,CAAC"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.9.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.
|
|
4
|
+
"version": "4.9.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",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"!vitest.config.ts",
|
|
18
18
|
"!.env",
|
|
19
19
|
"!src/**/*.test.ts",
|
|
20
|
+
"!src/**/*.test-d.ts",
|
|
20
21
|
"!src/__tests__/**/*"
|
|
21
22
|
],
|
|
22
23
|
"exports": {
|
|
@@ -64,5 +65,5 @@
|
|
|
64
65
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
65
66
|
},
|
|
66
67
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
67
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "9cd4dc759879defa6ac90f1ae7f8a378d9d1666f"
|
|
68
69
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getContract,
|
|
3
3
|
hexToBytes,
|
|
4
|
-
trim,
|
|
5
4
|
type Address,
|
|
6
5
|
type Chain,
|
|
7
6
|
type CustomSource,
|
|
@@ -483,7 +482,9 @@ export async function toSmartContractAccount(
|
|
|
483
482
|
);
|
|
484
483
|
}
|
|
485
484
|
|
|
486
|
-
|
|
485
|
+
// The storage slot contains a full bytes32, but we want only the last 20 bytes.
|
|
486
|
+
// So, slice off the leading `0x` and the first 12 bytes (24 characters), leaving the last 20 bytes, then prefix with `0x`.
|
|
487
|
+
return `0x${storage.slice(26)}`;
|
|
487
488
|
};
|
|
488
489
|
|
|
489
490
|
if (entryPoint.version !== "0.6.0" && entryPoint.version !== "0.7.0") {
|
package/src/errors/client.ts
CHANGED
|
@@ -53,3 +53,53 @@ export class ChainNotFoundError extends BaseError {
|
|
|
53
53
|
super("No chain supplied to the client");
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Error class denoting that the provided entity id is invalid because it's too large.
|
|
59
|
+
*/
|
|
60
|
+
export class InvalidEntityIdError extends BaseError {
|
|
61
|
+
override name = "InvalidEntityIdError";
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Initializes a new instance of the error message with a default message indicating that the entity id is invalid because it's too large.
|
|
65
|
+
*
|
|
66
|
+
* @param {number} entityId the invalid entityId used
|
|
67
|
+
*/
|
|
68
|
+
constructor(entityId: number) {
|
|
69
|
+
super(
|
|
70
|
+
`Entity ID used is ${entityId}, but must be less than or equal to uint32.max`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Error class denoting that the nonce key is invalid because its too large.
|
|
77
|
+
*/
|
|
78
|
+
export class InvalidNonceKeyError extends BaseError {
|
|
79
|
+
override name = "InvalidNonceKeyError";
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Initializes a new instance of the error message with a default message indicating that the nonce key is invalid.
|
|
83
|
+
*
|
|
84
|
+
* @param {bigint} nonceKey the invalid nonceKey used
|
|
85
|
+
*/
|
|
86
|
+
constructor(nonceKey: bigint) {
|
|
87
|
+
super(
|
|
88
|
+
`Nonce key is ${nonceKey} but has to be less than or equal to 2**152`
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Error class denoting that the provided entity id is invalid because it's overriding the native entity id.
|
|
95
|
+
*/
|
|
96
|
+
export class EntityIdOverrideError extends BaseError {
|
|
97
|
+
override name = "EntityIdOverrideError";
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Initializes a new instance of the error message with a default message indicating that the nonce key is invalid.
|
|
101
|
+
*/
|
|
102
|
+
constructor() {
|
|
103
|
+
super(`EntityId of 0 is reserved for the owner and cannot be used`);
|
|
104
|
+
}
|
|
105
|
+
}
|
package/src/index.ts
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -23,6 +23,11 @@ export type Deferrable<T> = {
|
|
|
23
23
|
[K in keyof T]: PromiseOrValue<T[K]>;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Used to ensure type doesn't extend another, for use in & chaining of properties
|
|
28
|
+
*/
|
|
29
|
+
export type NotType<A, B> = A extends B ? never : unknown;
|
|
30
|
+
|
|
26
31
|
/**
|
|
27
32
|
* Await all of the properties of a Deferrable object
|
|
28
33
|
*
|
package/src/version.ts
CHANGED