@account-kit/smart-contracts 4.6.1 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/src/ma-v2/abis/accountFactoryAbi.d.ts +492 -0
- package/dist/esm/src/ma-v2/abis/accountFactoryAbi.js +639 -0
- package/dist/esm/src/ma-v2/abis/accountFactoryAbi.js.map +1 -0
- package/dist/esm/src/ma-v2/abis/modularAccountAbi.d.ts +954 -0
- package/dist/esm/src/ma-v2/abis/modularAccountAbi.js +1242 -0
- package/dist/esm/src/ma-v2/abis/modularAccountAbi.js.map +1 -0
- package/dist/esm/src/ma-v2/abis/semiModularAccountBytecodeAbi.d.ts +991 -0
- package/dist/esm/src/ma-v2/abis/semiModularAccountBytecodeAbi.js +1289 -0
- package/dist/esm/src/ma-v2/abis/semiModularAccountBytecodeAbi.js.map +1 -0
- package/dist/esm/src/ma-v2/abis/semiModularAccountStorageAbi.d.ts +1001 -0
- package/dist/esm/src/ma-v2/abis/semiModularAccountStorageAbi.js +1302 -0
- package/dist/esm/src/ma-v2/abis/semiModularAccountStorageAbi.js.map +1 -0
- package/dist/esm/src/ma-v2/account/nativeSMASigner.d.ts +238 -0
- package/dist/esm/src/ma-v2/account/nativeSMASigner.js +88 -0
- package/dist/esm/src/ma-v2/account/nativeSMASigner.js.map +1 -0
- package/dist/esm/src/ma-v2/account/semiModularAccountV2.d.ts +41 -0
- package/dist/esm/src/ma-v2/account/semiModularAccountV2.js +148 -0
- package/dist/esm/src/ma-v2/account/semiModularAccountV2.js.map +1 -0
- package/dist/esm/src/ma-v2/actions/common/types.d.ts +31 -0
- package/dist/esm/src/ma-v2/actions/common/types.js +6 -0
- package/dist/esm/src/ma-v2/actions/common/types.js.map +1 -0
- package/dist/esm/src/ma-v2/actions/common/utils.d.ts +76 -0
- package/dist/esm/src/ma-v2/actions/common/utils.js +100 -0
- package/dist/esm/src/ma-v2/actions/common/utils.js.map +1 -0
- package/dist/esm/src/ma-v2/actions/install-validation/installValidation.d.ts +71 -0
- package/dist/esm/src/ma-v2/actions/install-validation/installValidation.js +109 -0
- package/dist/esm/src/ma-v2/actions/install-validation/installValidation.js.map +1 -0
- package/dist/esm/src/ma-v2/client/client.d.ts +6 -0
- package/dist/esm/src/ma-v2/client/client.js +40 -0
- package/dist/esm/src/ma-v2/client/client.js.map +1 -0
- package/dist/esm/src/ma-v2/index.d.ts +26 -0
- package/dist/esm/src/ma-v2/index.js +24 -0
- package/dist/esm/src/ma-v2/index.js.map +1 -0
- package/dist/esm/src/ma-v2/modules/allowlist-module/abis/allowlistModuleAbi.d.ts +556 -0
- package/dist/esm/src/ma-v2/modules/allowlist-module/abis/allowlistModuleAbi.js +716 -0
- package/dist/esm/src/ma-v2/modules/allowlist-module/abis/allowlistModuleAbi.js.map +1 -0
- package/dist/esm/src/ma-v2/modules/allowlist-module/module.d.ts +579 -0
- package/dist/esm/src/ma-v2/modules/allowlist-module/module.js +56 -0
- package/dist/esm/src/ma-v2/modules/allowlist-module/module.js.map +1 -0
- package/dist/esm/src/ma-v2/modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.d.ts +312 -0
- package/dist/esm/src/ma-v2/modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.js +404 -0
- package/dist/esm/src/ma-v2/modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.js.map +1 -0
- package/dist/esm/src/ma-v2/modules/native-token-limit-module/module.d.ts +322 -0
- package/dist/esm/src/ma-v2/modules/native-token-limit-module/module.js +14 -0
- package/dist/esm/src/ma-v2/modules/native-token-limit-module/module.js.map +1 -0
- package/dist/esm/src/ma-v2/modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.d.ts +186 -0
- package/dist/esm/src/ma-v2/modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.js +242 -0
- package/dist/esm/src/ma-v2/modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.js.map +1 -0
- package/dist/esm/src/ma-v2/modules/paymaster-guard-module/module.d.ts +196 -0
- package/dist/esm/src/ma-v2/modules/paymaster-guard-module/module.js +25 -0
- package/dist/esm/src/ma-v2/modules/paymaster-guard-module/module.js.map +1 -0
- package/dist/esm/src/ma-v2/modules/single-signer-validation/abis/singleSignerValidationModuleAbi.d.ts +45 -0
- package/dist/esm/src/ma-v2/modules/single-signer-validation/abis/singleSignerValidationModuleAbi.js +331 -0
- package/dist/esm/src/ma-v2/modules/single-signer-validation/abis/singleSignerValidationModuleAbi.js.map +1 -0
- package/dist/esm/src/ma-v2/modules/single-signer-validation/module.d.ts +10 -0
- package/dist/esm/src/ma-v2/modules/single-signer-validation/module.js +16 -0
- package/dist/esm/src/ma-v2/modules/single-signer-validation/module.js.map +1 -0
- package/dist/esm/src/ma-v2/modules/single-signer-validation/signer.d.ts +239 -0
- package/dist/esm/src/ma-v2/modules/single-signer-validation/signer.js +93 -0
- package/dist/esm/src/ma-v2/modules/single-signer-validation/signer.js.map +1 -0
- package/dist/esm/src/ma-v2/modules/time-range-module/abis/timeRangeModuleAbi.d.ts +229 -0
- package/dist/esm/src/ma-v2/modules/time-range-module/abis/timeRangeModuleAbi.js +296 -0
- package/dist/esm/src/ma-v2/modules/time-range-module/abis/timeRangeModuleAbi.js.map +1 -0
- package/dist/esm/src/ma-v2/modules/time-range-module/module.d.ts +245 -0
- package/dist/esm/src/ma-v2/modules/time-range-module/module.js +42 -0
- package/dist/esm/src/ma-v2/modules/time-range-module/module.js.map +1 -0
- package/dist/esm/src/ma-v2/modules/utils.d.ts +91 -0
- package/dist/esm/src/ma-v2/modules/utils.js +188 -0
- package/dist/esm/src/ma-v2/modules/utils.js.map +1 -0
- package/dist/esm/src/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.d.ts +287 -0
- package/dist/esm/src/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.js +374 -0
- package/dist/esm/src/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.js.map +1 -0
- package/dist/esm/src/ma-v2/utils.d.ts +16 -0
- package/dist/esm/src/ma-v2/utils.js +105 -0
- package/dist/esm/src/ma-v2/utils.js.map +1 -0
- package/dist/types/src/ma-v2/abis/accountFactoryAbi.d.ts +493 -0
- package/dist/types/src/ma-v2/abis/accountFactoryAbi.d.ts.map +1 -0
- package/dist/types/src/ma-v2/abis/modularAccountAbi.d.ts +955 -0
- package/dist/types/src/ma-v2/abis/modularAccountAbi.d.ts.map +1 -0
- package/dist/types/src/ma-v2/abis/semiModularAccountBytecodeAbi.d.ts +992 -0
- package/dist/types/src/ma-v2/abis/semiModularAccountBytecodeAbi.d.ts.map +1 -0
- package/dist/types/src/ma-v2/abis/semiModularAccountStorageAbi.d.ts +1002 -0
- package/dist/types/src/ma-v2/abis/semiModularAccountStorageAbi.d.ts.map +1 -0
- package/dist/types/src/ma-v2/account/nativeSMASigner.d.ts +239 -0
- package/dist/types/src/ma-v2/account/nativeSMASigner.d.ts.map +1 -0
- package/dist/types/src/ma-v2/account/semiModularAccountV2.d.ts +42 -0
- package/dist/types/src/ma-v2/account/semiModularAccountV2.d.ts.map +1 -0
- package/dist/types/src/ma-v2/actions/common/types.d.ts +32 -0
- package/dist/types/src/ma-v2/actions/common/types.d.ts.map +1 -0
- package/dist/types/src/ma-v2/actions/common/utils.d.ts +77 -0
- package/dist/types/src/ma-v2/actions/common/utils.d.ts.map +1 -0
- package/dist/types/src/ma-v2/actions/install-validation/installValidation.d.ts +72 -0
- package/dist/types/src/ma-v2/actions/install-validation/installValidation.d.ts.map +1 -0
- package/dist/types/src/ma-v2/client/client.d.ts +7 -0
- package/dist/types/src/ma-v2/client/client.d.ts.map +1 -0
- package/dist/types/src/ma-v2/index.d.ts +27 -0
- package/dist/types/src/ma-v2/index.d.ts.map +1 -0
- package/dist/types/src/ma-v2/modules/allowlist-module/abis/allowlistModuleAbi.d.ts +557 -0
- package/dist/types/src/ma-v2/modules/allowlist-module/abis/allowlistModuleAbi.d.ts.map +1 -0
- package/dist/types/src/ma-v2/modules/allowlist-module/module.d.ts +580 -0
- package/dist/types/src/ma-v2/modules/allowlist-module/module.d.ts.map +1 -0
- package/dist/types/src/ma-v2/modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.d.ts +313 -0
- package/dist/types/src/ma-v2/modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.d.ts.map +1 -0
- package/dist/types/src/ma-v2/modules/native-token-limit-module/module.d.ts +323 -0
- package/dist/types/src/ma-v2/modules/native-token-limit-module/module.d.ts.map +1 -0
- package/dist/types/src/ma-v2/modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.d.ts +187 -0
- package/dist/types/src/ma-v2/modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.d.ts.map +1 -0
- package/dist/types/src/ma-v2/modules/paymaster-guard-module/module.d.ts +197 -0
- package/dist/types/src/ma-v2/modules/paymaster-guard-module/module.d.ts.map +1 -0
- package/dist/types/src/ma-v2/modules/single-signer-validation/abis/singleSignerValidationModuleAbi.d.ts +46 -0
- package/dist/types/src/ma-v2/modules/single-signer-validation/abis/singleSignerValidationModuleAbi.d.ts.map +1 -0
- package/dist/types/src/ma-v2/modules/single-signer-validation/module.d.ts +11 -0
- package/dist/types/src/ma-v2/modules/single-signer-validation/module.d.ts.map +1 -0
- package/dist/types/src/ma-v2/modules/single-signer-validation/signer.d.ts +240 -0
- package/dist/types/src/ma-v2/modules/single-signer-validation/signer.d.ts.map +1 -0
- package/dist/types/src/ma-v2/modules/time-range-module/abis/timeRangeModuleAbi.d.ts +230 -0
- package/dist/types/src/ma-v2/modules/time-range-module/abis/timeRangeModuleAbi.d.ts.map +1 -0
- package/dist/types/src/ma-v2/modules/time-range-module/module.d.ts +246 -0
- package/dist/types/src/ma-v2/modules/time-range-module/module.d.ts.map +1 -0
- package/dist/types/src/ma-v2/modules/utils.d.ts +92 -0
- package/dist/types/src/ma-v2/modules/utils.d.ts.map +1 -0
- package/dist/types/src/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.d.ts +288 -0
- package/dist/types/src/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.d.ts.map +1 -0
- package/dist/types/src/ma-v2/utils.d.ts +17 -0
- package/dist/types/src/ma-v2/utils.d.ts.map +1 -0
- package/package.json +10 -5
- package/src/ma-v2/abis/accountFactoryAbi.ts +638 -0
- package/src/ma-v2/abis/modularAccountAbi.ts +1241 -0
- package/src/ma-v2/abis/semiModularAccountBytecodeAbi.ts +1288 -0
- package/src/ma-v2/abis/semiModularAccountStorageAbi.ts +1301 -0
- package/src/ma-v2/account/nativeSMASigner.ts +121 -0
- package/src/ma-v2/account/semiModularAccountV2.ts +289 -0
- package/src/ma-v2/actions/common/types.ts +37 -0
- package/src/ma-v2/actions/common/utils.ts +103 -0
- package/src/ma-v2/actions/install-validation/installValidation.ts +213 -0
- package/src/ma-v2/client/client.ts +74 -0
- package/src/ma-v2/index.ts +47 -0
- package/src/ma-v2/modules/allowlist-module/abis/allowlistModuleAbi.ts +715 -0
- package/src/ma-v2/modules/allowlist-module/module.ts +87 -0
- package/src/ma-v2/modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.ts +403 -0
- package/src/ma-v2/modules/native-token-limit-module/module.ts +21 -0
- package/src/ma-v2/modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.ts +241 -0
- package/src/ma-v2/modules/paymaster-guard-module/module.ts +35 -0
- package/src/ma-v2/modules/single-signer-validation/abis/singleSignerValidationModuleAbi.ts +330 -0
- package/src/ma-v2/modules/single-signer-validation/module.ts +24 -0
- package/src/ma-v2/modules/single-signer-validation/signer.ts +127 -0
- package/src/ma-v2/modules/time-range-module/abis/timeRangeModuleAbi.ts +295 -0
- package/src/ma-v2/modules/time-range-module/module.ts +63 -0
- package/src/ma-v2/modules/utils.ts +213 -0
- package/src/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.ts +373 -0
- package/src/ma-v2/utils.ts +138 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
+
import {
|
|
3
|
+
hashMessage,
|
|
4
|
+
hashTypedData,
|
|
5
|
+
concatHex,
|
|
6
|
+
type Hex,
|
|
7
|
+
type SignableMessage,
|
|
8
|
+
type TypedData,
|
|
9
|
+
type TypedDataDefinition,
|
|
10
|
+
type Chain,
|
|
11
|
+
type Address,
|
|
12
|
+
} from "viem";
|
|
13
|
+
import { getDefaultSingleSignerValidationModuleAddress } from "../utils.js";
|
|
14
|
+
|
|
15
|
+
import { packUOSignature, pack1271Signature } from "../../utils.js";
|
|
16
|
+
/**
|
|
17
|
+
* Creates an object with methods for generating a dummy signature, signing user operation hashes, signing messages, and signing typed data.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { singleSignerMessageSigner } from "@account-kit/smart-contracts";
|
|
23
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
24
|
+
*
|
|
25
|
+
* const MNEMONIC = "...":
|
|
26
|
+
*
|
|
27
|
+
* const account = createSMAV2Account({ config });
|
|
28
|
+
*
|
|
29
|
+
* const signer = LocalAccountSigner.mnemonicToAccountSigner(MNEMONIC);
|
|
30
|
+
*
|
|
31
|
+
* const messageSigner = singleSignerMessageSigner(signer, chain, account.address, account.signerEntity.entityId);
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @param {SmartAccountSigner} signer Signer to use for signing operations
|
|
35
|
+
* @param {Chain} chain Chain object for the signer
|
|
36
|
+
* @param {Address} accountAddress address of the smart account using this signer
|
|
37
|
+
* @param {number} entityId the entity id of the signing validation
|
|
38
|
+
* @returns {object} an object with methods for signing operations and managing signatures
|
|
39
|
+
*/
|
|
40
|
+
export const singleSignerMessageSigner = (
|
|
41
|
+
signer: SmartAccountSigner,
|
|
42
|
+
chain: Chain,
|
|
43
|
+
accountAddress: Address,
|
|
44
|
+
entityId: number
|
|
45
|
+
) => {
|
|
46
|
+
return {
|
|
47
|
+
getDummySignature: (): Hex => {
|
|
48
|
+
const dummyEcdsaSignature =
|
|
49
|
+
"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
|
|
50
|
+
|
|
51
|
+
return packUOSignature({
|
|
52
|
+
// orderedHookData: [],
|
|
53
|
+
validationSignature: dummyEcdsaSignature,
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
signUserOperationHash: (uoHash: Hex): Promise<Hex> => {
|
|
58
|
+
return signer.signMessage({ raw: uoHash }).then((signature: Hex) =>
|
|
59
|
+
packUOSignature({
|
|
60
|
+
// orderedHookData: [],
|
|
61
|
+
validationSignature: signature,
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
// we apply the expected 1271 packing here since the account contract will expect it
|
|
67
|
+
async signMessage({ message }: { message: SignableMessage }): Promise<Hex> {
|
|
68
|
+
const hash = await hashMessage(message);
|
|
69
|
+
|
|
70
|
+
return pack1271Signature({
|
|
71
|
+
validationSignature: await signer.signTypedData({
|
|
72
|
+
domain: {
|
|
73
|
+
chainId: Number(chain.id),
|
|
74
|
+
verifyingContract:
|
|
75
|
+
getDefaultSingleSignerValidationModuleAddress(chain),
|
|
76
|
+
salt: concatHex([`0x${"00".repeat(12)}`, accountAddress]),
|
|
77
|
+
},
|
|
78
|
+
types: {
|
|
79
|
+
ReplaySafeHash: [{ name: "hash", type: "bytes32" }],
|
|
80
|
+
},
|
|
81
|
+
message: {
|
|
82
|
+
hash,
|
|
83
|
+
},
|
|
84
|
+
primaryType: "ReplaySafeHash",
|
|
85
|
+
}),
|
|
86
|
+
entityId,
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
// TODO: maybe move "sign deferred actions" to a separate function?
|
|
91
|
+
// we don't apply the expected 1271 packing since deferred sigs use typed data sigs and don't expect the 1271 packing
|
|
92
|
+
signTypedData: async <
|
|
93
|
+
const typedData extends TypedData | Record<string, unknown>,
|
|
94
|
+
primaryType extends keyof typedData | "EIP712Domain" = keyof typedData
|
|
95
|
+
>(
|
|
96
|
+
typedDataDefinition: TypedDataDefinition<typedData, primaryType>
|
|
97
|
+
): Promise<Hex> => {
|
|
98
|
+
// the accounts domain already gives replay protection across accounts for deferred actions, so we don't need to apply another wrapping
|
|
99
|
+
const isDeferredAction =
|
|
100
|
+
typedDataDefinition?.primaryType === "DeferredAction" &&
|
|
101
|
+
typedDataDefinition?.domain?.verifyingContract === accountAddress;
|
|
102
|
+
|
|
103
|
+
const validationSignature = await signer.signTypedData({
|
|
104
|
+
domain: {
|
|
105
|
+
chainId: Number(chain.id),
|
|
106
|
+
verifyingContract:
|
|
107
|
+
getDefaultSingleSignerValidationModuleAddress(chain),
|
|
108
|
+
salt: concatHex([`0x${"00".repeat(12)}`, accountAddress]),
|
|
109
|
+
},
|
|
110
|
+
types: {
|
|
111
|
+
ReplaySafeHash: [{ name: "hash", type: "bytes32" }],
|
|
112
|
+
},
|
|
113
|
+
message: {
|
|
114
|
+
hash: await hashTypedData(typedDataDefinition),
|
|
115
|
+
},
|
|
116
|
+
primaryType: "ReplaySafeHash",
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
return isDeferredAction
|
|
120
|
+
? validationSignature
|
|
121
|
+
: pack1271Signature({
|
|
122
|
+
validationSignature,
|
|
123
|
+
entityId,
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
};
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
export const timeRangeModuleAbi = [
|
|
2
|
+
{
|
|
3
|
+
type: "function",
|
|
4
|
+
name: "moduleId",
|
|
5
|
+
inputs: [],
|
|
6
|
+
outputs: [
|
|
7
|
+
{
|
|
8
|
+
name: "",
|
|
9
|
+
type: "string",
|
|
10
|
+
internalType: "string",
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
stateMutability: "pure",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
type: "function",
|
|
17
|
+
name: "onInstall",
|
|
18
|
+
inputs: [
|
|
19
|
+
{
|
|
20
|
+
name: "data",
|
|
21
|
+
type: "bytes",
|
|
22
|
+
internalType: "bytes",
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
outputs: [],
|
|
26
|
+
stateMutability: "nonpayable",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: "function",
|
|
30
|
+
name: "onUninstall",
|
|
31
|
+
inputs: [
|
|
32
|
+
{
|
|
33
|
+
name: "data",
|
|
34
|
+
type: "bytes",
|
|
35
|
+
internalType: "bytes",
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
outputs: [],
|
|
39
|
+
stateMutability: "nonpayable",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: "function",
|
|
43
|
+
name: "preRuntimeValidationHook",
|
|
44
|
+
inputs: [
|
|
45
|
+
{
|
|
46
|
+
name: "entityId",
|
|
47
|
+
type: "uint32",
|
|
48
|
+
internalType: "uint32",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "",
|
|
52
|
+
type: "address",
|
|
53
|
+
internalType: "address",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "",
|
|
57
|
+
type: "uint256",
|
|
58
|
+
internalType: "uint256",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "",
|
|
62
|
+
type: "bytes",
|
|
63
|
+
internalType: "bytes",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "",
|
|
67
|
+
type: "bytes",
|
|
68
|
+
internalType: "bytes",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
outputs: [],
|
|
72
|
+
stateMutability: "view",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
type: "function",
|
|
76
|
+
name: "preSignatureValidationHook",
|
|
77
|
+
inputs: [
|
|
78
|
+
{
|
|
79
|
+
name: "",
|
|
80
|
+
type: "uint32",
|
|
81
|
+
internalType: "uint32",
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "",
|
|
85
|
+
type: "address",
|
|
86
|
+
internalType: "address",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "",
|
|
90
|
+
type: "bytes32",
|
|
91
|
+
internalType: "bytes32",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "",
|
|
95
|
+
type: "bytes",
|
|
96
|
+
internalType: "bytes",
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
outputs: [],
|
|
100
|
+
stateMutability: "pure",
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
type: "function",
|
|
104
|
+
name: "preUserOpValidationHook",
|
|
105
|
+
inputs: [
|
|
106
|
+
{
|
|
107
|
+
name: "entityId",
|
|
108
|
+
type: "uint32",
|
|
109
|
+
internalType: "uint32",
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: "userOp",
|
|
113
|
+
type: "tuple",
|
|
114
|
+
internalType: "struct PackedUserOperation",
|
|
115
|
+
components: [
|
|
116
|
+
{
|
|
117
|
+
name: "sender",
|
|
118
|
+
type: "address",
|
|
119
|
+
internalType: "address",
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "nonce",
|
|
123
|
+
type: "uint256",
|
|
124
|
+
internalType: "uint256",
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "initCode",
|
|
128
|
+
type: "bytes",
|
|
129
|
+
internalType: "bytes",
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "callData",
|
|
133
|
+
type: "bytes",
|
|
134
|
+
internalType: "bytes",
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "accountGasLimits",
|
|
138
|
+
type: "bytes32",
|
|
139
|
+
internalType: "bytes32",
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "preVerificationGas",
|
|
143
|
+
type: "uint256",
|
|
144
|
+
internalType: "uint256",
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "gasFees",
|
|
148
|
+
type: "bytes32",
|
|
149
|
+
internalType: "bytes32",
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: "paymasterAndData",
|
|
153
|
+
type: "bytes",
|
|
154
|
+
internalType: "bytes",
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: "signature",
|
|
158
|
+
type: "bytes",
|
|
159
|
+
internalType: "bytes",
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: "",
|
|
165
|
+
type: "bytes32",
|
|
166
|
+
internalType: "bytes32",
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
outputs: [
|
|
170
|
+
{
|
|
171
|
+
name: "",
|
|
172
|
+
type: "uint256",
|
|
173
|
+
internalType: "uint256",
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
stateMutability: "view",
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
type: "function",
|
|
180
|
+
name: "setTimeRange",
|
|
181
|
+
inputs: [
|
|
182
|
+
{
|
|
183
|
+
name: "entityId",
|
|
184
|
+
type: "uint32",
|
|
185
|
+
internalType: "uint32",
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: "validUntil",
|
|
189
|
+
type: "uint48",
|
|
190
|
+
internalType: "uint48",
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: "validAfter",
|
|
194
|
+
type: "uint48",
|
|
195
|
+
internalType: "uint48",
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
outputs: [],
|
|
199
|
+
stateMutability: "nonpayable",
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
type: "function",
|
|
203
|
+
name: "supportsInterface",
|
|
204
|
+
inputs: [
|
|
205
|
+
{
|
|
206
|
+
name: "interfaceId",
|
|
207
|
+
type: "bytes4",
|
|
208
|
+
internalType: "bytes4",
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
outputs: [
|
|
212
|
+
{
|
|
213
|
+
name: "",
|
|
214
|
+
type: "bool",
|
|
215
|
+
internalType: "bool",
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
stateMutability: "view",
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
type: "function",
|
|
222
|
+
name: "timeRanges",
|
|
223
|
+
inputs: [
|
|
224
|
+
{
|
|
225
|
+
name: "entityId",
|
|
226
|
+
type: "uint32",
|
|
227
|
+
internalType: "uint32",
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
name: "account",
|
|
231
|
+
type: "address",
|
|
232
|
+
internalType: "address",
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
outputs: [
|
|
236
|
+
{
|
|
237
|
+
name: "validUntil",
|
|
238
|
+
type: "uint48",
|
|
239
|
+
internalType: "uint48",
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: "validAfter",
|
|
243
|
+
type: "uint48",
|
|
244
|
+
internalType: "uint48",
|
|
245
|
+
},
|
|
246
|
+
],
|
|
247
|
+
stateMutability: "view",
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
type: "event",
|
|
251
|
+
name: "TimeRangeSet",
|
|
252
|
+
inputs: [
|
|
253
|
+
{
|
|
254
|
+
name: "entityId",
|
|
255
|
+
type: "uint32",
|
|
256
|
+
indexed: true,
|
|
257
|
+
internalType: "uint32",
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: "account",
|
|
261
|
+
type: "address",
|
|
262
|
+
indexed: true,
|
|
263
|
+
internalType: "address",
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
name: "validUntil",
|
|
267
|
+
type: "uint48",
|
|
268
|
+
indexed: false,
|
|
269
|
+
internalType: "uint48",
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
name: "validAfter",
|
|
273
|
+
type: "uint48",
|
|
274
|
+
indexed: false,
|
|
275
|
+
internalType: "uint48",
|
|
276
|
+
},
|
|
277
|
+
],
|
|
278
|
+
anonymous: false,
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
type: "error",
|
|
282
|
+
name: "NotImplemented",
|
|
283
|
+
inputs: [],
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
type: "error",
|
|
287
|
+
name: "TimeRangeNotValid",
|
|
288
|
+
inputs: [],
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
type: "error",
|
|
292
|
+
name: "UnexpectedDataPassed",
|
|
293
|
+
inputs: [],
|
|
294
|
+
},
|
|
295
|
+
] as const;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { encodeAbiParameters, type Hex } from "viem";
|
|
2
|
+
|
|
3
|
+
import { timeRangeModuleAbi } from "./abis/timeRangeModuleAbi.js";
|
|
4
|
+
|
|
5
|
+
export const TimeRangeModule = {
|
|
6
|
+
abi: timeRangeModuleAbi,
|
|
7
|
+
encodeOnInstallData: (args: {
|
|
8
|
+
entityId: number;
|
|
9
|
+
validUntil: number;
|
|
10
|
+
validAfter: number;
|
|
11
|
+
}): Hex => {
|
|
12
|
+
const { entityId, validUntil, validAfter } = args;
|
|
13
|
+
|
|
14
|
+
return encodeAbiParameters(
|
|
15
|
+
[
|
|
16
|
+
{
|
|
17
|
+
type: "uint32",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
type: "uint48",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: "uint48",
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
[entityId, validUntil, validAfter]
|
|
27
|
+
);
|
|
28
|
+
},
|
|
29
|
+
encodeOnUninstallData: (args: { entityId: number }): Hex => {
|
|
30
|
+
const { entityId } = args;
|
|
31
|
+
|
|
32
|
+
return encodeAbiParameters(
|
|
33
|
+
[
|
|
34
|
+
{
|
|
35
|
+
type: "uint32",
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
[entityId]
|
|
39
|
+
);
|
|
40
|
+
},
|
|
41
|
+
encodeSetTimeRange: (args: {
|
|
42
|
+
entityId: number;
|
|
43
|
+
validUntil: number;
|
|
44
|
+
validAfter: number;
|
|
45
|
+
}): Hex => {
|
|
46
|
+
const { entityId, validUntil, validAfter } = args;
|
|
47
|
+
|
|
48
|
+
return encodeAbiParameters(
|
|
49
|
+
[
|
|
50
|
+
{
|
|
51
|
+
type: "uint32",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
type: "uint48",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: "uint48",
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
[entityId, validUntil, validAfter]
|
|
61
|
+
);
|
|
62
|
+
},
|
|
63
|
+
};
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import type { Chain, Address } from "viem";
|
|
2
|
+
import {
|
|
3
|
+
arbitrum,
|
|
4
|
+
arbitrumSepolia,
|
|
5
|
+
base,
|
|
6
|
+
baseSepolia,
|
|
7
|
+
mainnet,
|
|
8
|
+
optimism,
|
|
9
|
+
optimismSepolia,
|
|
10
|
+
polygon,
|
|
11
|
+
polygonAmoy,
|
|
12
|
+
sepolia,
|
|
13
|
+
} from "@account-kit/infra";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Maps a given chain to a specific address of the webauthn validation module by its chain ID. If no direct mapping exists, it defaults to returning a specific address.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { getDefaultWebauthnValidationModuleAddress } from "@account-kit/smart-contracts";
|
|
21
|
+
* import { Chain, Address } from "viem";
|
|
22
|
+
*
|
|
23
|
+
* const chain: Chain = ...
|
|
24
|
+
* const webauthnValidationAddress: Address = getDefaultWebauthnValidationModuleAddress(chain);
|
|
25
|
+
* ```
|
|
26
|
+
* @param {Chain} chain The chain object containing the chain ID to map
|
|
27
|
+
* @returns {Address} The webauthn validation module address associated with the specified chain ID or a default address if no specific mapping exists
|
|
28
|
+
*/
|
|
29
|
+
export const getDefaultWebauthnValidationModuleAddress = (
|
|
30
|
+
chain: Chain
|
|
31
|
+
): Address => {
|
|
32
|
+
switch (chain.id) {
|
|
33
|
+
// TODO: case mekong.id:
|
|
34
|
+
case sepolia.id:
|
|
35
|
+
case baseSepolia.id:
|
|
36
|
+
case polygon.id:
|
|
37
|
+
case mainnet.id:
|
|
38
|
+
case polygonAmoy.id:
|
|
39
|
+
case optimism.id:
|
|
40
|
+
case optimismSepolia.id:
|
|
41
|
+
case arbitrum.id:
|
|
42
|
+
case arbitrumSepolia.id:
|
|
43
|
+
case base.id:
|
|
44
|
+
default:
|
|
45
|
+
return "0x0000000000001D9d34E07D9834274dF9ae575217";
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Maps a given chain to a specific address of the time range module by its chain ID. If no direct mapping exists, it defaults to returning a specific address.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* import { getDefaultTimeRangeModuleAddress } from "@account-kit/smart-contracts";
|
|
55
|
+
* import { Chain, Address } from "viem";
|
|
56
|
+
*
|
|
57
|
+
* const chain: Chain = ...
|
|
58
|
+
* const timeRangeModuleAddress: Address = getDefaultTimeRangeModuleAddress(chain);
|
|
59
|
+
* ```
|
|
60
|
+
* @param {Chain} chain The chain object containing the chain ID to map
|
|
61
|
+
* @returns {Address} The time range module address associated with the specified chain ID or a default address if no specific mapping exists
|
|
62
|
+
*/
|
|
63
|
+
export const getDefaultTimeRangeModuleAddress = (chain: Chain): Address => {
|
|
64
|
+
switch (chain.id) {
|
|
65
|
+
// TODO: case mekong.id:
|
|
66
|
+
case sepolia.id:
|
|
67
|
+
case baseSepolia.id:
|
|
68
|
+
case polygon.id:
|
|
69
|
+
case mainnet.id:
|
|
70
|
+
case polygonAmoy.id:
|
|
71
|
+
case optimism.id:
|
|
72
|
+
case optimismSepolia.id:
|
|
73
|
+
case arbitrum.id:
|
|
74
|
+
case arbitrumSepolia.id:
|
|
75
|
+
case base.id:
|
|
76
|
+
default:
|
|
77
|
+
return "0x00000000000082B8e2012be914dFA4f62A0573eA";
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Maps a given chain to a specific address of the single signer validation module by its chain ID. If no direct mapping exists, it defaults to returning a specific address.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* import { getDefaultSingleSignerValidationModuleAddress } from "@account-kit/smart-contracts";
|
|
87
|
+
* import { Chain, Address } from "viem";
|
|
88
|
+
*
|
|
89
|
+
* const chain: Chain = ...
|
|
90
|
+
* const singleSignerValidationAddress: Address = getDefaultSingleSignerValidationModuleAddress(chain);
|
|
91
|
+
* ```
|
|
92
|
+
* @param {Chain} chain The chain object containing the chain ID to map
|
|
93
|
+
* @returns {Address} The single signer validation module address associated with the specified chain ID or a default address if no specific mapping exists
|
|
94
|
+
*/
|
|
95
|
+
export const getDefaultSingleSignerValidationModuleAddress = (
|
|
96
|
+
chain: Chain
|
|
97
|
+
): Address => {
|
|
98
|
+
switch (chain.id) {
|
|
99
|
+
// TODO: case mekong.id:
|
|
100
|
+
case sepolia.id:
|
|
101
|
+
case baseSepolia.id:
|
|
102
|
+
case polygon.id:
|
|
103
|
+
case mainnet.id:
|
|
104
|
+
case polygonAmoy.id:
|
|
105
|
+
case optimism.id:
|
|
106
|
+
case optimismSepolia.id:
|
|
107
|
+
case arbitrum.id:
|
|
108
|
+
case arbitrumSepolia.id:
|
|
109
|
+
case base.id:
|
|
110
|
+
default:
|
|
111
|
+
return "0x00000000000099DE0BF6fA90dEB851E2A2df7d83";
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Maps a given chain to a specific address of the paymaster guard module by its chain ID. If no direct mapping exists, it defaults to returning a specific address.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* import { getDefaultPaymasterGuardModuleAddress } from "@account-kit/smart-contracts";
|
|
121
|
+
* import { Chain, Address } from "viem";
|
|
122
|
+
*
|
|
123
|
+
* const chain: Chain = ...
|
|
124
|
+
* const paymasterGuardAddress: Address = getDefaultPaymasterGuardModuleAddress(chain);
|
|
125
|
+
* ```
|
|
126
|
+
* @param {Chain} chain The chain object containing the chain ID to map
|
|
127
|
+
* @returns {Address} The paymaster guard module address associated with the specified chain ID or a default address if no specific mapping exists
|
|
128
|
+
*/
|
|
129
|
+
export const getDefaultPaymasterGuardModuleAddress = (
|
|
130
|
+
chain: Chain
|
|
131
|
+
): Address => {
|
|
132
|
+
switch (chain.id) {
|
|
133
|
+
// TODO: case mekong.id:
|
|
134
|
+
case sepolia.id:
|
|
135
|
+
case baseSepolia.id:
|
|
136
|
+
case polygon.id:
|
|
137
|
+
case mainnet.id:
|
|
138
|
+
case polygonAmoy.id:
|
|
139
|
+
case optimism.id:
|
|
140
|
+
case optimismSepolia.id:
|
|
141
|
+
case arbitrum.id:
|
|
142
|
+
case arbitrumSepolia.id:
|
|
143
|
+
case base.id:
|
|
144
|
+
default:
|
|
145
|
+
return "0x0000000000001aA7A7F7E29abe0be06c72FD42A1";
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Maps a given chain to a specific address of the native token limit module by its chain ID. If no direct mapping exists, it defaults to returning a specific address.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```ts
|
|
154
|
+
* import { getDefaultNativeTokenLimitModuleAddress } from "@account-kit/smart-contracts";
|
|
155
|
+
* import { Chain, Address } from "viem";
|
|
156
|
+
*
|
|
157
|
+
* const chain: Chain = ...
|
|
158
|
+
* const nativeTokenLimitAddress: Address = getDefaultNativeTokenLimitModuleAddress(chain);
|
|
159
|
+
* ```
|
|
160
|
+
* @param {Chain} chain The chain object containing the chain ID to map
|
|
161
|
+
* @returns {Address} The native token limit module address associated with the specified chain ID or a default address if no specific mapping exists
|
|
162
|
+
*/
|
|
163
|
+
export const getDefaultNativeTokenLimitModuleAddress = (
|
|
164
|
+
chain: Chain
|
|
165
|
+
): Address => {
|
|
166
|
+
switch (chain.id) {
|
|
167
|
+
// TODO: case mekong.id:
|
|
168
|
+
case sepolia.id:
|
|
169
|
+
case baseSepolia.id:
|
|
170
|
+
case polygon.id:
|
|
171
|
+
case mainnet.id:
|
|
172
|
+
case polygonAmoy.id:
|
|
173
|
+
case optimism.id:
|
|
174
|
+
case optimismSepolia.id:
|
|
175
|
+
case arbitrum.id:
|
|
176
|
+
case arbitrumSepolia.id:
|
|
177
|
+
case base.id:
|
|
178
|
+
default:
|
|
179
|
+
return "0x00000000000001e541f0D090868FBe24b59Fbe06";
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Maps a given chain to a specific address of the allowlist module by its chain ID. If no direct mapping exists, it defaults to returning a specific address.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```ts
|
|
188
|
+
* import { getDefaultAllowlistModuleAddress } from "@account-kit/smart-contracts";
|
|
189
|
+
* import { Chain, Address } from "viem";
|
|
190
|
+
*
|
|
191
|
+
* const chain: Chain = ...
|
|
192
|
+
* const allowlistModule: Address = getDefaultAllowlistModuleAddress(chain);
|
|
193
|
+
* ```
|
|
194
|
+
* @param {Chain} chain The chain object containing the chain ID to map
|
|
195
|
+
* @returns {Address} The allowlist module address associated with the specified chain ID or a default address if no specific mapping exists
|
|
196
|
+
*/
|
|
197
|
+
export const getDefaultAllowlistModuleAddress = (chain: Chain): Address => {
|
|
198
|
+
switch (chain.id) {
|
|
199
|
+
// TODO: case mekong.id:
|
|
200
|
+
case sepolia.id:
|
|
201
|
+
case baseSepolia.id:
|
|
202
|
+
case polygon.id:
|
|
203
|
+
case mainnet.id:
|
|
204
|
+
case polygonAmoy.id:
|
|
205
|
+
case optimism.id:
|
|
206
|
+
case optimismSepolia.id:
|
|
207
|
+
case arbitrum.id:
|
|
208
|
+
case arbitrumSepolia.id:
|
|
209
|
+
case base.id:
|
|
210
|
+
default:
|
|
211
|
+
return "0x0000000000002311EEE9A2B887af1F144dbb4F6e";
|
|
212
|
+
}
|
|
213
|
+
};
|