@account-kit/smart-contracts 4.25.0 → 4.25.1

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.
Files changed (31) hide show
  1. package/dist/esm/src/ma-v2/actions/deferralActions.d.ts +0 -5
  2. package/dist/esm/src/ma-v2/actions/deferralActions.js +0 -20
  3. package/dist/esm/src/ma-v2/actions/deferralActions.js.map +1 -1
  4. package/dist/esm/src/ma-v2/index.d.ts +2 -1
  5. package/dist/esm/src/ma-v2/index.js +2 -1
  6. package/dist/esm/src/ma-v2/index.js.map +1 -1
  7. package/dist/esm/src/ma-v2/permissionBuilder.d.ts +1 -0
  8. package/dist/esm/src/ma-v2/permissionBuilder.js +27 -20
  9. package/dist/esm/src/ma-v2/permissionBuilder.js.map +1 -1
  10. package/dist/esm/src/ma-v2/permissionBuilderErrors.d.ts +99 -0
  11. package/dist/esm/src/ma-v2/permissionBuilderErrors.js +176 -0
  12. package/dist/esm/src/ma-v2/permissionBuilderErrors.js.map +1 -0
  13. package/dist/esm/src/ma-v2/utils.d.ts +15 -0
  14. package/dist/esm/src/ma-v2/utils.js +20 -1
  15. package/dist/esm/src/ma-v2/utils.js.map +1 -1
  16. package/dist/types/src/ma-v2/actions/deferralActions.d.ts +0 -5
  17. package/dist/types/src/ma-v2/actions/deferralActions.d.ts.map +1 -1
  18. package/dist/types/src/ma-v2/index.d.ts +2 -1
  19. package/dist/types/src/ma-v2/index.d.ts.map +1 -1
  20. package/dist/types/src/ma-v2/permissionBuilder.d.ts +1 -0
  21. package/dist/types/src/ma-v2/permissionBuilder.d.ts.map +1 -1
  22. package/dist/types/src/ma-v2/permissionBuilderErrors.d.ts +100 -0
  23. package/dist/types/src/ma-v2/permissionBuilderErrors.d.ts.map +1 -0
  24. package/dist/types/src/ma-v2/utils.d.ts +15 -0
  25. package/dist/types/src/ma-v2/utils.d.ts.map +1 -1
  26. package/package.json +5 -5
  27. package/src/ma-v2/actions/deferralActions.ts +0 -31
  28. package/src/ma-v2/index.ts +2 -1
  29. package/src/ma-v2/permissionBuilder.ts +41 -53
  30. package/src/ma-v2/permissionBuilderErrors.ts +153 -0
  31. package/src/ma-v2/utils.ts +30 -0
@@ -37,10 +37,6 @@ export type CreateDeferredActionTypedDataParams = {
37
37
  deadline: number;
38
38
  nonce: bigint;
39
39
  };
40
- export type BuildDeferredActionDigestParams = {
41
- fullPreSignatureDeferredActionDigest: Hex;
42
- sig: Hex;
43
- };
44
40
  export type BuildPreSignatureDeferredActionDigestParams = {
45
41
  typedData: DeferredActionTypedData;
46
42
  };
@@ -57,7 +53,6 @@ export type EntityIdAndNonceParams = {
57
53
  };
58
54
  export type DeferralActions = {
59
55
  createDeferredActionTypedDataObject: (args: CreateDeferredActionTypedDataParams) => Promise<DeferredActionReturnData>;
60
- buildDeferredActionDigest: (args: BuildDeferredActionDigestParams) => Hex;
61
56
  buildPreSignatureDeferredActionDigest: (args: BuildPreSignatureDeferredActionDigestParams) => Hex;
62
57
  buildUserOperationWithDeferredAction: (args: BuildUserOperationWithDeferredActionParams) => Promise<UserOperationRequest_v7>;
63
58
  getEntityIdAndNonce: (args: EntityIdAndNonceParams) => Promise<{
@@ -39,25 +39,6 @@ export const deferralActions = (client) => {
39
39
  },
40
40
  };
41
41
  };
42
- /**
43
- * Creates the digest which must be prepended to the userOp signature.
44
- *
45
- * Assumption: The client this extends is used to sign the typed data.
46
- *
47
- * @param {object} args The argument object containing the following:
48
- * @param {Hex} args.fullPreSignatureDeferredActionDigest The The data to append the signature and length to
49
- * @param {Hex} args.sig The signature to include in the digest
50
- * @returns {Hex} The encoded digest to be prepended to the userOp signature
51
- */
52
- const buildDeferredActionDigest = ({ fullPreSignatureDeferredActionDigest, sig, }) => {
53
- const sigLength = size(sig);
54
- const encodedData = concatHex([
55
- fullPreSignatureDeferredActionDigest,
56
- toHex(sigLength, { size: 4 }),
57
- sig,
58
- ]);
59
- return encodedData;
60
- };
61
42
  const buildPreSignatureDeferredActionDigest = ({ typedData, }) => {
62
43
  const signerEntity = client.account.signerEntity;
63
44
  const validationLocator = (BigInt(signerEntity.entityId) << 8n) |
@@ -138,7 +119,6 @@ export const deferralActions = (client) => {
138
119
  };
139
120
  return {
140
121
  createDeferredActionTypedDataObject,
141
- buildDeferredActionDigest,
142
122
  buildPreSignatureDeferredActionDigest,
143
123
  buildUserOperationWithDeferredAction,
144
124
  getEntityIdAndNonce,
@@ -1 +1 @@
1
- {"version":3,"file":"deferralActions.js","sourceRoot":"","sources":["../../../../../src/ma-v2/actions/deferralActions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,GAIxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,SAAS,EACT,UAAU,EACV,YAAY,EACZ,IAAI,EACJ,KAAK,EACL,gBAAgB,EAChB,WAAW,GACZ,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAuE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAEL,CAAC,MAA8B,EAAmB,EAAE;IACzE,MAAM,mCAAmC,GAAG,KAAK,EAAE,EACjD,QAAQ,EACR,QAAQ,EACR,KAAK,GAC+B,EAAqC,EAAE;QAC3E,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,oBAAoB,EAAE,CAAC;QACnC,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QAClD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,uBAAuB,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC3D,CAAC;QAED,OAAO;YACL,SAAS,EAAE;gBACT,MAAM,EAAE;oBACN,OAAO,EAAE,MAAM,MAAM,CAAC,UAAU,EAAE;o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J,CAAC,CAAC","sourcesContent":["import {\n AccountNotFoundError,\n InvalidNonceKeyError,\n EntryPointNotFoundError,\n type UserOperationCallData,\n type BatchUserOperationCallData,\n type UserOperationRequest_v7,\n} from \"@aa-sdk/core\";\nimport {\n type Address,\n type Hex,\n concatHex,\n maxUint152,\n encodePacked,\n size,\n toHex,\n encodeDeployData,\n hexToNumber,\n} from \"viem\";\nimport { entityIdAndNonceReaderBytecode, buildFullNonceKey } from \"../utils.js\";\nimport { entityIdAndNonceReaderAbi } from \"../abis/entityIdAndNonceReader.js\";\nimport type { ModularAccountV2Client } from \"../client/client.js\";\n\nexport type DeferredActionTypedData = {\n domain: {\n chainId: number;\n verifyingContract: Address;\n };\n types: {\n DeferredAction: [\n { name: \"nonce\"; type: \"uint256\" },\n { name: \"deadline\"; type: \"uint48\" },\n { name: \"call\"; type: \"bytes\" }\n ];\n };\n primaryType: \"DeferredAction\";\n message: {\n nonce: bigint;\n deadline: number;\n call: Hex;\n };\n};\n\nexport type DeferredActionReturnData = {\n typedData: DeferredActionTypedData;\n};\n\nexport type CreateDeferredActionTypedDataParams = {\n callData: Hex;\n deadline: number;\n nonce: bigint;\n};\n\nexport type BuildDeferredActionDigestParams = {\n fullPreSignatureDeferredActionDigest: Hex;\n sig: Hex;\n};\n\nexport type BuildPreSignatureDeferredActionDigestParams = {\n typedData: DeferredActionTypedData;\n};\n\nexport type BuildUserOperationWithDeferredActionParams = {\n uo: UserOperationCallData | BatchUserOperationCallData;\n signaturePrepend: Hex;\n nonceOverride: bigint;\n};\n\nexport type EntityIdAndNonceParams = {\n entityId?: number;\n nonceKey?: bigint;\n isGlobalValidation: boolean;\n isDeferredAction?: boolean;\n};\n\nexport type DeferralActions = {\n createDeferredActionTypedDataObject: (\n args: CreateDeferredActionTypedDataParams\n ) => Promise<DeferredActionReturnData>;\n buildDeferredActionDigest: (args: BuildDeferredActionDigestParams) => Hex;\n buildPreSignatureDeferredActionDigest: (\n args: BuildPreSignatureDeferredActionDigestParams\n ) => Hex;\n buildUserOperationWithDeferredAction: (\n args: BuildUserOperationWithDeferredActionParams\n ) => Promise<UserOperationRequest_v7>;\n getEntityIdAndNonce: (\n args: EntityIdAndNonceParams\n ) => Promise<{ nonce: bigint; entityId: number }>;\n};\n\n/**\n * Provides deferred action functionalities for a MA v2 client, ensuring compatibility with `SmartAccountClient`.\n *\n * @param {ModularAccountV2Client} client - The client instance which provides account and sendUserOperation functionality.\n * @returns {object} - An object containing three methods: `createDeferredActionTypedDataObject`, `buildDeferredActionDigest`, and `buildUserOperationWithDeferredAction`.\n */\nexport const deferralActions: (\n client: ModularAccountV2Client\n) => DeferralActions = (client: ModularAccountV2Client): DeferralActions => {\n const createDeferredActionTypedDataObject = async ({\n callData,\n deadline,\n nonce,\n }: CreateDeferredActionTypedDataParams): Promise<DeferredActionReturnData> => {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n\n const entryPoint = client.account.getEntryPoint();\n if (entryPoint === undefined) {\n throw new EntryPointNotFoundError(client.chain, \"0.7.0\");\n }\n\n return {\n typedData: {\n domain: {\n chainId: await client.getChainId(),\n verifyingContract: client.account.address,\n },\n types: {\n DeferredAction: [\n { name: \"nonce\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint48\" },\n { name: \"call\", type: \"bytes\" },\n ],\n },\n primaryType: \"DeferredAction\",\n message: {\n nonce: nonce,\n deadline: deadline,\n call: callData,\n },\n },\n };\n };\n\n /**\n * Creates the digest which must be prepended to the userOp signature.\n *\n * Assumption: The client this extends is used to sign the typed data.\n *\n * @param {object} args The argument object containing the following:\n * @param {Hex} args.fullPreSignatureDeferredActionDigest The The data to append the signature and length to\n * @param {Hex} args.sig The signature to include in the digest\n * @returns {Hex} The encoded digest to be prepended to the userOp signature\n */\n const buildDeferredActionDigest = ({\n fullPreSignatureDeferredActionDigest,\n sig,\n }: BuildDeferredActionDigestParams): Hex => {\n const sigLength = size(sig);\n\n const encodedData = concatHex([\n fullPreSignatureDeferredActionDigest,\n toHex(sigLength, { size: 4 }),\n sig,\n ]);\n return encodedData;\n };\n\n const buildPreSignatureDeferredActionDigest = ({\n typedData,\n }: BuildPreSignatureDeferredActionDigestParams): Hex => {\n const signerEntity = client.account.signerEntity;\n const validationLocator =\n (BigInt(signerEntity.entityId) << 8n) |\n (signerEntity.isGlobalValidation ? 1n : 0n);\n\n const encodedCallData = encodePacked(\n [\"uint168\", \"uint48\", \"bytes\"],\n [validationLocator, typedData.message.deadline, typedData.message.call]\n );\n\n const encodedDataLength = size(encodedCallData);\n const encodedData = concatHex([\n toHex(encodedDataLength, { size: 4 }),\n encodedCallData,\n ]);\n return encodedData;\n };\n\n /**\n * Builds a user operation with a deferred action by wrapping buildUserOperation() with a dummy signature override.\n *\n * @param {object} args The argument object containing the following:\n * @param {UserOperationCallData | BatchUserOperationCallData} args.uo The user operation call data to build\n * @param {Hex} args.signaturePrepend The signature data to prepend to the dummy signature\n * @param {bigint} args.nonceOverride The nonce to override in the user operation, generally given from the typed data builder\n * @returns {Promise<UserOperationRequest_v7>} The unsigned user operation request with the deferred action\n */\n const buildUserOperationWithDeferredAction = async ({\n uo,\n signaturePrepend,\n nonceOverride,\n }: BuildUserOperationWithDeferredActionParams): Promise<UserOperationRequest_v7> => {\n // Check if client.account is defined\n if (client.account === undefined) {\n throw new AccountNotFoundError();\n }\n\n // Pre-fetch the dummy sig so we can override `client.account.getDummySignature()`\n const dummySig = await client.account.getDummySignature();\n\n // Cache the previous dummy signature getter\n const previousDummySigGetter = client.account.getDummySignature;\n\n // Override client.account.getDummySignature() so `client.buildUserOperation()` uses the prepended hex and the dummy signature during gas estimation\n client.account.getDummySignature = () => {\n return concatHex([signaturePrepend, dummySig as Hex]);\n };\n\n const unsignedUo = (await client.buildUserOperation({\n uo: uo,\n overrides: {\n nonce: nonceOverride,\n },\n })) as UserOperationRequest_v7;\n\n // Restore the dummy signature getter\n client.account.getDummySignature = previousDummySigGetter;\n\n return unsignedUo;\n };\n\n const getEntityIdAndNonce = async ({\n entityId = 1,\n nonceKey = 0n,\n isGlobalValidation,\n isDeferredAction = true,\n }: EntityIdAndNonceParams) => {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n\n if (nonceKey > maxUint152) {\n throw new InvalidNonceKeyError(nonceKey);\n }\n\n const entryPoint = client.account.getEntryPoint();\n if (entryPoint === undefined) {\n throw new EntryPointNotFoundError(client.chain, \"0.7.0\");\n }\n\n const bytecode = encodeDeployData({\n abi: entityIdAndNonceReaderAbi,\n bytecode: entityIdAndNonceReaderBytecode,\n args: [\n client.account.address,\n entryPoint.address,\n buildFullNonceKey({\n nonceKey,\n entityId,\n isGlobalValidation,\n isDeferredAction,\n }),\n ],\n });\n\n const { data } = await client.call({ data: bytecode });\n if (!data) {\n throw new Error(\"No data returned from contract call\");\n }\n\n return {\n nonce: BigInt(data),\n entityId: hexToNumber(`0x${data.slice(40, 48)}`),\n };\n };\n\n return {\n createDeferredActionTypedDataObject,\n buildDeferredActionDigest,\n buildPreSignatureDeferredActionDigest,\n buildUserOperationWithDeferredAction,\n getEntityIdAndNonce,\n };\n};\n"]}
1
+ {"version":3,"file":"deferralActions.js","sourceRoot":"","sources":["../../../../../src/ma-v2/actions/deferralActions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,GAIxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,SAAS,EACT,UAAU,EACV,YAAY,EACZ,IAAI,EACJ,KAAK,EACL,gBAAgB,EAChB,WAAW,GACZ,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAiE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAEL,CAAC,MAA8B,EAAmB,EAAE;IACzE,MAAM,mCAAmC,GAAG,KAAK,EAAE,EACjD,QAAQ,EACR,QAAQ,EACR,KAAK,GAC+B,EAAq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ACrC,oCAAoC;QACpC,mBAAmB;KACpB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n AccountNotFoundError,\n InvalidNonceKeyError,\n EntryPointNotFoundError,\n type UserOperationCallData,\n type BatchUserOperationCallData,\n type UserOperationRequest_v7,\n} from \"@aa-sdk/core\";\nimport {\n type Address,\n type Hex,\n concatHex,\n maxUint152,\n encodePacked,\n size,\n toHex,\n encodeDeployData,\n hexToNumber,\n} from \"viem\";\nimport { entityIdAndNonceReaderBytecode, buildFullNonceKey } from \"../utils.js\";\nimport { entityIdAndNonceReaderAbi } from \"../abis/entityIdAndNonceReader.js\";\nimport type { ModularAccountV2Client } from \"../client/client.js\";\n\nexport type DeferredActionTypedData = {\n domain: {\n chainId: number;\n verifyingContract: Address;\n };\n types: {\n DeferredAction: [\n { name: \"nonce\"; type: \"uint256\" },\n { name: \"deadline\"; type: \"uint48\" },\n { name: \"call\"; type: \"bytes\" }\n ];\n };\n primaryType: \"DeferredAction\";\n message: {\n nonce: bigint;\n deadline: number;\n call: Hex;\n };\n};\n\nexport type DeferredActionReturnData = {\n typedData: DeferredActionTypedData;\n};\n\nexport type CreateDeferredActionTypedDataParams = {\n callData: Hex;\n deadline: number;\n nonce: bigint;\n};\n\nexport type BuildPreSignatureDeferredActionDigestParams = {\n typedData: DeferredActionTypedData;\n};\n\nexport type BuildUserOperationWithDeferredActionParams = {\n uo: UserOperationCallData | BatchUserOperationCallData;\n signaturePrepend: Hex;\n nonceOverride: bigint;\n};\n\nexport type EntityIdAndNonceParams = {\n entityId?: number;\n nonceKey?: bigint;\n isGlobalValidation: boolean;\n isDeferredAction?: boolean;\n};\n\nexport type DeferralActions = {\n createDeferredActionTypedDataObject: (\n args: CreateDeferredActionTypedDataParams\n ) => Promise<DeferredActionReturnData>;\n buildPreSignatureDeferredActionDigest: (\n args: BuildPreSignatureDeferredActionDigestParams\n ) => Hex;\n buildUserOperationWithDeferredAction: (\n args: BuildUserOperationWithDeferredActionParams\n ) => Promise<UserOperationRequest_v7>;\n getEntityIdAndNonce: (\n args: EntityIdAndNonceParams\n ) => Promise<{ nonce: bigint; entityId: number }>;\n};\n\n/**\n * Provides deferred action functionalities for a MA v2 client, ensuring compatibility with `SmartAccountClient`.\n *\n * @param {ModularAccountV2Client} client - The client instance which provides account and sendUserOperation functionality.\n * @returns {object} - An object containing three methods: `createDeferredActionTypedDataObject`, `buildDeferredActionDigest`, and `buildUserOperationWithDeferredAction`.\n */\nexport const deferralActions: (\n client: ModularAccountV2Client\n) => DeferralActions = (client: ModularAccountV2Client): DeferralActions => {\n const createDeferredActionTypedDataObject = async ({\n callData,\n deadline,\n nonce,\n }: CreateDeferredActionTypedDataParams): Promise<DeferredActionReturnData> => {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n\n const entryPoint = client.account.getEntryPoint();\n if (entryPoint === undefined) {\n throw new EntryPointNotFoundError(client.chain, \"0.7.0\");\n }\n\n return {\n typedData: {\n domain: {\n chainId: await client.getChainId(),\n verifyingContract: client.account.address,\n },\n types: {\n DeferredAction: [\n { name: \"nonce\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint48\" },\n { name: \"call\", type: \"bytes\" },\n ],\n },\n primaryType: \"DeferredAction\",\n message: {\n nonce: nonce,\n deadline: deadline,\n call: callData,\n },\n },\n };\n };\n\n const buildPreSignatureDeferredActionDigest = ({\n typedData,\n }: BuildPreSignatureDeferredActionDigestParams): Hex => {\n const signerEntity = client.account.signerEntity;\n const validationLocator =\n (BigInt(signerEntity.entityId) << 8n) |\n (signerEntity.isGlobalValidation ? 1n : 0n);\n\n const encodedCallData = encodePacked(\n [\"uint168\", \"uint48\", \"bytes\"],\n [validationLocator, typedData.message.deadline, typedData.message.call]\n );\n\n const encodedDataLength = size(encodedCallData);\n const encodedData = concatHex([\n toHex(encodedDataLength, { size: 4 }),\n encodedCallData,\n ]);\n return encodedData;\n };\n\n /**\n * Builds a user operation with a deferred action by wrapping buildUserOperation() with a dummy signature override.\n *\n * @param {object} args The argument object containing the following:\n * @param {UserOperationCallData | BatchUserOperationCallData} args.uo The user operation call data to build\n * @param {Hex} args.signaturePrepend The signature data to prepend to the dummy signature\n * @param {bigint} args.nonceOverride The nonce to override in the user operation, generally given from the typed data builder\n * @returns {Promise<UserOperationRequest_v7>} The unsigned user operation request with the deferred action\n */\n const buildUserOperationWithDeferredAction = async ({\n uo,\n signaturePrepend,\n nonceOverride,\n }: BuildUserOperationWithDeferredActionParams): Promise<UserOperationRequest_v7> => {\n // Check if client.account is defined\n if (client.account === undefined) {\n throw new AccountNotFoundError();\n }\n\n // Pre-fetch the dummy sig so we can override `client.account.getDummySignature()`\n const dummySig = await client.account.getDummySignature();\n\n // Cache the previous dummy signature getter\n const previousDummySigGetter = client.account.getDummySignature;\n\n // Override client.account.getDummySignature() so `client.buildUserOperation()` uses the prepended hex and the dummy signature during gas estimation\n client.account.getDummySignature = () => {\n return concatHex([signaturePrepend, dummySig as Hex]);\n };\n\n const unsignedUo = (await client.buildUserOperation({\n uo: uo,\n overrides: {\n nonce: nonceOverride,\n },\n })) as UserOperationRequest_v7;\n\n // Restore the dummy signature getter\n client.account.getDummySignature = previousDummySigGetter;\n\n return unsignedUo;\n };\n\n const getEntityIdAndNonce = async ({\n entityId = 1,\n nonceKey = 0n,\n isGlobalValidation,\n isDeferredAction = true,\n }: EntityIdAndNonceParams) => {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n\n if (nonceKey > maxUint152) {\n throw new InvalidNonceKeyError(nonceKey);\n }\n\n const entryPoint = client.account.getEntryPoint();\n if (entryPoint === undefined) {\n throw new EntryPointNotFoundError(client.chain, \"0.7.0\");\n }\n\n const bytecode = encodeDeployData({\n abi: entityIdAndNonceReaderAbi,\n bytecode: entityIdAndNonceReaderBytecode,\n args: [\n client.account.address,\n entryPoint.address,\n buildFullNonceKey({\n nonceKey,\n entityId,\n isGlobalValidation,\n isDeferredAction,\n }),\n ],\n });\n\n const { data } = await client.call({ data: bytecode });\n if (!data) {\n throw new Error(\"No data returned from contract call\");\n }\n\n return {\n nonce: BigInt(data),\n entityId: hexToNumber(`0x${data.slice(40, 48)}`),\n };\n };\n\n return {\n createDeferredActionTypedDataObject,\n buildPreSignatureDeferredActionDigest,\n buildUserOperationWithDeferredAction,\n getEntityIdAndNonce,\n };\n};\n"]}
@@ -12,8 +12,9 @@ export type * from "./actions/deferralActions.js";
12
12
  export { deferralActions } from "./actions/deferralActions.js";
13
13
  export type * from "./permissionBuilder.js";
14
14
  export { PermissionBuilder, PermissionType } from "./permissionBuilder.js";
15
+ export * from "./permissionBuilderErrors.js";
15
16
  export { getDefaultAllowlistModuleAddress, getDefaultNativeTokenLimitModuleAddress, getDefaultPaymasterGuardModuleAddress, getDefaultSingleSignerValidationModuleAddress, getDefaultTimeRangeModuleAddress, getDefaultWebauthnValidationModuleAddress, } from "./modules/utils.js";
16
- export { buildFullNonceKey } from "./utils.js";
17
+ export { buildFullNonceKey, buildDeferredActionDigest } from "./utils.js";
17
18
  export { allowlistModuleAbi } from "./modules/allowlist-module/abis/allowlistModuleAbi.js";
18
19
  export { AllowlistModule } from "./modules/allowlist-module/module.js";
19
20
  export { nativeTokenLimitModuleAbi } from "./modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.js";
@@ -9,8 +9,9 @@ export { serializeValidationConfig, serializeHookConfig, serializeModuleEntity,
9
9
  export { installValidationActions } from "./actions/install-validation/installValidation.js";
10
10
  export { deferralActions } from "./actions/deferralActions.js";
11
11
  export { PermissionBuilder, PermissionType } from "./permissionBuilder.js";
12
+ export * from "./permissionBuilderErrors.js";
12
13
  export { getDefaultAllowlistModuleAddress, getDefaultNativeTokenLimitModuleAddress, getDefaultPaymasterGuardModuleAddress, getDefaultSingleSignerValidationModuleAddress, getDefaultTimeRangeModuleAddress, getDefaultWebauthnValidationModuleAddress, } from "./modules/utils.js";
13
- export { buildFullNonceKey } from "./utils.js";
14
+ export { buildFullNonceKey, buildDeferredActionDigest } from "./utils.js";
14
15
  export { allowlistModuleAbi } from "./modules/allowlist-module/abis/allowlistModuleAbi.js";
15
16
  export { AllowlistModule } from "./modules/allowlist-module/module.js";
16
17
  export { nativeTokenLimitModuleAbi } from "./modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ma-v2/index.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AAEtF,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAQ/D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,mDAAmD,CAAC;AAE7F,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE3E,OAAO,EACL,gCAAgC,EAChC,uCAAuC,EACvC,qCAAqC,EACrC,6CAA6C,EAC7C,gCAAgC,EAChC,yCAAyC,GAC1C,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uEAAuE,CAAC;AAClH,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,kEAAkE,CAAC;AAC3G,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,+BAA+B,EAAE,MAAM,4EAA4E,CAAC;AAC7H,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,6DAA6D,CAAC","sourcesContent":["// ma v2 exports\nexport { accountFactoryAbi } from \"./abis/accountFactoryAbi.js\";\nexport { modularAccountAbi } from \"./abis/modularAccountAbi.js\";\nexport { semiModularAccountBytecodeAbi } from \"./abis/semiModularAccountBytecodeAbi.js\";\nexport { semiModularAccountStorageAbi } from \"./abis/semiModularAccountStorageAbi.js\";\n\nexport { nativeSMASigner } from \"./account/nativeSMASigner.js\";\n\nexport type {\n ModuleEntity,\n ValidationConfig,\n HookConfig,\n ValidationData,\n} from \"./actions/common/types.js\";\nexport { HookType } from \"./actions/common/types.js\";\nexport {\n serializeValidationConfig,\n serializeHookConfig,\n serializeModuleEntity,\n} from \"./actions/common/utils.js\";\nexport type * from \"./actions/install-validation/installValidation.js\";\nexport { installValidationActions } from \"./actions/install-validation/installValidation.js\";\nexport type * from \"./actions/deferralActions.js\";\nexport { deferralActions } from \"./actions/deferralActions.js\";\nexport type * from \"./permissionBuilder.js\";\nexport { PermissionBuilder, PermissionType } from \"./permissionBuilder.js\";\n\nexport {\n getDefaultAllowlistModuleAddress,\n getDefaultNativeTokenLimitModuleAddress,\n getDefaultPaymasterGuardModuleAddress,\n getDefaultSingleSignerValidationModuleAddress,\n getDefaultTimeRangeModuleAddress,\n getDefaultWebauthnValidationModuleAddress,\n} from \"./modules/utils.js\";\nexport { buildFullNonceKey } from \"./utils.js\";\nexport { allowlistModuleAbi } from \"./modules/allowlist-module/abis/allowlistModuleAbi.js\";\nexport { AllowlistModule } from \"./modules/allowlist-module/module.js\";\nexport { nativeTokenLimitModuleAbi } from \"./modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.js\";\nexport { NativeTokenLimitModule } from \"./modules/native-token-limit-module/module.js\";\nexport { paymasterGuardModuleAbi } from \"./modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.js\";\nexport { PaymasterGuardModule } from \"./modules/paymaster-guard-module/module.js\";\nexport { singleSignerValidationModuleAbi } from \"./modules/single-signer-validation/abis/singleSignerValidationModuleAbi.js\";\nexport { SingleSignerValidationModule } from \"./modules/single-signer-validation/module.js\";\nexport { timeRangeModuleAbi } from \"./modules/time-range-module/abis/timeRangeModuleAbi.js\";\nexport { TimeRangeModule } from \"./modules/time-range-module/module.js\";\nexport { webauthnValidationModuleAbi } from \"./modules/webauthn-validation/abis/webauthnValidationAbi.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ma-v2/index.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AAEtF,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAQ/D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,mDAAmD,CAAC;AAE7F,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC3E,cAAc,8BAA8B,CAAC;AAE7C,OAAO,EACL,gCAAgC,EAChC,uCAAuC,EACvC,qCAAqC,EACrC,6CAA6C,EAC7C,gCAAgC,EAChC,yCAAyC,GAC1C,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uEAAuE,CAAC;AAClH,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,kEAAkE,CAAC;AAC3G,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,+BAA+B,EAAE,MAAM,4EAA4E,CAAC;AAC7H,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,6DAA6D,CAAC","sourcesContent":["// ma v2 exports\nexport { accountFactoryAbi } from \"./abis/accountFactoryAbi.js\";\nexport { modularAccountAbi } from \"./abis/modularAccountAbi.js\";\nexport { semiModularAccountBytecodeAbi } from \"./abis/semiModularAccountBytecodeAbi.js\";\nexport { semiModularAccountStorageAbi } from \"./abis/semiModularAccountStorageAbi.js\";\n\nexport { nativeSMASigner } from \"./account/nativeSMASigner.js\";\n\nexport type {\n ModuleEntity,\n ValidationConfig,\n HookConfig,\n ValidationData,\n} from \"./actions/common/types.js\";\nexport { HookType } from \"./actions/common/types.js\";\nexport {\n serializeValidationConfig,\n serializeHookConfig,\n serializeModuleEntity,\n} from \"./actions/common/utils.js\";\nexport type * from \"./actions/install-validation/installValidation.js\";\nexport { installValidationActions } from \"./actions/install-validation/installValidation.js\";\nexport type * from \"./actions/deferralActions.js\";\nexport { deferralActions } from \"./actions/deferralActions.js\";\nexport type * from \"./permissionBuilder.js\";\nexport { PermissionBuilder, PermissionType } from \"./permissionBuilder.js\";\nexport * from \"./permissionBuilderErrors.js\";\n\nexport {\n getDefaultAllowlistModuleAddress,\n getDefaultNativeTokenLimitModuleAddress,\n getDefaultPaymasterGuardModuleAddress,\n getDefaultSingleSignerValidationModuleAddress,\n getDefaultTimeRangeModuleAddress,\n getDefaultWebauthnValidationModuleAddress,\n} from \"./modules/utils.js\";\nexport { buildFullNonceKey, buildDeferredActionDigest } from \"./utils.js\";\nexport { allowlistModuleAbi } from \"./modules/allowlist-module/abis/allowlistModuleAbi.js\";\nexport { AllowlistModule } from \"./modules/allowlist-module/module.js\";\nexport { nativeTokenLimitModuleAbi } from \"./modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.js\";\nexport { NativeTokenLimitModule } from \"./modules/native-token-limit-module/module.js\";\nexport { paymasterGuardModuleAbi } from \"./modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.js\";\nexport { PaymasterGuardModule } from \"./modules/paymaster-guard-module/module.js\";\nexport { singleSignerValidationModuleAbi } from \"./modules/single-signer-validation/abis/singleSignerValidationModuleAbi.js\";\nexport { SingleSignerValidationModule } from \"./modules/single-signer-validation/module.js\";\nexport { timeRangeModuleAbi } from \"./modules/time-range-module/abis/timeRangeModuleAbi.js\";\nexport { TimeRangeModule } from \"./modules/time-range-module/module.js\";\nexport { webauthnValidationModuleAbi } from \"./modules/webauthn-validation/abis/webauthnValidationAbi.js\";\n"]}
@@ -110,4 +110,5 @@ export declare class PermissionBuilder {
110
110
  private translatePermissions;
111
111
  private addHooks;
112
112
  }
113
+ export declare function assertNever(_valid: never): never;
113
114
  export {};
@@ -1,4 +1,4 @@
1
- import { toHex, zeroAddress } from "viem";
1
+ import { maxUint48, toHex, zeroAddress } from "viem";
2
2
  import { HookType, } from "./actions/common/types.js";
3
3
  import { installValidationActions, } from "./actions/install-validation/installValidation.js";
4
4
  import { deferralActions, } from "./actions/deferralActions.js";
@@ -7,6 +7,7 @@ import { getDefaultAllowlistModuleAddress, getDefaultNativeTokenLimitModuleAddre
7
7
  import { SingleSignerValidationModule } from "./modules/single-signer-validation/module.js";
8
8
  import { AllowlistModule } from "./modules/allowlist-module/module.js";
9
9
  import { TimeRangeModule } from "./modules/time-range-module/module.js";
10
+ import { AccountAddressAsTargetError, DeadlineOverLimitError, DuplicateTargetAddressError, ExpiredDeadlineError, MultipleGasLimitError, MultipleNativeTokenTransferError, NoFunctionsProvidedError, RootPermissionOnlyError, UnsupportedPermissionTypeError, ValidationConfigUnsetError, ZeroAddressError, } from "./permissionBuilderErrors.js";
10
11
  // We use this to offset the ERC20 spend limit entityId
11
12
  const HALF_UINT32 = 2147483647;
12
13
  const ERC20_APPROVE_SELECTOR = "0x095ea7b3";
@@ -125,7 +126,7 @@ export class PermissionBuilder {
125
126
  // Check 1: If we're adding root, we can't have any other permissions
126
127
  if (permission.type === PermissionType.ROOT) {
127
128
  if (this.permissions.length !== 0) {
128
- throw new Error("PERMISSION: ROOT: Cannot add ROOT permission with other permissions");
129
+ throw new RootPermissionOnlyError(permission);
129
130
  }
130
131
  this.permissions.push(permission);
131
132
  // Set isGlobal to true
@@ -137,14 +138,14 @@ export class PermissionBuilder {
137
138
  // NOTE: Technically this could be replaced by checking permissions[0] since it should not be possible
138
139
  // to have >1 permission with root among them
139
140
  if (this.permissions.find((p) => p.type === PermissionType.ROOT)) {
140
- throw new Error(`PERMISSION: ${permission.type} => Cannot add permissions with ROOT enabled`);
141
+ throw new RootPermissionOnlyError(permission);
141
142
  }
142
143
  // Check 3: If the permission is either CONTRACT_ACCESS or FUNCTIONS_ON_CONTRACT, ensure it doesn't collide with another like it.
143
144
  if (permission.type === PermissionType.CONTRACT_ACCESS ||
144
145
  permission.type === PermissionType.FUNCTIONS_ON_CONTRACT) {
145
146
  // Check 3.1: address must not be the account address, or the user should use the ACCOUNT_FUNCTIONS permission
146
147
  if (permission.data.address === this.client.account.address) {
147
- throw new Error(`PERMISSION: ${permission.type} => Account address as target, use ACCOUNT_FUNCTIONS for account address`);
148
+ throw new AccountAddressAsTargetError(permission);
148
149
  }
149
150
  // Check 3.2: there must not be an existing permission with this address as a target
150
151
  const targetAddress = permission.data.address;
@@ -155,13 +156,15 @@ export class PermissionBuilder {
155
156
  "address" in p.data &&
156
157
  p.data.address === targetAddress));
157
158
  if (existingPermissionWithSameAddress) {
158
- throw new Error(`PERMISSION: ${permission.type} => Address ${targetAddress} already has a permission. Cannot add multiple CONTRACT_ACCESS or FUNCTIONS_ON_CONTRACT permissions for the same target address.`);
159
+ throw new DuplicateTargetAddressError(permission, targetAddress);
159
160
  }
160
161
  }
161
162
  // Check 4: If the permission is ACCOUNT_FUNCTIONS, add selectors
162
163
  if (permission.type === PermissionType.ACCOUNT_FUNCTIONS) {
164
+ if (permission.data.functions.length === 0) {
165
+ throw new NoFunctionsProvidedError(permission);
166
+ }
163
167
  this.selectors = [...this.selectors, ...permission.data.functions];
164
- return this;
165
168
  }
166
169
  this.permissions.push(permission);
167
170
  return this;
@@ -179,10 +182,13 @@ export class PermissionBuilder {
179
182
  // Add time range module hook via expiry
180
183
  if (this.deadline !== 0) {
181
184
  if (this.deadline < Date.now() / 1000) {
182
- throw new Error(`PERMISSION: compileDeferred(): deadline ${this.deadline} cannot be before now (${Date.now() / 1000})`);
185
+ throw new ExpiredDeadlineError(this.deadline, Date.now() / 1000);
186
+ }
187
+ if (this.deadline > maxUint48) {
188
+ throw new DeadlineOverLimitError(this.deadline);
183
189
  }
184
190
  this.hooks.push(TimeRangeModule.buildHook({
185
- entityId: this.validationConfig.entityId, // will be timerange entityId
191
+ entityId: this.validationConfig.entityId,
186
192
  validUntil: this.deadline,
187
193
  validAfter: 0,
188
194
  }, getDefaultTimeRangeModuleAddress(this.client.chain)));
@@ -234,7 +240,7 @@ export class PermissionBuilder {
234
240
  validateConfiguration() {
235
241
  if (this.validationConfig.isGlobal === false &&
236
242
  this.selectors.length === 0) {
237
- throw new Error("Validation config unset, use permissionBuilder.configure(...)");
243
+ throw new ValidationConfigUnsetError();
238
244
  }
239
245
  }
240
246
  // Used to translate consolidated permissions into raw unencoded hooks
@@ -251,7 +257,7 @@ export class PermissionBuilder {
251
257
  case PermissionType.NATIVE_TOKEN_TRANSFER:
252
258
  // Should never be added twice, check is on addPermission(s) too
253
259
  if (rawHooks[HookIdentifier.NATIVE_TOKEN_TRANSFER] !== undefined) {
254
- throw new Error("PERMISSION: NATIVE_TOKEN_TRANSFER => Must have at most ONE native token transfer permission");
260
+ throw new MultipleNativeTokenTransferError(permission);
255
261
  }
256
262
  rawHooks[HookIdentifier.NATIVE_TOKEN_TRANSFER] = {
257
263
  hookConfig: {
@@ -270,7 +276,7 @@ export class PermissionBuilder {
270
276
  break;
271
277
  case PermissionType.ERC20_TOKEN_TRANSFER:
272
278
  if (permission.data.address === zeroAddress) {
273
- throw new Error("PERMISSION: ERC20_TOKEN_TRANSFER => Zero address provided");
279
+ throw new ZeroAddressError(permission);
274
280
  }
275
281
  rawHooks[HookIdentifier.ERC20_TOKEN_TRANSFER] = {
276
282
  hookConfig: {
@@ -326,7 +332,7 @@ export class PermissionBuilder {
326
332
  case PermissionType.GAS_LIMIT:
327
333
  // Should only ever be added once, check is also on addPermission(s)
328
334
  if (rawHooks[HookIdentifier.GAS_LIMIT] !== undefined) {
329
- throw new Error("PERMISSION: GAS_LIMIT => Must have at most ONE gas limit permission");
335
+ throw new MultipleGasLimitError(permission);
330
336
  }
331
337
  rawHooks[HookIdentifier.GAS_LIMIT] = {
332
338
  hookConfig: {
@@ -344,7 +350,7 @@ export class PermissionBuilder {
344
350
  break;
345
351
  case PermissionType.CONTRACT_ACCESS:
346
352
  if (permission.data.address === zeroAddress) {
347
- throw new Error("PERMISSION: CONTRACT_ACCESS => Zero address provided");
353
+ throw new ZeroAddressError(permission);
348
354
  }
349
355
  rawHooks[HookIdentifier.PREVAL_ALLOWLIST] = {
350
356
  hookConfig: {
@@ -372,13 +378,11 @@ export class PermissionBuilder {
372
378
  };
373
379
  break;
374
380
  case PermissionType.ACCOUNT_FUNCTIONS:
375
- if (permission.data.functions.length === 0) {
376
- throw new Error("PERMISSION: ACCOUNT_FUNCTION => No functions provided"); // should be in add perm
377
- }
381
+ // This is handled in add permissions
378
382
  break;
379
383
  case PermissionType.FUNCTIONS_ON_ALL_CONTRACTS:
380
384
  if (permission.data.functions.length === 0) {
381
- throw new Error("PERMISSION: FUNCTIONS_ON_ALL_CONTRACTS => No functions provided");
385
+ throw new NoFunctionsProvidedError(permission);
382
386
  }
383
387
  rawHooks[HookIdentifier.PREVAL_ALLOWLIST] = {
384
388
  hookConfig: {
@@ -407,10 +411,10 @@ export class PermissionBuilder {
407
411
  break;
408
412
  case PermissionType.FUNCTIONS_ON_CONTRACT:
409
413
  if (permission.data.functions.length === 0) {
410
- throw new Error("PERMISSION: FUNCTIONS_ON_CONTRACT => No functions provided");
414
+ throw new NoFunctionsProvidedError(permission);
411
415
  }
412
416
  if (permission.data.address === zeroAddress) {
413
- throw new Error("PERMISSION: FUNCTIONS_ON_CONTRACT => Zero address provided");
417
+ throw new ZeroAddressError(permission);
414
418
  }
415
419
  rawHooks[HookIdentifier.PREVAL_ALLOWLIST] = {
416
420
  hookConfig: {
@@ -441,7 +445,7 @@ export class PermissionBuilder {
441
445
  // Root permission handled in addPermission
442
446
  break;
443
447
  default:
444
- throw new Error(`Unsupported permission type: ${permission.type}`);
448
+ assertNever(permission);
445
449
  }
446
450
  // isGlobal guaranteed to be false since it's only set with root permissions,
447
451
  // we must add access to execute & executeBatch if there's a preVal allowlist hook set.
@@ -484,4 +488,7 @@ export class PermissionBuilder {
484
488
  }
485
489
  }
486
490
  }
491
+ export function assertNever(_valid) {
492
+ throw new UnsupportedPermissionTypeError();
493
+ }
487
494
  //# sourceMappingURL=permissionBuilder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"perm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ClD,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,QAAQ,CAC5C;aACF,CAAC,CAAC;QACL,CAAC;QAED,IAAI,QAAQ,CAAC,cAAc,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC9C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;gBACd,UAAU,EAAE,QAAQ,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,UAAU;gBAChE,QAAQ,EAAE,eAAe,CAAC,mBAAmB,CAC3C,QAAQ,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CACnD;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF","sourcesContent":["import { toHex, zeroAddress, type Address, type Hex } from \"viem\";\nimport {\n HookType,\n type HookConfig,\n type ValidationConfig,\n} from \"./actions/common/types.js\";\nimport {\n installValidationActions,\n type InstallValidationParams,\n} from \"./actions/install-validation/installValidation.js\";\nimport type { ModularAccountV2Client } from \"./client/client.js\";\nimport {\n deferralActions,\n type DeferredActionTypedData,\n} from \"./actions/deferralActions.js\";\nimport { NativeTokenLimitModule } from \"./modules/native-token-limit-module/module.js\";\nimport {\n getDefaultAllowlistModuleAddress,\n getDefaultNativeTokenLimitModuleAddress,\n getDefaultSingleSignerValidationModuleAddress,\n getDefaultTimeRangeModuleAddress,\n} from \"./modules/utils.js\";\nimport { SingleSignerValidationModule } from \"./modules/single-signer-validation/module.js\";\nimport { AllowlistModule } from \"./modules/allowlist-module/module.js\";\nimport { TimeRangeModule } from \"./modules/time-range-module/module.js\";\n\n// We use this to offset the ERC20 spend limit entityId\nconst HALF_UINT32 = 2147483647;\nconst ERC20_APPROVE_SELECTOR = \"0x095ea7b3\";\nconst ERC20_TRANSFER_SELECTOR = \"0xa9059cbb\";\nconst ACCOUNT_EXECUTE_SELECTOR = \"0xb61d27f6\";\nconst ACCOUNT_EXECUTEBATCH_SELECTOR = \"0x34fcd5be\";\n\nexport enum PermissionType {\n NATIVE_TOKEN_TRANSFER = \"native-token-transfer\",\n ERC20_TOKEN_TRANSFER = \"erc20-token-transfer\",\n // ERC721_TOKEN_TRANSFER = \"erc721-token-transfer\", //Unimplemented\n // ERC1155_TOKEN_TRANSFER = \"erc1155-token-transfer\", //Unimplemented\n GAS_LIMIT = \"gas-limit\",\n // CALL_LIMIT = \"call-limit\", //Unimplemented\n // RATE_LIMIT = \"rate-limit\", //Unimplemented\n CONTRACT_ACCESS = \"contract-access\",\n ACCOUNT_FUNCTIONS = \"account-functions\",\n FUNCTIONS_ON_ALL_CONTRACTS = \"functions-on-all-contracts\",\n FUNCTIONS_ON_CONTRACT = \"functions-on-contract\",\n ROOT = \"root\",\n}\n\nenum HookIdentifier {\n NATIVE_TOKEN_TRANSFER,\n ERC20_TOKEN_TRANSFER,\n GAS_LIMIT,\n PREVAL_ALLOWLIST, // aggregate of CONTRACT_ACCESS, ACCOUNT_FUNCTIONS, FUNCTIONS_ON_ALL_CONTRACTS, FUNCTIONS_ON_CONTRACT\n}\n\ntype PreExecutionHookConfig = {\n address: Address;\n entityId: number;\n hookType: HookType.EXECUTION;\n hasPreHooks: true;\n hasPostHooks: false;\n};\n\ntype PreValidationHookConfig = {\n address: Address;\n entityId: number;\n hookType: HookType.VALIDATION;\n hasPreHooks: true;\n hasPostHooks: false;\n};\n\ntype RawHooks = {\n [HookIdentifier.NATIVE_TOKEN_TRANSFER]:\n | {\n hookConfig: PreExecutionHookConfig;\n initData: {\n entityId: number;\n spendLimit: bigint;\n };\n }\n | undefined;\n [HookIdentifier.ERC20_TOKEN_TRANSFER]:\n | {\n hookConfig: PreExecutionHookConfig;\n initData: {\n entityId: number;\n inputs: Array<{\n target: Address;\n hasSelectorAllowlist: boolean;\n hasERC20SpendLimit: boolean;\n erc20SpendLimit: bigint;\n selectors: Array<Hex>;\n }>;\n };\n }\n | undefined;\n [HookIdentifier.GAS_LIMIT]:\n | {\n hookConfig: PreValidationHookConfig;\n initData: {\n entityId: number;\n spendLimit: bigint;\n };\n }\n | undefined;\n [HookIdentifier.PREVAL_ALLOWLIST]:\n | {\n hookConfig: PreValidationHookConfig;\n\n initData: {\n entityId: number;\n inputs: Array<{\n target: Address;\n hasSelectorAllowlist: boolean;\n hasERC20SpendLimit: boolean;\n erc20SpendLimit: bigint;\n selectors: Array<Hex>;\n }>;\n };\n }\n | undefined;\n};\n\ntype OneOf<T extends {}[]> = T[number];\n\ntype Key = {\n publicKey: Hex;\n type: \"secp256k1\" | \"contract\";\n};\n\nexport type Permission = OneOf<\n [\n {\n // this permission allows transfer of native tokens from the account\n type: PermissionType.NATIVE_TOKEN_TRANSFER;\n data: {\n allowance: Hex;\n };\n },\n {\n // this permission allows transfer or approval of erc20 tokens from the account\n type: PermissionType.ERC20_TOKEN_TRANSFER;\n data: {\n address: Address; // erc20 token contract address\n allowance: Hex;\n };\n },\n {\n // this permissions allows the key to spend gas for UOs\n type: PermissionType.GAS_LIMIT;\n data: {\n limit: Hex;\n };\n },\n {\n // this permission grants access to all functions in a contract\n type: PermissionType.CONTRACT_ACCESS;\n data: {\n address: Address;\n };\n },\n {\n // this permission grants access to functions in the account\n type: PermissionType.ACCOUNT_FUNCTIONS;\n data: {\n functions: Hex[]; // function signatures\n };\n },\n {\n // this permission grants access to a function selector in any address or contract\n type: PermissionType.FUNCTIONS_ON_ALL_CONTRACTS;\n data: {\n functions: Hex[]; // function signatures\n };\n },\n {\n // this permission grants access to specified functions on a specific contract\n type: PermissionType.FUNCTIONS_ON_CONTRACT;\n data: {\n address: Address;\n functions: Hex[];\n };\n },\n {\n // this permission grants full access to everything\n type: PermissionType.ROOT;\n data?: never;\n }\n ]\n>;\n\ntype Hook = {\n hookConfig: HookConfig;\n initData: Hex;\n};\n\nexport class PermissionBuilder {\n private client: ModularAccountV2Client;\n private validationConfig: ValidationConfig = {\n moduleAddress: zeroAddress,\n entityId: 0, // uint32\n isGlobal: false,\n isSignatureValidation: false,\n isUserOpValidation: false,\n };\n private selectors: Hex[] = [];\n private installData: Hex = \"0x\";\n private permissions: Permission[] = [];\n private hooks: Hook[] = [];\n private nonce: bigint = 0n;\n private hasAssociatedExecHooks: boolean = false;\n private deadline: number = 0;\n\n constructor({\n client,\n key,\n entityId,\n nonce,\n selectors,\n hooks,\n deadline,\n }: {\n client: ModularAccountV2Client;\n key: Key;\n entityId: number;\n nonce: bigint;\n selectors?: Hex[];\n hooks?: Hook[];\n deadline?: number;\n }) {\n this.client = client;\n this.validationConfig = {\n moduleAddress: getDefaultSingleSignerValidationModuleAddress(\n this.client.chain\n ),\n entityId,\n isUserOpValidation: true,\n isGlobal: false,\n isSignatureValidation: false,\n };\n this.installData = SingleSignerValidationModule.encodeOnInstallData({\n entityId: entityId,\n signer: key.publicKey,\n });\n this.nonce = nonce;\n if (selectors) this.selectors = selectors;\n if (hooks) this.hooks = hooks;\n if (deadline) this.deadline = deadline;\n }\n\n addSelector({ selector }: { selector: Hex }): this {\n this.selectors.push(selector);\n return this;\n }\n\n addPermission({ permission }: { permission: Permission }): this {\n // Check 1: If we're adding root, we can't have any other permissions\n if (permission.type === PermissionType.ROOT) {\n if (this.permissions.length !== 0) {\n throw new Error(\n \"PERMISSION: ROOT: Cannot add ROOT permission with other permissions\"\n );\n }\n this.permissions.push(permission);\n // Set isGlobal to true\n this.validationConfig.isGlobal = true;\n return this;\n }\n\n // Check 2: If the permission is NOT ROOT (guaranteed), ensure there is no ROOT permission set\n // Will resolve to undefined if ROOT is not found\n // NOTE: Technically this could be replaced by checking permissions[0] since it should not be possible\n // to have >1 permission with root among them\n if (this.permissions.find((p) => p.type === PermissionType.ROOT)) {\n throw new Error(\n `PERMISSION: ${permission.type} => Cannot add permissions with ROOT enabled`\n );\n }\n\n // Check 3: If the permission is either CONTRACT_ACCESS or FUNCTIONS_ON_CONTRACT, ensure it doesn't collide with another like it.\n if (\n permission.type === PermissionType.CONTRACT_ACCESS ||\n permission.type === PermissionType.FUNCTIONS_ON_CONTRACT\n ) {\n // Check 3.1: address must not be the account address, or the user should use the ACCOUNT_FUNCTIONS permission\n if (permission.data.address === this.client.account.address) {\n throw new Error(\n `PERMISSION: ${permission.type} => Account address as target, use ACCOUNT_FUNCTIONS for account address`\n );\n }\n\n // Check 3.2: there must not be an existing permission with this address as a target\n const targetAddress = permission.data.address;\n const existingPermissionWithSameAddress = this.permissions.find(\n (p) =>\n (p.type === PermissionType.CONTRACT_ACCESS &&\n \"address\" in p.data &&\n p.data.address === targetAddress) ||\n (p.type === PermissionType.FUNCTIONS_ON_CONTRACT &&\n \"address\" in p.data &&\n p.data.address === targetAddress)\n );\n\n if (existingPermissionWithSameAddress) {\n throw new Error(\n `PERMISSION: ${permission.type} => Address ${targetAddress} already has a permission. Cannot add multiple CONTRACT_ACCESS or FUNCTIONS_ON_CONTRACT permissions for the same target address.`\n );\n }\n }\n\n // Check 4: If the permission is ACCOUNT_FUNCTIONS, add selectors\n if (permission.type === PermissionType.ACCOUNT_FUNCTIONS) {\n this.selectors = [...this.selectors, ...permission.data.functions];\n return this;\n }\n\n this.permissions.push(permission);\n\n return this;\n }\n\n addPermissions({ permissions }: { permissions: Permission[] }): this {\n // We could validate each permission here, but for simplicity we'll just add them\n // A better approach would be to call addPermission for each one\n permissions.forEach((permission) => {\n this.addPermission({ permission });\n });\n return this;\n }\n\n // Use for building deferred action typed data to sign\n async compileDeferred(): Promise<{\n typedData: DeferredActionTypedData;\n fullPreSignatureDeferredActionDigest: Hex;\n }> {\n // Add time range module hook via expiry\n if (this.deadline !== 0) {\n if (this.deadline < Date.now() / 1000) {\n throw new Error(\n `PERMISSION: compileDeferred(): deadline ${\n this.deadline\n } cannot be before now (${Date.now() / 1000})`\n );\n }\n this.hooks.push(\n TimeRangeModule.buildHook(\n {\n entityId: this.validationConfig.entityId, // will be timerange entityId\n validUntil: this.deadline,\n validAfter: 0,\n },\n getDefaultTimeRangeModuleAddress(this.client.chain)\n )\n );\n }\n\n const installValidationCall = await this.compileRaw();\n\n const { typedData } = await deferralActions(\n this.client\n ).createDeferredActionTypedDataObject({\n callData: installValidationCall,\n deadline: this.deadline,\n nonce: this.nonce,\n });\n\n const preSignatureDigest = deferralActions(\n this.client\n ).buildPreSignatureDeferredActionDigest({ typedData });\n\n // Encode additional information to build the full pre-signature digest\n const fullPreSignatureDeferredActionDigest: `0x${string}` = `0x0${\n this.hasAssociatedExecHooks ? \"1\" : \"0\"\n }${toHex(this.nonce, {\n size: 32,\n }).slice(2)}${preSignatureDigest.slice(2)}`;\n\n return {\n typedData,\n fullPreSignatureDeferredActionDigest,\n };\n }\n\n // Use for direct `installValidation()` low-level calls (maybe useless)\n async compileRaw(): Promise<Hex> {\n // Translate all permissions into raw hooks if >0\n if (this.permissions.length > 0) {\n const rawHooks = this.translatePermissions(\n this.validationConfig.entityId\n );\n // Add the translated permissions as hooks\n this.addHooks(rawHooks);\n }\n this.validateConfiguration();\n\n return await installValidationActions(this.client).encodeInstallValidation({\n validationConfig: this.validationConfig,\n selectors: this.selectors,\n installData: this.installData,\n hooks: this.hooks,\n account: this.client.account,\n });\n }\n\n // Use for compiling args to installValidation\n async compileInstallArgs(): Promise<InstallValidationParams> {\n this.validateConfiguration();\n\n return {\n validationConfig: this.validationConfig,\n selectors: this.selectors,\n installData: this.installData,\n hooks: this.hooks,\n account: this.client.account,\n };\n }\n\n private validateConfiguration(): void {\n if (\n this.validationConfig.isGlobal === false &&\n this.selectors.length === 0\n ) {\n throw new Error(\n \"Validation config unset, use permissionBuilder.configure(...)\"\n );\n }\n }\n\n // Used to translate consolidated permissions into raw unencoded hooks\n // Note entityId will be a member object later\n private translatePermissions(entityId: number): RawHooks {\n const rawHooks: RawHooks = {\n [HookIdentifier.NATIVE_TOKEN_TRANSFER]: undefined,\n [HookIdentifier.ERC20_TOKEN_TRANSFER]: undefined,\n [HookIdentifier.GAS_LIMIT]: undefined,\n [HookIdentifier.PREVAL_ALLOWLIST]: undefined,\n };\n\n this.permissions.forEach((permission) => {\n switch (permission.type) {\n case PermissionType.NATIVE_TOKEN_TRANSFER:\n // Should never be added twice, check is on addPermission(s) too\n if (rawHooks[HookIdentifier.NATIVE_TOKEN_TRANSFER] !== undefined) {\n throw new Error(\n \"PERMISSION: NATIVE_TOKEN_TRANSFER => Must have at most ONE native token transfer permission\"\n );\n }\n rawHooks[HookIdentifier.NATIVE_TOKEN_TRANSFER] = {\n hookConfig: {\n address: getDefaultNativeTokenLimitModuleAddress(\n this.client.chain\n ),\n entityId,\n hookType: HookType.EXECUTION,\n hasPreHooks: true,\n hasPostHooks: false,\n },\n initData: {\n entityId,\n spendLimit: BigInt(permission.data.allowance),\n },\n };\n this.hasAssociatedExecHooks = true;\n break;\n case PermissionType.ERC20_TOKEN_TRANSFER:\n if (permission.data.address === zeroAddress) {\n throw new Error(\n \"PERMISSION: ERC20_TOKEN_TRANSFER => Zero address provided\"\n );\n }\n rawHooks[HookIdentifier.ERC20_TOKEN_TRANSFER] = {\n hookConfig: {\n address: getDefaultAllowlistModuleAddress(this.client.chain),\n entityId: entityId + HALF_UINT32,\n hookType: HookType.EXECUTION,\n hasPreHooks: true,\n hasPostHooks: false,\n },\n initData: {\n entityId: entityId + HALF_UINT32,\n inputs: [\n // Add previous inputs if they exist\n ...(rawHooks[HookIdentifier.ERC20_TOKEN_TRANSFER]?.initData\n .inputs || []),\n {\n target: permission.data.address,\n hasSelectorAllowlist: false,\n hasERC20SpendLimit: true,\n erc20SpendLimit: BigInt(permission.data.allowance),\n selectors: [],\n },\n ],\n },\n };\n this.hasAssociatedExecHooks = true;\n // Also allow `approve` and `transfer` for the erc20\n rawHooks[HookIdentifier.PREVAL_ALLOWLIST] = {\n hookConfig: {\n address: getDefaultAllowlistModuleAddress(this.client.chain),\n entityId,\n hookType: HookType.VALIDATION,\n hasPreHooks: true,\n hasPostHooks: false,\n },\n initData: {\n entityId,\n inputs: [\n // Add previous inputs if they exist\n ...(rawHooks[HookIdentifier.PREVAL_ALLOWLIST]?.initData\n .inputs || []),\n {\n target: permission.data.address,\n hasSelectorAllowlist: true,\n hasERC20SpendLimit: false,\n erc20SpendLimit: 0n,\n selectors: [ERC20_APPROVE_SELECTOR, ERC20_TRANSFER_SELECTOR], // approve, transfer\n },\n ],\n },\n };\n break;\n case PermissionType.GAS_LIMIT:\n // Should only ever be added once, check is also on addPermission(s)\n if (rawHooks[HookIdentifier.GAS_LIMIT] !== undefined) {\n throw new Error(\n \"PERMISSION: GAS_LIMIT => Must have at most ONE gas limit permission\"\n );\n }\n rawHooks[HookIdentifier.GAS_LIMIT] = {\n hookConfig: {\n address: getDefaultNativeTokenLimitModuleAddress(\n this.client.chain\n ),\n entityId,\n hookType: HookType.VALIDATION,\n hasPreHooks: true,\n hasPostHooks: false,\n },\n initData: {\n entityId,\n spendLimit: BigInt(permission.data.limit),\n },\n };\n break;\n case PermissionType.CONTRACT_ACCESS:\n if (permission.data.address === zeroAddress) {\n throw new Error(\n \"PERMISSION: CONTRACT_ACCESS => Zero address provided\"\n );\n }\n rawHooks[HookIdentifier.PREVAL_ALLOWLIST] = {\n hookConfig: {\n address: getDefaultAllowlistModuleAddress(this.client.chain),\n entityId,\n hookType: HookType.VALIDATION,\n hasPreHooks: true,\n hasPostHooks: false,\n },\n initData: {\n entityId,\n inputs: [\n // Add previous inputs if they exist\n ...(rawHooks[HookIdentifier.PREVAL_ALLOWLIST]?.initData\n .inputs || []),\n {\n target: permission.data.address,\n hasSelectorAllowlist: false,\n hasERC20SpendLimit: false,\n erc20SpendLimit: 0n,\n selectors: [],\n },\n ],\n },\n };\n break;\n case PermissionType.ACCOUNT_FUNCTIONS:\n if (permission.data.functions.length === 0) {\n throw new Error(\n \"PERMISSION: ACCOUNT_FUNCTION => No functions provided\"\n ); // should be in add perm\n }\n break;\n case PermissionType.FUNCTIONS_ON_ALL_CONTRACTS:\n if (permission.data.functions.length === 0) {\n throw new Error(\n \"PERMISSION: FUNCTIONS_ON_ALL_CONTRACTS => No functions provided\"\n );\n }\n rawHooks[HookIdentifier.PREVAL_ALLOWLIST] = {\n hookConfig: {\n address: getDefaultAllowlistModuleAddress(this.client.chain),\n entityId,\n hookType: HookType.VALIDATION,\n hasPreHooks: true,\n hasPostHooks: false,\n },\n initData: {\n entityId,\n inputs: [\n // Add previous inputs if they exist\n ...(rawHooks[HookIdentifier.PREVAL_ALLOWLIST]?.initData\n .inputs || []),\n {\n target: zeroAddress,\n hasSelectorAllowlist: false,\n hasERC20SpendLimit: false,\n erc20SpendLimit: 0n,\n selectors: permission.data.functions,\n },\n ],\n },\n };\n break;\n case PermissionType.FUNCTIONS_ON_CONTRACT:\n if (permission.data.functions.length === 0) {\n throw new Error(\n \"PERMISSION: FUNCTIONS_ON_CONTRACT => No functions provided\"\n );\n }\n if (permission.data.address === zeroAddress) {\n throw new Error(\n \"PERMISSION: FUNCTIONS_ON_CONTRACT => Zero address provided\"\n );\n }\n rawHooks[HookIdentifier.PREVAL_ALLOWLIST] = {\n hookConfig: {\n address: getDefaultAllowlistModuleAddress(this.client.chain),\n entityId,\n hookType: HookType.VALIDATION,\n hasPreHooks: true,\n hasPostHooks: false,\n },\n initData: {\n entityId,\n inputs: [\n // Add previous inputs if they exist\n ...(rawHooks[HookIdentifier.PREVAL_ALLOWLIST]?.initData\n .inputs || []),\n {\n target: permission.data.address,\n hasSelectorAllowlist: true,\n hasERC20SpendLimit: false,\n erc20SpendLimit: 0n,\n selectors: permission.data.functions,\n },\n ],\n },\n };\n break;\n case PermissionType.ROOT:\n // Root permission handled in addPermission\n break;\n default:\n throw new Error(\n `Unsupported permission type: ${(permission as any).type}`\n );\n }\n\n // isGlobal guaranteed to be false since it's only set with root permissions,\n // we must add access to execute & executeBatch if there's a preVal allowlist hook set.\n if (rawHooks[HookIdentifier.PREVAL_ALLOWLIST] !== undefined) {\n const selectorsToAdd: `0x${string}`[] = [\n ACCOUNT_EXECUTE_SELECTOR,\n ACCOUNT_EXECUTEBATCH_SELECTOR,\n ]; // execute, executeBatch\n\n // Only add the selectors if they aren't already in this.selectors\n const newSelectors = selectorsToAdd.filter(\n (selector) => !this.selectors.includes(selector)\n );\n\n this.selectors = [...this.selectors, ...newSelectors];\n }\n });\n\n return rawHooks;\n }\n\n private addHooks(rawHooks: RawHooks) {\n if (rawHooks[HookIdentifier.NATIVE_TOKEN_TRANSFER]) {\n this.hooks.push({\n hookConfig: rawHooks[HookIdentifier.NATIVE_TOKEN_TRANSFER].hookConfig,\n initData: NativeTokenLimitModule.encodeOnInstallData(\n rawHooks[HookIdentifier.NATIVE_TOKEN_TRANSFER].initData\n ),\n });\n }\n\n if (rawHooks[HookIdentifier.ERC20_TOKEN_TRANSFER]) {\n this.hooks.push({\n hookConfig: rawHooks[HookIdentifier.ERC20_TOKEN_TRANSFER].hookConfig,\n initData: AllowlistModule.encodeOnInstallData(\n rawHooks[HookIdentifier.ERC20_TOKEN_TRANSFER].initData\n ),\n });\n }\n\n if (rawHooks[HookIdentifier.GAS_LIMIT]) {\n this.hooks.push({\n hookConfig: rawHooks[HookIdentifier.GAS_LIMIT].hookConfig,\n initData: NativeTokenLimitModule.encodeOnInstallData(\n rawHooks[HookIdentifier.GAS_LIMIT].initData\n ),\n });\n }\n\n if (rawHooks[HookIdentifier.PREVAL_ALLOWLIST]) {\n this.hooks.push({\n hookConfig: rawHooks[HookIdentifier.PREVAL_ALLOWLIST].hookConfig,\n initData: AllowlistModule.encodeOnInstallData(\n rawHooks[HookIdentifier.PREVAL_ALLOWLIST].initData\n ),\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"permissionBuilder.js","sourceRoot":"","sources":["../../../../src/ma-v2/permissionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAA0B,MAAM,MAAM,CAAC;AAC7E,OAAO,EACL,QAAQ,GAGT,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,wBAAwB,GAEzB,MAAM,mDAAmD,CAAC;AAE3D,OAAO,EACL,eAAe,GAEhB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EACL,gC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AAI,CAAC;gBACd,UAAU,EAAE,QAAQ,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,UAAU;gBAChE,QAAQ,EAAE,eAAe,CAAC,mBAAmB,CAC3C,QAAQ,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CACnD;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF;AAED,MAAM,UAAU,WAAW,CAAC,MAAa;IACvC,MAAM,IAAI,8BAA8B,EAAE,CAAC;AAC7C,CAAC","sourcesContent":["import { maxUint48, toHex, zeroAddress, type Address, type Hex } from \"viem\";\nimport {\n HookType,\n type HookConfig,\n type ValidationConfig,\n} from \"./actions/common/types.js\";\nimport {\n installValidationActions,\n type InstallValidationParams,\n} from \"./actions/install-validation/installValidation.js\";\nimport type { ModularAccountV2Client } from \"./client/client.js\";\nimport {\n deferralActions,\n type DeferredActionTypedData,\n} from \"./actions/deferralActions.js\";\nimport { NativeTokenLimitModule } from \"./modules/native-token-limit-module/module.js\";\nimport {\n getDefaultAllowlistModuleAddress,\n getDefaultNativeTokenLimitModuleAddress,\n getDefaultSingleSignerValidationModuleAddress,\n getDefaultTimeRangeModuleAddress,\n} from \"./modules/utils.js\";\nimport { SingleSignerValidationModule } from \"./modules/single-signer-validation/module.js\";\nimport { AllowlistModule } from \"./modules/allowlist-module/module.js\";\nimport { TimeRangeModule } from \"./modules/time-range-module/module.js\";\nimport {\n AccountAddressAsTargetError,\n DeadlineOverLimitError,\n DuplicateTargetAddressError,\n ExpiredDeadlineError,\n MultipleGasLimitError,\n MultipleNativeTokenTransferError,\n NoFunctionsProvidedError,\n RootPermissionOnlyError,\n UnsupportedPermissionTypeError,\n ValidationConfigUnsetError,\n ZeroAddressError,\n} from \"./permissionBuilderErrors.js\";\n\n// We use this to offset the ERC20 spend limit entityId\nconst HALF_UINT32 = 2147483647;\nconst ERC20_APPROVE_SELECTOR = \"0x095ea7b3\";\nconst ERC20_TRANSFER_SELECTOR = \"0xa9059cbb\";\nconst ACCOUNT_EXECUTE_SELECTOR = \"0xb61d27f6\";\nconst ACCOUNT_EXECUTEBATCH_SELECTOR = \"0x34fcd5be\";\n\nexport enum PermissionType {\n NATIVE_TOKEN_TRANSFER = \"native-token-transfer\",\n ERC20_TOKEN_TRANSFER = \"erc20-token-transfer\",\n // ERC721_TOKEN_TRANSFER = \"erc721-token-transfer\", //Unimplemented\n // ERC1155_TOKEN_TRANSFER = \"erc1155-token-transfer\", //Unimplemented\n GAS_LIMIT = \"gas-limit\",\n // CALL_LIMIT = \"call-limit\", //Unimplemented\n // RATE_LIMIT = \"rate-limit\", //Unimplemented\n CONTRACT_ACCESS = \"contract-access\",\n ACCOUNT_FUNCTIONS = \"account-functions\",\n FUNCTIONS_ON_ALL_CONTRACTS = \"functions-on-all-contracts\",\n FUNCTIONS_ON_CONTRACT = \"functions-on-contract\",\n ROOT = \"root\",\n}\n\nenum HookIdentifier {\n NATIVE_TOKEN_TRANSFER,\n ERC20_TOKEN_TRANSFER,\n GAS_LIMIT,\n PREVAL_ALLOWLIST, // aggregate of CONTRACT_ACCESS, ACCOUNT_FUNCTIONS, FUNCTIONS_ON_ALL_CONTRACTS, FUNCTIONS_ON_CONTRACT\n}\n\ntype PreExecutionHookConfig = {\n address: Address;\n entityId: number;\n hookType: HookType.EXECUTION;\n hasPreHooks: true;\n hasPostHooks: false;\n};\n\ntype PreValidationHookConfig = {\n address: Address;\n entityId: number;\n hookType: HookType.VALIDATION;\n hasPreHooks: true;\n hasPostHooks: false;\n};\n\ntype RawHooks = {\n [HookIdentifier.NATIVE_TOKEN_TRANSFER]:\n | {\n hookConfig: PreExecutionHookConfig;\n initData: {\n entityId: number;\n spendLimit: bigint;\n };\n }\n | undefined;\n [HookIdentifier.ERC20_TOKEN_TRANSFER]:\n | {\n hookConfig: PreExecutionHookConfig;\n initData: {\n entityId: number;\n inputs: Array<{\n target: Address;\n hasSelectorAllowlist: boolean;\n hasERC20SpendLimit: boolean;\n erc20SpendLimit: bigint;\n selectors: Array<Hex>;\n }>;\n };\n }\n | undefined;\n [HookIdentifier.GAS_LIMIT]:\n | {\n hookConfig: PreValidationHookConfig;\n initData: {\n entityId: number;\n spendLimit: bigint;\n };\n }\n | undefined;\n [HookIdentifier.PREVAL_ALLOWLIST]:\n | {\n hookConfig: PreValidationHookConfig;\n\n initData: {\n entityId: number;\n inputs: Array<{\n target: Address;\n hasSelectorAllowlist: boolean;\n hasERC20SpendLimit: boolean;\n erc20SpendLimit: bigint;\n selectors: Array<Hex>;\n }>;\n };\n }\n | undefined;\n};\n\ntype OneOf<T extends {}[]> = T[number];\n\ntype Key = {\n publicKey: Hex;\n type: \"secp256k1\" | \"contract\";\n};\n\nexport type Permission = OneOf<\n [\n {\n // this permission allows transfer of native tokens from the account\n type: PermissionType.NATIVE_TOKEN_TRANSFER;\n data: {\n allowance: Hex;\n };\n },\n {\n // this permission allows transfer or approval of erc20 tokens from the account\n type: PermissionType.ERC20_TOKEN_TRANSFER;\n data: {\n address: Address; // erc20 token contract address\n allowance: Hex;\n };\n },\n {\n // this permissions allows the key to spend gas for UOs\n type: PermissionType.GAS_LIMIT;\n data: {\n limit: Hex;\n };\n },\n {\n // this permission grants access to all functions in a contract\n type: PermissionType.CONTRACT_ACCESS;\n data: {\n address: Address;\n };\n },\n {\n // this permission grants access to functions in the account\n type: PermissionType.ACCOUNT_FUNCTIONS;\n data: {\n functions: Hex[]; // function signatures\n };\n },\n {\n // this permission grants access to a function selector in any address or contract\n type: PermissionType.FUNCTIONS_ON_ALL_CONTRACTS;\n data: {\n functions: Hex[]; // function signatures\n };\n },\n {\n // this permission grants access to specified functions on a specific contract\n type: PermissionType.FUNCTIONS_ON_CONTRACT;\n data: {\n address: Address;\n functions: Hex[];\n };\n },\n {\n // this permission grants full access to everything\n type: PermissionType.ROOT;\n data?: never;\n }\n ]\n>;\n\ntype Hook = {\n hookConfig: HookConfig;\n initData: Hex;\n};\n\nexport class PermissionBuilder {\n private client: ModularAccountV2Client;\n private validationConfig: ValidationConfig = {\n moduleAddress: zeroAddress,\n entityId: 0, // uint32\n isGlobal: false,\n isSignatureValidation: false,\n isUserOpValidation: false,\n };\n private selectors: Hex[] = [];\n private installData: Hex = \"0x\";\n private permissions: Permission[] = [];\n private hooks: Hook[] = [];\n private nonce: bigint = 0n;\n private hasAssociatedExecHooks: boolean = false;\n private deadline: number = 0;\n\n constructor({\n client,\n key,\n entityId,\n nonce,\n selectors,\n hooks,\n deadline,\n }: {\n client: ModularAccountV2Client;\n key: Key;\n entityId: number;\n nonce: bigint;\n selectors?: Hex[];\n hooks?: Hook[];\n deadline?: number;\n }) {\n this.client = client;\n this.validationConfig = {\n moduleAddress: getDefaultSingleSignerValidationModuleAddress(\n this.client.chain\n ),\n entityId,\n isUserOpValidation: true,\n isGlobal: false,\n isSignatureValidation: false,\n };\n this.installData = SingleSignerValidationModule.encodeOnInstallData({\n entityId: entityId,\n signer: key.publicKey,\n });\n this.nonce = nonce;\n if (selectors) this.selectors = selectors;\n if (hooks) this.hooks = hooks;\n if (deadline) this.deadline = deadline;\n }\n\n addSelector({ selector }: { selector: Hex }): this {\n this.selectors.push(selector);\n return this;\n }\n\n addPermission({ permission }: { permission: Permission }): this {\n // Check 1: If we're adding root, we can't have any other permissions\n if (permission.type === PermissionType.ROOT) {\n if (this.permissions.length !== 0) {\n throw new RootPermissionOnlyError(permission);\n }\n this.permissions.push(permission);\n // Set isGlobal to true\n this.validationConfig.isGlobal = true;\n return this;\n }\n\n // Check 2: If the permission is NOT ROOT (guaranteed), ensure there is no ROOT permission set\n // Will resolve to undefined if ROOT is not found\n // NOTE: Technically this could be replaced by checking permissions[0] since it should not be possible\n // to have >1 permission with root among them\n if (this.permissions.find((p) => p.type === PermissionType.ROOT)) {\n throw new RootPermissionOnlyError(permission);\n }\n\n // Check 3: If the permission is either CONTRACT_ACCESS or FUNCTIONS_ON_CONTRACT, ensure it doesn't collide with another like it.\n if (\n permission.type === PermissionType.CONTRACT_ACCESS ||\n permission.type === PermissionType.FUNCTIONS_ON_CONTRACT\n ) {\n // Check 3.1: address must not be the account address, or the user should use the ACCOUNT_FUNCTIONS permission\n if (permission.data.address === this.client.account.address) {\n throw new AccountAddressAsTargetError(permission);\n }\n\n // Check 3.2: there must not be an existing permission with this address as a target\n const targetAddress = permission.data.address;\n const existingPermissionWithSameAddress = this.permissions.find(\n (p) =>\n (p.type === PermissionType.CONTRACT_ACCESS &&\n \"address\" in p.data &&\n p.data.address === targetAddress) ||\n (p.type === PermissionType.FUNCTIONS_ON_CONTRACT &&\n \"address\" in p.data &&\n p.data.address === targetAddress)\n );\n\n if (existingPermissionWithSameAddress) {\n throw new DuplicateTargetAddressError(permission, targetAddress);\n }\n }\n\n // Check 4: If the permission is ACCOUNT_FUNCTIONS, add selectors\n if (permission.type === PermissionType.ACCOUNT_FUNCTIONS) {\n if (permission.data.functions.length === 0) {\n throw new NoFunctionsProvidedError(permission);\n }\n this.selectors = [...this.selectors, ...permission.data.functions];\n }\n\n this.permissions.push(permission);\n return this;\n }\n\n addPermissions({ permissions }: { permissions: Permission[] }): this {\n // We could validate each permission here, but for simplicity we'll just add them\n // A better approach would be to call addPermission for each one\n permissions.forEach((permission) => {\n this.addPermission({ permission });\n });\n return this;\n }\n\n // Use for building deferred action typed data to sign\n async compileDeferred(): Promise<{\n typedData: DeferredActionTypedData;\n fullPreSignatureDeferredActionDigest: Hex;\n }> {\n // Add time range module hook via expiry\n if (this.deadline !== 0) {\n if (this.deadline < Date.now() / 1000) {\n throw new ExpiredDeadlineError(this.deadline, Date.now() / 1000);\n }\n if (this.deadline > maxUint48) {\n throw new DeadlineOverLimitError(this.deadline);\n }\n\n this.hooks.push(\n TimeRangeModule.buildHook(\n {\n entityId: this.validationConfig.entityId,\n validUntil: this.deadline,\n validAfter: 0,\n },\n getDefaultTimeRangeModuleAddress(this.client.chain)\n )\n );\n }\n\n const installValidationCall = await this.compileRaw();\n\n const { typedData } = await deferralActions(\n this.client\n ).createDeferredActionTypedDataObject({\n callData: installValidationCall,\n deadline: this.deadline,\n nonce: this.nonce,\n });\n\n const preSignatureDigest = deferralActions(\n this.client\n ).buildPreSignatureDeferredActionDigest({ typedData });\n\n // Encode additional information to build the full pre-signature digest\n const fullPreSignatureDeferredActionDigest: `0x${string}` = `0x0${\n this.hasAssociatedExecHooks ? \"1\" : \"0\"\n }${toHex(this.nonce, {\n size: 32,\n }).slice(2)}${preSignatureDigest.slice(2)}`;\n\n return {\n typedData,\n fullPreSignatureDeferredActionDigest,\n };\n }\n\n // Use for direct `installValidation()` low-level calls (maybe useless)\n async compileRaw(): Promise<Hex> {\n // Translate all permissions into raw hooks if >0\n if (this.permissions.length > 0) {\n const rawHooks = this.translatePermissions(\n this.validationConfig.entityId\n );\n // Add the translated permissions as hooks\n this.addHooks(rawHooks);\n }\n this.validateConfiguration();\n\n return await installValidationActions(this.client).encodeInstallValidation({\n validationConfig: this.validationConfig,\n selectors: this.selectors,\n installData: this.installData,\n hooks: this.hooks,\n account: this.client.account,\n });\n }\n\n // Use for compiling args to installValidation\n async compileInstallArgs(): Promise<InstallValidationParams> {\n this.validateConfiguration();\n\n return {\n validationConfig: this.validationConfig,\n selectors: this.selectors,\n installData: this.installData,\n hooks: this.hooks,\n account: this.client.account,\n };\n }\n\n private validateConfiguration(): void {\n if (\n this.validationConfig.isGlobal === false &&\n this.selectors.length === 0\n ) {\n throw new ValidationConfigUnsetError();\n }\n }\n\n // Used to translate consolidated permissions into raw unencoded hooks\n // Note entityId will be a member object later\n private translatePermissions(entityId: number): RawHooks {\n const rawHooks: RawHooks = {\n [HookIdentifier.NATIVE_TOKEN_TRANSFER]: undefined,\n [HookIdentifier.ERC20_TOKEN_TRANSFER]: undefined,\n [HookIdentifier.GAS_LIMIT]: undefined,\n [HookIdentifier.PREVAL_ALLOWLIST]: undefined,\n };\n\n this.permissions.forEach((permission) => {\n switch (permission.type) {\n case PermissionType.NATIVE_TOKEN_TRANSFER:\n // Should never be added twice, check is on addPermission(s) too\n if (rawHooks[HookIdentifier.NATIVE_TOKEN_TRANSFER] !== undefined) {\n throw new MultipleNativeTokenTransferError(permission);\n }\n rawHooks[HookIdentifier.NATIVE_TOKEN_TRANSFER] = {\n hookConfig: {\n address: getDefaultNativeTokenLimitModuleAddress(\n this.client.chain\n ),\n entityId,\n hookType: HookType.EXECUTION,\n hasPreHooks: true,\n hasPostHooks: false,\n },\n initData: {\n entityId,\n spendLimit: BigInt(permission.data.allowance),\n },\n };\n this.hasAssociatedExecHooks = true;\n break;\n case PermissionType.ERC20_TOKEN_TRANSFER:\n if (permission.data.address === zeroAddress) {\n throw new ZeroAddressError(permission);\n }\n rawHooks[HookIdentifier.ERC20_TOKEN_TRANSFER] = {\n hookConfig: {\n address: getDefaultAllowlistModuleAddress(this.client.chain),\n entityId: entityId + HALF_UINT32,\n hookType: HookType.EXECUTION,\n hasPreHooks: true,\n hasPostHooks: false,\n },\n initData: {\n entityId: entityId + HALF_UINT32,\n inputs: [\n // Add previous inputs if they exist\n ...(rawHooks[HookIdentifier.ERC20_TOKEN_TRANSFER]?.initData\n .inputs || []),\n {\n target: permission.data.address,\n hasSelectorAllowlist: false,\n hasERC20SpendLimit: true,\n erc20SpendLimit: BigInt(permission.data.allowance),\n selectors: [],\n },\n ],\n },\n };\n this.hasAssociatedExecHooks = true;\n // Also allow `approve` and `transfer` for the erc20\n rawHooks[HookIdentifier.PREVAL_ALLOWLIST] = {\n hookConfig: {\n address: getDefaultAllowlistModuleAddress(this.client.chain),\n entityId,\n hookType: HookType.VALIDATION,\n hasPreHooks: true,\n hasPostHooks: false,\n },\n initData: {\n entityId,\n inputs: [\n // Add previous inputs if they exist\n ...(rawHooks[HookIdentifier.PREVAL_ALLOWLIST]?.initData\n .inputs || []),\n {\n target: permission.data.address,\n hasSelectorAllowlist: true,\n hasERC20SpendLimit: false,\n erc20SpendLimit: 0n,\n selectors: [ERC20_APPROVE_SELECTOR, ERC20_TRANSFER_SELECTOR], // approve, transfer\n },\n ],\n },\n };\n break;\n case PermissionType.GAS_LIMIT:\n // Should only ever be added once, check is also on addPermission(s)\n if (rawHooks[HookIdentifier.GAS_LIMIT] !== undefined) {\n throw new MultipleGasLimitError(permission);\n }\n rawHooks[HookIdentifier.GAS_LIMIT] = {\n hookConfig: {\n address: getDefaultNativeTokenLimitModuleAddress(\n this.client.chain\n ),\n entityId,\n hookType: HookType.VALIDATION,\n hasPreHooks: true,\n hasPostHooks: false,\n },\n initData: {\n entityId,\n spendLimit: BigInt(permission.data.limit),\n },\n };\n break;\n case PermissionType.CONTRACT_ACCESS:\n if (permission.data.address === zeroAddress) {\n throw new ZeroAddressError(permission);\n }\n rawHooks[HookIdentifier.PREVAL_ALLOWLIST] = {\n hookConfig: {\n address: getDefaultAllowlistModuleAddress(this.client.chain),\n entityId,\n hookType: HookType.VALIDATION,\n hasPreHooks: true,\n hasPostHooks: false,\n },\n initData: {\n entityId,\n inputs: [\n // Add previous inputs if they exist\n ...(rawHooks[HookIdentifier.PREVAL_ALLOWLIST]?.initData\n .inputs || []),\n {\n target: permission.data.address,\n hasSelectorAllowlist: false,\n hasERC20SpendLimit: false,\n erc20SpendLimit: 0n,\n selectors: [],\n },\n ],\n },\n };\n break;\n case PermissionType.ACCOUNT_FUNCTIONS:\n // This is handled in add permissions\n break;\n case PermissionType.FUNCTIONS_ON_ALL_CONTRACTS:\n if (permission.data.functions.length === 0) {\n throw new NoFunctionsProvidedError(permission);\n }\n rawHooks[HookIdentifier.PREVAL_ALLOWLIST] = {\n hookConfig: {\n address: getDefaultAllowlistModuleAddress(this.client.chain),\n entityId,\n hookType: HookType.VALIDATION,\n hasPreHooks: true,\n hasPostHooks: false,\n },\n initData: {\n entityId,\n inputs: [\n // Add previous inputs if they exist\n ...(rawHooks[HookIdentifier.PREVAL_ALLOWLIST]?.initData\n .inputs || []),\n {\n target: zeroAddress,\n hasSelectorAllowlist: false,\n hasERC20SpendLimit: false,\n erc20SpendLimit: 0n,\n selectors: permission.data.functions,\n },\n ],\n },\n };\n break;\n case PermissionType.FUNCTIONS_ON_CONTRACT:\n if (permission.data.functions.length === 0) {\n throw new NoFunctionsProvidedError(permission);\n }\n if (permission.data.address === zeroAddress) {\n throw new ZeroAddressError(permission);\n }\n rawHooks[HookIdentifier.PREVAL_ALLOWLIST] = {\n hookConfig: {\n address: getDefaultAllowlistModuleAddress(this.client.chain),\n entityId,\n hookType: HookType.VALIDATION,\n hasPreHooks: true,\n hasPostHooks: false,\n },\n initData: {\n entityId,\n inputs: [\n // Add previous inputs if they exist\n ...(rawHooks[HookIdentifier.PREVAL_ALLOWLIST]?.initData\n .inputs || []),\n {\n target: permission.data.address,\n hasSelectorAllowlist: true,\n hasERC20SpendLimit: false,\n erc20SpendLimit: 0n,\n selectors: permission.data.functions,\n },\n ],\n },\n };\n break;\n case PermissionType.ROOT:\n // Root permission handled in addPermission\n break;\n default:\n assertNever(permission);\n }\n\n // isGlobal guaranteed to be false since it's only set with root permissions,\n // we must add access to execute & executeBatch if there's a preVal allowlist hook set.\n if (rawHooks[HookIdentifier.PREVAL_ALLOWLIST] !== undefined) {\n const selectorsToAdd: `0x${string}`[] = [\n ACCOUNT_EXECUTE_SELECTOR,\n ACCOUNT_EXECUTEBATCH_SELECTOR,\n ]; // execute, executeBatch\n\n // Only add the selectors if they aren't already in this.selectors\n const newSelectors = selectorsToAdd.filter(\n (selector) => !this.selectors.includes(selector)\n );\n\n this.selectors = [...this.selectors, ...newSelectors];\n }\n });\n\n return rawHooks;\n }\n\n private addHooks(rawHooks: RawHooks) {\n if (rawHooks[HookIdentifier.NATIVE_TOKEN_TRANSFER]) {\n this.hooks.push({\n hookConfig: rawHooks[HookIdentifier.NATIVE_TOKEN_TRANSFER].hookConfig,\n initData: NativeTokenLimitModule.encodeOnInstallData(\n rawHooks[HookIdentifier.NATIVE_TOKEN_TRANSFER].initData\n ),\n });\n }\n\n if (rawHooks[HookIdentifier.ERC20_TOKEN_TRANSFER]) {\n this.hooks.push({\n hookConfig: rawHooks[HookIdentifier.ERC20_TOKEN_TRANSFER].hookConfig,\n initData: AllowlistModule.encodeOnInstallData(\n rawHooks[HookIdentifier.ERC20_TOKEN_TRANSFER].initData\n ),\n });\n }\n\n if (rawHooks[HookIdentifier.GAS_LIMIT]) {\n this.hooks.push({\n hookConfig: rawHooks[HookIdentifier.GAS_LIMIT].hookConfig,\n initData: NativeTokenLimitModule.encodeOnInstallData(\n rawHooks[HookIdentifier.GAS_LIMIT].initData\n ),\n });\n }\n\n if (rawHooks[HookIdentifier.PREVAL_ALLOWLIST]) {\n this.hooks.push({\n hookConfig: rawHooks[HookIdentifier.PREVAL_ALLOWLIST].hookConfig,\n initData: AllowlistModule.encodeOnInstallData(\n rawHooks[HookIdentifier.PREVAL_ALLOWLIST].initData\n ),\n });\n }\n }\n}\n\nexport function assertNever(_valid: never): never {\n throw new UnsupportedPermissionTypeError();\n}\n"]}
@@ -0,0 +1,99 @@
1
+ import { BaseError, type Address } from "@aa-sdk/core";
2
+ import type { Permission } from "./permissionBuilder";
3
+ export declare class RootPermissionOnlyError extends BaseError {
4
+ name: string;
5
+ /**
6
+ * Constructor for initializing an error message indicating that an account could not be found to execute the specified action.
7
+ *
8
+ * @param {Permission} permission The permission trying to be added atop the root permission
9
+ */
10
+ constructor(permission: Permission);
11
+ }
12
+ export declare class AccountAddressAsTargetError extends BaseError {
13
+ name: string;
14
+ /**
15
+ * Constructor for initializing an error message indicating that account address is used as target.
16
+ *
17
+ * @param {Permission} permission The permission with account address as target
18
+ */
19
+ constructor(permission: Permission);
20
+ }
21
+ export declare class DuplicateTargetAddressError extends BaseError {
22
+ name: string;
23
+ /**
24
+ * Constructor for initializing an error message indicating duplicate target address in permissions.
25
+ *
26
+ * @param {Permission} permission The permission with duplicate target address
27
+ * @param {Address} targetAddress The duplicate target address
28
+ */
29
+ constructor(permission: Permission, targetAddress: Address);
30
+ }
31
+ export declare class NoFunctionsProvidedError extends BaseError {
32
+ name: string;
33
+ /**
34
+ * Constructor for initializing an error message indicating no functions were provided.
35
+ *
36
+ * @param {Permission} permission The permission missing functions
37
+ */
38
+ constructor(permission: Permission);
39
+ }
40
+ export declare class ExpiredDeadlineError extends BaseError {
41
+ name: string;
42
+ /**
43
+ * Constructor for initializing an error message indicating the deadline has expired.
44
+ *
45
+ * @param {number} deadline The expired deadline timestamp
46
+ * @param {number} currentTime The current timestamp
47
+ */
48
+ constructor(deadline: number, currentTime: number);
49
+ }
50
+ export declare class DeadlineOverLimitError extends BaseError {
51
+ name: string;
52
+ /**
53
+ * Constructor for initializing an error message indicating the deadline has expired.
54
+ *
55
+ * @param {number} deadline The expired deadline timestamp
56
+ */
57
+ constructor(deadline: number);
58
+ }
59
+ export declare class ValidationConfigUnsetError extends BaseError {
60
+ name: string;
61
+ /**
62
+ * Constructor for initializing an error message indicating the validation config is unset.
63
+ */
64
+ constructor();
65
+ }
66
+ export declare class MultipleNativeTokenTransferError extends BaseError {
67
+ name: string;
68
+ /**
69
+ * Constructor for initializing an error message indicating multiple native token transfer permissions.
70
+ *
71
+ * @param {Permission} permission The duplicate native token transfer permission
72
+ */
73
+ constructor(permission: Permission);
74
+ }
75
+ export declare class ZeroAddressError extends BaseError {
76
+ name: string;
77
+ /**
78
+ * Constructor for initializing an error message indicating zero address was provided.
79
+ *
80
+ * @param {Permission} permission The permission with zero address
81
+ */
82
+ constructor(permission: Permission);
83
+ }
84
+ export declare class MultipleGasLimitError extends BaseError {
85
+ name: string;
86
+ /**
87
+ * Constructor for initializing an error message indicating multiple gas limit permissions.
88
+ *
89
+ * @param {Permission} permission The duplicate gas limit permission
90
+ */
91
+ constructor(permission: Permission);
92
+ }
93
+ export declare class UnsupportedPermissionTypeError extends BaseError {
94
+ name: string;
95
+ /**
96
+ * Constructor for initializing an error message indicating an unsupported permission type.
97
+ */
98
+ constructor();
99
+ }