@account-kit/wallet-client 0.1.0-alpha.4 → 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.d.ts +4 -0
- package/dist/esm/capabilities/eip7702Auth.js +18 -0
- package/dist/esm/capabilities/eip7702Auth.js.map +1 -0
- package/dist/esm/capabilities/index.d.ts +4 -0
- package/dist/esm/capabilities/index.js +2 -0
- package/dist/esm/capabilities/index.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 +2 -2
- package/dist/esm/capabilities/permissions/index.js +6 -3
- package/dist/esm/capabilities/permissions/index.js.map +1 -1
- package/dist/esm/capabilities/permissions/mav2.js +1 -0
- package/dist/esm/capabilities/permissions/mav2.js.map +1 -1
- package/dist/esm/client/actions/getCallsStatus.d.ts +1 -2
- package/dist/esm/client/actions/getCallsStatus.js +19 -0
- package/dist/esm/client/actions/getCallsStatus.js.map +1 -1
- package/dist/esm/client/actions/grantPermissions.d.ts +10 -65
- package/dist/esm/client/actions/grantPermissions.js +63 -4
- package/dist/esm/client/actions/grantPermissions.js.map +1 -1
- package/dist/esm/client/actions/prepareCalls.d.ts +4 -4
- package/dist/esm/client/actions/prepareCalls.js +38 -5
- package/dist/esm/client/actions/prepareCalls.js.map +1 -1
- package/dist/esm/client/actions/requestAccount.d.ts +3 -4
- package/dist/esm/client/actions/requestAccount.js +18 -1
- package/dist/esm/client/actions/requestAccount.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/signMessage.d.ts +3 -3
- package/dist/esm/client/actions/signMessage.js +18 -0
- package/dist/esm/client/actions/signMessage.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 +9 -8
- package/dist/esm/client/actions/signSignatureRequest.js +69 -31
- package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
- package/dist/esm/client/actions/signTypedData.d.ts +2 -2
- package/dist/esm/client/actions/signTypedData.js +31 -0
- package/dist/esm/client/actions/signTypedData.js.map +1 -1
- package/dist/esm/client/client.e2e-test.js +47 -44
- package/dist/esm/client/client.e2e-test.js.map +1 -1
- package/dist/esm/client/decorator.d.ts +7 -5
- package/dist/esm/client/decorator.js +3 -1
- package/dist/esm/client/decorator.js.map +1 -1
- package/dist/esm/client/index.d.ts +35 -10
- package/dist/esm/client/index.js +0 -29
- package/dist/esm/client/index.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 +15 -18
- package/dist/esm/isomorphic/actions/createSession.js.map +1 -1
- package/dist/esm/isomorphic/actions/getCallsStatus.js +62 -9
- package/dist/esm/isomorphic/actions/getCallsStatus.js.map +1 -1
- package/dist/esm/isomorphic/actions/prepareCalls.js +39 -26
- 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 +77 -37
- 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 +13 -6
- package/dist/esm/isomorphic/utils/7702.js +48 -13
- package/dist/esm/isomorphic/utils/7702.js.map +1 -1
- package/dist/esm/isomorphic/utils/createAccount.d.ts +2 -2
- package/dist/esm/isomorphic/utils/createAccount.js +4 -3
- package/dist/esm/isomorphic/utils/createAccount.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/isomorphic/utils/parsePermissionsContext.d.ts +2 -2
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js +8 -7
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +1 -1
- package/dist/esm/local/client.d.ts +2 -2
- package/dist/esm/local/client.js +2 -3
- package/dist/esm/local/client.js.map +1 -1
- package/dist/esm/remote/client.d.ts +8 -2
- package/dist/esm/remote/client.js +3 -13
- 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 +362 -44
- package/dist/esm/rpc/request.js +26 -56
- package/dist/esm/rpc/request.js.map +1 -1
- package/dist/esm/rpc/schema.d.ts +325 -49
- package/dist/esm/rpc/schema.js.map +1 -1
- package/dist/esm/schemas.d.ts +454 -14
- package/dist/esm/schemas.js +168 -53
- package/dist/esm/schemas.js.map +1 -1
- package/dist/esm/types.d.ts +10 -10
- package/dist/esm/types.js.map +1 -1
- package/dist/types/capabilities/eip7702Auth.d.ts +5 -0
- package/dist/types/capabilities/eip7702Auth.d.ts.map +1 -0
- package/dist/types/capabilities/index.d.ts +4 -0
- package/dist/types/capabilities/index.d.ts.map +1 -1
- package/dist/types/capabilities/permissions/index.d.ts +2 -2
- package/dist/types/capabilities/permissions/index.d.ts.map +1 -1
- package/dist/types/capabilities/permissions/mav2.d.ts.map +1 -1
- package/dist/types/client/actions/getCallsStatus.d.ts +1 -2
- package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
- package/dist/types/client/actions/grantPermissions.d.ts +10 -65
- package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
- package/dist/types/client/actions/prepareCalls.d.ts +4 -4
- package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/client/actions/requestAccount.d.ts +3 -4
- package/dist/types/client/actions/requestAccount.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/signMessage.d.ts +3 -3
- package/dist/types/client/actions/signMessage.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 +9 -8
- package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
- package/dist/types/client/actions/signTypedData.d.ts +2 -2
- package/dist/types/client/actions/signTypedData.d.ts.map +1 -1
- package/dist/types/client/decorator.d.ts +7 -5
- package/dist/types/client/decorator.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +35 -10
- package/dist/types/client/index.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/getCallsStatus.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 +13 -6
- package/dist/types/isomorphic/utils/7702.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/createAccount.d.ts +2 -2
- package/dist/types/isomorphic/utils/createAccount.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/isomorphic/utils/parsePermissionsContext.d.ts +2 -2
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +1 -1
- package/dist/types/local/client.d.ts +2 -2
- package/dist/types/local/client.d.ts.map +1 -1
- package/dist/types/remote/client.d.ts +8 -2
- 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 +362 -44
- package/dist/types/rpc/request.d.ts.map +1 -1
- package/dist/types/rpc/schema.d.ts +325 -49
- package/dist/types/rpc/schema.d.ts.map +1 -1
- package/dist/types/schemas.d.ts +454 -14
- package/dist/types/schemas.d.ts.map +1 -1
- package/dist/types/types.d.ts +10 -10
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/capabilities/eip7702Auth.ts +26 -0
- package/src/capabilities/index.ts +2 -0
- package/src/capabilities/overrides.ts +8 -8
- package/src/capabilities/permissions/index.ts +8 -3
- package/src/capabilities/permissions/mav2.ts +1 -0
- package/src/client/actions/getCallsStatus.ts +0 -10
- package/src/client/actions/grantPermissions.ts +16 -84
- package/src/client/actions/prepareCalls.ts +18 -23
- package/src/client/actions/requestAccount.ts +9 -26
- package/src/client/actions/sendPreparedCalls.ts +17 -17
- package/src/client/actions/signMessage.ts +2 -17
- package/src/client/actions/signPreparedCalls.ts +71 -0
- package/src/client/actions/signSignatureRequest.ts +51 -47
- package/src/client/actions/signTypedData.ts +1 -16
- package/src/client/client.e2e-test.ts +54 -57
- package/src/client/decorator.ts +19 -15
- package/src/client/index.ts +16 -39
- package/src/exports/index.ts +2 -1
- package/src/isomorphic/actions/createSession.ts +17 -20
- package/src/isomorphic/actions/getCallsStatus.ts +82 -10
- package/src/isomorphic/actions/prepareCalls.ts +43 -27
- package/src/isomorphic/actions/sendPreparedCalls.ts +105 -55
- package/src/isomorphic/utils/7702.ts +79 -21
- package/src/isomorphic/utils/createAccount.ts +5 -5
- package/src/isomorphic/utils/decodeSignature.ts +18 -0
- package/src/isomorphic/utils/parsePermissionsContext.ts +9 -9
- package/src/local/client.ts +5 -11
- package/src/remote/client.ts +7 -22
- package/src/rpc/examples.ts +3 -4
- package/src/rpc/request.ts +41 -64
- package/src/rpc/schema.ts +2 -2
- package/src/schemas.ts +232 -54
- package/src/types.ts +9 -21
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const Eip7702AuthCapability: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
2
|
+
account: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">>;
|
|
3
|
+
delegation: import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TLiteral<"0x69007702764179f14F51cdce752f4f775d74E139"> | import("@sinclair/typebox").TLiteral<"ModularAccountV2">)[]>;
|
|
4
|
+
}>, import("@sinclair/typebox").TLiteral<true>]>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { TypeAddress } from "../schemas.js";
|
|
3
|
+
import { EIP_7702_ACCOUNT_TYPE, SUPPORTED_DELEGATION_ADDRESSES, } from "../isomorphic/utils/7702.js";
|
|
4
|
+
export const Eip7702AuthCapability = Type.Union([
|
|
5
|
+
Type.Object({
|
|
6
|
+
account: Type.Optional(TypeAddress),
|
|
7
|
+
// Wallet applications must maintain a strict shortlist of well-known accounts.
|
|
8
|
+
// https://github.com/ethereum/ERCs/pull/947/files#diff-dab085f963ca621595044bcbc0922705aa38b69f5bf8770dcb3d0496a633efcfR189
|
|
9
|
+
delegation: Type.Union([
|
|
10
|
+
...SUPPORTED_DELEGATION_ADDRESSES.map((address) => Type.Literal(address)),
|
|
11
|
+
...EIP_7702_ACCOUNT_TYPE.map((it) => Type.Literal(it)),
|
|
12
|
+
]),
|
|
13
|
+
}, {
|
|
14
|
+
description: "Specify EIP-7702 delegation",
|
|
15
|
+
}),
|
|
16
|
+
Type.Literal(true, { description: "Default EIP-7702 delegation" }),
|
|
17
|
+
]);
|
|
18
|
+
//# sourceMappingURL=eip7702Auth.js.map
|
|
@@ -0,0 +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,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"]}
|
|
@@ -31,4 +31,8 @@ export declare const Capabilities: import("@sinclair/typebox").TObject<{
|
|
|
31
31
|
multiplier: import("@sinclair/typebox").TNumber;
|
|
32
32
|
}>]>>;
|
|
33
33
|
}>>;
|
|
34
|
+
eip7702Auth: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
35
|
+
account: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">>;
|
|
36
|
+
delegation: import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TLiteral<"0x69007702764179f14F51cdce752f4f775d74E139"> | import("@sinclair/typebox").TLiteral<"ModularAccountV2">)[]>;
|
|
37
|
+
}>, import("@sinclair/typebox").TLiteral<true>]>>;
|
|
34
38
|
}>;
|
|
@@ -2,9 +2,11 @@ import { Type } from "@sinclair/typebox";
|
|
|
2
2
|
import { GasParamsOverrideCapability } from "./overrides.js";
|
|
3
3
|
import { PaymasterCapability } from "./paymaster.js";
|
|
4
4
|
import { PermissionsCapability } from "./permissions/index.js";
|
|
5
|
+
import { Eip7702AuthCapability } from "./eip7702Auth.js";
|
|
5
6
|
export const Capabilities = Type.Object({
|
|
6
7
|
permissions: Type.Optional(PermissionsCapability),
|
|
7
8
|
paymasterService: Type.Optional(PaymasterCapability),
|
|
8
9
|
gasParamsOverride: Type.Optional(GasParamsOverrideCapability),
|
|
10
|
+
eip7702Auth: Type.Optional(Eip7702AuthCapability),
|
|
9
11
|
});
|
|
10
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/capabilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/capabilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;IACtC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC;IACjD,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC;IACpD,iBAAiB,EAAE,IAAI,CAAC,QAAQ,CAAC,2BAA2B,CAAC;IAC7D,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC;CAClD,CAAC,CAAC","sourcesContent":["import { Type } from \"@sinclair/typebox\";\nimport { GasParamsOverrideCapability } from \"./overrides.js\";\nimport { PaymasterCapability } from \"./paymaster.js\";\nimport { PermissionsCapability } from \"./permissions/index.js\";\nimport { Eip7702AuthCapability } from \"./eip7702Auth.js\";\n\nexport const Capabilities = Type.Object({\n permissions: Type.Optional(PermissionsCapability),\n paymasterService: Type.Optional(PaymasterCapability),\n gasParamsOverride: Type.Optional(GasParamsOverrideCapability),\n eip7702Auth: Type.Optional(Eip7702AuthCapability),\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,9 +90,9 @@ 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
|
-
type: import("@sinclair/typebox").TUnion<[TLiteral<"secp256k1">, TLiteral<"contract">]>;
|
|
95
|
+
type: import("@sinclair/typebox").TUnion<[TLiteral<"secp256k1">, TLiteral<"ecdsa">, TLiteral<"contract">]>;
|
|
96
96
|
publicKey: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
|
|
97
97
|
}>;
|
|
98
98
|
permissions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[TObject<{
|
|
@@ -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/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,UAAU,CACpC,uBAAuB,EACvB,cAAc,CAAC,qBAAqB,EACpC,IAAI,CAAC,MAAM,CAAC;IACV,SAAS,EAAE,OAAO,EAAE;CACrB,CAAC,EACF,mDAAmD,CACpD,CAAC;AAEF,MAAM,kBAAkB,GAAG,UAAU,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MAAM,IAAI,GAAG,UAAU,CACrB,MAAM,EACN,cAAc,CAAC,IAAI,EACnB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAC3B,kCAAkC,CACnC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC;IACvC,mBAAmB;IACnB,mBAAmB;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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AAe,GAAG,IAAI,CAAC,MAAM,CAAC;IACzC,OAAO,EAAE,OAAO,EAAE;IAClB,SAAS,EAAE,IAAI,CAAC,QAAQ,CACtB,IAAI,CAAC,OAAO,CAAC;QACX,OAAO,EAAE,UAAU,EAAE,yCAAyC;QAC9D,WAAW,EAAE,6CAA6C;KAC3D,CAAC,CACH;IACD,GAAG,EAAE,SAAS;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mav2.js","sourceRoot":"","sources":["../../../../src/capabilities/permissions/mav2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAE3E,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAY,MAAM,MAAM,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAC1C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAExC,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,2BAA2B,EAAE,MAAM;IACnC,0BAA0B,EAAE,MAAM;IAClC,mBAAmB,EAAE,MAAM;CACnB,CAAC;AA8BX,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,OAAkC,EAC7B,EAAE;IACP,QAAQ,OAAO,CAAC,cAAc,EAAE,CAAC;QAC/B,KAAK,6BAA6B;YAChC,OAAO,SAAS,CAAC;gBACf,yBAAyB,CAAC,2BAA2B;gBACrD,OAAO,CAAC,SAAS;gBACjB,OAAO,CAAC,SAAS;aAClB,CAAC,CAAC;QACL,KAAK,4BAA4B;YAC/B,OAAO,SAAS,CAAC;gBACf,yBAAyB,CAAC,0BAA0B;gBACpD,OAAO,CAAC,cAAc;aACvB,CAAC,CAAC;QACL,KAAK,qBAAqB;YACxB,OAAO,SAAS,CAAC;gBACf,yBAAyB,CAAC,mBAAmB;gBAC7C,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;gBAC5C,OAAO,CAAC,QAAQ;aACjB,CAAC,CAAC;QACL;YACE,O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AAE,qBAAqB;gBACrC,kBAAkB;gBAClB,QAAQ;aACT,CAAC;QACJ,CAAC;QACD;YACE,OAAO,WAAW,CAChB,cAAc,EACd,+BAA+B,cAAc,EAAE,CAChD,CAAC;IACN,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,GAAQ,EACR,IAAuB,EAClB,EAAE;IACP,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,WAAW;YACd,OAAO,SAAS,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;QAClC,KAAK,UAAU;YACb,OAAO,SAAS,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;QAClC;YACE,OAAO,WAAW,CAAC,IAAI,EAAE,6BAA6B,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,IAAyD,EAChD,EAAE;IACX,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,CAAC,CAAC;AACtE,CAAC,CAAC","sourcesContent":["import { PermissionType } from \"@account-kit/smart-contracts/experimental\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { concatHex, sliceHex, type Hex } from \"viem\";\nimport type { KeySigner } from \"../../schemas.ts\";\nimport { assertNever } from \"../../utils.js\";\nimport type { PermissionsCapability, PermissionsData } from \"./index.ts\";\n\nexport const SESSION_ID_LENGTH_BYTES = 16;\nexport const ENTITY_ID_LENGTH_BYTES = 4;\n\nexport const PermissionsContextVersion = {\n REMOTE_MODE_DEFERRED_ACTION: \"0x00\",\n LOCAL_MODE_DEFERRED_ACTION: \"0x01\",\n NON_DEFERRED_ACTION: \"0x02\",\n} as const;\n\ntype ContextVersionHex =\n (typeof PermissionsContextVersion)[keyof typeof PermissionsContextVersion];\n\ntype DecodedPermissionsContext = {\n contextVersion: keyof typeof PermissionsContextVersion;\n} & (\n | {\n contextVersion: \"REMOTE_MODE_DEFERRED_ACTION\";\n sessionId: Hex;\n signature: Hex;\n deferredAction?: never;\n }\n | {\n contextVersion: \"LOCAL_MODE_DEFERRED_ACTION\";\n deferredAction: Hex;\n sessionId?: never;\n signature?: never;\n }\n | {\n contextVersion: \"NON_DEFERRED_ACTION\";\n deferredAction?: never;\n sessionId?: never;\n signature?: never;\n entityId: Hex;\n isGlobalValidation: boolean;\n }\n);\n\nexport const encodePermissionsContext = (\n context: DecodedPermissionsContext,\n): Hex => {\n switch (context.contextVersion) {\n case \"REMOTE_MODE_DEFERRED_ACTION\":\n return concatHex([\n PermissionsContextVersion.REMOTE_MODE_DEFERRED_ACTION,\n context.sessionId,\n context.signature,\n ]);\n case \"LOCAL_MODE_DEFERRED_ACTION\":\n return concatHex([\n PermissionsContextVersion.LOCAL_MODE_DEFERRED_ACTION,\n context.deferredAction,\n ]);\n case \"NON_DEFERRED_ACTION\":\n return concatHex([\n PermissionsContextVersion.NON_DEFERRED_ACTION,\n context.isGlobalValidation ? \"0x01\" : \"0x00\",\n context.entityId,\n ]);\n default:\n return assertNever(context, \"Unexpected context version\");\n }\n};\n\nexport const decodePermissionsContext = (\n capability: Static<typeof PermissionsCapability>,\n): DecodedPermissionsContext => {\n if (!(\"context\" in capability)) {\n return {\n contextVersion: \"REMOTE_MODE_DEFERRED_ACTION\",\n sessionId: capability.sessionId,\n signature: capability.signature,\n };\n }\n\n const input = capability.context;\n\n const contextVersion = sliceHex(input, 0, 1) as ContextVersionHex;\n switch (contextVersion) {\n case \"0x00\": {\n const sessionId = sliceHex(input, 1, SESSION_ID_LENGTH_BYTES + 1);\n const signature = sliceHex(input, SESSION_ID_LENGTH_BYTES + 1);\n return {\n contextVersion: \"REMOTE_MODE_DEFERRED_ACTION\",\n sessionId,\n signature,\n };\n }\n case \"0x01\": {\n const deferredAction = sliceHex(input, 1);\n return {\n contextVersion: \"LOCAL_MODE_DEFERRED_ACTION\",\n deferredAction,\n };\n }\n case \"0x02\": {\n const isGlobalValidation = sliceHex(input, 1, 2) === \"0x01\";\n const entityId = sliceHex(input, 2, ENTITY_ID_LENGTH_BYTES + 2);\n return {\n contextVersion: \"NON_DEFERRED_ACTION\",\n isGlobalValidation,\n entityId,\n };\n }\n default:\n return assertNever(\n contextVersion,\n `Unexpected context version: ${contextVersion}`,\n );\n }\n};\n\nexport const prefixSignatureKeyType = (\n sig: Hex,\n type: KeySigner[\"type\"],\n): Hex => {\n switch (type) {\n case \"secp256k1\":\n return concatHex([\"0x00\", sig]);\n case \"contract\":\n return concatHex([\"0x01\", sig]);\n default:\n return assertNever(type, \"Unexpected session key type\");\n }\n};\n\nexport const isGlobalValidation = (\n data: Pick<Static<typeof PermissionsData>, \"permissions\">,\n): boolean => {\n return data.permissions.some((p) => p.type === PermissionType.ROOT);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"mav2.js","sourceRoot":"","sources":["../../../../src/capabilities/permissions/mav2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAE3E,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAY,MAAM,MAAM,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAC1C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAExC,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,2BAA2B,EAAE,MAAM;IACnC,0BAA0B,EAAE,MAAM;IAClC,mBAAmB,EAAE,MAAM;CACnB,CAAC;AA8BX,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,OAAkC,EAC7B,EAAE;IACP,QAAQ,OAAO,CAAC,cAAc,EAAE,CAAC;QAC/B,KAAK,6BAA6B;YAChC,OAAO,SAAS,CAAC;gBACf,yBAAyB,CAAC,2BAA2B;gBACrD,OAAO,CAAC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G,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC1C,OAAO;gBACL,cAAc,EAAE,4BAA4B;gBAC5C,cAAc;aACf,CAAC;QACJ,CAAC;QACD,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,MAAM,kBAAkB,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC;YAC5D,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,sBAAsB,GAAG,CAAC,CAAC,CAAC;YAChE,OAAO;gBACL,cAAc,EAAE,qBAAqB;gBACrC,kBAAkB;gBAClB,QAAQ;aACT,CAAC;QACJ,CAAC;QACD;YACE,OAAO,WAAW,CAChB,cAAc,EACd,+BAA+B,cAAc,EAAE,CAChD,CAAC;IACN,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,GAAQ,EACR,IAAuB,EAClB,EAAE;IACP,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,OAAO,CAAC;QACb,KAAK,WAAW;YACd,OAAO,SAAS,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;QAClC,KAAK,UAAU;YACb,OAAO,SAAS,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;QAClC;YACE,OAAO,WAAW,CAAC,IAAI,EAAE,6BAA6B,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,IAAyD,EAChD,EAAE;IACX,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,CAAC,CAAC;AACtE,CAAC,CAAC","sourcesContent":["import { PermissionType } from \"@account-kit/smart-contracts/experimental\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { concatHex, sliceHex, type Hex } from \"viem\";\nimport type { KeySigner } from \"../../schemas.ts\";\nimport { assertNever } from \"../../utils.js\";\nimport type { PermissionsCapability, PermissionsData } from \"./index.ts\";\n\nexport const SESSION_ID_LENGTH_BYTES = 16;\nexport const ENTITY_ID_LENGTH_BYTES = 4;\n\nexport const PermissionsContextVersion = {\n REMOTE_MODE_DEFERRED_ACTION: \"0x00\",\n LOCAL_MODE_DEFERRED_ACTION: \"0x01\",\n NON_DEFERRED_ACTION: \"0x02\",\n} as const;\n\ntype ContextVersionHex =\n (typeof PermissionsContextVersion)[keyof typeof PermissionsContextVersion];\n\ntype DecodedPermissionsContext = {\n contextVersion: keyof typeof PermissionsContextVersion;\n} & (\n | {\n contextVersion: \"REMOTE_MODE_DEFERRED_ACTION\";\n sessionId: Hex;\n signature: Hex;\n deferredAction?: never;\n }\n | {\n contextVersion: \"LOCAL_MODE_DEFERRED_ACTION\";\n deferredAction: Hex;\n sessionId?: never;\n signature?: never;\n }\n | {\n contextVersion: \"NON_DEFERRED_ACTION\";\n deferredAction?: never;\n sessionId?: never;\n signature?: never;\n entityId: Hex;\n isGlobalValidation: boolean;\n }\n);\n\nexport const encodePermissionsContext = (\n context: DecodedPermissionsContext,\n): Hex => {\n switch (context.contextVersion) {\n case \"REMOTE_MODE_DEFERRED_ACTION\":\n return concatHex([\n PermissionsContextVersion.REMOTE_MODE_DEFERRED_ACTION,\n context.sessionId,\n context.signature,\n ]);\n case \"LOCAL_MODE_DEFERRED_ACTION\":\n return concatHex([\n PermissionsContextVersion.LOCAL_MODE_DEFERRED_ACTION,\n context.deferredAction,\n ]);\n case \"NON_DEFERRED_ACTION\":\n return concatHex([\n PermissionsContextVersion.NON_DEFERRED_ACTION,\n context.isGlobalValidation ? \"0x01\" : \"0x00\",\n context.entityId,\n ]);\n default:\n return assertNever(context, \"Unexpected context version\");\n }\n};\n\nexport const decodePermissionsContext = (\n capability: Static<typeof PermissionsCapability>,\n): DecodedPermissionsContext => {\n if (!(\"context\" in capability)) {\n return {\n contextVersion: \"REMOTE_MODE_DEFERRED_ACTION\",\n sessionId: capability.sessionId,\n signature: capability.signature,\n };\n }\n\n const input = capability.context;\n\n const contextVersion = sliceHex(input, 0, 1) as ContextVersionHex;\n switch (contextVersion) {\n case \"0x00\": {\n const sessionId = sliceHex(input, 1, SESSION_ID_LENGTH_BYTES + 1);\n const signature = sliceHex(input, SESSION_ID_LENGTH_BYTES + 1);\n return {\n contextVersion: \"REMOTE_MODE_DEFERRED_ACTION\",\n sessionId,\n signature,\n };\n }\n case \"0x01\": {\n const deferredAction = sliceHex(input, 1);\n return {\n contextVersion: \"LOCAL_MODE_DEFERRED_ACTION\",\n deferredAction,\n };\n }\n case \"0x02\": {\n const isGlobalValidation = sliceHex(input, 1, 2) === \"0x01\";\n const entityId = sliceHex(input, 2, ENTITY_ID_LENGTH_BYTES + 2);\n return {\n contextVersion: \"NON_DEFERRED_ACTION\",\n isGlobalValidation,\n entityId,\n };\n }\n default:\n return assertNever(\n contextVersion,\n `Unexpected context version: ${contextVersion}`,\n );\n }\n};\n\nexport const prefixSignatureKeyType = (\n sig: Hex,\n type: KeySigner[\"type\"],\n): Hex => {\n switch (type) {\n case \"ecdsa\":\n case \"secp256k1\":\n return concatHex([\"0x00\", sig]);\n case \"contract\":\n return concatHex([\"0x01\", sig]);\n default:\n return assertNever(type, \"Unexpected session key type\");\n }\n};\n\nexport const isGlobalValidation = (\n data: Pick<Static<typeof PermissionsData>, \"permissions\">,\n): boolean => {\n return data.permissions.some((p) => p.type === PermissionType.ROOT);\n};\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Address, JsonRpcAccount } from "viem";
|
|
2
1
|
import type { GetCallsStatusParams as IsomorphicGetCallsStatusParams, GetCallsStatusResponse as IsomorphicGetCallsStatusResult } from "../../isomorphic/actions/getCallsStatus.ts";
|
|
3
2
|
import type { InnerWalletApiClient } from "../../types.ts";
|
|
4
3
|
export type GetCallsStatusParams = IsomorphicGetCallsStatusParams;
|
|
@@ -22,4 +21,4 @@ export type GetCallsStatusResult = IsomorphicGetCallsStatusResult;
|
|
|
22
21
|
* // Check the status of the first call ID
|
|
23
22
|
* const status = await client.getCallsStatus(sendResult.preparedCallIds[0]);
|
|
24
23
|
*/
|
|
25
|
-
export declare function getCallsStatus
|
|
24
|
+
export declare function getCallsStatus(client: InnerWalletApiClient, params: GetCallsStatusParams): Promise<GetCallsStatusResult>;
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the status of a prepared call by its ID.
|
|
3
|
+
* This method is used to check the execution status of calls sent via sendPreparedCalls.
|
|
4
|
+
*
|
|
5
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
6
|
+
* @param {GetCallsStatusParams} params - The ID of the prepared call to check
|
|
7
|
+
* @returns {Promise<GetCallsStatusResult>} A Promise that resolves to the status information including:
|
|
8
|
+
* - id: The hex ID of the call
|
|
9
|
+
* - chainId: The chain ID in hex format
|
|
10
|
+
* - status: The current status of the batch execution
|
|
11
|
+
* - receipts: Optional array of transaction receipts if the batch has been executed
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // After sending prepared calls
|
|
15
|
+
* const sendResult = await client.sendPreparedCalls({...});
|
|
16
|
+
*
|
|
17
|
+
* // Check the status of the first call ID
|
|
18
|
+
* const status = await client.getCallsStatus(sendResult.preparedCallIds[0]);
|
|
19
|
+
*/
|
|
1
20
|
export async function getCallsStatus(client, params) {
|
|
2
21
|
return await client.request({
|
|
3
22
|
method: "wallet_getCallsStatus",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../../src/client/actions/getCallsStatus.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../../src/client/actions/getCallsStatus.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA4B;IAE5B,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,MAAM,CAAC;KACjB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {\n GetCallsStatusParams as IsomorphicGetCallsStatusParams,\n GetCallsStatusResponse as IsomorphicGetCallsStatusResult,\n} from \"../../isomorphic/actions/getCallsStatus.ts\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\n\nexport type GetCallsStatusParams = IsomorphicGetCallsStatusParams;\n\nexport type GetCallsStatusResult = IsomorphicGetCallsStatusResult;\n\n/**\n * Gets the status of a prepared call by its ID.\n * This method is used to check the execution status of calls sent via sendPreparedCalls.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {GetCallsStatusParams} params - The ID of the prepared call to check\n * @returns {Promise<GetCallsStatusResult>} A Promise that resolves to the status information including:\n * - id: The hex ID of the call\n * - chainId: The chain ID in hex format\n * - status: The current status of the batch execution\n * - receipts: Optional array of transaction receipts if the batch has been executed\n *\n * @example\n * // After sending prepared calls\n * const sendResult = await client.sendPreparedCalls({...});\n *\n * // Check the status of the first call ID\n * const status = await client.getCallsStatus(sendResult.preparedCallIds[0]);\n */\nexport async function getCallsStatus(\n client: InnerWalletApiClient,\n params: GetCallsStatusParams,\n): Promise<GetCallsStatusResult> {\n return await client.request({\n method: \"wallet_getCallsStatus\",\n params: [params],\n });\n}\n"]}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type
|
|
3
|
-
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
1
|
+
import { type SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
+
import { type Address, type Hex, type IsUndefined } from "viem";
|
|
4
3
|
import type { CreateSessionParams } from "../../isomorphic/actions/createSession.ts";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
export type GrantPermissionsParams<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined> = Omit<CreateSessionParams, "account" | "chainId"> & (IsUndefined<TAccount> extends true ? {
|
|
4
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
5
|
+
export type GrantPermissionsParams<TAccount extends Address | undefined = Address | undefined> = Omit<CreateSessionParams, "account" | "chainId"> & (IsUndefined<TAccount> extends true ? {
|
|
8
6
|
account: Address;
|
|
9
7
|
} : {
|
|
10
8
|
account?: never;
|
|
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,53 +42,7 @@ export type GrantPermissionsResult = {
|
|
|
46
42
|
* });
|
|
47
43
|
*
|
|
48
44
|
* // Use the permissions to prepare a call
|
|
49
|
-
* const
|
|
50
|
-
* calls: [{ to: zeroAddress, value: "0x0" }],
|
|
51
|
-
* from: account.address,
|
|
52
|
-
* capabilities: {
|
|
53
|
-
* paymasterService: {
|
|
54
|
-
* policyId: "your-paymaster-policy-id",
|
|
55
|
-
* },
|
|
56
|
-
* permissions,
|
|
57
|
-
* },
|
|
58
|
-
* });
|
|
59
|
-
*
|
|
60
|
-
* // Sign with the session key
|
|
61
|
-
* const signature = await signSignatureRequest(
|
|
62
|
-
* sessionKey,
|
|
63
|
-
* preparedCall.signatureRequest,
|
|
64
|
-
* );
|
|
65
|
-
*
|
|
66
|
-
* // Send the prepared call using the session key
|
|
67
|
-
* const result = await client.sendPreparedCalls({
|
|
68
|
-
* ...preparedCall,
|
|
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({
|
|
45
|
+
* const preparedCalls = await client.prepareCalls({
|
|
96
46
|
* calls: [{ to: zeroAddress, value: "0x0" }],
|
|
97
47
|
* from: account.address,
|
|
98
48
|
* capabilities: {
|
|
@@ -104,22 +54,17 @@ export type GrantPermissionsResult = {
|
|
|
104
54
|
* });
|
|
105
55
|
*
|
|
106
56
|
* // Sign with the session key
|
|
107
|
-
*
|
|
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(
|
|
57
|
+
* const signedCalls = await client.signPreparedCalls(
|
|
111
58
|
* sessionKey,
|
|
112
|
-
*
|
|
59
|
+
* preparedCalls,
|
|
113
60
|
* );
|
|
114
61
|
*
|
|
115
62
|
* // Send the prepared call using the session key
|
|
116
63
|
* const result = await client.sendPreparedCalls({
|
|
117
|
-
* ...
|
|
118
|
-
* signature,
|
|
119
|
-
* signedAuthorization,
|
|
64
|
+
* ...signedCalls,
|
|
120
65
|
* capabilities: {
|
|
121
66
|
* permissions,
|
|
122
67
|
* },
|
|
123
68
|
* });
|
|
124
69
|
*/
|
|
125
|
-
export declare function grantPermissions<TAccount extends
|
|
70
|
+
export declare function grantPermissions<TAccount extends Address | undefined = Address | undefined>(client: InnerWalletApiClient, signer: SmartAccountSigner, params: GrantPermissionsParams<TAccount>): Promise<GrantPermissionsResult>;
|
|
@@ -1,11 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AccountNotFoundError } from "@aa-sdk/core";
|
|
2
|
+
import { toHex } from "viem";
|
|
3
|
+
/**
|
|
4
|
+
* Grants permissions to a smart account by creating a session.
|
|
5
|
+
* This allows another key to perform operations on behalf of the account.
|
|
6
|
+
*
|
|
7
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
8
|
+
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
9
|
+
* @param {GrantPermissionsParams} params - The parameters for granting permissions
|
|
10
|
+
* @param {Address} [params.account] - The account address (required if client was not initialized with an account)
|
|
11
|
+
* @param {number} params.expirySec - Unix timestamp when the permissions expire
|
|
12
|
+
* @param {object} params.key - The session key information
|
|
13
|
+
* @param {string} params.key.publicKey - The public key of the session key
|
|
14
|
+
* @param {string} params.key.type - The type of the key (e.g., "secp256k1")
|
|
15
|
+
* @param {Array} params.permissions - Array of permission objects defining what the session key can do
|
|
16
|
+
* @returns {Promise<GrantPermissionsResult>} A Promise that resolves to the result containing a context identifier
|
|
17
|
+
* @returns {Hex} result.context - A hex identifier for the granted permissions context
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Create a session key and grant root permissions
|
|
21
|
+
* const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
|
|
22
|
+
* const account = await client.requestAccount();
|
|
23
|
+
*
|
|
24
|
+
* const permissions = await client.grantPermissions({
|
|
25
|
+
* account: account.address,
|
|
26
|
+
* expiry: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour from now
|
|
27
|
+
* key: {
|
|
28
|
+
* publicKey: await sessionKey.getAddress(),
|
|
29
|
+
* type: "secp256k1",
|
|
30
|
+
* },
|
|
31
|
+
* permissions: [{ type: "root" }],
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* // Use the permissions to prepare a call
|
|
35
|
+
* const preparedCalls = await client.prepareCalls({
|
|
36
|
+
* calls: [{ to: zeroAddress, value: "0x0" }],
|
|
37
|
+
* from: account.address,
|
|
38
|
+
* capabilities: {
|
|
39
|
+
* paymasterService: {
|
|
40
|
+
* policyId: "your-paymaster-policy-id",
|
|
41
|
+
* },
|
|
42
|
+
* permissions,
|
|
43
|
+
* },
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* // Sign with the session key
|
|
47
|
+
* const signedCalls = await client.signPreparedCalls(
|
|
48
|
+
* sessionKey,
|
|
49
|
+
* preparedCalls,
|
|
50
|
+
* );
|
|
51
|
+
*
|
|
52
|
+
* // Send the prepared call using the session key
|
|
53
|
+
* const result = await client.sendPreparedCalls({
|
|
54
|
+
* ...signedCalls,
|
|
55
|
+
* capabilities: {
|
|
56
|
+
* permissions,
|
|
57
|
+
* },
|
|
58
|
+
* });
|
|
59
|
+
*/
|
|
3
60
|
export async function grantPermissions(client, signer, params) {
|
|
4
|
-
|
|
5
|
-
|
|
61
|
+
const account = params.account ?? client.account?.address;
|
|
62
|
+
if (!account) {
|
|
63
|
+
throw new AccountNotFoundError();
|
|
6
64
|
}
|
|
7
65
|
return client.grantPermissions(signer, {
|
|
8
66
|
...params,
|
|
67
|
+
account,
|
|
9
68
|
chainId: toHex(client.chain.id),
|
|
10
69
|
});
|
|
11
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grantPermissions.js","sourceRoot":"","sources":["../../../../src/client/actions/grantPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,12 +1,12 @@
|
|
|
1
|
-
import { type Address, type IsUndefined
|
|
1
|
+
import { type Address, type IsUndefined } from "viem";
|
|
2
2
|
import type { PrepareCallsParams as IsomorphicPrepareCallsParams, PrepareCallsResult as IsomorphicPrepareCallsResult } from "../../isomorphic/actions/prepareCalls.ts";
|
|
3
3
|
import type { InnerWalletApiClient } from "../../types.ts";
|
|
4
4
|
export type GetAccountParam<TAccount> = IsUndefined<TAccount> extends true ? {
|
|
5
5
|
account: Address;
|
|
6
6
|
} : {
|
|
7
|
-
account?:
|
|
7
|
+
account?: Address;
|
|
8
8
|
};
|
|
9
|
-
export type PrepareCallsParams<TAccount extends
|
|
9
|
+
export type PrepareCallsParams<TAccount extends Address | undefined = Address | undefined> = Omit<IsomorphicPrepareCallsParams, "from" | "chainId"> & (IsUndefined<TAccount> extends true ? {
|
|
10
10
|
from: Address;
|
|
11
11
|
} : {
|
|
12
12
|
from?: never;
|
|
@@ -38,4 +38,4 @@ export type PrepareCallsResult = IsomorphicPrepareCallsResult;
|
|
|
38
38
|
* }
|
|
39
39
|
* });
|
|
40
40
|
*/
|
|
41
|
-
export declare function prepareCalls<TAccount extends
|
|
41
|
+
export declare function prepareCalls<TAccount extends Address | undefined = Address | undefined>(client: InnerWalletApiClient, params: PrepareCallsParams<TAccount>): Promise<PrepareCallsResult>;
|
|
@@ -1,17 +1,50 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AccountNotFoundError } from "@aa-sdk/core";
|
|
2
|
+
import { toHex } from "viem";
|
|
3
|
+
/**
|
|
4
|
+
* Prepares a set of contract calls for execution by building a user operation.
|
|
5
|
+
* Returns the built user operation and a signature request that needs to be signed
|
|
6
|
+
* before submitting to sendPreparedCalls.
|
|
7
|
+
*
|
|
8
|
+
* @param {InnerWalletApiClient<TAccount>} client - The wallet API client to use for the request
|
|
9
|
+
* @param {PrepareCallsParams<TAccount>} params - Parameters for preparing calls
|
|
10
|
+
* @param {Array<{to: Address, data?: Hex, value?: Hex}>} params.calls - Array of contract calls to execute
|
|
11
|
+
* @param {Address} [params.from] - The address to execute the calls from (required if the client wasn't initialized with an account)
|
|
12
|
+
* @param {object} [params.capabilities] - Optional capabilities to include with the request
|
|
13
|
+
* @returns {Promise<PrepareCallsResult>} A Promise that resolves to the prepared calls result containing
|
|
14
|
+
* the user operation data and signature request
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Prepare a sponosored user operation call
|
|
18
|
+
* const result = await client.prepareCalls({
|
|
19
|
+
* calls: [{
|
|
20
|
+
* to: "0x1234...",
|
|
21
|
+
* data: "0xabcdef...",
|
|
22
|
+
* value: "0x0"
|
|
23
|
+
* }],
|
|
24
|
+
* capabilities: {
|
|
25
|
+
* paymasterService: { policyId: "your-policy-id" }
|
|
26
|
+
* }
|
|
27
|
+
* });
|
|
28
|
+
*/
|
|
2
29
|
export async function prepareCalls(client, params) {
|
|
30
|
+
const from = params.from ?? client.account?.address;
|
|
31
|
+
if (!from) {
|
|
32
|
+
throw new AccountNotFoundError();
|
|
33
|
+
}
|
|
3
34
|
if (client.policyId && !params.capabilities?.paymasterService) {
|
|
4
35
|
params.capabilities = {
|
|
5
36
|
...params.capabilities,
|
|
6
37
|
paymasterService: { policyId: client.policyId },
|
|
7
38
|
};
|
|
8
39
|
}
|
|
9
|
-
|
|
10
|
-
params
|
|
11
|
-
|
|
40
|
+
const params_ = {
|
|
41
|
+
...params,
|
|
42
|
+
chainId: toHex(client.chain.id),
|
|
43
|
+
from,
|
|
44
|
+
};
|
|
12
45
|
return await client.request({
|
|
13
46
|
method: "wallet_prepareCalls",
|
|
14
|
-
params: [
|
|
47
|
+
params: [params_],
|
|
15
48
|
});
|
|
16
49
|
}
|
|
17
50
|
//# sourceMappingURL=prepareCalls.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,KAAK,EAAkC,MAAM,MAAM,CAAC;AAmB7D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAGhC,MAA4B,EAC5B,MAAoC;IAEpC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;IAEpD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,gBAAgB,EAAE,CAAC;QAC9D,MAAM,CAAC,YAAY,GAAG;YACpB,GAAG,MAAM,CAAC,YAAY;YACtB,gBAAgB,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;SAChD,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG;QACd,GAAG,MAAM;QACT,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,IAAI;KACL,CAAC;IAEF,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE,CAAC,OAAO,CAAC;KAClB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { AccountNotFoundError } from \"@aa-sdk/core\";\nimport { toHex, type Address, type IsUndefined } from \"viem\";\nimport type {\n PrepareCallsParams as IsomorphicPrepareCallsParams,\n PrepareCallsResult as IsomorphicPrepareCallsResult,\n} from \"../../isomorphic/actions/prepareCalls.ts\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\n\nexport type GetAccountParam<TAccount> =\n IsUndefined<TAccount> extends true\n ? { account: Address }\n : { account?: Address };\n\nexport type PrepareCallsParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Omit<IsomorphicPrepareCallsParams, \"from\" | \"chainId\"> &\n (IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });\n\nexport type PrepareCallsResult = IsomorphicPrepareCallsResult;\n\n/**\n * Prepares a set of contract calls for execution by building a user operation.\n * Returns the built user operation and a signature request that needs to be signed\n * before submitting to sendPreparedCalls.\n *\n * @param {InnerWalletApiClient<TAccount>} client - The wallet API client to use for the request\n * @param {PrepareCallsParams<TAccount>} params - Parameters for preparing calls\n * @param {Array<{to: Address, data?: Hex, value?: Hex}>} params.calls - Array of contract calls to execute\n * @param {Address} [params.from] - The address to execute the calls from (required if the client wasn't initialized with an account)\n * @param {object} [params.capabilities] - Optional capabilities to include with the request\n * @returns {Promise<PrepareCallsResult>} A Promise that resolves to the prepared calls result containing\n * the user operation data and signature request\n *\n * @example\n * // Prepare a sponosored user operation call\n * const result = 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 */\nexport async function prepareCalls<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n params: PrepareCallsParams<TAccount>,\n): Promise<PrepareCallsResult> {\n const from = params.from ?? client.account?.address;\n\n if (!from) {\n throw new AccountNotFoundError();\n }\n\n if (client.policyId && !params.capabilities?.paymasterService) {\n params.capabilities = {\n ...params.capabilities,\n paymasterService: { policyId: client.policyId },\n };\n }\n\n const params_ = {\n ...params,\n chainId: toHex(client.chain.id),\n from,\n };\n\n return await client.request({\n method: \"wallet_prepareCalls\",\n params: [params_],\n });\n}\n"]}
|