@account-kit/wallet-client 0.1.0-alpha.0 → 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/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.js +3 -3
- package/dist/esm/capabilities/index.js.map +1 -1
- package/dist/esm/capabilities/overrides.js +1 -1
- package/dist/esm/capabilities/overrides.js.map +1 -1
- package/dist/esm/capabilities/permissions/index.js +1 -1
- package/dist/esm/capabilities/permissions/index.js.map +1 -1
- package/dist/esm/capabilities/permissions/mav2.d.ts +2 -2
- package/dist/esm/capabilities/permissions/mav2.js +1 -1
- 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 +23 -4
- package/dist/esm/client/actions/requestAccount.js +16 -5
- 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 +23 -3
- package/dist/esm/client/actions/signMessage.js +5 -3
- package/dist/esm/client/actions/signMessage.js.map +1 -1
- package/dist/esm/client/actions/signSignatureRequest.d.ts +32 -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 +36 -3
- package/dist/esm/client/actions/signTypedData.js +4 -2
- package/dist/esm/client/actions/signTypedData.js.map +1 -1
- package/dist/esm/client/client.e2e-test.js +101 -13
- package/dist/esm/client/client.e2e-test.js.map +1 -1
- package/dist/esm/client/decorator.d.ts +14 -12
- package/dist/esm/client/decorator.js +10 -10
- package/dist/esm/client/decorator.js.map +1 -1
- package/dist/esm/client/index.d.ts +5 -5
- package/dist/esm/client/index.js +32 -6
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/exports/index.d.ts +14 -13
- package/dist/esm/exports/index.js +14 -13
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/internal.d.ts +13 -13
- package/dist/esm/exports/internal.js +11 -11
- package/dist/esm/exports/internal.js.map +1 -1
- package/dist/esm/internal/decorator.d.ts +2 -0
- package/dist/esm/internal/decorator.js +10 -0
- package/dist/esm/internal/decorator.js.map +1 -0
- package/dist/esm/isomorphic/actions/createSession.d.ts +3 -3
- package/dist/esm/isomorphic/actions/createSession.js +5 -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 +2 -2
- package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -1
- package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +2 -2
- 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 +6 -6
- package/dist/esm/isomorphic/client.js +4 -4
- 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.d.ts +1 -1
- package/dist/esm/local/client.js +12 -5
- package/dist/esm/local/client.js.map +1 -1
- package/dist/esm/remote/client.d.ts +1 -1
- package/dist/esm/remote/client.js +9 -4
- package/dist/esm/remote/client.js.map +1 -1
- package/dist/esm/rpc/request.js +3 -3
- package/dist/esm/rpc/request.js.map +1 -1
- package/dist/esm/rpc/schema.d.ts +1 -1
- package/dist/esm/rpc/schema.js +1 -1
- package/dist/esm/rpc/schema.js.map +1 -1
- package/dist/esm/types.d.ts +15 -4
- package/dist/esm/types.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/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 +23 -4
- 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 +23 -3
- package/dist/types/client/actions/signMessage.d.ts.map +1 -1
- package/dist/types/client/actions/signSignatureRequest.d.ts +32 -1
- package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
- package/dist/types/client/actions/signTypedData.d.ts +36 -3
- package/dist/types/client/actions/signTypedData.d.ts.map +1 -1
- package/dist/types/client/decorator.d.ts +14 -12
- package/dist/types/client/decorator.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +5 -5
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +14 -13
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/exports/internal.d.ts +13 -13
- package/dist/types/exports/internal.d.ts.map +1 -1
- package/dist/types/internal/decorator.d.ts +3 -0
- package/dist/types/internal/decorator.d.ts.map +1 -0
- package/dist/types/isomorphic/actions/createSession.d.ts +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 +2 -2
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/isomorphic/client.d.ts +6 -6
- 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 +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 +14 -7
- package/src/abi/index.ts +8 -8
- package/src/capabilities/index.ts +3 -3
- package/src/capabilities/overrides.ts +1 -1
- package/src/capabilities/permissions/index.ts +1 -1
- package/src/capabilities/permissions/mav2.ts +3 -3
- 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 +44 -9
- package/src/client/actions/sendPreparedCalls.ts +39 -2
- package/src/client/actions/signMessage.ts +26 -6
- package/src/client/actions/signSignatureRequest.ts +33 -2
- package/src/client/actions/signTypedData.ts +41 -5
- package/src/client/client.e2e-test.ts +122 -13
- package/src/client/decorator.ts +25 -27
- package/src/client/index.ts +47 -13
- package/src/exports/index.ts +14 -13
- package/src/exports/internal.ts +13 -13
- package/src/internal/decorator.ts +12 -0
- package/src/isomorphic/actions/createSession.ts +15 -15
- package/src/isomorphic/actions/getCallsStatus.ts +6 -6
- package/src/isomorphic/actions/prepareCalls.ts +4 -4
- package/src/isomorphic/actions/sendPreparedCalls.ts +4 -4
- package/src/isomorphic/client.ts +8 -5
- package/src/isomorphic/utils/createAccount.ts +3 -3
- package/src/isomorphic/utils/parsePermissionsContext.ts +3 -3
- package/src/local/client.ts +56 -46
- package/src/remote/client.ts +13 -8
- package/src/rpc/request.ts +3 -3
- package/src/rpc/schema.ts +1 -1
- package/src/types.ts +18 -4
package/src/exports/index.ts
CHANGED
|
@@ -3,30 +3,31 @@
|
|
|
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";
|
|
33
|
+
export { grantPermissions } from "../client/actions/grantPermissions.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";
|
|
15
|
-
export type * from "../types";
|
|
16
|
-
export * from "../utils";
|
|
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
|
+
export type * from "../types.ts";
|
|
16
|
+
export * from "../utils.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CachedAccount, InternalState } from "../types.ts";
|
|
2
|
+
|
|
3
|
+
export function internalStateDecorator(): InternalState {
|
|
4
|
+
let account: CachedAccount | undefined = undefined;
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
setAccount: (newAccount: CachedAccount) => {
|
|
8
|
+
account = newAccount;
|
|
9
|
+
},
|
|
10
|
+
getAccount: () => account,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -3,27 +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";
|
|
25
|
-
import { Value } from "@sinclair/typebox/value";
|
|
26
|
-
import { TypePermission } from "../../capabilities/permissions";
|
|
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";
|
|
27
27
|
|
|
28
28
|
export type CreateSessionParams = Omit<
|
|
29
29
|
Static<
|
|
@@ -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"]
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
type Chain,
|
|
14
14
|
type Transport,
|
|
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<
|
|
@@ -14,10 +14,10 @@ import {
|
|
|
14
14
|
type Hex,
|
|
15
15
|
type Transport,
|
|
16
16
|
} from "viem";
|
|
17
|
-
import { decodePermissionsContext } from "../../capabilities/permissions/mav2";
|
|
18
|
-
import type { wallet_sendPreparedCalls } from "../../rpc/request";
|
|
19
|
-
import type { WalletServerViemRpcSchema } from "../../rpc/schema";
|
|
20
|
-
import { TypeCallId } from "../../schemas";
|
|
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<
|
package/src/isomorphic/client.ts
CHANGED
|
@@ -11,20 +11,23 @@ import {
|
|
|
11
11
|
type AlchemyTransport,
|
|
12
12
|
} from "@account-kit/infra";
|
|
13
13
|
import { type Chain, type Transport } from "viem";
|
|
14
|
-
import type { WalletServerViemRpcSchema } from "../rpc/schema";
|
|
14
|
+
import type { WalletServerViemRpcSchema } from "../rpc/schema.js";
|
|
15
15
|
import {
|
|
16
16
|
createSession,
|
|
17
17
|
type CreateSessionParams,
|
|
18
|
-
} from "./actions/createSession";
|
|
18
|
+
} from "./actions/createSession.js";
|
|
19
19
|
import {
|
|
20
20
|
getCallsStatus,
|
|
21
21
|
type GetCallsStatusParams,
|
|
22
|
-
} from "./actions/getCallsStatus";
|
|
23
|
-
import {
|
|
22
|
+
} from "./actions/getCallsStatus.js";
|
|
23
|
+
import {
|
|
24
|
+
prepareCalls,
|
|
25
|
+
type PrepareCallsParams,
|
|
26
|
+
} from "./actions/prepareCalls.js";
|
|
24
27
|
import {
|
|
25
28
|
sendPreparedCalls,
|
|
26
29
|
type SendPreparedCallsParams,
|
|
27
|
-
} from "./actions/sendPreparedCalls";
|
|
30
|
+
} from "./actions/sendPreparedCalls.js";
|
|
28
31
|
|
|
29
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
|
|
30
33
|
type ClientParams = {
|
|
@@ -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;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { StaticDecode } from "@sinclair/typebox";
|
|
2
|
-
import type { PrepareCallsParams } from "../actions/prepareCalls";
|
|
3
|
-
import type { TypeSerializedInitcode } from "../../schemas";
|
|
4
2
|
import { InvalidRequestError } from "ox/RpcResponse";
|
|
5
|
-
import { decodePermissionsContext } from "../../capabilities/permissions/mav2";
|
|
3
|
+
import { decodePermissionsContext } from "../../capabilities/permissions/mav2.js";
|
|
4
|
+
import type { TypeSerializedInitcode } from "../../schemas.js";
|
|
5
|
+
import type { PrepareCallsParams } from "../actions/prepareCalls.js";
|
|
6
6
|
|
|
7
7
|
export function parsePermissionsContext(
|
|
8
8
|
capabilities: PrepareCallsParams["capabilities"],
|
package/src/local/client.ts
CHANGED
|
@@ -4,19 +4,20 @@ import { createClient, custom, type Address, type JsonRpcAccount } from "viem";
|
|
|
4
4
|
import {
|
|
5
5
|
encodePermissionsContext,
|
|
6
6
|
prefixSignatureKeyType,
|
|
7
|
-
} from "../capabilities/permissions/mav2";
|
|
8
|
-
import { signSignatureRequest } from "../client/actions/signSignatureRequest";
|
|
9
|
-
import
|
|
7
|
+
} from "../capabilities/permissions/mav2.js";
|
|
8
|
+
import { signSignatureRequest } from "../client/actions/signSignatureRequest.js";
|
|
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,
|
|
13
|
-
} from "../isomorphic/client";
|
|
14
|
+
} from "../isomorphic/client.js";
|
|
14
15
|
import type {
|
|
15
16
|
CreateInnerClientParams,
|
|
16
17
|
InnerClientActions,
|
|
17
18
|
InnerWalletApiClient,
|
|
18
|
-
} from "../types";
|
|
19
|
-
import { assertNever } from "../utils";
|
|
19
|
+
} from "../types.ts";
|
|
20
|
+
import { assertNever } from "../utils.js";
|
|
20
21
|
|
|
21
22
|
const localMethods = [
|
|
22
23
|
"wallet_prepareCalls",
|
|
@@ -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
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Provider } from "ox";
|
|
2
2
|
import { createClient, custom, type Address, type JsonRpcAccount } from "viem";
|
|
3
|
-
import {
|
|
3
|
+
import { encodePermissionsContext } from "../capabilities/permissions/mav2.js";
|
|
4
|
+
import { signSignatureRequest } from "../client/actions/signSignatureRequest.js";
|
|
5
|
+
import { internalStateDecorator } from "../internal/decorator.js";
|
|
6
|
+
import { WalletServerRpcSchema } from "../rpc/schema.js";
|
|
4
7
|
import type {
|
|
5
8
|
CreateInnerClientParams,
|
|
6
9
|
InnerClientActions,
|
|
7
10
|
InnerWalletApiClient,
|
|
8
11
|
InnerWalletApiClientBase,
|
|
9
|
-
} from "../types";
|
|
10
|
-
import { signSignatureRequest } from "../client/actions/signSignatureRequest";
|
|
11
|
-
import { encodePermissionsContext } from "../capabilities/permissions/mav2";
|
|
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/rpc/request.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Type } from "@sinclair/typebox";
|
|
2
|
-
import { Capabilities } from "../capabilities";
|
|
2
|
+
import { Capabilities } from "../capabilities/index.js";
|
|
3
3
|
import {
|
|
4
4
|
PermissionsContext,
|
|
5
5
|
PermissionsData,
|
|
6
|
-
} from "../capabilities/permissions";
|
|
6
|
+
} from "../capabilities/permissions/index.js";
|
|
7
7
|
import {
|
|
8
8
|
TypeAddress,
|
|
9
9
|
TypeBase64UrlEncodedString,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
TypeUserOperationRequest_v6,
|
|
15
15
|
TypeUserOperationRequest_v7,
|
|
16
16
|
TypeUuid,
|
|
17
|
-
} from "../schemas";
|
|
17
|
+
} from "../schemas.js";
|
|
18
18
|
|
|
19
19
|
export const wallet_sendPreparedCalls = Type.Object(
|
|
20
20
|
{
|
package/src/rpc/schema.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Static, type StaticDecode } from "@sinclair/typebox";
|
|
2
2
|
import { RpcSchema } from "ox";
|
|
3
|
-
import * as Requests from "./request";
|
|
3
|
+
import * as Requests from "./request.js";
|
|
4
4
|
|
|
5
5
|
export const WalletServerRpcSchema = RpcSchema.from<
|
|
6
6
|
| Static<typeof Requests.wallet_prepareCalls>
|
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
|
+
>;
|