@account-kit/wallet-client 0.1.0-alpha.1 → 0.1.0-alpha.10
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 +210 -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 +39 -10
- 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 +37 -26
- 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 +138 -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 +256 -54
- 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 +55 -12
- package/src/isomorphic/actions/formatSign.ts +76 -0
- package/src/isomorphic/actions/getCallsStatus.ts +46 -32
- package/src/isomorphic/actions/prepareCalls.ts +95 -23
- package/src/isomorphic/actions/prepareSign.ts +91 -0
- package/src/isomorphic/actions/sendPreparedCalls.ts +181 -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
|
@@ -1,18 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import type { InnerWalletApiClient } from "../types";
|
|
1
|
+
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
+
import type { AlchemyTransport } from "@account-kit/infra";
|
|
3
|
+
import type { Address, Chain, Prettify } from "viem";
|
|
4
|
+
import type { InnerWalletApiClient } from "../types.ts";
|
|
5
5
|
import { type SmartWalletActions } from "./decorator.js";
|
|
6
|
-
export type SmartWalletClientParams<TAccount extends
|
|
6
|
+
export type SmartWalletClientParams<TAccount extends Address | undefined = Address | undefined> = Prettify<{
|
|
7
7
|
transport: AlchemyTransport;
|
|
8
8
|
chain: Chain;
|
|
9
9
|
signer: SmartAccountSigner;
|
|
10
10
|
mode: "local" | "remote";
|
|
11
11
|
policyId?: string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
account?: TAccount | Address | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
export type SmartWalletClient<TAccount extends Address | undefined = Address | undefined> = InnerWalletApiClient & SmartWalletActions<TAccount>;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a smart wallet client that can be used to interact with a smart account.
|
|
17
|
+
*
|
|
18
|
+
* @param {SmartWalletClientParams} params - The parameters for creating the smart wallet client
|
|
19
|
+
* @param {AlchemyTransport} params.transport - The Alchemy transport to use
|
|
20
|
+
* @param {Chain} params.chain - The chain to use
|
|
21
|
+
* @param {SmartAccountSigner} params.signer - The signer to use for the smart account
|
|
22
|
+
* @param {"local" | "remote"} params.mode - The client's mode (local or remote).
|
|
23
|
+
* @param {string} [params.policyId] - The policy ID for gas sponsorship (optional)
|
|
24
|
+
* @param {Address} [params.account] - The smart account address to use (optional)
|
|
25
|
+
* @returns {SmartWalletClient} - A viem-compatible client
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
29
|
+
* import { alchemy, arbitrumSepolia } from "@account-kit/infra";
|
|
30
|
+
* import { generatePrivateKey } from "viem/accounts";
|
|
31
|
+
* import { createSmartWalletClient } from "@account-kit/wallet-client";
|
|
32
|
+
*
|
|
33
|
+
* const signer = LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey());
|
|
34
|
+
* const transport = alchemy({
|
|
35
|
+
* apiKey: "your-alchemy-api-key",
|
|
36
|
+
* });
|
|
37
|
+
* const client = createSmartWalletClient({
|
|
38
|
+
* transport,
|
|
39
|
+
* chain: arbitrumSepolia,
|
|
40
|
+
* mode: "remote",
|
|
41
|
+
* signer,
|
|
42
|
+
* });
|
|
43
|
+
*/
|
|
44
|
+
export declare function createSmartWalletClient<TAccount extends Address | undefined = undefined>(params: SmartWalletClientParams<TAccount>): SmartWalletClient<TAccount>;
|
package/dist/esm/client/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {} from "@aa-sdk/core";
|
|
2
|
-
import {} from "@account-kit/infra";
|
|
3
|
-
import {} from "viem";
|
|
4
1
|
import { createLocalClient } from "../local/client.js";
|
|
5
2
|
import { createRemoteClient } from "../remote/client.js";
|
|
6
3
|
import { smartWalletClientActions, } from "./decorator.js";
|
|
@@ -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":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EACL,wBAAwB,GAEzB,MAAM,gBAAgB,CAAC;AAkDxB,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 { AlchemyTransport } from \"@account-kit/infra\";\nimport type { Address, Chain, Prettify } 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\";\n\nexport type SmartWalletClientParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Prettify<{\n transport: AlchemyTransport;\n chain: Chain;\n signer: SmartAccountSigner;\n mode: \"local\" | \"remote\";\n policyId?: string;\n account?: TAccount | Address | undefined;\n}>;\n\nexport type SmartWalletClient<\n TAccount extends Address | undefined = Address | undefined,\n> = InnerWalletApiClient & 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 {SmartWalletClient} - 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-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 TAccount extends Address | undefined = undefined,\n>(params: SmartWalletClientParams<TAccount>): SmartWalletClient<TAccount>;\n\nexport function createSmartWalletClient(\n params: SmartWalletClientParams,\n): SmartWalletClient {\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,12 @@
|
|
|
1
|
-
export { createSmartWalletClient, type SmartWalletClientParams, } from "../client/index.js";
|
|
2
|
-
export { WalletServerRpcSchema, type WalletServerRpcSchemaType,
|
|
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";
|
|
1
|
+
export { createSmartWalletClient, type SmartWalletClient, type SmartWalletClientParams, } from "../client/index.js";
|
|
2
|
+
export { WalletServerRpcSchema, type WalletServerRpcSchemaType, } from "@alchemy/wallet-api-types/rpc";
|
|
6
3
|
export { createAccount } from "../client/actions/createAccount.js";
|
|
7
4
|
export { getCallsStatus } from "../client/actions/getCallsStatus.js";
|
|
5
|
+
export { grantPermissions } from "../client/actions/grantPermissions.js";
|
|
8
6
|
export { listAccounts } from "../client/actions/listAccounts.js";
|
|
9
7
|
export { prepareCalls } from "../client/actions/prepareCalls.js";
|
|
10
8
|
export { requestAccount } from "../client/actions/requestAccount.js";
|
|
11
|
-
export { signMessage } from "../client/actions/signMessage.js";
|
|
12
9
|
export { signSignatureRequest } from "../client/actions/signSignatureRequest.js";
|
|
10
|
+
export { signPreparedCalls } from "../client/actions/signPreparedCalls.js";
|
|
11
|
+
export { signMessage } from "../client/actions/signMessage.js";
|
|
13
12
|
export { signTypedData } from "../client/actions/signTypedData.js";
|
|
@@ -1,18 +1,16 @@
|
|
|
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
3
|
export { createSmartWalletClient, } from "../client/index.js";
|
|
4
|
-
export { WalletServerRpcSchema, } from "
|
|
5
|
-
// capabilities: TODO: should these actually just have the types exported?
|
|
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";
|
|
4
|
+
export { WalletServerRpcSchema, } from "@alchemy/wallet-api-types/rpc";
|
|
9
5
|
// client actions
|
|
10
6
|
export { createAccount } from "../client/actions/createAccount.js";
|
|
11
7
|
export { getCallsStatus } from "../client/actions/getCallsStatus.js";
|
|
8
|
+
export { grantPermissions } from "../client/actions/grantPermissions.js";
|
|
12
9
|
export { listAccounts } from "../client/actions/listAccounts.js";
|
|
13
10
|
export { prepareCalls } from "../client/actions/prepareCalls.js";
|
|
14
11
|
export { requestAccount } from "../client/actions/requestAccount.js";
|
|
15
|
-
export { signMessage } from "../client/actions/signMessage.js";
|
|
16
12
|
export { signSignatureRequest } from "../client/actions/signSignatureRequest.js";
|
|
13
|
+
export { signPreparedCalls } from "../client/actions/signPreparedCalls.js";
|
|
14
|
+
export { signMessage } from "../client/actions/signMessage.js";
|
|
17
15
|
export { signTypedData } from "../client/actions/signTypedData.js";
|
|
18
16
|
//# 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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exports/index.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,yDAAyD;AACzD,OAAO,EACL,uBAAuB,GAGxB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,qBAAqB,GAEtB,MAAM,+BAA+B,CAAC;AAEvC,iBAAiB;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,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,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,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 SmartWalletClient,\n type SmartWalletClientParams,\n} from \"../client/index.js\";\n\nexport {\n WalletServerRpcSchema,\n type WalletServerRpcSchemaType,\n} from \"@alchemy/wallet-api-types/rpc\";\n\n// client actions\nexport { createAccount } from \"../client/actions/createAccount.js\";\nexport { getCallsStatus } from \"../client/actions/getCallsStatus.js\";\nexport { grantPermissions } from \"../client/actions/grantPermissions.js\";\nexport { listAccounts } from \"../client/actions/listAccounts.js\";\nexport { prepareCalls } from \"../client/actions/prepareCalls.js\";\nexport { requestAccount } from \"../client/actions/requestAccount.js\";\nexport { signSignatureRequest } from \"../client/actions/signSignatureRequest.js\";\nexport { signPreparedCalls } from \"../client/actions/signPreparedCalls.js\";\nexport { signMessage } from \"../client/actions/signMessage.js\";\nexport { signTypedData } from \"../client/actions/signTypedData.js\";\n"]}
|
|
@@ -1,13 +1,4 @@
|
|
|
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
1
|
export type * from "../isomorphic/client.js";
|
|
6
2
|
export { createIsomorphicClient } from "../isomorphic/client.js";
|
|
7
3
|
export { createDummySigner } from "../isomorphic/utils/createDummySigner.js";
|
|
8
|
-
export * from "../
|
|
9
|
-
export * as RpcSchemas from "../rpc/request.js";
|
|
10
|
-
export * from "../rpc/schema.js";
|
|
11
|
-
export * from "../schemas.js";
|
|
12
|
-
export type * from "../types";
|
|
13
|
-
export * from "../utils.js";
|
|
4
|
+
export type * from "../types.ts";
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
// exports from this file are meant to be imported by our packages in the monorepo
|
|
2
|
-
// we will expose this in the package.json as a named export like `this-pkg/internal`
|
|
3
|
-
// TODO: name `this-pkg`
|
|
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
1
|
export { createIsomorphicClient } from "../isomorphic/client.js";
|
|
9
2
|
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
3
|
//# sourceMappingURL=internal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/exports/internal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/exports/internal.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,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 type * from \"../isomorphic/client.js\";\nexport { createIsomorphicClient } from \"../isomorphic/client.js\";\nexport { createDummySigner } from \"../isomorphic/utils/createDummySigner.js\";\n\nexport type * from \"../types.ts\";\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,7 @@
|
|
|
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 Hex, type Transport } from "viem";
|
|
4
|
-
import type { wallet_createSession } from "
|
|
5
|
-
import type { WalletServerViemRpcSchema } from "../../rpc/schema.js";
|
|
4
|
+
import type { wallet_createSession, WalletServerViemRpcSchema } from "@alchemy/wallet-api-types/rpc";
|
|
6
5
|
export type CreateSessionParams = Omit<Static<(typeof wallet_createSession)["properties"]["Request"]["properties"]["params"]>[0], "chainId"> & {
|
|
7
6
|
entityId?: Hex;
|
|
8
7
|
};
|
|
@@ -1,36 +1,59 @@
|
|
|
1
1
|
import { createSmartAccountClient, } from "@aa-sdk/core";
|
|
2
2
|
import { deferralActions, PermissionBuilder, } from "@account-kit/smart-contracts/experimental";
|
|
3
3
|
import { Value } from "@sinclair/typebox/value";
|
|
4
|
-
import { ChainNotFoundError, custom, hexToNumber, toHex, } from "viem";
|
|
5
|
-
import {
|
|
6
|
-
import { isGlobalValidation } from "
|
|
4
|
+
import { ChainNotFoundError, custom, hashTypedData, hexToNumber, toHex, } from "viem";
|
|
5
|
+
import { InvalidRequestError } from "ox/RpcResponse";
|
|
6
|
+
import { TypePermission, isGlobalValidation, } from "@alchemy/wallet-api-types/capabilities";
|
|
7
7
|
import { createAccount, isModularAccountV2 } from "../utils/createAccount.js";
|
|
8
8
|
import { createDummySigner } from "../utils/createDummySigner.js";
|
|
9
|
+
import { supportsFeature } from "../utils/supportsFeature.js";
|
|
10
|
+
import { isDelegated } from "../utils/7702.js";
|
|
9
11
|
export async function createSession(client, params) {
|
|
10
12
|
if (!client.chain) {
|
|
11
13
|
throw new ChainNotFoundError();
|
|
12
14
|
}
|
|
13
|
-
const { counterfactualInfo } = await client.request({
|
|
15
|
+
const { counterfactualInfo, delegation } = await client.request({
|
|
14
16
|
method: "wallet_requestAccount",
|
|
15
17
|
params: [
|
|
16
18
|
{
|
|
17
|
-
includeCounterfactualInfo: true,
|
|
18
19
|
accountAddress: params.account,
|
|
20
|
+
includeCounterfactualInfo: true,
|
|
19
21
|
},
|
|
20
22
|
],
|
|
21
23
|
});
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
+
if (delegation &&
|
|
25
|
+
!(await isDelegated(client, {
|
|
26
|
+
address: params.account,
|
|
27
|
+
delegation,
|
|
28
|
+
}))) {
|
|
29
|
+
throw new InvalidRequestError({
|
|
30
|
+
message: "7702 account must be delegated before calling `wallet_createSession`",
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (!delegation && !counterfactualInfo) {
|
|
34
|
+
throw new InvalidRequestError({
|
|
35
|
+
message: "No counterfactual info found.",
|
|
36
|
+
});
|
|
24
37
|
}
|
|
38
|
+
if (counterfactualInfo &&
|
|
39
|
+
!supportsFeature(counterfactualInfo, "permissions")) {
|
|
40
|
+
throw new InvalidRequestError({
|
|
41
|
+
message: "Account type does not support createSession",
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
// At this point we know the account supports the permission feature
|
|
25
45
|
const account = await createAccount({
|
|
26
46
|
chain: client.chain,
|
|
27
47
|
transport: custom(client.transport),
|
|
28
48
|
signer: createDummySigner(params.account),
|
|
29
49
|
accountAddress: params.account,
|
|
30
50
|
counterfactualInfo,
|
|
51
|
+
delegation,
|
|
31
52
|
});
|
|
32
53
|
if (!isModularAccountV2(account)) {
|
|
33
|
-
throw new
|
|
54
|
+
throw new InvalidRequestError({
|
|
55
|
+
message: "Sessions are currently only supported by MAv2 accounts.",
|
|
56
|
+
});
|
|
34
57
|
}
|
|
35
58
|
const _client = createSmartAccountClient({
|
|
36
59
|
chain: client.chain,
|
|
@@ -43,10 +66,14 @@ export async function createSession(client, params) {
|
|
|
43
66
|
});
|
|
44
67
|
const { typedData, fullPreSignatureDeferredActionDigest } = await new PermissionBuilder({
|
|
45
68
|
client: _client,
|
|
46
|
-
key:
|
|
69
|
+
key: {
|
|
70
|
+
...params.key,
|
|
71
|
+
// Alias 'ecdsa' to 'secp256k1'
|
|
72
|
+
type: params.key.type === "ecdsa" ? "secp256k1" : params.key.type,
|
|
73
|
+
},
|
|
47
74
|
entityId,
|
|
48
75
|
nonce,
|
|
49
|
-
deadline: params.
|
|
76
|
+
deadline: params.expirySec,
|
|
50
77
|
})
|
|
51
78
|
.addPermissions({
|
|
52
79
|
permissions: params.permissions.map((permission) => Value.Encode(TypePermission, permission)),
|
|
@@ -54,10 +81,12 @@ export async function createSession(client, params) {
|
|
|
54
81
|
.compileDeferred();
|
|
55
82
|
return {
|
|
56
83
|
sessionId: null, // In remote mode, the server will set this later.
|
|
84
|
+
chainId: toHex(client.chain.id),
|
|
57
85
|
entityId: toHex(entityId),
|
|
58
86
|
signatureRequest: {
|
|
59
87
|
type: "eth_signTypedData_v4",
|
|
60
88
|
data: typedData,
|
|
89
|
+
rawPayload: hashTypedData(typedData),
|
|
61
90
|
},
|
|
62
91
|
fullPreSignatureDeferredActionDigest,
|
|
63
92
|
};
|
|
@@ -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,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,
|
|
1
|
+
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/createSession.ts"],"names":[],"mappings":"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","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 hashTypedData,\n hexToNumber,\n toHex,\n type Chain,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { InvalidRequestError } from \"ox/RpcResponse\";\nimport {\n TypePermission,\n isGlobalValidation,\n} from \"@alchemy/wallet-api-types/capabilities\";\nimport type {\n wallet_createSession,\n WalletServerViemRpcSchema,\n} from \"@alchemy/wallet-api-types/rpc\";\nimport { createAccount, isModularAccountV2 } from \"../utils/createAccount.js\";\nimport { createDummySigner } from \"../utils/createDummySigner.js\";\nimport { supportsFeature } from \"../utils/supportsFeature.js\";\nimport { isDelegated } from \"../utils/7702.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, delegation } = await client.request({\n method: \"wallet_requestAccount\",\n params: [\n {\n accountAddress: params.account,\n includeCounterfactualInfo: true,\n },\n ],\n });\n\n if (\n delegation &&\n !(await isDelegated(client, {\n address: params.account,\n delegation,\n }))\n ) {\n throw new InvalidRequestError({\n message:\n \"7702 account must be delegated before calling `wallet_createSession`\",\n });\n }\n\n if (!delegation && !counterfactualInfo) {\n throw new InvalidRequestError({\n message: \"No counterfactual info found.\",\n });\n }\n\n if (\n counterfactualInfo &&\n !supportsFeature(counterfactualInfo, \"permissions\")\n ) {\n throw new InvalidRequestError({\n message: \"Account type does not support createSession\",\n });\n }\n\n // At this point we know the account supports the permission feature\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 delegation,\n });\n\n if (!isModularAccountV2(account)) {\n throw new InvalidRequestError({\n message: \"Sessions are currently only supported by MAv2 accounts.\",\n });\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: {\n ...params.key,\n // Alias 'ecdsa' to 'secp256k1'\n type: params.key.type === \"ecdsa\" ? \"secp256k1\" : params.key.type,\n },\n entityId,\n nonce,\n deadline: params.expirySec,\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 chainId: toHex(client.chain.id),\n entityId: toHex(entityId),\n signatureRequest: {\n type: \"eth_signTypedData_v4\" as const,\n data: typedData,\n rawPayload: hashTypedData(typedData),\n },\n fullPreSignatureDeferredActionDigest,\n };\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Static } from "@sinclair/typebox";
|
|
2
|
+
import type { wallet_formatSign } from "@alchemy/wallet-api-types/rpc";
|
|
3
|
+
import type { SmartAccountClient, SmartContractAccount } from "@aa-sdk/core";
|
|
4
|
+
import { type Chain, type Transport } from "viem";
|
|
5
|
+
import type { WalletServerViemRpcSchema } from "@alchemy/wallet-api-types/rpc";
|
|
6
|
+
export type FormatSignParams = Static<(typeof wallet_formatSign)["properties"]["Request"]["properties"]["params"]>[0];
|
|
7
|
+
export type FormatSignResult = Static<(typeof wallet_formatSign)["properties"]["ReturnType"]>;
|
|
8
|
+
export declare function formatSign(client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>, params: FormatSignParams): Promise<FormatSignResult>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ChainNotFoundError, concat, custom, encodeAbiParameters, parseAbiParameters, } from "viem";
|
|
2
|
+
import { createAccount } from "../utils/createAccount.js";
|
|
3
|
+
import { createDummySigner } from "../utils/createDummySigner.js";
|
|
4
|
+
import { magicBytes } from "ox/erc6492/WrappedSignature";
|
|
5
|
+
export async function formatSign(client, params) {
|
|
6
|
+
if (!client.chain) {
|
|
7
|
+
throw new ChainNotFoundError();
|
|
8
|
+
}
|
|
9
|
+
const { counterfactualInfo, delegation } = await client.request({
|
|
10
|
+
method: "wallet_requestAccount",
|
|
11
|
+
params: [
|
|
12
|
+
{
|
|
13
|
+
accountAddress: params.from,
|
|
14
|
+
includeCounterfactualInfo: true,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
});
|
|
18
|
+
const account = await createAccount({
|
|
19
|
+
chain: client.chain,
|
|
20
|
+
transport: custom(client.transport),
|
|
21
|
+
signer: createDummySigner(params.from),
|
|
22
|
+
accountAddress: params.from,
|
|
23
|
+
counterfactualInfo,
|
|
24
|
+
permissions: params.capabilities?.permissions,
|
|
25
|
+
delegation,
|
|
26
|
+
});
|
|
27
|
+
let formattedSignature = await account.formatSign(params.signature.data);
|
|
28
|
+
if (counterfactualInfo && !(await account.isAccountDeployed())) {
|
|
29
|
+
formattedSignature = concat([
|
|
30
|
+
encodeAbiParameters(parseAbiParameters("address, bytes, bytes"), [
|
|
31
|
+
counterfactualInfo.factoryAddress,
|
|
32
|
+
counterfactualInfo.factoryData,
|
|
33
|
+
formattedSignature,
|
|
34
|
+
]),
|
|
35
|
+
magicBytes,
|
|
36
|
+
]);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
signature: formattedSignature,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=formatSign.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatSign.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/formatSign.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,MAAM,EACN,mBAAmB,EACnB,kBAAkB,GAGnB,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAUzD,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,MAMC,EACD,MAAwB;IAExB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAC9D,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE;YACN;gBACE,cAAc,EAAE,MAAM,CAAC,IAAI;gBAC3B,yBAAyB,EAAE,IAAI;aAChC;SACF;KACF,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC;QAClC,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;QACnC,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC;QACtC,cAAc,EAAE,MAAM,CAAC,IAAI;QAC3B,kBAAkB;QAClB,WAAW,EAAE,MAAM,CAAC,YAAY,EAAE,WAAW;QAC7C,UAAU;KACX,CAAC,CAAC;IAEH,IAAI,kBAAkB,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAEzE,IAAI,kBAAkB,IAAI,CAAC,CAAC,MAAM,OAAO,CAAC,iBAAiB,EAAE,CAAC,EAAE,CAAC;QAC/D,kBAAkB,GAAG,MAAM,CAAC;YAC1B,mBAAmB,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,EAAE;gBAC/D,kBAAkB,CAAC,cAAc;gBACjC,kBAAkB,CAAC,WAAW;gBAC9B,kBAAkB;aACnB,CAAC;YACF,UAAU;SACX,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,SAAS,EAAE,kBAAkB;KAC9B,CAAC;AACJ,CAAC","sourcesContent":["import type { Static } from \"@sinclair/typebox\";\nimport type { wallet_formatSign } from \"@alchemy/wallet-api-types/rpc\";\nimport type { SmartAccountClient, SmartContractAccount } from \"@aa-sdk/core\";\nimport {\n ChainNotFoundError,\n concat,\n custom,\n encodeAbiParameters,\n parseAbiParameters,\n type Chain,\n type Transport,\n} from \"viem\";\nimport type { WalletServerViemRpcSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport { createAccount } from \"../utils/createAccount.js\";\nimport { createDummySigner } from \"../utils/createDummySigner.js\";\nimport { magicBytes } from \"ox/erc6492/WrappedSignature\";\n\nexport type FormatSignParams = Static<\n (typeof wallet_formatSign)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n>[0];\n\nexport type FormatSignResult = Static<\n (typeof wallet_formatSign)[\"properties\"][\"ReturnType\"]\n>;\n\nexport async function formatSign(\n client: SmartAccountClient<\n Transport,\n Chain,\n SmartContractAccount | undefined,\n Record<string, unknown>,\n WalletServerViemRpcSchema\n >,\n params: FormatSignParams,\n): Promise<FormatSignResult> {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const { counterfactualInfo, delegation } = await client.request({\n method: \"wallet_requestAccount\",\n params: [\n {\n accountAddress: params.from,\n includeCounterfactualInfo: true,\n },\n ],\n });\n\n const account = await createAccount({\n chain: client.chain,\n transport: custom(client.transport),\n signer: createDummySigner(params.from),\n accountAddress: params.from,\n counterfactualInfo,\n permissions: params.capabilities?.permissions,\n delegation,\n });\n\n let formattedSignature = await account.formatSign(params.signature.data);\n\n if (counterfactualInfo && !(await account.isAccountDeployed())) {\n formattedSignature = concat([\n encodeAbiParameters(parseAbiParameters(\"address, bytes, bytes\"), [\n counterfactualInfo.factoryAddress,\n counterfactualInfo.factoryData,\n formattedSignature,\n ]),\n magicBytes,\n ]);\n }\n\n return {\n signature: formattedSignature,\n };\n}\n"]}
|
|
@@ -1,21 +1,7 @@
|
|
|
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
|
|
5
|
-
import type { WalletServerViemRpcSchema } from "../../rpc/schema.js";
|
|
4
|
+
import { type wallet_getCallsStatus, type WalletServerViemRpcSchema } from "@alchemy/wallet-api-types/rpc";
|
|
6
5
|
export type GetCallsStatusParams = Static<(typeof wallet_getCallsStatus)["properties"]["Request"]["properties"]["params"]>[0];
|
|
7
6
|
export type GetCallsStatusResponse = Static<(typeof wallet_getCallsStatus)["properties"]["ReturnType"]>;
|
|
8
|
-
/** EIP-5792 call status codes */
|
|
9
|
-
export declare const CallStatusCode: {
|
|
10
|
-
/** Batch has been received by the wallet but has not completed execution onchain */
|
|
11
|
-
readonly PENDING: 100;
|
|
12
|
-
/** Batch has been included onchain without reverts, receipts array contains info of all calls */
|
|
13
|
-
readonly CONFIRMED: 200;
|
|
14
|
-
/** Batch has not been included onchain and wallet will not retry */
|
|
15
|
-
readonly OFFCHAIN_FAILURE: 400;
|
|
16
|
-
/** Batch reverted *completely* and only changes related to gas charge may have been included onchain */
|
|
17
|
-
readonly CHAIN_RULES_FAILURE: 500;
|
|
18
|
-
/** Batch reverted *partially* and some changes related to batch calls may have been included onchain */
|
|
19
|
-
readonly PARTIAL_CHAIN_RULES_FAILURE: 600;
|
|
20
|
-
};
|
|
21
7
|
export declare function getCallsStatus(client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>, callId: GetCallsStatusParams): Promise<GetCallsStatusResponse>;
|
|
@@ -1,43 +1,54 @@
|
|
|
1
1
|
import {} from "@aa-sdk/core";
|
|
2
2
|
import { Value } from "@sinclair/typebox/value";
|
|
3
3
|
import { ChainNotFoundError, isHex, } from "viem";
|
|
4
|
-
import {
|
|
4
|
+
import { BaseError } from "ox/RpcResponse";
|
|
5
|
+
import { CallStatusCode, CallStatusErrorCode, } from "@alchemy/wallet-api-types/rpc";
|
|
6
|
+
import { TypeCallId } from "@alchemy/wallet-api-types";
|
|
5
7
|
import { castToHex } from "../../utils.js";
|
|
6
|
-
const ReceiptStatus = {
|
|
7
|
-
reverted: "0x0",
|
|
8
|
-
success: "0x1",
|
|
9
|
-
};
|
|
10
|
-
/** EIP-5792 call status codes */
|
|
11
|
-
export const CallStatusCode = {
|
|
12
|
-
/** Batch has been received by the wallet but has not completed execution onchain */
|
|
13
|
-
PENDING: 100,
|
|
14
|
-
/** Batch has been included onchain without reverts, receipts array contains info of all calls */
|
|
15
|
-
CONFIRMED: 200,
|
|
16
|
-
/** Batch has not been included onchain and wallet will not retry */
|
|
17
|
-
OFFCHAIN_FAILURE: 400,
|
|
18
|
-
/** Batch reverted *completely* and only changes related to gas charge may have been included onchain */
|
|
19
|
-
CHAIN_RULES_FAILURE: 500,
|
|
20
|
-
/** Batch reverted *partially* and some changes related to batch calls may have been included onchain */
|
|
21
|
-
PARTIAL_CHAIN_RULES_FAILURE: 600,
|
|
22
|
-
};
|
|
23
8
|
export async function getCallsStatus(client, callId) {
|
|
24
9
|
if (!client.chain) {
|
|
25
10
|
throw new ChainNotFoundError();
|
|
26
11
|
}
|
|
27
12
|
const { chainId, hash } = Value.Decode(TypeCallId, callId);
|
|
28
|
-
const
|
|
29
|
-
return {
|
|
13
|
+
const baseResp = {
|
|
30
14
|
id: callId,
|
|
31
15
|
chainId,
|
|
32
16
|
atomic: true,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
17
|
+
};
|
|
18
|
+
const result = await client.getUserOperationByHash(hash);
|
|
19
|
+
if (!result) {
|
|
20
|
+
throw new BaseError({
|
|
21
|
+
message: `callId ${callId} not found`,
|
|
22
|
+
code: CallStatusErrorCode.UNKNOWN_BUNDLE_ID,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
if (result && !result.transactionHash) {
|
|
26
|
+
// A result but no txn hash means it's valid but pending.
|
|
27
|
+
return {
|
|
28
|
+
...baseResp,
|
|
29
|
+
status: CallStatusCode.PENDING,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const receipt = await client.getUserOperationReceipt(hash);
|
|
33
|
+
if (!receipt) {
|
|
34
|
+
// Handles edge case of hash being retrieved immediately before the 150 block limit falloff.
|
|
35
|
+
throw new BaseError({
|
|
36
|
+
message: `callId ${callId} not found`,
|
|
37
|
+
code: CallStatusErrorCode.UNKNOWN_BUNDLE_ID,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
...baseResp,
|
|
42
|
+
status: receipt.success
|
|
43
|
+
? CallStatusCode.CONFIRMED
|
|
44
|
+
: CallStatusCode.CHAIN_RULES_FAILURE,
|
|
45
|
+
receipts: [transformReceipt(receipt.receipt)],
|
|
39
46
|
};
|
|
40
47
|
}
|
|
48
|
+
const ReceiptStatus = {
|
|
49
|
+
reverted: "0x0",
|
|
50
|
+
success: "0x1",
|
|
51
|
+
};
|
|
41
52
|
function transformReceipt(receipt) {
|
|
42
53
|
return {
|
|
43
54
|
// viem's type for status is "success" | "reverted", but the actual value seems to already be 0x0 or 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,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EACL,kBAAkB,EAClB,KAAK,GAKN,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../../src/isomorphic/actions/getCallsStatus.ts"],"names":[],"mappings":"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","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 { BaseError } from \"ox/RpcResponse\";\nimport {\n CallStatusCode,\n CallStatusErrorCode,\n type wallet_getCallsStatus,\n type WalletServerViemRpcSchema,\n} from \"@alchemy/wallet-api-types/rpc\";\nimport { TypeCallId } from \"@alchemy/wallet-api-types\";\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\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 const { chainId, hash } = Value.Decode(TypeCallId, callId);\n\n const baseResp = {\n id: callId,\n chainId,\n atomic: true,\n };\n\n const result = await client.getUserOperationByHash(hash);\n if (!result) {\n throw new BaseError({\n message: `callId ${callId} not found`,\n code: CallStatusErrorCode.UNKNOWN_BUNDLE_ID,\n });\n }\n if (result && !result.transactionHash) {\n // A result but no txn hash means it's valid but pending.\n return {\n ...baseResp,\n status: CallStatusCode.PENDING,\n };\n }\n\n const receipt = await client.getUserOperationReceipt(hash);\n if (!receipt) {\n // Handles edge case of hash being retrieved immediately before the 150 block limit falloff.\n throw new BaseError({\n message: `callId ${callId} not found`,\n code: CallStatusErrorCode.UNKNOWN_BUNDLE_ID,\n });\n }\n\n return {\n ...baseResp,\n status: receipt.success\n ? CallStatusCode.CONFIRMED\n : CallStatusCode.CHAIN_RULES_FAILURE,\n receipts: [transformReceipt(receipt.receipt)],\n };\n}\n\nconst ReceiptStatus: Record<TransactionReceipt[\"status\"], Hex> = {\n reverted: \"0x0\",\n success: \"0x1\",\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,7 @@
|
|
|
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 "
|
|
5
|
-
import type { WalletServerViemRpcSchema } from "../../rpc/schema.js";
|
|
4
|
+
import type { wallet_prepareCalls, WalletServerViemRpcSchema } from "@alchemy/wallet-api-types/rpc";
|
|
6
5
|
export type PrepareCallsParams = Omit<Static<(typeof wallet_prepareCalls)["properties"]["Request"]["properties"]["params"]>[0], "chainId">;
|
|
7
6
|
export type PrepareCallsResult = Static<(typeof wallet_prepareCalls)["properties"]["ReturnType"]>;
|
|
8
7
|
export declare function prepareCalls(client: SmartAccountClient<Transport, Chain, SmartContractAccount | undefined, Record<string, unknown>, WalletServerViemRpcSchema>, params: PrepareCallsParams): Promise<PrepareCallsResult>;
|