@account-kit/wallet-client 0.0.1-alpha.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.
- package/dist/esm/abi/LightAccountFactoryAbi_V1_0_1.d.ts +55 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V1_0_1.js +45 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V1_0_1.js.map +1 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V1_0_2.d.ts +55 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V1_0_2.js +45 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V1_0_2.js.map +1 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V1_1_0.d.ts +55 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V1_1_0.js +45 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V1_1_0.js.map +1 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V2_0_0.d.ts +256 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V2_0_0.js +202 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V2_0_0.js.map +1 -0
- package/dist/esm/abi/ModularAccountFactoryAbi_V2_0_0.d.ts +492 -0
- package/dist/esm/abi/ModularAccountFactoryAbi_V2_0_0.js +399 -0
- package/dist/esm/abi/ModularAccountFactoryAbi_V2_0_0.js.map +1 -0
- package/dist/esm/abi/MultiOwnerLightAccountFactoryAbi_V2_0_0.d.ts +286 -0
- package/dist/esm/abi/MultiOwnerLightAccountFactoryAbi_V2_0_0.js +225 -0
- package/dist/esm/abi/MultiOwnerLightAccountFactoryAbi_V2_0_0.js.map +1 -0
- package/dist/esm/abi/MultiOwnerModularAccountFactoryAbi_V1_0_0.d.ts +234 -0
- package/dist/esm/abi/MultiOwnerModularAccountFactoryAbi_V1_0_0.js +179 -0
- package/dist/esm/abi/MultiOwnerModularAccountFactoryAbi_V1_0_0.js.map +1 -0
- package/dist/esm/abi/MultisigModularAccountFactoryAbi_V1_0_0.d.ts +246 -0
- package/dist/esm/abi/MultisigModularAccountFactoryAbi_V1_0_0.js +182 -0
- package/dist/esm/abi/MultisigModularAccountFactoryAbi_V1_0_0.js.map +1 -0
- package/dist/esm/abi/index.d.ts +8 -0
- package/dist/esm/abi/index.js +9 -0
- package/dist/esm/abi/index.js.map +1 -0
- package/dist/esm/capabilities/index.d.ts +8 -0
- package/dist/esm/capabilities/index.js +8 -0
- package/dist/esm/capabilities/index.js.map +1 -0
- package/dist/esm/capabilities/paymaster.d.ts +3 -0
- package/dist/esm/capabilities/paymaster.js +5 -0
- package/dist/esm/capabilities/paymaster.js.map +1 -0
- package/dist/esm/capabilities/permissions/index.d.ts +98 -0
- package/dist/esm/capabilities/permissions/index.js +60 -0
- package/dist/esm/capabilities/permissions/index.js.map +1 -0
- package/dist/esm/capabilities/permissions/mav2.d.ts +36 -0
- package/dist/esm/capabilities/permissions/mav2.js +79 -0
- package/dist/esm/capabilities/permissions/mav2.js.map +1 -0
- package/dist/esm/client/actions/createAccount.d.ts +10 -0
- package/dist/esm/client/actions/createAccount.js +7 -0
- package/dist/esm/client/actions/createAccount.js.map +1 -0
- package/dist/esm/client/actions/getCallsStatus.d.ts +6 -0
- package/dist/esm/client/actions/getCallsStatus.js +7 -0
- package/dist/esm/client/actions/getCallsStatus.js.map +1 -0
- package/dist/esm/client/actions/grantPermissions.d.ts +13 -0
- package/dist/esm/client/actions/grantPermissions.js +11 -0
- package/dist/esm/client/actions/grantPermissions.js.map +1 -0
- package/dist/esm/client/actions/listAccounts.d.ts +6 -0
- package/dist/esm/client/actions/listAccounts.js +4 -0
- package/dist/esm/client/actions/listAccounts.js.map +1 -0
- package/dist/esm/client/actions/prepareCalls.d.ts +15 -0
- package/dist/esm/client/actions/prepareCalls.js +17 -0
- package/dist/esm/client/actions/prepareCalls.js.map +1 -0
- package/dist/esm/client/actions/requestAccount.d.ts +11 -0
- package/dist/esm/client/actions/requestAccount.js +28 -0
- package/dist/esm/client/actions/requestAccount.js.map +1 -0
- package/dist/esm/client/actions/sendPreparedCalls.d.ts +6 -0
- package/dist/esm/client/actions/sendPreparedCalls.js +8 -0
- package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -0
- package/dist/esm/client/actions/signMessage.d.ts +6 -0
- package/dist/esm/client/actions/signMessage.js +7 -0
- package/dist/esm/client/actions/signMessage.js.map +1 -0
- package/dist/esm/client/actions/signSignatureRequest.d.ts +10 -0
- package/dist/esm/client/actions/signSignatureRequest.js +15 -0
- package/dist/esm/client/actions/signSignatureRequest.js.map +1 -0
- package/dist/esm/client/actions/signTypedData.d.ts +6 -0
- package/dist/esm/client/actions/signTypedData.js +7 -0
- package/dist/esm/client/actions/signTypedData.js.map +1 -0
- package/dist/esm/client/client.e2e-test.d.ts +1 -0
- package/dist/esm/client/client.e2e-test.js +238 -0
- package/dist/esm/client/client.e2e-test.js.map +1 -0
- package/dist/esm/client/decorator.d.ts +24 -0
- package/dist/esm/client/decorator.js +25 -0
- package/dist/esm/client/decorator.js.map +1 -0
- package/dist/esm/client/index.d.ts +18 -0
- package/dist/esm/client/index.js +43 -0
- package/dist/esm/client/index.js.map +1 -0
- package/dist/esm/exports/index.d.ts +13 -0
- package/dist/esm/exports/index.js +18 -0
- package/dist/esm/exports/index.js.map +1 -0
- package/dist/esm/exports/internal.d.ts +13 -0
- package/dist/esm/exports/internal.js +15 -0
- package/dist/esm/exports/internal.js.map +1 -0
- package/dist/esm/isomorphic/actions/createSession.d.ts +14 -0
- package/dist/esm/isomorphic/actions/createSession.js +63 -0
- package/dist/esm/isomorphic/actions/createSession.js.map +1 -0
- package/dist/esm/isomorphic/actions/getCallsStatus.d.ts +21 -0
- package/dist/esm/isomorphic/actions/getCallsStatus.js +60 -0
- package/dist/esm/isomorphic/actions/getCallsStatus.js.map +1 -0
- package/dist/esm/isomorphic/actions/prepareCalls.d.ts +8 -0
- package/dist/esm/isomorphic/actions/prepareCalls.js +57 -0
- package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -0
- package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +8 -0
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js +43 -0
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -0
- package/dist/esm/isomorphic/client.d.ts +97 -0
- package/dist/esm/isomorphic/client.js +30 -0
- package/dist/esm/isomorphic/client.js.map +1 -0
- package/dist/esm/isomorphic/utils/createAccount.d.ts +22 -0
- package/dist/esm/isomorphic/utils/createAccount.js +32 -0
- package/dist/esm/isomorphic/utils/createAccount.js.map +1 -0
- package/dist/esm/isomorphic/utils/createDummySigner.d.ts +3 -0
- package/dist/esm/isomorphic/utils/createDummySigner.js +17 -0
- package/dist/esm/isomorphic/utils/createDummySigner.js.map +1 -0
- package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +20 -0
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js +21 -0
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +1 -0
- package/dist/esm/local/client.d.ts +3 -0
- package/dist/esm/local/client.js +89 -0
- package/dist/esm/local/client.js.map +1 -0
- package/dist/esm/remote/client.d.ts +3 -0
- package/dist/esm/remote/client.js +42 -0
- package/dist/esm/remote/client.js.map +1 -0
- package/dist/esm/rpc/request.d.ts +329 -0
- package/dist/esm/rpc/request.js +194 -0
- package/dist/esm/rpc/request.js.map +1 -0
- package/dist/esm/rpc/schema.d.ts +319 -0
- package/dist/esm/rpc/schema.js +5 -0
- package/dist/esm/rpc/schema.js.map +1 -0
- package/dist/esm/schemas.d.ts +216 -0
- package/dist/esm/schemas.js +211 -0
- package/dist/esm/schemas.js.map +1 -0
- package/dist/esm/types.d.ts +27 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils.d.ts +4 -0
- package/dist/esm/utils.js +12 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/types/abi/LightAccountFactoryAbi_V1_0_1.d.ts +56 -0
- package/dist/types/abi/LightAccountFactoryAbi_V1_0_1.d.ts.map +1 -0
- package/dist/types/abi/LightAccountFactoryAbi_V1_0_2.d.ts +56 -0
- package/dist/types/abi/LightAccountFactoryAbi_V1_0_2.d.ts.map +1 -0
- package/dist/types/abi/LightAccountFactoryAbi_V1_1_0.d.ts +56 -0
- package/dist/types/abi/LightAccountFactoryAbi_V1_1_0.d.ts.map +1 -0
- package/dist/types/abi/LightAccountFactoryAbi_V2_0_0.d.ts +257 -0
- package/dist/types/abi/LightAccountFactoryAbi_V2_0_0.d.ts.map +1 -0
- package/dist/types/abi/ModularAccountFactoryAbi_V2_0_0.d.ts +493 -0
- package/dist/types/abi/ModularAccountFactoryAbi_V2_0_0.d.ts.map +1 -0
- package/dist/types/abi/MultiOwnerLightAccountFactoryAbi_V2_0_0.d.ts +287 -0
- package/dist/types/abi/MultiOwnerLightAccountFactoryAbi_V2_0_0.d.ts.map +1 -0
- package/dist/types/abi/MultiOwnerModularAccountFactoryAbi_V1_0_0.d.ts +235 -0
- package/dist/types/abi/MultiOwnerModularAccountFactoryAbi_V1_0_0.d.ts.map +1 -0
- package/dist/types/abi/MultisigModularAccountFactoryAbi_V1_0_0.d.ts +247 -0
- package/dist/types/abi/MultisigModularAccountFactoryAbi_V1_0_0.d.ts.map +1 -0
- package/dist/types/abi/index.d.ts +9 -0
- package/dist/types/abi/index.d.ts.map +1 -0
- package/dist/types/capabilities/index.d.ts +9 -0
- package/dist/types/capabilities/index.d.ts.map +1 -0
- package/dist/types/capabilities/paymaster.d.ts +4 -0
- package/dist/types/capabilities/paymaster.d.ts.map +1 -0
- package/dist/types/capabilities/permissions/index.d.ts +99 -0
- package/dist/types/capabilities/permissions/index.d.ts.map +1 -0
- package/dist/types/capabilities/permissions/mav2.d.ts +37 -0
- package/dist/types/capabilities/permissions/mav2.d.ts.map +1 -0
- package/dist/types/client/actions/createAccount.d.ts +11 -0
- package/dist/types/client/actions/createAccount.d.ts.map +1 -0
- package/dist/types/client/actions/getCallsStatus.d.ts +7 -0
- package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -0
- package/dist/types/client/actions/grantPermissions.d.ts +14 -0
- package/dist/types/client/actions/grantPermissions.d.ts.map +1 -0
- package/dist/types/client/actions/listAccounts.d.ts +7 -0
- package/dist/types/client/actions/listAccounts.d.ts.map +1 -0
- package/dist/types/client/actions/prepareCalls.d.ts +16 -0
- package/dist/types/client/actions/prepareCalls.d.ts.map +1 -0
- package/dist/types/client/actions/requestAccount.d.ts +12 -0
- package/dist/types/client/actions/requestAccount.d.ts.map +1 -0
- package/dist/types/client/actions/sendPreparedCalls.d.ts +7 -0
- package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -0
- package/dist/types/client/actions/signMessage.d.ts +7 -0
- package/dist/types/client/actions/signMessage.d.ts.map +1 -0
- package/dist/types/client/actions/signSignatureRequest.d.ts +11 -0
- package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -0
- package/dist/types/client/actions/signTypedData.d.ts +7 -0
- package/dist/types/client/actions/signTypedData.d.ts.map +1 -0
- package/dist/types/client/client.e2e-test.d.ts +2 -0
- package/dist/types/client/client.e2e-test.d.ts.map +1 -0
- package/dist/types/client/decorator.d.ts +25 -0
- package/dist/types/client/decorator.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +19 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/exports/index.d.ts +14 -0
- package/dist/types/exports/index.d.ts.map +1 -0
- package/dist/types/exports/internal.d.ts +14 -0
- package/dist/types/exports/internal.d.ts.map +1 -0
- package/dist/types/isomorphic/actions/createSession.d.ts +15 -0
- package/dist/types/isomorphic/actions/createSession.d.ts.map +1 -0
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts +22 -0
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +1 -0
- package/dist/types/isomorphic/actions/prepareCalls.d.ts +9 -0
- package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +1 -0
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +9 -0
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -0
- package/dist/types/isomorphic/client.d.ts +98 -0
- package/dist/types/isomorphic/client.d.ts.map +1 -0
- package/dist/types/isomorphic/utils/createAccount.d.ts +23 -0
- package/dist/types/isomorphic/utils/createAccount.d.ts.map +1 -0
- package/dist/types/isomorphic/utils/createDummySigner.d.ts +4 -0
- package/dist/types/isomorphic/utils/createDummySigner.d.ts.map +1 -0
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +21 -0
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +1 -0
- package/dist/types/local/client.d.ts +4 -0
- package/dist/types/local/client.d.ts.map +1 -0
- package/dist/types/remote/client.d.ts +4 -0
- package/dist/types/remote/client.d.ts.map +1 -0
- package/dist/types/rpc/request.d.ts +330 -0
- package/dist/types/rpc/request.d.ts.map +1 -0
- package/dist/types/rpc/schema.d.ts +320 -0
- package/dist/types/rpc/schema.d.ts.map +1 -0
- package/dist/types/schemas.d.ts +217 -0
- package/dist/types/schemas.d.ts.map +1 -0
- package/dist/types/types.d.ts +28 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils.d.ts +5 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/package.json +67 -0
- package/src/abi/LightAccountFactoryAbi_V1_0_1.ts +44 -0
- package/src/abi/LightAccountFactoryAbi_V1_0_2.ts +44 -0
- package/src/abi/LightAccountFactoryAbi_V1_1_0.ts +44 -0
- package/src/abi/LightAccountFactoryAbi_V2_0_0.ts +201 -0
- package/src/abi/ModularAccountFactoryAbi_V2_0_0.ts +398 -0
- package/src/abi/MultiOwnerLightAccountFactoryAbi_V2_0_0.ts +224 -0
- package/src/abi/MultiOwnerModularAccountFactoryAbi_V1_0_0.ts +178 -0
- package/src/abi/MultisigModularAccountFactoryAbi_V1_0_0.ts +181 -0
- package/src/abi/index.ts +8 -0
- package/src/capabilities/index.ts +11 -0
- package/src/capabilities/paymaster.ts +5 -0
- package/src/capabilities/permissions/index.ts +124 -0
- package/src/capabilities/permissions/mav2.ts +127 -0
- package/src/client/actions/createAccount.ts +28 -0
- package/src/client/actions/getCallsStatus.ts +29 -0
- package/src/client/actions/grantPermissions.ts +48 -0
- package/src/client/actions/listAccounts.ts +18 -0
- package/src/client/actions/prepareCalls.ts +55 -0
- package/src/client/actions/requestAccount.ts +71 -0
- package/src/client/actions/sendPreparedCalls.ts +23 -0
- package/src/client/actions/signMessage.ts +32 -0
- package/src/client/actions/signSignatureRequest.ts +34 -0
- package/src/client/actions/signTypedData.ts +32 -0
- package/src/client/client.e2e-test.ts +294 -0
- package/src/client/decorator.ts +102 -0
- package/src/client/index.ts +93 -0
- package/src/exports/index.ts +32 -0
- package/src/exports/internal.ts +16 -0
- package/src/isomorphic/actions/createSession.ts +116 -0
- package/src/isomorphic/actions/getCallsStatus.ts +98 -0
- package/src/isomorphic/actions/prepareCalls.ts +99 -0
- package/src/isomorphic/actions/sendPreparedCalls.ts +95 -0
- package/src/isomorphic/client.ts +81 -0
- package/src/isomorphic/utils/createAccount.ts +58 -0
- package/src/isomorphic/utils/createDummySigner.ts +26 -0
- package/src/isomorphic/utils/parsePermissionsContext.ts +33 -0
- package/src/local/client.ts +132 -0
- package/src/remote/client.ts +67 -0
- package/src/rpc/request.ts +258 -0
- package/src/rpc/schema.ts +40 -0
- package/src/schemas.ts +257 -0
- package/src/types.ts +60 -0
- package/src/utils.ts +13 -0
package/src/schemas.ts
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FormatRegistry,
|
|
3
|
+
Type,
|
|
4
|
+
type SchemaOptions,
|
|
5
|
+
type Static,
|
|
6
|
+
} from "@sinclair/typebox";
|
|
7
|
+
import { toHex, slice, pad, concat, hexToBigInt } from "viem";
|
|
8
|
+
|
|
9
|
+
const UUID_V4_REGEX =
|
|
10
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
11
|
+
FormatRegistry.Set("uuid", (value) => UUID_V4_REGEX.test(value));
|
|
12
|
+
|
|
13
|
+
const BASE_64_URL_REGEX = /^[A-Za-z0-9_-]+$/; // Matches base64url encoded strings (without padding)
|
|
14
|
+
FormatRegistry.Set("base64url", (value) => BASE_64_URL_REGEX.test(value));
|
|
15
|
+
|
|
16
|
+
export const TypeHex = (options?: SchemaOptions) =>
|
|
17
|
+
Type.TemplateLiteral("0x${string}", options);
|
|
18
|
+
export const TypeAddress = Type.TemplateLiteral("0x${string}");
|
|
19
|
+
export const TypeUuid = Type.String({ format: "uuid" });
|
|
20
|
+
export const TypeBase64UrlEncodedString = Type.String({
|
|
21
|
+
format: "base64url",
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// BigInt is not json-serializable, so it must be encoded as a string.
|
|
25
|
+
export const TypeU256 = Type.Transform(Type.String())
|
|
26
|
+
.Decode((value) => BigInt(value))
|
|
27
|
+
.Encode((value) => toHex(value));
|
|
28
|
+
|
|
29
|
+
export const TypeU32 = Type.Transform(Type.String())
|
|
30
|
+
.Decode((value) => Number.parseInt(value, 16))
|
|
31
|
+
.Encode((value) => toHex(value));
|
|
32
|
+
|
|
33
|
+
export const TypeUserOperationRequest_v6 = Type.Object({
|
|
34
|
+
sender: TypeAddress,
|
|
35
|
+
nonce: TypeHex(),
|
|
36
|
+
initCode: Type.Union([TypeHex(), Type.Literal("0x")]),
|
|
37
|
+
callData: TypeHex(),
|
|
38
|
+
callGasLimit: TypeHex(),
|
|
39
|
+
verificationGasLimit: TypeHex(),
|
|
40
|
+
preVerificationGas: TypeHex(),
|
|
41
|
+
maxFeePerGas: TypeHex(),
|
|
42
|
+
maxPriorityFeePerGas: TypeHex(),
|
|
43
|
+
paymasterAndData: Type.Union([TypeHex(), Type.Literal("0x")]),
|
|
44
|
+
signature: TypeHex(),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export const TypeUserOperationRequest_v7 = Type.Object({
|
|
48
|
+
sender: TypeAddress,
|
|
49
|
+
nonce: TypeHex(),
|
|
50
|
+
factory: Type.Optional(TypeAddress),
|
|
51
|
+
factoryData: Type.Optional(TypeHex()),
|
|
52
|
+
callData: TypeHex(),
|
|
53
|
+
callGasLimit: TypeHex(),
|
|
54
|
+
verificationGasLimit: TypeHex(),
|
|
55
|
+
preVerificationGas: TypeHex(),
|
|
56
|
+
maxFeePerGas: TypeHex(),
|
|
57
|
+
maxPriorityFeePerGas: TypeHex(),
|
|
58
|
+
paymaster: Type.Optional(TypeAddress),
|
|
59
|
+
paymasterData: Type.Optional(TypeHex()),
|
|
60
|
+
paymasterVerificationGasLimit: Type.Optional(TypeHex()),
|
|
61
|
+
paymasterPostOpGasLimit: Type.Optional(TypeHex()),
|
|
62
|
+
signature: TypeHex(),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export const TypeWebAuthnPublicKey = Type.Object({
|
|
66
|
+
x: TypeU256,
|
|
67
|
+
y: TypeU256,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export const TypePersistedInitcode = Type.Object({
|
|
71
|
+
factoryAddress: TypeAddress,
|
|
72
|
+
initcode: Type.Union([
|
|
73
|
+
Type.Object({
|
|
74
|
+
factoryType: Type.Literal("unknown"),
|
|
75
|
+
factoryData: TypeHex(),
|
|
76
|
+
}),
|
|
77
|
+
Type.Object({
|
|
78
|
+
factoryType: Type.Union([
|
|
79
|
+
Type.Literal("LightAccountV2.0.0"),
|
|
80
|
+
Type.Literal("LightAccountV1.1.0"),
|
|
81
|
+
Type.Literal("LightAccountV1.0.2"),
|
|
82
|
+
Type.Literal("LightAccountV1.0.1"),
|
|
83
|
+
]),
|
|
84
|
+
salt: TypeU256,
|
|
85
|
+
initialOwner: TypeAddress,
|
|
86
|
+
}),
|
|
87
|
+
Type.Object({
|
|
88
|
+
factoryType: Type.Union([
|
|
89
|
+
Type.Literal("MAv1.0.0-MultiOwner"),
|
|
90
|
+
Type.Literal("LightAccountV2.0.0-MultiOwner"),
|
|
91
|
+
]),
|
|
92
|
+
salt: TypeU256,
|
|
93
|
+
initialOwners: Type.Array(TypeAddress),
|
|
94
|
+
}),
|
|
95
|
+
Type.Object({
|
|
96
|
+
factoryType: Type.Literal("MAv1.0.0-MultiSig"),
|
|
97
|
+
salt: TypeU256,
|
|
98
|
+
initialOwners: Type.Array(TypeAddress),
|
|
99
|
+
threshold: TypeU256,
|
|
100
|
+
}),
|
|
101
|
+
Type.Intersect([
|
|
102
|
+
Type.Object({
|
|
103
|
+
factoryType: Type.Literal("MAv2.0.0"),
|
|
104
|
+
salt: TypeU256,
|
|
105
|
+
}),
|
|
106
|
+
Type.Union([
|
|
107
|
+
Type.Object({
|
|
108
|
+
mav2type: Type.Literal("ma-ssv"),
|
|
109
|
+
initialOwner: TypeAddress,
|
|
110
|
+
entityId: TypeU32,
|
|
111
|
+
}),
|
|
112
|
+
Type.Object({
|
|
113
|
+
mav2type: Type.Literal("sma-b"),
|
|
114
|
+
initialOwner: TypeAddress,
|
|
115
|
+
}),
|
|
116
|
+
Type.Object({
|
|
117
|
+
mav2type: Type.Literal("ma-webauthn"),
|
|
118
|
+
initialOwner: TypeWebAuthnPublicKey,
|
|
119
|
+
entityId: TypeU32,
|
|
120
|
+
}),
|
|
121
|
+
]),
|
|
122
|
+
]),
|
|
123
|
+
]),
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
export const TypeSerializedInitcode = Type.Object({
|
|
127
|
+
factoryType: Type.Union([
|
|
128
|
+
Type.Literal("LightAccountV1.0.1"),
|
|
129
|
+
Type.Literal("LightAccountV1.0.2"),
|
|
130
|
+
Type.Literal("LightAccountV1.1.0"),
|
|
131
|
+
Type.Literal("LightAccountV2.0.0"),
|
|
132
|
+
Type.Literal("LightAccountV2.0.0-MultiOwner"),
|
|
133
|
+
Type.Literal("MAv1.0.0-MultiOwner"),
|
|
134
|
+
Type.Literal("MAv1.0.0-MultiSig"),
|
|
135
|
+
Type.Literal("MAv2.0.0-sma-b"),
|
|
136
|
+
Type.Literal("MAv2.0.0-ma-ssv"),
|
|
137
|
+
Type.Literal("MAv2.0.0-ma-webauthn"),
|
|
138
|
+
Type.Literal("unknown"),
|
|
139
|
+
]),
|
|
140
|
+
factoryAddress: TypeAddress,
|
|
141
|
+
factoryData: TypeHex(),
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
export const TypeCounterfactualInfo = Type.Intersect([
|
|
145
|
+
Type.Object({
|
|
146
|
+
accountAddress: TypeAddress,
|
|
147
|
+
}),
|
|
148
|
+
Type.Union([
|
|
149
|
+
Type.Intersect([
|
|
150
|
+
Type.Object({
|
|
151
|
+
type: Type.Literal("sca"),
|
|
152
|
+
}),
|
|
153
|
+
TypePersistedInitcode,
|
|
154
|
+
]),
|
|
155
|
+
Type.Object({
|
|
156
|
+
type: Type.Literal("7702"),
|
|
157
|
+
}),
|
|
158
|
+
]),
|
|
159
|
+
]);
|
|
160
|
+
export type TypeCounterfactualInfo = Static<typeof TypeCounterfactualInfo>;
|
|
161
|
+
|
|
162
|
+
export const TypeCreationOptions = Type.Optional(
|
|
163
|
+
Type.Union([
|
|
164
|
+
Type.Object({
|
|
165
|
+
// Optional b/c `sma-b` is the default if no accountType is specified.
|
|
166
|
+
accountType: Type.Optional(Type.Literal("sma-b")),
|
|
167
|
+
salt: Type.Optional(TypeHex()),
|
|
168
|
+
}),
|
|
169
|
+
// TODO: add more options after v0.
|
|
170
|
+
]),
|
|
171
|
+
);
|
|
172
|
+
export type TypeCreationOptions = Static<typeof TypeCreationOptions>;
|
|
173
|
+
|
|
174
|
+
export type TypeAccountType = Exclude<
|
|
175
|
+
Static<typeof TypeCreationOptions>,
|
|
176
|
+
undefined
|
|
177
|
+
>["accountType"];
|
|
178
|
+
|
|
179
|
+
export const KeySigner = Type.Object({
|
|
180
|
+
type: Type.Union([Type.Literal("secp256k1"), Type.Literal("contract")]),
|
|
181
|
+
publicKey: TypeHex(),
|
|
182
|
+
});
|
|
183
|
+
export type KeySigner = Static<typeof KeySigner>;
|
|
184
|
+
|
|
185
|
+
export const TTypedDataDefinition = Type.Transform(
|
|
186
|
+
Type.Object({
|
|
187
|
+
domain: Type.Optional(
|
|
188
|
+
Type.Object({
|
|
189
|
+
chainId: Type.Optional(Type.Number()),
|
|
190
|
+
name: Type.Optional(Type.String()),
|
|
191
|
+
salt: Type.Optional(TypeHex()),
|
|
192
|
+
verifyingContract: Type.Optional(TypeAddress),
|
|
193
|
+
version: Type.Optional(Type.String()),
|
|
194
|
+
}),
|
|
195
|
+
),
|
|
196
|
+
types: Type.Record(
|
|
197
|
+
Type.String(),
|
|
198
|
+
Type.Array(
|
|
199
|
+
Type.Object({
|
|
200
|
+
name: Type.String(),
|
|
201
|
+
type: Type.String(),
|
|
202
|
+
}),
|
|
203
|
+
),
|
|
204
|
+
),
|
|
205
|
+
primaryType: Type.String(),
|
|
206
|
+
message: Type.Record(Type.String(), Type.Unknown()),
|
|
207
|
+
}),
|
|
208
|
+
)
|
|
209
|
+
// No-op b/c Viem is happy w/ the encoded version too.
|
|
210
|
+
.Decode((it) => it)
|
|
211
|
+
// Encode the TypedDataDefinition into our json-serialized format.
|
|
212
|
+
.Encode(({ domain, types, primaryType, message }) => {
|
|
213
|
+
return {
|
|
214
|
+
domain: {
|
|
215
|
+
...domain,
|
|
216
|
+
chainId:
|
|
217
|
+
typeof domain?.chainId === "bigint"
|
|
218
|
+
? Number(domain.chainId)
|
|
219
|
+
: domain?.chainId,
|
|
220
|
+
},
|
|
221
|
+
types,
|
|
222
|
+
primaryType,
|
|
223
|
+
message: JSON.parse(
|
|
224
|
+
JSON.stringify(message, (_, v) =>
|
|
225
|
+
typeof v === "bigint" ? toHex(v) : v,
|
|
226
|
+
),
|
|
227
|
+
),
|
|
228
|
+
};
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
export const TypeSignatureRequest = Type.Union([
|
|
232
|
+
Type.Object({
|
|
233
|
+
type: Type.Literal("personal_sign"),
|
|
234
|
+
data: Type.Union([
|
|
235
|
+
Type.String({ minLength: 1 }),
|
|
236
|
+
Type.Object({
|
|
237
|
+
raw: TypeHex(),
|
|
238
|
+
}),
|
|
239
|
+
]),
|
|
240
|
+
}),
|
|
241
|
+
Type.Object({
|
|
242
|
+
type: Type.Literal("eth_signTypedData_v4"),
|
|
243
|
+
data: TTypedDataDefinition,
|
|
244
|
+
}),
|
|
245
|
+
]);
|
|
246
|
+
|
|
247
|
+
export const TypeCallId = Type.Transform(TypeHex())
|
|
248
|
+
.Decode((value) => {
|
|
249
|
+
return {
|
|
250
|
+
chainId: toHex(hexToBigInt(slice(value, 0, 32))),
|
|
251
|
+
hash: slice(value, 32),
|
|
252
|
+
};
|
|
253
|
+
})
|
|
254
|
+
.Encode(({ chainId, hash }) => {
|
|
255
|
+
const chainIdPadded = pad(chainId, { size: 32 });
|
|
256
|
+
return concat([chainIdPadded, hash]);
|
|
257
|
+
});
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { AlchemyTransport } from "@account-kit/infra";
|
|
2
|
+
import type {
|
|
3
|
+
Address,
|
|
4
|
+
Chain,
|
|
5
|
+
Client,
|
|
6
|
+
Hex,
|
|
7
|
+
IsUndefined,
|
|
8
|
+
JsonRpcAccount,
|
|
9
|
+
Transport,
|
|
10
|
+
} from "viem";
|
|
11
|
+
import type { WalletServerViemRpcSchema } from "./rpc/schema";
|
|
12
|
+
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
13
|
+
import type {
|
|
14
|
+
GrantPermissionsParams,
|
|
15
|
+
GrantPermissionsResult,
|
|
16
|
+
} from "./client/actions/grantPermissions";
|
|
17
|
+
|
|
18
|
+
export type CreateInnerClientParams<
|
|
19
|
+
TAccount extends JsonRpcAccount<Address> | undefined =
|
|
20
|
+
| JsonRpcAccount<Address>
|
|
21
|
+
| undefined,
|
|
22
|
+
> = {
|
|
23
|
+
chain: Chain;
|
|
24
|
+
transport: AlchemyTransport;
|
|
25
|
+
policyId?: string;
|
|
26
|
+
} & (IsUndefined<TAccount> extends true
|
|
27
|
+
? {
|
|
28
|
+
account?: never;
|
|
29
|
+
}
|
|
30
|
+
: {
|
|
31
|
+
account: Address;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export type InnerWalletApiClientBase<
|
|
35
|
+
TAccount extends JsonRpcAccount<Address> | undefined =
|
|
36
|
+
| JsonRpcAccount<Address>
|
|
37
|
+
| undefined,
|
|
38
|
+
TExtend extends { [key: string]: unknown } | undefined =
|
|
39
|
+
| { [key: string]: unknown }
|
|
40
|
+
| undefined,
|
|
41
|
+
> = Client<
|
|
42
|
+
Transport,
|
|
43
|
+
Chain,
|
|
44
|
+
TAccount,
|
|
45
|
+
WalletServerViemRpcSchema,
|
|
46
|
+
{ policyId?: string } & TExtend
|
|
47
|
+
>;
|
|
48
|
+
|
|
49
|
+
export type InnerClientActions = {
|
|
50
|
+
grantPermissions: (
|
|
51
|
+
signer: SmartAccountSigner,
|
|
52
|
+
params: GrantPermissionsParams & { chainId: Hex },
|
|
53
|
+
) => Promise<GrantPermissionsResult>;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type InnerWalletApiClient<
|
|
57
|
+
TAccount extends JsonRpcAccount<Address> | undefined =
|
|
58
|
+
| JsonRpcAccount<Address>
|
|
59
|
+
| undefined,
|
|
60
|
+
> = InnerWalletApiClientBase<TAccount, InnerClientActions>;
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isHex, toHex, type Hex } from "viem";
|
|
2
|
+
|
|
3
|
+
export const assertNever = (_val: never, msg: string): never => {
|
|
4
|
+
throw new Error(msg);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
/** If the value is already Hex, it is returned unchanged. If it's a string, number or bigint, it's converted. */
|
|
8
|
+
export const castToHex = (val: string | number | bigint | Hex): Hex => {
|
|
9
|
+
if (isHex(val)) {
|
|
10
|
+
return val;
|
|
11
|
+
}
|
|
12
|
+
return toHex(val);
|
|
13
|
+
};
|