@account-kit/wallet-client 0.1.0-alpha.1 → 0.1.0-alpha.11
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/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/formatSign.d.ts +28 -0
- package/dist/esm/client/actions/formatSign.js +30 -0
- package/dist/esm/client/actions/formatSign.js.map +1 -0
- package/dist/esm/client/actions/getCallsStatus.d.ts +22 -4
- package/dist/esm/client/actions/getCallsStatus.js +19 -0
- package/dist/esm/client/actions/getCallsStatus.js.map +1 -1
- package/dist/esm/client/actions/grantPermissions.d.ts +63 -6
- package/dist/esm/client/actions/grantPermissions.js +63 -3
- package/dist/esm/client/actions/grantPermissions.js.map +1 -1
- package/dist/esm/client/actions/listAccounts.d.ts +32 -4
- package/dist/esm/client/actions/listAccounts.js +35 -2
- package/dist/esm/client/actions/listAccounts.js.map +1 -1
- package/dist/esm/client/actions/prepareCalls.d.ts +32 -6
- package/dist/esm/client/actions/prepareCalls.js +39 -5
- package/dist/esm/client/actions/prepareCalls.js.map +1 -1
- package/dist/esm/client/actions/prepareSign.d.ts +25 -0
- package/dist/esm/client/actions/prepareSign.js +28 -0
- package/dist/esm/client/actions/prepareSign.js.map +1 -0
- package/dist/esm/client/actions/requestAccount.d.ts +24 -6
- package/dist/esm/client/actions/requestAccount.js +38 -7
- package/dist/esm/client/actions/requestAccount.js.map +1 -1
- package/dist/esm/client/actions/sendPreparedCalls.d.ts +33 -4
- package/dist/esm/client/actions/sendPreparedCalls.js +37 -1
- package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/client/actions/signMessage.d.ts +25 -5
- package/dist/esm/client/actions/signMessage.js +22 -2
- package/dist/esm/client/actions/signMessage.js.map +1 -1
- package/dist/esm/client/actions/signPreparedCalls.d.ts +14 -0
- package/dist/esm/client/actions/signPreparedCalls.js +43 -0
- package/dist/esm/client/actions/signPreparedCalls.js.map +1 -0
- package/dist/esm/client/actions/signSignatureRequest.d.ts +39 -5
- package/dist/esm/client/actions/signSignatureRequest.js +69 -11
- package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
- package/dist/esm/client/actions/signTypedData.d.ts +37 -4
- package/dist/esm/client/actions/signTypedData.js +34 -1
- package/dist/esm/client/actions/signTypedData.js.map +1 -1
- package/dist/esm/client/client.e2e-test.js +249 -45
- package/dist/esm/client/client.e2e-test.js.map +1 -1
- package/dist/esm/client/decorator.d.ts +12 -8
- package/dist/esm/client/decorator.js +5 -3
- package/dist/esm/client/decorator.js.map +1 -1
- package/dist/esm/client/index.d.ts +38 -12
- package/dist/esm/client/index.js +0 -3
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/exports/index.d.ts +5 -6
- package/dist/esm/exports/index.js +4 -6
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/internal.d.ts +1 -10
- package/dist/esm/exports/internal.js +0 -12
- 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 +1 -2
- package/dist/esm/isomorphic/actions/createSession.js +40 -11
- package/dist/esm/isomorphic/actions/createSession.js.map +1 -1
- package/dist/esm/isomorphic/actions/formatSign.d.ts +8 -0
- package/dist/esm/isomorphic/actions/formatSign.js +42 -0
- package/dist/esm/isomorphic/actions/formatSign.js.map +1 -0
- package/dist/esm/isomorphic/actions/getCallsStatus.d.ts +1 -15
- package/dist/esm/isomorphic/actions/getCallsStatus.js +38 -27
- package/dist/esm/isomorphic/actions/getCallsStatus.js.map +1 -1
- package/dist/esm/isomorphic/actions/prepareCalls.d.ts +1 -2
- package/dist/esm/isomorphic/actions/prepareCalls.js +78 -20
- package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -1
- package/dist/esm/isomorphic/actions/prepareSign.d.ts +7 -0
- package/dist/esm/isomorphic/actions/prepareSign.js +49 -0
- package/dist/esm/isomorphic/actions/prepareSign.js.map +1 -0
- package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +3 -4
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js +165 -25
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/isomorphic/client.d.ts +204 -27
- package/dist/esm/isomorphic/client.js +6 -2
- package/dist/esm/isomorphic/client.js.map +1 -1
- package/dist/esm/isomorphic/utils/7702.d.ts +19 -0
- package/dist/esm/isomorphic/utils/7702.js +70 -0
- package/dist/esm/isomorphic/utils/7702.js.map +1 -0
- package/dist/esm/isomorphic/utils/createAccount.d.ts +5 -4
- package/dist/esm/isomorphic/utils/createAccount.js +84 -10
- package/dist/esm/isomorphic/utils/createAccount.js.map +1 -1
- package/dist/esm/isomorphic/utils/createDummySigner.js +3 -3
- package/dist/esm/isomorphic/utils/createDummySigner.js.map +1 -1
- package/dist/esm/isomorphic/utils/decodeSignature.d.ts +3 -0
- package/dist/esm/isomorphic/utils/decodeSignature.js +15 -0
- package/dist/esm/isomorphic/utils/decodeSignature.js.map +1 -0
- package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +6 -5
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js +19 -6
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +1 -1
- package/dist/esm/isomorphic/utils/supportsFeature.d.ts +4 -0
- package/dist/esm/isomorphic/utils/supportsFeature.js +21 -0
- package/dist/esm/isomorphic/utils/supportsFeature.js.map +1 -0
- package/dist/esm/local/client.d.ts +3 -3
- package/dist/esm/local/client.js +11 -4
- package/dist/esm/local/client.js.map +1 -1
- package/dist/esm/remote/client.d.ts +9 -3
- package/dist/esm/remote/client.js +10 -11
- package/dist/esm/remote/client.js.map +1 -1
- package/dist/esm/types.d.ts +27 -13
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils.d.ts +1 -0
- package/dist/esm/utils.js.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/formatSign.d.ts +29 -0
- package/dist/types/client/actions/formatSign.d.ts.map +1 -0
- package/dist/types/client/actions/getCallsStatus.d.ts +22 -4
- package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
- package/dist/types/client/actions/grantPermissions.d.ts +63 -6
- package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
- package/dist/types/client/actions/listAccounts.d.ts +32 -4
- package/dist/types/client/actions/listAccounts.d.ts.map +1 -1
- package/dist/types/client/actions/prepareCalls.d.ts +32 -6
- package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/client/actions/prepareSign.d.ts +26 -0
- package/dist/types/client/actions/prepareSign.d.ts.map +1 -0
- package/dist/types/client/actions/requestAccount.d.ts +24 -6
- package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
- package/dist/types/client/actions/sendPreparedCalls.d.ts +33 -4
- package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/client/actions/signMessage.d.ts +25 -5
- package/dist/types/client/actions/signMessage.d.ts.map +1 -1
- package/dist/types/client/actions/signPreparedCalls.d.ts +15 -0
- package/dist/types/client/actions/signPreparedCalls.d.ts.map +1 -0
- package/dist/types/client/actions/signSignatureRequest.d.ts +39 -5
- package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
- package/dist/types/client/actions/signTypedData.d.ts +37 -4
- package/dist/types/client/actions/signTypedData.d.ts.map +1 -1
- package/dist/types/client/decorator.d.ts +12 -8
- package/dist/types/client/decorator.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +38 -12
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +5 -6
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/exports/internal.d.ts +1 -10
- 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 +1 -2
- package/dist/types/isomorphic/actions/createSession.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/formatSign.d.ts +9 -0
- package/dist/types/isomorphic/actions/formatSign.d.ts.map +1 -0
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts +1 -15
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/prepareCalls.d.ts +1 -2
- package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/prepareSign.d.ts +8 -0
- package/dist/types/isomorphic/actions/prepareSign.d.ts.map +1 -0
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +3 -4
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/isomorphic/client.d.ts +204 -27
- package/dist/types/isomorphic/client.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/7702.d.ts +20 -0
- package/dist/types/isomorphic/utils/7702.d.ts.map +1 -0
- package/dist/types/isomorphic/utils/createAccount.d.ts +5 -4
- package/dist/types/isomorphic/utils/createAccount.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/createDummySigner.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/decodeSignature.d.ts +4 -0
- package/dist/types/isomorphic/utils/decodeSignature.d.ts.map +1 -0
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +6 -5
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/supportsFeature.d.ts +5 -0
- package/dist/types/isomorphic/utils/supportsFeature.d.ts.map +1 -0
- package/dist/types/local/client.d.ts +3 -3
- package/dist/types/local/client.d.ts.map +1 -1
- package/dist/types/remote/client.d.ts +9 -3
- package/dist/types/remote/client.d.ts.map +1 -1
- package/dist/types/types.d.ts +27 -13
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +1 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +9 -6
- package/src/client/actions/createAccount.ts +27 -2
- package/src/client/actions/formatSign.ts +53 -0
- package/src/client/actions/getCallsStatus.ts +21 -12
- package/src/client/actions/grantPermissions.ts +69 -26
- package/src/client/actions/listAccounts.ts +44 -6
- package/src/client/actions/prepareCalls.ts +46 -26
- package/src/client/actions/prepareSign.ts +46 -0
- package/src/client/actions/requestAccount.ts +60 -41
- package/src/client/actions/sendPreparedCalls.ts +44 -7
- package/src/client/actions/signMessage.ts +26 -21
- package/src/client/actions/signPreparedCalls.ts +67 -0
- package/src/client/actions/signSignatureRequest.ts +84 -20
- package/src/client/actions/signTypedData.ts +40 -19
- package/src/client/client.e2e-test.ts +408 -127
- package/src/client/decorator.ts +28 -26
- package/src/client/index.ts +50 -40
- package/src/exports/index.ts +5 -13
- package/src/exports/internal.ts +2 -10
- package/src/internal/decorator.ts +12 -0
- package/src/isomorphic/actions/createSession.ts +56 -13
- package/src/isomorphic/actions/formatSign.ts +76 -0
- package/src/isomorphic/actions/getCallsStatus.ts +47 -33
- package/src/isomorphic/actions/prepareCalls.ts +95 -23
- package/src/isomorphic/actions/prepareSign.ts +88 -0
- package/src/isomorphic/actions/sendPreparedCalls.ts +218 -42
- package/src/isomorphic/client.ts +10 -2
- package/src/isomorphic/utils/7702.ts +135 -0
- package/src/isomorphic/utils/createAccount.ts +101 -13
- package/src/isomorphic/utils/createDummySigner.ts +3 -2
- package/src/isomorphic/utils/decodeSignature.ts +21 -0
- package/src/isomorphic/utils/parsePermissionsContext.ts +29 -11
- package/src/isomorphic/utils/supportsFeature.ts +34 -0
- package/src/local/client.ts +58 -55
- package/src/remote/client.ts +19 -19
- package/src/types.ts +29 -23
- package/src/utils.ts +2 -0
- package/dist/esm/capabilities/index.d.ts +0 -31
- package/dist/esm/capabilities/index.js +0 -10
- package/dist/esm/capabilities/index.js.map +0 -1
- package/dist/esm/capabilities/overrides.d.ts +0 -26
- package/dist/esm/capabilities/overrides.js +0 -14
- package/dist/esm/capabilities/overrides.js.map +0 -1
- package/dist/esm/capabilities/paymaster.d.ts +0 -3
- package/dist/esm/capabilities/paymaster.js +0 -5
- package/dist/esm/capabilities/paymaster.js.map +0 -1
- package/dist/esm/capabilities/permissions/index.d.ts +0 -138
- package/dist/esm/capabilities/permissions/index.js +0 -71
- package/dist/esm/capabilities/permissions/index.js.map +0 -1
- package/dist/esm/capabilities/permissions/mav2.d.ts +0 -36
- package/dist/esm/capabilities/permissions/mav2.js +0 -79
- package/dist/esm/capabilities/permissions/mav2.js.map +0 -1
- package/dist/esm/rpc/request.d.ts +0 -352
- package/dist/esm/rpc/request.js +0 -204
- package/dist/esm/rpc/request.js.map +0 -1
- package/dist/esm/rpc/schema.d.ts +0 -342
- package/dist/esm/rpc/schema.js +0 -5
- package/dist/esm/rpc/schema.js.map +0 -1
- package/dist/esm/schemas.d.ts +0 -216
- package/dist/esm/schemas.js +0 -211
- package/dist/esm/schemas.js.map +0 -1
- package/dist/types/capabilities/index.d.ts +0 -32
- package/dist/types/capabilities/index.d.ts.map +0 -1
- package/dist/types/capabilities/overrides.d.ts +0 -27
- package/dist/types/capabilities/overrides.d.ts.map +0 -1
- package/dist/types/capabilities/paymaster.d.ts +0 -4
- package/dist/types/capabilities/paymaster.d.ts.map +0 -1
- package/dist/types/capabilities/permissions/index.d.ts +0 -139
- package/dist/types/capabilities/permissions/index.d.ts.map +0 -1
- package/dist/types/capabilities/permissions/mav2.d.ts +0 -37
- package/dist/types/capabilities/permissions/mav2.d.ts.map +0 -1
- package/dist/types/rpc/request.d.ts +0 -353
- package/dist/types/rpc/request.d.ts.map +0 -1
- package/dist/types/rpc/schema.d.ts +0 -343
- package/dist/types/rpc/schema.d.ts.map +0 -1
- package/dist/types/schemas.d.ts +0 -217
- package/dist/types/schemas.d.ts.map +0 -1
- package/src/capabilities/index.ts +0 -13
- package/src/capabilities/overrides.ts +0 -20
- package/src/capabilities/paymaster.ts +0 -5
- package/src/capabilities/permissions/index.ts +0 -142
- package/src/capabilities/permissions/mav2.ts +0 -127
- package/src/rpc/request.ts +0 -273
- package/src/rpc/schema.ts +0 -40
- package/src/schemas.ts +0 -257
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { StaticDecode } from "@sinclair/typebox";
|
|
2
|
+
import type { SerializedInitcode } from "@alchemy/wallet-api-types";
|
|
3
|
+
export type Feature = "permissions";
|
|
4
|
+
export declare function supportsFeature(counterfactualInfo: StaticDecode<typeof SerializedInitcode>, feature: Feature): boolean;
|
|
5
|
+
//# sourceMappingURL=supportsFeature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supportsFeature.d.ts","sourceRoot":"","sources":["../../../../src/isomorphic/utils/supportsFeature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,MAAM,MAAM,OAAO,GAAG,aAAa,CAAC;AAkBpC,wBAAgB,eAAe,CAC7B,kBAAkB,EAAE,YAAY,CAAC,OAAO,kBAAkB,CAAC,EAC3D,OAAO,EAAE,OAAO,GACf,OAAO,CAST"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Address
|
|
2
|
-
import type { CreateInnerClientParams, InnerWalletApiClient } from "../types";
|
|
3
|
-
export declare function createLocalClient<TAccount extends
|
|
1
|
+
import { type Address } from "viem";
|
|
2
|
+
import type { CreateInnerClientParams, InnerWalletApiClient } from "../types.ts";
|
|
3
|
+
export declare function createLocalClient<TAccount extends Address | undefined = Address | undefined>(params: CreateInnerClientParams<TAccount>): InnerWalletApiClient;
|
|
4
4
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/local/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,KAAK,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/local/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAY1D,OAAO,KAAK,EACV,uBAAuB,EAEvB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAWrB,wBAAgB,iBAAiB,CAC/B,QAAQ,SAAS,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,EAC1D,MAAM,EAAE,uBAAuB,CAAC,QAAQ,CAAC,GAAG,oBAAoB,CAAC"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import { type Address
|
|
2
|
-
import type { CreateInnerClientParams, InnerWalletApiClient } from "../types";
|
|
3
|
-
|
|
1
|
+
import { type Address } from "viem";
|
|
2
|
+
import type { CreateInnerClientParams, InnerWalletApiClient } from "../types.ts";
|
|
3
|
+
/**
|
|
4
|
+
* This is a low-level client just used to make RPC requests in remote mode
|
|
5
|
+
* This should be wrapped by a higher-level smart account client that provides actions
|
|
6
|
+
* that uses this client under the hood
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function createRemoteClient<TAccount extends Address | undefined = Address | undefined>(params: CreateInnerClientParams<TAccount>): InnerWalletApiClient;
|
|
4
10
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/remote/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/remote/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAK1D,OAAO,KAAK,EACV,uBAAuB,EAEvB,oBAAoB,EAErB,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,SAAS,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,EAC1D,MAAM,EAAE,uBAAuB,CAAC,QAAQ,CAAC,GAAG,oBAAoB,CAAC"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
+
import type { SmartAccountSigner, SmartContractAccount } from "@aa-sdk/core";
|
|
1
2
|
import type { AlchemyTransport } from "@account-kit/infra";
|
|
2
|
-
import type { Address, Chain, Client, Hex,
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
export type CreateInnerClientParams<TAccount extends
|
|
3
|
+
import type { Address, Chain, Client, Hex, JsonRpcAccount, Transport } from "viem";
|
|
4
|
+
import type { GrantPermissionsParams, GrantPermissionsResult } from "./client/actions/grantPermissions.ts";
|
|
5
|
+
import type { RequestAccountParams } from "./client/actions/requestAccount.ts";
|
|
6
|
+
import type { WalletServerViemRpcSchema } from "@alchemy/wallet-api-types/rpc";
|
|
7
|
+
export type CreateInnerClientParams<TAccount extends Address | undefined = Address | undefined> = {
|
|
7
8
|
chain: Chain;
|
|
8
9
|
transport: AlchemyTransport;
|
|
9
10
|
policyId?: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
account: Address;
|
|
14
|
-
});
|
|
15
|
-
export type InnerWalletApiClientBase<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined, TExtend extends {
|
|
11
|
+
account?: TAccount | Address | undefined;
|
|
12
|
+
};
|
|
13
|
+
export type InnerWalletApiClientBase<TExtend extends {
|
|
16
14
|
[key: string]: unknown;
|
|
17
15
|
} | undefined = {
|
|
18
16
|
[key: string]: unknown;
|
|
19
|
-
} | undefined> = Client<Transport, Chain,
|
|
17
|
+
} | undefined> = Client<Transport, Chain, JsonRpcAccount<Address> | undefined, WalletServerViemRpcSchema, {
|
|
20
18
|
policyId?: string;
|
|
21
19
|
} & TExtend>;
|
|
22
20
|
export type InnerClientActions = {
|
|
@@ -24,5 +22,21 @@ export type InnerClientActions = {
|
|
|
24
22
|
chainId: Hex;
|
|
25
23
|
}) => Promise<GrantPermissionsResult>;
|
|
26
24
|
};
|
|
27
|
-
export type
|
|
25
|
+
export type CachedAccount = {
|
|
26
|
+
account: SmartContractAccount;
|
|
27
|
+
requestParams: RequestAccountParams;
|
|
28
|
+
};
|
|
29
|
+
export type InternalState = {
|
|
30
|
+
setAccount: (account: CachedAccount) => void;
|
|
31
|
+
getAccount: () => CachedAccount | undefined;
|
|
32
|
+
};
|
|
33
|
+
export type InnerWalletApiClient = InnerWalletApiClientBase<InnerClientActions & {
|
|
34
|
+
internal: InternalState;
|
|
35
|
+
}>;
|
|
36
|
+
export type WithoutChainId<T> = T extends {
|
|
37
|
+
chainId: Hex;
|
|
38
|
+
} ? Omit<T, "chainId"> : T;
|
|
39
|
+
export type WithoutRawPayload<T> = T extends {
|
|
40
|
+
rawPayload: Hex;
|
|
41
|
+
} ? Omit<T, "rawPayload"> : T;
|
|
28
42
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EACL,MAAM,EACN,GAAG,EACH,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EACL,MAAM,EACN,GAAG,EACH,cAAc,EACd,SAAS,EACV,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE/E,MAAM,MAAM,uBAAuB,CACjC,QAAQ,SAAS,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,IACxD;IACF,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,gBAAgB,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,wBAAwB,CAClC,OAAO,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,GAAG,SAAS,GAClD;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,GAC1B,SAAS,IACX,MAAM,CACR,SAAS,EACT,KAAK,EACL,cAAc,CAAC,OAAO,CAAC,GAAG,SAAS,EACnC,yBAAyB,EACzB;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAChC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB,EAAE,CAChB,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,sBAAsB,GAAG;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,KAC9C,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,aAAa,EAAE,oBAAoB,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7C,UAAU,EAAE,MAAM,aAAa,GAAG,SAAS,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,wBAAwB,CACzD,kBAAkB,GAAG;IAAE,QAAQ,EAAE,aAAa,CAAA;CAAE,CACjD,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,OAAO,EAAE,GAAG,CAAA;CAAE,GACtD,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,GAClB,CAAC,CAAC;AAEN,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,UAAU,EAAE,GAAG,CAAA;CAAE,GAC5D,IAAI,CAAC,CAAC,EAAE,YAAY,CAAC,GACrB,CAAC,CAAC"}
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Hex } from "viem";
|
|
2
|
+
export type Expect<T extends true> = T;
|
|
2
3
|
export declare const assertNever: (_val: never, msg: string) => never;
|
|
3
4
|
/** If the value is already Hex, it is returned unchanged. If it's a string, number or bigint, it's converted. */
|
|
4
5
|
export declare const castToHex: (val: string | number | bigint | Hex) => Hex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAE9C,eAAO,MAAM,WAAW,GAAI,MAAM,KAAK,EAAE,KAAK,MAAM,KAAG,KAEtD,CAAC;AAEF,iHAAiH;AACjH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,GAAG,KAAG,GAK/D,CAAC"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAE9C,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;AAEvC,eAAO,MAAM,WAAW,GAAI,MAAM,KAAK,EAAE,KAAK,MAAM,KAAG,KAEtD,CAAC;AAEF,iHAAiH;AACjH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,GAAG,KAAG,GAK/D,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@account-kit/wallet-client",
|
|
3
3
|
"private": false,
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.1.0-alpha.
|
|
5
|
+
"version": "0.1.0-alpha.11",
|
|
6
6
|
"main": "./dist/esm/exports/index.js",
|
|
7
7
|
"module": "./dist/esm/exports/index.js",
|
|
8
8
|
"types": "./dist/types/exports/index.d.ts",
|
|
@@ -51,22 +51,25 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@repo/configs": "workspace:*",
|
|
54
|
+
"@types/deep-equal": "^1.0.4",
|
|
54
55
|
"eslint-plugin-import": "^2.31.0"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
57
58
|
"typescript": "^5.8.2"
|
|
58
59
|
},
|
|
59
60
|
"dependencies": {
|
|
60
|
-
"@aa-sdk/core": "^4.
|
|
61
|
-
"@account-kit/infra": "^4.
|
|
62
|
-
"@account-kit/smart-contracts": "^4.
|
|
61
|
+
"@aa-sdk/core": "^4.43.1",
|
|
62
|
+
"@account-kit/infra": "^4.43.1",
|
|
63
|
+
"@account-kit/smart-contracts": "^4.43.1",
|
|
64
|
+
"@alchemy/wallet-api-types": "0.1.0-alpha.11",
|
|
63
65
|
"@sinclair/typebox": "^0.34.33",
|
|
66
|
+
"deep-equal": "^2.2.3",
|
|
64
67
|
"ox": "^0.6.12",
|
|
65
|
-
"viem": "
|
|
68
|
+
"viem": "2.29.2"
|
|
66
69
|
},
|
|
67
70
|
"publishConfig": {
|
|
68
71
|
"access": "public",
|
|
69
72
|
"registry": "https://registry.npmjs.org/"
|
|
70
73
|
},
|
|
71
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "62b331ec0e6d8d1d15f36920fa2ca07b266554d1"
|
|
72
75
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import type { Static } from "@sinclair/typebox";
|
|
3
3
|
import type { Address } from "abitype";
|
|
4
|
-
import type { wallet_createAccount } from "
|
|
5
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
4
|
+
import type { wallet_createAccount } from "@alchemy/wallet-api-types/rpc";
|
|
5
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
6
6
|
|
|
7
7
|
export type CreateAccountParams = Omit<
|
|
8
8
|
Extract<
|
|
@@ -16,6 +16,31 @@ export type CreateAccountResult = Static<
|
|
|
16
16
|
typeof wallet_createAccount
|
|
17
17
|
>["ReturnType"];
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new account for the provided signer using the wallet API client.
|
|
21
|
+
* This method is primarily used to import existing accounts.
|
|
22
|
+
* For most cases, you should use requestAccount instead.
|
|
23
|
+
* If the account already exists, an error will be thrown.
|
|
24
|
+
*
|
|
25
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
26
|
+
* @param {SmartAccountSigner} signer - The signer that will be associated with the account
|
|
27
|
+
* @param {CreateAccountParams} params - Parameters for creating the account
|
|
28
|
+
* @param {string} [params.id] - Optional UUID v4 identifier for the account
|
|
29
|
+
* @param {object} params.creationOptions - Options for account creation
|
|
30
|
+
* @param {string} [params.creationOptions.accountType] - Currently only "sma-b" (Modular Account v2) is supported
|
|
31
|
+
* @param {string} [params.creationOptions.salt] - Optional hex string to use as salt for account creation
|
|
32
|
+
* @returns {Promise<CreateAccountResult>} A Promise that resolves to the created account information
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Create a new account with a custom salt
|
|
36
|
+
* const account = await client.createAccount({
|
|
37
|
+
* creationOptions: {
|
|
38
|
+
* accountType: "sma-b",
|
|
39
|
+
* salt: "0x04"
|
|
40
|
+
* }
|
|
41
|
+
* });
|
|
42
|
+
* console.log(`Created account at address: ${account.accountAddress}`);
|
|
43
|
+
*/
|
|
19
44
|
export async function createAccount(
|
|
20
45
|
client: InnerWalletApiClient,
|
|
21
46
|
signer: SmartAccountSigner,
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Static } from "@sinclair/typebox";
|
|
2
|
+
import type { wallet_formatSign } from "@alchemy/wallet-api-types/rpc";
|
|
3
|
+
import type { InnerWalletApiClient, WithoutChainId } from "../../types.ts";
|
|
4
|
+
import { toHex, type Address, type IsUndefined } from "viem";
|
|
5
|
+
import { AccountNotFoundError } from "@aa-sdk/core";
|
|
6
|
+
|
|
7
|
+
export type FormatSignParams<
|
|
8
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
9
|
+
> = Omit<
|
|
10
|
+
WithoutChainId<
|
|
11
|
+
Static<
|
|
12
|
+
(typeof wallet_formatSign)["properties"]["Request"]["properties"]["params"]
|
|
13
|
+
>[0]
|
|
14
|
+
>,
|
|
15
|
+
"from"
|
|
16
|
+
> &
|
|
17
|
+
(IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });
|
|
18
|
+
|
|
19
|
+
export type FormatSignResult = Static<typeof wallet_formatSign>["ReturnType"];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Formats a signature request for signing messages or transactions.
|
|
23
|
+
*
|
|
24
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
25
|
+
* @param {FormatSignParams} params - Parameters for formatting the signature
|
|
26
|
+
* @returns {Promise<FormatSignResult>} A Promise that resolves to the formatSign result containing the formatted signature.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Formats a signature
|
|
30
|
+
* const result = await client.formatSign({
|
|
31
|
+
* from: "0x1234...",
|
|
32
|
+
* signature: {
|
|
33
|
+
* type: "ecdsa",
|
|
34
|
+
* data: "0xabcd..."
|
|
35
|
+
* },
|
|
36
|
+
* });
|
|
37
|
+
*/
|
|
38
|
+
export async function formatSign<
|
|
39
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
40
|
+
>(
|
|
41
|
+
client: InnerWalletApiClient,
|
|
42
|
+
params: FormatSignParams<TAccount>,
|
|
43
|
+
): Promise<FormatSignResult> {
|
|
44
|
+
const from = params.from ?? client.account?.address;
|
|
45
|
+
if (!from) {
|
|
46
|
+
throw new AccountNotFoundError();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return client.request({
|
|
50
|
+
method: "wallet_formatSign",
|
|
51
|
+
params: [{ ...params, from, chainId: toHex(client.chain.id) }],
|
|
52
|
+
});
|
|
53
|
+
}
|
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
import type { Address, JsonRpcAccount } from "viem";
|
|
2
1
|
import type {
|
|
3
2
|
GetCallsStatusParams as IsomorphicGetCallsStatusParams,
|
|
4
3
|
GetCallsStatusResponse as IsomorphicGetCallsStatusResult,
|
|
5
|
-
} from "../../isomorphic/actions/getCallsStatus";
|
|
6
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
4
|
+
} from "../../isomorphic/actions/getCallsStatus.ts";
|
|
5
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
7
6
|
|
|
8
7
|
export type GetCallsStatusParams = IsomorphicGetCallsStatusParams;
|
|
9
8
|
|
|
10
9
|
export type GetCallsStatusResult = IsomorphicGetCallsStatusResult;
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Gets the status of a prepared call by its ID.
|
|
13
|
+
* This method is used to check the execution status of calls sent via sendPreparedCalls.
|
|
14
|
+
*
|
|
15
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
16
|
+
* @param {GetCallsStatusParams} params - The ID of the prepared call to check
|
|
17
|
+
* @returns {Promise<GetCallsStatusResult>} A Promise that resolves to the status information including:
|
|
18
|
+
* - id: The hex ID of the call
|
|
19
|
+
* - chainId: The chain ID in hex format
|
|
20
|
+
* - status: The current status of the batch execution
|
|
21
|
+
* - receipts: Optional array of transaction receipts if the batch has been executed
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // After sending prepared calls
|
|
25
|
+
* const sendResult = await client.sendPreparedCalls({...});
|
|
26
|
+
*
|
|
27
|
+
* // Check the status of the first call ID
|
|
28
|
+
* const status = await client.getCallsStatus(sendResult.preparedCallIds[0]);
|
|
29
|
+
*/
|
|
21
30
|
export async function getCallsStatus(
|
|
22
31
|
client: InnerWalletApiClient,
|
|
23
32
|
params: GetCallsStatusParams,
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type JsonRpcAccount,
|
|
6
|
-
toHex,
|
|
7
|
-
} from "viem";
|
|
8
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
9
|
-
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
10
|
-
import type { CreateSessionParams } from "../../isomorphic/actions/createSession";
|
|
1
|
+
import { AccountNotFoundError, type SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
+
import { type Address, type Hex, type IsUndefined, toHex } from "viem";
|
|
3
|
+
import type { CreateSessionParams } from "../../isomorphic/actions/createSession.ts";
|
|
4
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
11
5
|
|
|
12
6
|
export type GrantPermissionsParams<
|
|
13
|
-
TAccount extends
|
|
14
|
-
|
|
15
|
-
| undefined,
|
|
16
|
-
> = Omit<CreateSessionParams, "account" | "chainId"> &
|
|
7
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
8
|
+
> = Omit<CreateSessionParams, "account" | "chainId" | "entityId"> &
|
|
17
9
|
(IsUndefined<TAccount> extends true
|
|
18
10
|
? { account: Address }
|
|
19
11
|
: { account?: never });
|
|
@@ -22,27 +14,78 @@ export type GrantPermissionsResult = {
|
|
|
22
14
|
context: Hex;
|
|
23
15
|
};
|
|
24
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Grants permissions to a smart account by creating a session.
|
|
19
|
+
* This allows another key to perform operations on behalf of the account.
|
|
20
|
+
*
|
|
21
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
22
|
+
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
23
|
+
* @param {GrantPermissionsParams} params - The parameters for granting permissions
|
|
24
|
+
* @param {Address} [params.account] - The account address (required if client was not initialized with an account)
|
|
25
|
+
* @param {number} params.expirySec - Unix timestamp when the permissions expire
|
|
26
|
+
* @param {object} params.key - The session key information
|
|
27
|
+
* @param {string} params.key.publicKey - The public key of the session key
|
|
28
|
+
* @param {string} params.key.type - The type of the key (e.g., "secp256k1")
|
|
29
|
+
* @param {Array} params.permissions - Array of permission objects defining what the session key can do
|
|
30
|
+
* @returns {Promise<GrantPermissionsResult>} A Promise that resolves to the result containing a context identifier
|
|
31
|
+
* @returns {Hex} result.context - A hex identifier for the granted permissions context
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // Create a session key and grant root permissions
|
|
35
|
+
* const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
|
|
36
|
+
* const account = await client.requestAccount();
|
|
37
|
+
*
|
|
38
|
+
* const permissions = await client.grantPermissions({
|
|
39
|
+
* account: account.address,
|
|
40
|
+
* expiry: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour from now
|
|
41
|
+
* key: {
|
|
42
|
+
* publicKey: await sessionKey.getAddress(),
|
|
43
|
+
* type: "secp256k1",
|
|
44
|
+
* },
|
|
45
|
+
* permissions: [{ type: "root" }],
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* // Use the permissions to prepare a call
|
|
49
|
+
* const preparedCalls = await client.prepareCalls({
|
|
50
|
+
* calls: [{ to: zeroAddress, value: "0x0" }],
|
|
51
|
+
* from: account.address,
|
|
52
|
+
* capabilities: {
|
|
53
|
+
* paymasterService: {
|
|
54
|
+
* policyId: "your-paymaster-policy-id",
|
|
55
|
+
* },
|
|
56
|
+
* permissions,
|
|
57
|
+
* },
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* // Sign with the session key
|
|
61
|
+
* const signedCalls = await client.signPreparedCalls(
|
|
62
|
+
* sessionKey,
|
|
63
|
+
* preparedCalls,
|
|
64
|
+
* );
|
|
65
|
+
*
|
|
66
|
+
* // Send the prepared call using the session key
|
|
67
|
+
* const result = await client.sendPreparedCalls({
|
|
68
|
+
* ...signedCalls,
|
|
69
|
+
* capabilities: {
|
|
70
|
+
* permissions,
|
|
71
|
+
* },
|
|
72
|
+
* });
|
|
73
|
+
*/
|
|
25
74
|
export async function grantPermissions<
|
|
26
|
-
TAccount extends
|
|
27
|
-
| JsonRpcAccount<Address>
|
|
28
|
-
| undefined,
|
|
75
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
29
76
|
>(
|
|
30
|
-
client: InnerWalletApiClient<TAccount>,
|
|
31
|
-
signer: SmartAccountSigner,
|
|
32
|
-
params: GrantPermissionsParams<TAccount>,
|
|
33
|
-
): Promise<GrantPermissionsResult>;
|
|
34
|
-
|
|
35
|
-
export async function grantPermissions(
|
|
36
77
|
client: InnerWalletApiClient,
|
|
37
78
|
signer: SmartAccountSigner,
|
|
38
|
-
params: GrantPermissionsParams
|
|
79
|
+
params: GrantPermissionsParams<TAccount>,
|
|
39
80
|
): Promise<GrantPermissionsResult> {
|
|
40
|
-
|
|
41
|
-
|
|
81
|
+
const account = params.account ?? client.account?.address;
|
|
82
|
+
if (!account) {
|
|
83
|
+
throw new AccountNotFoundError();
|
|
42
84
|
}
|
|
43
85
|
|
|
44
86
|
return client.grantPermissions(signer, {
|
|
45
87
|
...params,
|
|
88
|
+
account,
|
|
46
89
|
chainId: toHex(client.chain.id),
|
|
47
90
|
});
|
|
48
91
|
}
|
|
@@ -1,18 +1,56 @@
|
|
|
1
1
|
import type { Static } from "@sinclair/typebox";
|
|
2
|
-
import type { wallet_listAccounts } from "
|
|
3
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
2
|
+
import type { wallet_listAccounts } from "@alchemy/wallet-api-types/rpc";
|
|
3
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
4
|
+
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
5
|
+
import type { Address } from "viem";
|
|
4
6
|
|
|
5
|
-
export type ListAccountsParams =
|
|
6
|
-
typeof wallet_listAccounts
|
|
7
|
-
|
|
7
|
+
export type ListAccountsParams = Omit<
|
|
8
|
+
Static<typeof wallet_listAccounts>["Request"]["params"][0],
|
|
9
|
+
"signerAddress"
|
|
10
|
+
> & { signerAddress?: Address };
|
|
8
11
|
|
|
9
12
|
export type ListAccountsResult = Static<
|
|
10
13
|
typeof wallet_listAccounts
|
|
11
14
|
>["ReturnType"];
|
|
12
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Lists all smart accounts for a given signer using the wallet API client.
|
|
18
|
+
*
|
|
19
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
20
|
+
* @param {ListAccountsParams} params - Parameters for listing accounts
|
|
21
|
+
* @param {string} params.signerAddress - The address of the signer to list accounts for
|
|
22
|
+
* @param {number} [params.limit] - Optional maximum number of accounts to return (default: 100, max: 100)
|
|
23
|
+
* @param {string} [params.after] - Optional pagination cursor for fetching subsequent pages
|
|
24
|
+
* @returns {Promise<ListAccountsResult>} A Promise that resolves to the list of accounts and pagination metadata
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Fetch the first page of accounts
|
|
28
|
+
* const firstPage = await client.listAccounts({
|
|
29
|
+
* signerAddress: "0x123...",
|
|
30
|
+
* limit: 10
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // If an 'after' cursor exists, use it to fetch the next page
|
|
34
|
+
* const nextPage = await client.listAccounts({
|
|
35
|
+
* signerAddress: "0x123...",
|
|
36
|
+
* limit: 10,
|
|
37
|
+
* after: firstPage.meta.after
|
|
38
|
+
* });
|
|
39
|
+
*/
|
|
13
40
|
export async function listAccounts(
|
|
14
41
|
client: InnerWalletApiClient,
|
|
42
|
+
signer: SmartAccountSigner,
|
|
15
43
|
params: ListAccountsParams,
|
|
16
44
|
): Promise<ListAccountsResult> {
|
|
17
|
-
|
|
45
|
+
const signerAddress = params.signerAddress ?? (await signer.getAddress());
|
|
46
|
+
|
|
47
|
+
return client.request({
|
|
48
|
+
method: "wallet_listAccounts",
|
|
49
|
+
params: [
|
|
50
|
+
{
|
|
51
|
+
...params,
|
|
52
|
+
signerAddress,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
});
|
|
18
56
|
}
|
|
@@ -1,42 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type Address,
|
|
4
|
-
type IsUndefined,
|
|
5
|
-
type JsonRpcAccount,
|
|
6
|
-
} from "viem";
|
|
1
|
+
import { AccountNotFoundError } from "@aa-sdk/core";
|
|
2
|
+
import { toHex, type Address, type IsUndefined } from "viem";
|
|
7
3
|
import type {
|
|
8
4
|
PrepareCallsParams as IsomorphicPrepareCallsParams,
|
|
9
5
|
PrepareCallsResult as IsomorphicPrepareCallsResult,
|
|
10
|
-
} from "../../isomorphic/actions/prepareCalls";
|
|
11
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
6
|
+
} from "../../isomorphic/actions/prepareCalls.ts";
|
|
7
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
12
8
|
|
|
13
9
|
export type GetAccountParam<TAccount> =
|
|
14
10
|
IsUndefined<TAccount> extends true
|
|
15
11
|
? { account: Address }
|
|
16
|
-
: { account?:
|
|
12
|
+
: { account?: Address };
|
|
17
13
|
|
|
18
14
|
export type PrepareCallsParams<
|
|
19
|
-
TAccount extends
|
|
20
|
-
| JsonRpcAccount<Address>
|
|
21
|
-
| undefined,
|
|
15
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
22
16
|
> = Omit<IsomorphicPrepareCallsParams, "from" | "chainId"> &
|
|
23
17
|
(IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });
|
|
24
18
|
|
|
25
19
|
export type PrepareCallsResult = IsomorphicPrepareCallsResult;
|
|
26
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Prepares a set of contract calls for execution by building a user operation.
|
|
23
|
+
* Returns the built user operation and a signature request that needs to be signed
|
|
24
|
+
* before submitting to sendPreparedCalls.
|
|
25
|
+
*
|
|
26
|
+
* @param {InnerWalletApiClient<TAccount>} client - The wallet API client to use for the request
|
|
27
|
+
* @param {PrepareCallsParams<TAccount>} params - Parameters for preparing calls
|
|
28
|
+
* @param {Array<{to: Address, data?: Hex, value?: Hex}>} params.calls - Array of contract calls to execute
|
|
29
|
+
* @param {Address} [params.from] - The address to execute the calls from (required if the client wasn't initialized with an account)
|
|
30
|
+
* @param {object} [params.capabilities] - Optional capabilities to include with the request
|
|
31
|
+
* @returns {Promise<PrepareCallsResult>} A Promise that resolves to the prepared calls result containing
|
|
32
|
+
* the user operation data and signature request
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Prepare a sponsored user operation call
|
|
36
|
+
* const result = await client.prepareCalls({
|
|
37
|
+
* calls: [{
|
|
38
|
+
* to: "0x1234...",
|
|
39
|
+
* data: "0xabcdef...",
|
|
40
|
+
* value: "0x0"
|
|
41
|
+
* }],
|
|
42
|
+
* capabilities: {
|
|
43
|
+
* paymasterService: { policyId: "your-policy-id" }
|
|
44
|
+
* }
|
|
45
|
+
* });
|
|
46
|
+
*/
|
|
27
47
|
export async function prepareCalls<
|
|
28
|
-
TAccount extends
|
|
29
|
-
| JsonRpcAccount<Address>
|
|
30
|
-
| undefined,
|
|
48
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
31
49
|
>(
|
|
32
|
-
client: InnerWalletApiClient<TAccount>,
|
|
33
|
-
params: PrepareCallsParams<TAccount>,
|
|
34
|
-
): Promise<PrepareCallsResult>;
|
|
35
|
-
|
|
36
|
-
export async function prepareCalls(
|
|
37
50
|
client: InnerWalletApiClient,
|
|
38
|
-
params: PrepareCallsParams
|
|
51
|
+
params: PrepareCallsParams<TAccount>,
|
|
39
52
|
): Promise<PrepareCallsResult> {
|
|
53
|
+
const from = params.from ?? client.account?.address;
|
|
54
|
+
if (!from) {
|
|
55
|
+
throw new AccountNotFoundError();
|
|
56
|
+
}
|
|
57
|
+
|
|
40
58
|
if (client.policyId && !params.capabilities?.paymasterService) {
|
|
41
59
|
params.capabilities = {
|
|
42
60
|
...params.capabilities,
|
|
@@ -44,12 +62,14 @@ export async function prepareCalls(
|
|
|
44
62
|
};
|
|
45
63
|
}
|
|
46
64
|
|
|
47
|
-
if (client.account && !params.from) {
|
|
48
|
-
params.from = client.account.address;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
65
|
return await client.request({
|
|
52
66
|
method: "wallet_prepareCalls",
|
|
53
|
-
params: [
|
|
67
|
+
params: [
|
|
68
|
+
{
|
|
69
|
+
...params,
|
|
70
|
+
chainId: toHex(client.chain.id),
|
|
71
|
+
from,
|
|
72
|
+
},
|
|
73
|
+
],
|
|
54
74
|
});
|
|
55
75
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
2
|
+
import { toHex, type Address, type IsUndefined } from "viem";
|
|
3
|
+
import type {
|
|
4
|
+
PrepareSignParams as IsomorphicPrepareSignParams,
|
|
5
|
+
PrepareSignResult as IsomorphicPrepareSignResult,
|
|
6
|
+
} from "../../isomorphic/actions/prepareSign.ts";
|
|
7
|
+
import { AccountNotFoundError } from "@aa-sdk/core";
|
|
8
|
+
|
|
9
|
+
export type PrepareSignParams<
|
|
10
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
11
|
+
> = Omit<IsomorphicPrepareSignParams, "from" | "chainId"> &
|
|
12
|
+
(IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });
|
|
13
|
+
|
|
14
|
+
export type PrepareSignResult = IsomorphicPrepareSignResult;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Prepares a signature request for signing messages or transactions.
|
|
18
|
+
*
|
|
19
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
20
|
+
* @param {PrepareSignParams} params - Parameters for preparing the signature request
|
|
21
|
+
* @returns {Promise<PrepareSignResult>} A Promise that resolves to the prepare sign result containing a signature request
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Prepare a message to be signed
|
|
25
|
+
* const result = await client.prepareSign({
|
|
26
|
+
* from: "0x1234...",
|
|
27
|
+
* type: "personal_sign",
|
|
28
|
+
* data: "Hello, world!",
|
|
29
|
+
* });
|
|
30
|
+
*/
|
|
31
|
+
export async function prepareSign<
|
|
32
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
33
|
+
>(
|
|
34
|
+
client: InnerWalletApiClient,
|
|
35
|
+
params: PrepareSignParams<TAccount>,
|
|
36
|
+
): Promise<PrepareSignResult> {
|
|
37
|
+
const from = params.from ?? client.account?.address;
|
|
38
|
+
if (!from) {
|
|
39
|
+
throw new AccountNotFoundError();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return client.request({
|
|
43
|
+
method: "wallet_prepareSign",
|
|
44
|
+
params: [{ ...params, from, chainId: toHex(client.chain.id) }],
|
|
45
|
+
});
|
|
46
|
+
}
|