@account-kit/wallet-client 0.1.0-alpha.5 → 0.1.0-alpha.6
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/capabilities/eip7702Auth.js +3 -1
- package/dist/esm/capabilities/eip7702Auth.js.map +1 -1
- package/dist/esm/capabilities/overrides.js +8 -8
- package/dist/esm/capabilities/overrides.js.map +1 -1
- package/dist/esm/capabilities/permissions/index.d.ts +1 -1
- package/dist/esm/capabilities/permissions/index.js +6 -3
- package/dist/esm/capabilities/permissions/index.js.map +1 -1
- package/dist/esm/client/actions/grantPermissions.d.ts +5 -60
- package/dist/esm/client/actions/grantPermissions.js +5 -58
- package/dist/esm/client/actions/grantPermissions.js.map +1 -1
- package/dist/esm/client/actions/sendPreparedCalls.d.ts +6 -14
- package/dist/esm/client/actions/sendPreparedCalls.js +11 -12
- package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/client/actions/signPreparedCalls.d.ts +14 -0
- package/dist/esm/client/actions/signPreparedCalls.js +53 -0
- package/dist/esm/client/actions/signPreparedCalls.js.map +1 -0
- package/dist/esm/client/actions/signSignatureRequest.d.ts +8 -7
- package/dist/esm/client/actions/signSignatureRequest.js +69 -31
- package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
- package/dist/esm/client/client.e2e-test.js +28 -25
- package/dist/esm/client/client.e2e-test.js.map +1 -1
- package/dist/esm/client/decorator.d.ts +3 -1
- package/dist/esm/client/decorator.js +3 -1
- package/dist/esm/client/decorator.js.map +1 -1
- package/dist/esm/exports/index.d.ts +2 -1
- package/dist/esm/exports/index.js +2 -1
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/isomorphic/actions/createSession.js +18 -32
- package/dist/esm/isomorphic/actions/createSession.js.map +1 -1
- package/dist/esm/isomorphic/actions/prepareCalls.js +22 -16
- package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -1
- package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +3 -3
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js +76 -36
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/isomorphic/client.d.ts +139 -13
- package/dist/esm/isomorphic/utils/7702.d.ts +4 -3
- package/dist/esm/isomorphic/utils/7702.js +14 -6
- package/dist/esm/isomorphic/utils/7702.js.map +1 -1
- package/dist/esm/isomorphic/utils/decodeSignature.d.ts +3 -0
- package/dist/esm/isomorphic/utils/decodeSignature.js +13 -0
- package/dist/esm/isomorphic/utils/decodeSignature.js.map +1 -0
- package/dist/esm/local/client.js +2 -3
- package/dist/esm/local/client.js.map +1 -1
- package/dist/esm/remote/client.js +3 -7
- package/dist/esm/remote/client.js.map +1 -1
- package/dist/esm/rpc/examples.d.ts +3 -3
- package/dist/esm/rpc/examples.js +3 -3
- package/dist/esm/rpc/examples.js.map +1 -1
- package/dist/esm/rpc/request.d.ts +357 -49
- package/dist/esm/rpc/request.js +26 -53
- package/dist/esm/rpc/request.js.map +1 -1
- package/dist/esm/rpc/schema.d.ts +323 -57
- package/dist/esm/rpc/schema.js.map +1 -1
- package/dist/esm/schemas.d.ts +451 -13
- package/dist/esm/schemas.js +165 -52
- package/dist/esm/schemas.js.map +1 -1
- package/dist/esm/types.d.ts +3 -0
- package/dist/esm/types.js.map +1 -1
- package/dist/types/capabilities/eip7702Auth.d.ts.map +1 -1
- package/dist/types/capabilities/permissions/index.d.ts +1 -1
- package/dist/types/capabilities/permissions/index.d.ts.map +1 -1
- package/dist/types/client/actions/grantPermissions.d.ts +5 -60
- package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
- package/dist/types/client/actions/sendPreparedCalls.d.ts +6 -14
- package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/client/actions/signPreparedCalls.d.ts +15 -0
- package/dist/types/client/actions/signPreparedCalls.d.ts.map +1 -0
- package/dist/types/client/actions/signSignatureRequest.d.ts +8 -7
- package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
- package/dist/types/client/decorator.d.ts +3 -1
- package/dist/types/client/decorator.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +2 -1
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/createSession.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +3 -3
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/isomorphic/client.d.ts +139 -13
- package/dist/types/isomorphic/client.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/7702.d.ts +4 -3
- package/dist/types/isomorphic/utils/7702.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/decodeSignature.d.ts +4 -0
- package/dist/types/isomorphic/utils/decodeSignature.d.ts.map +1 -0
- package/dist/types/remote/client.d.ts.map +1 -1
- package/dist/types/rpc/examples.d.ts +3 -3
- package/dist/types/rpc/examples.d.ts.map +1 -1
- package/dist/types/rpc/request.d.ts +357 -49
- package/dist/types/rpc/request.d.ts.map +1 -1
- package/dist/types/rpc/schema.d.ts +323 -57
- package/dist/types/rpc/schema.d.ts.map +1 -1
- package/dist/types/schemas.d.ts +451 -13
- package/dist/types/schemas.d.ts.map +1 -1
- package/dist/types/types.d.ts +3 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/capabilities/eip7702Auth.ts +17 -10
- package/src/capabilities/overrides.ts +8 -8
- package/src/capabilities/permissions/index.ts +8 -3
- package/src/client/actions/grantPermissions.ts +5 -60
- package/src/client/actions/sendPreparedCalls.ts +17 -17
- package/src/client/actions/signPreparedCalls.ts +71 -0
- package/src/client/actions/signSignatureRequest.ts +50 -46
- package/src/client/client.e2e-test.ts +32 -35
- package/src/client/decorator.ts +14 -5
- package/src/exports/index.ts +2 -1
- package/src/isomorphic/actions/createSession.ts +20 -42
- package/src/isomorphic/actions/prepareCalls.ts +25 -17
- package/src/isomorphic/actions/sendPreparedCalls.ts +104 -54
- package/src/isomorphic/utils/7702.ts +18 -8
- package/src/isomorphic/utils/decodeSignature.ts +18 -0
- package/src/local/client.ts +2 -6
- package/src/remote/client.ts +3 -10
- package/src/rpc/examples.ts +3 -4
- package/src/rpc/request.ts +41 -63
- package/src/rpc/schema.ts +2 -2
- package/src/schemas.ts +227 -53
- package/src/types.ts +4 -0
|
@@ -10,7 +10,9 @@ export const Eip7702AuthCapability = Type.Union([
|
|
|
10
10
|
...SUPPORTED_DELEGATION_ADDRESSES.map((address) => Type.Literal(address)),
|
|
11
11
|
...EIP_7702_ACCOUNT_TYPE.map((it) => Type.Literal(it)),
|
|
12
12
|
]),
|
|
13
|
+
}, {
|
|
14
|
+
description: "Specify EIP-7702 delegation",
|
|
13
15
|
}),
|
|
14
|
-
Type.Literal(true),
|
|
16
|
+
Type.Literal(true, { description: "Default EIP-7702 delegation" }),
|
|
15
17
|
]);
|
|
16
18
|
//# sourceMappingURL=eip7702Auth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eip7702Auth.js","sourceRoot":"","sources":["../../../src/capabilities/eip7702Auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACL,qBAAqB,EACrB,8BAA8B,GAC/B,MAAM,6BAA6B,CAAC;AAErC,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC,KAAK,CAAC;IAC9C,IAAI,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"eip7702Auth.js","sourceRoot":"","sources":["../../../src/capabilities/eip7702Auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACL,qBAAqB,EACrB,8BAA8B,GAC/B,MAAM,6BAA6B,CAAC;AAErC,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC,KAAK,CAAC;IAC9C,IAAI,CAAC,MAAM,CACT;QACE,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;QACnC,+EAA+E;QAC/E,4HAA4H;QAC5H,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC;YACrB,GAAG,8BAA8B,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAChD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CACtB;YACD,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;SACvD,CAAC;KACH,EACD;QACE,WAAW,EAAE,6BAA6B;KAC3C,CACF;IACD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;CACnE,CAAC,CAAC","sourcesContent":["import { Type } from \"@sinclair/typebox\";\nimport { TypeAddress } from \"../schemas.js\";\nimport {\n EIP_7702_ACCOUNT_TYPE,\n SUPPORTED_DELEGATION_ADDRESSES,\n} from \"../isomorphic/utils/7702.js\";\n\nexport const Eip7702AuthCapability = Type.Union([\n Type.Object(\n {\n account: Type.Optional(TypeAddress),\n // Wallet applications must maintain a strict shortlist of well-known accounts.\n // https://github.com/ethereum/ERCs/pull/947/files#diff-dab085f963ca621595044bcbc0922705aa38b69f5bf8770dcb3d0496a633efcfR189\n delegation: Type.Union([\n ...SUPPORTED_DELEGATION_ADDRESSES.map((address) =>\n Type.Literal(address),\n ),\n ...EIP_7702_ACCOUNT_TYPE.map((it) => Type.Literal(it)),\n ]),\n },\n {\n description: \"Specify EIP-7702 delegation\",\n },\n ),\n Type.Literal(true, { description: \"Default EIP-7702 delegation\" }),\n]);\n"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Type } from "@sinclair/typebox";
|
|
2
2
|
import { TypeHex } from "../schemas.js";
|
|
3
|
-
export const Mutliplier = Type.Object({ multiplier: Type.Number() }, {
|
|
3
|
+
export const Mutliplier = Type.Object({ multiplier: Type.Number() }, { description: "Multiplier" });
|
|
4
4
|
// This is still being defined in https://github.com/ethereum/ERCs/pull/947/files#diff-dab085f963ca621595044bcbc0922705aa38b69f5bf8770dcb3d0496a633efcfR158
|
|
5
5
|
export const GasParamsOverrideCapability = Type.Object({
|
|
6
|
-
preVerificationGas: Type.Optional(Type.Union([TypeHex({
|
|
7
|
-
verificationGasLimit: Type.Optional(Type.Union([TypeHex({
|
|
8
|
-
callGasLimit: Type.Optional(Type.Union([TypeHex({
|
|
9
|
-
paymasterVerificationGasLimit: Type.Optional(Type.Union([TypeHex({
|
|
10
|
-
paymasterPostOpGasLimit: Type.Optional(Type.Union([TypeHex({
|
|
11
|
-
maxFeePerGas: Type.Optional(Type.Union([TypeHex({
|
|
12
|
-
maxPriorityFeePerGas: Type.Optional(Type.Union([TypeHex({
|
|
6
|
+
preVerificationGas: Type.Optional(Type.Union([TypeHex({ description: "Absolute" }), Mutliplier])),
|
|
7
|
+
verificationGasLimit: Type.Optional(Type.Union([TypeHex({ description: "Absolute" }), Mutliplier])),
|
|
8
|
+
callGasLimit: Type.Optional(Type.Union([TypeHex({ description: "Absolute" }), Mutliplier])),
|
|
9
|
+
paymasterVerificationGasLimit: Type.Optional(Type.Union([TypeHex({ description: "Absolute" }), Mutliplier])),
|
|
10
|
+
paymasterPostOpGasLimit: Type.Optional(Type.Union([TypeHex({ description: "Absolute" }), Mutliplier])),
|
|
11
|
+
maxFeePerGas: Type.Optional(Type.Union([TypeHex({ description: "Absolute" }), Mutliplier])),
|
|
12
|
+
maxPriorityFeePerGas: Type.Optional(Type.Union([TypeHex({ description: "Absolute" }), Mutliplier])),
|
|
13
13
|
}, { minProperties: 1 });
|
|
14
14
|
//# sourceMappingURL=overrides.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overrides.js","sourceRoot":"","sources":["../../../src/capabilities/overrides.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CACnC,EAAE,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,EAC7B,EAAE,
|
|
1
|
+
{"version":3,"file":"overrides.js","sourceRoot":"","sources":["../../../src/capabilities/overrides.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CACnC,EAAE,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,EAC7B,EAAE,WAAW,EAAE,YAAY,EAAE,CAC9B,CAAC;AAEF,2JAA2J;AAC3J,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC,MAAM,CACpD;IACE,kBAAkB,EAAE,IAAI,CAAC,QAAQ,CAC/B,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,CAC/D;IACD,oBAAoB,EAAE,IAAI,CAAC,QAAQ,CACjC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,CAC/D;IACD,YAAY,EAAE,IAAI,CAAC,QAAQ,CACzB,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,CAC/D;IACD,6BAA6B,EAAE,IAAI,CAAC,QAAQ,CAC1C,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,CAC/D;IACD,uBAAuB,EAAE,IAAI,CAAC,QAAQ,CACpC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,CAC/D;IACD,YAAY,EAAE,IAAI,CAAC,QAAQ,CACzB,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,CAC/D;IACD,oBAAoB,EAAE,IAAI,CAAC,QAAQ,CACjC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,CAC/D;CACF,EACD,EAAE,aAAa,EAAE,CAAC,EAAE,CACrB,CAAC","sourcesContent":["import { Type } from \"@sinclair/typebox\";\nimport { TypeHex } from \"../schemas.js\";\n\nexport const Mutliplier = Type.Object(\n { multiplier: Type.Number() },\n { description: \"Multiplier\" },\n);\n\n// This is still being defined in https://github.com/ethereum/ERCs/pull/947/files#diff-dab085f963ca621595044bcbc0922705aa38b69f5bf8770dcb3d0496a633efcfR158\nexport const GasParamsOverrideCapability = Type.Object(\n {\n preVerificationGas: Type.Optional(\n Type.Union([TypeHex({ description: \"Absolute\" }), Mutliplier]),\n ),\n verificationGasLimit: Type.Optional(\n Type.Union([TypeHex({ description: \"Absolute\" }), Mutliplier]),\n ),\n callGasLimit: Type.Optional(\n Type.Union([TypeHex({ description: \"Absolute\" }), Mutliplier]),\n ),\n paymasterVerificationGasLimit: Type.Optional(\n Type.Union([TypeHex({ description: \"Absolute\" }), Mutliplier]),\n ),\n paymasterPostOpGasLimit: Type.Optional(\n Type.Union([TypeHex({ description: \"Absolute\" }), Mutliplier]),\n ),\n maxFeePerGas: Type.Optional(\n Type.Union([TypeHex({ description: \"Absolute\" }), Mutliplier]),\n ),\n maxPriorityFeePerGas: Type.Optional(\n Type.Union([TypeHex({ description: \"Absolute\" }), Mutliplier]),\n ),\n },\n { minProperties: 1 },\n);\n"]}
|
|
@@ -90,7 +90,7 @@ export declare const RemotePermission: TObject<{
|
|
|
90
90
|
}>;
|
|
91
91
|
export declare const PermissionsData: TObject<{
|
|
92
92
|
chainId: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
|
|
93
|
-
|
|
93
|
+
expirySec: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
94
94
|
key: TObject<{
|
|
95
95
|
type: import("@sinclair/typebox").TUnion<[TLiteral<"secp256k1">, TLiteral<"ecdsa">, TLiteral<"contract">]>;
|
|
96
96
|
publicKey: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
|
|
@@ -57,17 +57,20 @@ export const PermissionsArray = Type.Array(TypePermission, { minItems: 1 });
|
|
|
57
57
|
export const PermissionsContext = Type.Object({
|
|
58
58
|
context: TypeHex(),
|
|
59
59
|
}, {
|
|
60
|
-
|
|
60
|
+
description: "Permissions context",
|
|
61
61
|
});
|
|
62
62
|
export const RemotePermission = Type.Object({
|
|
63
63
|
sessionId: TypeHex(),
|
|
64
64
|
signature: TypeHex(),
|
|
65
65
|
}, {
|
|
66
|
-
|
|
66
|
+
description: "Remote permission",
|
|
67
67
|
});
|
|
68
68
|
export const PermissionsData = Type.Object({
|
|
69
69
|
chainId: TypeHex(),
|
|
70
|
-
|
|
70
|
+
expirySec: Type.Optional(Type.Integer({
|
|
71
|
+
maximum: 9999999999, // This is valid until November 20, 2286.
|
|
72
|
+
description: "Unix timestamp in seconds (0 for no expiry)",
|
|
73
|
+
})),
|
|
71
74
|
key: KeySigner,
|
|
72
75
|
permissions: PermissionsArray,
|
|
73
76
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/capabilities/permiss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;IACnB,kBAAkB;IAClB,QAAQ;IACR,yBAAyB;IACzB,cAAc;IACd,eAAe;IACf,yBAAyB;IACzB,sBAAsB;IACtB,IAAI;CACL,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;AAE5E,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAC3C;IACE,OAAO,EAAE,OAAO,EAAE;CACnB,EACD;IACE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/capabilities/permissions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EACL,IAAI,GAKL,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEnE,MAAM,UAAU,GAAG,CAKjB,UAAuB,EAAE,eAAe;AACxC,QAAqB,EAAE,4BAA4B;AACnD,IAAW,EACX,WAAmB,EACoB,EAAE;IACzC,OAAO,IAAI,CAAC,SAAS,CACnB,IAAI,CAAC,MAAM,CACT;QACE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC5B,IAAI;KACL,EACD,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,UAAU,EAAE,EAAE,CACxC,CACF;SACE,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAClB,GAAG,KAAK;QACR,IAAI,EAAE,UAAU,EAAE,gBAAgB;KACnC,CAAC,CAAC;SACF,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAClB,GAAG,KAAK;QACR,IAAI,EAAE,QAAQ,EAAE,gBAAgB;KACjC,CAAC,CAAU,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,U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S;IACd,WAAW,EAAE,gBAAgB;CAC9B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC,KAAK,CAAC;IAC9C,kBAAkB;IAClB,gBAAgB;IAChB,oFAAoF;IACpF,mBAAmB;CACpB,CAAC,CAAC","sourcesContent":["import { PermissionType } from \"@account-kit/smart-contracts/experimental\";\nimport {\n Type,\n type TLiteral,\n type TLiteralValue,\n type TObject,\n type TSchema,\n} from \"@sinclair/typebox\";\nimport { KeySigner, TypeAddress, TypeHex } from \"../../schemas.js\";\n\nconst Permission = <\n TData extends TSchema,\n TLiteralVal extends TLiteralValue,\n TType extends TLiteral<TLiteralVal>,\n>(\n typeString: TLiteralVal, // e.g., \"root\"\n typeEnum: TLiteralVal, // e.g., PermissionType.ROOT\n data: TData,\n description: string,\n): TObject<{ type: TType; data: TData }> => {\n return Type.Transform(\n Type.Object(\n {\n type: Type.Literal(typeEnum),\n data,\n },\n { description, title: `${typeString}` },\n ),\n )\n .Decode((value) => ({\n ...value,\n type: typeString, // enum → string\n }))\n .Encode((value) => ({\n ...value,\n type: typeEnum, // string → enum\n })) as never;\n};\n\nconst NativeTokenTransfer = Permission(\n \"native-token-transfer\",\n PermissionType.NATIVE_TOKEN_TRANSFER,\n Type.Object({\n allowance: TypeHex(),\n }),\n \"allows transfer of native tokens from the account\",\n);\n\nconst Erc20TokenTransfer = Permission(\n \"erc20-token-transfer\",\n PermissionType.ERC20_TOKEN_TRANSFER,\n Type.Object({\n allowance: TypeHex(),\n address: TypeAddress,\n }),\n \"allows transfer or approval of erc20 tokens from the account\",\n);\n\nconst GasLimit = Permission(\n \"gas-limit\",\n PermissionType.GAS_LIMIT,\n Type.Object({\n limit: TypeHex(),\n }),\n \"allows the key to spend gas for UOs\",\n);\n\nconst ContractAccess = Permission(\n \"contract-access\",\n PermissionType.CONTRACT_ACCESS,\n Type.Object({\n address: TypeAddress,\n }),\n \"grants access to all functions in a contract\",\n);\n\nconst AccountFunction = Permission(\n \"account-functions\",\n PermissionType.ACCOUNT_FUNCTIONS,\n Type.Object({\n functions: Type.Array(TypeHex(), { minItems: 1 }),\n }),\n \"grants access to functions in the account\",\n);\n\nconst AllExternalFunctionAccess = Permission(\n \"functions-on-all-contracts\",\n PermissionType.FUNCTIONS_ON_ALL_CONTRACTS,\n Type.Object({\n functions: Type.Array(TypeHex(), { minItems: 1 }),\n }),\n \"access to a function selector in any address or contract\",\n);\n\nconst ContractFunctionAccess = Permission(\n \"functions-on-contract\",\n PermissionType.FUNCTIONS_ON_CONTRACT,\n Type.Object({\n address: TypeAddress,\n functions: Type.Array(TypeHex(), { minItems: 1 }),\n }),\n \"grants access to specified functions on a specific contract\",\n);\n\nconst Root = Permission(\n \"root\",\n PermissionType.ROOT,\n Type.Optional(Type.Never()),\n \"grants full access to everything\",\n);\n\nexport const TypePermission = Type.Union([\n // 7715 permissions\n NativeTokenTransfer,\n Erc20TokenTransfer,\n GasLimit,\n // additional permissions\n ContractAccess,\n AccountFunction,\n AllExternalFunctionAccess,\n ContractFunctionAccess,\n Root,\n]);\n\nexport const PermissionsArray = Type.Array(TypePermission, { minItems: 1 });\n\nexport const PermissionsContext = Type.Object(\n {\n context: TypeHex(),\n },\n {\n description: \"Permissions context\",\n },\n);\n\nexport const RemotePermission = Type.Object(\n {\n sessionId: TypeHex(),\n signature: TypeHex(),\n },\n {\n description: \"Remote permission\",\n },\n);\n\nexport const PermissionsData = Type.Object({\n chainId: TypeHex(),\n expirySec: Type.Optional(\n Type.Integer({\n maximum: 9999999999, // This is valid until November 20, 2286.\n description: \"Unix timestamp in seconds (0 for no expiry)\",\n }),\n ),\n key: KeySigner,\n permissions: PermissionsArray,\n});\n\nexport const PermissionsCapability = Type.Union([\n PermissionsContext,\n RemotePermission,\n // TODO: support permissions object here instead of only context-encoded permissions\n // PermissionsData,\n]);\n"]}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { type SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
-
import type { Static } from "@sinclair/typebox";
|
|
3
2
|
import { type Address, type Hex, type IsUndefined } from "viem";
|
|
4
3
|
import type { CreateSessionParams } from "../../isomorphic/actions/createSession.ts";
|
|
5
|
-
import { TypeEip7702AuthExtendedFields } from "../../schemas.js";
|
|
6
4
|
import type { InnerWalletApiClient } from "../../types.ts";
|
|
7
5
|
export type GrantPermissionsParams<TAccount extends Address | undefined = Address | undefined> = Omit<CreateSessionParams, "account" | "chainId"> & (IsUndefined<TAccount> extends true ? {
|
|
8
6
|
account: Address;
|
|
@@ -11,7 +9,6 @@ export type GrantPermissionsParams<TAccount extends Address | undefined = Addres
|
|
|
11
9
|
});
|
|
12
10
|
export type GrantPermissionsResult = {
|
|
13
11
|
context: Hex;
|
|
14
|
-
signedAuthorization?: Static<typeof TypeEip7702AuthExtendedFields>;
|
|
15
12
|
};
|
|
16
13
|
/**
|
|
17
14
|
* Grants permissions to a smart account by creating a session.
|
|
@@ -21,14 +18,13 @@ export type GrantPermissionsResult = {
|
|
|
21
18
|
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
22
19
|
* @param {GrantPermissionsParams} params - The parameters for granting permissions
|
|
23
20
|
* @param {Address} [params.account] - The account address (required if client was not initialized with an account)
|
|
24
|
-
* @param {number} params.
|
|
21
|
+
* @param {number} params.expirySec - Unix timestamp when the permissions expire
|
|
25
22
|
* @param {object} params.key - The session key information
|
|
26
23
|
* @param {string} params.key.publicKey - The public key of the session key
|
|
27
24
|
* @param {string} params.key.type - The type of the key (e.g., "secp256k1")
|
|
28
25
|
* @param {Array} params.permissions - Array of permission objects defining what the session key can do
|
|
29
26
|
* @returns {Promise<GrantPermissionsResult>} A Promise that resolves to the result containing a context identifier
|
|
30
27
|
* @returns {Hex} result.context - A hex identifier for the granted permissions context
|
|
31
|
-
* @returns {Static<typeof TypeEip7702AuthExtendedFields>} result.signedAuthorization - The EIP-7702 authorization fields, if applicable
|
|
32
28
|
*
|
|
33
29
|
* @example
|
|
34
30
|
* // Create a session key and grant root permissions
|
|
@@ -46,7 +42,7 @@ export type GrantPermissionsResult = {
|
|
|
46
42
|
* });
|
|
47
43
|
*
|
|
48
44
|
* // Use the permissions to prepare a call
|
|
49
|
-
* const
|
|
45
|
+
* const preparedCalls = await client.prepareCalls({
|
|
50
46
|
* calls: [{ to: zeroAddress, value: "0x0" }],
|
|
51
47
|
* from: account.address,
|
|
52
48
|
* capabilities: {
|
|
@@ -58,65 +54,14 @@ export type GrantPermissionsResult = {
|
|
|
58
54
|
* });
|
|
59
55
|
*
|
|
60
56
|
* // Sign with the session key
|
|
61
|
-
* const
|
|
57
|
+
* const signedCalls = await client.signPreparedCalls(
|
|
62
58
|
* sessionKey,
|
|
63
|
-
*
|
|
59
|
+
* preparedCalls,
|
|
64
60
|
* );
|
|
65
61
|
*
|
|
66
62
|
* // Send the prepared call using the session key
|
|
67
63
|
* const result = await client.sendPreparedCalls({
|
|
68
|
-
* ...
|
|
69
|
-
* signature,
|
|
70
|
-
* capabilities: {
|
|
71
|
-
* permissions,
|
|
72
|
-
* },
|
|
73
|
-
* });
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* // Create a session key and grant root permissions using a 7702 account
|
|
77
|
-
* const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
|
|
78
|
-
* const account = await client.requestAccount({
|
|
79
|
-
* creationHint: {
|
|
80
|
-
* accountType: "7702",
|
|
81
|
-
* }
|
|
82
|
-
* });
|
|
83
|
-
*
|
|
84
|
-
* const permissions = await client.grantPermissions({
|
|
85
|
-
* account: account.address,
|
|
86
|
-
* expiry: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour from now
|
|
87
|
-
* key: {
|
|
88
|
-
* publicKey: await sessionKey.getAddress(),
|
|
89
|
-
* type: "secp256k1",
|
|
90
|
-
* },
|
|
91
|
-
* permissions: [{ type: "root" }],
|
|
92
|
-
* });
|
|
93
|
-
*
|
|
94
|
-
* // Use the permissions to prepare a call
|
|
95
|
-
* const preparedCall = await client.prepareCalls({
|
|
96
|
-
* calls: [{ to: zeroAddress, value: "0x0" }],
|
|
97
|
-
* from: account.address,
|
|
98
|
-
* capabilities: {
|
|
99
|
-
* paymasterService: {
|
|
100
|
-
* policyId: "your-paymaster-policy-id",
|
|
101
|
-
* },
|
|
102
|
-
* permissions,
|
|
103
|
-
* },
|
|
104
|
-
* });
|
|
105
|
-
*
|
|
106
|
-
* // Sign with the session key
|
|
107
|
-
* // If the 7702 account delegation is not yet installed, the result
|
|
108
|
-
* // here will include a `signedAuthorization` field that that
|
|
109
|
-
* // must be included when sending the account's first call.
|
|
110
|
-
* const { signedAuthorization, ...signature} = await signSignatureRequest(
|
|
111
|
-
* sessionKey,
|
|
112
|
-
* preparedCall.signatureRequest,
|
|
113
|
-
* );
|
|
114
|
-
*
|
|
115
|
-
* // Send the prepared call using the session key
|
|
116
|
-
* const result = await client.sendPreparedCalls({
|
|
117
|
-
* ...preparedCall,
|
|
118
|
-
* signature,
|
|
119
|
-
* signedAuthorization,
|
|
64
|
+
* ...signedCalls,
|
|
120
65
|
* capabilities: {
|
|
121
66
|
* permissions,
|
|
122
67
|
* },
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AccountNotFoundError } from "@aa-sdk/core";
|
|
2
2
|
import { toHex } from "viem";
|
|
3
|
-
import { TypeEip7702AuthExtendedFields } from "../../schemas.js";
|
|
4
3
|
/**
|
|
5
4
|
* Grants permissions to a smart account by creating a session.
|
|
6
5
|
* This allows another key to perform operations on behalf of the account.
|
|
@@ -9,14 +8,13 @@ import { TypeEip7702AuthExtendedFields } from "../../schemas.js";
|
|
|
9
8
|
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
10
9
|
* @param {GrantPermissionsParams} params - The parameters for granting permissions
|
|
11
10
|
* @param {Address} [params.account] - The account address (required if client was not initialized with an account)
|
|
12
|
-
* @param {number} params.
|
|
11
|
+
* @param {number} params.expirySec - Unix timestamp when the permissions expire
|
|
13
12
|
* @param {object} params.key - The session key information
|
|
14
13
|
* @param {string} params.key.publicKey - The public key of the session key
|
|
15
14
|
* @param {string} params.key.type - The type of the key (e.g., "secp256k1")
|
|
16
15
|
* @param {Array} params.permissions - Array of permission objects defining what the session key can do
|
|
17
16
|
* @returns {Promise<GrantPermissionsResult>} A Promise that resolves to the result containing a context identifier
|
|
18
17
|
* @returns {Hex} result.context - A hex identifier for the granted permissions context
|
|
19
|
-
* @returns {Static<typeof TypeEip7702AuthExtendedFields>} result.signedAuthorization - The EIP-7702 authorization fields, if applicable
|
|
20
18
|
*
|
|
21
19
|
* @example
|
|
22
20
|
* // Create a session key and grant root permissions
|
|
@@ -34,7 +32,7 @@ import { TypeEip7702AuthExtendedFields } from "../../schemas.js";
|
|
|
34
32
|
* });
|
|
35
33
|
*
|
|
36
34
|
* // Use the permissions to prepare a call
|
|
37
|
-
* const
|
|
35
|
+
* const preparedCalls = await client.prepareCalls({
|
|
38
36
|
* calls: [{ to: zeroAddress, value: "0x0" }],
|
|
39
37
|
* from: account.address,
|
|
40
38
|
* capabilities: {
|
|
@@ -46,65 +44,14 @@ import { TypeEip7702AuthExtendedFields } from "../../schemas.js";
|
|
|
46
44
|
* });
|
|
47
45
|
*
|
|
48
46
|
* // Sign with the session key
|
|
49
|
-
* const
|
|
47
|
+
* const signedCalls = await client.signPreparedCalls(
|
|
50
48
|
* sessionKey,
|
|
51
|
-
*
|
|
49
|
+
* preparedCalls,
|
|
52
50
|
* );
|
|
53
51
|
*
|
|
54
52
|
* // Send the prepared call using the session key
|
|
55
53
|
* const result = await client.sendPreparedCalls({
|
|
56
|
-
* ...
|
|
57
|
-
* signature,
|
|
58
|
-
* capabilities: {
|
|
59
|
-
* permissions,
|
|
60
|
-
* },
|
|
61
|
-
* });
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* // Create a session key and grant root permissions using a 7702 account
|
|
65
|
-
* const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
|
|
66
|
-
* const account = await client.requestAccount({
|
|
67
|
-
* creationHint: {
|
|
68
|
-
* accountType: "7702",
|
|
69
|
-
* }
|
|
70
|
-
* });
|
|
71
|
-
*
|
|
72
|
-
* const permissions = await client.grantPermissions({
|
|
73
|
-
* account: account.address,
|
|
74
|
-
* expiry: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour from now
|
|
75
|
-
* key: {
|
|
76
|
-
* publicKey: await sessionKey.getAddress(),
|
|
77
|
-
* type: "secp256k1",
|
|
78
|
-
* },
|
|
79
|
-
* permissions: [{ type: "root" }],
|
|
80
|
-
* });
|
|
81
|
-
*
|
|
82
|
-
* // Use the permissions to prepare a call
|
|
83
|
-
* const preparedCall = await client.prepareCalls({
|
|
84
|
-
* calls: [{ to: zeroAddress, value: "0x0" }],
|
|
85
|
-
* from: account.address,
|
|
86
|
-
* capabilities: {
|
|
87
|
-
* paymasterService: {
|
|
88
|
-
* policyId: "your-paymaster-policy-id",
|
|
89
|
-
* },
|
|
90
|
-
* permissions,
|
|
91
|
-
* },
|
|
92
|
-
* });
|
|
93
|
-
*
|
|
94
|
-
* // Sign with the session key
|
|
95
|
-
* // If the 7702 account delegation is not yet installed, the result
|
|
96
|
-
* // here will include a `signedAuthorization` field that that
|
|
97
|
-
* // must be included when sending the account's first call.
|
|
98
|
-
* const { signedAuthorization, ...signature} = await signSignatureRequest(
|
|
99
|
-
* sessionKey,
|
|
100
|
-
* preparedCall.signatureRequest,
|
|
101
|
-
* );
|
|
102
|
-
*
|
|
103
|
-
* // Send the prepared call using the session key
|
|
104
|
-
* const result = await client.sendPreparedCalls({
|
|
105
|
-
* ...preparedCall,
|
|
106
|
-
* signature,
|
|
107
|
-
* signedAuthorization,
|
|
54
|
+
* ...signedCalls,
|
|
108
55
|
* capabilities: {
|
|
109
56
|
* permissions,
|
|
110
57
|
* },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grantPermissions.js","sourceRoot":"","sources":["../../../../src/client/actions/grantPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAA2B,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"grantPermissions.js","sourceRoot":"","sources":["../../../../src/client/actions/grantPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAA2B,MAAM,cAAc,CAAC;AAC7E,OAAO,EAA4C,KAAK,EAAE,MAAM,MAAM,CAAC;AAevE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAGpC,MAA4B,EAC5B,MAA0B,EAC1B,MAAwC;IAExC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE;QACrC,GAAG,MAAM;QACT,OAAO;QACP,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;KAChC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { AccountNotFoundError, type SmartAccountSigner } from \"@aa-sdk/core\";\nimport { type Address, type Hex, type IsUndefined, toHex } from \"viem\";\nimport type { CreateSessionParams } from \"../../isomorphic/actions/createSession.ts\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\n\nexport type GrantPermissionsParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Omit<CreateSessionParams, \"account\" | \"chainId\"> &\n (IsUndefined<TAccount> extends true\n ? { account: Address }\n : { account?: never });\n\nexport type GrantPermissionsResult = {\n context: Hex;\n};\n\n/**\n * Grants permissions to a smart account by creating a session.\n * This allows another key to perform operations on behalf of the account.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer of the smart account\n * @param {GrantPermissionsParams} params - The parameters for granting permissions\n * @param {Address} [params.account] - The account address (required if client was not initialized with an account)\n * @param {number} params.expirySec - Unix timestamp when the permissions expire\n * @param {object} params.key - The session key information\n * @param {string} params.key.publicKey - The public key of the session key\n * @param {string} params.key.type - The type of the key (e.g., \"secp256k1\")\n * @param {Array} params.permissions - Array of permission objects defining what the session key can do\n * @returns {Promise<GrantPermissionsResult>} A Promise that resolves to the result containing a context identifier\n * @returns {Hex} result.context - A hex identifier for the granted permissions context\n *\n * @example\n * // Create a session key and grant root permissions\n * const sessionKey = LocalAccountSigner.generatePrivateKeySigner();\n * const account = await client.requestAccount();\n *\n * const permissions = await client.grantPermissions({\n * account: account.address,\n * expiry: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour from now\n * key: {\n * publicKey: await sessionKey.getAddress(),\n * type: \"secp256k1\",\n * },\n * permissions: [{ type: \"root\" }],\n * });\n *\n * // Use the permissions to prepare a call\n * const preparedCalls = await client.prepareCalls({\n * calls: [{ to: zeroAddress, value: \"0x0\" }],\n * from: account.address,\n * capabilities: {\n * paymasterService: {\n * policyId: \"your-paymaster-policy-id\",\n * },\n * permissions,\n * },\n * });\n *\n * // Sign with the session key\n * const signedCalls = await client.signPreparedCalls(\n * sessionKey,\n * preparedCalls,\n * );\n *\n * // Send the prepared call using the session key\n * const result = await client.sendPreparedCalls({\n * ...signedCalls,\n * capabilities: {\n * permissions,\n * },\n * });\n */\nexport async function grantPermissions<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params: GrantPermissionsParams<TAccount>,\n): Promise<GrantPermissionsResult> {\n const account = params.account ?? client.account?.address;\n\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n return client.grantPermissions(signer, {\n ...params,\n account,\n chainId: toHex(client.chain.id),\n });\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Static
|
|
1
|
+
import type { Static } from "@sinclair/typebox";
|
|
2
2
|
import type { wallet_sendPreparedCalls } from "../../rpc/request.ts";
|
|
3
|
-
import type { InnerWalletApiClient } from "../../types.ts";
|
|
4
|
-
export type SendPreparedCallsParams =
|
|
3
|
+
import type { InnerWalletApiClient, WithoutChainId } from "../../types.ts";
|
|
4
|
+
export type SendPreparedCallsParams = WithoutChainId<Static<(typeof wallet_sendPreparedCalls)["properties"]["Request"]["properties"]["params"]>[0]>;
|
|
5
5
|
export type SendPreparedCallsResult = Static<typeof wallet_sendPreparedCalls>["ReturnType"];
|
|
6
6
|
/**
|
|
7
7
|
* Sends prepared calls by submitting a signed user operation.
|
|
@@ -9,13 +9,6 @@ export type SendPreparedCallsResult = Static<typeof wallet_sendPreparedCalls>["R
|
|
|
9
9
|
*
|
|
10
10
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
11
11
|
* @param {SendPreparedCallsParams} params - Parameters for sending prepared calls
|
|
12
|
-
* @param {string} params.type - The user operation type ('user-operation-v060' or 'user-operation-v070')
|
|
13
|
-
* @param {object} params.data - The user operation data without signature
|
|
14
|
-
* @param {string} params.chainId - The chain ID in hex format
|
|
15
|
-
* @param {object} params.signature - The signature object
|
|
16
|
-
* @param {string} params.signature.type - The signature type (must be 'ecdsa')
|
|
17
|
-
* @param {string} params.signature.signature - The hex-encoded signature value
|
|
18
|
-
* @param {object} [params.capabilities] - Optional capabilities to include with the request
|
|
19
12
|
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs
|
|
20
13
|
*
|
|
21
14
|
* @example
|
|
@@ -31,13 +24,12 @@ export type SendPreparedCallsResult = Static<typeof wallet_sendPreparedCalls>["R
|
|
|
31
24
|
* }
|
|
32
25
|
* });
|
|
33
26
|
*
|
|
34
|
-
* //
|
|
35
|
-
* const
|
|
27
|
+
* // Then sign the calls
|
|
28
|
+
* const signedCalls = await client.signPreparedCalls(preparedCalls);
|
|
36
29
|
*
|
|
37
30
|
* // Then send the prepared calls with the signature
|
|
38
31
|
* const result = await client.sendPreparedCalls({
|
|
39
|
-
*
|
|
40
|
-
* signature: signedRequest.signature,
|
|
32
|
+
* signedCalls,
|
|
41
33
|
* });
|
|
42
34
|
*/
|
|
43
35
|
export declare function sendPreparedCalls(client: InnerWalletApiClient, params: SendPreparedCallsParams): Promise<SendPreparedCallsResult>;
|
|
@@ -5,13 +5,6 @@ import { toHex } from "viem";
|
|
|
5
5
|
*
|
|
6
6
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
7
7
|
* @param {SendPreparedCallsParams} params - Parameters for sending prepared calls
|
|
8
|
-
* @param {string} params.type - The user operation type ('user-operation-v060' or 'user-operation-v070')
|
|
9
|
-
* @param {object} params.data - The user operation data without signature
|
|
10
|
-
* @param {string} params.chainId - The chain ID in hex format
|
|
11
|
-
* @param {object} params.signature - The signature object
|
|
12
|
-
* @param {string} params.signature.type - The signature type (must be 'ecdsa')
|
|
13
|
-
* @param {string} params.signature.signature - The hex-encoded signature value
|
|
14
|
-
* @param {object} [params.capabilities] - Optional capabilities to include with the request
|
|
15
8
|
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs
|
|
16
9
|
*
|
|
17
10
|
* @example
|
|
@@ -27,19 +20,25 @@ import { toHex } from "viem";
|
|
|
27
20
|
* }
|
|
28
21
|
* });
|
|
29
22
|
*
|
|
30
|
-
* //
|
|
31
|
-
* const
|
|
23
|
+
* // Then sign the calls
|
|
24
|
+
* const signedCalls = await client.signPreparedCalls(preparedCalls);
|
|
32
25
|
*
|
|
33
26
|
* // Then send the prepared calls with the signature
|
|
34
27
|
* const result = await client.sendPreparedCalls({
|
|
35
|
-
*
|
|
36
|
-
* signature: signedRequest.signature,
|
|
28
|
+
* signedCalls,
|
|
37
29
|
* });
|
|
38
30
|
*/
|
|
39
31
|
export async function sendPreparedCalls(client, params) {
|
|
40
32
|
return client.request({
|
|
41
33
|
method: "wallet_sendPreparedCalls",
|
|
42
|
-
params: [
|
|
34
|
+
params: [
|
|
35
|
+
params.type === "array"
|
|
36
|
+
? params
|
|
37
|
+
: {
|
|
38
|
+
...params,
|
|
39
|
+
chainId: toHex(client.chain.id),
|
|
40
|
+
},
|
|
41
|
+
],
|
|
43
42
|
});
|
|
44
43
|
}
|
|
45
44
|
//# sourceMappingURL=sendPreparedCalls.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAc7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,MAA+B;IAE/B,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE;YACN,MAAM,CAAC,IAAI,KAAK,OAAO;gBACrB,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC;oBACE,GAAG,MAAM;oBACT,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;iBAChC;SACN;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Static } from \"@sinclair/typebox\";\nimport { toHex } from \"viem\";\nimport type { wallet_sendPreparedCalls } from \"../../rpc/request.ts\";\nimport type { InnerWalletApiClient, WithoutChainId } from \"../../types.ts\";\n\nexport type SendPreparedCallsParams = WithoutChainId<\n Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0]\n>;\n\nexport type SendPreparedCallsResult = Static<\n typeof wallet_sendPreparedCalls\n>[\"ReturnType\"];\n\n/**\n * Sends prepared calls by submitting a signed user operation.\n * This method is used after signing the signature request returned from prepareCalls.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SendPreparedCallsParams} params - Parameters for sending prepared calls\n * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs\n *\n * @example\n * // First prepare the calls\n * const preparedCalls = await client.prepareCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: \"0x0\"\n * }],\n * capabilities: {\n * paymasterService: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // Then sign the calls\n * const signedCalls = await client.signPreparedCalls(preparedCalls);\n *\n * // Then send the prepared calls with the signature\n * const result = await client.sendPreparedCalls({\n * signedCalls,\n * });\n */\nexport async function sendPreparedCalls(\n client: InnerWalletApiClient,\n params: SendPreparedCallsParams,\n): Promise<SendPreparedCallsResult> {\n return client.request({\n method: \"wallet_sendPreparedCalls\",\n params: [\n params.type === \"array\"\n ? params\n : {\n ...params,\n chainId: toHex(client.chain.id),\n },\n ],\n });\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PrepareCallsResult } from "./prepareCalls.ts";
|
|
2
|
+
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
3
|
+
import type { Static } from "@sinclair/typebox";
|
|
4
|
+
import { wallet_sendPreparedCalls } from "../../rpc/request.js";
|
|
5
|
+
export type SignPreparedCallsParams = PrepareCallsResult;
|
|
6
|
+
export type SignPreparedCallsResult = Static<(typeof wallet_sendPreparedCalls)["properties"]["Request"]["properties"]["params"]>[0];
|
|
7
|
+
/**
|
|
8
|
+
* Signs prepared calls using the provided signer.
|
|
9
|
+
*
|
|
10
|
+
* @param {SmartAccountSigner} signer - The signer to use
|
|
11
|
+
* @param {SignPreparedCallsParams} params - The prepared calls with signature requests
|
|
12
|
+
* @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls
|
|
13
|
+
**/
|
|
14
|
+
export declare function signPreparedCalls(signer: SmartAccountSigner, params: SignPreparedCallsParams): Promise<SignPreparedCallsResult>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { signSignatureRequest } from "./signSignatureRequest.js";
|
|
2
|
+
import { wallet_sendPreparedCalls } from "../../rpc/request.js";
|
|
3
|
+
import { assertNever } from "../../utils.js";
|
|
4
|
+
/**
|
|
5
|
+
* Signs prepared calls using the provided signer.
|
|
6
|
+
*
|
|
7
|
+
* @param {SmartAccountSigner} signer - The signer to use
|
|
8
|
+
* @param {SignPreparedCallsParams} params - The prepared calls with signature requests
|
|
9
|
+
* @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls
|
|
10
|
+
**/
|
|
11
|
+
export async function signPreparedCalls(signer, params) {
|
|
12
|
+
if (params.type !== "array") {
|
|
13
|
+
const { signatureRequest, ...call } = params;
|
|
14
|
+
const signature = await signSignatureRequest(signer, signatureRequest);
|
|
15
|
+
return {
|
|
16
|
+
...call,
|
|
17
|
+
signature,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
type: "array",
|
|
22
|
+
data: await Promise.all(params.data.map(async (call) => {
|
|
23
|
+
switch (call.type) {
|
|
24
|
+
case "authorization": {
|
|
25
|
+
const signature = await signSignatureRequest(signer, {
|
|
26
|
+
type: "eip7702Auth",
|
|
27
|
+
data: {
|
|
28
|
+
...call.data,
|
|
29
|
+
chainId: call.chainId,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
...call,
|
|
34
|
+
signature,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
case "user-operation-v060":
|
|
38
|
+
case "user-operation-v070": {
|
|
39
|
+
const { signatureRequest, ...rest } = call;
|
|
40
|
+
const signature = await signSignatureRequest(signer, signatureRequest);
|
|
41
|
+
return {
|
|
42
|
+
...rest,
|
|
43
|
+
signature,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
default: {
|
|
47
|
+
return assertNever(call, "Unexpected call type");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
})),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=signPreparedCalls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/signPreparedCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAQ7C;;;;;;IAMI;AACJ,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA0B,EAC1B,MAA+B;IAE/B,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC5B,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC7C,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACvE,OAAO;YACL,GAAG,IAAI;YACP,SAAS;SACV,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,OAAgB;QACtB,IAAI,EAAE,MAAM,OAAO,CAAC,GAAG,CACrB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAC7B,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;gBAClB,KAAK,eAAe,CAAC,CAAC,CAAC;oBACrB,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE;wBACnD,IAAI,EAAE,aAAa;wBACnB,IAAI,EAAE;4BACJ,GAAG,IAAI,CAAC,IAAI;4BACZ,OAAO,EAAE,IAAI,CAAC,OAAO;yBACtB;qBACF,CAAC,CAAC;oBACH,OAAO;wBACL,GAAG,IAAI;wBACP,SAAS;qBACV,CAAC;gBACJ,CAAC;gBACD,KAAK,qBAAqB,CAAC;gBAC3B,KAAK,qBAAqB,CAAC,CAAC,CAAC;oBAC3B,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;oBAC3C,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAC1C,MAAM,EACN,gBAAgB,CACjB,CAAC;oBACF,OAAO;wBACL,GAAG,IAAI;wBACP,SAAS;qBACV,CAAC;gBACJ,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACR,OAAO,WAAW,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;gBACnD,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CACH;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { PrepareCallsResult } from \"./prepareCalls.ts\";\nimport type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { wallet_sendPreparedCalls } from \"../../rpc/request.js\";\nimport { assertNever } from \"../../utils.js\";\n\nexport type SignPreparedCallsParams = PrepareCallsResult;\n\nexport type SignPreparedCallsResult = Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n>[0];\n\n/**\n * Signs prepared calls using the provided signer.\n *\n * @param {SmartAccountSigner} signer - The signer to use\n * @param {SignPreparedCallsParams} params - The prepared calls with signature requests\n * @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls\n **/\nexport async function signPreparedCalls(\n signer: SmartAccountSigner,\n params: SignPreparedCallsParams,\n): Promise<SignPreparedCallsResult> {\n if (params.type !== \"array\") {\n const { signatureRequest, ...call } = params;\n const signature = await signSignatureRequest(signer, signatureRequest);\n return {\n ...call,\n signature,\n };\n }\n\n return {\n type: \"array\" as const,\n data: await Promise.all(\n params.data.map(async (call) => {\n switch (call.type) {\n case \"authorization\": {\n const signature = await signSignatureRequest(signer, {\n type: \"eip7702Auth\",\n data: {\n ...call.data,\n chainId: call.chainId,\n },\n });\n return {\n ...call,\n signature,\n };\n }\n case \"user-operation-v060\":\n case \"user-operation-v070\": {\n const { signatureRequest, ...rest } = call;\n const signature = await signSignatureRequest(\n signer,\n signatureRequest,\n );\n return {\n ...rest,\n signature,\n };\n }\n default: {\n return assertNever(call, \"Unexpected call type\");\n }\n }\n }),\n ),\n };\n}\n"]}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import type { Static } from "@sinclair/typebox";
|
|
3
3
|
import { type Hex } from "viem";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
export type SignSignatureRequestParams = Static<typeof
|
|
4
|
+
import { TypeAuthorizationSignatureRequest, TypePersonalSignSignatureRequest, TypeTypedDataSignatureRequest } from "../../schemas.js";
|
|
5
|
+
import { TypeEip7702UnsignedAuth } from "../../schemas.js";
|
|
6
|
+
export type SignSignatureRequestParams = Static<typeof TypePersonalSignSignatureRequest> | Static<typeof TypeTypedDataSignatureRequest> | (Static<typeof TypeAuthorizationSignatureRequest> & {
|
|
7
|
+
data: Static<typeof TypeEip7702UnsignedAuth>;
|
|
8
|
+
});
|
|
7
9
|
export type SignSignatureRequestResult = {
|
|
8
|
-
type:
|
|
9
|
-
|
|
10
|
-
signedAuthorization?: Eip7702ExtendedFields["eip7702Auth"];
|
|
10
|
+
type: "secp256k1";
|
|
11
|
+
data: Hex;
|
|
11
12
|
};
|
|
12
13
|
/**
|
|
13
14
|
* Signs a signature request using the provided signer.
|
|
14
|
-
* This method handles different types of signature requests including personal_sign and
|
|
15
|
+
* This method handles different types of signature requests including personal_sign, eth_signTypedData_v4, and authorization.
|
|
15
16
|
*
|
|
16
17
|
* @param {SmartAccountSigner} signer - The signer to use for signing the request
|
|
17
18
|
* @param {SignSignatureRequestParams} params - The signature request parameters
|