@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
|
@@ -2,33 +2,33 @@ import type { StaticDecode } from "@sinclair/typebox";
|
|
|
2
2
|
import { InvalidRequestError } from "ox/RpcResponse";
|
|
3
3
|
import { decodePermissionsContext } from "../../capabilities/permissions/mav2.js";
|
|
4
4
|
import type { TypeSerializedInitcode } from "../../schemas.js";
|
|
5
|
-
import type { PrepareCallsParams } from "../actions/prepareCalls.js";
|
|
6
5
|
import type { Address } from "viem";
|
|
7
|
-
import {
|
|
6
|
+
import { getAccountTypeForDelegationAddress7702 } from "./7702.js";
|
|
7
|
+
import { PermissionsCapability } from "../../capabilities/permissions/index.js";
|
|
8
8
|
|
|
9
9
|
export function parsePermissionsContext(
|
|
10
|
-
|
|
11
|
-
parsedCi
|
|
10
|
+
permissions?: StaticDecode<typeof PermissionsCapability>,
|
|
11
|
+
parsedCi?: StaticDecode<typeof TypeSerializedInitcode> | undefined,
|
|
12
12
|
delegation7702?: Address,
|
|
13
13
|
) {
|
|
14
|
-
if (!
|
|
14
|
+
if (!permissions) {
|
|
15
15
|
return undefined;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
if ("sessionId" in
|
|
18
|
+
if ("sessionId" in permissions) {
|
|
19
19
|
throw new InvalidRequestError({
|
|
20
20
|
message: "Remote permissions are not supported in isomorphic client",
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
if (!("context" in
|
|
24
|
+
if (!("context" in permissions)) {
|
|
25
25
|
return undefined;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const isMAV2 =
|
|
29
29
|
(parsedCi && parsedCi.factoryType === "MAv2.0.0-sma-b") ||
|
|
30
30
|
(delegation7702 &&
|
|
31
|
-
|
|
31
|
+
getAccountTypeForDelegationAddress7702(delegation7702) ===
|
|
32
32
|
"ModularAccountV2");
|
|
33
33
|
|
|
34
34
|
if (!isMAV2) {
|
|
@@ -37,7 +37,7 @@ export function parsePermissionsContext(
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
const context = decodePermissionsContext(
|
|
40
|
+
const context = decodePermissionsContext(permissions);
|
|
41
41
|
|
|
42
42
|
if (context?.contextVersion === "REMOTE_MODE_DEFERRED_ACTION") {
|
|
43
43
|
throw new InvalidRequestError({
|
package/src/local/client.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { split } from "@aa-sdk/core";
|
|
2
2
|
import { buildDeferredActionDigest } from "@account-kit/smart-contracts/experimental";
|
|
3
|
-
import { createClient, custom, type Address
|
|
3
|
+
import { createClient, custom, type Address } from "viem";
|
|
4
4
|
import {
|
|
5
5
|
encodePermissionsContext,
|
|
6
6
|
prefixSignatureKeyType,
|
|
@@ -28,10 +28,8 @@ const localMethods = [
|
|
|
28
28
|
type LocalMethod = (typeof localMethods)[number];
|
|
29
29
|
|
|
30
30
|
export function createLocalClient<
|
|
31
|
-
TAccount extends
|
|
32
|
-
|
|
33
|
-
| undefined,
|
|
34
|
-
>(params: CreateInnerClientParams<TAccount>): InnerWalletApiClient<TAccount>;
|
|
31
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
32
|
+
>(params: CreateInnerClientParams<TAccount>): InnerWalletApiClient;
|
|
35
33
|
|
|
36
34
|
export function createLocalClient(
|
|
37
35
|
params: CreateInnerClientParams,
|
package/src/remote/client.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { Provider } from "ox";
|
|
2
|
-
import {
|
|
3
|
-
BaseError,
|
|
4
|
-
createClient,
|
|
5
|
-
custom,
|
|
6
|
-
type Address,
|
|
7
|
-
type JsonRpcAccount,
|
|
8
|
-
} from "viem";
|
|
2
|
+
import { BaseError, createClient, custom, type Address } from "viem";
|
|
9
3
|
import { encodePermissionsContext } from "../capabilities/permissions/mav2.js";
|
|
10
4
|
import { signSignatureRequest } from "../client/actions/signSignatureRequest.js";
|
|
11
5
|
import { internalStateDecorator } from "../internal/decorator.js";
|
|
@@ -17,18 +11,16 @@ import type {
|
|
|
17
11
|
InnerWalletApiClientBase,
|
|
18
12
|
} from "../types.ts";
|
|
19
13
|
|
|
20
|
-
export function createRemoteClient<
|
|
21
|
-
TAccount extends JsonRpcAccount<Address> | undefined =
|
|
22
|
-
| JsonRpcAccount<Address>
|
|
23
|
-
| undefined,
|
|
24
|
-
>(params: CreateInnerClientParams<TAccount>): InnerWalletApiClient<TAccount>;
|
|
25
|
-
|
|
26
14
|
/**
|
|
27
15
|
* This is a low-level client just used to make RPC requests in remote mode
|
|
28
16
|
* This should be wrapped by a higher-level smart account client that provides actions
|
|
29
17
|
* that uses this client under the hood
|
|
30
18
|
* @returns
|
|
31
19
|
*/
|
|
20
|
+
export function createRemoteClient<
|
|
21
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
22
|
+
>(params: CreateInnerClientParams<TAccount>): InnerWalletApiClient;
|
|
23
|
+
|
|
32
24
|
export function createRemoteClient(
|
|
33
25
|
params: CreateInnerClientParams,
|
|
34
26
|
): InnerWalletApiClient {
|
package/src/rpc/request.ts
CHANGED
|
@@ -16,8 +16,10 @@ import {
|
|
|
16
16
|
TypeUserOperationRequest_v6,
|
|
17
17
|
TypeUserOperationRequest_v7,
|
|
18
18
|
TypeUuid,
|
|
19
|
+
TypeSignatureType,
|
|
19
20
|
} from "../schemas.js";
|
|
20
21
|
import { Examples } from "./examples.js";
|
|
22
|
+
import { Eip7702AuthCapability } from "../capabilities/eip7702Auth.js";
|
|
21
23
|
|
|
22
24
|
export const wallet_sendPreparedCalls = Type.Object(
|
|
23
25
|
{
|
|
@@ -43,15 +45,7 @@ export const wallet_sendPreparedCalls = Type.Object(
|
|
|
43
45
|
]),
|
|
44
46
|
chainId: TypeHex(),
|
|
45
47
|
signature: Type.Object({
|
|
46
|
-
type: Type.
|
|
47
|
-
.Decode((value) => {
|
|
48
|
-
if (value.toLowerCase() !== "ecdsa") {
|
|
49
|
-
throw new Error("Invalid signature type, must be 'ecdsa'");
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return "ecdsa" as const;
|
|
53
|
-
})
|
|
54
|
-
.Encode((value) => value),
|
|
48
|
+
type: Type.Exclude(TypeSignatureType, Type.Literal("contract")),
|
|
55
49
|
signature: TypeHex(),
|
|
56
50
|
}),
|
|
57
51
|
signedAuthorization: Type.Optional(TypeEip7702AuthExtendedFields),
|
|
@@ -235,6 +229,11 @@ export const wallet_createSession = Type.Object(
|
|
|
235
229
|
PermissionsData,
|
|
236
230
|
Type.Object({
|
|
237
231
|
account: TypeAddress,
|
|
232
|
+
capabilities: Type.Optional(
|
|
233
|
+
Type.Object({
|
|
234
|
+
eip7702Auth: Type.Optional(Eip7702AuthCapability),
|
|
235
|
+
}),
|
|
236
|
+
),
|
|
238
237
|
}),
|
|
239
238
|
]),
|
|
240
239
|
]),
|
package/src/schemas.ts
CHANGED
|
@@ -287,11 +287,15 @@ export type TypeAccountType = Exclude<
|
|
|
287
287
|
undefined
|
|
288
288
|
>["accountType"];
|
|
289
289
|
|
|
290
|
+
export const TypeSignatureType = Type.Union([
|
|
291
|
+
Type.Literal("secp256k1", { title: "Secp256k1" }),
|
|
292
|
+
Type.Literal("ecdsa", { title: "ECDSA (alias for secp256k1)" }),
|
|
293
|
+
Type.Literal("contract", { title: "Contract" }),
|
|
294
|
+
]);
|
|
295
|
+
export type TypeSignatureType = Static<typeof TypeSignatureType>;
|
|
296
|
+
|
|
290
297
|
export const KeySigner = Type.Object({
|
|
291
|
-
type:
|
|
292
|
-
Type.Literal("secp256k1", { title: "Secp256k1" }),
|
|
293
|
-
Type.Literal("contract", { title: "Contract" }),
|
|
294
|
-
]),
|
|
298
|
+
type: TypeSignatureType,
|
|
295
299
|
publicKey: TypeHex({}),
|
|
296
300
|
});
|
|
297
301
|
export type KeySigner = Static<typeof KeySigner>;
|
package/src/types.ts
CHANGED
|
@@ -5,7 +5,6 @@ import type {
|
|
|
5
5
|
Chain,
|
|
6
6
|
Client,
|
|
7
7
|
Hex,
|
|
8
|
-
IsUndefined,
|
|
9
8
|
JsonRpcAccount,
|
|
10
9
|
Transport,
|
|
11
10
|
} from "viem";
|
|
@@ -17,32 +16,22 @@ import type { RequestAccountParams } from "./client/actions/requestAccount.ts";
|
|
|
17
16
|
import type { WalletServerViemRpcSchema } from "./rpc/schema.ts";
|
|
18
17
|
|
|
19
18
|
export type CreateInnerClientParams<
|
|
20
|
-
TAccount extends
|
|
21
|
-
| JsonRpcAccount<Address>
|
|
22
|
-
| undefined,
|
|
19
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
23
20
|
> = {
|
|
24
21
|
chain: Chain;
|
|
25
22
|
transport: AlchemyTransport;
|
|
26
23
|
policyId?: string;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
account?: never;
|
|
30
|
-
}
|
|
31
|
-
: {
|
|
32
|
-
account: Address;
|
|
33
|
-
});
|
|
24
|
+
account?: TAccount | Address | undefined;
|
|
25
|
+
};
|
|
34
26
|
|
|
35
27
|
export type InnerWalletApiClientBase<
|
|
36
|
-
TAccount extends JsonRpcAccount<Address> | undefined =
|
|
37
|
-
| JsonRpcAccount<Address>
|
|
38
|
-
| undefined,
|
|
39
28
|
TExtend extends { [key: string]: unknown } | undefined =
|
|
40
29
|
| { [key: string]: unknown }
|
|
41
30
|
| undefined,
|
|
42
31
|
> = Client<
|
|
43
32
|
Transport,
|
|
44
33
|
Chain,
|
|
45
|
-
|
|
34
|
+
JsonRpcAccount<Address> | undefined,
|
|
46
35
|
WalletServerViemRpcSchema,
|
|
47
36
|
{ policyId?: string } & TExtend
|
|
48
37
|
>;
|
|
@@ -64,11 +53,6 @@ export type InternalState = {
|
|
|
64
53
|
getAccount: () => CachedAccount | undefined;
|
|
65
54
|
};
|
|
66
55
|
|
|
67
|
-
export type InnerWalletApiClient<
|
|
68
|
-
TAccount extends JsonRpcAccount<Address> | undefined =
|
|
69
|
-
| JsonRpcAccount<Address>
|
|
70
|
-
| undefined,
|
|
71
|
-
> = InnerWalletApiClientBase<
|
|
72
|
-
TAccount,
|
|
56
|
+
export type InnerWalletApiClient = InnerWalletApiClientBase<
|
|
73
57
|
InnerClientActions & { internal: InternalState }
|
|
74
58
|
>;
|