@account-kit/wallet-client 0.0.1-alpha.1 → 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/abi/index.d.ts +8 -8
- package/dist/esm/abi/index.js +8 -8
- package/dist/esm/abi/index.js.map +1 -1
- package/dist/esm/capabilities/index.d.ts +23 -0
- package/dist/esm/capabilities/index.js +4 -2
- package/dist/esm/capabilities/index.js.map +1 -1
- package/dist/esm/capabilities/overrides.d.ts +26 -0
- package/dist/esm/capabilities/overrides.js +14 -0
- package/dist/esm/capabilities/overrides.js.map +1 -0
- package/dist/esm/capabilities/permissions/index.d.ts +57 -17
- package/dist/esm/capabilities/permissions/index.js +26 -15
- package/dist/esm/capabilities/permissions/index.js.map +1 -1
- package/dist/esm/capabilities/permissions/mav2.js +1 -1
- package/dist/esm/capabilities/permissions/mav2.js.map +1 -1
- package/dist/esm/client/actions/grantPermissions.d.ts +1 -1
- package/dist/esm/client/actions/grantPermissions.js.map +1 -1
- package/dist/esm/client/actions/requestAccount.d.ts +2 -2
- package/dist/esm/client/actions/requestAccount.js +2 -2
- package/dist/esm/client/actions/requestAccount.js.map +1 -1
- package/dist/esm/client/actions/sendPreparedCalls.d.ts +2 -2
- package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/client/actions/signMessage.d.ts +1 -1
- package/dist/esm/client/actions/signMessage.js +1 -1
- package/dist/esm/client/actions/signMessage.js.map +1 -1
- package/dist/esm/client/actions/signSignatureRequest.d.ts +1 -1
- 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 +1 -1
- package/dist/esm/client/actions/signTypedData.js +1 -1
- package/dist/esm/client/actions/signTypedData.js.map +1 -1
- package/dist/esm/client/client.e2e-test.js +5 -6
- package/dist/esm/client/client.e2e-test.js.map +1 -1
- package/dist/esm/client/decorator.d.ts +8 -8
- package/dist/esm/client/decorator.js +10 -10
- package/dist/esm/client/decorator.js.map +1 -1
- package/dist/esm/client/index.d.ts +1 -1
- package/dist/esm/client/index.js +3 -3
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/exports/index.d.ts +13 -13
- package/dist/esm/exports/index.js +13 -13
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/internal.d.ts +12 -12
- package/dist/esm/exports/internal.js +11 -11
- package/dist/esm/exports/internal.js.map +1 -1
- package/dist/esm/isomorphic/actions/createSession.d.ts +3 -3
- package/dist/esm/isomorphic/actions/createSession.js +7 -5
- package/dist/esm/isomorphic/actions/createSession.js.map +1 -1
- package/dist/esm/isomorphic/actions/getCallsStatus.d.ts +2 -2
- package/dist/esm/isomorphic/actions/getCallsStatus.js +3 -3
- package/dist/esm/isomorphic/actions/getCallsStatus.js.map +1 -1
- package/dist/esm/isomorphic/actions/prepareCalls.d.ts +2 -2
- package/dist/esm/isomorphic/actions/prepareCalls.js +4 -3
- package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -1
- package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +4 -4
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js +3 -3
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/isomorphic/client.d.ts +8 -7
- package/dist/esm/isomorphic/client.js +15 -8
- package/dist/esm/isomorphic/client.js.map +1 -1
- package/dist/esm/isomorphic/utils/createAccount.d.ts +2 -2
- package/dist/esm/isomorphic/utils/createAccount.js +1 -1
- package/dist/esm/isomorphic/utils/createAccount.js.map +1 -1
- package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +4 -4
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js +1 -1
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +1 -1
- package/dist/esm/local/client.js +6 -5
- package/dist/esm/local/client.js.map +1 -1
- package/dist/esm/remote/client.js +3 -3
- package/dist/esm/remote/client.js.map +1 -1
- package/dist/esm/rpc/request.d.ts +32 -9
- package/dist/esm/rpc/request.js +17 -7
- package/dist/esm/rpc/request.js.map +1 -1
- package/dist/esm/rpc/schema.d.ts +32 -9
- package/dist/esm/rpc/schema.js +1 -1
- package/dist/esm/rpc/schema.js.map +1 -1
- package/dist/types/abi/index.d.ts +8 -8
- package/dist/types/abi/index.d.ts.map +1 -1
- package/dist/types/capabilities/index.d.ts +23 -0
- package/dist/types/capabilities/index.d.ts.map +1 -1
- package/dist/types/capabilities/overrides.d.ts +27 -0
- package/dist/types/capabilities/overrides.d.ts.map +1 -0
- package/dist/types/capabilities/permissions/index.d.ts +57 -17
- package/dist/types/capabilities/permissions/index.d.ts.map +1 -1
- package/dist/types/client/actions/grantPermissions.d.ts +1 -1
- package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
- package/dist/types/client/actions/requestAccount.d.ts +2 -2
- package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
- package/dist/types/client/actions/sendPreparedCalls.d.ts +2 -2
- package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/client/actions/signMessage.d.ts +1 -1
- package/dist/types/client/actions/signMessage.d.ts.map +1 -1
- package/dist/types/client/actions/signSignatureRequest.d.ts +1 -1
- package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
- package/dist/types/client/actions/signTypedData.d.ts +1 -1
- package/dist/types/client/actions/signTypedData.d.ts.map +1 -1
- package/dist/types/client/decorator.d.ts +8 -8
- package/dist/types/client/decorator.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +1 -1
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +13 -13
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/exports/internal.d.ts +12 -12
- package/dist/types/exports/internal.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/createSession.d.ts +3 -3
- package/dist/types/isomorphic/actions/createSession.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts +2 -2
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/prepareCalls.d.ts +2 -2
- package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +4 -4
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/isomorphic/client.d.ts +8 -7
- package/dist/types/isomorphic/client.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 +4 -4
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +1 -1
- package/dist/types/local/client.d.ts.map +1 -1
- package/dist/types/remote/client.d.ts.map +1 -1
- package/dist/types/rpc/request.d.ts +32 -9
- package/dist/types/rpc/request.d.ts.map +1 -1
- package/dist/types/rpc/schema.d.ts +32 -9
- package/dist/types/rpc/schema.d.ts.map +1 -1
- package/package.json +8 -3
- package/src/abi/index.ts +8 -8
- package/src/capabilities/index.ts +4 -2
- package/src/capabilities/overrides.ts +20 -0
- package/src/capabilities/permissions/index.ts +42 -24
- package/src/capabilities/permissions/mav2.ts +1 -1
- package/src/client/actions/grantPermissions.ts +1 -1
- package/src/client/actions/requestAccount.ts +4 -4
- package/src/client/actions/sendPreparedCalls.ts +3 -3
- package/src/client/actions/signMessage.ts +2 -2
- package/src/client/actions/signSignatureRequest.ts +2 -2
- package/src/client/actions/signTypedData.ts +2 -2
- package/src/client/client.e2e-test.ts +5 -6
- package/src/client/decorator.ts +19 -19
- package/src/client/index.ts +6 -3
- package/src/exports/index.ts +13 -13
- package/src/exports/internal.ts +12 -12
- package/src/isomorphic/actions/createSession.ts +18 -14
- package/src/isomorphic/actions/getCallsStatus.ts +6 -6
- package/src/isomorphic/actions/prepareCalls.ts +7 -6
- package/src/isomorphic/actions/sendPreparedCalls.ts +7 -7
- package/src/isomorphic/client.ts +24 -11
- package/src/isomorphic/utils/createAccount.ts +3 -3
- package/src/isomorphic/utils/parsePermissionsContext.ts +3 -3
- package/src/local/client.ts +9 -8
- package/src/remote/client.ts +3 -3
- package/src/rpc/request.ts +33 -18
- package/src/rpc/schema.ts +3 -3
|
@@ -6,27 +6,39 @@ import {
|
|
|
6
6
|
type TObject,
|
|
7
7
|
type TSchema,
|
|
8
8
|
} from "@sinclair/typebox";
|
|
9
|
-
import { KeySigner, TypeAddress, TypeHex } from "../../schemas";
|
|
9
|
+
import { KeySigner, TypeAddress, TypeHex } from "../../schemas.js";
|
|
10
10
|
|
|
11
11
|
const Permission = <
|
|
12
12
|
TData extends TSchema,
|
|
13
13
|
TLiteralVal extends TLiteralValue,
|
|
14
14
|
TType extends TLiteral<TLiteralVal>,
|
|
15
15
|
>(
|
|
16
|
-
|
|
16
|
+
typeString: TLiteralVal, // e.g., "root"
|
|
17
|
+
typeEnum: TLiteralVal, // e.g., PermissionType.ROOT
|
|
17
18
|
data: TData,
|
|
18
19
|
description: string,
|
|
19
20
|
): TObject<{ type: TType; data: TData }> => {
|
|
20
|
-
return Type.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
return Type.Transform(
|
|
22
|
+
Type.Object(
|
|
23
|
+
{
|
|
24
|
+
type: Type.Literal(typeEnum),
|
|
25
|
+
data,
|
|
26
|
+
},
|
|
27
|
+
{ description },
|
|
28
|
+
),
|
|
29
|
+
)
|
|
30
|
+
.Decode((value) => ({
|
|
31
|
+
...value,
|
|
32
|
+
type: typeString, // enum → string
|
|
33
|
+
}))
|
|
34
|
+
.Encode((value) => ({
|
|
35
|
+
...value,
|
|
36
|
+
type: typeEnum, // string → enum
|
|
37
|
+
})) as never;
|
|
27
38
|
};
|
|
28
39
|
|
|
29
40
|
const NativeTokenTransfer = Permission(
|
|
41
|
+
"native-token-transfer",
|
|
30
42
|
PermissionType.NATIVE_TOKEN_TRANSFER,
|
|
31
43
|
Type.Object({
|
|
32
44
|
allowance: TypeHex(),
|
|
@@ -35,6 +47,7 @@ const NativeTokenTransfer = Permission(
|
|
|
35
47
|
);
|
|
36
48
|
|
|
37
49
|
const Erc20TokenTransfer = Permission(
|
|
50
|
+
"erc20-token-transfer",
|
|
38
51
|
PermissionType.ERC20_TOKEN_TRANSFER,
|
|
39
52
|
Type.Object({
|
|
40
53
|
allowance: TypeHex(),
|
|
@@ -44,6 +57,7 @@ const Erc20TokenTransfer = Permission(
|
|
|
44
57
|
);
|
|
45
58
|
|
|
46
59
|
const GasLimit = Permission(
|
|
60
|
+
"gas-limit",
|
|
47
61
|
PermissionType.GAS_LIMIT,
|
|
48
62
|
Type.Object({
|
|
49
63
|
limit: TypeHex(),
|
|
@@ -52,6 +66,7 @@ const GasLimit = Permission(
|
|
|
52
66
|
);
|
|
53
67
|
|
|
54
68
|
const ContractAccess = Permission(
|
|
69
|
+
"contract-access",
|
|
55
70
|
PermissionType.CONTRACT_ACCESS,
|
|
56
71
|
Type.Object({
|
|
57
72
|
address: TypeAddress,
|
|
@@ -60,6 +75,7 @@ const ContractAccess = Permission(
|
|
|
60
75
|
);
|
|
61
76
|
|
|
62
77
|
const AccountFunction = Permission(
|
|
78
|
+
"account-functions",
|
|
63
79
|
PermissionType.ACCOUNT_FUNCTIONS,
|
|
64
80
|
Type.Object({
|
|
65
81
|
functions: Type.Array(TypeHex(), { minItems: 1 }),
|
|
@@ -68,6 +84,7 @@ const AccountFunction = Permission(
|
|
|
68
84
|
);
|
|
69
85
|
|
|
70
86
|
const AllExternalFunctionAccess = Permission(
|
|
87
|
+
"functions-on-all-contracts",
|
|
71
88
|
PermissionType.FUNCTIONS_ON_ALL_CONTRACTS,
|
|
72
89
|
Type.Object({
|
|
73
90
|
functions: Type.Array(TypeHex(), { minItems: 1 }),
|
|
@@ -76,6 +93,7 @@ const AllExternalFunctionAccess = Permission(
|
|
|
76
93
|
);
|
|
77
94
|
|
|
78
95
|
const ContractFunctionAccess = Permission(
|
|
96
|
+
"functions-on-contract",
|
|
79
97
|
PermissionType.FUNCTIONS_ON_CONTRACT,
|
|
80
98
|
Type.Object({
|
|
81
99
|
address: TypeAddress,
|
|
@@ -85,26 +103,26 @@ const ContractFunctionAccess = Permission(
|
|
|
85
103
|
);
|
|
86
104
|
|
|
87
105
|
const Root = Permission(
|
|
106
|
+
"root",
|
|
88
107
|
PermissionType.ROOT,
|
|
89
108
|
Type.Optional(Type.Never()),
|
|
90
109
|
"grants full access to everything",
|
|
91
110
|
);
|
|
92
111
|
|
|
93
|
-
export const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
);
|
|
112
|
+
export const TypePermission = Type.Union([
|
|
113
|
+
// 7715 permissions
|
|
114
|
+
NativeTokenTransfer,
|
|
115
|
+
Erc20TokenTransfer,
|
|
116
|
+
GasLimit,
|
|
117
|
+
// additional permissions
|
|
118
|
+
ContractAccess,
|
|
119
|
+
AccountFunction,
|
|
120
|
+
AllExternalFunctionAccess,
|
|
121
|
+
ContractFunctionAccess,
|
|
122
|
+
Root,
|
|
123
|
+
]);
|
|
124
|
+
|
|
125
|
+
export const PermissionsArray = Type.Array(TypePermission, { minItems: 1 });
|
|
108
126
|
|
|
109
127
|
export const PermissionsContext = Type.Object({
|
|
110
128
|
context: TypeHex(),
|
|
@@ -3,7 +3,7 @@ import type { Static } from "@sinclair/typebox";
|
|
|
3
3
|
import { concatHex, sliceHex, type Hex } from "viem";
|
|
4
4
|
import type { PermissionsData } from ".";
|
|
5
5
|
import type { KeySigner } from "../../schemas";
|
|
6
|
-
import { assertNever } from "../../utils";
|
|
6
|
+
import { assertNever } from "../../utils.js";
|
|
7
7
|
|
|
8
8
|
export const SESSION_ID_LENGTH_BYTES = 16;
|
|
9
9
|
export const ENTITY_ID_LENGTH_BYTES = 4;
|
|
@@ -27,7 +27,7 @@ export async function grantPermissions<
|
|
|
27
27
|
| JsonRpcAccount<Address>
|
|
28
28
|
| undefined,
|
|
29
29
|
>(
|
|
30
|
-
client: InnerWalletApiClient
|
|
30
|
+
client: InnerWalletApiClient<TAccount>,
|
|
31
31
|
signer: SmartAccountSigner,
|
|
32
32
|
params: GrantPermissionsParams<TAccount>,
|
|
33
33
|
): Promise<GrantPermissionsResult>;
|
|
@@ -3,10 +3,10 @@ import type { Static } from "@sinclair/typebox";
|
|
|
3
3
|
import { Value } from "@sinclair/typebox/value";
|
|
4
4
|
import type { Address } from "abitype";
|
|
5
5
|
import { custom, type IsUndefined, type JsonRpcAccount } from "viem";
|
|
6
|
-
import { createAccount } from "../../isomorphic/utils/createAccount";
|
|
7
|
-
import type { wallet_requestAccount } from "../../rpc/request";
|
|
8
|
-
import { TypeSerializedInitcode } from "../../schemas";
|
|
9
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
6
|
+
import { createAccount } from "../../isomorphic/utils/createAccount.js";
|
|
7
|
+
import type { wallet_requestAccount } from "../../rpc/request.js";
|
|
8
|
+
import { TypeSerializedInitcode } from "../../schemas.js";
|
|
9
|
+
import type { InnerWalletApiClient } from "../../types.js";
|
|
10
10
|
|
|
11
11
|
export type RequestAccountParams<
|
|
12
12
|
TAccount extends JsonRpcAccount<Address> | undefined =
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Static } from "@sinclair/typebox";
|
|
1
|
+
import type { Static, StaticDecode } from "@sinclair/typebox";
|
|
2
|
+
import { toHex } from "viem";
|
|
2
3
|
import type { wallet_sendPreparedCalls } from "../../rpc/request";
|
|
3
4
|
import type { InnerWalletApiClient } from "../../types";
|
|
4
|
-
import { toHex } from "viem";
|
|
5
5
|
|
|
6
6
|
export type SendPreparedCallsParams = Omit<
|
|
7
|
-
|
|
7
|
+
StaticDecode<typeof wallet_sendPreparedCalls>["Request"]["params"][0],
|
|
8
8
|
"chainId"
|
|
9
9
|
>;
|
|
10
10
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
1
2
|
import {
|
|
2
3
|
type Address,
|
|
3
4
|
type Hex,
|
|
@@ -5,8 +6,7 @@ import {
|
|
|
5
6
|
type SignableMessage,
|
|
6
7
|
} from "viem";
|
|
7
8
|
import type { InnerWalletApiClient } from "../../types";
|
|
8
|
-
import
|
|
9
|
-
import { requestAccount } from "./requestAccount";
|
|
9
|
+
import { requestAccount } from "./requestAccount.js";
|
|
10
10
|
|
|
11
11
|
export type SignMessageParams = SignableMessage;
|
|
12
12
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import type { Static } from "@sinclair/typebox";
|
|
3
3
|
import { type Hex } from "viem";
|
|
4
|
-
import { TypeSignatureRequest } from "../../schemas";
|
|
5
|
-
import { assertNever } from "../../utils";
|
|
4
|
+
import { TypeSignatureRequest } from "../../schemas.js";
|
|
5
|
+
import { assertNever } from "../../utils.js";
|
|
6
6
|
|
|
7
7
|
export type SignSignatureRequestParams = Static<typeof TypeSignatureRequest>;
|
|
8
8
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
1
2
|
import {
|
|
2
3
|
type Address,
|
|
3
4
|
type Hex,
|
|
@@ -5,8 +6,7 @@ import {
|
|
|
5
6
|
type TypedDataDefinition,
|
|
6
7
|
} from "viem";
|
|
7
8
|
import type { InnerWalletApiClient } from "../../types";
|
|
8
|
-
import
|
|
9
|
-
import { requestAccount } from "./requestAccount";
|
|
9
|
+
import { requestAccount } from "./requestAccount.js";
|
|
10
10
|
|
|
11
11
|
export type SignTypedDataParams = TypedDataDefinition;
|
|
12
12
|
|
|
@@ -2,9 +2,8 @@ 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 {
|
|
6
|
-
import {
|
|
7
|
-
import { signSignatureRequest } from "./actions/signSignatureRequest";
|
|
5
|
+
import { signSignatureRequest } from "./actions/signSignatureRequest.js";
|
|
6
|
+
import { createSmartWalletClient } from "./index.js";
|
|
8
7
|
|
|
9
8
|
describe("Client E2E Tests", () => {
|
|
10
9
|
const transport = alchemy(
|
|
@@ -90,7 +89,7 @@ describe("Client E2E Tests", () => {
|
|
|
90
89
|
const result = await client.sendPreparedCalls({
|
|
91
90
|
...preparedUO,
|
|
92
91
|
signature: {
|
|
93
|
-
type: "
|
|
92
|
+
type: "ecdsa",
|
|
94
93
|
signature,
|
|
95
94
|
},
|
|
96
95
|
});
|
|
@@ -110,7 +109,7 @@ describe("Client E2E Tests", () => {
|
|
|
110
109
|
publicKey: await sessionKey.getAddress(),
|
|
111
110
|
type: "secp256k1",
|
|
112
111
|
},
|
|
113
|
-
permissions: [{ type:
|
|
112
|
+
permissions: [{ type: "root" }],
|
|
114
113
|
});
|
|
115
114
|
|
|
116
115
|
const preparedUO = await client.prepareCalls({
|
|
@@ -228,7 +227,7 @@ describe("Client E2E Tests", () => {
|
|
|
228
227
|
publicKey: await sessionKey.getAddress(),
|
|
229
228
|
type: "secp256k1",
|
|
230
229
|
},
|
|
231
|
-
permissions: [{ type:
|
|
230
|
+
permissions: [{ type: "root" }],
|
|
232
231
|
});
|
|
233
232
|
|
|
234
233
|
const preparedUO = await client.prepareCalls({
|
package/src/client/decorator.ts
CHANGED
|
@@ -14,40 +14,40 @@ import {
|
|
|
14
14
|
createAccount,
|
|
15
15
|
type CreateAccountParams,
|
|
16
16
|
type CreateAccountResult,
|
|
17
|
-
} from "./actions/createAccount";
|
|
17
|
+
} from "./actions/createAccount.js";
|
|
18
|
+
import {
|
|
19
|
+
getCallsStatus,
|
|
20
|
+
type GetCallsStatusParams,
|
|
21
|
+
type GetCallsStatusResult,
|
|
22
|
+
} from "./actions/getCallsStatus.js";
|
|
23
|
+
import {
|
|
24
|
+
grantPermissions,
|
|
25
|
+
type GrantPermissionsParams,
|
|
26
|
+
type GrantPermissionsResult,
|
|
27
|
+
} from "./actions/grantPermissions.js";
|
|
18
28
|
import {
|
|
19
29
|
listAccounts,
|
|
20
30
|
type ListAccountsParams,
|
|
21
31
|
type ListAccountsResult,
|
|
22
|
-
} from "./actions/listAccounts";
|
|
32
|
+
} from "./actions/listAccounts.js";
|
|
23
33
|
import {
|
|
24
34
|
prepareCalls,
|
|
25
35
|
type PrepareCallsParams,
|
|
26
36
|
type PrepareCallsResult,
|
|
27
|
-
} from "./actions/prepareCalls";
|
|
37
|
+
} from "./actions/prepareCalls.js";
|
|
28
38
|
import {
|
|
29
39
|
requestAccount,
|
|
30
40
|
type RequestAccountParams,
|
|
31
41
|
type RequestAccountResult,
|
|
32
|
-
} from "./actions/requestAccount";
|
|
33
|
-
import {
|
|
34
|
-
|
|
35
|
-
type GetCallsStatusParams,
|
|
36
|
-
type GetCallsStatusResult,
|
|
37
|
-
} from "./actions/getCallsStatus";
|
|
42
|
+
} from "./actions/requestAccount.js";
|
|
43
|
+
import { sendPreparedCalls } from "./actions/sendPreparedCalls.js";
|
|
44
|
+
import { signMessage } from "./actions/signMessage.js";
|
|
38
45
|
import {
|
|
39
46
|
signSignatureRequest,
|
|
40
47
|
type SignSignatureRequestParams,
|
|
41
48
|
type SignSignatureRequestResult,
|
|
42
|
-
} from "./actions/signSignatureRequest";
|
|
43
|
-
import {
|
|
44
|
-
import { signTypedData } from "./actions/signTypedData";
|
|
45
|
-
import {
|
|
46
|
-
grantPermissions,
|
|
47
|
-
type GrantPermissionsParams,
|
|
48
|
-
type GrantPermissionsResult,
|
|
49
|
-
} from "./actions/grantPermissions";
|
|
50
|
-
import { sendPreparedCalls } from "./actions/sendPreparedCalls";
|
|
49
|
+
} from "./actions/signSignatureRequest.js";
|
|
50
|
+
import { signTypedData } from "./actions/signTypedData.js";
|
|
51
51
|
|
|
52
52
|
export type SmartWalletActions<
|
|
53
53
|
TAccount extends JsonRpcAccount | undefined = JsonRpcAccount | undefined,
|
|
@@ -72,7 +72,7 @@ export type SmartWalletActions<
|
|
|
72
72
|
signMessage: (params: SignableMessage) => Promise<Hex>;
|
|
73
73
|
signTypedData: (params: TypedDataDefinition) => Promise<Hex>;
|
|
74
74
|
grantPermissions: (
|
|
75
|
-
params: GrantPermissionsParams
|
|
75
|
+
params: GrantPermissionsParams<TAccount>,
|
|
76
76
|
) => Promise<GrantPermissionsResult>;
|
|
77
77
|
};
|
|
78
78
|
|
package/src/client/index.ts
CHANGED
|
@@ -7,10 +7,13 @@ import {
|
|
|
7
7
|
type JsonRpcAccount,
|
|
8
8
|
type Prettify,
|
|
9
9
|
} from "viem";
|
|
10
|
-
import { createLocalClient } from "../local/client";
|
|
11
|
-
import { createRemoteClient } from "../remote/client";
|
|
10
|
+
import { createLocalClient } from "../local/client.js";
|
|
11
|
+
import { createRemoteClient } from "../remote/client.js";
|
|
12
12
|
import type { InnerWalletApiClient } from "../types";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
smartWalletClientActions,
|
|
15
|
+
type SmartWalletActions,
|
|
16
|
+
} from "./decorator.js";
|
|
14
17
|
|
|
15
18
|
export type SmartWalletClientParams<
|
|
16
19
|
TAccount extends JsonRpcAccount<Address> | undefined =
|
package/src/exports/index.ts
CHANGED
|
@@ -3,30 +3,30 @@
|
|
|
3
3
|
export {
|
|
4
4
|
createSmartWalletClient,
|
|
5
5
|
type SmartWalletClientParams,
|
|
6
|
-
} from "../client";
|
|
6
|
+
} from "../client/index.js";
|
|
7
7
|
|
|
8
8
|
export {
|
|
9
9
|
WalletServerRpcSchema,
|
|
10
10
|
type WalletServerRpcSchemaType,
|
|
11
11
|
type WalletServerViemRpcSchema,
|
|
12
|
-
} from "../rpc/schema";
|
|
12
|
+
} from "../rpc/schema.js";
|
|
13
13
|
|
|
14
14
|
// capabilities: TODO: should these actually just have the types exported?
|
|
15
|
-
export { Capabilities } from "../capabilities";
|
|
16
|
-
export { PaymasterCapability } from "../capabilities/paymaster";
|
|
15
|
+
export { Capabilities } from "../capabilities/index.js";
|
|
16
|
+
export { PaymasterCapability } from "../capabilities/paymaster.js";
|
|
17
17
|
export {
|
|
18
18
|
PermissionsArray,
|
|
19
19
|
PermissionsCapability,
|
|
20
20
|
PermissionsContext,
|
|
21
21
|
PermissionsData,
|
|
22
|
-
} from "../capabilities/permissions";
|
|
22
|
+
} from "../capabilities/permissions/index.js";
|
|
23
23
|
|
|
24
24
|
// client actions
|
|
25
|
-
export { createAccount } from "../client/actions/createAccount";
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
export {
|
|
32
|
-
export { signTypedData } from "../client/actions/signTypedData";
|
|
25
|
+
export { createAccount } from "../client/actions/createAccount.js";
|
|
26
|
+
export { getCallsStatus } from "../client/actions/getCallsStatus.js";
|
|
27
|
+
export { listAccounts } from "../client/actions/listAccounts.js";
|
|
28
|
+
export { prepareCalls } from "../client/actions/prepareCalls.js";
|
|
29
|
+
export { requestAccount } from "../client/actions/requestAccount.js";
|
|
30
|
+
export { signMessage } from "../client/actions/signMessage.js";
|
|
31
|
+
export { signSignatureRequest } from "../client/actions/signSignatureRequest.js";
|
|
32
|
+
export { signTypedData } from "../client/actions/signTypedData.js";
|
package/src/exports/internal.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// exports from this file are meant to be imported by our packages in the monorepo
|
|
2
2
|
// we will expose this in the package.json as a named export like `this-pkg/internal`
|
|
3
3
|
// TODO: name `this-pkg`
|
|
4
|
-
export * from "../capabilities";
|
|
5
|
-
export * from "../capabilities/paymaster";
|
|
6
|
-
export * from "../capabilities/permissions";
|
|
7
|
-
export * from "../capabilities/permissions/mav2";
|
|
8
|
-
export type * from "../isomorphic/client";
|
|
9
|
-
export { createIsomorphicClient } from "../isomorphic/client";
|
|
10
|
-
export { createDummySigner } from "../isomorphic/utils/createDummySigner";
|
|
11
|
-
export * from "../rpc/request";
|
|
12
|
-
export * as RpcSchemas from "../rpc/request";
|
|
13
|
-
export * from "../rpc/schema";
|
|
14
|
-
export * from "../schemas";
|
|
4
|
+
export * from "../capabilities/index.js";
|
|
5
|
+
export * from "../capabilities/paymaster.js";
|
|
6
|
+
export * from "../capabilities/permissions/index.js";
|
|
7
|
+
export * from "../capabilities/permissions/mav2.js";
|
|
8
|
+
export type * from "../isomorphic/client.js";
|
|
9
|
+
export { createIsomorphicClient } from "../isomorphic/client.js";
|
|
10
|
+
export { createDummySigner } from "../isomorphic/utils/createDummySigner.js";
|
|
11
|
+
export * from "../rpc/request.js";
|
|
12
|
+
export * as RpcSchemas from "../rpc/request.js";
|
|
13
|
+
export * from "../rpc/schema.js";
|
|
14
|
+
export * from "../schemas.js";
|
|
15
15
|
export type * from "../types";
|
|
16
|
-
export * from "../utils";
|
|
16
|
+
export * from "../utils.js";
|
|
@@ -3,25 +3,27 @@ import {
|
|
|
3
3
|
type SmartAccountClient,
|
|
4
4
|
type SmartContractAccount,
|
|
5
5
|
} from "@aa-sdk/core";
|
|
6
|
+
import {
|
|
7
|
+
deferralActions,
|
|
8
|
+
PermissionBuilder,
|
|
9
|
+
} from "@account-kit/smart-contracts/experimental";
|
|
10
|
+
import type { Static } from "@sinclair/typebox";
|
|
11
|
+
import { Value } from "@sinclair/typebox/value";
|
|
6
12
|
import {
|
|
7
13
|
ChainNotFoundError,
|
|
8
|
-
type Chain,
|
|
9
|
-
type Transport,
|
|
10
14
|
custom,
|
|
11
15
|
hexToNumber,
|
|
12
|
-
type Hex,
|
|
13
16
|
toHex,
|
|
17
|
+
type Chain,
|
|
18
|
+
type Hex,
|
|
19
|
+
type Transport,
|
|
14
20
|
} from "viem";
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import type {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
PermissionBuilder,
|
|
22
|
-
} from "@account-kit/smart-contracts/experimental";
|
|
23
|
-
import { createDummySigner } from "../utils/createDummySigner";
|
|
24
|
-
import { createAccount, isModularAccountV2 } from "../utils/createAccount";
|
|
21
|
+
import { TypePermission } from "../../capabilities/permissions/index.js";
|
|
22
|
+
import { isGlobalValidation } from "../../capabilities/permissions/mav2.js";
|
|
23
|
+
import type { wallet_createSession } from "../../rpc/request.js";
|
|
24
|
+
import type { WalletServerViemRpcSchema } from "../../rpc/schema.js";
|
|
25
|
+
import { createAccount, isModularAccountV2 } from "../utils/createAccount.js";
|
|
26
|
+
import { createDummySigner } from "../utils/createDummySigner.js";
|
|
25
27
|
|
|
26
28
|
export type CreateSessionParams = Omit<
|
|
27
29
|
Static<
|
|
@@ -100,7 +102,9 @@ export async function createSession(
|
|
|
100
102
|
deadline: params.expiry,
|
|
101
103
|
})
|
|
102
104
|
.addPermissions({
|
|
103
|
-
permissions: params.permissions
|
|
105
|
+
permissions: params.permissions.map((permission) =>
|
|
106
|
+
Value.Encode(TypePermission, permission),
|
|
107
|
+
),
|
|
104
108
|
})
|
|
105
109
|
.compileDeferred();
|
|
106
110
|
|
|
@@ -3,19 +3,19 @@ import {
|
|
|
3
3
|
type SmartContractAccount,
|
|
4
4
|
} from "@aa-sdk/core";
|
|
5
5
|
import type { Static } from "@sinclair/typebox";
|
|
6
|
+
import { Value } from "@sinclair/typebox/value";
|
|
6
7
|
import {
|
|
7
8
|
ChainNotFoundError,
|
|
9
|
+
isHex,
|
|
8
10
|
type Chain,
|
|
9
11
|
type Hex,
|
|
10
12
|
type TransactionReceipt,
|
|
11
13
|
type Transport,
|
|
12
|
-
isHex,
|
|
13
14
|
} from "viem";
|
|
14
|
-
import type { wallet_getCallsStatus } from "../../rpc/request";
|
|
15
|
-
import type { WalletServerViemRpcSchema } from "../../rpc/schema";
|
|
16
|
-
import { TypeCallId } from "../../schemas";
|
|
17
|
-
import { castToHex } from "../../utils";
|
|
18
|
-
import { Value } from "@sinclair/typebox/value";
|
|
15
|
+
import type { wallet_getCallsStatus } from "../../rpc/request.js";
|
|
16
|
+
import type { WalletServerViemRpcSchema } from "../../rpc/schema.js";
|
|
17
|
+
import { TypeCallId } from "../../schemas.js";
|
|
18
|
+
import { castToHex } from "../../utils.js";
|
|
19
19
|
|
|
20
20
|
export type GetCallsStatusParams = Static<
|
|
21
21
|
(typeof wallet_getCallsStatus)["properties"]["Request"]["properties"]["params"]
|
|
@@ -5,18 +5,18 @@ import {
|
|
|
5
5
|
} from "@aa-sdk/core";
|
|
6
6
|
import type { Static } from "@sinclair/typebox";
|
|
7
7
|
import {
|
|
8
|
+
ChainNotFoundError,
|
|
8
9
|
custom,
|
|
9
10
|
fromHex,
|
|
11
|
+
toHex,
|
|
10
12
|
zeroAddress,
|
|
11
13
|
type Chain,
|
|
12
14
|
type Transport,
|
|
13
|
-
ChainNotFoundError,
|
|
14
|
-
toHex,
|
|
15
15
|
} from "viem";
|
|
16
|
-
import type { wallet_prepareCalls } from "../../rpc/request";
|
|
17
|
-
import type { WalletServerViemRpcSchema } from "../../rpc/schema";
|
|
18
|
-
import { createAccount } from "../utils/createAccount";
|
|
19
|
-
import { createDummySigner } from "../utils/createDummySigner";
|
|
16
|
+
import type { wallet_prepareCalls } from "../../rpc/request.js";
|
|
17
|
+
import type { WalletServerViemRpcSchema } from "../../rpc/schema.js";
|
|
18
|
+
import { createAccount } from "../utils/createAccount.js";
|
|
19
|
+
import { createDummySigner } from "../utils/createDummySigner.js";
|
|
20
20
|
|
|
21
21
|
export type PrepareCallsParams = Omit<
|
|
22
22
|
Static<
|
|
@@ -76,6 +76,7 @@ export async function prepareCalls(
|
|
|
76
76
|
value: x.value ? fromHex(x.value, "bigint") : undefined,
|
|
77
77
|
})),
|
|
78
78
|
account,
|
|
79
|
+
overrides: params.capabilities?.gasParamsOverride,
|
|
79
80
|
});
|
|
80
81
|
|
|
81
82
|
const uoRequest = deepHexlify(builtUo);
|
|
@@ -3,6 +3,8 @@ import {
|
|
|
3
3
|
type SmartAccountClient,
|
|
4
4
|
type SmartContractAccount,
|
|
5
5
|
} from "@aa-sdk/core";
|
|
6
|
+
import type { Static, StaticDecode } from "@sinclair/typebox";
|
|
7
|
+
import { Value } from "@sinclair/typebox/value";
|
|
6
8
|
import {
|
|
7
9
|
ChainNotFoundError,
|
|
8
10
|
concat,
|
|
@@ -12,15 +14,13 @@ import {
|
|
|
12
14
|
type Hex,
|
|
13
15
|
type Transport,
|
|
14
16
|
} from "viem";
|
|
15
|
-
import { decodePermissionsContext } from "../../capabilities/permissions/mav2";
|
|
16
|
-
import type { wallet_sendPreparedCalls } from "../../rpc/request";
|
|
17
|
-
import type { WalletServerViemRpcSchema } from "../../rpc/schema";
|
|
18
|
-
import {
|
|
19
|
-
import { TypeCallId } from "../../schemas";
|
|
20
|
-
import type { Static } from "@sinclair/typebox";
|
|
17
|
+
import { decodePermissionsContext } from "../../capabilities/permissions/mav2.js";
|
|
18
|
+
import type { wallet_sendPreparedCalls } from "../../rpc/request.js";
|
|
19
|
+
import type { WalletServerViemRpcSchema } from "../../rpc/schema.js";
|
|
20
|
+
import { TypeCallId } from "../../schemas.js";
|
|
21
21
|
|
|
22
22
|
export type SendPreparedCallsParams = Omit<
|
|
23
|
-
|
|
23
|
+
StaticDecode<
|
|
24
24
|
(typeof wallet_sendPreparedCalls)["properties"]["Request"]["properties"]["params"]
|
|
25
25
|
>[0],
|
|
26
26
|
"chainId"
|
package/src/isomorphic/client.ts
CHANGED
|
@@ -6,30 +6,35 @@ import {
|
|
|
6
6
|
} from "@aa-sdk/core";
|
|
7
7
|
import {
|
|
8
8
|
alchemyFeeEstimator,
|
|
9
|
+
alchemyGasAndPaymasterAndDataMiddleware,
|
|
9
10
|
alchemyGasManagerMiddleware,
|
|
10
11
|
type AlchemyTransport,
|
|
11
12
|
} from "@account-kit/infra";
|
|
12
13
|
import { type Chain, type Transport } from "viem";
|
|
13
|
-
import type { WalletServerViemRpcSchema } from "../rpc/schema";
|
|
14
|
-
import { prepareCalls, type PrepareCallsParams } from "./actions/prepareCalls";
|
|
14
|
+
import type { WalletServerViemRpcSchema } from "../rpc/schema.js";
|
|
15
15
|
import {
|
|
16
|
-
|
|
17
|
-
type
|
|
18
|
-
} from "./actions/
|
|
16
|
+
createSession,
|
|
17
|
+
type CreateSessionParams,
|
|
18
|
+
} from "./actions/createSession.js";
|
|
19
19
|
import {
|
|
20
20
|
getCallsStatus,
|
|
21
21
|
type GetCallsStatusParams,
|
|
22
|
-
} from "./actions/getCallsStatus";
|
|
22
|
+
} from "./actions/getCallsStatus.js";
|
|
23
23
|
import {
|
|
24
|
-
|
|
25
|
-
type
|
|
26
|
-
} from "./actions/
|
|
24
|
+
prepareCalls,
|
|
25
|
+
type PrepareCallsParams,
|
|
26
|
+
} from "./actions/prepareCalls.js";
|
|
27
|
+
import {
|
|
28
|
+
sendPreparedCalls,
|
|
29
|
+
type SendPreparedCallsParams,
|
|
30
|
+
} from "./actions/sendPreparedCalls.js";
|
|
27
31
|
|
|
28
32
|
// let's start with something that takes in as many params as possible, then we can eliminate them as we don't need them
|
|
29
33
|
type ClientParams = {
|
|
30
34
|
chain: Chain;
|
|
31
35
|
transport: Transport;
|
|
32
36
|
policyId?: string;
|
|
37
|
+
useErc7677middleware?: boolean;
|
|
33
38
|
};
|
|
34
39
|
|
|
35
40
|
export function isomorphicClientActions(
|
|
@@ -58,6 +63,7 @@ export function createIsomorphicClient({
|
|
|
58
63
|
chain,
|
|
59
64
|
transport,
|
|
60
65
|
policyId,
|
|
66
|
+
useErc7677middleware = true,
|
|
61
67
|
}: ClientParams): SmartAccountClient<
|
|
62
68
|
Transport,
|
|
63
69
|
Chain,
|
|
@@ -71,8 +77,15 @@ export function createIsomorphicClient({
|
|
|
71
77
|
chain,
|
|
72
78
|
// TODO: we will want to enforce alchemy transport here probably
|
|
73
79
|
feeEstimator: alchemyFeeEstimator(transport as AlchemyTransport),
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
...(policyId
|
|
81
|
+
? useErc7677middleware
|
|
82
|
+
? alchemyGasManagerMiddleware(policyId)
|
|
83
|
+
: // NOTE: DO NOT USE THIS MIDDLEWARE in the server, currently we require using the erc7677 middleware
|
|
84
|
+
alchemyGasAndPaymasterAndDataMiddleware({
|
|
85
|
+
policyId,
|
|
86
|
+
transport: transport as AlchemyTransport,
|
|
87
|
+
})
|
|
88
|
+
: {}),
|
|
76
89
|
}).extend(isomorphicClientActions);
|
|
77
90
|
|
|
78
91
|
return client;
|
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
import type { StaticDecode } from "@sinclair/typebox";
|
|
7
7
|
import type { Address, Chain, Transport } from "viem";
|
|
8
8
|
import { concatHex, hexToNumber } from "viem";
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
import { parsePermissionsContext } from "./parsePermissionsContext";
|
|
9
|
+
import type { Capabilities } from "../../capabilities/index.js";
|
|
10
|
+
import type { TypeSerializedInitcode } from "../../schemas.js";
|
|
11
|
+
import { parsePermissionsContext } from "./parsePermissionsContext.js";
|
|
12
12
|
|
|
13
13
|
type CreateAccountParams = {
|
|
14
14
|
chain: Chain;
|