@account-kit/wallet-client 4.83.2 → 4.84.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/client/actions/getCallsStatus.d.ts +2 -2
- package/dist/esm/client/actions/getCallsStatus.js +2 -2
- package/dist/esm/client/actions/getCallsStatus.js.map +1 -1
- package/dist/esm/client/actions/grantPermissions.d.ts +1 -1
- package/dist/esm/client/actions/grantPermissions.js +1 -5
- package/dist/esm/client/actions/grantPermissions.js.map +1 -1
- package/dist/esm/client/actions/listAccounts.d.ts +4 -8
- package/dist/esm/client/actions/listAccounts.js +6 -27
- package/dist/esm/client/actions/listAccounts.js.map +1 -1
- package/dist/esm/client/actions/requestAccount.d.ts +3 -6
- package/dist/esm/client/actions/requestAccount.js +5 -31
- package/dist/esm/client/actions/requestAccount.js.map +1 -1
- package/dist/esm/client/actions/sendCalls.d.ts +4 -4
- package/dist/esm/client/actions/sendCalls.js +4 -8
- package/dist/esm/client/actions/sendCalls.js.map +1 -1
- package/dist/esm/client/actions/sendPreparedCalls.d.ts +1 -1
- package/dist/esm/client/actions/sendPreparedCalls.js +1 -1
- package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/client/actions/signMessage.d.ts +1 -1
- package/dist/esm/client/actions/signMessage.js +1 -1
- package/dist/esm/client/actions/signMessage.js.map +1 -1
- package/dist/esm/client/actions/signPreparedCalls.d.ts +1 -1
- package/dist/esm/client/actions/signPreparedCalls.js +2 -5
- package/dist/esm/client/actions/signPreparedCalls.js.map +1 -1
- package/dist/esm/client/actions/signSignatureRequest.d.ts +34 -9
- package/dist/esm/client/actions/signSignatureRequest.js +2 -30
- package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
- package/dist/esm/client/actions/signTypedData.d.ts +1 -1
- package/dist/esm/client/actions/signTypedData.js +1 -1
- package/dist/esm/client/actions/signTypedData.js.map +1 -1
- package/dist/esm/client/decorator.js +1 -13
- package/dist/esm/client/decorator.js.map +1 -1
- package/dist/esm/client/index.d.ts +2 -8
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/internal/account.d.ts +1 -1
- package/dist/esm/internal/account.js +1 -19
- package/dist/esm/internal/account.js.map +1 -1
- package/dist/esm/utils.d.ts +0 -6
- package/dist/esm/utils.js +1 -14
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/client/actions/getCallsStatus.d.ts +2 -2
- package/dist/types/client/actions/grantPermissions.d.ts +1 -1
- package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
- package/dist/types/client/actions/listAccounts.d.ts +4 -8
- package/dist/types/client/actions/listAccounts.d.ts.map +1 -1
- package/dist/types/client/actions/requestAccount.d.ts +3 -6
- package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
- package/dist/types/client/actions/sendCalls.d.ts +4 -4
- package/dist/types/client/actions/sendCalls.d.ts.map +1 -1
- package/dist/types/client/actions/sendPreparedCalls.d.ts +1 -1
- package/dist/types/client/actions/signMessage.d.ts +1 -1
- package/dist/types/client/actions/signPreparedCalls.d.ts +1 -1
- package/dist/types/client/actions/signPreparedCalls.d.ts.map +1 -1
- package/dist/types/client/actions/signSignatureRequest.d.ts +34 -9
- package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
- package/dist/types/client/actions/signTypedData.d.ts +1 -1
- package/dist/types/client/decorator.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +2 -8
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/internal/account.d.ts +1 -1
- package/dist/types/internal/account.d.ts.map +1 -1
- package/dist/types/utils.d.ts +0 -6
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +6 -6
- package/src/client/actions/getCallsStatus.ts +2 -2
- package/src/client/actions/grantPermissions.ts +1 -8
- package/src/client/actions/listAccounts.ts +7 -35
- package/src/client/actions/requestAccount.ts +8 -51
- package/src/client/actions/sendCalls.ts +4 -10
- package/src/client/actions/sendPreparedCalls.ts +1 -1
- package/src/client/actions/signMessage.ts +1 -1
- package/src/client/actions/signPreparedCalls.ts +2 -7
- package/src/client/actions/signSignatureRequest.ts +5 -75
- package/src/client/actions/signTypedData.ts +1 -1
- package/src/client/decorator.ts +1 -19
- package/src/client/index.ts +2 -9
- package/src/internal/account.ts +2 -26
- package/src/utils.ts +1 -25
- package/src/version.ts +1 -1
|
@@ -24,8 +24,8 @@ export type GetCallsStatusResult = RpcSchema["ReturnType"];
|
|
|
24
24
|
* // After sending prepared calls
|
|
25
25
|
* const sendResult = await client.sendPreparedCalls({...});
|
|
26
26
|
*
|
|
27
|
-
* // Check the status of the
|
|
28
|
-
* const status = await client.getCallsStatus(sendResult.
|
|
27
|
+
* // Check the status of the call ID
|
|
28
|
+
* const status = await client.getCallsStatus(sendResult.id);
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
export declare function getCallsStatus(client: InnerWalletApiClient, params: GetCallsStatusParams): Promise<GetCallsStatusResult>;
|
|
@@ -16,8 +16,8 @@ import { metrics } from "../../metrics.js";
|
|
|
16
16
|
* // After sending prepared calls
|
|
17
17
|
* const sendResult = await client.sendPreparedCalls({...});
|
|
18
18
|
*
|
|
19
|
-
* // Check the status of the
|
|
20
|
-
* const status = await client.getCallsStatus(sendResult.
|
|
19
|
+
* // Check the status of the call ID
|
|
20
|
+
* const status = await client.getCallsStatus(sendResult.id);
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
export async function getCallsStatus(client, params) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../../src/client/actions/getCallsStatus.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAe3C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA4B;IAE5B,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,kBAAkB;KACzB,CAAC,CAAC;IAEH,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,MAAM,CAAC;KACjB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { InnerWalletApiClient } from \"../../types.ts\";\nimport type { WalletServerRpcSchemaType } from \"@alchemy/wallet-api-types/rpc\";\nimport { metrics } from \"../../metrics.js\";\n\ntype RpcSchema = Extract<\n WalletServerRpcSchemaType,\n {\n Request: {\n method: \"wallet_getCallsStatus\";\n };\n }\n>;\n\nexport type GetCallsStatusParams = RpcSchema[\"Request\"][\"params\"][0];\n\nexport type GetCallsStatusResult = RpcSchema[\"ReturnType\"];\n\n/**\n * Gets the status of a prepared call by its ID.\n * This method is used to check the execution status of calls sent via sendPreparedCalls.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {GetCallsStatusParams} params - The ID of the prepared call to check\n * @returns {Promise<GetCallsStatusResult>} A Promise that resolves to the status information including:\n * - id: The hex ID of the call\n * - chainId: The chain ID in hex format\n * - status: The current status of the batch execution\n * - receipts: Optional array of transaction receipts if the batch has been executed\n *\n * @example\n * ```ts\n * // After sending prepared calls\n * const sendResult = await client.sendPreparedCalls({...});\n *\n * // Check the status of the
|
|
1
|
+
{"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../../src/client/actions/getCallsStatus.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAe3C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA4B;IAE5B,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,kBAAkB;KACzB,CAAC,CAAC;IAEH,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,MAAM,CAAC;KACjB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { InnerWalletApiClient } from \"../../types.ts\";\nimport type { WalletServerRpcSchemaType } from \"@alchemy/wallet-api-types/rpc\";\nimport { metrics } from \"../../metrics.js\";\n\ntype RpcSchema = Extract<\n WalletServerRpcSchemaType,\n {\n Request: {\n method: \"wallet_getCallsStatus\";\n };\n }\n>;\n\nexport type GetCallsStatusParams = RpcSchema[\"Request\"][\"params\"][0];\n\nexport type GetCallsStatusResult = RpcSchema[\"ReturnType\"];\n\n/**\n * Gets the status of a prepared call by its ID.\n * This method is used to check the execution status of calls sent via sendPreparedCalls.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {GetCallsStatusParams} params - The ID of the prepared call to check\n * @returns {Promise<GetCallsStatusResult>} A Promise that resolves to the status information including:\n * - id: The hex ID of the call\n * - chainId: The chain ID in hex format\n * - status: The current status of the batch execution\n * - receipts: Optional array of transaction receipts if the batch has been executed\n *\n * @example\n * ```ts\n * // After sending prepared calls\n * const sendResult = await client.sendPreparedCalls({...});\n *\n * // Check the status of the call ID\n * const status = await client.getCallsStatus(sendResult.id);\n * ```\n */\nexport async function getCallsStatus(\n client: InnerWalletApiClient,\n params: GetCallsStatusParams,\n): Promise<GetCallsStatusResult> {\n metrics.trackEvent({\n name: \"get_calls_status\",\n });\n\n return await client.request({\n method: \"wallet_getCallsStatus\",\n params: [params],\n });\n}\n"]}
|
|
@@ -20,7 +20,7 @@ export type GrantPermissionsResult = {
|
|
|
20
20
|
* This allows another key to perform operations on behalf of the account.
|
|
21
21
|
*
|
|
22
22
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
23
|
-
* @param {SmartAccountSigner
|
|
23
|
+
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
24
24
|
* @param {GrantPermissionsParams} params - The parameters for granting permissions
|
|
25
25
|
* @param {Address} [params.account] - The account address (required if client was not initialized with an account)
|
|
26
26
|
* @param {number} params.expirySec - Unix timestamp when the permissions expire
|
|
@@ -2,13 +2,12 @@ import { AccountNotFoundError } from "@aa-sdk/core";
|
|
|
2
2
|
import { toHex, concatHex, serializeSignature, } from "viem";
|
|
3
3
|
import { signSignatureRequest } from "./signSignatureRequest.js";
|
|
4
4
|
import { metrics } from "../../metrics.js";
|
|
5
|
-
import { isWebAuthnSigner } from "../../utils.js";
|
|
6
5
|
/**
|
|
7
6
|
* Grants permissions to a smart account by creating a session.
|
|
8
7
|
* This allows another key to perform operations on behalf of the account.
|
|
9
8
|
*
|
|
10
9
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
11
|
-
* @param {SmartAccountSigner
|
|
10
|
+
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
12
11
|
* @param {GrantPermissionsParams} params - The parameters for granting permissions
|
|
13
12
|
* @param {Address} [params.account] - The account address (required if client was not initialized with an account)
|
|
14
13
|
* @param {number} params.expirySec - Unix timestamp when the permissions expire
|
|
@@ -66,9 +65,6 @@ export async function grantPermissions(client, signer, params) {
|
|
|
66
65
|
if (!account) {
|
|
67
66
|
throw new AccountNotFoundError();
|
|
68
67
|
}
|
|
69
|
-
if (isWebAuthnSigner(signer)) {
|
|
70
|
-
throw new Error("WebAuthn signer is not currently supported for grantPermissions");
|
|
71
|
-
}
|
|
72
68
|
const { sessionId, signatureRequest } = await client.request({
|
|
73
69
|
method: "wallet_createSession",
|
|
74
70
|
params: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grantPermissions.js","sourceRoot":"","sources":["../../../../src/client/actions/grantPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,KAAK,EAKL,SAAS,EACT,kBAAkB,GACnB,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACj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IAChC,CAAC;SAAM,CAAC;QACN,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC;QAC/B,IAAI,SAAS,IAAI,OAAO,EAAE,CAAC;YACzB,YAAY,GAAG,kBAAkB,CAAC;gBAChC,CAAC,EAAE,OAAO,CAAC,CAAC;gBACZ,CAAC,EAAE,OAAO,CAAC,CAAC;gBACZ,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;aACjC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,YAAY,GAAG,kBAAkB,CAAC;gBAChC,CAAC,EAAE,OAAO,CAAC,CAAC;gBACZ,CAAC,EAAE,OAAO,CAAC,CAAC;gBACZ,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;aACrB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,SAAS,CAAC;YACjB,MAAM,EAAE,cAAc;YACtB,SAAS;YACT,YAAY;SACb,CAAC;KACH,CAAC;AACJ,CAAC","sourcesContent":["import { AccountNotFoundError } from \"@aa-sdk/core\";\nimport {\n toHex,\n type Address,\n type Hex,\n type IsUndefined,\n type Prettify,\n concatHex,\n serializeSignature,\n} from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport type { WalletServerRpcSchemaType } from \"@alchemy/wallet-api-types/rpc\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport { metrics } from \"../../metrics.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\n\ntype RpcSchema = Extract<\n WalletServerRpcSchemaType,\n {\n Request: {\n method: \"wallet_createSession\";\n };\n }\n>;\n\nexport type GrantPermissionsParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Prettify<\n Omit<RpcSchema[\"Request\"][\"params\"][0], \"account\" | \"chainId\"> &\n (IsUndefined<TAccount> extends true\n ? { account: Address }\n : { account?: never })\n>;\n\nexport type GrantPermissionsResult = {\n context: Hex;\n};\n\n/**\n * Grants permissions to a smart account by creating a session.\n * This allows another key to perform operations on behalf of the account.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer of the smart account\n * @param {GrantPermissionsParams} params - The parameters for granting permissions\n * @param {Address} [params.account] - The account address (required if client was not initialized with an account)\n * @param {number} params.expirySec - Unix timestamp when the permissions expire\n * @param {sessionKeyData} params.key - The session key information\n * @param {string} params.key.publicKey - The public key of the session key\n * @param {string} params.key.type - The type of the key (e.g., \"secp256k1\")\n * @param {Array} params.permissions - Array of permission objects defining what the session key can do\n * @returns {Promise<GrantPermissionsResult>} A Promise that resolves to the result containing a context identifier\n *\n * @example\n * ```ts\n * // Create a session key and grant root permissions\n * const sessionKey = LocalAccountSigner.generatePrivateKeySigner();\n * const account = await client.requestAccount();\n *\n * const permissions = await client.grantPermissions({\n * account: account.address,\n * expirySec: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour from now\n * key: {\n * publicKey: await sessionKey.getAddress(),\n * type: \"secp256k1\",\n * },\n * permissions: [{ type: \"root\" }],\n * });\n *\n * // Use the permissions to prepare a call\n * const preparedCalls = await client.prepareCalls({\n * calls: [{ to: zeroAddress, value: \"0x0\" }],\n * from: account.address,\n * capabilities: {\n * paymasterService: {\n * policyId: \"your-paymaster-policy-id\",\n * },\n * permissions,\n * },\n * });\n *\n * // Sign with the session key\n * const signedCalls = await signPreparedCalls(sessionKey, preparedCalls);\n *\n * // Send the prepared call using the session key\n * const result = await client.sendPreparedCalls({\n * ...signedCalls,\n * capabilities: {\n * permissions,\n * },\n * });\n * ```\n */\nexport async function grantPermissions<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n signer: SmartWalletSigner,\n params: GrantPermissionsParams<TAccount>,\n): Promise<GrantPermissionsResult> {\n metrics.trackEvent({\n name: \"grant_permissions\",\n });\n\n const account = params.account ?? client.account?.address;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n const { sessionId, signatureRequest } = await client.request({\n method: \"wallet_createSession\",\n params: [\n {\n ...params,\n account,\n chainId: toHex(client.chain.id),\n },\n ],\n });\n\n const signature = await signSignatureRequest(signer, signatureRequest);\n\n let signatureHex: Hex;\n if (typeof signature.data === \"string\") {\n signatureHex = signature.data;\n } else {\n const sigData = signature.data;\n if (\"yParity\" in sigData) {\n signatureHex = serializeSignature({\n r: sigData.r,\n s: sigData.s,\n yParity: Number(sigData.yParity),\n });\n } else {\n signatureHex = serializeSignature({\n r: sigData.r,\n s: sigData.s,\n v: BigInt(sigData.v),\n });\n }\n }\n\n return {\n context: concatHex([\n \"0x00\", // remote mode\n sessionId,\n signatureHex,\n ]),\n };\n}\n"]}
|
|
@@ -2,26 +2,22 @@ import type { WalletServerRpcSchemaType } from "@alchemy/wallet-api-types/rpc";
|
|
|
2
2
|
import type { InnerWalletApiClient } from "../../types.ts";
|
|
3
3
|
import type { Address } from "viem";
|
|
4
4
|
import type { SmartWalletSigner } from "../index.js";
|
|
5
|
-
import type { WebAuthnPublicKey } from "@alchemy/wallet-api-types";
|
|
6
5
|
type RpcSchema = Extract<WalletServerRpcSchemaType, {
|
|
7
6
|
Request: {
|
|
8
7
|
method: "wallet_listAccounts";
|
|
9
8
|
};
|
|
10
9
|
}>;
|
|
11
|
-
export type ListAccountsParams = Omit<RpcSchema["Request"]["params"][0], "signerAddress" | "signerPublicKey"> &
|
|
12
|
-
signerAddress
|
|
13
|
-
}
|
|
14
|
-
signerPublicKey: WebAuthnPublicKey;
|
|
15
|
-
} | {});
|
|
10
|
+
export type ListAccountsParams = Omit<RpcSchema["Request"]["params"][0], "signerAddress" | "signerPublicKey"> & {
|
|
11
|
+
signerAddress?: Address;
|
|
12
|
+
};
|
|
16
13
|
export type ListAccountsResult = RpcSchema["ReturnType"];
|
|
17
14
|
/**
|
|
18
15
|
* Lists all smart accounts for a given signer using the wallet API client.
|
|
19
16
|
*
|
|
20
17
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
21
|
-
* @param {SmartAccountSigner
|
|
18
|
+
* @param {SmartAccountSigner} signer - The signer for which to list accounts
|
|
22
19
|
* @param {ListAccountsParams} params - Parameters for listing accounts
|
|
23
20
|
* @param {Address} [params.signerAddress] - The address of the signer to list accounts for
|
|
24
|
-
* @param {WebAuthnPublicKey} [params.signerPublicKey] - The public key of the signer to list accounts for
|
|
25
21
|
* @param {number} [params.limit] - Optional maximum number of accounts to return (default: 100, max: 100)
|
|
26
22
|
* @param {string} [params.after] - Optional pagination cursor for fetching subsequent pages
|
|
27
23
|
* @returns {Promise<ListAccountsResult>} A Promise that resolves to the list of accounts and pagination metadata
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { metrics } from "../../metrics.js";
|
|
2
|
-
import { credentialToWebAuthnPublicKey, isWebAuthnSigner, } from "../../utils.js";
|
|
3
2
|
/**
|
|
4
3
|
* Lists all smart accounts for a given signer using the wallet API client.
|
|
5
4
|
*
|
|
6
5
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
7
|
-
* @param {SmartAccountSigner
|
|
6
|
+
* @param {SmartAccountSigner} signer - The signer for which to list accounts
|
|
8
7
|
* @param {ListAccountsParams} params - Parameters for listing accounts
|
|
9
8
|
* @param {Address} [params.signerAddress] - The address of the signer to list accounts for
|
|
10
|
-
* @param {WebAuthnPublicKey} [params.signerPublicKey] - The public key of the signer to list accounts for
|
|
11
9
|
* @param {number} [params.limit] - Optional maximum number of accounts to return (default: 100, max: 100)
|
|
12
10
|
* @param {string} [params.after] - Optional pagination cursor for fetching subsequent pages
|
|
13
11
|
* @returns {Promise<ListAccountsResult>} A Promise that resolves to the list of accounts and pagination metadata
|
|
@@ -32,34 +30,15 @@ export async function listAccounts(client, signer, params) {
|
|
|
32
30
|
metrics.trackEvent({
|
|
33
31
|
name: "list_accounts",
|
|
34
32
|
});
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const signerArg = "signerAddress" in params
|
|
39
|
-
? { signerAddress: params.signerAddress }
|
|
40
|
-
: "signerPublicKey" in params
|
|
41
|
-
? {
|
|
42
|
-
signerPublicKey: {
|
|
43
|
-
...params.signerPublicKey,
|
|
44
|
-
type: "webauthn-p256",
|
|
45
|
-
},
|
|
46
|
-
}
|
|
47
|
-
: isWebAuthnSigner(signer)
|
|
48
|
-
? {
|
|
49
|
-
signerPublicKey: {
|
|
50
|
-
...credentialToWebAuthnPublicKey(signer.credential),
|
|
51
|
-
type: "webauthn-p256",
|
|
52
|
-
},
|
|
53
|
-
}
|
|
54
|
-
: {
|
|
55
|
-
signerAddress: await signer.getAddress(),
|
|
56
|
-
};
|
|
33
|
+
// signerAddress in params takes priority; otherwise fallback to client's attached signer
|
|
34
|
+
const signerAddress = params.signerAddress ?? (await signer.getAddress());
|
|
35
|
+
const { signerAddress: _signerAddress, ...rest } = params;
|
|
57
36
|
return client.request({
|
|
58
37
|
method: "wallet_listAccounts",
|
|
59
38
|
params: [
|
|
60
39
|
{
|
|
61
|
-
...
|
|
62
|
-
|
|
40
|
+
...rest,
|
|
41
|
+
signerAddress,
|
|
63
42
|
},
|
|
64
43
|
],
|
|
65
44
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listAccounts.js","sourceRoot":"","sources":["../../../../src/client/actions/listAccounts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"listAccounts.js","sourceRoot":"","sources":["../../../../src/client/actions/listAccounts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAmB3C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA4B,EAC5B,MAAyB,EACzB,MAA0B;IAE1B,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,eAAe;KACtB,CAAC,CAAC;IAEH,yFAAyF;IACzF,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,CAAC,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1E,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IAE1D,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE;YACN;gBACE,GAAG,IAAI;gBACP,aAAa;aACd;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { WalletServerRpcSchemaType } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport type { Address } from \"viem\";\nimport { metrics } from \"../../metrics.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\n\ntype RpcSchema = Extract<\n WalletServerRpcSchemaType,\n {\n Request: {\n method: \"wallet_listAccounts\";\n };\n }\n>;\n\nexport type ListAccountsParams = Omit<\n RpcSchema[\"Request\"][\"params\"][0],\n \"signerAddress\" | \"signerPublicKey\"\n> & { signerAddress?: Address };\n\nexport type ListAccountsResult = RpcSchema[\"ReturnType\"];\n\n/**\n * Lists all smart accounts for a given signer using the wallet API client.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer for which to list accounts\n * @param {ListAccountsParams} params - Parameters for listing accounts\n * @param {Address} [params.signerAddress] - The address of the signer to list accounts for\n * @param {number} [params.limit] - Optional maximum number of accounts to return (default: 100, max: 100)\n * @param {string} [params.after] - Optional pagination cursor for fetching subsequent pages\n * @returns {Promise<ListAccountsResult>} A Promise that resolves to the list of accounts and pagination metadata\n *\n * @example\n * ```ts\n * // Fetch the first page of accounts\n * const firstPage = await client.listAccounts({\n * signerAddress: \"0x123...\",\n * limit: 10\n * });\n *\n * // If an 'after' cursor exists, use it to fetch the next page\n * const nextPage = await client.listAccounts({\n * signerAddress: \"0x123...\",\n * limit: 10,\n * after: firstPage.meta.after\n * });\n * ```\n */\nexport async function listAccounts(\n client: InnerWalletApiClient,\n signer: SmartWalletSigner,\n params: ListAccountsParams,\n): Promise<ListAccountsResult> {\n metrics.trackEvent({\n name: \"list_accounts\",\n });\n\n // signerAddress in params takes priority; otherwise fallback to client's attached signer\n const signerAddress = params.signerAddress ?? (await signer.getAddress());\n const { signerAddress: _signerAddress, ...rest } = params;\n\n return client.request({\n method: \"wallet_listAccounts\",\n params: [\n {\n ...rest,\n signerAddress,\n },\n ],\n });\n}\n"]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SmartContractAccount } from "@aa-sdk/core";
|
|
2
2
|
import type { Address } from "abitype";
|
|
3
3
|
import type { WalletServerRpcSchemaType } from "@alchemy/wallet-api-types/rpc";
|
|
4
4
|
import type { InnerWalletApiClient } from "../../types.js";
|
|
5
5
|
import type { SmartWalletSigner } from "../index.js";
|
|
6
|
-
import type { WebAuthnPublicKey } from "@alchemy/wallet-api-types";
|
|
7
6
|
type RpcSchema = Extract<WalletServerRpcSchemaType, {
|
|
8
7
|
Request: {
|
|
9
8
|
method: "wallet_requestAccount";
|
|
@@ -11,9 +10,7 @@ type RpcSchema = Extract<WalletServerRpcSchemaType, {
|
|
|
11
10
|
}>;
|
|
12
11
|
export type RequestAccountParams = Omit<Extract<RpcSchema["Request"]["params"][0], {
|
|
13
12
|
signerAddress: Address;
|
|
14
|
-
} | {
|
|
15
|
-
signerPublicKey: WebAuthnPublicKey;
|
|
16
|
-
}>, "signerAddress" | "signerPublicKey" | "includeCounterfactualInfo"> & {
|
|
13
|
+
}>, "signerAddress" | "includeCounterfactualInfo"> & {
|
|
17
14
|
accountAddress?: Address;
|
|
18
15
|
};
|
|
19
16
|
export type RequestAccountResult = SmartContractAccount;
|
|
@@ -23,7 +20,7 @@ export type RequestAccountResult = SmartContractAccount;
|
|
|
23
20
|
* If an account already exists, the creationHint will be ignored.
|
|
24
21
|
*
|
|
25
22
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
26
|
-
* @param {SmartAccountSigner
|
|
23
|
+
* @param {SmartAccountSigner} signer - The signer that will be associated with the account
|
|
27
24
|
* @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account
|
|
28
25
|
* @param {string} [params.id] - Optional identifier for the account. If specified, a new account with this ID will be created even if one already exists for the signer
|
|
29
26
|
* @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { BaseError } from "@aa-sdk/core";
|
|
2
1
|
import deepEqual from "deep-equal";
|
|
3
2
|
import { custom } from "viem";
|
|
4
3
|
import { createAccount } from "../../internal/account.js";
|
|
5
|
-
import { credentialToWebAuthnPublicKey, isWebAuthnSigner, } from "../../utils.js";
|
|
6
4
|
/**
|
|
7
5
|
* Requests an account for the provided signer using the wallet API client.
|
|
8
6
|
* If an account already exists for the signer, it will always return that account unless a new ID is specified.
|
|
9
7
|
* If an account already exists, the creationHint will be ignored.
|
|
10
8
|
*
|
|
11
9
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
12
|
-
* @param {SmartAccountSigner
|
|
10
|
+
* @param {SmartAccountSigner} signer - The signer that will be associated with the account
|
|
13
11
|
* @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account
|
|
14
12
|
* @param {string} [params.id] - Optional identifier for the account. If specified, a new account with this ID will be created even if one already exists for the signer
|
|
15
13
|
* @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists
|
|
@@ -24,42 +22,18 @@ import { credentialToWebAuthnPublicKey, isWebAuthnSigner, } from "../../utils.js
|
|
|
24
22
|
*/
|
|
25
23
|
export async function requestAccount(client, signer, params) {
|
|
26
24
|
const { creationHint = {} } = params ?? {};
|
|
27
|
-
if (isWebAuthnSigner(signer)) {
|
|
28
|
-
if (creationHint.accountType &&
|
|
29
|
-
creationHint.accountType !== "mav2-webauthn") {
|
|
30
|
-
throw new BaseError("WebAuthn signers are only supported with mav2-webauthn account type");
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
// non-webauthn signers do not support the "mav2-webauthn" account type
|
|
35
|
-
if (creationHint.accountType === "mav2-webauthn") {
|
|
36
|
-
throw new BaseError("ECDSA (secp256k1) signers are not supported with mav2-webauthn account type");
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
25
|
const args = ((client.account && !params) || params?.accountAddress
|
|
40
26
|
? {
|
|
41
27
|
accountAddress: params?.accountAddress ?? client.account.address,
|
|
42
28
|
includeCounterfactualInfo: true,
|
|
43
29
|
}
|
|
44
30
|
: {
|
|
45
|
-
|
|
31
|
+
signerAddress: await signer.getAddress(),
|
|
32
|
+
...(creationHint
|
|
46
33
|
? {
|
|
47
|
-
|
|
48
|
-
...credentialToWebAuthnPublicKey(signer.credential),
|
|
49
|
-
type: "webauthn-p256",
|
|
50
|
-
},
|
|
51
|
-
...(creationHint
|
|
52
|
-
? { creationHint: creationHint }
|
|
53
|
-
: {}),
|
|
34
|
+
creationHint,
|
|
54
35
|
}
|
|
55
|
-
: {
|
|
56
|
-
signerAddress: await signer.getAddress(),
|
|
57
|
-
...(creationHint
|
|
58
|
-
? {
|
|
59
|
-
creationHint: creationHint,
|
|
60
|
-
}
|
|
61
|
-
: {}),
|
|
62
|
-
}),
|
|
36
|
+
: {}),
|
|
63
37
|
includeCounterfactualInfo: true,
|
|
64
38
|
});
|
|
65
39
|
const cachedAccount = client.internal.getAccount();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/requestAccount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"requestAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/requestAccount.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAG9B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAmB1D;;;;;;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AS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;QACnC,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAE7D,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { SmartContractAccount } from \"@aa-sdk/core\";\nimport type { Address } from \"abitype\";\nimport deepEqual from \"deep-equal\";\nimport { custom } from \"viem\";\nimport type { WalletServerRpcSchemaType } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClient } from \"../../types.js\";\nimport { createAccount } from \"../../internal/account.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\n\ntype RpcSchema = Extract<\n WalletServerRpcSchemaType,\n {\n Request: {\n method: \"wallet_requestAccount\";\n };\n }\n>;\n\nexport type RequestAccountParams = Omit<\n Extract<RpcSchema[\"Request\"][\"params\"][0], { signerAddress: Address }>,\n \"signerAddress\" | \"includeCounterfactualInfo\"\n> & { accountAddress?: Address };\n\nexport type RequestAccountResult = SmartContractAccount;\n\n/**\n * Requests an account for the provided signer using the wallet API client.\n * If an account already exists for the signer, it will always return that account unless a new ID is specified.\n * If an account already exists, the creationHint will be ignored.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer that will be associated with the account\n * @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account\n * @param {string} [params.id] - Optional identifier for the account. If specified, a new account with this ID will be created even if one already exists for the signer\n * @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists\n * @returns {Promise<RequestAccountResult>} A Promise that resolves to a SmartContractAccount instance\n *\n * @example\n * ```ts\n * // Request an account with default parameters using a local signer\n * const signer = LocalAccountSigner.privateKeyToAccountSigner(\"0x...\");\n * const account = await client.requestAccount(signer);\n * ```\n */\nexport async function requestAccount(\n client: InnerWalletApiClient,\n signer: SmartWalletSigner,\n params?: RequestAccountParams,\n): Promise<RequestAccountResult> {\n const { creationHint = {} } = params ?? {};\n\n const args = (\n (client.account && !params) || params?.accountAddress\n ? {\n accountAddress: params?.accountAddress ?? client.account!.address,\n includeCounterfactualInfo: true,\n }\n : {\n signerAddress: await signer.getAddress(),\n ...(creationHint\n ? {\n creationHint,\n }\n : {}),\n includeCounterfactualInfo: true,\n }\n ) satisfies RpcSchema[\"Request\"][\"params\"][0];\n\n const cachedAccount = client.internal.getAccount();\n\n if (\n cachedAccount &&\n ((args.accountAddress &&\n cachedAccount.account.address === args.accountAddress) ||\n deepEqual(cachedAccount.requestParams, args, { strict: true }))\n ) {\n return cachedAccount.account;\n }\n\n const { accountAddress, counterfactualInfo, delegation } =\n await client.request({\n method: \"wallet_requestAccount\",\n params: [args],\n });\n\n const account = await createAccount({\n accountAddress,\n counterfactualInfo,\n delegation,\n chain: client.chain,\n transport: custom(client.transport),\n signer,\n });\n\n client.internal.setAccount({ account, requestParams: args });\n\n return account;\n}\n"]}
|
|
@@ -14,12 +14,12 @@ export type SendCallsResult = SendPreparedCallsResult;
|
|
|
14
14
|
* </Note>
|
|
15
15
|
*
|
|
16
16
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
17
|
-
* @param {SmartAccountSigner
|
|
17
|
+
* @param {SmartAccountSigner} signer - The signer to use
|
|
18
18
|
* @param {PrepareCallsParams<TAccount>} params - Parameters for sending calls
|
|
19
19
|
* @param {Array<{to: Address, data?: Hex, value?: Hex}>} params.calls - Array of contract calls to execute
|
|
20
20
|
* @param {Address} [params.from] - The address to execute the calls from (required if the client wasn't initialized with an account)
|
|
21
21
|
* @param {object} [params.capabilities] - Optional capabilities to include with the request. See [API documentation](/wallets/api-reference/smart-wallets/wallet-api-endpoints/wallet-api-endpoints/wallet-prepare-calls#request.body.prepareCallsRequest.capabilities) for details.
|
|
22
|
-
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the
|
|
22
|
+
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the call ID.
|
|
23
23
|
*
|
|
24
24
|
* @example
|
|
25
25
|
* ```ts
|
|
@@ -34,8 +34,8 @@ export type SendCallsResult = SendPreparedCallsResult;
|
|
|
34
34
|
* }
|
|
35
35
|
* });
|
|
36
36
|
*
|
|
37
|
-
* // The result contains the
|
|
38
|
-
* console.log(result.
|
|
37
|
+
* // The result contains the call ID
|
|
38
|
+
* console.log(result.id);
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
41
|
export declare function sendCalls<TAccount extends Address | undefined = Address | undefined>(client: InnerWalletApiClient, signer: SmartWalletSigner, params: SendCallsParams<TAccount>): Promise<SendCallsResult>;
|
|
@@ -3,7 +3,6 @@ import { metrics } from "../../metrics.js";
|
|
|
3
3
|
import { signPreparedCalls } from "./signPreparedCalls.js";
|
|
4
4
|
import { sendPreparedCalls, } from "./sendPreparedCalls.js";
|
|
5
5
|
import { signSignatureRequest } from "./signSignatureRequest.js";
|
|
6
|
-
import { isWebAuthnSigner } from "../../utils.js";
|
|
7
6
|
import { extractCapabilitiesForSending } from "../../internal/capabilities.js";
|
|
8
7
|
/**
|
|
9
8
|
* Prepares, signs, and submits calls. This function internally calls `prepareCalls`, `signPreparedCalls`, and `sendPreparedCalls`.
|
|
@@ -14,12 +13,12 @@ import { extractCapabilitiesForSending } from "../../internal/capabilities.js";
|
|
|
14
13
|
* </Note>
|
|
15
14
|
*
|
|
16
15
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
17
|
-
* @param {SmartAccountSigner
|
|
16
|
+
* @param {SmartAccountSigner} signer - The signer to use
|
|
18
17
|
* @param {PrepareCallsParams<TAccount>} params - Parameters for sending calls
|
|
19
18
|
* @param {Array<{to: Address, data?: Hex, value?: Hex}>} params.calls - Array of contract calls to execute
|
|
20
19
|
* @param {Address} [params.from] - The address to execute the calls from (required if the client wasn't initialized with an account)
|
|
21
20
|
* @param {object} [params.capabilities] - Optional capabilities to include with the request. See [API documentation](/wallets/api-reference/smart-wallets/wallet-api-endpoints/wallet-api-endpoints/wallet-prepare-calls#request.body.prepareCallsRequest.capabilities) for details.
|
|
22
|
-
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the
|
|
21
|
+
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the call ID.
|
|
23
22
|
*
|
|
24
23
|
* @example
|
|
25
24
|
* ```ts
|
|
@@ -34,8 +33,8 @@ import { extractCapabilitiesForSending } from "../../internal/capabilities.js";
|
|
|
34
33
|
* }
|
|
35
34
|
* });
|
|
36
35
|
*
|
|
37
|
-
* // The result contains the
|
|
38
|
-
* console.log(result.
|
|
36
|
+
* // The result contains the call ID
|
|
37
|
+
* console.log(result.id);
|
|
39
38
|
* ```
|
|
40
39
|
*/
|
|
41
40
|
export async function sendCalls(client, signer, params) {
|
|
@@ -44,9 +43,6 @@ export async function sendCalls(client, signer, params) {
|
|
|
44
43
|
});
|
|
45
44
|
let calls = await prepareCalls(client, params);
|
|
46
45
|
if (calls.type === "paymaster-permit") {
|
|
47
|
-
if (isWebAuthnSigner(signer)) {
|
|
48
|
-
throw new Error("WebAuthn signer is not currently supported for signing paymaster permit signatures");
|
|
49
|
-
}
|
|
50
46
|
const signature = await signSignatureRequest(signer, calls.signatureRequest);
|
|
51
47
|
const secondCallParams = {
|
|
52
48
|
from: calls.modifiedRequest.from,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/sendCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAA2B,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,iBAAiB,GAElB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,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MAAM,CAAC,YAAY,CAAC,CAAC;IAExE,OAAO,MAAM,iBAAiB,CAAC,MAAM,EAAE;QACrC,GAAG,WAAW;QACd,GAAG,CAAC,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Address } from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.js\";\nimport { prepareCalls, type PrepareCallsParams } from \"./prepareCalls.js\";\nimport { metrics } from \"../../metrics.js\";\nimport { signPreparedCalls } from \"./signPreparedCalls.js\";\nimport {\n sendPreparedCalls,\n type SendPreparedCallsResult,\n} from \"./sendPreparedCalls.js\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\nimport { extractCapabilitiesForSending } from \"../../internal/capabilities.js\";\n\nexport type SendCallsParams<\n TAccount extends Address | undefined = Address | undefined,\n> = PrepareCallsParams<TAccount>;\n\nexport type SendCallsResult = SendPreparedCallsResult;\n\n/**\n * Prepares, signs, and submits calls. This function internally calls `prepareCalls`, `signPreparedCalls`, and `sendPreparedCalls`.\n *\n * <Note>\n * If using this action with an ERC-20 paymaster in pre-operation mode with `autoPermit`, the contents of the permit will be hidden\n * from the user. It is recommended to use the `prepareCalls` action instead to manually handle the permit signature.\n * </Note>\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer to use\n * @param {PrepareCallsParams<TAccount>} params - Parameters for sending calls\n * @param {Array<{to: Address, data?: Hex, value?: Hex}>} params.calls - Array of contract calls to execute\n * @param {Address} [params.from] - The address to execute the calls from (required if the client wasn't initialized with an account)\n * @param {object} [params.capabilities] - Optional capabilities to include with the request. See [API documentation](/wallets/api-reference/smart-wallets/wallet-api-endpoints/wallet-api-endpoints/wallet-prepare-calls#request.body.prepareCallsRequest.capabilities) for details.\n * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the call ID.\n *\n * @example\n * ```ts\n * const result = await client.sendCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: \"0x0\"\n * }],\n * capabilities: {\n * paymasterService: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // The result contains the call ID\n * console.log(result.id);\n * ```\n */\nexport async function sendCalls<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n signer: SmartWalletSigner,\n params: SendCallsParams<TAccount>,\n): Promise<SendCallsResult> {\n metrics.trackEvent({\n name: \"send_calls\",\n });\n\n let calls = await prepareCalls(client, params);\n\n if (calls.type === \"paymaster-permit\") {\n const signature = await signSignatureRequest(\n signer,\n calls.signatureRequest,\n );\n\n const secondCallParams = {\n from: calls.modifiedRequest.from,\n calls: calls.modifiedRequest.calls,\n capabilities: calls.modifiedRequest.capabilities,\n paymasterPermitSignature: signature,\n };\n\n calls = await prepareCalls(client, secondCallParams);\n }\n\n const signedCalls = await signPreparedCalls(signer, calls);\n\n const capabilities = extractCapabilitiesForSending(params.capabilities);\n\n return await sendPreparedCalls(client, {\n ...signedCalls,\n ...(capabilities != null ? { capabilities } : {}),\n });\n}\n"]}
|
|
@@ -13,7 +13,7 @@ export type SendPreparedCallsResult = RpcSchema["ReturnType"];
|
|
|
13
13
|
*
|
|
14
14
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
15
15
|
* @param {SendPreparedCallsParams} params - Parameters for sending prepared calls
|
|
16
|
-
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the
|
|
16
|
+
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the call ID
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* ```ts
|
|
@@ -7,7 +7,7 @@ import { mergeClientCapabilities } from "../../internal/capabilities.js";
|
|
|
7
7
|
*
|
|
8
8
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
9
9
|
* @param {SendPreparedCallsParams} params - Parameters for sending prepared calls
|
|
10
|
-
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the
|
|
10
|
+
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the call ID
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAG7B,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAiBzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,MAA+B;IAE/B,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB;KACF,CAAC,CAAC;IAEH,MAAM,CAAC,YAAY,GAAG,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;IAE3E,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE;YACN,MAAM,CAAC,IAAI,KAAK,OAAO;gBACrB,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC;oBACE,GAAG,MAAM;oBACT,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;iBAChC;SACN;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { toHex } from \"viem\";\nimport type { WalletServerRpcSchemaType } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClient, WithoutChainId } from \"../../types.ts\";\nimport { metrics } from \"../../metrics.js\";\nimport { mergeClientCapabilities } from \"../../internal/capabilities.js\";\n\ntype RpcSchema = Extract<\n WalletServerRpcSchemaType,\n {\n Request: {\n method: \"wallet_sendPreparedCalls\";\n };\n }\n>;\n\nexport type SendPreparedCallsParams = WithoutChainId<\n RpcSchema[\"Request\"][\"params\"][0]\n>;\n\nexport type SendPreparedCallsResult = RpcSchema[\"ReturnType\"];\n\n/**\n * Sends prepared calls by submitting a signed user operation.\n * This method is used after signing the signature request returned from prepareCalls.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SendPreparedCallsParams} params - Parameters for sending prepared calls\n * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the
|
|
1
|
+
{"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAG7B,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAiBzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,MAA+B;IAE/B,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB;KACF,CAAC,CAAC;IAEH,MAAM,CAAC,YAAY,GAAG,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;IAE3E,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE;YACN,MAAM,CAAC,IAAI,KAAK,OAAO;gBACrB,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC;oBACE,GAAG,MAAM;oBACT,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;iBAChC;SACN;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { toHex } from \"viem\";\nimport type { WalletServerRpcSchemaType } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClient, WithoutChainId } from \"../../types.ts\";\nimport { metrics } from \"../../metrics.js\";\nimport { mergeClientCapabilities } from \"../../internal/capabilities.js\";\n\ntype RpcSchema = Extract<\n WalletServerRpcSchemaType,\n {\n Request: {\n method: \"wallet_sendPreparedCalls\";\n };\n }\n>;\n\nexport type SendPreparedCallsParams = WithoutChainId<\n RpcSchema[\"Request\"][\"params\"][0]\n>;\n\nexport type SendPreparedCallsResult = RpcSchema[\"ReturnType\"];\n\n/**\n * Sends prepared calls by submitting a signed user operation.\n * This method is used after signing the signature request returned from prepareCalls.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SendPreparedCallsParams} params - Parameters for sending prepared calls\n * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the call ID\n *\n * @example\n * ```ts\n * // First prepare the calls\n * const preparedCalls = await client.prepareCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: \"0x0\"\n * }],\n * capabilities: {\n * paymasterService: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // Then sign the calls\n * const signedCalls = await client.signPreparedCalls(preparedCalls);\n *\n * // Then send the prepared calls with the signature\n * const result = await client.sendPreparedCalls({\n * signedCalls,\n * });\n * ```\n */\nexport async function sendPreparedCalls(\n client: InnerWalletApiClient,\n params: SendPreparedCallsParams,\n): Promise<SendPreparedCallsResult> {\n metrics.trackEvent({\n name: \"send_prepared_calls\",\n data: {\n type: params.type,\n },\n });\n\n params.capabilities = mergeClientCapabilities(client, params.capabilities);\n\n return client.request({\n method: \"wallet_sendPreparedCalls\",\n params: [\n params.type === \"array\"\n ? params\n : {\n ...params,\n chainId: toHex(client.chain.id),\n },\n ],\n });\n}\n"]}
|
|
@@ -11,7 +11,7 @@ export type SignMessageResult = Hex;
|
|
|
11
11
|
* This method requests the account associated with the signer and uses it to sign the message.
|
|
12
12
|
*
|
|
13
13
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
14
|
-
* @param {SmartAccountSigner
|
|
14
|
+
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
15
15
|
* @param {SignMessageParams} params - Parameters for signing the message
|
|
16
16
|
* @param {SignableMessage} params.message - The message to sign using EIP-191. Can be a string, or object with raw bytes.
|
|
17
17
|
* @param {Address} [params.account] - Optional account address to use for signing. If not provided, uses the client's current account.
|
|
@@ -5,7 +5,7 @@ import { metrics } from "../../metrics.js";
|
|
|
5
5
|
* This method requests the account associated with the signer and uses it to sign the message.
|
|
6
6
|
*
|
|
7
7
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
8
|
-
* @param {SmartAccountSigner
|
|
8
|
+
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
9
9
|
* @param {SignMessageParams} params - Parameters for signing the message
|
|
10
10
|
* @param {SignableMessage} params.message - The message to sign using EIP-191. Can be a string, or object with raw bytes.
|
|
11
11
|
* @param {Address} [params.account] - Optional account address to use for signing. If not provided, uses the client's current account.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signMessage.js","sourceRoot":"","sources":["../../../../src/client/actions/signMessage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAO3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAA4B,EAC5B,MAAyB,EACzB,MAAyB;IAEzB,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,cAAc;KACrB,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE;QACnD,cAAc,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO;KAC1D,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import type { Address, Hex, SignableMessage } from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport { requestAccount } from \"./requestAccount.js\";\nimport { metrics } from \"../../metrics.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\n\nexport type SignMessageParams = { message: SignableMessage; account?: Address };\n\nexport type SignMessageResult = Hex;\n\n/**\n * Signs a message using the smart account.\n * This method requests the account associated with the signer and uses it to sign the message.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner
|
|
1
|
+
{"version":3,"file":"signMessage.js","sourceRoot":"","sources":["../../../../src/client/actions/signMessage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAO3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAA4B,EAC5B,MAAyB,EACzB,MAAyB;IAEzB,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,cAAc;KACrB,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE;QACnD,cAAc,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO;KAC1D,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import type { Address, Hex, SignableMessage } from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport { requestAccount } from \"./requestAccount.js\";\nimport { metrics } from \"../../metrics.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\n\nexport type SignMessageParams = { message: SignableMessage; account?: Address };\n\nexport type SignMessageResult = Hex;\n\n/**\n * Signs a message using the smart account.\n * This method requests the account associated with the signer and uses it to sign the message.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer of the smart account\n * @param {SignMessageParams} params - Parameters for signing the message\n * @param {SignableMessage} params.message - The message to sign using EIP-191. Can be a string, or object with raw bytes.\n * @param {Address} [params.account] - Optional account address to use for signing. If not provided, uses the client's current account.\n * @returns {Promise<SignMessageResult>} A Promise that resolves to the signed message as a hex string\n *\n * @example\n * ```ts\n * // Sign a simple text message\n * const signature = await client.signMessage(\"Hello, world!\");\n *\n * // Sign a raw hex message\n * const signature = await client.signMessage({ raw: \"0x48656c6c6f2c20776f726c6421\" });\n * ```\n */\nexport async function signMessage(\n client: InnerWalletApiClient,\n signer: SmartWalletSigner,\n params: SignMessageParams,\n): Promise<SignMessageResult> {\n metrics.trackEvent({\n name: \"sign_message\",\n });\n\n const account = await requestAccount(client, signer, {\n accountAddress: params.account ?? client.account?.address,\n });\n\n return account.signMessageWith6492({ message: params.message });\n}\n"]}
|
|
@@ -11,7 +11,7 @@ export type SignPreparedCallsResult = RpcSchema["Request"]["params"][0];
|
|
|
11
11
|
/**
|
|
12
12
|
* Signs prepared calls using the provided signer.
|
|
13
13
|
*
|
|
14
|
-
* @param {SmartAccountSigner
|
|
14
|
+
* @param {SmartAccountSigner} signer - The signer to use
|
|
15
15
|
* @param {SignPreparedCallsParams} params - The prepared calls with signature requests
|
|
16
16
|
* @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls
|
|
17
17
|
*/
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BaseError } from "@aa-sdk/core";
|
|
2
2
|
import { signSignatureRequest } from "./signSignatureRequest.js";
|
|
3
3
|
import { metrics } from "../../metrics.js";
|
|
4
|
-
import { assertNever
|
|
4
|
+
import { assertNever } from "../../utils.js";
|
|
5
5
|
/**
|
|
6
6
|
* Signs prepared calls using the provided signer.
|
|
7
7
|
*
|
|
8
|
-
* @param {SmartAccountSigner
|
|
8
|
+
* @param {SmartAccountSigner} signer - The signer to use
|
|
9
9
|
* @param {SignPreparedCallsParams} params - The prepared calls with signature requests
|
|
10
10
|
* @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls
|
|
11
11
|
*/
|
|
@@ -18,9 +18,6 @@ export async function signPreparedCalls(signer, params) {
|
|
|
18
18
|
});
|
|
19
19
|
const signAuthorizationCall = async (call) => {
|
|
20
20
|
const { signatureRequest: _signatureRequest, ...rest } = call;
|
|
21
|
-
if (isWebAuthnSigner(signer)) {
|
|
22
|
-
throw new Error("WebAuthn account cannot sign EIP-7702 authorization requests");
|
|
23
|
-
}
|
|
24
21
|
const signature = await signSignatureRequest(signer, {
|
|
25
22
|
type: "eip7702Auth",
|
|
26
23
|
data: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/signPreparedCalls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAOjE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"signPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/signPreparedCalls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAOjE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAgB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AAC,CAAC,qBAAqB,CAAC,IAAI,CAAC;gBAC7B,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAChC,CACF;SACF,CAAC;IACJ,CAAC;SAAM,IACL,MAAM,CAAC,IAAI,KAAK,qBAAqB;QACrC,MAAM,CAAC,IAAI,KAAK,qBAAqB,EACrC,CAAC;QACD,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;SAAM,IAAI,MAAM,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QAC9C,MAAM,IAAI,SAAS,CACjB,qBAAqB,MAAM,CAAC,IAAI,6BAA6B,CAC9D,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,WAAW,CAChB,MAAM,EACN,2BAA2B,MAAM,6BAA6B,CAC/D,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { PrepareCallsResult } from \"./prepareCalls.ts\";\nimport { BaseError } from \"@aa-sdk/core\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport type { WalletServerRpcSchemaType } from \"@alchemy/wallet-api-types/rpc\";\nimport type {\n PreparedCall_Authorization,\n PreparedCall_UserOpV060,\n PreparedCall_UserOpV070,\n} from \"@alchemy/wallet-api-types\";\nimport { metrics } from \"../../metrics.js\";\nimport { assertNever } from \"../../utils.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\n\ntype RpcSchema = Extract<\n WalletServerRpcSchemaType,\n {\n Request: {\n method: \"wallet_sendPreparedCalls\";\n };\n }\n>;\n\nexport type SignPreparedCallsParams = PrepareCallsResult;\n\nexport type SignPreparedCallsResult = RpcSchema[\"Request\"][\"params\"][0];\n\n/**\n * Signs prepared calls using the provided signer.\n *\n * @param {SmartAccountSigner} signer - The signer to use\n * @param {SignPreparedCallsParams} params - The prepared calls with signature requests\n * @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls\n */\nexport async function signPreparedCalls(\n signer: SmartWalletSigner,\n params: SignPreparedCallsParams,\n): Promise<SignPreparedCallsResult> {\n metrics.trackEvent({\n name: \"sign_prepared_calls\",\n data: {\n type: params.type,\n },\n });\n\n const signAuthorizationCall = async (call: PreparedCall_Authorization) => {\n const { signatureRequest: _signatureRequest, ...rest } = call;\n const signature = await signSignatureRequest(signer, {\n type: \"eip7702Auth\",\n data: {\n ...rest.data,\n chainId: call.chainId,\n },\n });\n return {\n ...rest,\n signature,\n };\n };\n\n const signUserOperationCall = async (\n call: PreparedCall_UserOpV060 | PreparedCall_UserOpV070,\n ) => {\n const { signatureRequest, ...rest } = call;\n\n if (!signatureRequest) {\n throw new BaseError(\n \"Signature request is required for signing user operation calls. Ensure `onlyEstimation` is set to `false` when calling `prepareCalls`.\",\n );\n }\n\n const signature = await signSignatureRequest(signer, signatureRequest);\n return {\n ...rest,\n signature,\n };\n };\n\n if (params.type === \"array\") {\n return {\n type: \"array\" as const,\n data: await Promise.all(\n params.data.map((call) =>\n call.type === \"authorization\"\n ? signAuthorizationCall(call)\n : signUserOperationCall(call),\n ),\n ),\n };\n } else if (\n params.type === \"user-operation-v060\" ||\n params.type === \"user-operation-v070\"\n ) {\n return signUserOperationCall(params);\n } else if (params.type === \"paymaster-permit\") {\n throw new BaseError(\n `Invalid call type ${params.type} for signing prepared calls`,\n );\n } else {\n return assertNever(\n params,\n `Unexpected call type in ${params} for signing prepared calls`,\n );\n }\n}\n"]}
|