@account-kit/wallet-client 0.1.0-alpha.1 → 0.1.0-alpha.2
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/permissions/mav2.d.ts +2 -2
- package/dist/esm/capabilities/permissions/mav2.js.map +1 -1
- 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/getCallsStatus.d.ts +21 -2
- package/dist/esm/client/actions/getCallsStatus.js.map +1 -1
- package/dist/esm/client/actions/grantPermissions.d.ts +60 -2
- package/dist/esm/client/actions/grantPermissions.js.map +1 -1
- package/dist/esm/client/actions/listAccounts.d.ts +26 -2
- package/dist/esm/client/actions/listAccounts.js +24 -0
- package/dist/esm/client/actions/listAccounts.js.map +1 -1
- package/dist/esm/client/actions/prepareCalls.d.ts +28 -2
- package/dist/esm/client/actions/prepareCalls.js.map +1 -1
- package/dist/esm/client/actions/requestAccount.d.ts +21 -2
- package/dist/esm/client/actions/requestAccount.js +14 -3
- package/dist/esm/client/actions/requestAccount.js.map +1 -1
- package/dist/esm/client/actions/sendPreparedCalls.d.ts +39 -2
- package/dist/esm/client/actions/sendPreparedCalls.js +37 -0
- package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/client/actions/signMessage.d.ts +22 -2
- package/dist/esm/client/actions/signMessage.js +4 -2
- package/dist/esm/client/actions/signMessage.js.map +1 -1
- package/dist/esm/client/actions/signSignatureRequest.d.ts +31 -0
- package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
- package/dist/esm/client/actions/signTypedData.d.ts +35 -2
- package/dist/esm/client/actions/signTypedData.js +3 -1
- package/dist/esm/client/actions/signTypedData.js.map +1 -1
- package/dist/esm/client/client.e2e-test.js +99 -11
- package/dist/esm/client/client.e2e-test.js.map +1 -1
- package/dist/esm/client/decorator.d.ts +7 -5
- package/dist/esm/client/decorator.js +1 -1
- package/dist/esm/client/decorator.js.map +1 -1
- package/dist/esm/client/index.d.ts +4 -4
- package/dist/esm/client/index.js +29 -3
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/exports/index.d.ts +1 -0
- package/dist/esm/exports/index.js +1 -0
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/internal.d.ts +1 -1
- 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/local/client.d.ts +1 -1
- package/dist/esm/local/client.js +8 -1
- package/dist/esm/local/client.js.map +1 -1
- package/dist/esm/remote/client.d.ts +1 -1
- package/dist/esm/remote/client.js +6 -1
- package/dist/esm/remote/client.js.map +1 -1
- package/dist/esm/rpc/schema.d.ts +1 -1
- package/dist/esm/types.d.ts +15 -4
- package/dist/esm/types.js.map +1 -1
- package/dist/types/capabilities/permissions/mav2.d.ts +2 -2
- package/dist/types/capabilities/permissions/mav2.d.ts.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/getCallsStatus.d.ts +21 -2
- package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
- package/dist/types/client/actions/grantPermissions.d.ts +60 -2
- package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
- package/dist/types/client/actions/listAccounts.d.ts +26 -2
- package/dist/types/client/actions/listAccounts.d.ts.map +1 -1
- package/dist/types/client/actions/prepareCalls.d.ts +28 -2
- package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/client/actions/requestAccount.d.ts +21 -2
- package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
- package/dist/types/client/actions/sendPreparedCalls.d.ts +39 -2
- package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/client/actions/signMessage.d.ts +22 -2
- package/dist/types/client/actions/signMessage.d.ts.map +1 -1
- package/dist/types/client/actions/signSignatureRequest.d.ts +31 -0
- package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
- package/dist/types/client/actions/signTypedData.d.ts +35 -2
- package/dist/types/client/actions/signTypedData.d.ts.map +1 -1
- package/dist/types/client/decorator.d.ts +7 -5
- package/dist/types/client/decorator.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +4 -4
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +1 -0
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/exports/internal.d.ts +1 -1
- 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/local/client.d.ts +1 -1
- package/dist/types/local/client.d.ts.map +1 -1
- package/dist/types/remote/client.d.ts +1 -1
- package/dist/types/remote/client.d.ts.map +1 -1
- package/dist/types/rpc/schema.d.ts +1 -1
- package/dist/types/types.d.ts +15 -4
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +8 -6
- package/src/capabilities/permissions/mav2.ts +2 -2
- package/src/client/actions/createAccount.ts +27 -2
- package/src/client/actions/getCallsStatus.ts +21 -2
- package/src/client/actions/grantPermissions.ts +60 -2
- package/src/client/actions/listAccounts.ts +26 -2
- package/src/client/actions/prepareCalls.ts +28 -2
- package/src/client/actions/requestAccount.ts +40 -5
- package/src/client/actions/sendPreparedCalls.ts +39 -2
- package/src/client/actions/signMessage.ts +24 -4
- package/src/client/actions/signSignatureRequest.ts +31 -0
- package/src/client/actions/signTypedData.ts +39 -3
- package/src/client/client.e2e-test.ts +120 -11
- package/src/client/decorator.ts +10 -12
- package/src/client/index.ts +41 -10
- package/src/exports/index.ts +1 -0
- package/src/exports/internal.ts +1 -1
- package/src/internal/decorator.ts +12 -0
- package/src/local/client.ts +52 -42
- package/src/remote/client.ts +10 -5
- package/src/types.ts +18 -4
package/src/local/client.ts
CHANGED
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
prefixSignatureKeyType,
|
|
7
7
|
} from "../capabilities/permissions/mav2.js";
|
|
8
8
|
import { signSignatureRequest } from "../client/actions/signSignatureRequest.js";
|
|
9
|
-
import
|
|
9
|
+
import { internalStateDecorator } from "../internal/decorator.js";
|
|
10
|
+
import type { PrepareCallsParams } from "../isomorphic/actions/prepareCalls.ts";
|
|
10
11
|
import {
|
|
11
12
|
createIsomorphicClient,
|
|
12
13
|
type IsomorphicClient,
|
|
@@ -15,7 +16,7 @@ import type {
|
|
|
15
16
|
CreateInnerClientParams,
|
|
16
17
|
InnerClientActions,
|
|
17
18
|
InnerWalletApiClient,
|
|
18
|
-
} from "../types";
|
|
19
|
+
} from "../types.ts";
|
|
19
20
|
import { assertNever } from "../utils.js";
|
|
20
21
|
|
|
21
22
|
const localMethods = [
|
|
@@ -51,46 +52,51 @@ export function createLocalClient(
|
|
|
51
52
|
overrides: [
|
|
52
53
|
{
|
|
53
54
|
methods: localMethods,
|
|
54
|
-
transport: custom(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
transport: custom(
|
|
56
|
+
{
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
+
async request(args: { method: LocalMethod; params: any }) {
|
|
59
|
+
switch (args.method) {
|
|
60
|
+
case "wallet_prepareCalls": {
|
|
61
|
+
const params = args.params[0] as PrepareCallsParams;
|
|
62
|
+
const capabilityPolicyId =
|
|
63
|
+
params.capabilities?.paymasterService?.policyId;
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
if (
|
|
66
|
+
capabilityPolicyId != null &&
|
|
67
|
+
policyId !== capabilityPolicyId &&
|
|
68
|
+
!clientMap[capabilityPolicyId]
|
|
69
|
+
) {
|
|
70
|
+
clientMap[capabilityPolicyId] = createIsomorphicClient({
|
|
71
|
+
transport,
|
|
72
|
+
chain,
|
|
73
|
+
policyId: capabilityPolicyId,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
77
|
+
const client =
|
|
78
|
+
clientMap[capabilityPolicyId ?? policyId ?? "default"];
|
|
79
|
+
return client.prepareCalls(params);
|
|
80
|
+
}
|
|
81
|
+
case "wallet_sendPreparedCalls":
|
|
82
|
+
return isomorphicClient.sendPreparedCalls(args.params[0]);
|
|
83
|
+
case "wallet_getCallsStatus":
|
|
84
|
+
return isomorphicClient.getCallsStatus(args.params[0]);
|
|
85
|
+
case "wallet_createSession": {
|
|
86
|
+
return isomorphicClient.createSession(args.params[0]);
|
|
87
|
+
}
|
|
88
|
+
default:
|
|
89
|
+
return assertNever(
|
|
90
|
+
args.method,
|
|
91
|
+
`Unexpected method: ${args.method}`,
|
|
92
|
+
);
|
|
85
93
|
}
|
|
86
|
-
|
|
87
|
-
return assertNever(
|
|
88
|
-
args.method,
|
|
89
|
-
`Unexpected method: ${args.method}`,
|
|
90
|
-
);
|
|
91
|
-
}
|
|
94
|
+
},
|
|
92
95
|
},
|
|
93
|
-
|
|
96
|
+
{
|
|
97
|
+
retryCount: 0,
|
|
98
|
+
},
|
|
99
|
+
),
|
|
94
100
|
},
|
|
95
101
|
],
|
|
96
102
|
fallback: transport,
|
|
@@ -100,10 +106,14 @@ export function createLocalClient(
|
|
|
100
106
|
transport: innerTransport,
|
|
101
107
|
chain,
|
|
102
108
|
account,
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
})
|
|
110
|
+
.extend(() => ({
|
|
111
|
+
policyId,
|
|
112
|
+
...innerClientActions(isomorphicClient),
|
|
113
|
+
}))
|
|
114
|
+
.extend(() => ({
|
|
115
|
+
internal: internalStateDecorator(),
|
|
116
|
+
}));
|
|
107
117
|
}
|
|
108
118
|
|
|
109
119
|
const innerClientActions = (
|
package/src/remote/client.ts
CHANGED
|
@@ -2,13 +2,14 @@ import { Provider } from "ox";
|
|
|
2
2
|
import { createClient, custom, type Address, type JsonRpcAccount } from "viem";
|
|
3
3
|
import { encodePermissionsContext } from "../capabilities/permissions/mav2.js";
|
|
4
4
|
import { signSignatureRequest } from "../client/actions/signSignatureRequest.js";
|
|
5
|
+
import { internalStateDecorator } from "../internal/decorator.js";
|
|
5
6
|
import { WalletServerRpcSchema } from "../rpc/schema.js";
|
|
6
7
|
import type {
|
|
7
8
|
CreateInnerClientParams,
|
|
8
9
|
InnerClientActions,
|
|
9
10
|
InnerWalletApiClient,
|
|
10
11
|
InnerWalletApiClientBase,
|
|
11
|
-
} from "../types";
|
|
12
|
+
} from "../types.ts";
|
|
12
13
|
|
|
13
14
|
export function createRemoteClient<
|
|
14
15
|
TAccount extends JsonRpcAccount<Address> | undefined =
|
|
@@ -34,10 +35,14 @@ export function createRemoteClient(
|
|
|
34
35
|
),
|
|
35
36
|
chain,
|
|
36
37
|
account,
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
})
|
|
39
|
+
.extend((_client) => ({
|
|
40
|
+
policyId: params.policyId,
|
|
41
|
+
...innerClientActions(_client),
|
|
42
|
+
}))
|
|
43
|
+
.extend(() => ({
|
|
44
|
+
internal: internalStateDecorator(),
|
|
45
|
+
}));
|
|
41
46
|
|
|
42
47
|
return client;
|
|
43
48
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SmartAccountSigner, SmartContractAccount } from "@aa-sdk/core";
|
|
1
2
|
import type { AlchemyTransport } from "@account-kit/infra";
|
|
2
3
|
import type {
|
|
3
4
|
Address,
|
|
@@ -8,12 +9,12 @@ import type {
|
|
|
8
9
|
JsonRpcAccount,
|
|
9
10
|
Transport,
|
|
10
11
|
} from "viem";
|
|
11
|
-
import type { WalletServerViemRpcSchema } from "./rpc/schema";
|
|
12
|
-
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
13
12
|
import type {
|
|
14
13
|
GrantPermissionsParams,
|
|
15
14
|
GrantPermissionsResult,
|
|
16
|
-
} from "./client/actions/grantPermissions";
|
|
15
|
+
} from "./client/actions/grantPermissions.ts";
|
|
16
|
+
import type { RequestAccountParams } from "./client/actions/requestAccount.ts";
|
|
17
|
+
import type { WalletServerViemRpcSchema } from "./rpc/schema.ts";
|
|
17
18
|
|
|
18
19
|
export type CreateInnerClientParams<
|
|
19
20
|
TAccount extends JsonRpcAccount<Address> | undefined =
|
|
@@ -53,8 +54,21 @@ export type InnerClientActions = {
|
|
|
53
54
|
) => Promise<GrantPermissionsResult>;
|
|
54
55
|
};
|
|
55
56
|
|
|
57
|
+
export type CachedAccount = {
|
|
58
|
+
account: SmartContractAccount;
|
|
59
|
+
requestParams: RequestAccountParams;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export type InternalState = {
|
|
63
|
+
setAccount: (account: CachedAccount) => void;
|
|
64
|
+
getAccount: () => CachedAccount | undefined;
|
|
65
|
+
};
|
|
66
|
+
|
|
56
67
|
export type InnerWalletApiClient<
|
|
57
68
|
TAccount extends JsonRpcAccount<Address> | undefined =
|
|
58
69
|
| JsonRpcAccount<Address>
|
|
59
70
|
| undefined,
|
|
60
|
-
> = InnerWalletApiClientBase<
|
|
71
|
+
> = InnerWalletApiClientBase<
|
|
72
|
+
TAccount,
|
|
73
|
+
InnerClientActions & { internal: InternalState }
|
|
74
|
+
>;
|