@alchemy/smart-accounts 0.0.0-alpha.9 → 5.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +36 -0
- package/dist/esm/index.d.ts +2 -4
- package/dist/esm/index.js +2 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/light-account/accounts/account.d.ts +7 -3
- package/dist/esm/light-account/accounts/account.js +20 -10
- package/dist/esm/light-account/accounts/account.js.map +1 -1
- package/dist/esm/light-account/accounts/base.js +50 -23
- package/dist/esm/light-account/accounts/base.js.map +1 -1
- package/dist/esm/light-account/accounts/calldataCodec.js +3 -2
- package/dist/esm/light-account/accounts/calldataCodec.js.map +1 -1
- package/dist/esm/light-account/accounts/multi-owner-account.d.ts +6 -2
- package/dist/esm/light-account/accounts/multi-owner-account.js +14 -6
- package/dist/esm/light-account/accounts/multi-owner-account.js.map +1 -1
- package/dist/esm/light-account/lightAccountStaticImpl.d.ts +3 -1
- package/dist/esm/light-account/lightAccountStaticImpl.js +57 -7
- package/dist/esm/light-account/lightAccountStaticImpl.js.map +1 -1
- package/dist/esm/light-account/predictAddress.d.ts +40 -2
- package/dist/esm/light-account/predictAddress.js +83 -3
- package/dist/esm/light-account/predictAddress.js.map +1 -1
- package/dist/esm/light-account/registry.d.ts +3410 -0
- package/dist/esm/light-account/registry.js +33 -1
- package/dist/esm/light-account/registry.js.map +1 -1
- package/dist/esm/logger.d.ts +1 -1
- package/dist/esm/logger.js +1 -1
- package/dist/esm/logger.js.map +1 -1
- package/dist/esm/ma-v1/accounts/multi-owner-account.d.ts +6 -2
- package/dist/esm/ma-v1/accounts/multi-owner-account.js +18 -7
- package/dist/esm/ma-v1/accounts/multi-owner-account.js.map +1 -1
- package/dist/esm/ma-v1/predictAddress.d.ts +20 -1
- package/dist/esm/ma-v1/predictAddress.js +38 -2
- package/dist/esm/ma-v1/predictAddress.js.map +1 -1
- package/dist/esm/ma-v2/accounts/account.d.ts +8 -5
- package/dist/esm/ma-v2/accounts/account.js +23 -42
- package/dist/esm/ma-v2/accounts/account.js.map +1 -1
- package/dist/esm/ma-v2/accounts/base.d.ts +2 -2
- package/dist/esm/ma-v2/accounts/base.js +12 -59
- package/dist/esm/ma-v2/accounts/base.js.map +1 -1
- package/dist/esm/ma-v2/mav2StaticImpl.d.ts +1 -15
- package/dist/esm/ma-v2/mav2StaticImpl.js +0 -33
- package/dist/esm/ma-v2/mav2StaticImpl.js.map +1 -1
- package/dist/esm/ma-v2/modules/time-range-module/module.js +3 -2
- package/dist/esm/ma-v2/modules/time-range-module/module.js.map +1 -1
- package/dist/esm/ma-v2/predictAddress.d.ts +22 -6
- package/dist/esm/ma-v2/predictAddress.js +46 -12
- package/dist/esm/ma-v2/predictAddress.js.map +1 -1
- package/dist/esm/ma-v2/utils/account.d.ts +0 -3
- package/dist/esm/ma-v2/utils/account.js +0 -3
- package/dist/esm/ma-v2/utils/account.js.map +1 -1
- package/dist/esm/ma-v2/utils/signature.d.ts +1 -16
- package/dist/esm/ma-v2/utils/signature.js +1 -38
- package/dist/esm/ma-v2/utils/signature.js.map +1 -1
- package/dist/esm/utils.d.ts +24 -11
- package/dist/esm/utils.js +67 -21
- package/dist/esm/utils.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/index.d.ts +2 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/light-account/accounts/account.d.ts +7 -3
- package/dist/types/light-account/accounts/account.d.ts.map +1 -1
- package/dist/types/light-account/accounts/base.d.ts.map +1 -1
- package/dist/types/light-account/accounts/calldataCodec.d.ts.map +1 -1
- package/dist/types/light-account/accounts/multi-owner-account.d.ts +6 -2
- package/dist/types/light-account/accounts/multi-owner-account.d.ts.map +1 -1
- package/dist/types/light-account/lightAccountStaticImpl.d.ts +3 -1
- package/dist/types/light-account/lightAccountStaticImpl.d.ts.map +1 -1
- package/dist/types/light-account/predictAddress.d.ts +40 -2
- package/dist/types/light-account/predictAddress.d.ts.map +1 -1
- package/dist/types/light-account/registry.d.ts +3410 -0
- package/dist/types/light-account/registry.d.ts.map +1 -1
- package/dist/types/logger.d.ts +1 -1
- package/dist/types/logger.d.ts.map +1 -1
- package/dist/types/ma-v1/accounts/multi-owner-account.d.ts +6 -2
- package/dist/types/ma-v1/accounts/multi-owner-account.d.ts.map +1 -1
- package/dist/types/ma-v1/predictAddress.d.ts +20 -1
- package/dist/types/ma-v1/predictAddress.d.ts.map +1 -1
- package/dist/types/ma-v2/accounts/account.d.ts +8 -5
- package/dist/types/ma-v2/accounts/account.d.ts.map +1 -1
- package/dist/types/ma-v2/accounts/base.d.ts +2 -2
- package/dist/types/ma-v2/accounts/base.d.ts.map +1 -1
- package/dist/types/ma-v2/mav2StaticImpl.d.ts +1 -15
- package/dist/types/ma-v2/mav2StaticImpl.d.ts.map +1 -1
- package/dist/types/ma-v2/modules/time-range-module/module.d.ts.map +1 -1
- package/dist/types/ma-v2/predictAddress.d.ts +22 -6
- package/dist/types/ma-v2/predictAddress.d.ts.map +1 -1
- package/dist/types/ma-v2/utils/account.d.ts +0 -3
- package/dist/types/ma-v2/utils/account.d.ts.map +1 -1
- package/dist/types/ma-v2/utils/signature.d.ts +1 -16
- package/dist/types/ma-v2/utils/signature.d.ts.map +1 -1
- package/dist/types/utils.d.ts +24 -11
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +9 -8
- package/src/index.ts +0 -6
- package/src/light-account/accounts/account.ts +30 -16
- package/src/light-account/accounts/base.ts +62 -23
- package/src/light-account/accounts/calldataCodec.ts +3 -2
- package/src/light-account/accounts/multi-owner-account.ts +22 -9
- package/src/light-account/lightAccountStaticImpl.ts +84 -11
- package/src/light-account/predictAddress.ts +124 -3
- package/src/light-account/registry.ts +44 -0
- package/src/logger.ts +2 -2
- package/src/ma-v1/accounts/multi-owner-account.ts +26 -11
- package/src/ma-v1/predictAddress.ts +60 -3
- package/src/ma-v2/accounts/account.ts +39 -52
- package/src/ma-v2/accounts/base.ts +11 -84
- package/src/ma-v2/mav2StaticImpl.ts +1 -52
- package/src/ma-v2/modules/time-range-module/module.ts +3 -2
- package/src/ma-v2/predictAddress.ts +68 -30
- package/src/ma-v2/utils/account.ts +0 -3
- package/src/ma-v2/utils/signature.ts +2 -57
- package/src/utils.ts +111 -27
- package/src/version.ts +1 -1
- package/dist/esm/ma-v2/abis/webAuthnFactoryAbi.d.ts +0 -330
- package/dist/esm/ma-v2/abis/webAuthnFactoryAbi.js +0 -260
- package/dist/esm/ma-v2/abis/webAuthnFactoryAbi.js.map +0 -1
- package/dist/esm/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.d.ts +0 -287
- package/dist/esm/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.js +0 -374
- package/dist/esm/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.js.map +0 -1
- package/dist/esm/ma-v2/modules/webauthn-validation/module.d.ts +0 -11
- package/dist/esm/ma-v2/modules/webauthn-validation/module.js +0 -16
- package/dist/esm/ma-v2/modules/webauthn-validation/module.js.map +0 -1
- package/dist/types/ma-v2/abis/webAuthnFactoryAbi.d.ts +0 -331
- package/dist/types/ma-v2/abis/webAuthnFactoryAbi.d.ts.map +0 -1
- package/dist/types/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.d.ts +0 -288
- package/dist/types/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.d.ts.map +0 -1
- package/dist/types/ma-v2/modules/webauthn-validation/module.d.ts +0 -12
- package/dist/types/ma-v2/modules/webauthn-validation/module.d.ts.map +0 -1
- package/src/ma-v2/abis/webAuthnFactoryAbi.ts +0 -259
- package/src/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.ts +0 -373
- package/src/ma-v2/modules/webauthn-validation/module.ts +0 -28
|
@@ -5,18 +5,15 @@ import { semiModularAccountStorageAbi } from "../abis/semiModularAccountStorageA
|
|
|
5
5
|
*/
|
|
6
6
|
export const DefaultAddress = {
|
|
7
7
|
MAV2_FACTORY: "0x00000000000017c61b5bEe81050EC8eFc9c6fecd",
|
|
8
|
-
MAV2_FACTORY_WEBAUTHN: "0x55010E571dCf07e254994bfc88b9C1C8FAe31960",
|
|
9
8
|
SMAV2_BYTECODE: "0x000000000000c5A9089039570Dd36455b5C07383",
|
|
10
9
|
SMAV2_STORAGE: "0x0000000000006E2f9d80CaEc0Da6500f005EB25A",
|
|
11
10
|
SMAV2_7702: "0x69007702764179f14F51cdce752f4f775d74E139",
|
|
12
|
-
MAV2: "0x00000000000002377B26b1EdA7b0BC371C60DD4f",
|
|
13
11
|
};
|
|
14
12
|
/**
|
|
15
13
|
* A mapping of default addresses for the ModularAccountV2 modules.
|
|
16
14
|
*/
|
|
17
15
|
export const DefaultModuleAddress = {
|
|
18
16
|
SINGLE_SIGNER_VALIDATION: "0x00000000000099DE0BF6fA90dEB851E2A2df7d83",
|
|
19
|
-
WEBAUTHN_VALIDATION: "0x0000000000001D9d34E07D9834274dF9ae575217",
|
|
20
17
|
TIME_RANGE: "0x00000000000082B8e2012be914dFA4f62A0573eA",
|
|
21
18
|
PAYMASTER_GUARD: "0x0000000000001aA7A7F7E29abe0be06c72FD42A1",
|
|
22
19
|
NATIVE_TOKEN_LIMIT: "0x00000000000001e541f0D090868FBe24b59Fbe06",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../src/ma-v2/utils/account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,KAAK,GAGN,MAAM,MAAM,CAAC;AAId,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AAGvF;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,YAAY,EAAE,4CAA4C;IAC1D,
|
|
1
|
+
{"version":3,"file":"account.js","s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Q,IAAI,GAAG,CAAC;QACjB,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxB,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5B,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC/B,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAoB;IACxD,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAChF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAqB;IAErB,OAAO,CACL,kBAAkB,IAAI,OAAO;QAC7B,OAAO,CAAC,gBAAgB,KAAK,kBAAkB,CAChD,CAAC;AACJ,CAAC","sourcesContent":["import {\n concatHex,\n encodeFunctionData,\n toHex,\n type Address,\n type Hex,\n} from \"viem\";\nimport type { SmartAccount } from \"viem/account-abstraction\";\nimport type { GetAccountParameter } from \"../../types.js\";\nimport type { ModuleEntity, UpgradeToData } from \"../types.js\";\nimport { semiModularAccountStorageAbi } from \"../abis/semiModularAccountStorageAbi.js\";\nimport type { ModularAccountV2Base } from \"../accounts/base.js\";\n\n/**\n * A mapping of default addresses for the ModularAccountV2.\n */\nexport const DefaultAddress = {\n MAV2_FACTORY: \"0x00000000000017c61b5bEe81050EC8eFc9c6fecd\",\n SMAV2_BYTECODE: \"0x000000000000c5A9089039570Dd36455b5C07383\",\n SMAV2_STORAGE: \"0x0000000000006E2f9d80CaEc0Da6500f005EB25A\",\n SMAV2_7702: \"0x69007702764179f14F51cdce752f4f775d74E139\",\n} satisfies Record<string, Address>;\n\n/**\n * A mapping of default addresses for the ModularAccountV2 modules.\n */\nexport const DefaultModuleAddress = {\n SINGLE_SIGNER_VALIDATION: \"0x00000000000099DE0BF6fA90dEB851E2A2df7d83\",\n TIME_RANGE: \"0x00000000000082B8e2012be914dFA4f62A0573eA\",\n PAYMASTER_GUARD: \"0x0000000000001aA7A7F7E29abe0be06c72FD42A1\",\n NATIVE_TOKEN_LIMIT: \"0x00000000000001e541f0D090868FBe24b59Fbe06\",\n ALLOWLIST: \"0x00000000003e826473a313e600b5b9b791f5a59a\",\n} satisfies Record<string, Address>;\n\n/**\n * The default owner entity ID.\n */\nexport const DEFAULT_OWNER_ENTITY_ID = 0;\n\n/**\n * The selector for the execute user operation function.\n */\nexport const EXECUTE_USER_OP_SELECTOR: Hex = \"0x8DD7712F\";\n\nexport type GetMAV2UpgradeToData<\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n> = GetAccountParameter<TAccount>;\n\n/**\n * Gets the upgrade to data for the ModularAccountV2.\n *\n * @param {Address} ownerAddress - The address of the owner.\n * @returns {Promise<UpgradeToData>} The upgrade to data.\n */\nexport async function getMAV2UpgradeToData(\n ownerAddress: Address,\n): Promise<UpgradeToData> {\n const initData = encodeFunctionData({\n abi: semiModularAccountStorageAbi,\n functionName: \"initialize\",\n args: [ownerAddress],\n });\n\n return {\n implAddress: DefaultAddress.SMAV2_STORAGE,\n initializationData: initData,\n // TODO(v5): do we need `createModularAccountV2FromExisting()` in the return type here like we had in v4 or no?\n // Almost certainly not, but we need to clean up other parts in SDK for client-side upgrades.\n };\n}\n\nexport type BuildNonceParams = {\n nonceKey?: bigint;\n entityId?: number;\n isGlobalValidation?: boolean;\n isDeferredAction?: boolean;\n isDirectCallValidation?: boolean;\n};\n\n/**\n * Builds a full nonce key.\n *\n * @param {BuildNonceParams} params - The parameters for building a full nonce key.\n * @returns {bigint} The full nonce key.\n */\nexport const buildFullNonceKey = ({\n nonceKey = 0n,\n entityId = 0,\n isGlobalValidation = true,\n isDeferredAction = false,\n}: BuildNonceParams): bigint => {\n return (\n (nonceKey << 40n) +\n (BigInt(entityId) << 8n) +\n (isDeferredAction ? 2n : 0n) +\n (isGlobalValidation ? 1n : 0n)\n );\n};\n\n/**\n * Serializes a module entity into a hexadecimal format by concatenating the module address and entity ID.\n *\n * @example\n * ```ts\n * import { serializeModuleEntity } from \"@alchemy/smart-accounts\";\n * import { Address } from \"viem\";\n *\n * const moduleAddress: Address = \"0x1234\";\n * const entityId: number = 1234;\n *\n * const moduleEntityHex = serializeModuleEntity({\n * moduleAddress,\n * entityId\n * });\n * ```\n *\n * @param {ModuleEntity} config The module entity configuration containing the module address and entity ID\n * @returns {Hex} A hexadecimal string representation of the serialized module entity\n */\nexport function serializeModuleEntity(config: ModuleEntity): Hex {\n return concatHex([config.moduleAddress, toHex(config.entityId, { size: 4 })]);\n}\n\n/**\n * Checks if an account is a ModularAccountV2.\n *\n * @param {SmartAccount} account - The account to check.\n * @returns {boolean} True if the account is a ModularAccountV2, false otherwise.\n */\nexport function isModularAccountV2(\n account: SmartAccount,\n): account is ModularAccountV2Base {\n return (\n \"smartAccountType\" in account &&\n account.smartAccountType === \"ModularAccountV2\"\n );\n}\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type Address, type Hash, type Hex } from "viem";
|
|
2
2
|
import { SignaturePrefix } from "../types.js";
|
|
3
|
-
import { type WebAuthnP256 } from "ox";
|
|
4
3
|
export type PackUOSignatureParams = {
|
|
5
4
|
validationSignature: Hex;
|
|
6
5
|
};
|
|
@@ -13,7 +12,7 @@ export type PackUOSignatureParams = {
|
|
|
13
12
|
export declare const packUOSignature: ({ validationSignature, }: PackUOSignatureParams) => Hex;
|
|
14
13
|
export type Pack1271SignatureParams = {
|
|
15
14
|
entityId: number;
|
|
16
|
-
validationSignaturePrefix: SignaturePrefix
|
|
15
|
+
validationSignaturePrefix: SignaturePrefix;
|
|
17
16
|
validationSignature: Hex;
|
|
18
17
|
};
|
|
19
18
|
/**
|
|
@@ -51,17 +50,3 @@ export declare function toReplaySafeTypedData({ address, chainId, hash, salt, }:
|
|
|
51
50
|
};
|
|
52
51
|
primaryType: "ReplaySafeHash";
|
|
53
52
|
};
|
|
54
|
-
/**
|
|
55
|
-
* Wraps a P256 signature with the webauthn metadata.
|
|
56
|
-
*
|
|
57
|
-
* @param {ToWebAuthnSignatureParams} params - The parameters for wrapping a P256 signature with the webauthn metadata.
|
|
58
|
-
* @returns {object} The wrapped P256 signature.
|
|
59
|
-
*/
|
|
60
|
-
export declare function toWebAuthnSignature({ webauthn, signature, }: {
|
|
61
|
-
webauthn: WebAuthnP256.SignMetadata;
|
|
62
|
-
signature: Hex;
|
|
63
|
-
}): `0x${string}`;
|
|
64
|
-
/**
|
|
65
|
-
* A dummy WebAuthn signature used for gas estimation.
|
|
66
|
-
*/
|
|
67
|
-
export declare const WEBAUTHN_DUMMY_SIGNATURE = "0xff000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000001949fc7c88032b9fcb5f6efc7a7b8c63668eae9871b765e23123bb473ff57aa831a7c0d9276168ebcc29f2875a0239cffdf2a9cd1c2007c5c77c071db9264df1d000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008a7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a2273496a396e6164474850596759334b7156384f7a4a666c726275504b474f716d59576f4d57516869467773222c226f726967696e223a2268747470733a2f2f7369676e2e636f696e626173652e636f6d222c2263726f73734f726967696e223a66616c73657d00000000000000000000000000000000000000000000";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { concatHex,
|
|
1
|
+
import { concatHex, toHex } from "viem";
|
|
2
2
|
import { SignaturePrefix } from "../types.js";
|
|
3
|
-
import { Signature } from "ox";
|
|
4
3
|
/**
|
|
5
4
|
* Signature packing utility for user operations.
|
|
6
5
|
*
|
|
@@ -49,40 +48,4 @@ export function toReplaySafeTypedData({ address, chainId, hash, salt, }) {
|
|
|
49
48
|
primaryType: "ReplaySafeHash",
|
|
50
49
|
};
|
|
51
50
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Wraps a P256 signature with the webauthn metadata.
|
|
54
|
-
*
|
|
55
|
-
* @param {ToWebAuthnSignatureParams} params - The parameters for wrapping a P256 signature with the webauthn metadata.
|
|
56
|
-
* @returns {object} The wrapped P256 signature.
|
|
57
|
-
*/
|
|
58
|
-
export function toWebAuthnSignature({ webauthn, signature, }) {
|
|
59
|
-
const { r, s } = Signature.fromHex(signature);
|
|
60
|
-
return encodeAbiParameters([
|
|
61
|
-
{
|
|
62
|
-
name: "params",
|
|
63
|
-
type: "tuple",
|
|
64
|
-
components: [
|
|
65
|
-
{ name: "authenticatorData", type: "bytes" },
|
|
66
|
-
{ name: "clientDataJSON", type: "string" },
|
|
67
|
-
{ name: "challengeIndex", type: "uint256" },
|
|
68
|
-
{ name: "typeIndex", type: "uint256" },
|
|
69
|
-
{ name: "r", type: "uint256" },
|
|
70
|
-
{ name: "s", type: "uint256" },
|
|
71
|
-
],
|
|
72
|
-
},
|
|
73
|
-
], [
|
|
74
|
-
{
|
|
75
|
-
authenticatorData: webauthn.authenticatorData,
|
|
76
|
-
clientDataJSON: webauthn.clientDataJSON,
|
|
77
|
-
challengeIndex: BigInt(webauthn.challengeIndex),
|
|
78
|
-
typeIndex: BigInt(webauthn.typeIndex),
|
|
79
|
-
r,
|
|
80
|
-
s,
|
|
81
|
-
},
|
|
82
|
-
]);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* A dummy WebAuthn signature used for gas estimation.
|
|
86
|
-
*/
|
|
87
|
-
export const WEBAUTHN_DUMMY_SIGNATURE = "0xff000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000001949fc7c88032b9fcb5f6efc7a7b8c63668eae9871b765e23123bb473ff57aa831a7c0d9276168ebcc29f2875a0239cffdf2a9cd1c2007c5c77c071db9264df1d000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008a7b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a2273496a396e6164474850596759334b7156384f7a4a666c726275504b474f716d59576f4d57516869467773222c226f726967696e223a2268747470733a2f2f7369676e2e636f696e626173652e636f6d222c2263726f73734f726967696e223a66616c73657d00000000000000000000000000000000000000000000";
|
|
88
51
|
//# sourceMappingURL=signature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature.js","sourceRoot":"","sources":["../../../../src/ma-v2/utils/signature.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"signature.js","sourceRoot":"","sources":["../../../../src/ma-v2/utils/signature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAqC,MAAM,MAAM,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAO9C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC;AAC9B,iEAAiE;AACjE,mBAAmB,GACG,EAAO,EAAE;IAC/B,OAAO,SAAS,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC;AAC1D,CAAC,CAAC;AASF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,QAAQ,EACR,yBAAyB,EACzB,mBAAmB,GACK,EAAO,EAAE;IACjC,OAAO,SAAS,CAAC;QACf,MAAM;QACN,KAAK,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAC5B,MAAM;QACN,GAAG,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACjE,mBAAmB;KACpB,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,EACpC,OAAO,EACP,OAAO,EACP,IAAI,EACJ,IAAI,GAML;IACC,OAAO;QACL,MAAM,EAAE;YACN,OAAO;YACP,iBAAiB,EAAE,OAAO;YAC1B,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1B;QACD,KAAK,EAAE;YACL,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;SACpD;QACD,OAAO,EAAE;YACP,IAAI;SACL;QACD,WAAW,EAAE,gBAAyB;KACvC,CAAC;AACJ,CAAC","sourcesContent":["import { concatHex, toHex, type Address, type Hash, type Hex } from \"viem\";\nimport { SignaturePrefix } from \"../types.js\";\n\nexport type PackUOSignatureParams = {\n // orderedHookData: HookData[];\n validationSignature: Hex;\n};\n\n/**\n * Signature packing utility for user operations.\n *\n * @param {PackUOSignatureParams} params - The parameters for packing a user operation signature.\n * @returns {Hex} The packed user operation signature.\n */\nexport const packUOSignature = ({\n // orderedHookData, TODO: integrate in next iteration of MAv2 sdk\n validationSignature,\n}: PackUOSignatureParams): Hex => {\n return concatHex([\"0xFF\", \"0x00\", validationSignature]);\n};\n\n// TODO(v4): direct call validation 1271\nexport type Pack1271SignatureParams = {\n entityId: number;\n validationSignaturePrefix: SignaturePrefix;\n validationSignature: Hex;\n};\n\n/**\n * Signature packing utility for 1271 signatures.\n *\n * @param {Pack1271SignatureParams} params - The parameters for packing a 1271 signature.\n * @returns {Hex} The packed 1271 signature.\n */\nexport const pack1271Signature = ({\n entityId,\n validationSignaturePrefix,\n validationSignature,\n}: Pack1271SignatureParams): Hex => {\n return concatHex([\n \"0x00\",\n toHex(entityId, { size: 4 }),\n \"0xFF\",\n ...(validationSignaturePrefix ? [validationSignaturePrefix] : []),\n validationSignature,\n ]);\n};\n\n/**\n * Converts a hash to a replay safe typed data.\n *\n * @param {ToReplaySafeTypedDataParams} params - The parameters for converting a hash to a replay safe typed data.\n * @returns {object} The replay safe typed data.\n */\nexport function toReplaySafeTypedData({\n address,\n chainId,\n hash,\n salt,\n}: {\n address: Address;\n chainId: number;\n hash: Hash;\n salt?: Hex;\n}) {\n return {\n domain: {\n chainId,\n verifyingContract: address,\n ...(salt ? { salt } : {}),\n },\n types: {\n ReplaySafeHash: [{ name: \"hash\", type: \"bytes32\" }],\n },\n message: {\n hash,\n },\n primaryType: \"ReplaySafeHash\" as const,\n };\n}\n"]}
|
package/dist/esm/utils.d.ts
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
import { type Client, type Hex } from "viem";
|
|
2
|
-
import type
|
|
3
|
-
/**
|
|
4
|
-
* Checks if the current chain supports RIP-7212 (precompiled contract for secp256r1 curve operations).
|
|
5
|
-
* This is used to determine if the chain has native support for P256 signature verification,
|
|
6
|
-
* which is commonly used in WebAuthn/passkey implementations.
|
|
7
|
-
*
|
|
8
|
-
* @param {Client} client - The viem client to use for the check
|
|
9
|
-
* @returns {Promise<boolean>} True if the chain supports RIP-7212, false otherwise
|
|
10
|
-
*/
|
|
11
|
-
export declare const chainHas7212: (client: Client) => Promise<boolean>;
|
|
1
|
+
import { type Address, type Client, type Hex } from "viem";
|
|
2
|
+
import { type EntryPointVersion, type UserOperation } from "viem/account-abstraction";
|
|
12
3
|
export declare function packAccountGasLimits(data: Pick<UserOperation, "verificationGasLimit" | "callGasLimit"> | Pick<UserOperation, "maxPriorityFeePerGas" | "maxFeePerGas">): Hex;
|
|
13
4
|
export declare function packPaymasterData({ paymaster, paymasterVerificationGasLimit, paymasterPostOpGasLimit, paymasterData, }: Pick<UserOperation, "paymaster" | "paymasterVerificationGasLimit" | "paymasterPostOpGasLimit" | "paymasterData">): Hex;
|
|
14
5
|
export declare const bigIntMultiply: (base: number | bigint | Hex, multiplier: number, roundingMode?: "ROUND" | "FLOOR" | "CEIL") => bigint;
|
|
6
|
+
/**
|
|
7
|
+
* Derives the counterfactual smart account address from init code by calling
|
|
8
|
+
* the entry point's `getSenderAddress` function.
|
|
9
|
+
*
|
|
10
|
+
* @param {Client} client - The viem client to use for the call.
|
|
11
|
+
* @param {object} params - The parameters for deriving the sender address.
|
|
12
|
+
* @param {Hex} params.factory - The factory address for the account.
|
|
13
|
+
* @param {Hex} params.factoryData - The factory data for the account.
|
|
14
|
+
* @param {object} params.entryPoint - The entry point contract details.
|
|
15
|
+
* @param {EntryPointVersion} [params.entryPoint.version] - The entry point version.
|
|
16
|
+
* @param {Address} params.entryPoint.address - The entry point contract address.
|
|
17
|
+
* @returns {Promise<Address>} The counterfactual address of the smart account.
|
|
18
|
+
*/
|
|
19
|
+
export declare const getSenderFromFactoryData: (client: Client, params: {
|
|
20
|
+
factory: Hex;
|
|
21
|
+
factoryData: Hex;
|
|
22
|
+
entryPoint: {
|
|
23
|
+
version: EntryPointVersion;
|
|
24
|
+
address: Address;
|
|
25
|
+
};
|
|
26
|
+
}) => Promise<Address>;
|
|
27
|
+
export declare function is7702Delegated(delegation: Address, code: Hex | undefined): boolean;
|
package/dist/esm/utils.js
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { concatHex, RawContractError, BaseError as ViemBaseError, toHex, } from "viem";
|
|
2
|
+
import { decodeErrorResult, encodeFunctionData, getAction, getAddress, isHex, } from "viem/utils";
|
|
3
|
+
import { entryPoint07Abi, } from "viem/account-abstraction";
|
|
4
|
+
import { assertNever, BaseError } from "@alchemy/common";
|
|
2
5
|
import { call } from "viem/actions";
|
|
3
|
-
import { getAction } from "viem/utils";
|
|
4
|
-
import { BaseError } from "@alchemy/common";
|
|
5
|
-
const RIP_7212_CHECK_BYTECODE = "0x60806040526040517f532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25815260056020820152600160408201527f4a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e560608201527f3e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0608082015260208160a0836101005afa503d5f823e3d81f3fe";
|
|
6
|
-
/**
|
|
7
|
-
* Checks if the current chain supports RIP-7212 (precompiled contract for secp256r1 curve operations).
|
|
8
|
-
* This is used to determine if the chain has native support for P256 signature verification,
|
|
9
|
-
* which is commonly used in WebAuthn/passkey implementations.
|
|
10
|
-
*
|
|
11
|
-
* @param {Client} client - The viem client to use for the check
|
|
12
|
-
* @returns {Promise<boolean>} True if the chain supports RIP-7212, false otherwise
|
|
13
|
-
*/
|
|
14
|
-
export const chainHas7212 = async (client) => {
|
|
15
|
-
const callAction = getAction(client, call, "call");
|
|
16
|
-
const { data } = await callAction({
|
|
17
|
-
data: RIP_7212_CHECK_BYTECODE,
|
|
18
|
-
});
|
|
19
|
-
return data ? BigInt(data) === 1n : false;
|
|
20
|
-
};
|
|
21
6
|
export function packAccountGasLimits(data) {
|
|
22
|
-
return
|
|
7
|
+
return concatHex(Object.values(data).map((v) => toHex(v, { size: 16 })));
|
|
23
8
|
}
|
|
24
9
|
export function packPaymasterData({ paymaster, paymasterVerificationGasLimit, paymasterPostOpGasLimit, paymasterData, }) {
|
|
25
10
|
if (!paymaster ||
|
|
@@ -28,7 +13,7 @@ export function packPaymasterData({ paymaster, paymasterVerificationGasLimit, pa
|
|
|
28
13
|
!paymasterData) {
|
|
29
14
|
return "0x";
|
|
30
15
|
}
|
|
31
|
-
return
|
|
16
|
+
return concatHex([
|
|
32
17
|
paymaster,
|
|
33
18
|
toHex(paymasterVerificationGasLimit, { size: 16 }),
|
|
34
19
|
toHex(paymasterPostOpGasLimit, { size: 16 }),
|
|
@@ -57,4 +42,65 @@ export const bigIntMultiply = (base, multiplier, roundingMode = "CEIL") => {
|
|
|
57
42
|
return product >= 0n ? product / scale : (product - scale + 1n) / scale;
|
|
58
43
|
}
|
|
59
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Derives the counterfactual smart account address from init code by calling
|
|
47
|
+
* the entry point's `getSenderAddress` function.
|
|
48
|
+
*
|
|
49
|
+
* @param {Client} client - The viem client to use for the call.
|
|
50
|
+
* @param {object} params - The parameters for deriving the sender address.
|
|
51
|
+
* @param {Hex} params.factory - The factory address for the account.
|
|
52
|
+
* @param {Hex} params.factoryData - The factory data for the account.
|
|
53
|
+
* @param {object} params.entryPoint - The entry point contract details.
|
|
54
|
+
* @param {EntryPointVersion} [params.entryPoint.version] - The entry point version.
|
|
55
|
+
* @param {Address} params.entryPoint.address - The entry point contract address.
|
|
56
|
+
* @returns {Promise<Address>} The counterfactual address of the smart account.
|
|
57
|
+
*/
|
|
58
|
+
export const getSenderFromFactoryData = async (client, params) => {
|
|
59
|
+
const action = getAction(client, call, "call");
|
|
60
|
+
const data = encodeFunctionData({
|
|
61
|
+
abi: entryPoint07Abi, // getSenderAddress is the same for EP v0.6, EP v0.7, and v0.8
|
|
62
|
+
functionName: "getSenderAddress",
|
|
63
|
+
args: [concatHex([params.factory, params.factoryData])],
|
|
64
|
+
});
|
|
65
|
+
try {
|
|
66
|
+
// getSenderAddress is expected to revert with the computed sender
|
|
67
|
+
await action({ to: params.entryPoint.address, data });
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
const revertData = getRevertErrorData(err);
|
|
71
|
+
if (!isHex(revertData)) {
|
|
72
|
+
throw new BaseError("Failed to get sender address from init code: no revert data found.");
|
|
73
|
+
}
|
|
74
|
+
switch (params.entryPoint.version) {
|
|
75
|
+
case "0.9":
|
|
76
|
+
case "0.8":
|
|
77
|
+
case "0.7": {
|
|
78
|
+
const decoded = decodeErrorResult({
|
|
79
|
+
abi: entryPoint07Abi, // same error signature for EP v0.7 and v0.8
|
|
80
|
+
data: revertData,
|
|
81
|
+
});
|
|
82
|
+
if (decoded.errorName !== "SenderAddressResult") {
|
|
83
|
+
throw new BaseError(`Unexpected error from getSenderAddress: ${decoded.errorName}`);
|
|
84
|
+
}
|
|
85
|
+
return decoded.args[0];
|
|
86
|
+
}
|
|
87
|
+
case "0.6":
|
|
88
|
+
// EP v0.6: last 20 bytes is the address.
|
|
89
|
+
return getAddress(`0x${revertData.slice(-40)}`);
|
|
90
|
+
default:
|
|
91
|
+
return assertNever(params.entryPoint.version, "Unexpected entry point version");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
throw new BaseError("Expected getSenderAddress to revert.");
|
|
95
|
+
};
|
|
96
|
+
// Borrowed from Viem: https://github.com/wevm/viem/blob/3ff6c2f19350dcbe49017e2b3d5a2cf761ab9070/src/actions/public/call.ts#L473
|
|
97
|
+
function getRevertErrorData(err) {
|
|
98
|
+
if (!(err instanceof ViemBaseError))
|
|
99
|
+
return undefined;
|
|
100
|
+
const error = err.walk();
|
|
101
|
+
return typeof error?.data === "object" ? error.data?.data : error.data;
|
|
102
|
+
}
|
|
103
|
+
export function is7702Delegated(delegation, code) {
|
|
104
|
+
return (code?.toLowerCase() === concatHex(["0xef0100", delegation]).toLowerCase());
|
|
105
|
+
}
|
|
60
106
|
//# sourceMappingURL=utils.js.map
|
package/dist/esm/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EAET,gBAAgB,EAChB,SAAS,IAAI,aAAa,EAC1B,KAAK,GACN,MAAM,MAAM,CAAC;AACd,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,KAAK,GACN,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,eAAe,GAGhB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,WAAW,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AAO,OAAO,KAAK,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,UAAmB,EACnB,IAAqB;IAErB,OAAO,CACL,IAAI,EAAE,WAAW,EAAE,KAAK,SAAS,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,WAAW,EAAE,CAC1E,CAAC;AACJ,CAAC","sourcesContent":["import {\n type Address,\n type Client,\n concatHex,\n type Hex,\n RawContractError,\n BaseError as ViemBaseError,\n toHex,\n} from \"viem\";\nimport {\n decodeErrorResult,\n encodeFunctionData,\n getAction,\n getAddress,\n isHex,\n} from \"viem/utils\";\nimport {\n entryPoint07Abi,\n type EntryPointVersion,\n type UserOperation,\n} from \"viem/account-abstraction\";\nimport { assertNever, BaseError } from \"@alchemy/common\";\nimport { call } from \"viem/actions\";\n\nexport function packAccountGasLimits(\n data:\n | Pick<UserOperation, \"verificationGasLimit\" | \"callGasLimit\">\n | Pick<UserOperation, \"maxPriorityFeePerGas\" | \"maxFeePerGas\">,\n): Hex {\n return concatHex(Object.values(data).map((v) => toHex(v, { size: 16 })));\n}\n\nexport function packPaymasterData({\n paymaster,\n paymasterVerificationGasLimit,\n paymasterPostOpGasLimit,\n paymasterData,\n}: Pick<\n UserOperation,\n | \"paymaster\"\n | \"paymasterVerificationGasLimit\"\n | \"paymasterPostOpGasLimit\"\n | \"paymasterData\"\n>): Hex {\n if (\n !paymaster ||\n !paymasterVerificationGasLimit ||\n !paymasterPostOpGasLimit ||\n !paymasterData\n ) {\n return \"0x\";\n }\n return concatHex([\n paymaster,\n toHex(paymasterVerificationGasLimit, { size: 16 }),\n toHex(paymasterPostOpGasLimit, { size: 16 }),\n paymasterData,\n ]);\n}\n\nexport const bigIntMultiply = (\n base: number | bigint | Hex,\n multiplier: number,\n roundingMode: \"ROUND\" | \"FLOOR\" | \"CEIL\" = \"CEIL\",\n) => {\n if (Number.isInteger(multiplier)) {\n return BigInt(base) * BigInt(multiplier);\n }\n\n const multiplierStr = multiplier.toString();\n const decimalPlaces = multiplierStr.split(\".\")[1]?.length ?? 0;\n\n if (decimalPlaces > 4) {\n throw new BaseError(\"bigIntMultiply max precision is 4 decimal places.\");\n }\n\n const scale = BigInt(10 ** decimalPlaces);\n const scaledMultiplier = BigInt(multiplierStr.replace(\".\", \"\"));\n const product = BigInt(base) * scaledMultiplier;\n\n switch (roundingMode) {\n case \"ROUND\":\n return (product + scale / 2n) / scale;\n case \"CEIL\":\n return product >= 0n ? (product + scale - 1n) / scale : product / scale;\n case \"FLOOR\":\n default:\n return product >= 0n ? product / scale : (product - scale + 1n) / scale;\n }\n};\n\n/**\n * Derives the counterfactual smart account address from init code by calling\n * the entry point's `getSenderAddress` function.\n *\n * @param {Client} client - The viem client to use for the call.\n * @param {object} params - The parameters for deriving the sender address.\n * @param {Hex} params.factory - The factory address for the account.\n * @param {Hex} params.factoryData - The factory data for the account.\n * @param {object} params.entryPoint - The entry point contract details.\n * @param {EntryPointVersion} [params.entryPoint.version] - The entry point version.\n * @param {Address} params.entryPoint.address - The entry point contract address.\n * @returns {Promise<Address>} The counterfactual address of the smart account.\n */\nexport const getSenderFromFactoryData = async (\n client: Client,\n params: {\n factory: Hex;\n factoryData: Hex;\n entryPoint: {\n version: EntryPointVersion;\n address: Address;\n };\n },\n): Promise<Address> => {\n const action = getAction(client, call, \"call\");\n\n const data = encodeFunctionData({\n abi: entryPoint07Abi, // getSenderAddress is the same for EP v0.6, EP v0.7, and v0.8\n functionName: \"getSenderAddress\",\n args: [concatHex([params.factory, params.factoryData])],\n });\n\n try {\n // getSenderAddress is expected to revert with the computed sender\n await action({ to: params.entryPoint.address, data });\n } catch (err) {\n const revertData = getRevertErrorData(err);\n if (!isHex(revertData)) {\n throw new BaseError(\n \"Failed to get sender address from init code: no revert data found.\",\n );\n }\n\n switch (params.entryPoint.version) {\n case \"0.9\":\n case \"0.8\":\n case \"0.7\": {\n const decoded = decodeErrorResult({\n abi: entryPoint07Abi, // same error signature for EP v0.7 and v0.8\n data: revertData,\n });\n if (decoded.errorName !== \"SenderAddressResult\") {\n throw new BaseError(\n `Unexpected error from getSenderAddress: ${decoded.errorName}`,\n );\n }\n return decoded.args[0];\n }\n case \"0.6\":\n // EP v0.6: last 20 bytes is the address.\n return getAddress(`0x${revertData.slice(-40)}`);\n default:\n return assertNever(\n params.entryPoint.version,\n \"Unexpected entry point version\",\n );\n }\n }\n throw new BaseError(\"Expected getSenderAddress to revert.\");\n};\n\n// Borrowed from Viem: https://github.com/wevm/viem/blob/3ff6c2f19350dcbe49017e2b3d5a2cf761ab9070/src/actions/public/call.ts#L473\nfunction getRevertErrorData(err: unknown) {\n if (!(err instanceof ViemBaseError)) return undefined;\n const error = err.walk() as RawContractError;\n return typeof error?.data === \"object\" ? error.data?.data : error.data;\n}\n\nexport function is7702Delegated(\n delegation: Address,\n code: Hex | undefined,\n): boolean {\n return (\n code?.toLowerCase() === concatHex([\"0xef0100\", delegation]).toLowerCase()\n );\n}\n"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "
|
|
1
|
+
export declare const VERSION = "5.0.0-beta.1";
|
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,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,cAAc,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"5.0.0-beta.1\";\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export type * from "./types.js";
|
|
2
|
-
export { chainHas7212 } from "./utils.js";
|
|
3
2
|
export type * from "./light-account/accounts/account.js";
|
|
4
3
|
export { toLightAccount } from "./light-account/accounts/account.js";
|
|
5
4
|
export type * from "./light-account/accounts/multi-owner-account.js";
|
|
@@ -32,14 +31,13 @@ export type * from "./ma-v2/decorators/deferralActions.js";
|
|
|
32
31
|
export { deferralActions } from "./ma-v2/decorators/deferralActions.js";
|
|
33
32
|
export type * from "./ma-v2/decorators/installValidation.js";
|
|
34
33
|
export { installValidationActions } from "./ma-v2/decorators/installValidation.js";
|
|
35
|
-
export { semiModularAccountV2StaticImpl, semiModularAccount7702StaticImpl,
|
|
34
|
+
export { semiModularAccountV2StaticImpl, semiModularAccount7702StaticImpl, } from "./ma-v2/mav2StaticImpl.js";
|
|
36
35
|
export type * from "./ma-v2/mav2StaticImpl.js";
|
|
37
36
|
export { AllowlistModule } from "./ma-v2/modules/allowlist-module/module.js";
|
|
38
37
|
export { NativeTokenLimitModule } from "./ma-v2/modules/native-token-limit-module/module.js";
|
|
39
38
|
export { PaymasterGuardModule } from "./ma-v2/modules/paymaster-guard-module/module.js";
|
|
40
39
|
export { SingleSignerValidationModule } from "./ma-v2/modules/single-signer-validation/module.js";
|
|
41
40
|
export { TimeRangeModule } from "./ma-v2/modules/time-range-module/module.js";
|
|
42
|
-
export { WebAuthnValidationModule } from "./ma-v2/modules/webauthn-validation/module.js";
|
|
43
41
|
export type * from "./ma-v2/permissionBuilder.js";
|
|
44
42
|
export { PermissionBuilder, PermissionType, } from "./ma-v2/permissionBuilder.js";
|
|
45
43
|
export type * from "./ma-v2/predictAddress.js";
|
|
@@ -52,7 +50,7 @@ export { parseDeferredAction, buildDeferredActionDigest, } from "./ma-v2/utils/d
|
|
|
52
50
|
export type * from "./ma-v2/utils/hooks.js";
|
|
53
51
|
export { serializeValidationConfig, serializeHookConfig, } from "./ma-v2/utils/hooks.js";
|
|
54
52
|
export type * from "./ma-v2/utils/signature.js";
|
|
55
|
-
export { packUOSignature, pack1271Signature, toReplaySafeTypedData,
|
|
53
|
+
export { packUOSignature, pack1271Signature, toReplaySafeTypedData, } from "./ma-v2/utils/signature.js";
|
|
56
54
|
export { EntityIdOverrideError } from "./errors/EntityIdOverrideError.js";
|
|
57
55
|
export { InvalidDeferredActionNonceError } from "./errors/InvalidDeferredActionNonceError.js";
|
|
58
56
|
export { InvalidEntityIdError } from "./errors/InvalidEntityIdError.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAC;AAGhC,mBAAmB,qCAAqC,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAErE,mBAAmB,iDAAiD,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAC;AAM3F,mBAAmB,2CAA2C,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,2CAA2C,CAAC;AAE3F,mBAAmB,0CAA0C,CAAC;AAC9D,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AAEzF,mBAAmB,mCAAmC,CAAC;AACvD,OAAO,EACL,0BAA0B,EAC1B,oCAAoC,GACrC,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,mBAAmB,6BAA6B,CAAC;AACjD,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,oCAAoC,EACpC,gCAAgC,GACjC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,E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"Light
|
|
|
8
8
|
export type ToLightAccountParams<TLightAccountVersion extends LightAccountVersion<"LightAccount"> = LightAccountVersion<"LightAccount">> = {
|
|
9
9
|
client: Client<Transport, Chain, JsonRpcAccount | LocalAccount | undefined>;
|
|
10
10
|
owner: JsonRpcAccount | LocalAccount;
|
|
11
|
-
salt?: bigint;
|
|
12
11
|
accountAddress?: Address;
|
|
13
12
|
factory?: Address;
|
|
14
|
-
factoryData?: Hex;
|
|
15
13
|
version?: TLightAccountVersion;
|
|
16
|
-
}
|
|
14
|
+
} & ({
|
|
15
|
+
salt?: bigint;
|
|
16
|
+
factoryData?: never;
|
|
17
|
+
} | {
|
|
18
|
+
salt?: never;
|
|
19
|
+
factoryData?: Hex;
|
|
20
|
+
});
|
|
17
21
|
/**
|
|
18
22
|
* Creates a light account.
|
|
19
23
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../../src/light-account/accounts/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../../src/light-account/accounts/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,MAAM,CAAC;AAUd,OAAO,EACL,KAAK,mBAAmB,EAGzB,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAKtE,MAAM,MAAM,YAAY,CACtB,oBAAoB,SAClB,mBAAmB,CAAC,cAAc,CAAC,GAAG,mBAAmB,C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@@
|
|
|
1
|
-
{"version":3,"file":"calldataCodec.d.ts","sourceRoot":"","sources":["../../../../src/light-account/accounts/calldataCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"calldataCodec.d.ts","sourceRoot":"","sources":["../../../../src/light-account/accounts/calldataCodec.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;AAMd,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,GAAG,CAyBzD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,cAAc,EAAE,OAAO,GAAG,IAAI,EAAE,CAqDxE"}
|
|
@@ -9,11 +9,15 @@ export type ToMultiOwnerLightAccountParams = {
|
|
|
9
9
|
owners: [OneOf<JsonRpcAccount | LocalAccount>, ...{
|
|
10
10
|
address: Address;
|
|
11
11
|
}[]];
|
|
12
|
-
salt?: bigint;
|
|
13
12
|
accountAddress?: Address;
|
|
14
13
|
factory?: Address;
|
|
14
|
+
} & ({
|
|
15
|
+
salt?: bigint;
|
|
16
|
+
factoryData?: never;
|
|
17
|
+
} | {
|
|
18
|
+
salt?: never;
|
|
15
19
|
factoryData?: Hex;
|
|
16
|
-
};
|
|
20
|
+
});
|
|
17
21
|
/**
|
|
18
22
|
* Creates a multi-owner light account.
|
|
19
23
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-owner-account.d.ts","sourceRoot":"","sources":["../../../../src/light-account/accounts/multi-owner-account.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,SAAS,EACf,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"multi-owner-account.d.ts","sourceRoot":"","sources":["../../../../src/light-account/accounts/multi-owner-account.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,SAAS,EACf,MAAM,MAAM,CAAC;AAQd,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAKtE,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CACnD,wBAAwB,EACxB,QAAQ,CACT,GAAG;IACF,kBAAkB,EAAE,CAClB,WAAW,EAAE,OAAO,EAAE,EACtB,cAAc,EAAE,OAAO,EAAE,KACtB,GAAG,CAAC;IACT,iBAAiB,EAAE,MAAM,OAAO,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,cAAc,GAAG,YAAY,GAAG,SAAS,CAAC,CAAC;IAC5E,MAAM,EAAE,CAAC,KAAK,CAAC,cAAc,GAAG,YAAY,CAAC,EAAE,GAAG;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC,CAAC;IAC1E,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GAAG,CACA;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,KAAK,CAAA;CAAE,GACtC;IAAE,IAAI,CAAC,EAAE,KAAK,CAAC;IAAC,WAAW,CAAC,EAAE,GAAG,CAAA;CAAE,CACtC,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAAC,EAC7C,MAAM,EACN,IAAS,EACT,MAAM,EACN,cAAc,EAAE,eAAe,EAC/B,OACiB,EACjB,WAAW,EAAE,YAAY,GAC1B,EAAE,8BAA8B,GAAG,OAAO,CAAC,sBAAsB,CAAC,CA+FlE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Address } from "viem";
|
|
2
|
-
import { entryPoint06Abi, entryPoint07Abi } from "viem/account-abstraction";
|
|
2
|
+
import { entryPoint06Abi, entryPoint07Abi, entryPoint08Abi, entryPoint09Abi } from "viem/account-abstraction";
|
|
3
3
|
import { LightAccountAbi_v1 } from "./abis/LightAccountAbi_v1.js";
|
|
4
4
|
import { LightAccountFactoryAbi_v1 } from "./abis/LightAccountFactoryAbi_v1.js";
|
|
5
5
|
import type { StaticSmartAccountImplementation } from "../types.js";
|
|
@@ -21,5 +21,7 @@ export type MultiOwnerLightAccountFactoryArgs = {
|
|
|
21
21
|
salt: bigint;
|
|
22
22
|
};
|
|
23
23
|
export declare const multiOwnerLightAccountStaticImplV2_0_0: StaticSmartAccountImplementation<false, "0.7", MultiOwnerLightAccountFactoryArgs, typeof entryPoint07Abi, typeof MultiOwnerLightAccountAbi, typeof MultiOwnerLightAccountFactoryAbi>;
|
|
24
|
+
export declare const lightAccountStaticImplV2_1_0: StaticSmartAccountImplementation<false, "0.8", LightAccountFactoryArgs, typeof entryPoint08Abi, typeof LightAccountAbi_v2, typeof LightAccountFactoryAbi_v2>;
|
|
25
|
+
export declare const lightAccountStaticImplV2_2_0: StaticSmartAccountImplementation<false, "0.9", LightAccountFactoryArgs, typeof entryPoint09Abi, typeof LightAccountAbi_v2, typeof LightAccountFactoryAbi_v2>;
|
|
24
26
|
export {};
|
|
25
27
|
//# sourceMappingURL=lightAccountStaticImpl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lightAccountStaticImpl.d.ts","sourceRoot":"","sources":["../../../src/light-account/lightAccountStaticImpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AACxD,OAAO,EACL,eAAe,EACf,eAAe,
|
|
1
|
+
{"version":3,"file":"lightAccountStaticImpl.d.ts","sourceRoot":"","sources":["../../../src/light-account/lightAccountStaticImpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AACxD,OAAO,EACL,eAAe,EACf,eAAe,EAGf,eAAe,EAEf,eAAe,EAEhB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,aAAa,CAAC;AAKpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,gCAAgC,EAAE,MAAM,4CAA4C,CAAC;AAG9F,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAGF,KAAK,wBAAwB,GAAG,gCAAgC,CAC9D,KAAK,EACL,KAAK,EACL,uBAAuB,EACvB,OAAO,eAAe,EACtB,OAAO,kBAAkB,EACzB,OAAO,yBAAyB,CACjC,CAAC;AAmBF,eAAO,MAAM,4BAA4B,EAAE,wBAa1C,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,wBAa1C,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,wBAa1C,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,gCAAgC,CACzE,KAAK,EACL,KAAK,EACL,uBAAuB,EACvB,OAAO,eAAe,EACtB,OAAO,kBAAkB,EACzB,OAAO,yBAAyB,CA2BjC,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,sCAAsC,EAAE,gCAAgC,CACnF,KAAK,EACL,KAAK,EACL,iCAAiC,EACjC,OAAO,eAAe,EACtB,OAAO,yBAAyB,EAChC,OAAO,gCAAgC,CA0BxC,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,gCAAgC,CACzE,KAAK,EACL,KAAK,EACL,uBAAuB,EACvB,OAAO,eAAe,EACtB,OAAO,kBAAkB,EACzB,OAAO,yBAAyB,CA2BjC,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,gCAAgC,CACzE,KAAK,EACL,KAAK,EACL,uBAAuB,EACvB,OAAO,eAAe,EACtB,OAAO,kBAAkB,EACzB,OAAO,yBAAyB,CA2BjC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type Address } from "viem";
|
|
2
|
-
import {
|
|
1
|
+
import { type Address, type Client, type Hex } from "viem";
|
|
2
|
+
import type { EntryPointVersion } from "viem/account-abstraction";
|
|
3
|
+
import { AccountVersionRegistry, type LightAccountVersion } from "./registry.js";
|
|
3
4
|
export type PredictLightAccountAddressParams = {
|
|
4
5
|
version: keyof typeof AccountVersionRegistry.LightAccount;
|
|
5
6
|
salt: bigint;
|
|
@@ -33,4 +34,41 @@ export type PredictMultiOwnerLightAccountAddressParams = {
|
|
|
33
34
|
* @returns {Address} Predicted account address for the multi-owner light account.
|
|
34
35
|
*/
|
|
35
36
|
export declare function predictMultiOwnerLightAccountAddress({ salt, ownerAddresses, factoryAddress, }: PredictMultiOwnerLightAccountAddressParams): Address;
|
|
37
|
+
export type GetLightAccountAddressFromFactoryDataParams = {
|
|
38
|
+
client: Client;
|
|
39
|
+
factoryAddress: Address;
|
|
40
|
+
factoryData: Hex;
|
|
41
|
+
entryPoint: {
|
|
42
|
+
version: EntryPointVersion;
|
|
43
|
+
address: Address;
|
|
44
|
+
};
|
|
45
|
+
version: LightAccountVersion<"LightAccount">;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Gets the light account address from factory data.
|
|
49
|
+
* If the factory is a known default, decodes the args and predicts without RPC.
|
|
50
|
+
* Otherwise falls back to calling the entry point's getSenderAddress.
|
|
51
|
+
*
|
|
52
|
+
* @param {GetLightAccountAddressFromFactoryDataParams} params - The parameters
|
|
53
|
+
* @returns {Promise<Address>} The account address
|
|
54
|
+
*/
|
|
55
|
+
export declare function getLightAccountAddressFromFactoryData({ client, factoryAddress, factoryData, entryPoint, version, }: GetLightAccountAddressFromFactoryDataParams): Promise<Address>;
|
|
56
|
+
export type GetMultiOwnerLightAccountAddressFromFactoryDataParams = {
|
|
57
|
+
client: Client;
|
|
58
|
+
factoryAddress: Address;
|
|
59
|
+
factoryData: Hex;
|
|
60
|
+
entryPoint: {
|
|
61
|
+
version: EntryPointVersion;
|
|
62
|
+
address: Address;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Gets the multi-owner light account address from factory data.
|
|
67
|
+
* If the factory is a known default, decodes the args and predicts without RPC.
|
|
68
|
+
* Otherwise falls back to calling the entry point's getSenderAddress.
|
|
69
|
+
*
|
|
70
|
+
* @param {GetMultiOwnerLightAccountAddressFromFactoryDataParams} params - The parameters
|
|
71
|
+
* @returns {Promise<Address>} The account address
|
|
72
|
+
*/
|
|
73
|
+
export declare function getMultiOwnerLightAccountAddressFromFactoryData({ client, factoryAddress, factoryData, entryPoint, }: GetMultiOwnerLightAccountAddressFromFactoryDataParams): Promise<Address>;
|
|
36
74
|
//# sourceMappingURL=predictAddress.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predictAddress.d.ts","sourceRoot":"","sources":["../../../src/light-account/predictAddress.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"predictAddress.d.ts","sourceRoot":"","sources":["../../../src/light-account/predictAddress.ts"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