@account-kit/wallet-client 0.1.0-alpha.1 → 0.1.0-alpha.10
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/client/actions/createAccount.d.ts +27 -2
- package/dist/esm/client/actions/createAccount.js +25 -0
- package/dist/esm/client/actions/createAccount.js.map +1 -1
- package/dist/esm/client/actions/formatSign.d.ts +28 -0
- package/dist/esm/client/actions/formatSign.js +30 -0
- package/dist/esm/client/actions/formatSign.js.map +1 -0
- package/dist/esm/client/actions/getCallsStatus.d.ts +22 -4
- 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 +63 -6
- package/dist/esm/client/actions/grantPermissions.js +63 -3
- package/dist/esm/client/actions/grantPermissions.js.map +1 -1
- package/dist/esm/client/actions/listAccounts.d.ts +32 -4
- package/dist/esm/client/actions/listAccounts.js +35 -2
- package/dist/esm/client/actions/listAccounts.js.map +1 -1
- package/dist/esm/client/actions/prepareCalls.d.ts +32 -6
- package/dist/esm/client/actions/prepareCalls.js +39 -5
- package/dist/esm/client/actions/prepareCalls.js.map +1 -1
- package/dist/esm/client/actions/prepareSign.d.ts +25 -0
- package/dist/esm/client/actions/prepareSign.js +28 -0
- package/dist/esm/client/actions/prepareSign.js.map +1 -0
- package/dist/esm/client/actions/requestAccount.d.ts +24 -6
- package/dist/esm/client/actions/requestAccount.js +38 -7
- package/dist/esm/client/actions/requestAccount.js.map +1 -1
- package/dist/esm/client/actions/sendPreparedCalls.d.ts +33 -4
- package/dist/esm/client/actions/sendPreparedCalls.js +37 -1
- package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/client/actions/signMessage.d.ts +25 -5
- package/dist/esm/client/actions/signMessage.js +22 -2
- 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 +43 -0
- package/dist/esm/client/actions/signPreparedCalls.js.map +1 -0
- package/dist/esm/client/actions/signSignatureRequest.d.ts +39 -5
- package/dist/esm/client/actions/signSignatureRequest.js +69 -11
- package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
- package/dist/esm/client/actions/signTypedData.d.ts +37 -4
- package/dist/esm/client/actions/signTypedData.js +34 -1
- package/dist/esm/client/actions/signTypedData.js.map +1 -1
- package/dist/esm/client/client.e2e-test.js +210 -45
- package/dist/esm/client/client.e2e-test.js.map +1 -1
- package/dist/esm/client/decorator.d.ts +12 -8
- package/dist/esm/client/decorator.js +5 -3
- package/dist/esm/client/decorator.js.map +1 -1
- package/dist/esm/client/index.d.ts +38 -12
- package/dist/esm/client/index.js +0 -3
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/exports/index.d.ts +5 -6
- package/dist/esm/exports/index.js +4 -6
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/internal.d.ts +1 -10
- package/dist/esm/exports/internal.js +0 -12
- package/dist/esm/exports/internal.js.map +1 -1
- package/dist/esm/internal/decorator.d.ts +2 -0
- package/dist/esm/internal/decorator.js +10 -0
- package/dist/esm/internal/decorator.js.map +1 -0
- package/dist/esm/isomorphic/actions/createSession.d.ts +1 -2
- package/dist/esm/isomorphic/actions/createSession.js +39 -10
- package/dist/esm/isomorphic/actions/createSession.js.map +1 -1
- package/dist/esm/isomorphic/actions/formatSign.d.ts +8 -0
- package/dist/esm/isomorphic/actions/formatSign.js +42 -0
- package/dist/esm/isomorphic/actions/formatSign.js.map +1 -0
- package/dist/esm/isomorphic/actions/getCallsStatus.d.ts +1 -15
- package/dist/esm/isomorphic/actions/getCallsStatus.js +37 -26
- package/dist/esm/isomorphic/actions/getCallsStatus.js.map +1 -1
- package/dist/esm/isomorphic/actions/prepareCalls.d.ts +1 -2
- package/dist/esm/isomorphic/actions/prepareCalls.js +78 -20
- package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -1
- package/dist/esm/isomorphic/actions/prepareSign.d.ts +7 -0
- package/dist/esm/isomorphic/actions/prepareSign.js +49 -0
- package/dist/esm/isomorphic/actions/prepareSign.js.map +1 -0
- package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +3 -4
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js +138 -25
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/isomorphic/client.d.ts +204 -27
- package/dist/esm/isomorphic/client.js +6 -2
- package/dist/esm/isomorphic/client.js.map +1 -1
- package/dist/esm/isomorphic/utils/7702.d.ts +19 -0
- package/dist/esm/isomorphic/utils/7702.js +70 -0
- package/dist/esm/isomorphic/utils/7702.js.map +1 -0
- package/dist/esm/isomorphic/utils/createAccount.d.ts +5 -4
- package/dist/esm/isomorphic/utils/createAccount.js +84 -10
- package/dist/esm/isomorphic/utils/createAccount.js.map +1 -1
- package/dist/esm/isomorphic/utils/createDummySigner.js +3 -3
- package/dist/esm/isomorphic/utils/createDummySigner.js.map +1 -1
- package/dist/esm/isomorphic/utils/decodeSignature.d.ts +3 -0
- package/dist/esm/isomorphic/utils/decodeSignature.js +15 -0
- package/dist/esm/isomorphic/utils/decodeSignature.js.map +1 -0
- package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +6 -5
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js +19 -6
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +1 -1
- package/dist/esm/isomorphic/utils/supportsFeature.d.ts +4 -0
- package/dist/esm/isomorphic/utils/supportsFeature.js +21 -0
- package/dist/esm/isomorphic/utils/supportsFeature.js.map +1 -0
- package/dist/esm/local/client.d.ts +3 -3
- package/dist/esm/local/client.js +11 -4
- package/dist/esm/local/client.js.map +1 -1
- package/dist/esm/remote/client.d.ts +9 -3
- package/dist/esm/remote/client.js +10 -11
- package/dist/esm/remote/client.js.map +1 -1
- package/dist/esm/types.d.ts +27 -13
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils.d.ts +1 -0
- package/dist/esm/utils.js.map +1 -1
- package/dist/types/client/actions/createAccount.d.ts +27 -2
- package/dist/types/client/actions/createAccount.d.ts.map +1 -1
- package/dist/types/client/actions/formatSign.d.ts +29 -0
- package/dist/types/client/actions/formatSign.d.ts.map +1 -0
- package/dist/types/client/actions/getCallsStatus.d.ts +22 -4
- package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
- package/dist/types/client/actions/grantPermissions.d.ts +63 -6
- package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
- package/dist/types/client/actions/listAccounts.d.ts +32 -4
- package/dist/types/client/actions/listAccounts.d.ts.map +1 -1
- package/dist/types/client/actions/prepareCalls.d.ts +32 -6
- package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/client/actions/prepareSign.d.ts +26 -0
- package/dist/types/client/actions/prepareSign.d.ts.map +1 -0
- package/dist/types/client/actions/requestAccount.d.ts +24 -6
- package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
- package/dist/types/client/actions/sendPreparedCalls.d.ts +33 -4
- package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/client/actions/signMessage.d.ts +25 -5
- 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 +39 -5
- package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
- package/dist/types/client/actions/signTypedData.d.ts +37 -4
- package/dist/types/client/actions/signTypedData.d.ts.map +1 -1
- package/dist/types/client/decorator.d.ts +12 -8
- package/dist/types/client/decorator.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +38 -12
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +5 -6
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/exports/internal.d.ts +1 -10
- package/dist/types/exports/internal.d.ts.map +1 -1
- package/dist/types/internal/decorator.d.ts +3 -0
- package/dist/types/internal/decorator.d.ts.map +1 -0
- package/dist/types/isomorphic/actions/createSession.d.ts +1 -2
- package/dist/types/isomorphic/actions/createSession.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/formatSign.d.ts +9 -0
- package/dist/types/isomorphic/actions/formatSign.d.ts.map +1 -0
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts +1 -15
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/prepareCalls.d.ts +1 -2
- package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/prepareSign.d.ts +8 -0
- package/dist/types/isomorphic/actions/prepareSign.d.ts.map +1 -0
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +3 -4
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/isomorphic/client.d.ts +204 -27
- package/dist/types/isomorphic/client.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/7702.d.ts +20 -0
- package/dist/types/isomorphic/utils/7702.d.ts.map +1 -0
- package/dist/types/isomorphic/utils/createAccount.d.ts +5 -4
- package/dist/types/isomorphic/utils/createAccount.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/createDummySigner.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 +6 -5
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/supportsFeature.d.ts +5 -0
- package/dist/types/isomorphic/utils/supportsFeature.d.ts.map +1 -0
- package/dist/types/local/client.d.ts +3 -3
- package/dist/types/local/client.d.ts.map +1 -1
- package/dist/types/remote/client.d.ts +9 -3
- package/dist/types/remote/client.d.ts.map +1 -1
- package/dist/types/types.d.ts +27 -13
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +1 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +9 -6
- package/src/client/actions/createAccount.ts +27 -2
- package/src/client/actions/formatSign.ts +53 -0
- package/src/client/actions/getCallsStatus.ts +21 -12
- package/src/client/actions/grantPermissions.ts +69 -26
- package/src/client/actions/listAccounts.ts +44 -6
- package/src/client/actions/prepareCalls.ts +46 -26
- package/src/client/actions/prepareSign.ts +46 -0
- package/src/client/actions/requestAccount.ts +60 -41
- package/src/client/actions/sendPreparedCalls.ts +44 -7
- package/src/client/actions/signMessage.ts +26 -21
- package/src/client/actions/signPreparedCalls.ts +67 -0
- package/src/client/actions/signSignatureRequest.ts +84 -20
- package/src/client/actions/signTypedData.ts +40 -19
- package/src/client/client.e2e-test.ts +256 -54
- package/src/client/decorator.ts +28 -26
- package/src/client/index.ts +50 -40
- package/src/exports/index.ts +5 -13
- package/src/exports/internal.ts +2 -10
- package/src/internal/decorator.ts +12 -0
- package/src/isomorphic/actions/createSession.ts +55 -12
- package/src/isomorphic/actions/formatSign.ts +76 -0
- package/src/isomorphic/actions/getCallsStatus.ts +46 -32
- package/src/isomorphic/actions/prepareCalls.ts +95 -23
- package/src/isomorphic/actions/prepareSign.ts +91 -0
- package/src/isomorphic/actions/sendPreparedCalls.ts +181 -42
- package/src/isomorphic/client.ts +10 -2
- package/src/isomorphic/utils/7702.ts +135 -0
- package/src/isomorphic/utils/createAccount.ts +101 -13
- package/src/isomorphic/utils/createDummySigner.ts +3 -2
- package/src/isomorphic/utils/decodeSignature.ts +21 -0
- package/src/isomorphic/utils/parsePermissionsContext.ts +29 -11
- package/src/isomorphic/utils/supportsFeature.ts +34 -0
- package/src/local/client.ts +58 -55
- package/src/remote/client.ts +19 -19
- package/src/types.ts +29 -23
- package/src/utils.ts +2 -0
- package/dist/esm/capabilities/index.d.ts +0 -31
- package/dist/esm/capabilities/index.js +0 -10
- package/dist/esm/capabilities/index.js.map +0 -1
- package/dist/esm/capabilities/overrides.d.ts +0 -26
- package/dist/esm/capabilities/overrides.js +0 -14
- package/dist/esm/capabilities/overrides.js.map +0 -1
- package/dist/esm/capabilities/paymaster.d.ts +0 -3
- package/dist/esm/capabilities/paymaster.js +0 -5
- package/dist/esm/capabilities/paymaster.js.map +0 -1
- package/dist/esm/capabilities/permissions/index.d.ts +0 -138
- package/dist/esm/capabilities/permissions/index.js +0 -71
- package/dist/esm/capabilities/permissions/index.js.map +0 -1
- package/dist/esm/capabilities/permissions/mav2.d.ts +0 -36
- package/dist/esm/capabilities/permissions/mav2.js +0 -79
- package/dist/esm/capabilities/permissions/mav2.js.map +0 -1
- package/dist/esm/rpc/request.d.ts +0 -352
- package/dist/esm/rpc/request.js +0 -204
- package/dist/esm/rpc/request.js.map +0 -1
- package/dist/esm/rpc/schema.d.ts +0 -342
- package/dist/esm/rpc/schema.js +0 -5
- package/dist/esm/rpc/schema.js.map +0 -1
- package/dist/esm/schemas.d.ts +0 -216
- package/dist/esm/schemas.js +0 -211
- package/dist/esm/schemas.js.map +0 -1
- package/dist/types/capabilities/index.d.ts +0 -32
- package/dist/types/capabilities/index.d.ts.map +0 -1
- package/dist/types/capabilities/overrides.d.ts +0 -27
- package/dist/types/capabilities/overrides.d.ts.map +0 -1
- package/dist/types/capabilities/paymaster.d.ts +0 -4
- package/dist/types/capabilities/paymaster.d.ts.map +0 -1
- package/dist/types/capabilities/permissions/index.d.ts +0 -139
- package/dist/types/capabilities/permissions/index.d.ts.map +0 -1
- package/dist/types/capabilities/permissions/mav2.d.ts +0 -37
- package/dist/types/capabilities/permissions/mav2.d.ts.map +0 -1
- package/dist/types/rpc/request.d.ts +0 -353
- package/dist/types/rpc/request.d.ts.map +0 -1
- package/dist/types/rpc/schema.d.ts +0 -343
- package/dist/types/rpc/schema.d.ts.map +0 -1
- package/dist/types/schemas.d.ts +0 -217
- package/dist/types/schemas.d.ts.map +0 -1
- package/src/capabilities/index.ts +0 -13
- package/src/capabilities/overrides.ts +0 -20
- package/src/capabilities/paymaster.ts +0 -5
- package/src/capabilities/permissions/index.ts +0 -142
- package/src/capabilities/permissions/mav2.ts +0 -127
- package/src/rpc/request.ts +0 -273
- package/src/rpc/schema.ts +0 -40
- package/src/schemas.ts +0 -257
|
@@ -2,7 +2,6 @@ import { LocalAccountSigner } from "@aa-sdk/core";
|
|
|
2
2
|
import { alchemy, arbitrumSepolia } from "@account-kit/infra";
|
|
3
3
|
import { describe, expect, it } from "bun:test";
|
|
4
4
|
import { createPublicClient, zeroAddress, type Address } from "viem";
|
|
5
|
-
import { signSignatureRequest } from "./actions/signSignatureRequest.js";
|
|
6
5
|
import { createSmartWalletClient } from "./index.js";
|
|
7
6
|
|
|
8
7
|
describe("Client E2E Tests", () => {
|
|
@@ -17,7 +16,7 @@ describe("Client E2E Tests", () => {
|
|
|
17
16
|
);
|
|
18
17
|
describe("Local Mode Tests", () => {
|
|
19
18
|
const signer = LocalAccountSigner.privateKeyToAccountSigner(
|
|
20
|
-
"
|
|
19
|
+
"0xbaca22d9b6846ec09a4da378ffa07e2f14ce7d65675d135911b6fd281416bb03",
|
|
21
20
|
);
|
|
22
21
|
|
|
23
22
|
const client = createSmartWalletClient({
|
|
@@ -35,21 +34,38 @@ describe("Client E2E Tests", () => {
|
|
|
35
34
|
it("should successfully get a counterfactual address", async () => {
|
|
36
35
|
const account = await client.requestAccount();
|
|
37
36
|
expect(account.address).toMatchInlineSnapshot(
|
|
38
|
-
`"
|
|
37
|
+
`"0xa46944b7a39c35d931D514ACAc3ac77c226a81ff"`,
|
|
39
38
|
);
|
|
40
39
|
});
|
|
41
40
|
|
|
41
|
+
it("should successfully request account with different salt", async () => {
|
|
42
|
+
const account = await client.requestAccount({
|
|
43
|
+
id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
|
|
44
|
+
creationHint: { salt: "0x1" },
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
expect(account.address).toMatchInlineSnapshot(
|
|
48
|
+
`"0xA692f0E5AfAD20F771443D89C635146C6A592f06"`,
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("should not cache account if different inputs provided", async () => {
|
|
53
|
+
const account = await client.requestAccount();
|
|
54
|
+
const account2 = await client.requestAccount({
|
|
55
|
+
id: "52ab44be-b03e-47ed-ad65-43014ea5fbfc",
|
|
56
|
+
creationHint: { salt: "0x2" },
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
expect(account.address).not.toEqual(account2.address);
|
|
60
|
+
});
|
|
61
|
+
|
|
42
62
|
it("can correctly sign a message", async () => {
|
|
43
63
|
const account = await client.requestAccount();
|
|
44
64
|
const message = "hello world";
|
|
45
|
-
const signature = await client.signMessage(message);
|
|
46
|
-
const publicClient = createPublicClient({
|
|
47
|
-
chain: arbitrumSepolia,
|
|
48
|
-
transport,
|
|
49
|
-
});
|
|
65
|
+
const signature = await client.signMessage({ message });
|
|
50
66
|
const isValid = await publicClient.verifyMessage({
|
|
51
67
|
address: account.address,
|
|
52
|
-
message
|
|
68
|
+
message,
|
|
53
69
|
signature,
|
|
54
70
|
});
|
|
55
71
|
expect(isValid).toBeTrue();
|
|
@@ -66,9 +82,62 @@ describe("Client E2E Tests", () => {
|
|
|
66
82
|
expect(isValid).toBeTrue();
|
|
67
83
|
});
|
|
68
84
|
|
|
69
|
-
it("
|
|
70
|
-
const account = await client.requestAccount(
|
|
71
|
-
|
|
85
|
+
it("can correctly sign a message with a different account", async () => {
|
|
86
|
+
const account = await client.requestAccount({
|
|
87
|
+
id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
|
|
88
|
+
creationHint: { salt: "0x1" },
|
|
89
|
+
});
|
|
90
|
+
const message = "hello world";
|
|
91
|
+
|
|
92
|
+
const signature = await client.signMessage({
|
|
93
|
+
message,
|
|
94
|
+
account: account.address,
|
|
95
|
+
});
|
|
96
|
+
const isValid = await publicClient.verifyMessage({
|
|
97
|
+
address: account.address,
|
|
98
|
+
message,
|
|
99
|
+
signature,
|
|
100
|
+
});
|
|
101
|
+
expect(isValid).toBeTrue();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("can correctly sign typed data with a different account", async () => {
|
|
105
|
+
const account = await client.requestAccount({
|
|
106
|
+
id: "f4c1d956-24ef-4002-a141-2c9d6d92af1a",
|
|
107
|
+
creationHint: { salt: "0x1" },
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const signature = await client.signTypedData({
|
|
111
|
+
...givenTypedData,
|
|
112
|
+
account: account.address,
|
|
113
|
+
});
|
|
114
|
+
const isValid = await publicClient.verifyTypedData({
|
|
115
|
+
...givenTypedData,
|
|
116
|
+
signature,
|
|
117
|
+
address: account.address,
|
|
118
|
+
});
|
|
119
|
+
expect(isValid).toBeTrue();
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("should successfully send a UO with paymaster using 7702", async () => {
|
|
123
|
+
const _signer = LocalAccountSigner.privateKeyToAccountSigner(
|
|
124
|
+
"0x49daf21e92c997093e9ffdf7e7ddbf8970e9eadc5d4847d0f690db25d5128e1f",
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const _client = createSmartWalletClient({
|
|
128
|
+
transport,
|
|
129
|
+
chain: arbitrumSepolia,
|
|
130
|
+
mode: "local",
|
|
131
|
+
signer: _signer,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const account = await _client.requestAccount({
|
|
135
|
+
creationHint: {
|
|
136
|
+
accountType: "7702",
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const preparedCalls = await _client.prepareCalls({
|
|
72
141
|
calls: [{ to: zeroAddress, value: "0x0" }],
|
|
73
142
|
from: account.address,
|
|
74
143
|
capabilities: {
|
|
@@ -78,22 +147,29 @@ describe("Client E2E Tests", () => {
|
|
|
78
147
|
},
|
|
79
148
|
});
|
|
80
149
|
|
|
81
|
-
|
|
82
|
-
throw new Error("Invalid signature request type");
|
|
83
|
-
}
|
|
150
|
+
const signedCalls = await _client.signPreparedCalls(preparedCalls);
|
|
84
151
|
|
|
85
|
-
const
|
|
86
|
-
preparedUO.signatureRequest.data,
|
|
87
|
-
);
|
|
152
|
+
const result = await _client.sendPreparedCalls(signedCalls);
|
|
88
153
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
154
|
+
expect(result.preparedCallIds).toBeArrayOfSize(1);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("should successfully send a UO with paymaster", async () => {
|
|
158
|
+
const account = await client.requestAccount();
|
|
159
|
+
const preparedCalls = await client.prepareCalls({
|
|
160
|
+
calls: [{ to: zeroAddress, value: "0x0" }],
|
|
161
|
+
from: account.address,
|
|
162
|
+
capabilities: {
|
|
163
|
+
paymasterService: {
|
|
164
|
+
policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
|
|
165
|
+
},
|
|
94
166
|
},
|
|
95
167
|
});
|
|
96
168
|
|
|
169
|
+
const signedCalls = await client.signPreparedCalls(preparedCalls);
|
|
170
|
+
|
|
171
|
+
const result = await client.sendPreparedCalls(signedCalls);
|
|
172
|
+
|
|
97
173
|
expect(result.preparedCallIds).toBeArrayOfSize(1);
|
|
98
174
|
});
|
|
99
175
|
|
|
@@ -104,7 +180,7 @@ describe("Client E2E Tests", () => {
|
|
|
104
180
|
|
|
105
181
|
const permissions = await client.grantPermissions({
|
|
106
182
|
account: account.address,
|
|
107
|
-
|
|
183
|
+
expirySec: Math.floor(Date.now() / 1000) + 60 * 60,
|
|
108
184
|
key: {
|
|
109
185
|
publicKey: await sessionKey.getAddress(),
|
|
110
186
|
type: "secp256k1",
|
|
@@ -112,7 +188,14 @@ describe("Client E2E Tests", () => {
|
|
|
112
188
|
permissions: [{ type: "root" }],
|
|
113
189
|
});
|
|
114
190
|
|
|
115
|
-
const
|
|
191
|
+
const sessionKeyClient = createSmartWalletClient({
|
|
192
|
+
transport,
|
|
193
|
+
chain: arbitrumSepolia,
|
|
194
|
+
mode: "local",
|
|
195
|
+
signer: sessionKey,
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
const preparedCalls = await sessionKeyClient.prepareCalls({
|
|
116
199
|
calls: [{ to: zeroAddress, value: "0x0" }],
|
|
117
200
|
from: account.address,
|
|
118
201
|
capabilities: {
|
|
@@ -123,14 +206,11 @@ describe("Client E2E Tests", () => {
|
|
|
123
206
|
},
|
|
124
207
|
});
|
|
125
208
|
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
preparedUO.signatureRequest,
|
|
129
|
-
);
|
|
209
|
+
const signedCalls =
|
|
210
|
+
await sessionKeyClient.signPreparedCalls(preparedCalls);
|
|
130
211
|
|
|
131
|
-
const result = await
|
|
132
|
-
...
|
|
133
|
-
signature,
|
|
212
|
+
const result = await sessionKeyClient.sendPreparedCalls({
|
|
213
|
+
...signedCalls,
|
|
134
214
|
capabilities: {
|
|
135
215
|
permissions,
|
|
136
216
|
},
|
|
@@ -142,7 +222,7 @@ describe("Client E2E Tests", () => {
|
|
|
142
222
|
|
|
143
223
|
describe("Remote Mode Tests", () => {
|
|
144
224
|
const signer = LocalAccountSigner.privateKeyToAccountSigner(
|
|
145
|
-
"
|
|
225
|
+
"0xd7b061ef04d29cf68b3c89356678eccec9988de8d5ed892c19461c4a9d65925d",
|
|
146
226
|
);
|
|
147
227
|
|
|
148
228
|
const client = createSmartWalletClient({
|
|
@@ -160,18 +240,35 @@ describe("Client E2E Tests", () => {
|
|
|
160
240
|
it("should successfully get a counterfactual address", async () => {
|
|
161
241
|
const account = await client.requestAccount();
|
|
162
242
|
expect(account.address).toMatchInlineSnapshot(
|
|
163
|
-
`"
|
|
243
|
+
`"0x76E765e80FFAC96ac10Aa8908a8267A3B80d606D"`,
|
|
244
|
+
);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it("should successfully request account with different salt", async () => {
|
|
248
|
+
const account = await client.requestAccount({
|
|
249
|
+
id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
|
|
250
|
+
creationHint: { salt: "0x1" },
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
expect(account.address).toMatchInlineSnapshot(
|
|
254
|
+
`"0xdfdd407b9569D40BEFa503208753E59cAc9713fA"`,
|
|
164
255
|
);
|
|
165
256
|
});
|
|
166
257
|
|
|
258
|
+
it("should not cache account if different inputs provided", async () => {
|
|
259
|
+
const account = await client.requestAccount();
|
|
260
|
+
const account2 = await client.requestAccount({
|
|
261
|
+
id: "2a3320b4-6ed2-4833-a488-5188e9bdd9d2",
|
|
262
|
+
creationHint: { salt: "0x2" },
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
expect(account.address).not.toEqual(account2.address);
|
|
266
|
+
});
|
|
267
|
+
|
|
167
268
|
it("can correctly sign a message", async () => {
|
|
168
269
|
const account = await client.requestAccount();
|
|
169
270
|
const message = "hello world";
|
|
170
|
-
const signature = await client.signMessage(message);
|
|
171
|
-
const publicClient = createPublicClient({
|
|
172
|
-
chain: arbitrumSepolia,
|
|
173
|
-
transport,
|
|
174
|
-
});
|
|
271
|
+
const signature = await client.signMessage({ message });
|
|
175
272
|
const isValid = await publicClient.verifyMessage({
|
|
176
273
|
address: account.address,
|
|
177
274
|
message: "hello world",
|
|
@@ -191,9 +288,66 @@ describe("Client E2E Tests", () => {
|
|
|
191
288
|
expect(isValid).toBeTrue();
|
|
192
289
|
});
|
|
193
290
|
|
|
291
|
+
it("can correctly sign a message with a different account", async () => {
|
|
292
|
+
const account = await client.requestAccount({
|
|
293
|
+
id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
|
|
294
|
+
creationHint: { salt: "0x1" },
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
const message = "hello world";
|
|
298
|
+
const signature = await client.signMessage({
|
|
299
|
+
message,
|
|
300
|
+
account: account.address,
|
|
301
|
+
});
|
|
302
|
+
const isValid = await publicClient.verifyMessage({
|
|
303
|
+
address: account.address,
|
|
304
|
+
message: "hello world",
|
|
305
|
+
signature,
|
|
306
|
+
});
|
|
307
|
+
expect(isValid).toBeTrue();
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it("can correctly sign typed data with a different account", async () => {
|
|
311
|
+
const account = await client.requestAccount({
|
|
312
|
+
id: "26b375e3-c94a-4e98-b6b7-5a97121aa583",
|
|
313
|
+
creationHint: { salt: "0x1" },
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
const signature = await client.signTypedData({
|
|
317
|
+
...givenTypedData,
|
|
318
|
+
account: account.address,
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
const isValid = await publicClient.verifyTypedData({
|
|
322
|
+
...givenTypedData,
|
|
323
|
+
signature,
|
|
324
|
+
address: account.address,
|
|
325
|
+
});
|
|
326
|
+
expect(isValid).toBeTrue();
|
|
327
|
+
});
|
|
328
|
+
|
|
194
329
|
it("should successfully send a UO with paymaster", async () => {
|
|
195
330
|
const account = await client.requestAccount();
|
|
196
|
-
const
|
|
331
|
+
const preparedCalls = await client.prepareCalls({
|
|
332
|
+
calls: [{ to: zeroAddress, value: "0x0" }],
|
|
333
|
+
from: account.address,
|
|
334
|
+
capabilities: {
|
|
335
|
+
paymasterService: {
|
|
336
|
+
policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
|
|
337
|
+
},
|
|
338
|
+
},
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
const signedCalls = await client.signPreparedCalls(preparedCalls);
|
|
342
|
+
|
|
343
|
+
const result = await client.sendPreparedCalls(signedCalls);
|
|
344
|
+
|
|
345
|
+
expect(result.preparedCallIds).toBeArrayOfSize(1);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
it("should successfully drop and replace a UO with repeat calls", async () => {
|
|
349
|
+
const account = await client.requestAccount();
|
|
350
|
+
const preparedCalls = await client.prepareCalls({
|
|
197
351
|
calls: [{ to: zeroAddress, value: "0x0" }],
|
|
198
352
|
from: account.address,
|
|
199
353
|
capabilities: {
|
|
@@ -203,15 +357,59 @@ describe("Client E2E Tests", () => {
|
|
|
203
357
|
},
|
|
204
358
|
});
|
|
205
359
|
|
|
206
|
-
const
|
|
207
|
-
|
|
360
|
+
const signedCalls = await client.signPreparedCalls(preparedCalls);
|
|
361
|
+
const result = await client.sendPreparedCalls(signedCalls);
|
|
362
|
+
|
|
363
|
+
expect(result.preparedCallIds).toBeArrayOfSize(1);
|
|
364
|
+
|
|
365
|
+
const prepareCalls2 = await client.prepareCalls({
|
|
366
|
+
calls: [{ to: zeroAddress, value: "0x0" }],
|
|
367
|
+
from: account.address,
|
|
368
|
+
capabilities: {
|
|
369
|
+
paymasterService: {
|
|
370
|
+
policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
|
|
371
|
+
},
|
|
372
|
+
},
|
|
373
|
+
});
|
|
374
|
+
const signedCalls2 = await client.signPreparedCalls(prepareCalls2);
|
|
375
|
+
const result2 = await client.sendPreparedCalls(signedCalls2);
|
|
376
|
+
|
|
377
|
+
expect(result2.preparedCallIds).toBeArrayOfSize(1);
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
it("should successfully send a UO with paymaster using 7702", async () => {
|
|
381
|
+
const _signer = LocalAccountSigner.privateKeyToAccountSigner(
|
|
382
|
+
"0x00d35c6d307b5cddeb70aeed96ee27a551fee58bf1a43858477e6c11f9172ba8",
|
|
208
383
|
);
|
|
209
384
|
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
385
|
+
const _client = createSmartWalletClient({
|
|
386
|
+
transport,
|
|
387
|
+
chain: arbitrumSepolia,
|
|
388
|
+
mode: "remote",
|
|
389
|
+
signer: _signer,
|
|
213
390
|
});
|
|
214
391
|
|
|
392
|
+
const account = await _client.requestAccount({
|
|
393
|
+
creationHint: {
|
|
394
|
+
accountType: "7702",
|
|
395
|
+
},
|
|
396
|
+
});
|
|
397
|
+
expect(account.address).toBe(await _signer.getAddress());
|
|
398
|
+
|
|
399
|
+
const preparedCalls = await _client.prepareCalls({
|
|
400
|
+
calls: [{ to: zeroAddress, value: "0x0" }],
|
|
401
|
+
from: account.address,
|
|
402
|
+
capabilities: {
|
|
403
|
+
paymasterService: {
|
|
404
|
+
policyId: process.env.TEST_PAYMASTER_POLICY_ID!,
|
|
405
|
+
},
|
|
406
|
+
},
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
const signedCalls = await _client.signPreparedCalls(preparedCalls);
|
|
410
|
+
|
|
411
|
+
const result = await _client.sendPreparedCalls(signedCalls);
|
|
412
|
+
|
|
215
413
|
expect(result.preparedCallIds).toBeArrayOfSize(1);
|
|
216
414
|
});
|
|
217
415
|
|
|
@@ -222,7 +420,7 @@ describe("Client E2E Tests", () => {
|
|
|
222
420
|
|
|
223
421
|
const permissions = await client.grantPermissions({
|
|
224
422
|
account: account.address,
|
|
225
|
-
|
|
423
|
+
expirySec: Math.floor(Date.now() / 1000) + 60 * 60,
|
|
226
424
|
key: {
|
|
227
425
|
publicKey: await sessionKey.getAddress(),
|
|
228
426
|
type: "secp256k1",
|
|
@@ -230,7 +428,14 @@ describe("Client E2E Tests", () => {
|
|
|
230
428
|
permissions: [{ type: "root" }],
|
|
231
429
|
});
|
|
232
430
|
|
|
233
|
-
const
|
|
431
|
+
const sessionKeyClient = createSmartWalletClient({
|
|
432
|
+
transport,
|
|
433
|
+
chain: arbitrumSepolia,
|
|
434
|
+
mode: "remote",
|
|
435
|
+
signer: sessionKey,
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
const preparedCalls = await sessionKeyClient.prepareCalls({
|
|
234
439
|
calls: [{ to: zeroAddress, value: "0x0" }],
|
|
235
440
|
from: account.address,
|
|
236
441
|
capabilities: {
|
|
@@ -241,14 +446,11 @@ describe("Client E2E Tests", () => {
|
|
|
241
446
|
},
|
|
242
447
|
});
|
|
243
448
|
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
preparedUO.signatureRequest,
|
|
247
|
-
);
|
|
449
|
+
const signedCalls =
|
|
450
|
+
await sessionKeyClient.signPreparedCalls(preparedCalls);
|
|
248
451
|
|
|
249
|
-
const result = await
|
|
250
|
-
...
|
|
251
|
-
signature,
|
|
452
|
+
const result = await sessionKeyClient.sendPreparedCalls({
|
|
453
|
+
...signedCalls,
|
|
252
454
|
capabilities: {
|
|
253
455
|
permissions,
|
|
254
456
|
},
|
package/src/client/decorator.ts
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
JsonRpcAccount,
|
|
5
|
-
SignableMessage,
|
|
6
|
-
TypedDataDefinition,
|
|
7
|
-
} from "viem";
|
|
8
|
-
import type {
|
|
9
|
-
SendPreparedCallsParams,
|
|
10
|
-
SendPreparedCallsResult,
|
|
11
|
-
} from "../isomorphic/actions/sendPreparedCalls";
|
|
12
|
-
import type { InnerWalletApiClient } from "../types";
|
|
2
|
+
import type { Address, Hex } from "viem";
|
|
3
|
+
import type { InnerWalletApiClient } from "../types.ts";
|
|
13
4
|
import {
|
|
14
5
|
createAccount,
|
|
15
6
|
type CreateAccountParams,
|
|
@@ -40,20 +31,32 @@ import {
|
|
|
40
31
|
type RequestAccountParams,
|
|
41
32
|
type RequestAccountResult,
|
|
42
33
|
} from "./actions/requestAccount.js";
|
|
43
|
-
import {
|
|
44
|
-
|
|
34
|
+
import {
|
|
35
|
+
sendPreparedCalls,
|
|
36
|
+
type SendPreparedCallsParams,
|
|
37
|
+
type SendPreparedCallsResult,
|
|
38
|
+
} from "./actions/sendPreparedCalls.js";
|
|
39
|
+
import { signMessage, type SignMessageParams } from "./actions/signMessage.js";
|
|
45
40
|
import {
|
|
46
41
|
signSignatureRequest,
|
|
47
42
|
type SignSignatureRequestParams,
|
|
48
43
|
type SignSignatureRequestResult,
|
|
49
44
|
} from "./actions/signSignatureRequest.js";
|
|
50
|
-
import {
|
|
45
|
+
import {
|
|
46
|
+
signTypedData,
|
|
47
|
+
type SignTypedDataParams,
|
|
48
|
+
} from "./actions/signTypedData.js";
|
|
49
|
+
import {
|
|
50
|
+
signPreparedCalls,
|
|
51
|
+
type SignPreparedCallsParams,
|
|
52
|
+
type SignPreparedCallsResult,
|
|
53
|
+
} from "./actions/signPreparedCalls.js";
|
|
51
54
|
|
|
52
55
|
export type SmartWalletActions<
|
|
53
|
-
TAccount extends
|
|
56
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
54
57
|
> = {
|
|
55
58
|
requestAccount: (
|
|
56
|
-
params?: RequestAccountParams
|
|
59
|
+
params?: RequestAccountParams,
|
|
57
60
|
) => Promise<RequestAccountResult>;
|
|
58
61
|
prepareCalls: (
|
|
59
62
|
params: PrepareCallsParams<TAccount>,
|
|
@@ -69,32 +72,31 @@ export type SmartWalletActions<
|
|
|
69
72
|
signSignatureRequest: (
|
|
70
73
|
params: SignSignatureRequestParams,
|
|
71
74
|
) => Promise<SignSignatureRequestResult>;
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
signPreparedCalls: (
|
|
76
|
+
params: SignPreparedCallsParams,
|
|
77
|
+
) => Promise<SignPreparedCallsResult>;
|
|
78
|
+
signMessage: (params: SignMessageParams) => Promise<Hex>;
|
|
79
|
+
signTypedData: (params: SignTypedDataParams) => Promise<Hex>;
|
|
74
80
|
grantPermissions: (
|
|
75
81
|
params: GrantPermissionsParams<TAccount>,
|
|
76
82
|
) => Promise<GrantPermissionsResult>;
|
|
77
83
|
};
|
|
78
84
|
|
|
79
85
|
export function smartWalletClientActions<
|
|
80
|
-
TAccount extends
|
|
86
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
81
87
|
>(
|
|
82
|
-
client: InnerWalletApiClient<TAccount>,
|
|
83
|
-
signer: SmartAccountSigner,
|
|
84
|
-
): SmartWalletActions<TAccount>;
|
|
85
|
-
|
|
86
|
-
export function smartWalletClientActions(
|
|
87
88
|
client: InnerWalletApiClient,
|
|
88
89
|
signer: SmartAccountSigner,
|
|
89
|
-
): SmartWalletActions {
|
|
90
|
+
): SmartWalletActions<TAccount> {
|
|
90
91
|
return {
|
|
91
92
|
requestAccount: (params) => requestAccount(client, signer, params),
|
|
92
93
|
createAccount: (params) => createAccount(client, signer, params),
|
|
93
94
|
prepareCalls: (params) => prepareCalls(client, params),
|
|
94
|
-
listAccounts: (params) => listAccounts(client, params),
|
|
95
|
+
listAccounts: (params) => listAccounts(client, signer, params),
|
|
95
96
|
sendPreparedCalls: (params) => sendPreparedCalls(client, params),
|
|
96
97
|
getCallsStatus: (params) => getCallsStatus(client, params),
|
|
97
98
|
signSignatureRequest: (params) => signSignatureRequest(signer, params),
|
|
99
|
+
signPreparedCalls: (params) => signPreparedCalls(signer, params),
|
|
98
100
|
signMessage: (params) => signMessage(client, signer, params),
|
|
99
101
|
signTypedData: (params) => signTypedData(client, signer, params),
|
|
100
102
|
grantPermissions: (params) => grantPermissions(client, signer, params),
|
package/src/client/index.ts
CHANGED
|
@@ -1,55 +1,65 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
type Address,
|
|
5
|
-
type Chain,
|
|
6
|
-
type IsUndefined,
|
|
7
|
-
type JsonRpcAccount,
|
|
8
|
-
type Prettify,
|
|
9
|
-
} from "viem";
|
|
1
|
+
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
+
import type { AlchemyTransport } from "@account-kit/infra";
|
|
3
|
+
import type { Address, Chain, Prettify } from "viem";
|
|
10
4
|
import { createLocalClient } from "../local/client.js";
|
|
11
5
|
import { createRemoteClient } from "../remote/client.js";
|
|
12
|
-
import type { InnerWalletApiClient } from "../types";
|
|
6
|
+
import type { InnerWalletApiClient } from "../types.ts";
|
|
13
7
|
import {
|
|
14
8
|
smartWalletClientActions,
|
|
15
9
|
type SmartWalletActions,
|
|
16
10
|
} from "./decorator.js";
|
|
17
11
|
|
|
18
12
|
export type SmartWalletClientParams<
|
|
19
|
-
TAccount extends
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
policyId?: string;
|
|
29
|
-
} & (IsUndefined<TAccount> extends true
|
|
30
|
-
? {
|
|
31
|
-
account?: never;
|
|
32
|
-
}
|
|
33
|
-
: {
|
|
34
|
-
account: Address;
|
|
35
|
-
})
|
|
36
|
-
>;
|
|
13
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
14
|
+
> = Prettify<{
|
|
15
|
+
transport: AlchemyTransport;
|
|
16
|
+
chain: Chain;
|
|
17
|
+
signer: SmartAccountSigner;
|
|
18
|
+
mode: "local" | "remote";
|
|
19
|
+
policyId?: string;
|
|
20
|
+
account?: TAccount | Address | undefined;
|
|
21
|
+
}>;
|
|
37
22
|
|
|
38
|
-
export
|
|
39
|
-
TAccount extends
|
|
40
|
-
|
|
41
|
-
| undefined,
|
|
42
|
-
>(
|
|
43
|
-
params: SmartWalletClientParams<TAccount>,
|
|
44
|
-
): InnerWalletApiClient<TAccount> & SmartWalletActions<TAccount>;
|
|
23
|
+
export type SmartWalletClient<
|
|
24
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
25
|
+
> = InnerWalletApiClient & SmartWalletActions<TAccount>;
|
|
45
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Creates a smart wallet client that can be used to interact with a smart account.
|
|
29
|
+
*
|
|
30
|
+
* @param {SmartWalletClientParams} params - The parameters for creating the smart wallet client
|
|
31
|
+
* @param {AlchemyTransport} params.transport - The Alchemy transport to use
|
|
32
|
+
* @param {Chain} params.chain - The chain to use
|
|
33
|
+
* @param {SmartAccountSigner} params.signer - The signer to use for the smart account
|
|
34
|
+
* @param {"local" | "remote"} params.mode - The client's mode (local or remote).
|
|
35
|
+
* @param {string} [params.policyId] - The policy ID for gas sponsorship (optional)
|
|
36
|
+
* @param {Address} [params.account] - The smart account address to use (optional)
|
|
37
|
+
* @returns {SmartWalletClient} - A viem-compatible client
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
41
|
+
* import { alchemy, arbitrumSepolia } from "@account-kit/infra";
|
|
42
|
+
* import { generatePrivateKey } from "viem/accounts";
|
|
43
|
+
* import { createSmartWalletClient } from "@account-kit/wallet-client";
|
|
44
|
+
*
|
|
45
|
+
* const signer = LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey());
|
|
46
|
+
* const transport = alchemy({
|
|
47
|
+
* apiKey: "your-alchemy-api-key",
|
|
48
|
+
* });
|
|
49
|
+
* const client = createSmartWalletClient({
|
|
50
|
+
* transport,
|
|
51
|
+
* chain: arbitrumSepolia,
|
|
52
|
+
* mode: "remote",
|
|
53
|
+
* signer,
|
|
54
|
+
* });
|
|
55
|
+
*/
|
|
46
56
|
export function createSmartWalletClient<
|
|
47
|
-
TAccount extends
|
|
48
|
-
>(
|
|
49
|
-
params: SmartWalletClientParams<TAccount>,
|
|
50
|
-
): InnerWalletApiClient<TAccount> & SmartWalletActions<TAccount>;
|
|
57
|
+
TAccount extends Address | undefined = undefined,
|
|
58
|
+
>(params: SmartWalletClientParams<TAccount>): SmartWalletClient<TAccount>;
|
|
51
59
|
|
|
52
|
-
export function createSmartWalletClient(
|
|
60
|
+
export function createSmartWalletClient(
|
|
61
|
+
params: SmartWalletClientParams,
|
|
62
|
+
): SmartWalletClient {
|
|
53
63
|
const { transport, chain, policyId, mode, account, signer } = params;
|
|
54
64
|
|
|
55
65
|
const innerClient =
|
package/src/exports/index.ts
CHANGED
|
@@ -2,31 +2,23 @@
|
|
|
2
2
|
// and we shouldn't export * for the sake of tree-shaking
|
|
3
3
|
export {
|
|
4
4
|
createSmartWalletClient,
|
|
5
|
+
type SmartWalletClient,
|
|
5
6
|
type SmartWalletClientParams,
|
|
6
7
|
} from "../client/index.js";
|
|
7
8
|
|
|
8
9
|
export {
|
|
9
10
|
WalletServerRpcSchema,
|
|
10
11
|
type WalletServerRpcSchemaType,
|
|
11
|
-
|
|
12
|
-
} from "../rpc/schema.js";
|
|
13
|
-
|
|
14
|
-
// capabilities: TODO: should these actually just have the types exported?
|
|
15
|
-
export { Capabilities } from "../capabilities/index.js";
|
|
16
|
-
export { PaymasterCapability } from "../capabilities/paymaster.js";
|
|
17
|
-
export {
|
|
18
|
-
PermissionsArray,
|
|
19
|
-
PermissionsCapability,
|
|
20
|
-
PermissionsContext,
|
|
21
|
-
PermissionsData,
|
|
22
|
-
} from "../capabilities/permissions/index.js";
|
|
12
|
+
} from "@alchemy/wallet-api-types/rpc";
|
|
23
13
|
|
|
24
14
|
// client actions
|
|
25
15
|
export { createAccount } from "../client/actions/createAccount.js";
|
|
26
16
|
export { getCallsStatus } from "../client/actions/getCallsStatus.js";
|
|
17
|
+
export { grantPermissions } from "../client/actions/grantPermissions.js";
|
|
27
18
|
export { listAccounts } from "../client/actions/listAccounts.js";
|
|
28
19
|
export { prepareCalls } from "../client/actions/prepareCalls.js";
|
|
29
20
|
export { requestAccount } from "../client/actions/requestAccount.js";
|
|
30
|
-
export { signMessage } from "../client/actions/signMessage.js";
|
|
31
21
|
export { signSignatureRequest } from "../client/actions/signSignatureRequest.js";
|
|
22
|
+
export { signPreparedCalls } from "../client/actions/signPreparedCalls.js";
|
|
23
|
+
export { signMessage } from "../client/actions/signMessage.js";
|
|
32
24
|
export { signTypedData } from "../client/actions/signTypedData.js";
|