@account-kit/wallet-client 0.1.0-alpha.3 → 0.1.0-alpha.5
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 +16 -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/permissions/index.d.ts +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 +6 -6
- package/dist/esm/client/actions/grantPermissions.js +115 -3
- 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/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/signSignatureRequest.d.ts +3 -3
- package/dist/esm/client/actions/signSignatureRequest.js +2 -2
- 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 +19 -19
- package/dist/esm/client/client.e2e-test.js.map +1 -1
- package/dist/esm/client/decorator.d.ts +4 -4
- package/dist/esm/client/decorator.js.map +1 -1
- package/dist/esm/client/index.d.ts +36 -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 -2
- package/dist/esm/exports/index.js +1 -1
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/isomorphic/actions/createSession.js +21 -10
- 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 +18 -11
- package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -1
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js +2 -2
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/isomorphic/client.d.ts +1 -1
- package/dist/esm/isomorphic/utils/7702.d.ts +9 -3
- package/dist/esm/isomorphic/utils/7702.js +35 -8
- 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/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.map +1 -1
- package/dist/esm/remote/client.d.ts +8 -2
- package/dist/esm/remote/client.js +1 -7
- package/dist/esm/remote/client.js.map +1 -1
- package/dist/esm/rpc/request.d.ts +12 -2
- package/dist/esm/rpc/request.js +6 -9
- package/dist/esm/rpc/request.js.map +1 -1
- package/dist/esm/rpc/schema.d.ts +23 -13
- package/dist/esm/schemas.d.ts +3 -1
- package/dist/esm/schemas.js +6 -4
- package/dist/esm/schemas.js.map +1 -1
- package/dist/esm/types.d.ts +7 -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 +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 +6 -6
- 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/signMessage.d.ts +3 -3
- package/dist/types/client/actions/signMessage.d.ts.map +1 -1
- package/dist/types/client/actions/signSignatureRequest.d.ts +3 -3
- 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 +4 -4
- package/dist/types/client/decorator.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +36 -10
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +2 -2
- 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/client.d.ts +1 -1
- package/dist/types/isomorphic/utils/7702.d.ts +9 -3
- 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/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/request.d.ts +12 -2
- package/dist/types/rpc/request.d.ts.map +1 -1
- package/dist/types/rpc/schema.d.ts +23 -13
- package/dist/types/rpc/schema.d.ts.map +1 -1
- package/dist/types/schemas.d.ts +3 -1
- package/dist/types/schemas.d.ts.map +1 -1
- package/dist/types/types.d.ts +7 -10
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/capabilities/eip7702Auth.ts +19 -0
- package/src/capabilities/index.ts +2 -0
- package/src/capabilities/permissions/mav2.ts +1 -0
- package/src/client/actions/getCallsStatus.ts +0 -10
- package/src/client/actions/grantPermissions.ts +12 -25
- package/src/client/actions/prepareCalls.ts +18 -23
- package/src/client/actions/requestAccount.ts +9 -26
- package/src/client/actions/signMessage.ts +2 -17
- package/src/client/actions/signSignatureRequest.ts +5 -5
- package/src/client/actions/signTypedData.ts +1 -16
- package/src/client/client.e2e-test.ts +22 -22
- package/src/client/decorator.ts +5 -10
- package/src/client/index.ts +20 -41
- package/src/exports/index.ts +2 -1
- package/src/isomorphic/actions/createSession.ts +29 -10
- package/src/isomorphic/actions/getCallsStatus.ts +82 -10
- package/src/isomorphic/actions/prepareCalls.ts +19 -11
- package/src/isomorphic/actions/sendPreparedCalls.ts +2 -2
- package/src/isomorphic/utils/7702.ts +61 -13
- package/src/isomorphic/utils/createAccount.ts +5 -5
- package/src/isomorphic/utils/parsePermissionsContext.ts +9 -9
- package/src/local/client.ts +3 -5
- package/src/remote/client.ts +5 -13
- package/src/rpc/request.ts +8 -9
- package/src/schemas.ts +8 -4
- package/src/types.ts +5 -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,16 @@
|
|
|
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
|
+
Type.Literal(true),
|
|
15
|
+
]);
|
|
16
|
+
//# 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,CAAC;QACV,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,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACzE,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;SACvD,CAAC;KACH,CAAC;IACF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;CACnB,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 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) => Type.Literal(address)),\n ...EIP_7702_ACCOUNT_TYPE.map((it) => Type.Literal(it)),\n ]),\n }),\n Type.Literal(true),\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"]}
|
|
@@ -92,7 +92,7 @@ export declare const PermissionsData: TObject<{
|
|
|
92
92
|
chainId: import("@sinclair/typebox").TTemplateLiteralSyntax<"0x${string}">;
|
|
93
93
|
expiry: 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<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mav2.js","sourceRoot":"","sources":["../../../../src/capabilities/permissions/mav2.ts"],"names":[],"mappings":"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","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,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,OAAO,WAAW,CAAC,OAAO,EAAE,4BAA4B,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,UAAgD,EACrB,EAAE;IAC7B,IAAI,CAAC,CAAC,SAAS,IAAI,UAAU,CAAC,EAAE,CAAC;QAC/B,OAAO;YACL,cAAc,EAAE,6BAA6B;YAC7C,SAAS,EAAE,UAAU,CAAC,SAAS;YAC/B,SAAS,EAAE,UAAU,CAAC,SAAS;SAChC,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC;IAEjC,MAAM,cAAc,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAsB,CAAC;IAClE,QAAQ,cAAc,EAAE,CAAC;QACvB,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,uBAAuB,GAAG,CAAC,CAAC,CAAC;YAClE,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,EAAE,uBAAuB,GAAG,CAAC,CAAC,CAAC;YAC/D,OAAO;gBACL,cAAc,EAAE,6BAA6B;gBAC7C,SAAS;gBACT,SAAS;aACV,CAAC;QACJ,CAAC;QACD,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,MAAM,cAAc,GAAG,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,10 +1,10 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type {
|
|
3
|
-
import type
|
|
1
|
+
import { type SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
+
import type { Static } from "@sinclair/typebox";
|
|
3
|
+
import { type Address, type Hex, type IsUndefined } from "viem";
|
|
4
4
|
import type { CreateSessionParams } from "../../isomorphic/actions/createSession.ts";
|
|
5
5
|
import { TypeEip7702AuthExtendedFields } from "../../schemas.js";
|
|
6
|
-
import type {
|
|
7
|
-
export type GrantPermissionsParams<TAccount extends
|
|
6
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
7
|
+
export type GrantPermissionsParams<TAccount extends Address | undefined = Address | undefined> = Omit<CreateSessionParams, "account" | "chainId"> & (IsUndefined<TAccount> extends true ? {
|
|
8
8
|
account: Address;
|
|
9
9
|
} : {
|
|
10
10
|
account?: never;
|
|
@@ -122,4 +122,4 @@ export type GrantPermissionsResult = {
|
|
|
122
122
|
* },
|
|
123
123
|
* });
|
|
124
124
|
*/
|
|
125
|
-
export declare function grantPermissions<TAccount extends
|
|
125
|
+
export declare function grantPermissions<TAccount extends Address | undefined = Address | undefined>(client: InnerWalletApiClient, signer: SmartAccountSigner, params: GrantPermissionsParams<TAccount>): Promise<GrantPermissionsResult>;
|
|
@@ -1,11 +1,123 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AccountNotFoundError } from "@aa-sdk/core";
|
|
2
|
+
import { toHex } from "viem";
|
|
2
3
|
import { TypeEip7702AuthExtendedFields } from "../../schemas.js";
|
|
4
|
+
/**
|
|
5
|
+
* Grants permissions to a smart account by creating a session.
|
|
6
|
+
* This allows another key to perform operations on behalf of the account.
|
|
7
|
+
*
|
|
8
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
9
|
+
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
10
|
+
* @param {GrantPermissionsParams} params - The parameters for granting permissions
|
|
11
|
+
* @param {Address} [params.account] - The account address (required if client was not initialized with an account)
|
|
12
|
+
* @param {number} params.expiry - Unix timestamp when the permissions expire
|
|
13
|
+
* @param {object} params.key - The session key information
|
|
14
|
+
* @param {string} params.key.publicKey - The public key of the session key
|
|
15
|
+
* @param {string} params.key.type - The type of the key (e.g., "secp256k1")
|
|
16
|
+
* @param {Array} params.permissions - Array of permission objects defining what the session key can do
|
|
17
|
+
* @returns {Promise<GrantPermissionsResult>} A Promise that resolves to the result containing a context identifier
|
|
18
|
+
* @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
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Create a session key and grant root permissions
|
|
23
|
+
* const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
|
|
24
|
+
* const account = await client.requestAccount();
|
|
25
|
+
*
|
|
26
|
+
* const permissions = await client.grantPermissions({
|
|
27
|
+
* account: account.address,
|
|
28
|
+
* expiry: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour from now
|
|
29
|
+
* key: {
|
|
30
|
+
* publicKey: await sessionKey.getAddress(),
|
|
31
|
+
* type: "secp256k1",
|
|
32
|
+
* },
|
|
33
|
+
* permissions: [{ type: "root" }],
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* // Use the permissions to prepare a call
|
|
37
|
+
* const preparedCall = await client.prepareCalls({
|
|
38
|
+
* calls: [{ to: zeroAddress, value: "0x0" }],
|
|
39
|
+
* from: account.address,
|
|
40
|
+
* capabilities: {
|
|
41
|
+
* paymasterService: {
|
|
42
|
+
* policyId: "your-paymaster-policy-id",
|
|
43
|
+
* },
|
|
44
|
+
* permissions,
|
|
45
|
+
* },
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* // Sign with the session key
|
|
49
|
+
* const signature = await signSignatureRequest(
|
|
50
|
+
* sessionKey,
|
|
51
|
+
* preparedCall.signatureRequest,
|
|
52
|
+
* );
|
|
53
|
+
*
|
|
54
|
+
* // Send the prepared call using the session key
|
|
55
|
+
* const result = await client.sendPreparedCalls({
|
|
56
|
+
* ...preparedCall,
|
|
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,
|
|
108
|
+
* capabilities: {
|
|
109
|
+
* permissions,
|
|
110
|
+
* },
|
|
111
|
+
* });
|
|
112
|
+
*/
|
|
3
113
|
export async function grantPermissions(client, signer, params) {
|
|
4
|
-
|
|
5
|
-
|
|
114
|
+
const account = params.account ?? client.account?.address;
|
|
115
|
+
if (!account) {
|
|
116
|
+
throw new AccountNotFoundError();
|
|
6
117
|
}
|
|
7
118
|
return client.grantPermissions(signer, {
|
|
8
119
|
...params,
|
|
120
|
+
account,
|
|
9
121
|
chainId: toHex(client.chain.id),
|
|
10
122
|
});
|
|
11
123
|
}
|
|
@@ -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;AAE7E,OAAO,EAA4C,KAAK,EAAE,MAAM,MAAM,CAAC;AAEvE,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAejE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4GG;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 { Static } from \"@sinclair/typebox\";\nimport { type Address, type Hex, type IsUndefined, toHex } from \"viem\";\nimport type { CreateSessionParams } from \"../../isomorphic/actions/createSession.ts\";\nimport { TypeEip7702AuthExtendedFields } from \"../../schemas.js\";\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 signedAuthorization?: Static<typeof TypeEip7702AuthExtendedFields>;\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.expiry - 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 * @returns {Static<typeof TypeEip7702AuthExtendedFields>} result.signedAuthorization - The EIP-7702 authorization fields, if applicable\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 preparedCall = 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 signature = await signSignatureRequest(\n * sessionKey,\n * preparedCall.signatureRequest,\n * );\n *\n * // Send the prepared call using the session key\n * const result = await client.sendPreparedCalls({\n * ...preparedCall,\n * signature,\n * capabilities: {\n * permissions,\n * },\n * });\n *\n * @example\n * // Create a session key and grant root permissions using a 7702 account\n * const sessionKey = LocalAccountSigner.generatePrivateKeySigner();\n * const account = await client.requestAccount({\n * creationHint: {\n * accountType: \"7702\",\n * }\n * });\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 preparedCall = 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 * // If the 7702 account delegation is not yet installed, the result\n * // here will include a `signedAuthorization` field that that\n * // must be included when sending the account's first call.\n * const { signedAuthorization, ...signature} = await signSignatureRequest(\n * sessionKey,\n * preparedCall.signatureRequest,\n * );\n *\n * // Send the prepared call using the session key\n * const result = await client.sendPreparedCalls({\n * ...preparedCall,\n * signature,\n * signedAuthorization,\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"]}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { type SmartAccountSigner, type SmartContractAccount } from "@aa-sdk/core";
|
|
2
2
|
import type { Static } from "@sinclair/typebox";
|
|
3
3
|
import type { Address } from "abitype";
|
|
4
|
-
import { type IsUndefined, type JsonRpcAccount } from "viem";
|
|
5
4
|
import type { wallet_requestAccount } from "../../rpc/request.js";
|
|
6
5
|
import type { InnerWalletApiClient } from "../../types.js";
|
|
7
|
-
export type RequestAccountParams
|
|
6
|
+
export type RequestAccountParams = Omit<Extract<Static<typeof wallet_requestAccount>["Request"]["params"][0], {
|
|
8
7
|
signerAddress: Address;
|
|
9
8
|
}>, "signerAddress" | "includeCounterfactualInfo"> & {
|
|
10
9
|
accountAddress?: Address;
|
|
11
|
-
}
|
|
10
|
+
};
|
|
12
11
|
export type RequestAccountResult = SmartContractAccount;
|
|
13
12
|
/**
|
|
14
13
|
* Requests an account for the provided signer using the wallet API client.
|
|
@@ -27,4 +26,4 @@ export type RequestAccountResult = SmartContractAccount;
|
|
|
27
26
|
* const signer = LocalAccountSigner.privateKeyToAccountSigner("0x...");
|
|
28
27
|
* const account = await client.requestAccount(signer);
|
|
29
28
|
*/
|
|
30
|
-
export declare function requestAccount
|
|
29
|
+
export declare function requestAccount(client: InnerWalletApiClient, signer: SmartAccountSigner, params?: RequestAccountParams): Promise<RequestAccountResult>;
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
import {} from "@aa-sdk/core";
|
|
2
2
|
import { Value } from "@sinclair/typebox/value";
|
|
3
|
+
import deepEqual from "deep-equal";
|
|
3
4
|
import { custom } from "viem";
|
|
4
5
|
import { createAccount } from "../../isomorphic/utils/createAccount.js";
|
|
5
6
|
import { TypeSerializedInitcode } from "../../schemas.js";
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Requests an account for the provided signer using the wallet API client.
|
|
9
|
+
* If an account already exists for the signer, it will always return that account unless a new ID is specified.
|
|
10
|
+
* If an account already exists, the creationHint will be ignored.
|
|
11
|
+
*
|
|
12
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
13
|
+
* @param {SmartAccountSigner} signer - The signer that will be associated with the account
|
|
14
|
+
* @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account
|
|
15
|
+
* @param {string} [params.id] - Optional identifier for the account. If specified, a new account with this ID will be created even if one already exists for the signer
|
|
16
|
+
* @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists
|
|
17
|
+
* @returns {Promise<RequestAccountResult>} A Promise that resolves to a SmartContractAccount instance
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Request an account with default parameters using a local signer
|
|
21
|
+
* const signer = LocalAccountSigner.privateKeyToAccountSigner("0x...");
|
|
22
|
+
* const account = await client.requestAccount(signer);
|
|
23
|
+
*/
|
|
7
24
|
export async function requestAccount(client, signer, params) {
|
|
8
25
|
const args = (client.account && !params) || params?.accountAddress
|
|
9
26
|
? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/requestAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"requestAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/requestAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAExE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAa1D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA0B,EAC1B,MAA6B;IAE7B,MAAM,IAAI,GACR,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,MAAM,EAAE,cAAc;QACnD,CAAC,CAAC;YACE,cAAc,EAAE,MAAM,EAAE,cAAc,IAAI,MAAM,CAAC,OAAQ,CAAC,OAAO;YACjE,yBAAyB,EAAE,IAAI;SAChC;QACH,CAAC,CAAC;YACE,GAAG,MAAM;YACT,aAAa,EAAE,MAAM,MAAM,CAAC,UAAU,EAAE;YACxC,yBAAyB,EAAE,IAAI;SAChC,CAAC;IAER,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACnD,IACE,aAAa;QACb,CAAC,CAAC,IAAI,CAAC,cAAc;YACnB,aAAa,CAAC,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC,cAAc,CAAC;YACtD,SAAS,CAAC,aAAa,CAAC,aAAa,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EACjE,CAAC;QACD,OAAO,aAAa,CAAC,OAAO,CAAC;IAC/B,CAAC;IAED,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClE,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,IAAI,CAAC;KACf,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC;QAClC,cAAc;QACd,kBAAkB,EAAE,KAAK,CAAC,KAAK,CAC7B,sBAAsB,EACtB,kBAAmB,CACpB;QACD,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;QACnC,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAE7D,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import {\n type SmartAccountSigner,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport type { Address } from \"abitype\";\nimport deepEqual from \"deep-equal\";\nimport { custom } from \"viem\";\nimport { createAccount } from \"../../isomorphic/utils/createAccount.js\";\nimport type { wallet_requestAccount } from \"../../rpc/request.js\";\nimport { TypeSerializedInitcode } from \"../../schemas.js\";\nimport type { InnerWalletApiClient } from \"../../types.js\";\n\nexport type RequestAccountParams = Omit<\n Extract<\n Static<typeof wallet_requestAccount>[\"Request\"][\"params\"][0],\n { signerAddress: Address }\n >,\n \"signerAddress\" | \"includeCounterfactualInfo\"\n> & { accountAddress?: Address };\n\nexport type RequestAccountResult = SmartContractAccount;\n\n/**\n * Requests an account for the provided signer using the wallet API client.\n * If an account already exists for the signer, it will always return that account unless a new ID is specified.\n * If an account already exists, the creationHint will be ignored.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer that will be associated with the account\n * @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account\n * @param {string} [params.id] - Optional identifier for the account. If specified, a new account with this ID will be created even if one already exists for the signer\n * @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists\n * @returns {Promise<RequestAccountResult>} A Promise that resolves to a SmartContractAccount instance\n *\n * @example\n * // Request an account with default parameters using a local signer\n * const signer = LocalAccountSigner.privateKeyToAccountSigner(\"0x...\");\n * const account = await client.requestAccount(signer);\n */\nexport async function requestAccount(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params?: RequestAccountParams,\n): Promise<RequestAccountResult> {\n const args =\n (client.account && !params) || params?.accountAddress\n ? {\n accountAddress: params?.accountAddress ?? client.account!.address,\n includeCounterfactualInfo: true,\n }\n : {\n ...params,\n signerAddress: await signer.getAddress(),\n includeCounterfactualInfo: true,\n };\n\n const cachedAccount = client.internal.getAccount();\n if (\n cachedAccount &&\n ((args.accountAddress &&\n cachedAccount.account.address === args.accountAddress) ||\n deepEqual(cachedAccount.requestParams, args, { strict: true }))\n ) {\n return cachedAccount.account;\n }\n\n const { counterfactualInfo, accountAddress } = await client.request({\n method: \"wallet_requestAccount\",\n params: [args],\n });\n\n const account = await createAccount({\n accountAddress,\n counterfactualInfo: Value.Parse(\n TypeSerializedInitcode,\n counterfactualInfo!,\n ),\n chain: client.chain,\n transport: custom(client.transport),\n signer,\n });\n\n client.internal.setAccount({ account, requestParams: args });\n\n return account;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { type Address, type Hex, type
|
|
1
|
+
import { type SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
+
import { type Address, type Hex, type SignableMessage } from "viem";
|
|
3
3
|
import type { InnerWalletApiClient } from "../../types.ts";
|
|
4
4
|
export type SignMessageParams = {
|
|
5
5
|
message: SignableMessage;
|
|
@@ -23,4 +23,4 @@ export type SignMessageResult = Hex;
|
|
|
23
23
|
* // Sign a raw hex message
|
|
24
24
|
* const signature = await client.signMessage({ raw: "0x48656c6c6f2c20776f726c6421" });
|
|
25
25
|
*/
|
|
26
|
-
export declare function signMessage
|
|
26
|
+
export declare function signMessage(client: InnerWalletApiClient, signer: SmartAccountSigner, params: SignMessageParams): Promise<SignMessageResult>;
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
+
import {} from "@aa-sdk/core";
|
|
1
2
|
import {} from "viem";
|
|
2
3
|
import { requestAccount } from "./requestAccount.js";
|
|
4
|
+
/**
|
|
5
|
+
* Signs a message using the smart account.
|
|
6
|
+
* This method requests the account associated with the signer and uses it to sign the message.
|
|
7
|
+
*
|
|
8
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
9
|
+
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
10
|
+
* @param {SignableMessage} message - The message to sign
|
|
11
|
+
* @returns {Promise<SignMessageResult>} A Promise that resolves to the signed message as a hex string
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Sign a simple text message
|
|
15
|
+
* const signature = await client.signMessage("Hello, world!");
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Sign a raw hex message
|
|
19
|
+
* const signature = await client.signMessage({ raw: "0x48656c6c6f2c20776f726c6421" });
|
|
20
|
+
*/
|
|
3
21
|
export async function signMessage(client, signer, params) {
|
|
4
22
|
const account = await requestAccount(client, signer, {
|
|
5
23
|
accountAddress: params.account ?? client.account?.address,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signMessage.js","sourceRoot":"","sources":["../../../../src/client/actions/signMessage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signMessage.js","sourceRoot":"","sources":["../../../../src/client/actions/signMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,MAAM,cAAc,CAAC;AACvD,OAAO,EAAgD,MAAM,MAAM,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAMrD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAA4B,EAC5B,MAA0B,EAC1B,MAAyB;IAEzB,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE;QACnD,cAAc,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO;KAC1D,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import { type SmartAccountSigner } from \"@aa-sdk/core\";\nimport { type Address, type Hex, type SignableMessage } from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport { requestAccount } from \"./requestAccount.js\";\n\nexport type SignMessageParams = { message: SignableMessage; account?: Address };\n\nexport type SignMessageResult = Hex;\n\n/**\n * Signs a message using the smart account.\n * This method requests the account associated with the signer and uses it to sign the message.\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 {SignableMessage} message - The message to sign\n * @returns {Promise<SignMessageResult>} A Promise that resolves to the signed message as a hex string\n *\n * @example\n * // Sign a simple text message\n * const signature = await client.signMessage(\"Hello, world!\");\n *\n * @example\n * // Sign a raw hex message\n * const signature = await client.signMessage({ raw: \"0x48656c6c6f2c20776f726c6421\" });\n */\nexport async function signMessage(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params: SignMessageParams,\n): Promise<SignMessageResult> {\n const account = await requestAccount(client, signer, {\n accountAddress: params.account ?? client.account?.address,\n });\n\n return account.signMessageWith6492({ message: params.message });\n}\n"]}
|