@account-kit/wallet-client 0.0.1-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/LightAccountFactoryAbi_V1_0_1.d.ts +55 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V1_0_1.js +45 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V1_0_1.js.map +1 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V1_0_2.d.ts +55 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V1_0_2.js +45 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V1_0_2.js.map +1 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V1_1_0.d.ts +55 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V1_1_0.js +45 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V1_1_0.js.map +1 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V2_0_0.d.ts +256 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V2_0_0.js +202 -0
- package/dist/esm/abi/LightAccountFactoryAbi_V2_0_0.js.map +1 -0
- package/dist/esm/abi/ModularAccountFactoryAbi_V2_0_0.d.ts +492 -0
- package/dist/esm/abi/ModularAccountFactoryAbi_V2_0_0.js +399 -0
- package/dist/esm/abi/ModularAccountFactoryAbi_V2_0_0.js.map +1 -0
- package/dist/esm/abi/MultiOwnerLightAccountFactoryAbi_V2_0_0.d.ts +286 -0
- package/dist/esm/abi/MultiOwnerLightAccountFactoryAbi_V2_0_0.js +225 -0
- package/dist/esm/abi/MultiOwnerLightAccountFactoryAbi_V2_0_0.js.map +1 -0
- package/dist/esm/abi/MultiOwnerModularAccountFactoryAbi_V1_0_0.d.ts +234 -0
- package/dist/esm/abi/MultiOwnerModularAccountFactoryAbi_V1_0_0.js +179 -0
- package/dist/esm/abi/MultiOwnerModularAccountFactoryAbi_V1_0_0.js.map +1 -0
- package/dist/esm/abi/MultisigModularAccountFactoryAbi_V1_0_0.d.ts +246 -0
- package/dist/esm/abi/MultisigModularAccountFactoryAbi_V1_0_0.js +182 -0
- package/dist/esm/abi/MultisigModularAccountFactoryAbi_V1_0_0.js.map +1 -0
- package/dist/esm/abi/index.d.ts +8 -0
- package/dist/esm/abi/index.js +9 -0
- package/dist/esm/abi/index.js.map +1 -0
- package/dist/esm/capabilities/index.d.ts +8 -0
- package/dist/esm/capabilities/index.js +8 -0
- package/dist/esm/capabilities/index.js.map +1 -0
- package/dist/esm/capabilities/paymaster.d.ts +3 -0
- package/dist/esm/capabilities/paymaster.js +5 -0
- package/dist/esm/capabilities/paymaster.js.map +1 -0
- package/dist/esm/capabilities/permissions/index.d.ts +98 -0
- package/dist/esm/capabilities/permissions/index.js +60 -0
- package/dist/esm/capabilities/permissions/index.js.map +1 -0
- package/dist/esm/capabilities/permissions/mav2.d.ts +36 -0
- package/dist/esm/capabilities/permissions/mav2.js +79 -0
- package/dist/esm/capabilities/permissions/mav2.js.map +1 -0
- package/dist/esm/client/actions/createAccount.d.ts +10 -0
- package/dist/esm/client/actions/createAccount.js +7 -0
- package/dist/esm/client/actions/createAccount.js.map +1 -0
- package/dist/esm/client/actions/getCallsStatus.d.ts +6 -0
- package/dist/esm/client/actions/getCallsStatus.js +7 -0
- package/dist/esm/client/actions/getCallsStatus.js.map +1 -0
- package/dist/esm/client/actions/grantPermissions.d.ts +13 -0
- package/dist/esm/client/actions/grantPermissions.js +11 -0
- package/dist/esm/client/actions/grantPermissions.js.map +1 -0
- package/dist/esm/client/actions/listAccounts.d.ts +6 -0
- package/dist/esm/client/actions/listAccounts.js +4 -0
- package/dist/esm/client/actions/listAccounts.js.map +1 -0
- package/dist/esm/client/actions/prepareCalls.d.ts +15 -0
- package/dist/esm/client/actions/prepareCalls.js +17 -0
- package/dist/esm/client/actions/prepareCalls.js.map +1 -0
- package/dist/esm/client/actions/requestAccount.d.ts +11 -0
- package/dist/esm/client/actions/requestAccount.js +28 -0
- package/dist/esm/client/actions/requestAccount.js.map +1 -0
- package/dist/esm/client/actions/sendPreparedCalls.d.ts +6 -0
- package/dist/esm/client/actions/sendPreparedCalls.js +8 -0
- package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -0
- package/dist/esm/client/actions/signMessage.d.ts +6 -0
- package/dist/esm/client/actions/signMessage.js +7 -0
- package/dist/esm/client/actions/signMessage.js.map +1 -0
- package/dist/esm/client/actions/signSignatureRequest.d.ts +10 -0
- package/dist/esm/client/actions/signSignatureRequest.js +15 -0
- package/dist/esm/client/actions/signSignatureRequest.js.map +1 -0
- package/dist/esm/client/actions/signTypedData.d.ts +6 -0
- package/dist/esm/client/actions/signTypedData.js +7 -0
- package/dist/esm/client/actions/signTypedData.js.map +1 -0
- package/dist/esm/client/client.e2e-test.d.ts +1 -0
- package/dist/esm/client/client.e2e-test.js +238 -0
- package/dist/esm/client/client.e2e-test.js.map +1 -0
- package/dist/esm/client/decorator.d.ts +24 -0
- package/dist/esm/client/decorator.js +25 -0
- package/dist/esm/client/decorator.js.map +1 -0
- package/dist/esm/client/index.d.ts +18 -0
- package/dist/esm/client/index.js +43 -0
- package/dist/esm/client/index.js.map +1 -0
- package/dist/esm/exports/index.d.ts +13 -0
- package/dist/esm/exports/index.js +18 -0
- package/dist/esm/exports/index.js.map +1 -0
- package/dist/esm/exports/internal.d.ts +13 -0
- package/dist/esm/exports/internal.js +15 -0
- package/dist/esm/exports/internal.js.map +1 -0
- package/dist/esm/isomorphic/actions/createSession.d.ts +14 -0
- package/dist/esm/isomorphic/actions/createSession.js +63 -0
- package/dist/esm/isomorphic/actions/createSession.js.map +1 -0
- package/dist/esm/isomorphic/actions/getCallsStatus.d.ts +21 -0
- package/dist/esm/isomorphic/actions/getCallsStatus.js +60 -0
- package/dist/esm/isomorphic/actions/getCallsStatus.js.map +1 -0
- package/dist/esm/isomorphic/actions/prepareCalls.d.ts +8 -0
- package/dist/esm/isomorphic/actions/prepareCalls.js +57 -0
- package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -0
- package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +8 -0
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js +43 -0
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -0
- package/dist/esm/isomorphic/client.d.ts +97 -0
- package/dist/esm/isomorphic/client.js +30 -0
- package/dist/esm/isomorphic/client.js.map +1 -0
- package/dist/esm/isomorphic/utils/createAccount.d.ts +22 -0
- package/dist/esm/isomorphic/utils/createAccount.js +32 -0
- package/dist/esm/isomorphic/utils/createAccount.js.map +1 -0
- package/dist/esm/isomorphic/utils/createDummySigner.d.ts +3 -0
- package/dist/esm/isomorphic/utils/createDummySigner.js +17 -0
- package/dist/esm/isomorphic/utils/createDummySigner.js.map +1 -0
- package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +20 -0
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js +21 -0
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +1 -0
- package/dist/esm/local/client.d.ts +3 -0
- package/dist/esm/local/client.js +89 -0
- package/dist/esm/local/client.js.map +1 -0
- package/dist/esm/remote/client.d.ts +3 -0
- package/dist/esm/remote/client.js +42 -0
- package/dist/esm/remote/client.js.map +1 -0
- package/dist/esm/rpc/request.d.ts +329 -0
- package/dist/esm/rpc/request.js +194 -0
- package/dist/esm/rpc/request.js.map +1 -0
- package/dist/esm/rpc/schema.d.ts +319 -0
- package/dist/esm/rpc/schema.js +5 -0
- package/dist/esm/rpc/schema.js.map +1 -0
- package/dist/esm/schemas.d.ts +216 -0
- package/dist/esm/schemas.js +211 -0
- package/dist/esm/schemas.js.map +1 -0
- package/dist/esm/types.d.ts +27 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils.d.ts +4 -0
- package/dist/esm/utils.js +12 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/types/abi/LightAccountFactoryAbi_V1_0_1.d.ts +56 -0
- package/dist/types/abi/LightAccountFactoryAbi_V1_0_1.d.ts.map +1 -0
- package/dist/types/abi/LightAccountFactoryAbi_V1_0_2.d.ts +56 -0
- package/dist/types/abi/LightAccountFactoryAbi_V1_0_2.d.ts.map +1 -0
- package/dist/types/abi/LightAccountFactoryAbi_V1_1_0.d.ts +56 -0
- package/dist/types/abi/LightAccountFactoryAbi_V1_1_0.d.ts.map +1 -0
- package/dist/types/abi/LightAccountFactoryAbi_V2_0_0.d.ts +257 -0
- package/dist/types/abi/LightAccountFactoryAbi_V2_0_0.d.ts.map +1 -0
- package/dist/types/abi/ModularAccountFactoryAbi_V2_0_0.d.ts +493 -0
- package/dist/types/abi/ModularAccountFactoryAbi_V2_0_0.d.ts.map +1 -0
- package/dist/types/abi/MultiOwnerLightAccountFactoryAbi_V2_0_0.d.ts +287 -0
- package/dist/types/abi/MultiOwnerLightAccountFactoryAbi_V2_0_0.d.ts.map +1 -0
- package/dist/types/abi/MultiOwnerModularAccountFactoryAbi_V1_0_0.d.ts +235 -0
- package/dist/types/abi/MultiOwnerModularAccountFactoryAbi_V1_0_0.d.ts.map +1 -0
- package/dist/types/abi/MultisigModularAccountFactoryAbi_V1_0_0.d.ts +247 -0
- package/dist/types/abi/MultisigModularAccountFactoryAbi_V1_0_0.d.ts.map +1 -0
- package/dist/types/abi/index.d.ts +9 -0
- package/dist/types/abi/index.d.ts.map +1 -0
- package/dist/types/capabilities/index.d.ts +9 -0
- package/dist/types/capabilities/index.d.ts.map +1 -0
- package/dist/types/capabilities/paymaster.d.ts +4 -0
- package/dist/types/capabilities/paymaster.d.ts.map +1 -0
- package/dist/types/capabilities/permissions/index.d.ts +99 -0
- package/dist/types/capabilities/permissions/index.d.ts.map +1 -0
- package/dist/types/capabilities/permissions/mav2.d.ts +37 -0
- package/dist/types/capabilities/permissions/mav2.d.ts.map +1 -0
- package/dist/types/client/actions/createAccount.d.ts +11 -0
- package/dist/types/client/actions/createAccount.d.ts.map +1 -0
- package/dist/types/client/actions/getCallsStatus.d.ts +7 -0
- package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -0
- package/dist/types/client/actions/grantPermissions.d.ts +14 -0
- package/dist/types/client/actions/grantPermissions.d.ts.map +1 -0
- package/dist/types/client/actions/listAccounts.d.ts +7 -0
- package/dist/types/client/actions/listAccounts.d.ts.map +1 -0
- package/dist/types/client/actions/prepareCalls.d.ts +16 -0
- package/dist/types/client/actions/prepareCalls.d.ts.map +1 -0
- package/dist/types/client/actions/requestAccount.d.ts +12 -0
- package/dist/types/client/actions/requestAccount.d.ts.map +1 -0
- package/dist/types/client/actions/sendPreparedCalls.d.ts +7 -0
- package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -0
- package/dist/types/client/actions/signMessage.d.ts +7 -0
- package/dist/types/client/actions/signMessage.d.ts.map +1 -0
- package/dist/types/client/actions/signSignatureRequest.d.ts +11 -0
- package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -0
- package/dist/types/client/actions/signTypedData.d.ts +7 -0
- package/dist/types/client/actions/signTypedData.d.ts.map +1 -0
- package/dist/types/client/client.e2e-test.d.ts +2 -0
- package/dist/types/client/client.e2e-test.d.ts.map +1 -0
- package/dist/types/client/decorator.d.ts +25 -0
- package/dist/types/client/decorator.d.ts.map +1 -0
- package/dist/types/client/index.d.ts +19 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/exports/index.d.ts +14 -0
- package/dist/types/exports/index.d.ts.map +1 -0
- package/dist/types/exports/internal.d.ts +14 -0
- package/dist/types/exports/internal.d.ts.map +1 -0
- package/dist/types/isomorphic/actions/createSession.d.ts +15 -0
- package/dist/types/isomorphic/actions/createSession.d.ts.map +1 -0
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts +22 -0
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +1 -0
- package/dist/types/isomorphic/actions/prepareCalls.d.ts +9 -0
- package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +1 -0
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +9 -0
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -0
- package/dist/types/isomorphic/client.d.ts +98 -0
- package/dist/types/isomorphic/client.d.ts.map +1 -0
- package/dist/types/isomorphic/utils/createAccount.d.ts +23 -0
- package/dist/types/isomorphic/utils/createAccount.d.ts.map +1 -0
- package/dist/types/isomorphic/utils/createDummySigner.d.ts +4 -0
- package/dist/types/isomorphic/utils/createDummySigner.d.ts.map +1 -0
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +21 -0
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +1 -0
- package/dist/types/local/client.d.ts +4 -0
- package/dist/types/local/client.d.ts.map +1 -0
- package/dist/types/remote/client.d.ts +4 -0
- package/dist/types/remote/client.d.ts.map +1 -0
- package/dist/types/rpc/request.d.ts +330 -0
- package/dist/types/rpc/request.d.ts.map +1 -0
- package/dist/types/rpc/schema.d.ts +320 -0
- package/dist/types/rpc/schema.d.ts.map +1 -0
- package/dist/types/schemas.d.ts +217 -0
- package/dist/types/schemas.d.ts.map +1 -0
- package/dist/types/types.d.ts +28 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils.d.ts +5 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/package.json +67 -0
- package/src/abi/LightAccountFactoryAbi_V1_0_1.ts +44 -0
- package/src/abi/LightAccountFactoryAbi_V1_0_2.ts +44 -0
- package/src/abi/LightAccountFactoryAbi_V1_1_0.ts +44 -0
- package/src/abi/LightAccountFactoryAbi_V2_0_0.ts +201 -0
- package/src/abi/ModularAccountFactoryAbi_V2_0_0.ts +398 -0
- package/src/abi/MultiOwnerLightAccountFactoryAbi_V2_0_0.ts +224 -0
- package/src/abi/MultiOwnerModularAccountFactoryAbi_V1_0_0.ts +178 -0
- package/src/abi/MultisigModularAccountFactoryAbi_V1_0_0.ts +181 -0
- package/src/abi/index.ts +8 -0
- package/src/capabilities/index.ts +11 -0
- package/src/capabilities/paymaster.ts +5 -0
- package/src/capabilities/permissions/index.ts +124 -0
- package/src/capabilities/permissions/mav2.ts +127 -0
- package/src/client/actions/createAccount.ts +28 -0
- package/src/client/actions/getCallsStatus.ts +29 -0
- package/src/client/actions/grantPermissions.ts +48 -0
- package/src/client/actions/listAccounts.ts +18 -0
- package/src/client/actions/prepareCalls.ts +55 -0
- package/src/client/actions/requestAccount.ts +71 -0
- package/src/client/actions/sendPreparedCalls.ts +23 -0
- package/src/client/actions/signMessage.ts +32 -0
- package/src/client/actions/signSignatureRequest.ts +34 -0
- package/src/client/actions/signTypedData.ts +32 -0
- package/src/client/client.e2e-test.ts +294 -0
- package/src/client/decorator.ts +102 -0
- package/src/client/index.ts +93 -0
- package/src/exports/index.ts +32 -0
- package/src/exports/internal.ts +16 -0
- package/src/isomorphic/actions/createSession.ts +116 -0
- package/src/isomorphic/actions/getCallsStatus.ts +98 -0
- package/src/isomorphic/actions/prepareCalls.ts +99 -0
- package/src/isomorphic/actions/sendPreparedCalls.ts +95 -0
- package/src/isomorphic/client.ts +81 -0
- package/src/isomorphic/utils/createAccount.ts +58 -0
- package/src/isomorphic/utils/createDummySigner.ts +26 -0
- package/src/isomorphic/utils/parsePermissionsContext.ts +33 -0
- package/src/local/client.ts +132 -0
- package/src/remote/client.ts +67 -0
- package/src/rpc/request.ts +258 -0
- package/src/rpc/schema.ts +40 -0
- package/src/schemas.ts +257 -0
- package/src/types.ts +60 -0
- package/src/utils.ts +13 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createSmartAccountClient,
|
|
3
|
+
type SmartAccountClient,
|
|
4
|
+
type SmartAccountClientRpcSchema,
|
|
5
|
+
type SmartContractAccount,
|
|
6
|
+
} from "@aa-sdk/core";
|
|
7
|
+
import {
|
|
8
|
+
alchemyFeeEstimator,
|
|
9
|
+
alchemyGasManagerMiddleware,
|
|
10
|
+
type AlchemyTransport,
|
|
11
|
+
} from "@account-kit/infra";
|
|
12
|
+
import { type Chain, type Transport } from "viem";
|
|
13
|
+
import type { WalletServerViemRpcSchema } from "../rpc/schema";
|
|
14
|
+
import { prepareCalls, type PrepareCallsParams } from "./actions/prepareCalls";
|
|
15
|
+
import {
|
|
16
|
+
sendPreparedCalls,
|
|
17
|
+
type SendPreparedCallsParams,
|
|
18
|
+
} from "./actions/sendPreparedCalls";
|
|
19
|
+
import {
|
|
20
|
+
getCallsStatus,
|
|
21
|
+
type GetCallsStatusParams,
|
|
22
|
+
} from "./actions/getCallsStatus";
|
|
23
|
+
import {
|
|
24
|
+
createSession,
|
|
25
|
+
type CreateSessionParams,
|
|
26
|
+
} from "./actions/createSession";
|
|
27
|
+
|
|
28
|
+
// 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
|
+
type ClientParams = {
|
|
30
|
+
chain: Chain;
|
|
31
|
+
transport: Transport;
|
|
32
|
+
policyId?: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export function isomorphicClientActions(
|
|
36
|
+
client: SmartAccountClient<
|
|
37
|
+
Transport,
|
|
38
|
+
Chain,
|
|
39
|
+
SmartContractAccount | undefined,
|
|
40
|
+
Record<string, unknown>,
|
|
41
|
+
WalletServerViemRpcSchema
|
|
42
|
+
>,
|
|
43
|
+
) {
|
|
44
|
+
return {
|
|
45
|
+
prepareCalls: (params: PrepareCallsParams) => prepareCalls(client, params),
|
|
46
|
+
sendPreparedCalls: (params: SendPreparedCallsParams) =>
|
|
47
|
+
sendPreparedCalls(client, params),
|
|
48
|
+
getCallsStatus: (params: GetCallsStatusParams) =>
|
|
49
|
+
getCallsStatus(client, params),
|
|
50
|
+
createSession: (params: CreateSessionParams) =>
|
|
51
|
+
createSession(client, params),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// the isomorphic client likely won't be exposed directly. This client contains the business logic that can be run on the wallet server or on the client
|
|
56
|
+
// if the dev chooses to run the client in "local" mode.
|
|
57
|
+
export function createIsomorphicClient({
|
|
58
|
+
chain,
|
|
59
|
+
transport,
|
|
60
|
+
policyId,
|
|
61
|
+
}: ClientParams): SmartAccountClient<
|
|
62
|
+
Transport,
|
|
63
|
+
Chain,
|
|
64
|
+
SmartContractAccount | undefined,
|
|
65
|
+
ReturnType<typeof isomorphicClientActions>,
|
|
66
|
+
WalletServerViemRpcSchema & SmartAccountClientRpcSchema
|
|
67
|
+
> {
|
|
68
|
+
// This must be a smart account client since as of now we use it to build UOs under the hood
|
|
69
|
+
const client = createSmartAccountClient({
|
|
70
|
+
transport,
|
|
71
|
+
chain,
|
|
72
|
+
// TODO: we will want to enforce alchemy transport here probably
|
|
73
|
+
feeEstimator: alchemyFeeEstimator(transport as AlchemyTransport),
|
|
74
|
+
// TODO: we need to use the other middleware that does gas estimation as well here
|
|
75
|
+
...(policyId ? alchemyGasManagerMiddleware(policyId) : {}),
|
|
76
|
+
}).extend(isomorphicClientActions);
|
|
77
|
+
|
|
78
|
+
return client;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type IsomorphicClient = ReturnType<typeof createIsomorphicClient>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { SmartAccountSigner, SmartContractAccount } from "@aa-sdk/core";
|
|
2
|
+
import {
|
|
3
|
+
createModularAccountV2,
|
|
4
|
+
type ModularAccountV2,
|
|
5
|
+
} from "@account-kit/smart-contracts";
|
|
6
|
+
import type { StaticDecode } from "@sinclair/typebox";
|
|
7
|
+
import type { Address, Chain, Transport } from "viem";
|
|
8
|
+
import { concatHex, hexToNumber } from "viem";
|
|
9
|
+
import type { TypeSerializedInitcode } from "../../schemas";
|
|
10
|
+
import type { Capabilities } from "../../capabilities";
|
|
11
|
+
import { parsePermissionsContext } from "./parsePermissionsContext";
|
|
12
|
+
|
|
13
|
+
type CreateAccountParams = {
|
|
14
|
+
chain: Chain;
|
|
15
|
+
transport: Transport;
|
|
16
|
+
signer: SmartAccountSigner;
|
|
17
|
+
accountAddress: Address;
|
|
18
|
+
counterfactualInfo: StaticDecode<typeof TypeSerializedInitcode>;
|
|
19
|
+
capabilities?: StaticDecode<typeof Capabilities>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Creates a smart account instance from the given parameters.
|
|
24
|
+
* @param params - The parameters for creating a smart account.
|
|
25
|
+
* @returns A promise that resolves to the created smart account.
|
|
26
|
+
*/
|
|
27
|
+
export async function createAccount(
|
|
28
|
+
params: CreateAccountParams,
|
|
29
|
+
): Promise<SmartContractAccount> {
|
|
30
|
+
const { counterfactualInfo: ci, ...accountParams } = params;
|
|
31
|
+
// TODO: Implement support for other account types.
|
|
32
|
+
if (ci.factoryType !== "MAv2.0.0-sma-b") {
|
|
33
|
+
throw new Error("Only MAv2 SMA-B accounts are currently supported");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const parsedContext = parsePermissionsContext(params.capabilities, ci);
|
|
37
|
+
|
|
38
|
+
const signerEntity =
|
|
39
|
+
parsedContext?.contextVersion === "NON_DEFERRED_ACTION"
|
|
40
|
+
? {
|
|
41
|
+
entityId: hexToNumber(parsedContext.entityId),
|
|
42
|
+
isGlobalValidation: parsedContext.isGlobalValidation,
|
|
43
|
+
}
|
|
44
|
+
: undefined;
|
|
45
|
+
|
|
46
|
+
return createModularAccountV2({
|
|
47
|
+
...accountParams,
|
|
48
|
+
signerEntity,
|
|
49
|
+
deferredAction: parsedContext?.deferredAction,
|
|
50
|
+
initCode: concatHex([ci.factoryAddress, ci.factoryData]),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function isModularAccountV2(
|
|
55
|
+
account: SmartContractAccount,
|
|
56
|
+
): account is ModularAccountV2 {
|
|
57
|
+
return account.source === "ModularAccountV2";
|
|
58
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
+
import type { TypedData } from "abitype";
|
|
3
|
+
import {
|
|
4
|
+
type Address,
|
|
5
|
+
type Hex,
|
|
6
|
+
type SignableMessage,
|
|
7
|
+
type TypedDataDefinition,
|
|
8
|
+
} from "viem";
|
|
9
|
+
|
|
10
|
+
export const createDummySigner = (address: Address): SmartAccountSigner => ({
|
|
11
|
+
signerType: "",
|
|
12
|
+
inner: undefined,
|
|
13
|
+
getAddress: async function (): Promise<`0x${string}`> {
|
|
14
|
+
return address;
|
|
15
|
+
},
|
|
16
|
+
// Not supported on the server
|
|
17
|
+
signMessage: function (_message: SignableMessage): Promise<Hex> {
|
|
18
|
+
throw new Error("Function not implemented.");
|
|
19
|
+
},
|
|
20
|
+
signTypedData: function <
|
|
21
|
+
const TTypedData extends TypedData | Record<string, unknown>,
|
|
22
|
+
TPrimaryType extends keyof TTypedData | "EIP712Domain" = keyof TTypedData,
|
|
23
|
+
>(_params: TypedDataDefinition<TTypedData, TPrimaryType>): Promise<Hex> {
|
|
24
|
+
throw new Error("Function not implemented.");
|
|
25
|
+
},
|
|
26
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { StaticDecode } from "@sinclair/typebox";
|
|
2
|
+
import type { PrepareCallsParams } from "../actions/prepareCalls";
|
|
3
|
+
import type { TypeSerializedInitcode } from "../../schemas";
|
|
4
|
+
import { InvalidRequestError } from "ox/RpcResponse";
|
|
5
|
+
import { decodePermissionsContext } from "../../capabilities/permissions/mav2";
|
|
6
|
+
|
|
7
|
+
export function parsePermissionsContext(
|
|
8
|
+
capabilities: PrepareCallsParams["capabilities"],
|
|
9
|
+
parsedCi: StaticDecode<typeof TypeSerializedInitcode>,
|
|
10
|
+
) {
|
|
11
|
+
if (!capabilities?.permissions?.context) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (
|
|
16
|
+
capabilities?.permissions?.context &&
|
|
17
|
+
parsedCi.factoryType !== "MAv2.0.0-sma-b"
|
|
18
|
+
) {
|
|
19
|
+
throw new InvalidRequestError({
|
|
20
|
+
message: "Permissions are currently only supported by MAv2 accounts",
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const context = decodePermissionsContext(capabilities.permissions.context);
|
|
25
|
+
|
|
26
|
+
if (context?.contextVersion === "REMOTE_MODE_DEFERRED_ACTION") {
|
|
27
|
+
throw new InvalidRequestError({
|
|
28
|
+
message: "Remote mode deferred action not supported in isomorphic client",
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return context;
|
|
33
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { split } from "@aa-sdk/core";
|
|
2
|
+
import { createClient, custom, type Address, type JsonRpcAccount } from "viem";
|
|
3
|
+
import type { PrepareCallsParams } from "../isomorphic/actions/prepareCalls";
|
|
4
|
+
import {
|
|
5
|
+
createIsomorphicClient,
|
|
6
|
+
type IsomorphicClient,
|
|
7
|
+
} from "../isomorphic/client";
|
|
8
|
+
import type {
|
|
9
|
+
CreateInnerClientParams,
|
|
10
|
+
InnerClientActions,
|
|
11
|
+
InnerWalletApiClient,
|
|
12
|
+
} from "../types";
|
|
13
|
+
import { assertNever } from "../utils";
|
|
14
|
+
import { signSignatureRequest } from "../client/actions/signSignatureRequest";
|
|
15
|
+
import {
|
|
16
|
+
encodePermissionsContext,
|
|
17
|
+
prefixSignatureKeyType,
|
|
18
|
+
} from "../capabilities/permissions/mav2";
|
|
19
|
+
import { buildDeferredActionDigest } from "@account-kit/smart-contracts/experimental";
|
|
20
|
+
|
|
21
|
+
const localMethods = [
|
|
22
|
+
"wallet_prepareCalls",
|
|
23
|
+
"wallet_sendPreparedCalls",
|
|
24
|
+
"wallet_getCallsStatus",
|
|
25
|
+
"wallet_createSession",
|
|
26
|
+
] as const satisfies string[];
|
|
27
|
+
type LocalMethod = (typeof localMethods)[number];
|
|
28
|
+
|
|
29
|
+
export function createLocalClient<
|
|
30
|
+
TAccount extends JsonRpcAccount<Address> | undefined =
|
|
31
|
+
| JsonRpcAccount<Address>
|
|
32
|
+
| undefined,
|
|
33
|
+
>(params: CreateInnerClientParams<TAccount>): InnerWalletApiClient<TAccount>;
|
|
34
|
+
|
|
35
|
+
export function createLocalClient(
|
|
36
|
+
params: CreateInnerClientParams,
|
|
37
|
+
): InnerWalletApiClient {
|
|
38
|
+
const { chain, transport, policyId, account } = params;
|
|
39
|
+
const isomorphicClient = createIsomorphicClient({
|
|
40
|
+
transport,
|
|
41
|
+
chain,
|
|
42
|
+
policyId,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const clientMap: Record<string, ReturnType<typeof createIsomorphicClient>> = {
|
|
46
|
+
[policyId ?? "default"]: isomorphicClient,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const innerTransport = split({
|
|
50
|
+
overrides: [
|
|
51
|
+
{
|
|
52
|
+
methods: localMethods,
|
|
53
|
+
transport: custom({
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
+
async request(args: { method: LocalMethod; params: any }) {
|
|
56
|
+
switch (args.method) {
|
|
57
|
+
case "wallet_prepareCalls": {
|
|
58
|
+
const params = args.params[0] as PrepareCallsParams;
|
|
59
|
+
const capabilityPolicyId =
|
|
60
|
+
params.capabilities?.paymasterService?.policyId;
|
|
61
|
+
|
|
62
|
+
if (
|
|
63
|
+
capabilityPolicyId != null &&
|
|
64
|
+
policyId !== capabilityPolicyId &&
|
|
65
|
+
!clientMap[capabilityPolicyId]
|
|
66
|
+
) {
|
|
67
|
+
clientMap[capabilityPolicyId] = createIsomorphicClient({
|
|
68
|
+
transport,
|
|
69
|
+
chain,
|
|
70
|
+
policyId: capabilityPolicyId,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const client =
|
|
75
|
+
clientMap[capabilityPolicyId ?? policyId ?? "default"];
|
|
76
|
+
return client.prepareCalls(params);
|
|
77
|
+
}
|
|
78
|
+
case "wallet_sendPreparedCalls":
|
|
79
|
+
return isomorphicClient.sendPreparedCalls(args.params[0]);
|
|
80
|
+
case "wallet_getCallsStatus":
|
|
81
|
+
return isomorphicClient.getCallsStatus(args.params[0]);
|
|
82
|
+
case "wallet_createSession": {
|
|
83
|
+
return isomorphicClient.createSession(args.params[0]);
|
|
84
|
+
}
|
|
85
|
+
default:
|
|
86
|
+
return assertNever(
|
|
87
|
+
args.method,
|
|
88
|
+
`Unexpected method: ${args.method}`,
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
}),
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
fallback: transport,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
return createClient({
|
|
99
|
+
transport: innerTransport,
|
|
100
|
+
chain,
|
|
101
|
+
account,
|
|
102
|
+
}).extend(() => ({
|
|
103
|
+
policyId,
|
|
104
|
+
...innerClientActions(isomorphicClient),
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const innerClientActions = (
|
|
109
|
+
isomorphicClient: IsomorphicClient,
|
|
110
|
+
): InnerClientActions => {
|
|
111
|
+
return {
|
|
112
|
+
grantPermissions: async (signer, params) => {
|
|
113
|
+
const { signatureRequest, fullPreSignatureDeferredActionDigest } =
|
|
114
|
+
await isomorphicClient.createSession(params);
|
|
115
|
+
|
|
116
|
+
const { signature } = await signSignatureRequest(
|
|
117
|
+
signer,
|
|
118
|
+
signatureRequest,
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
context: encodePermissionsContext({
|
|
123
|
+
contextVersion: "LOCAL_MODE_DEFERRED_ACTION",
|
|
124
|
+
deferredAction: buildDeferredActionDigest({
|
|
125
|
+
fullPreSignatureDeferredActionDigest,
|
|
126
|
+
sig: prefixSignatureKeyType(signature, "secp256k1"),
|
|
127
|
+
}),
|
|
128
|
+
}),
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Provider } from "ox";
|
|
2
|
+
import { createClient, custom, type Address, type JsonRpcAccount } from "viem";
|
|
3
|
+
import { WalletServerRpcSchema } from "../rpc/schema";
|
|
4
|
+
import type {
|
|
5
|
+
CreateInnerClientParams,
|
|
6
|
+
InnerClientActions,
|
|
7
|
+
InnerWalletApiClient,
|
|
8
|
+
InnerWalletApiClientBase,
|
|
9
|
+
} from "../types";
|
|
10
|
+
import { signSignatureRequest } from "../client/actions/signSignatureRequest";
|
|
11
|
+
import { encodePermissionsContext } from "../capabilities/permissions/mav2";
|
|
12
|
+
|
|
13
|
+
export function createRemoteClient<
|
|
14
|
+
TAccount extends JsonRpcAccount<Address> | undefined =
|
|
15
|
+
| JsonRpcAccount<Address>
|
|
16
|
+
| undefined,
|
|
17
|
+
>(params: CreateInnerClientParams<TAccount>): InnerWalletApiClient<TAccount>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* This is a low-level client just used to make RPC requests in remote mode
|
|
21
|
+
* This should be wrapped by a higher-level smart account client that provides actions
|
|
22
|
+
* that uses this client under the hood
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
export function createRemoteClient(
|
|
26
|
+
params: CreateInnerClientParams,
|
|
27
|
+
): InnerWalletApiClient {
|
|
28
|
+
const { transport, chain, account } = params;
|
|
29
|
+
|
|
30
|
+
const client = createClient({
|
|
31
|
+
transport: (opts) =>
|
|
32
|
+
custom(Provider.from(transport(opts), { schema: WalletServerRpcSchema }))(
|
|
33
|
+
opts,
|
|
34
|
+
),
|
|
35
|
+
chain,
|
|
36
|
+
account,
|
|
37
|
+
}).extend((_client) => ({
|
|
38
|
+
policyId: params.policyId,
|
|
39
|
+
...innerClientActions(_client),
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
return client;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const innerClientActions = (
|
|
46
|
+
apiClient: InnerWalletApiClientBase,
|
|
47
|
+
): InnerClientActions => {
|
|
48
|
+
return {
|
|
49
|
+
grantPermissions: async (signer, params) => {
|
|
50
|
+
const { sessionId, signatureRequest } = await apiClient.request({
|
|
51
|
+
method: "wallet_createSession",
|
|
52
|
+
params: [params],
|
|
53
|
+
});
|
|
54
|
+
const { signature } = await signSignatureRequest(
|
|
55
|
+
signer,
|
|
56
|
+
signatureRequest,
|
|
57
|
+
);
|
|
58
|
+
return {
|
|
59
|
+
context: encodePermissionsContext({
|
|
60
|
+
contextVersion: "REMOTE_MODE_DEFERRED_ACTION",
|
|
61
|
+
sessionId,
|
|
62
|
+
signature,
|
|
63
|
+
}),
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
};
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { Capabilities } from "../capabilities";
|
|
3
|
+
import {
|
|
4
|
+
PermissionsContext,
|
|
5
|
+
PermissionsData,
|
|
6
|
+
} from "../capabilities/permissions";
|
|
7
|
+
import {
|
|
8
|
+
TypeAddress,
|
|
9
|
+
TypeBase64UrlEncodedString,
|
|
10
|
+
TypeCreationOptions,
|
|
11
|
+
TypeHex,
|
|
12
|
+
TypeSerializedInitcode,
|
|
13
|
+
TypeSignatureRequest,
|
|
14
|
+
TypeUserOperationRequest_v6,
|
|
15
|
+
TypeUserOperationRequest_v7,
|
|
16
|
+
TypeUuid,
|
|
17
|
+
} from "../schemas";
|
|
18
|
+
|
|
19
|
+
export const wallet_sendPreparedCalls = Type.Object(
|
|
20
|
+
{
|
|
21
|
+
Request: Type.Object({
|
|
22
|
+
method: Type.Literal("wallet_sendPreparedCalls"),
|
|
23
|
+
params: Type.Tuple([
|
|
24
|
+
Type.Object({
|
|
25
|
+
type: Type.Union([
|
|
26
|
+
Type.Literal("user-operation-v060"),
|
|
27
|
+
Type.Literal("user-operation-v070"),
|
|
28
|
+
]),
|
|
29
|
+
data: Type.Union([
|
|
30
|
+
Type.Omit(TypeUserOperationRequest_v6, ["signature"]),
|
|
31
|
+
Type.Omit(TypeUserOperationRequest_v7, ["signature"]),
|
|
32
|
+
]),
|
|
33
|
+
chainId: TypeHex(),
|
|
34
|
+
signature: Type.Object({
|
|
35
|
+
// ignored, but in the spec can be used when the signature on the UO needs to be formatted differently
|
|
36
|
+
// potentially useful for deferred actions?
|
|
37
|
+
type: Type.String(),
|
|
38
|
+
signature: TypeHex(),
|
|
39
|
+
}),
|
|
40
|
+
capabilities: Type.Optional(
|
|
41
|
+
Type.Object({ permissions: PermissionsContext }),
|
|
42
|
+
),
|
|
43
|
+
}),
|
|
44
|
+
]),
|
|
45
|
+
}),
|
|
46
|
+
ReturnType: Type.Object({
|
|
47
|
+
preparedCallIds: Type.Array(TypeHex()),
|
|
48
|
+
}),
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
description:
|
|
52
|
+
"This method is used after signing the signatureRequest returned from prepareCalls to submit a user operation",
|
|
53
|
+
},
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
export const wallet_prepareCalls = Type.Object(
|
|
57
|
+
{
|
|
58
|
+
Request: Type.Object({
|
|
59
|
+
method: Type.Literal("wallet_prepareCalls"),
|
|
60
|
+
params: Type.Tuple([
|
|
61
|
+
Type.Object({
|
|
62
|
+
calls: Type.Array(
|
|
63
|
+
Type.Object({
|
|
64
|
+
to: TypeAddress,
|
|
65
|
+
data: Type.Optional(TypeHex()),
|
|
66
|
+
value: Type.Optional(TypeHex()),
|
|
67
|
+
}),
|
|
68
|
+
),
|
|
69
|
+
from: TypeAddress,
|
|
70
|
+
chainId: TypeHex(),
|
|
71
|
+
capabilities: Type.Optional(Capabilities),
|
|
72
|
+
}),
|
|
73
|
+
]),
|
|
74
|
+
}),
|
|
75
|
+
ReturnType: Type.Object({
|
|
76
|
+
type: Type.Union([
|
|
77
|
+
Type.Literal("user-operation-v060"),
|
|
78
|
+
Type.Literal("user-operation-v070"),
|
|
79
|
+
]),
|
|
80
|
+
data: Type.Union([
|
|
81
|
+
Type.Omit(TypeUserOperationRequest_v6, ["signature"]),
|
|
82
|
+
Type.Omit(TypeUserOperationRequest_v7, ["signature"]),
|
|
83
|
+
]),
|
|
84
|
+
chainId: TypeHex(),
|
|
85
|
+
signatureRequest: TypeSignatureRequest,
|
|
86
|
+
}),
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
description:
|
|
90
|
+
"This method is used to prepare a user operation for submission. It will return a built user operation and a signature request which needs to be signed by the user before submitting to wallet_sendPreparedCalls",
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
export const wallet_requestAccount = Type.Object(
|
|
95
|
+
{
|
|
96
|
+
Request: Type.Object({
|
|
97
|
+
method: Type.Literal("wallet_requestAccount"),
|
|
98
|
+
params: Type.Tuple([
|
|
99
|
+
Type.Union([
|
|
100
|
+
Type.Object({
|
|
101
|
+
signerAddress: TypeAddress,
|
|
102
|
+
id: Type.Optional(TypeUuid),
|
|
103
|
+
creationHint: TypeCreationOptions,
|
|
104
|
+
includeCounterfactualInfo: Type.Optional(
|
|
105
|
+
Type.Boolean({ default: false }),
|
|
106
|
+
),
|
|
107
|
+
}),
|
|
108
|
+
Type.Object({
|
|
109
|
+
accountAddress: TypeAddress,
|
|
110
|
+
includeCounterfactualInfo: Type.Optional(
|
|
111
|
+
Type.Boolean({ default: false }),
|
|
112
|
+
),
|
|
113
|
+
}),
|
|
114
|
+
]),
|
|
115
|
+
]),
|
|
116
|
+
}),
|
|
117
|
+
ReturnType: Type.Object({
|
|
118
|
+
accountAddress: TypeAddress,
|
|
119
|
+
id: TypeUuid,
|
|
120
|
+
counterfactualInfo: Type.Optional(TypeSerializedInitcode),
|
|
121
|
+
}),
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
description: `This method is used to get the smart account address and relevant info for a given signer. If an account does not already exist for a given signer, this method will create one before returning the counterfactual address.`,
|
|
125
|
+
},
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
export const wallet_createAccount = Type.Object(
|
|
129
|
+
{
|
|
130
|
+
Request: Type.Object({
|
|
131
|
+
method: Type.Literal("wallet_createAccount"),
|
|
132
|
+
params: Type.Tuple([
|
|
133
|
+
Type.Object({
|
|
134
|
+
signerAddress: TypeAddress,
|
|
135
|
+
id: Type.Optional(TypeUuid),
|
|
136
|
+
creationOptions: TypeCreationOptions,
|
|
137
|
+
}),
|
|
138
|
+
]),
|
|
139
|
+
}),
|
|
140
|
+
ReturnType: Type.Object({
|
|
141
|
+
accountAddress: TypeAddress,
|
|
142
|
+
id: TypeUuid,
|
|
143
|
+
}),
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
description: `This method is used to create a smart account for a given signer. This method is primarly used to import existing accounts. For most cases, you should use wallet_requestAccount instead.`,
|
|
147
|
+
},
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
export const wallet_listAccounts = Type.Object(
|
|
151
|
+
{
|
|
152
|
+
Request: Type.Object({
|
|
153
|
+
method: Type.Literal("wallet_listAccounts"),
|
|
154
|
+
params: Type.Tuple([
|
|
155
|
+
Type.Object({
|
|
156
|
+
signerAddress: TypeAddress,
|
|
157
|
+
limit: Type.Optional(
|
|
158
|
+
Type.Number({ minimum: 1, maximum: 100, default: 100 }),
|
|
159
|
+
),
|
|
160
|
+
after: Type.Optional(TypeBase64UrlEncodedString),
|
|
161
|
+
}),
|
|
162
|
+
]),
|
|
163
|
+
}),
|
|
164
|
+
ReturnType: Type.Object({
|
|
165
|
+
accounts: Type.Array(
|
|
166
|
+
Type.Object({
|
|
167
|
+
accountAddress: TypeAddress,
|
|
168
|
+
id: TypeUuid,
|
|
169
|
+
}),
|
|
170
|
+
),
|
|
171
|
+
meta: Type.Object({
|
|
172
|
+
totalCount: Type.Number(),
|
|
173
|
+
after: Type.Union([TypeBase64UrlEncodedString, Type.Null()]),
|
|
174
|
+
}),
|
|
175
|
+
}),
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
description:
|
|
179
|
+
"This method is used to list all smart accounts for a given signer.",
|
|
180
|
+
},
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
export const wallet_createSession = Type.Object({
|
|
184
|
+
Request: Type.Object({
|
|
185
|
+
method: Type.Literal("wallet_createSession"),
|
|
186
|
+
params: Type.Tuple([
|
|
187
|
+
Type.Intersect([PermissionsData, Type.Object({ account: TypeAddress })]),
|
|
188
|
+
]),
|
|
189
|
+
}),
|
|
190
|
+
ReturnType: Type.Object({
|
|
191
|
+
sessionId: TypeHex(),
|
|
192
|
+
signatureRequest: TypeSignatureRequest,
|
|
193
|
+
}),
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
export const wallet_getCallsStatus = Type.Object(
|
|
197
|
+
{
|
|
198
|
+
Request: Type.Object({
|
|
199
|
+
method: Type.Literal("wallet_getCallsStatus"),
|
|
200
|
+
params: Type.Tuple([
|
|
201
|
+
TypeHex({
|
|
202
|
+
description: "The call ID returned from wallet_sendPreparedCalls",
|
|
203
|
+
}),
|
|
204
|
+
]),
|
|
205
|
+
}),
|
|
206
|
+
ReturnType: Type.Object({
|
|
207
|
+
id: TypeHex(),
|
|
208
|
+
chainId: TypeHex(),
|
|
209
|
+
atomic: Type.Boolean(),
|
|
210
|
+
status: Type.Union([
|
|
211
|
+
Type.Literal(100, {
|
|
212
|
+
description:
|
|
213
|
+
"Batch has been received by the wallet but has not completed execution onchain",
|
|
214
|
+
}),
|
|
215
|
+
Type.Literal(200, {
|
|
216
|
+
description:
|
|
217
|
+
"Batch has been included onchain without reverts, receipts array contains info of all calls",
|
|
218
|
+
}),
|
|
219
|
+
Type.Literal(400, {
|
|
220
|
+
description:
|
|
221
|
+
"Batch has not been included onchain and wallet will not retry",
|
|
222
|
+
}),
|
|
223
|
+
Type.Literal(500, {
|
|
224
|
+
description:
|
|
225
|
+
"Batch reverted *completely* and only changes related to gas charge may have been included onchain",
|
|
226
|
+
}),
|
|
227
|
+
Type.Literal(600, {
|
|
228
|
+
description:
|
|
229
|
+
"Batch reverted *partially* and some changes related to batch calls may have been included onchain",
|
|
230
|
+
}),
|
|
231
|
+
]),
|
|
232
|
+
receipts: Type.Optional(
|
|
233
|
+
Type.Array(
|
|
234
|
+
Type.Object({
|
|
235
|
+
logs: Type.Array(
|
|
236
|
+
Type.Object({
|
|
237
|
+
address: TypeAddress,
|
|
238
|
+
data: TypeHex(),
|
|
239
|
+
topics: Type.Array(TypeHex()),
|
|
240
|
+
}),
|
|
241
|
+
),
|
|
242
|
+
status: TypeHex({
|
|
243
|
+
description: "0x1 for success, 0x0 for failure",
|
|
244
|
+
}),
|
|
245
|
+
blockHash: TypeHex(),
|
|
246
|
+
blockNumber: TypeHex(),
|
|
247
|
+
gasUsed: TypeHex(),
|
|
248
|
+
transactionHash: TypeHex(),
|
|
249
|
+
}),
|
|
250
|
+
),
|
|
251
|
+
),
|
|
252
|
+
}),
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
description:
|
|
256
|
+
"This method is used to get the status of calls IDs returned from wallet_sendPreparedCalls.",
|
|
257
|
+
},
|
|
258
|
+
);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Static } from "@sinclair/typebox";
|
|
2
|
+
import { RpcSchema } from "ox";
|
|
3
|
+
import * as Requests from "./request";
|
|
4
|
+
|
|
5
|
+
export const WalletServerRpcSchema = RpcSchema.from<
|
|
6
|
+
| Static<typeof Requests.wallet_prepareCalls>
|
|
7
|
+
| Static<typeof Requests.wallet_sendPreparedCalls>
|
|
8
|
+
| Static<typeof Requests.wallet_createAccount>
|
|
9
|
+
| Static<typeof Requests.wallet_requestAccount>
|
|
10
|
+
| Static<typeof Requests.wallet_listAccounts>
|
|
11
|
+
| Static<typeof Requests.wallet_createSession>
|
|
12
|
+
| Static<typeof Requests.wallet_getCallsStatus>
|
|
13
|
+
>();
|
|
14
|
+
|
|
15
|
+
export type WalletServerRpcSchemaType = typeof WalletServerRpcSchema;
|
|
16
|
+
|
|
17
|
+
type MethodToViemRpcSchema = {
|
|
18
|
+
[K in WalletServerRpcSchemaType["Request"]["method"]]: {
|
|
19
|
+
Method: K;
|
|
20
|
+
Parameters: Extract<
|
|
21
|
+
WalletServerRpcSchemaType["Request"],
|
|
22
|
+
{ method: K }
|
|
23
|
+
>["params"];
|
|
24
|
+
ReturnType: Extract<
|
|
25
|
+
WalletServerRpcSchemaType,
|
|
26
|
+
{ Request: { method: K } }
|
|
27
|
+
>["ReturnType"];
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// TODO: figure out how we can do this without manually listing all the methods
|
|
32
|
+
export type WalletServerViemRpcSchema = [
|
|
33
|
+
MethodToViemRpcSchema["wallet_createAccount"],
|
|
34
|
+
MethodToViemRpcSchema["wallet_requestAccount"],
|
|
35
|
+
MethodToViemRpcSchema["wallet_listAccounts"],
|
|
36
|
+
MethodToViemRpcSchema["wallet_prepareCalls"],
|
|
37
|
+
MethodToViemRpcSchema["wallet_sendPreparedCalls"],
|
|
38
|
+
MethodToViemRpcSchema["wallet_getCallsStatus"],
|
|
39
|
+
MethodToViemRpcSchema["wallet_createSession"],
|
|
40
|
+
];
|