@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
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
-
import type { Hex, JsonRpcAccount
|
|
3
|
-
import type { SendPreparedCallsParams, SendPreparedCallsResult } from "../isomorphic/actions/sendPreparedCalls";
|
|
4
|
-
import type { InnerWalletApiClient } from "../types";
|
|
5
|
-
import { type CreateAccountParams, type CreateAccountResult } from "./actions/createAccount";
|
|
6
|
-
import { type
|
|
7
|
-
import { type
|
|
8
|
-
import { type
|
|
9
|
-
import { type
|
|
10
|
-
import { type
|
|
11
|
-
import { type
|
|
2
|
+
import type { Hex, JsonRpcAccount } from "viem";
|
|
3
|
+
import type { SendPreparedCallsParams, SendPreparedCallsResult } from "../isomorphic/actions/sendPreparedCalls.ts";
|
|
4
|
+
import type { InnerWalletApiClient } from "../types.ts";
|
|
5
|
+
import { type CreateAccountParams, type CreateAccountResult } from "./actions/createAccount.js";
|
|
6
|
+
import { type GetCallsStatusParams, type GetCallsStatusResult } from "./actions/getCallsStatus.js";
|
|
7
|
+
import { type GrantPermissionsParams, type GrantPermissionsResult } from "./actions/grantPermissions.js";
|
|
8
|
+
import { type ListAccountsParams, type ListAccountsResult } from "./actions/listAccounts.js";
|
|
9
|
+
import { type PrepareCallsParams, type PrepareCallsResult } from "./actions/prepareCalls.js";
|
|
10
|
+
import { type RequestAccountParams, type RequestAccountResult } from "./actions/requestAccount.js";
|
|
11
|
+
import { type SignMessageParams } from "./actions/signMessage.js";
|
|
12
|
+
import { type SignSignatureRequestParams, type SignSignatureRequestResult } from "./actions/signSignatureRequest.js";
|
|
13
|
+
import { type SignTypedDataParams } from "./actions/signTypedData.js";
|
|
12
14
|
export type SmartWalletActions<TAccount extends JsonRpcAccount | undefined = JsonRpcAccount | undefined> = {
|
|
13
15
|
requestAccount: (params?: RequestAccountParams<TAccount>) => Promise<RequestAccountResult>;
|
|
14
16
|
prepareCalls: (params: PrepareCallsParams<TAccount>) => Promise<PrepareCallsResult>;
|
|
@@ -17,8 +19,8 @@ export type SmartWalletActions<TAccount extends JsonRpcAccount | undefined = Jso
|
|
|
17
19
|
listAccounts: (params: ListAccountsParams) => Promise<ListAccountsResult>;
|
|
18
20
|
getCallsStatus: (params: GetCallsStatusParams) => Promise<GetCallsStatusResult>;
|
|
19
21
|
signSignatureRequest: (params: SignSignatureRequestParams) => Promise<SignSignatureRequestResult>;
|
|
20
|
-
signMessage: (params:
|
|
21
|
-
signTypedData: (params:
|
|
22
|
+
signMessage: (params: SignMessageParams) => Promise<Hex>;
|
|
23
|
+
signTypedData: (params: SignTypedDataParams) => Promise<Hex>;
|
|
22
24
|
grantPermissions: (params: GrantPermissionsParams<TAccount>) => Promise<GrantPermissionsResult>;
|
|
23
25
|
};
|
|
24
26
|
export declare function smartWalletClientActions<TAccount extends JsonRpcAccount | undefined = JsonRpcAccount | undefined>(client: InnerWalletApiClient<TAccount>, signer: SmartAccountSigner): SmartWalletActions<TAccount>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { createAccount, } from "./actions/createAccount";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
1
|
+
import { createAccount, } from "./actions/createAccount.js";
|
|
2
|
+
import { getCallsStatus, } from "./actions/getCallsStatus.js";
|
|
3
|
+
import { grantPermissions, } from "./actions/grantPermissions.js";
|
|
4
|
+
import { listAccounts, } from "./actions/listAccounts.js";
|
|
5
|
+
import { prepareCalls, } from "./actions/prepareCalls.js";
|
|
6
|
+
import { requestAccount, } from "./actions/requestAccount.js";
|
|
7
|
+
import { sendPreparedCalls } from "./actions/sendPreparedCalls.js";
|
|
8
|
+
import { signMessage } from "./actions/signMessage.js";
|
|
9
|
+
import { signSignatureRequest, } from "./actions/signSignatureRequest.js";
|
|
10
|
+
import { signTypedData, } from "./actions/signTypedData.js";
|
|
11
11
|
export function smartWalletClientActions(client, signer) {
|
|
12
12
|
return {
|
|
13
13
|
requestAccount: (params) => requestAccount(client, signer, params),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../src/client/decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../src/client/decorator.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,aAAa,GAGd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,cAAc,GAGf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,gBAAgB,GAGjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,YAAY,GAGb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,YAAY,GAGb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,cAAc,GAGf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,WAAW,EAA0B,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EACL,oBAAoB,GAGrB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,aAAa,GAEd,MAAM,4BAA4B,CAAC;AAoCpC,MAAM,UAAU,wBAAwB,CACtC,MAA4B,EAC5B,MAA0B;IAE1B,OAAO;QACL,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;QAClE,aAAa,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;QAChE,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC;QACtD,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC;QACtD,iBAAiB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC;QAChE,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC;QAC1D,oBAAoB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC;QACtE,WAAW,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;QAC5D,aAAa,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;QAChE,gBAAgB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;KACvE,CAAC;AACJ,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { Hex, JsonRpcAccount } from \"viem\";\nimport type {\n SendPreparedCallsParams,\n SendPreparedCallsResult,\n} from \"../isomorphic/actions/sendPreparedCalls.ts\";\nimport type { InnerWalletApiClient } from \"../types.ts\";\nimport {\n createAccount,\n type CreateAccountParams,\n type CreateAccountResult,\n} from \"./actions/createAccount.js\";\nimport {\n getCallsStatus,\n type GetCallsStatusParams,\n type GetCallsStatusResult,\n} from \"./actions/getCallsStatus.js\";\nimport {\n grantPermissions,\n type GrantPermissionsParams,\n type GrantPermissionsResult,\n} from \"./actions/grantPermissions.js\";\nimport {\n listAccounts,\n type ListAccountsParams,\n type ListAccountsResult,\n} from \"./actions/listAccounts.js\";\nimport {\n prepareCalls,\n type PrepareCallsParams,\n type PrepareCallsResult,\n} from \"./actions/prepareCalls.js\";\nimport {\n requestAccount,\n type RequestAccountParams,\n type RequestAccountResult,\n} from \"./actions/requestAccount.js\";\nimport { sendPreparedCalls } from \"./actions/sendPreparedCalls.js\";\nimport { signMessage, type SignMessageParams } from \"./actions/signMessage.js\";\nimport {\n signSignatureRequest,\n type SignSignatureRequestParams,\n type SignSignatureRequestResult,\n} from \"./actions/signSignatureRequest.js\";\nimport {\n signTypedData,\n type SignTypedDataParams,\n} from \"./actions/signTypedData.js\";\n\nexport type SmartWalletActions<\n TAccount extends JsonRpcAccount | undefined = JsonRpcAccount | undefined,\n> = {\n requestAccount: (\n params?: RequestAccountParams<TAccount>,\n ) => Promise<RequestAccountResult>;\n prepareCalls: (\n params: PrepareCallsParams<TAccount>,\n ) => Promise<PrepareCallsResult>;\n sendPreparedCalls: (\n params: SendPreparedCallsParams,\n ) => Promise<SendPreparedCallsResult>;\n createAccount: (params: CreateAccountParams) => Promise<CreateAccountResult>;\n listAccounts: (params: ListAccountsParams) => Promise<ListAccountsResult>;\n getCallsStatus: (\n params: GetCallsStatusParams,\n ) => Promise<GetCallsStatusResult>;\n signSignatureRequest: (\n params: SignSignatureRequestParams,\n ) => Promise<SignSignatureRequestResult>;\n signMessage: (params: SignMessageParams) => Promise<Hex>;\n signTypedData: (params: SignTypedDataParams) => Promise<Hex>;\n grantPermissions: (\n params: GrantPermissionsParams<TAccount>,\n ) => Promise<GrantPermissionsResult>;\n};\n\nexport function smartWalletClientActions<\n TAccount extends JsonRpcAccount | undefined = JsonRpcAccount | undefined,\n>(\n client: InnerWalletApiClient<TAccount>,\n signer: SmartAccountSigner,\n): SmartWalletActions<TAccount>;\n\nexport function smartWalletClientActions(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n): SmartWalletActions {\n return {\n requestAccount: (params) => requestAccount(client, signer, params),\n createAccount: (params) => createAccount(client, signer, params),\n prepareCalls: (params) => prepareCalls(client, params),\n listAccounts: (params) => listAccounts(client, params),\n sendPreparedCalls: (params) => sendPreparedCalls(client, params),\n getCallsStatus: (params) => getCallsStatus(client, params),\n signSignatureRequest: (params) => signSignatureRequest(signer, params),\n signMessage: (params) => signMessage(client, signer, params),\n signTypedData: (params) => signTypedData(client, signer, params),\n grantPermissions: (params) => grantPermissions(client, signer, params),\n };\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import type
|
|
5
|
-
import {
|
|
1
|
+
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
+
import type { Address, Chain, IsUndefined, JsonRpcAccount, Prettify } from "viem";
|
|
3
|
+
import type { InnerWalletApiClient } from "../types.ts";
|
|
4
|
+
import { type SmartWalletActions } from "./decorator.js";
|
|
5
|
+
import type { AlchemyTransport } from "@account-kit/infra";
|
|
6
6
|
export type SmartWalletClientParams<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined> = Prettify<{
|
|
7
7
|
transport: AlchemyTransport;
|
|
8
8
|
chain: Chain;
|
package/dist/esm/client/index.js
CHANGED
|
@@ -1,9 +1,35 @@
|
|
|
1
|
-
import {} from "
|
|
2
|
-
import {} from "
|
|
3
|
-
import {} from "
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { createLocalClient } from "../local/client.js";
|
|
2
|
+
import { createRemoteClient } from "../remote/client.js";
|
|
3
|
+
import { smartWalletClientActions, } from "./decorator.js";
|
|
4
|
+
/**
|
|
5
|
+
* Creates a smart wallet client that can be used to interact with a smart account.
|
|
6
|
+
*
|
|
7
|
+
* @param {SmartWalletClientParams} params - The parameters for creating the smart wallet client
|
|
8
|
+
* @param {AlchemyTransport} params.transport - The Alchemy transport to use
|
|
9
|
+
* @param {Chain} params.chain - The chain to use
|
|
10
|
+
* @param {SmartAccountSigner} params.signer - The signer to use for the smart account
|
|
11
|
+
* @param {"local" | "remote"} params.mode - The client's mode (local or remote).
|
|
12
|
+
* @param {string} [params.policyId] - The policy ID for gas sponsorship (optional)
|
|
13
|
+
* @param {Address} [params.account] - The smart account address to use (optional)
|
|
14
|
+
* @returns {InnerWalletApiClient & SmartWalletActions} - A viem-compatible client
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
18
|
+
* import { alchemy, arbitrumSepolia } from "@account-kit/infra";
|
|
19
|
+
* import { generatePrivateKey } from "viem/accounts";
|
|
20
|
+
* import { createSmartWalletClient } from "@account-kit/wallet-apis"; // TODO(jh): update this if we change the pkg name to `@account-kit/wallet-client`
|
|
21
|
+
*
|
|
22
|
+
* const signer = LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey());
|
|
23
|
+
* const transport = alchemy({
|
|
24
|
+
* apiKey: "your-alchemy-api-key",
|
|
25
|
+
* });
|
|
26
|
+
* const client = createSmartWalletClient({
|
|
27
|
+
* transport,
|
|
28
|
+
* chain: arbitrumSepolia,
|
|
29
|
+
* mode: "remote",
|
|
30
|
+
* signer,
|
|
31
|
+
* });
|
|
32
|
+
*/
|
|
7
33
|
export function createSmartWalletClient(params) {
|
|
8
34
|
const { transport, chain, policyId, mode, account, signer } = params;
|
|
9
35
|
const innerClient = mode === "local"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EACL,wBAAwB,GAEzB,MAAM,gBAAgB,CAAC;AAqCxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAA+B;IAE/B,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAErE,MAAM,WAAW,GACf,IAAI,KAAK,OAAO;QACd,CAAC,CAAC,iBAAiB,CAAC;YAChB,SAAS;YACT,KAAK;YACL,QAAQ;YACR,OAAO;SACR,CAAC;QACJ,CAAC,CAAC,kBAAkB,CAAC;YACjB,SAAS;YACT,KAAK;YACL,QAAQ;YACR,OAAO;SACR,CAAC,CAAC;IAET,yCAAyC;IACzC,qDAAqD;IACrD,4JAA4J;IAC5J,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CACnC,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,CACzC,CAAC;AACJ,CAAC;AAED,iBAAiB;AACjB,yDAAyD;AACzD,2CAA2C;AAC3C,wBAAwB;AACxB,4CAA4C;AAC5C,mBAAmB;AACnB,MAAM;AAEN,gEAAgE;AAEhE,sDAAsD;AACtD,2CAA2C;AAC3C,wBAAwB;AACxB,4CAA4C;AAC5C,mBAAmB;AACnB,0BAA0B;AAC1B,MAAM;AAEN,6DAA6D","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type {\n Address,\n Chain,\n IsUndefined,\n JsonRpcAccount,\n Prettify,\n} from \"viem\";\nimport { createLocalClient } from \"../local/client.js\";\nimport { createRemoteClient } from \"../remote/client.js\";\nimport type { InnerWalletApiClient } from \"../types.ts\";\nimport {\n smartWalletClientActions,\n type SmartWalletActions,\n} from \"./decorator.js\";\nimport type { AlchemyTransport } from \"@account-kit/infra\";\n\nexport type SmartWalletClientParams<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n> = Prettify<\n {\n transport: AlchemyTransport;\n chain: Chain;\n signer: SmartAccountSigner;\n mode: \"local\" | \"remote\";\n policyId?: string;\n } & (IsUndefined<TAccount> extends true\n ? {\n account?: never;\n }\n : {\n account: Address;\n })\n>;\n\nexport function createSmartWalletClient<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(\n params: SmartWalletClientParams<TAccount>,\n): InnerWalletApiClient<TAccount> & SmartWalletActions<TAccount>;\n\nexport function createSmartWalletClient<\n TAccount extends JsonRpcAccount<Address> = JsonRpcAccount<Address>,\n>(\n params: SmartWalletClientParams<TAccount>,\n): InnerWalletApiClient<TAccount> & SmartWalletActions<TAccount>;\n\n/**\n * Creates a smart wallet client that can be used to interact with a smart account.\n *\n * @param {SmartWalletClientParams} params - The parameters for creating the smart wallet client\n * @param {AlchemyTransport} params.transport - The Alchemy transport to use\n * @param {Chain} params.chain - The chain to use\n * @param {SmartAccountSigner} params.signer - The signer to use for the smart account\n * @param {\"local\" | \"remote\"} params.mode - The client's mode (local or remote).\n * @param {string} [params.policyId] - The policy ID for gas sponsorship (optional)\n * @param {Address} [params.account] - The smart account address to use (optional)\n * @returns {InnerWalletApiClient & SmartWalletActions} - A viem-compatible client\n *\n * @example\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { alchemy, arbitrumSepolia } from \"@account-kit/infra\";\n * import { generatePrivateKey } from \"viem/accounts\";\n * import { createSmartWalletClient } from \"@account-kit/wallet-apis\"; // TODO(jh): update this if we change the pkg name to `@account-kit/wallet-client`\n *\n * const signer = LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey());\n * const transport = alchemy({\n * apiKey: \"your-alchemy-api-key\",\n * });\n * const client = createSmartWalletClient({\n * transport,\n * chain: arbitrumSepolia,\n * mode: \"remote\",\n * signer,\n * });\n */\nexport function createSmartWalletClient(\n params: SmartWalletClientParams,\n): InnerWalletApiClient & SmartWalletActions {\n const { transport, chain, policyId, mode, account, signer } = params;\n\n const innerClient =\n mode === \"local\"\n ? createLocalClient({\n transport,\n chain,\n policyId,\n account,\n })\n : createRemoteClient({\n transport,\n chain,\n policyId,\n account,\n });\n\n // TODO: we need to do a few things here:\n // 1. decorate the client with the wallet api actions\n // 2. potentially we might want to make this client async and have it use `requestAccount` so that it can create a SCA client with an account attached to it\n return innerClient.extend((client) =>\n smartWalletClientActions(client, signer),\n );\n}\n\n// Example usage:\n// const clientWithoutAccount = createSmartWalletClient({\n// transport: alchemy({ apiKey: \"123\" }),\n// chain: baseSepolia,\n// signer: createDummySigner(zeroAddress),\n// mode: \"local\",\n// });\n\n// const account1 = await clientWithoutAccount.requestAccount();\n\n// const clientWithAccount = createSmartWalletClient({\n// transport: alchemy({ apiKey: \"123\" }),\n// chain: baseSepolia,\n// signer: createDummySigner(zeroAddress),\n// mode: \"local\",\n// account: zeroAddress,\n// });\n\n// const account2 = await clientWithAccount.requestAccount();\n"]}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
export { createSmartWalletClient, type SmartWalletClientParams, } from "../client";
|
|
2
|
-
export { WalletServerRpcSchema, type WalletServerRpcSchemaType, type WalletServerViemRpcSchema, } from "../rpc/schema";
|
|
3
|
-
export { Capabilities } from "../capabilities";
|
|
4
|
-
export { PaymasterCapability } from "../capabilities/paymaster";
|
|
5
|
-
export { PermissionsArray, PermissionsCapability, PermissionsContext, PermissionsData, } from "../capabilities/permissions";
|
|
6
|
-
export { createAccount } from "../client/actions/createAccount";
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export { signTypedData } from "../client/actions/signTypedData";
|
|
1
|
+
export { createSmartWalletClient, type SmartWalletClientParams, } from "../client/index.js";
|
|
2
|
+
export { WalletServerRpcSchema, type WalletServerRpcSchemaType, type WalletServerViemRpcSchema, } from "../rpc/schema.js";
|
|
3
|
+
export { Capabilities } from "../capabilities/index.js";
|
|
4
|
+
export { PaymasterCapability } from "../capabilities/paymaster.js";
|
|
5
|
+
export { PermissionsArray, PermissionsCapability, PermissionsContext, PermissionsData, } from "../capabilities/permissions/index.js";
|
|
6
|
+
export { createAccount } from "../client/actions/createAccount.js";
|
|
7
|
+
export { getCallsStatus } from "../client/actions/getCallsStatus.js";
|
|
8
|
+
export { listAccounts } from "../client/actions/listAccounts.js";
|
|
9
|
+
export { prepareCalls } from "../client/actions/prepareCalls.js";
|
|
10
|
+
export { requestAccount } from "../client/actions/requestAccount.js";
|
|
11
|
+
export { signMessage } from "../client/actions/signMessage.js";
|
|
12
|
+
export { signSignatureRequest } from "../client/actions/signSignatureRequest.js";
|
|
13
|
+
export { signTypedData } from "../client/actions/signTypedData.js";
|
|
14
|
+
export { grantPermissions } from "../client/actions/grantPermissions.js";
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
// TODO: anything that we want to expose publicly should be exported from `index.ts` files in the subdirectories
|
|
2
2
|
// and we shouldn't export * for the sake of tree-shaking
|
|
3
|
-
export { createSmartWalletClient, } from "../client";
|
|
4
|
-
export { WalletServerRpcSchema, } from "../rpc/schema";
|
|
3
|
+
export { createSmartWalletClient, } from "../client/index.js";
|
|
4
|
+
export { WalletServerRpcSchema, } from "../rpc/schema.js";
|
|
5
5
|
// capabilities: TODO: should these actually just have the types exported?
|
|
6
|
-
export { Capabilities } from "../capabilities";
|
|
7
|
-
export { PaymasterCapability } from "../capabilities/paymaster";
|
|
8
|
-
export { PermissionsArray, PermissionsCapability, PermissionsContext, PermissionsData, } from "../capabilities/permissions";
|
|
6
|
+
export { Capabilities } from "../capabilities/index.js";
|
|
7
|
+
export { PaymasterCapability } from "../capabilities/paymaster.js";
|
|
8
|
+
export { PermissionsArray, PermissionsCapability, PermissionsContext, PermissionsData, } from "../capabilities/permissions/index.js";
|
|
9
9
|
// client actions
|
|
10
|
-
export { createAccount } from "../client/actions/createAccount";
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export { signTypedData } from "../client/actions/signTypedData";
|
|
10
|
+
export { createAccount } from "../client/actions/createAccount.js";
|
|
11
|
+
export { getCallsStatus } from "../client/actions/getCallsStatus.js";
|
|
12
|
+
export { listAccounts } from "../client/actions/listAccounts.js";
|
|
13
|
+
export { prepareCalls } from "../client/actions/prepareCalls.js";
|
|
14
|
+
export { requestAccount } from "../client/actions/requestAccount.js";
|
|
15
|
+
export { signMessage } from "../client/actions/signMessage.js";
|
|
16
|
+
export { signSignatureRequest } from "../client/actions/signSignatureRequest.js";
|
|
17
|
+
export { signTypedData } from "../client/actions/signTypedData.js";
|
|
18
|
+
export { grantPermissions } from "../client/actions/grantPermissions.js";
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exports/index.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,yDAAyD;AACzD,OAAO,EACL,uBAAuB,GAExB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exports/index.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,yDAAyD;AACzD,OAAO,EACL,uBAAuB,GAExB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,qBAAqB,GAGtB,MAAM,kBAAkB,CAAC;AAE1B,0EAA0E;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,GAChB,MAAM,sCAAsC,CAAC;AAE9C,iBAAiB;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC","sourcesContent":["// TODO: anything that we want to expose publicly should be exported from `index.ts` files in the subdirectories\n// and we shouldn't export * for the sake of tree-shaking\nexport {\n createSmartWalletClient,\n type SmartWalletClientParams,\n} from \"../client/index.js\";\n\nexport {\n WalletServerRpcSchema,\n type WalletServerRpcSchemaType,\n type WalletServerViemRpcSchema,\n} from \"../rpc/schema.js\";\n\n// capabilities: TODO: should these actually just have the types exported?\nexport { Capabilities } from \"../capabilities/index.js\";\nexport { PaymasterCapability } from \"../capabilities/paymaster.js\";\nexport {\n PermissionsArray,\n PermissionsCapability,\n PermissionsContext,\n PermissionsData,\n} from \"../capabilities/permissions/index.js\";\n\n// client actions\nexport { createAccount } from \"../client/actions/createAccount.js\";\nexport { getCallsStatus } from \"../client/actions/getCallsStatus.js\";\nexport { listAccounts } from \"../client/actions/listAccounts.js\";\nexport { prepareCalls } from \"../client/actions/prepareCalls.js\";\nexport { requestAccount } from \"../client/actions/requestAccount.js\";\nexport { signMessage } from \"../client/actions/signMessage.js\";\nexport { signSignatureRequest } from \"../client/actions/signSignatureRequest.js\";\nexport { signTypedData } from \"../client/actions/signTypedData.js\";\nexport { grantPermissions } from \"../client/actions/grantPermissions.js\";\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export * from "../capabilities";
|
|
2
|
-
export * from "../capabilities/paymaster";
|
|
3
|
-
export * from "../capabilities/permissions";
|
|
4
|
-
export * from "../capabilities/permissions/mav2";
|
|
5
|
-
export type * from "../isomorphic/client";
|
|
6
|
-
export { createIsomorphicClient } from "../isomorphic/client";
|
|
7
|
-
export { createDummySigner } from "../isomorphic/utils/createDummySigner";
|
|
8
|
-
export * from "../rpc/request";
|
|
9
|
-
export * as RpcSchemas from "../rpc/request";
|
|
10
|
-
export * from "../rpc/schema";
|
|
11
|
-
export * from "../schemas";
|
|
12
|
-
export type * from "../types";
|
|
13
|
-
export * from "../utils";
|
|
1
|
+
export * from "../capabilities/index.js";
|
|
2
|
+
export * from "../capabilities/paymaster.js";
|
|
3
|
+
export * from "../capabilities/permissions/index.js";
|
|
4
|
+
export * from "../capabilities/permissions/mav2.js";
|
|
5
|
+
export type * from "../isomorphic/client.js";
|
|
6
|
+
export { createIsomorphicClient } from "../isomorphic/client.js";
|
|
7
|
+
export { createDummySigner } from "../isomorphic/utils/createDummySigner.js";
|
|
8
|
+
export * from "../rpc/request.js";
|
|
9
|
+
export * as RpcSchemas from "../rpc/request.js";
|
|
10
|
+
export * from "../rpc/schema.js";
|
|
11
|
+
export * from "../schemas.js";
|
|
12
|
+
export type * from "../types.ts";
|
|
13
|
+
export * from "../utils.js";
|
|
@@ -1,15 +1,15 @@
|
|
|
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 { createIsomorphicClient } from "../isomorphic/client";
|
|
9
|
-
export { createDummySigner } from "../isomorphic/utils/createDummySigner";
|
|
10
|
-
export * from "../rpc/request";
|
|
11
|
-
export * as RpcSchemas from "../rpc/request";
|
|
12
|
-
export * from "../rpc/schema";
|
|
13
|
-
export * from "../schemas";
|
|
14
|
-
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 { createIsomorphicClient } from "../isomorphic/client.js";
|
|
9
|
+
export { createDummySigner } from "../isomorphic/utils/createDummySigner.js";
|
|
10
|
+
export * from "../rpc/request.js";
|
|
11
|
+
export * as RpcSchemas from "../rpc/request.js";
|
|
12
|
+
export * from "../rpc/schema.js";
|
|
13
|
+
export * from "../schemas.js";
|
|
14
|
+
export * from "../utils.js";
|
|
15
15
|
//# sourceMappingURL=internal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/exports/internal.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,qFAAqF;AACrF,wBAAwB;AACxB,cAAc,
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/exports/internal.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,qFAAqF;AACrF,wBAAwB;AACxB,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sCAAsC,CAAC;AACrD,cAAc,qCAAqC,CAAC;AAEpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,cAAc,mBAAmB,CAAC;AAClC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAE9B,cAAc,aAAa,CAAC","sourcesContent":["// exports from this file are meant to be imported by our packages in the monorepo\n// we will expose this in the package.json as a named export like `this-pkg/internal`\n// TODO: name `this-pkg`\nexport * from \"../capabilities/index.js\";\nexport * from \"../capabilities/paymaster.js\";\nexport * from \"../capabilities/permissions/index.js\";\nexport * from \"../capabilities/permissions/mav2.js\";\nexport type * from \"../isomorphic/client.js\";\nexport { createIsomorphicClient } from \"../isomorphic/client.js\";\nexport { createDummySigner } from \"../isomorphic/utils/createDummySigner.js\";\nexport * from \"../rpc/request.js\";\nexport * as RpcSchemas from \"../rpc/request.js\";\nexport * from \"../rpc/schema.js\";\nexport * from \"../schemas.js\";\nexport type * from \"../types.ts\";\nexport * from \"../utils.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../src/internal/decorator.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,sBAAsB;IACpC,IAAI,OAAO,GAA8B,SAAS,CAAC;IAEnD,OAAO;QACL,UAAU,EAAE,CAAC,UAAyB,EAAE,EAAE;YACxC,OAAO,GAAG,UAAU,CAAC;QACvB,CAAC;QACD,UAAU,EAAE,GAAG,EAAE,CAAC,OAAO;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["import type { CachedAccount, InternalState } from \"../types.ts\";\n\nexport function internalStateDecorator(): InternalState {\n let account: CachedAccount | undefined = undefined;\n\n return {\n setAccount: (newAccount: CachedAccount) => {\n account = newAccount;\n },\n getAccount: () => account,\n };\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type SmartAccountClient, type SmartContractAccount } from "@aa-sdk/core";
|
|
2
|
-
import { type Chain, type Transport, type Hex } from "viem";
|
|
3
|
-
import type { wallet_createSession } from "../../rpc/request";
|
|
4
|
-
import type { WalletServerViemRpcSchema } from "../../rpc/schema";
|
|
5
2
|
import type { Static } from "@sinclair/typebox";
|
|
3
|
+
import { type Chain, type Hex, type Transport } from "viem";
|
|
4
|
+
import type { wallet_createSession } from "../../rpc/request.js";
|
|
5
|
+
import type { WalletServerViemRpcSchema } from "../../rpc/schema.js";
|
|
6
6
|
export type CreateSessionParams = Omit<Static<(typeof wallet_createSession)["properties"]["Request"]["properties"]["params"]>[0], "chainId"> & {
|
|
7
7
|
entityId?: Hex;
|
|
8
8
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createSmartAccountClient, } from "@aa-sdk/core";
|
|
2
|
-
import { ChainNotFoundError, custom, hexToNumber, toHex, } from "viem";
|
|
3
|
-
import { isGlobalValidation } from "../../capabilities/permissions/mav2";
|
|
4
2
|
import { deferralActions, PermissionBuilder, } from "@account-kit/smart-contracts/experimental";
|
|
5
|
-
import { createDummySigner } from "../utils/createDummySigner";
|
|
6
|
-
import { createAccount, isModularAccountV2 } from "../utils/createAccount";
|
|
7
3
|
import { Value } from "@sinclair/typebox/value";
|
|
8
|
-
import {
|
|
4
|
+
import { ChainNotFoundError, custom, hexToNumber, toHex, } from "viem";
|
|
5
|
+
import { TypePermission } from "../../capabilities/permissions/index.js";
|
|
6
|
+
import { isGlobalValidation } from "../../capabilities/permissions/mav2.js";
|
|
7
|
+
import { createAccount, isModularAccountV2 } from "../utils/createAccount.js";
|
|
8
|
+
import { createDummySigner } from "../utils/createDummySigner.js";
|
|
9
9
|
export async function createSession(client, params) {
|
|
10
10
|
if (!client.chain) {
|
|
11
11
|
throw new ChainNotFoundError();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAGzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,GAGzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,eAAe,EACf,iBAAiB,GAClB,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,WAAW,EACX,KAAK,GAIN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAG5E,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAoBlE,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAMC,EACD,MAA2B;IAE3B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,EAAE,kBAAkB,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClD,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE;YACN;gBACE,yBAAyB,EAAE,IAAI;gBAC/B,cAAc,EAA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AC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CACjD,KAAK,CAAC,MAAM,CAAC,cAAc,EAAE,UAAU,CAAC,CACzC;KACF,CAAC;SACD,eAAe,EAAE,CAAC;IAEvB,OAAO;QACL,SAAS,EAAE,IAAI,EAAE,kDAAkD;QACnE,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC;QACzB,gBAAgB,EAAE;YAChB,IAAI,EAAE,sBAAsB;YAC5B,IAAI,EAAE,SAAS;SAChB;QACD,oCAAoC;KACrC,CAAC;AACJ,CAAC","sourcesContent":["import {\n createSmartAccountClient,\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport {\n deferralActions,\n PermissionBuilder,\n} from \"@account-kit/smart-contracts/experimental\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport {\n ChainNotFoundError,\n custom,\n hexToNumber,\n toHex,\n type Chain,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { TypePermission } from \"../../capabilities/permissions/index.js\";\nimport { isGlobalValidation } from \"../../capabilities/permissions/mav2.js\";\nimport type { wallet_createSession } from \"../../rpc/request.js\";\nimport type { WalletServerViemRpcSchema } from \"../../rpc/schema.js\";\nimport { createAccount, isModularAccountV2 } from \"../utils/createAccount.js\";\nimport { createDummySigner } from \"../utils/createDummySigner.js\";\n\nexport type CreateSessionParams = Omit<\n Static<\n (typeof wallet_createSession)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"chainId\"\n> & {\n entityId?: Hex;\n};\n\nexport type CreateSessionResult = Omit<\n Static<(typeof wallet_createSession)[\"properties\"][\"ReturnType\"]>,\n \"sessionId\"\n> & {\n sessionId: Hex | null;\n entityId: Hex;\n fullPreSignatureDeferredActionDigest: Hex;\n};\n\nexport async function createSession(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: CreateSessionParams,\n): Promise<CreateSessionResult> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const { counterfactualInfo } = await client.request({\n method: \"wallet_requestAccount\",\n params: [\n {\n includeCounterfactualInfo: true,\n accountAddress: params.account,\n },\n ],\n });\n if (!counterfactualInfo) {\n throw new Error(\"No counterfactual info found.\");\n }\n\n const account = await createAccount({\n chain: client.chain,\n transport: custom(client.transport),\n signer: createDummySigner(params.account),\n accountAddress: params.account,\n counterfactualInfo,\n });\n\n if (!isModularAccountV2(account)) {\n throw new Error(\"Sessions are currently only supported by MAv2 accounts.\");\n }\n\n const _client = createSmartAccountClient({\n chain: client.chain,\n transport: custom(client.transport),\n account,\n }).extend(deferralActions);\n\n const { entityId, nonce } = await _client.getEntityIdAndNonce({\n entityId: params.entityId ? hexToNumber(params.entityId) : undefined,\n isGlobalValidation: isGlobalValidation(params),\n });\n\n const { typedData, fullPreSignatureDeferredActionDigest } =\n await new PermissionBuilder({\n client: _client,\n key: params.key,\n entityId,\n nonce,\n deadline: params.expiry,\n })\n .addPermissions({\n permissions: params.permissions.map((permission) =>\n Value.Encode(TypePermission, permission),\n ),\n })\n .compileDeferred();\n\n return {\n sessionId: null, // In remote mode, the server will set this later.\n entityId: toHex(entityId),\n signatureRequest: {\n type: \"eth_signTypedData_v4\",\n data: typedData,\n },\n fullPreSignatureDeferredActionDigest,\n };\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type SmartAccountClient, type SmartContractAccount } from "@aa-sdk/core";
|
|
2
2
|
import type { Static } from "@sinclair/typebox";
|
|
3
3
|
import { type Chain, type Transport } from "viem";
|
|
4
|
-
import type { wallet_getCallsStatus } from "../../rpc/request";
|
|
5
|
-
import type { WalletServerViemRpcSchema } from "../../rpc/schema";
|
|
4
|
+
import type { wallet_getCallsStatus } from "../../rpc/request.js";
|
|
5
|
+
import type { WalletServerViemRpcSchema } from "../../rpc/schema.js";
|
|
6
6
|
export type GetCallsStatusParams = Static<(typeof wallet_getCallsStatus)["properties"]["Request"]["properties"]["params"]>[0];
|
|
7
7
|
export type GetCallsStatusResponse = Static<(typeof wallet_getCallsStatus)["properties"]["ReturnType"]>;
|
|
8
8
|
/** EIP-5792 call status codes */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {} from "@aa-sdk/core";
|
|
2
|
-
import { ChainNotFoundError, isHex, } from "viem";
|
|
3
|
-
import { TypeCallId } from "../../schemas";
|
|
4
|
-
import { castToHex } from "../../utils";
|
|
5
2
|
import { Value } from "@sinclair/typebox/value";
|
|
3
|
+
import { ChainNotFoundError, isHex, } from "viem";
|
|
4
|
+
import { TypeCallId } from "../../schemas.js";
|
|
5
|
+
import { castToHex } from "../../utils.js";
|
|
6
6
|
const ReceiptStatus = {
|
|
7
7
|
reverted: "0x0",
|
|
8
8
|
success: "0x1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/getCallsStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,MAAM,cAAc,CAAC;AAEtB,OAAO,
|
|
1
|
+
{"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/getCallsStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EACL,kBAAkB,EAClB,KAAK,GAKN,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAU3C,MAAM,aAAa,GAA8C;IAC/D,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,KAAK;CACf,CAAC;AAEF,iCAAiC;AACjC,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,oFAAoF;IACpF,OAAO,EAAE,GAAG;IACZ,iGAAi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AC3C,2FAA2F;QAC3F,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC;QACnC,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC/B,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,MAAM,EAAE,GAAG,CAAC,MAAM;SACnB,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC","sourcesContent":["import {\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport {\n ChainNotFoundError,\n isHex,\n type Chain,\n type Hex,\n type TransactionReceipt,\n type Transport,\n} from \"viem\";\nimport type { wallet_getCallsStatus } from \"../../rpc/request.js\";\nimport type { WalletServerViemRpcSchema } from \"../../rpc/schema.js\";\nimport { TypeCallId } from \"../../schemas.js\";\nimport { castToHex } from \"../../utils.js\";\n\nexport type GetCallsStatusParams = Static<\n (typeof wallet_getCallsStatus)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n>[0];\n\nexport type GetCallsStatusResponse = Static<\n (typeof wallet_getCallsStatus)[\"properties\"][\"ReturnType\"]\n>;\n\nconst ReceiptStatus: Record<TransactionReceipt[\"status\"], Hex> = {\n reverted: \"0x0\",\n success: \"0x1\",\n};\n\n/** EIP-5792 call status codes */\nexport const CallStatusCode = {\n /** Batch has been received by the wallet but has not completed execution onchain */\n PENDING: 100,\n /** Batch has been included onchain without reverts, receipts array contains info of all calls */\n CONFIRMED: 200,\n /** Batch has not been included onchain and wallet will not retry */\n OFFCHAIN_FAILURE: 400,\n /** Batch reverted *completely* and only changes related to gas charge may have been included onchain */\n CHAIN_RULES_FAILURE: 500,\n /** Batch reverted *partially* and some changes related to batch calls may have been included onchain */\n PARTIAL_CHAIN_RULES_FAILURE: 600,\n} as const;\n\nexport async function getCallsStatus(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n callId: GetCallsStatusParams,\n): Promise<GetCallsStatusResponse> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const { chainId, hash } = Value.Decode(TypeCallId, callId);\n\n const result = await client.getUserOperationReceipt(hash);\n\n return {\n id: callId,\n chainId,\n atomic: true,\n status: !result?.receipt\n ? CallStatusCode.PENDING\n : result.success\n ? CallStatusCode.CONFIRMED\n : CallStatusCode.CHAIN_RULES_FAILURE,\n receipts: !result?.receipt ? undefined : [transformReceipt(result.receipt)],\n };\n}\n\nfunction transformReceipt(\n receipt: TransactionReceipt,\n): NonNullable<GetCallsStatusResponse[\"receipts\"]>[number] {\n return {\n // viem's type for status is \"success\" | \"reverted\", but the actual value seems to already be 0x0 or 0x1\n status: isHex(receipt.status)\n ? receipt.status\n : ReceiptStatus[receipt.status],\n blockHash: receipt.blockHash,\n // viem's type for blockNumber is bigint, but the actual value seems to already be a hex string\n blockNumber: castToHex(receipt.blockNumber),\n // viem's type for gasUsed is bigint, but the actual value seems to already be a hex string\n gasUsed: castToHex(receipt.gasUsed),\n transactionHash: receipt.transactionHash,\n logs: receipt.logs.map((log) => ({\n address: log.address,\n data: log.data,\n topics: log.topics,\n })),\n };\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type SmartAccountClient, type SmartContractAccount } from "@aa-sdk/core";
|
|
2
2
|
import type { Static } from "@sinclair/typebox";
|
|
3
3
|
import { type Chain, type Transport } from "viem";
|
|
4
|
-
import type { wallet_prepareCalls } from "../../rpc/request";
|
|
5
|
-
import type { WalletServerViemRpcSchema } from "../../rpc/schema";
|
|
4
|
+
import type { wallet_prepareCalls } from "../../rpc/request.js";
|
|
5
|
+
import type { WalletServerViemRpcSchema } from "../../rpc/schema.js";
|
|
6
6
|
export type PrepareCallsParams = Omit<Static<(typeof wallet_prepareCalls)["properties"]["Request"]["properties"]["params"]>[0], "chainId">;
|
|
7
7
|
export type PrepareCallsResult = Static<(typeof wallet_prepareCalls)["properties"]["ReturnType"]>;
|
|
8
8
|
export declare function prepareCalls(client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>, params: PrepareCallsParams): Promise<PrepareCallsResult>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { deepHexlify, } from "@aa-sdk/core";
|
|
2
2
|
import { ChainNotFoundError, custom, fromHex, toHex, zeroAddress, } from "viem";
|
|
3
|
-
import { createAccount } from "../utils/createAccount";
|
|
4
|
-
import { createDummySigner } from "../utils/createDummySigner";
|
|
3
|
+
import { createAccount } from "../utils/createAccount.js";
|
|
4
|
+
import { createDummySigner } from "../utils/createDummySigner.js";
|
|
5
5
|
// TODO: handle capabilities like permissions and paymaster here
|
|
6
6
|
export async function prepareCalls(client, params) {
|
|
7
7
|
if (!client.chain) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GAGZ,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,OAAO,EACP,KAAK,EACL,WAAW,GAGZ,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GAGZ,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,OAAO,EACP,KAAK,EACL,WAAW,GAGZ,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE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AO;QACP,SAAS,EAAE,MAAM,CAAC,YAAY,EAAE,iBAAiB;KAClD,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAEvC,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAErE,OAAO;QACL,IAAI,EACF,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,KAAK,OAAO;YACzC,CAAC,CAAC,qBAAqB;YACvB,CAAC,CAAC,qBAAqB;QAC3B,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,gBAAgB,EAAE;YAChB,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE;gBACJ,GAAG,EAAE,IAAI;aACV;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n deepHexlify,\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport {\n ChainNotFoundError,\n custom,\n fromHex,\n toHex,\n zeroAddress,\n type Chain,\n type Transport,\n} from \"viem\";\nimport type { wallet_prepareCalls } from \"../../rpc/request.js\";\nimport type { WalletServerViemRpcSchema } from \"../../rpc/schema.js\";\nimport { createAccount } from \"../utils/createAccount.js\";\nimport { createDummySigner } from \"../utils/createDummySigner.js\";\n\nexport type PrepareCallsParams = Omit<\n Static<\n (typeof wallet_prepareCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"chainId\"\n>;\n\nexport type PrepareCallsResult = Static<\n (typeof wallet_prepareCalls)[\"properties\"][\"ReturnType\"]\n>;\n\n// TODO: handle capabilities like permissions and paymaster here\nexport async function prepareCalls(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: PrepareCallsParams,\n): Promise<PrepareCallsResult> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n // in local mode, we probably want some kind of caching for this\n const { counterfactualInfo } = await client.request({\n method: \"wallet_requestAccount\",\n params: [\n {\n accountAddress: params.from,\n includeCounterfactualInfo: true,\n },\n ],\n });\n if (!counterfactualInfo) {\n throw new Error(\"No counterfactual info found.\");\n }\n\n const account = await createAccount({\n chain: client.chain,\n transport: custom(client.transport),\n signer: createDummySigner(zeroAddress),\n accountAddress: params.from,\n counterfactualInfo,\n capabilities: params.capabilities,\n });\n\n // TODO: oops we don't actually support setting the policyId as an override here\n // if we assume that the the isomorphic client is never used directly, then we can assume that this is handled upstream correctly\n const builtUo = await client.buildUserOperation({\n uo: params.calls.map((x) => ({\n target: x.to,\n data: x.data ?? \"0x\",\n value: x.value ? fromHex(x.value, \"bigint\") : undefined,\n })),\n account,\n overrides: params.capabilities?.gasParamsOverride,\n });\n\n const uoRequest = deepHexlify(builtUo);\n\n const hash = account.getEntryPoint().getUserOperationHash(uoRequest);\n\n return {\n type:\n account.getEntryPoint().version === \"0.7.0\"\n ? \"user-operation-v070\"\n : \"user-operation-v060\",\n data: uoRequest,\n chainId: toHex(client.chain.id),\n signatureRequest: {\n type: \"personal_sign\",\n data: {\n raw: hash,\n },\n },\n };\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type SmartAccountClient, type SmartContractAccount } from "@aa-sdk/core";
|
|
2
2
|
import type { Static, StaticDecode } from "@sinclair/typebox";
|
|
3
3
|
import { type Chain, type Transport } from "viem";
|
|
4
|
-
import type { wallet_sendPreparedCalls } from "../../rpc/request";
|
|
5
|
-
import type { WalletServerViemRpcSchema } from "../../rpc/schema";
|
|
4
|
+
import type { wallet_sendPreparedCalls } from "../../rpc/request.js";
|
|
5
|
+
import type { WalletServerViemRpcSchema } from "../../rpc/schema.js";
|
|
6
6
|
export type SendPreparedCallsParams = Omit<StaticDecode<(typeof wallet_sendPreparedCalls)["properties"]["Request"]["properties"]["params"]>[0], "chainId">;
|
|
7
7
|
export type SendPreparedCallsResult = Static<(typeof wallet_sendPreparedCalls)["properties"]["ReturnType"]>;
|
|
8
8
|
export declare function sendPreparedCalls(client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>, params: SendPreparedCallsParams): Promise<SendPreparedCallsResult>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getEntryPoint, } from "@aa-sdk/core";
|
|
2
2
|
import { Value } from "@sinclair/typebox/value";
|
|
3
3
|
import { ChainNotFoundError, concat, concatHex, toHex, } from "viem";
|
|
4
|
-
import { decodePermissionsContext } from "../../capabilities/permissions/mav2";
|
|
5
|
-
import { TypeCallId } from "../../schemas";
|
|
4
|
+
import { decodePermissionsContext } from "../../capabilities/permissions/mav2.js";
|
|
5
|
+
import { TypeCallId } from "../../schemas.js";
|
|
6
6
|
// TODO: this only supports MAv2 right now, we need to fix this
|
|
7
7
|
export async function sendPreparedCalls(client, params) {
|
|
8
8
|
if (!client.chain) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GAGd,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,KAAK,GAIN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,wBAAwB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GAGd,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,KAA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S,CAAC,SAAS;aAC3B,CAAC;YACJ,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;KAC3D,EACD,UAAU,CAAC,OAAO,CACnB,CAAC;IAEF,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE;QACtC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,IAAI;KACL,CAAC,CAAC;IAEH,OAAO;QACL,eAAe,EAAE,CAAC,MAAM,CAAC;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["import {\n getEntryPoint,\n type SmartAccountClient,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Static, StaticDecode } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport {\n ChainNotFoundError,\n concat,\n concatHex,\n toHex,\n type Chain,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { decodePermissionsContext } from \"../../capabilities/permissions/mav2.js\";\nimport type { wallet_sendPreparedCalls } from \"../../rpc/request.js\";\nimport type { WalletServerViemRpcSchema } from \"../../rpc/schema.js\";\nimport { TypeCallId } from \"../../schemas.js\";\n\nexport type SendPreparedCallsParams = Omit<\n StaticDecode<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"chainId\"\n>;\n\nexport type SendPreparedCallsResult = Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"ReturnType\"]\n>;\n\n// TODO: this only supports MAv2 right now, we need to fix this\nexport async function sendPreparedCalls(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: SendPreparedCallsParams,\n): Promise<SendPreparedCallsResult> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const deferredAction: Hex | undefined = (() => {\n if (!params.capabilities?.permissions?.context) {\n return;\n }\n\n const decodedContext = decodePermissionsContext(\n params.capabilities.permissions.context,\n );\n\n if (decodedContext.contextVersion === \"REMOTE_MODE_DEFERRED_ACTION\") {\n throw new Error(\n \"Remote mode deferred action not supported in isomorphic client\",\n );\n }\n\n return decodedContext.deferredAction;\n })();\n\n const entryPoint =\n params.type === \"user-operation-v060\"\n ? getEntryPoint(client.chain, { version: \"0.6.0\" })\n : getEntryPoint(client.chain, { version: \"0.7.0\" });\n\n const hash = await client.sendRawUserOperation(\n {\n ...params.data,\n signature:\n deferredAction != null\n ? concatHex([\n `0x${deferredAction.slice(68)}`, // Cuts off stuff preprended to the digest (nonce, etc. that we had previously).\n \"0xff\",\n \"0x00\",\n params.signature.signature,\n ])\n : concat([\"0xFF\", \"0x00\", params.signature.signature]),\n },\n entryPoint.address,\n );\n\n const callId = Value.Encode(TypeCallId, {\n chainId: toHex(client.chain.id),\n hash,\n });\n\n return {\n preparedCallIds: [callId],\n };\n}\n"]}
|