@account-kit/wallet-client 0.1.0-alpha.1 → 0.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/capabilities/permissions/mav2.d.ts +2 -2
- package/dist/esm/capabilities/permissions/mav2.js.map +1 -1
- package/dist/esm/client/actions/createAccount.d.ts +27 -2
- package/dist/esm/client/actions/createAccount.js +25 -0
- package/dist/esm/client/actions/createAccount.js.map +1 -1
- package/dist/esm/client/actions/getCallsStatus.d.ts +21 -2
- package/dist/esm/client/actions/getCallsStatus.js.map +1 -1
- package/dist/esm/client/actions/grantPermissions.d.ts +60 -2
- package/dist/esm/client/actions/grantPermissions.js.map +1 -1
- package/dist/esm/client/actions/listAccounts.d.ts +26 -2
- package/dist/esm/client/actions/listAccounts.js +24 -0
- package/dist/esm/client/actions/listAccounts.js.map +1 -1
- package/dist/esm/client/actions/prepareCalls.d.ts +28 -2
- package/dist/esm/client/actions/prepareCalls.js.map +1 -1
- package/dist/esm/client/actions/requestAccount.d.ts +21 -2
- package/dist/esm/client/actions/requestAccount.js +14 -3
- package/dist/esm/client/actions/requestAccount.js.map +1 -1
- package/dist/esm/client/actions/sendPreparedCalls.d.ts +39 -2
- package/dist/esm/client/actions/sendPreparedCalls.js +37 -0
- package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/client/actions/signMessage.d.ts +22 -2
- package/dist/esm/client/actions/signMessage.js +4 -2
- package/dist/esm/client/actions/signMessage.js.map +1 -1
- package/dist/esm/client/actions/signSignatureRequest.d.ts +31 -0
- package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
- package/dist/esm/client/actions/signTypedData.d.ts +35 -2
- package/dist/esm/client/actions/signTypedData.js +3 -1
- package/dist/esm/client/actions/signTypedData.js.map +1 -1
- package/dist/esm/client/client.e2e-test.js +99 -11
- package/dist/esm/client/client.e2e-test.js.map +1 -1
- package/dist/esm/client/decorator.d.ts +7 -5
- package/dist/esm/client/decorator.js +1 -1
- package/dist/esm/client/decorator.js.map +1 -1
- package/dist/esm/client/index.d.ts +4 -4
- package/dist/esm/client/index.js +29 -3
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/exports/index.d.ts +1 -0
- package/dist/esm/exports/index.js +1 -0
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/internal.d.ts +1 -1
- 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/local/client.d.ts +1 -1
- package/dist/esm/local/client.js +8 -1
- package/dist/esm/local/client.js.map +1 -1
- package/dist/esm/remote/client.d.ts +1 -1
- package/dist/esm/remote/client.js +6 -1
- package/dist/esm/remote/client.js.map +1 -1
- package/dist/esm/rpc/schema.d.ts +1 -1
- package/dist/esm/types.d.ts +15 -4
- package/dist/esm/types.js.map +1 -1
- package/dist/types/capabilities/permissions/mav2.d.ts +2 -2
- package/dist/types/capabilities/permissions/mav2.d.ts.map +1 -1
- package/dist/types/client/actions/createAccount.d.ts +27 -2
- package/dist/types/client/actions/createAccount.d.ts.map +1 -1
- package/dist/types/client/actions/getCallsStatus.d.ts +21 -2
- package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
- package/dist/types/client/actions/grantPermissions.d.ts +60 -2
- package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
- package/dist/types/client/actions/listAccounts.d.ts +26 -2
- package/dist/types/client/actions/listAccounts.d.ts.map +1 -1
- package/dist/types/client/actions/prepareCalls.d.ts +28 -2
- package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/client/actions/requestAccount.d.ts +21 -2
- package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
- package/dist/types/client/actions/sendPreparedCalls.d.ts +39 -2
- package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/client/actions/signMessage.d.ts +22 -2
- package/dist/types/client/actions/signMessage.d.ts.map +1 -1
- package/dist/types/client/actions/signSignatureRequest.d.ts +31 -0
- package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
- package/dist/types/client/actions/signTypedData.d.ts +35 -2
- package/dist/types/client/actions/signTypedData.d.ts.map +1 -1
- package/dist/types/client/decorator.d.ts +7 -5
- package/dist/types/client/decorator.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +4 -4
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +1 -0
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/exports/internal.d.ts +1 -1
- 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/local/client.d.ts +1 -1
- package/dist/types/local/client.d.ts.map +1 -1
- package/dist/types/remote/client.d.ts +1 -1
- package/dist/types/remote/client.d.ts.map +1 -1
- package/dist/types/rpc/schema.d.ts +1 -1
- package/dist/types/types.d.ts +15 -4
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +8 -6
- package/src/capabilities/permissions/mav2.ts +2 -2
- package/src/client/actions/createAccount.ts +27 -2
- package/src/client/actions/getCallsStatus.ts +21 -2
- package/src/client/actions/grantPermissions.ts +60 -2
- package/src/client/actions/listAccounts.ts +26 -2
- package/src/client/actions/prepareCalls.ts +28 -2
- package/src/client/actions/requestAccount.ts +40 -5
- package/src/client/actions/sendPreparedCalls.ts +39 -2
- package/src/client/actions/signMessage.ts +24 -4
- package/src/client/actions/signSignatureRequest.ts +31 -0
- package/src/client/actions/signTypedData.ts +39 -3
- package/src/client/client.e2e-test.ts +120 -11
- package/src/client/decorator.ts +10 -12
- package/src/client/index.ts +41 -10
- package/src/exports/index.ts +1 -0
- package/src/exports/internal.ts +1 -1
- package/src/internal/decorator.ts +12 -0
- package/src/local/client.ts +52 -42
- package/src/remote/client.ts +10 -5
- package/src/types.ts +18 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Static } from "@sinclair/typebox";
|
|
2
2
|
import { type Hex } from "viem";
|
|
3
|
-
import type { PermissionsData } from ".";
|
|
4
|
-
import type { KeySigner } from "../../schemas";
|
|
3
|
+
import type { PermissionsData } from "./index.ts";
|
|
4
|
+
import type { KeySigner } from "../../schemas.ts";
|
|
5
5
|
export declare const SESSION_ID_LENGTH_BYTES = 16;
|
|
6
6
|
export declare const ENTITY_ID_LENGTH_BYTES = 4;
|
|
7
7
|
export declare const PermissionsContextVersion: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mav2.js","sourceRoot":"","sources":["../../../../src/capabilities/permissions/mav2.ts"],"names":[],"mappings":"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","sourcesContent":["import { PermissionType } from \"@account-kit/smart-contracts/experimental\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { concatHex, sliceHex, type Hex } from \"viem\";\nimport type { PermissionsData } from \"
|
|
1
|
+
{"version":3,"file":"mav2.js","sourceRoot":"","sources":["../../../../src/capabilities/permissions/mav2.ts"],"names":[],"mappings":"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","sourcesContent":["import { PermissionType } from \"@account-kit/smart-contracts/experimental\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { concatHex, sliceHex, type Hex } from \"viem\";\nimport type { PermissionsData } from \"./index.ts\";\nimport type { KeySigner } from \"../../schemas.ts\";\nimport { assertNever } from \"../../utils.js\";\n\nexport const SESSION_ID_LENGTH_BYTES = 16;\nexport const ENTITY_ID_LENGTH_BYTES = 4;\n\nexport const PermissionsContextVersion = {\n REMOTE_MODE_DEFERRED_ACTION: \"0x00\",\n LOCAL_MODE_DEFERRED_ACTION: \"0x01\",\n NON_DEFERRED_ACTION: \"0x02\",\n} as const;\n\ntype ContextVersionHex =\n (typeof PermissionsContextVersion)[keyof typeof PermissionsContextVersion];\n\ntype DecodedPermissionsContext = {\n contextVersion: keyof typeof PermissionsContextVersion;\n} & (\n | {\n contextVersion: \"REMOTE_MODE_DEFERRED_ACTION\";\n sessionId: Hex;\n signature: Hex;\n deferredAction?: never;\n }\n | {\n contextVersion: \"LOCAL_MODE_DEFERRED_ACTION\";\n deferredAction: Hex;\n sessionId?: never;\n signature?: never;\n }\n | {\n contextVersion: \"NON_DEFERRED_ACTION\";\n deferredAction?: never;\n sessionId?: never;\n signature?: never;\n entityId: Hex;\n isGlobalValidation: boolean;\n }\n);\n\nexport const encodePermissionsContext = (\n context: DecodedPermissionsContext,\n): Hex => {\n switch (context.contextVersion) {\n case \"REMOTE_MODE_DEFERRED_ACTION\":\n return concatHex([\n PermissionsContextVersion.REMOTE_MODE_DEFERRED_ACTION,\n context.sessionId,\n context.signature,\n ]);\n case \"LOCAL_MODE_DEFERRED_ACTION\":\n return concatHex([\n PermissionsContextVersion.LOCAL_MODE_DEFERRED_ACTION,\n context.deferredAction,\n ]);\n case \"NON_DEFERRED_ACTION\":\n return concatHex([\n PermissionsContextVersion.NON_DEFERRED_ACTION,\n context.isGlobalValidation ? \"0x01\" : \"0x00\",\n context.entityId,\n ]);\n default:\n return assertNever(context, \"Unexpected context version\");\n }\n};\n\nexport const decodePermissionsContext = (\n input: Hex,\n): DecodedPermissionsContext => {\n const contextVersion = sliceHex(input, 0, 1) as ContextVersionHex;\n switch (contextVersion) {\n case \"0x00\": {\n const sessionId = sliceHex(input, 1, SESSION_ID_LENGTH_BYTES + 1);\n const signature = sliceHex(input, SESSION_ID_LENGTH_BYTES + 1);\n return {\n contextVersion: \"REMOTE_MODE_DEFERRED_ACTION\",\n sessionId,\n signature,\n };\n }\n case \"0x01\": {\n const deferredAction = sliceHex(input, 1);\n return {\n contextVersion: \"LOCAL_MODE_DEFERRED_ACTION\",\n deferredAction,\n };\n }\n case \"0x02\": {\n const isGlobalValidation = sliceHex(input, 1, 2) === \"0x01\";\n const entityId = sliceHex(input, 2, ENTITY_ID_LENGTH_BYTES + 2);\n return {\n contextVersion: \"NON_DEFERRED_ACTION\",\n isGlobalValidation,\n entityId,\n };\n }\n default:\n return assertNever(\n contextVersion,\n `Unexpected context version: ${contextVersion}`,\n );\n }\n};\n\nexport const prefixSignatureKeyType = (\n sig: Hex,\n type: KeySigner[\"type\"],\n): Hex => {\n switch (type) {\n case \"secp256k1\":\n return concatHex([\"0x00\", sig]);\n case \"contract\":\n return concatHex([\"0x01\", sig]);\n default:\n return assertNever(type, \"Unexpected session key type\");\n }\n};\n\nexport const isGlobalValidation = (\n data: Pick<Static<typeof PermissionsData>, \"permissions\">,\n): boolean => {\n return data.permissions.some((p) => p.type === PermissionType.ROOT);\n};\n"]}
|
|
@@ -1,10 +1,35 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import type { Static } from "@sinclair/typebox";
|
|
3
3
|
import type { Address } from "abitype";
|
|
4
|
-
import type { wallet_createAccount } from "../../rpc/request";
|
|
5
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
4
|
+
import type { wallet_createAccount } from "../../rpc/request.ts";
|
|
5
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
6
6
|
export type CreateAccountParams = Omit<Extract<Static<typeof wallet_createAccount>["Request"]["params"][0], {
|
|
7
7
|
signerAddress: Address;
|
|
8
8
|
}>, "signerAddress">;
|
|
9
9
|
export type CreateAccountResult = Static<typeof wallet_createAccount>["ReturnType"];
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new account for the provided signer using the wallet API client.
|
|
12
|
+
* This method is primarily used to import existing accounts.
|
|
13
|
+
* For most cases, you should use requestAccount instead.
|
|
14
|
+
* If the account already exists, an error will be thrown.
|
|
15
|
+
*
|
|
16
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
17
|
+
* @param {SmartAccountSigner} signer - The signer that will be associated with the account
|
|
18
|
+
* @param {CreateAccountParams} params - Parameters for creating the account
|
|
19
|
+
* @param {string} [params.id] - Optional UUID v4 identifier for the account
|
|
20
|
+
* @param {object} params.creationOptions - Options for account creation
|
|
21
|
+
* @param {string} [params.creationOptions.accountType] - Currently only "sma-b" (Modular Account v2) is supported
|
|
22
|
+
* @param {string} [params.creationOptions.salt] - Optional hex string to use as salt for account creation
|
|
23
|
+
* @returns {Promise<CreateAccountResult>} A Promise that resolves to the created account information
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Create a new account with a custom salt
|
|
27
|
+
* const account = await client.createAccount({
|
|
28
|
+
* creationOptions: {
|
|
29
|
+
* accountType: "sma-b",
|
|
30
|
+
* salt: "0x04"
|
|
31
|
+
* }
|
|
32
|
+
* });
|
|
33
|
+
* console.log(`Created account at address: ${account.accountAddress}`);
|
|
34
|
+
*/
|
|
10
35
|
export declare function createAccount(client: InnerWalletApiClient, signer: SmartAccountSigner, params: CreateAccountParams): Promise<CreateAccountResult>;
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new account for the provided signer using the wallet API client.
|
|
3
|
+
* This method is primarily used to import existing accounts.
|
|
4
|
+
* For most cases, you should use requestAccount instead.
|
|
5
|
+
* If the account already exists, an error will be thrown.
|
|
6
|
+
*
|
|
7
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
8
|
+
* @param {SmartAccountSigner} signer - The signer that will be associated with the account
|
|
9
|
+
* @param {CreateAccountParams} params - Parameters for creating the account
|
|
10
|
+
* @param {string} [params.id] - Optional UUID v4 identifier for the account
|
|
11
|
+
* @param {object} params.creationOptions - Options for account creation
|
|
12
|
+
* @param {string} [params.creationOptions.accountType] - Currently only "sma-b" (Modular Account v2) is supported
|
|
13
|
+
* @param {string} [params.creationOptions.salt] - Optional hex string to use as salt for account creation
|
|
14
|
+
* @returns {Promise<CreateAccountResult>} A Promise that resolves to the created account information
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Create a new account with a custom salt
|
|
18
|
+
* const account = await client.createAccount({
|
|
19
|
+
* creationOptions: {
|
|
20
|
+
* accountType: "sma-b",
|
|
21
|
+
* salt: "0x04"
|
|
22
|
+
* }
|
|
23
|
+
* });
|
|
24
|
+
* console.log(`Created account at address: ${account.accountAddress}`);
|
|
25
|
+
*/
|
|
1
26
|
export async function createAccount(client, signer, params) {
|
|
2
27
|
return client.request({
|
|
3
28
|
method: "wallet_createAccount",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/createAccount.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA4B,EAC5B,MAA0B,EAC1B,MAA2B;IAE3B,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,sBAAsB;QAC9B,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC,UAAU,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC;KAClE,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport type { Address } from \"abitype\";\nimport type { wallet_createAccount } from \"../../rpc/request\";\nimport type { InnerWalletApiClient } from \"../../types\";\n\nexport type CreateAccountParams = Omit<\n Extract<\n Static<typeof wallet_createAccount>[\"Request\"][\"params\"][0],\n { signerAddress: Address }\n >,\n \"signerAddress\"\n>;\n\nexport type CreateAccountResult = Static<\n typeof wallet_createAccount\n>[\"ReturnType\"];\n\nexport async function createAccount(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params: CreateAccountParams,\n): Promise<CreateAccountResult> {\n return client.request({\n method: \"wallet_createAccount\",\n params: [{ signerAddress: await signer.getAddress(), ...params }],\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"createAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/createAccount.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA4B,EAC5B,MAA0B,EAC1B,MAA2B;IAE3B,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,sBAAsB;QAC9B,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC,UAAU,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC;KAClE,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport type { Address } from \"abitype\";\nimport type { wallet_createAccount } from \"../../rpc/request.ts\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\n\nexport type CreateAccountParams = Omit<\n Extract<\n Static<typeof wallet_createAccount>[\"Request\"][\"params\"][0],\n { signerAddress: Address }\n >,\n \"signerAddress\"\n>;\n\nexport type CreateAccountResult = Static<\n typeof wallet_createAccount\n>[\"ReturnType\"];\n\n/**\n * Creates a new account for the provided signer using the wallet API client.\n * This method is primarily used to import existing accounts.\n * For most cases, you should use requestAccount instead.\n * If the account already exists, an error will be thrown.\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 {CreateAccountParams} params - Parameters for creating the account\n * @param {string} [params.id] - Optional UUID v4 identifier for the account\n * @param {object} params.creationOptions - Options for account creation\n * @param {string} [params.creationOptions.accountType] - Currently only \"sma-b\" (Modular Account v2) is supported\n * @param {string} [params.creationOptions.salt] - Optional hex string to use as salt for account creation\n * @returns {Promise<CreateAccountResult>} A Promise that resolves to the created account information\n *\n * @example\n * // Create a new account with a custom salt\n * const account = await client.createAccount({\n * creationOptions: {\n * accountType: \"sma-b\",\n * salt: \"0x04\"\n * }\n * });\n * console.log(`Created account at address: ${account.accountAddress}`);\n */\nexport async function createAccount(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params: CreateAccountParams,\n): Promise<CreateAccountResult> {\n return client.request({\n method: \"wallet_createAccount\",\n params: [{ signerAddress: await signer.getAddress(), ...params }],\n });\n}\n"]}
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import type { Address, JsonRpcAccount } from "viem";
|
|
2
|
-
import type { GetCallsStatusParams as IsomorphicGetCallsStatusParams, GetCallsStatusResponse as IsomorphicGetCallsStatusResult } from "../../isomorphic/actions/getCallsStatus";
|
|
3
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
2
|
+
import type { GetCallsStatusParams as IsomorphicGetCallsStatusParams, GetCallsStatusResponse as IsomorphicGetCallsStatusResult } from "../../isomorphic/actions/getCallsStatus.ts";
|
|
3
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
4
4
|
export type GetCallsStatusParams = IsomorphicGetCallsStatusParams;
|
|
5
5
|
export type GetCallsStatusResult = IsomorphicGetCallsStatusResult;
|
|
6
|
+
/**
|
|
7
|
+
* Gets the status of a prepared call by its ID.
|
|
8
|
+
* This method is used to check the execution status of calls sent via sendPreparedCalls.
|
|
9
|
+
*
|
|
10
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
11
|
+
* @param {GetCallsStatusParams} params - The ID of the prepared call to check
|
|
12
|
+
* @returns {Promise<GetCallsStatusResult>} A Promise that resolves to the status information including:
|
|
13
|
+
* - id: The hex ID of the call
|
|
14
|
+
* - chainId: The chain ID in hex format
|
|
15
|
+
* - status: The current status of the batch execution
|
|
16
|
+
* - receipts: Optional array of transaction receipts if the batch has been executed
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // After sending prepared calls
|
|
20
|
+
* const sendResult = await client.sendPreparedCalls({...});
|
|
21
|
+
*
|
|
22
|
+
* // Check the status of the first call ID
|
|
23
|
+
* const status = await client.getCallsStatus(sendResult.preparedCallIds[0]);
|
|
24
|
+
*/
|
|
6
25
|
export declare function getCallsStatus<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined>(client: InnerWalletApiClient<TAccount>, params: GetCallsStatusParams): Promise<GetCallsStatusResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../../src/client/actions/getCallsStatus.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../../src/client/actions/getCallsStatus.ts"],"names":[],"mappings":"AAuCA,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA4B;IAE5B,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 { Address, JsonRpcAccount } from \"viem\";\nimport type {\n GetCallsStatusParams as IsomorphicGetCallsStatusParams,\n GetCallsStatusResponse as IsomorphicGetCallsStatusResult,\n} from \"../../isomorphic/actions/getCallsStatus.ts\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\n\nexport type GetCallsStatusParams = IsomorphicGetCallsStatusParams;\n\nexport type GetCallsStatusResult = IsomorphicGetCallsStatusResult;\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 * // After sending prepared calls\n * const sendResult = await client.sendPreparedCalls({...});\n *\n * // Check the status of the first call ID\n * const status = await client.getCallsStatus(sendResult.preparedCallIds[0]);\n */\nexport async function getCallsStatus<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(\n client: InnerWalletApiClient<TAccount>,\n params: GetCallsStatusParams,\n): Promise<GetCallsStatusResult>;\n\nexport async function getCallsStatus(\n client: InnerWalletApiClient,\n params: GetCallsStatusParams,\n): Promise<GetCallsStatusResult> {\n return await client.request({\n method: \"wallet_getCallsStatus\",\n params: [params],\n });\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Address, type Hex, type IsUndefined, type JsonRpcAccount } from "viem";
|
|
2
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
2
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
3
3
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
4
|
-
import type { CreateSessionParams } from "../../isomorphic/actions/createSession";
|
|
4
|
+
import type { CreateSessionParams } from "../../isomorphic/actions/createSession.ts";
|
|
5
5
|
export type GrantPermissionsParams<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined> = Omit<CreateSessionParams, "account" | "chainId"> & (IsUndefined<TAccount> extends true ? {
|
|
6
6
|
account: Address;
|
|
7
7
|
} : {
|
|
@@ -10,4 +10,62 @@ export type GrantPermissionsParams<TAccount extends JsonRpcAccount<Address> | un
|
|
|
10
10
|
export type GrantPermissionsResult = {
|
|
11
11
|
context: Hex;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Grants permissions to a smart account by creating a session.
|
|
15
|
+
* This allows another key to perform operations on behalf of the account.
|
|
16
|
+
*
|
|
17
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
18
|
+
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
19
|
+
* @param {GrantPermissionsParams} params - The parameters for granting permissions
|
|
20
|
+
* @param {Address} [params.account] - The account address (required if client was not initialized with an account)
|
|
21
|
+
* @param {number} params.expiry - Unix timestamp when the permissions expire
|
|
22
|
+
* @param {object} params.key - The session key information
|
|
23
|
+
* @param {string} params.key.publicKey - The public key of the session key
|
|
24
|
+
* @param {string} params.key.type - The type of the key (e.g., "secp256k1")
|
|
25
|
+
* @param {Array} params.permissions - Array of permission objects defining what the session key can do
|
|
26
|
+
* @returns {Promise<GrantPermissionsResult>} A Promise that resolves to the result containing a context identifier
|
|
27
|
+
* @returns {Hex} result.context - A hex identifier for the granted permissions context
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Create a session key and grant root permissions
|
|
31
|
+
* const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
|
|
32
|
+
* const account = await client.requestAccount();
|
|
33
|
+
*
|
|
34
|
+
* const permissions = await client.grantPermissions({
|
|
35
|
+
* account: account.address,
|
|
36
|
+
* expiry: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour from now
|
|
37
|
+
* key: {
|
|
38
|
+
* publicKey: await sessionKey.getAddress(),
|
|
39
|
+
* type: "secp256k1",
|
|
40
|
+
* },
|
|
41
|
+
* permissions: [{ type: "root" }],
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* // Use the permissions to prepare a call
|
|
45
|
+
* const preparedUO = await client.prepareCalls({
|
|
46
|
+
* calls: [{ to: zeroAddress, value: "0x0" }],
|
|
47
|
+
* from: account.address,
|
|
48
|
+
* capabilities: {
|
|
49
|
+
* paymasterService: {
|
|
50
|
+
* policyId: "your-paymaster-policy-id",
|
|
51
|
+
* },
|
|
52
|
+
* permissions,
|
|
53
|
+
* },
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* // Sign with the session key
|
|
57
|
+
* const signature = await signSignatureRequest(
|
|
58
|
+
* sessionKey,
|
|
59
|
+
* preparedUO.signatureRequest,
|
|
60
|
+
* );
|
|
61
|
+
*
|
|
62
|
+
* // Send the prepared call using the session key
|
|
63
|
+
* const result = await client.sendPreparedCalls({
|
|
64
|
+
* ...preparedUO,
|
|
65
|
+
* signature,
|
|
66
|
+
* capabilities: {
|
|
67
|
+
* permissions,
|
|
68
|
+
* },
|
|
69
|
+
* });
|
|
70
|
+
*/
|
|
13
71
|
export declare function grantPermissions<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined>(client: InnerWalletApiClient<TAccount>, signer: SmartAccountSigner, params: GrantPermissionsParams<TAccount>): Promise<GrantPermissionsResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grantPermissions.js","sourceRoot":"","sources":["../../../../src/client/actions/grantPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,GACN,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"grantPermissions.js","sourceRoot":"","sources":["../../../../src/client/actions/grantPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,GACN,MAAM,MAAM,CAAC;AAsFd,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAA4B,EAC5B,MAA0B,EAC1B,MAA8B;IAE9B,IAAI,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAC1C,CAAC;IAED,OAAO,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE;QACrC,GAAG,MAAM;QACT,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;KAChC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n type Address,\n type Hex,\n type IsUndefined,\n type JsonRpcAccount,\n toHex,\n} from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { CreateSessionParams } from \"../../isomorphic/actions/createSession.ts\";\n\nexport type GrantPermissionsParams<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n> = Omit<CreateSessionParams, \"account\" | \"chainId\"> &\n (IsUndefined<TAccount> extends true\n ? { account: Address }\n : { account?: never });\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.expiry - Unix timestamp when the permissions expire\n * @param {object} 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 * @returns {Hex} result.context - A hex identifier for the granted permissions context\n *\n * @example\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 * expiry: 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 preparedUO = 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 signature = await signSignatureRequest(\n * sessionKey,\n * preparedUO.signatureRequest,\n * );\n *\n * // Send the prepared call using the session key\n * const result = await client.sendPreparedCalls({\n * ...preparedUO,\n * signature,\n * capabilities: {\n * permissions,\n * },\n * });\n */\nexport async function grantPermissions<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(\n client: InnerWalletApiClient<TAccount>,\n signer: SmartAccountSigner,\n params: GrantPermissionsParams<TAccount>,\n): Promise<GrantPermissionsResult>;\n\nexport async function grantPermissions(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params: GrantPermissionsParams,\n): Promise<GrantPermissionsResult> {\n if (client.account && !params.account) {\n params.account = client.account.address;\n }\n\n return client.grantPermissions(signer, {\n ...params,\n chainId: toHex(client.chain.id),\n });\n}\n"]}
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
import type { Static } from "@sinclair/typebox";
|
|
2
|
-
import type { wallet_listAccounts } from "../../rpc/request";
|
|
3
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
2
|
+
import type { wallet_listAccounts } from "../../rpc/request.ts";
|
|
3
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
4
4
|
export type ListAccountsParams = Static<typeof wallet_listAccounts>["Request"]["params"][0];
|
|
5
5
|
export type ListAccountsResult = Static<typeof wallet_listAccounts>["ReturnType"];
|
|
6
|
+
/**
|
|
7
|
+
* Lists all smart accounts for a given signer using the wallet API client.
|
|
8
|
+
*
|
|
9
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
10
|
+
* @param {ListAccountsParams} params - Parameters for listing accounts
|
|
11
|
+
* @param {string} params.signerAddress - The address of the signer to list accounts for
|
|
12
|
+
* @param {number} [params.limit] - Optional maximum number of accounts to return (default: 100, max: 100)
|
|
13
|
+
* @param {string} [params.after] - Optional pagination cursor for fetching subsequent pages
|
|
14
|
+
* @returns {Promise<ListAccountsResult>} A Promise that resolves to the list of accounts and pagination metadata
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Fetch the first page of accounts
|
|
18
|
+
* const firstPage = await client.listAccounts({
|
|
19
|
+
* signerAddress: "0x123...",
|
|
20
|
+
* limit: 10
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // If an 'after' cursor exists, use it to fetch the next page
|
|
24
|
+
* const nextPage = await client.listAccounts({
|
|
25
|
+
* signerAddress: "0x123...",
|
|
26
|
+
* limit: 10,
|
|
27
|
+
* after: firstPage.meta.after
|
|
28
|
+
* });
|
|
29
|
+
*/
|
|
6
30
|
export declare function listAccounts(client: InnerWalletApiClient, params: ListAccountsParams): Promise<ListAccountsResult>;
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lists all smart accounts for a given signer using the wallet API client.
|
|
3
|
+
*
|
|
4
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
5
|
+
* @param {ListAccountsParams} params - Parameters for listing accounts
|
|
6
|
+
* @param {string} params.signerAddress - The address of the signer to list accounts for
|
|
7
|
+
* @param {number} [params.limit] - Optional maximum number of accounts to return (default: 100, max: 100)
|
|
8
|
+
* @param {string} [params.after] - Optional pagination cursor for fetching subsequent pages
|
|
9
|
+
* @returns {Promise<ListAccountsResult>} A Promise that resolves to the list of accounts and pagination metadata
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Fetch the first page of accounts
|
|
13
|
+
* const firstPage = await client.listAccounts({
|
|
14
|
+
* signerAddress: "0x123...",
|
|
15
|
+
* limit: 10
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // If an 'after' cursor exists, use it to fetch the next page
|
|
19
|
+
* const nextPage = await client.listAccounts({
|
|
20
|
+
* signerAddress: "0x123...",
|
|
21
|
+
* limit: 10,
|
|
22
|
+
* after: firstPage.meta.after
|
|
23
|
+
* });
|
|
24
|
+
*/
|
|
1
25
|
export async function listAccounts(client, params) {
|
|
2
26
|
return client.request({ method: "wallet_listAccounts", params: [params] });
|
|
3
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listAccounts.js","sourceRoot":"","sources":["../../../../src/client/actions/listAccounts.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA4B,EAC5B,MAA0B;IAE1B,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import type { Static } from \"@sinclair/typebox\";\nimport type { wallet_listAccounts } from \"../../rpc/request\";\nimport type { InnerWalletApiClient } from \"../../types\";\n\nexport type ListAccountsParams = Static<\n typeof wallet_listAccounts\n>[\"Request\"][\"params\"][0];\n\nexport type ListAccountsResult = Static<\n typeof wallet_listAccounts\n>[\"ReturnType\"];\n\nexport async function listAccounts(\n client: InnerWalletApiClient,\n params: ListAccountsParams,\n): Promise<ListAccountsResult> {\n return client.request({ method: \"wallet_listAccounts\", params: [params] });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"listAccounts.js","sourceRoot":"","sources":["../../../../src/client/actions/listAccounts.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA4B,EAC5B,MAA0B;IAE1B,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import type { Static } from \"@sinclair/typebox\";\nimport type { wallet_listAccounts } from \"../../rpc/request.ts\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\n\nexport type ListAccountsParams = Static<\n typeof wallet_listAccounts\n>[\"Request\"][\"params\"][0];\n\nexport type ListAccountsResult = Static<\n typeof wallet_listAccounts\n>[\"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 {ListAccountsParams} params - Parameters for listing accounts\n * @param {string} 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 * // 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 */\nexport async function listAccounts(\n client: InnerWalletApiClient,\n params: ListAccountsParams,\n): Promise<ListAccountsResult> {\n return client.request({ method: \"wallet_listAccounts\", params: [params] });\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Address, type IsUndefined, type JsonRpcAccount } from "viem";
|
|
2
|
-
import type { PrepareCallsParams as IsomorphicPrepareCallsParams, PrepareCallsResult as IsomorphicPrepareCallsResult } from "../../isomorphic/actions/prepareCalls";
|
|
3
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
2
|
+
import type { PrepareCallsParams as IsomorphicPrepareCallsParams, PrepareCallsResult as IsomorphicPrepareCallsResult } from "../../isomorphic/actions/prepareCalls.ts";
|
|
3
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
4
4
|
export type GetAccountParam<TAccount> = IsUndefined<TAccount> extends true ? {
|
|
5
5
|
account: Address;
|
|
6
6
|
} : {
|
|
@@ -12,4 +12,30 @@ export type PrepareCallsParams<TAccount extends JsonRpcAccount<Address> | undefi
|
|
|
12
12
|
from?: never;
|
|
13
13
|
});
|
|
14
14
|
export type PrepareCallsResult = IsomorphicPrepareCallsResult;
|
|
15
|
+
/**
|
|
16
|
+
* Prepares a set of contract calls for execution by building a user operation.
|
|
17
|
+
* Returns the built user operation and a signature request that needs to be signed
|
|
18
|
+
* before submitting to sendPreparedCalls.
|
|
19
|
+
*
|
|
20
|
+
* @param {InnerWalletApiClient<TAccount>} client - The wallet API client to use for the request
|
|
21
|
+
* @param {PrepareCallsParams<TAccount>} params - Parameters for preparing calls
|
|
22
|
+
* @param {Array<{to: Address, data?: Hex, value?: Hex}>} params.calls - Array of contract calls to execute
|
|
23
|
+
* @param {Address} [params.from] - The address to execute the calls from (required if the client wasn't initialized with an account)
|
|
24
|
+
* @param {object} [params.capabilities] - Optional capabilities to include with the request
|
|
25
|
+
* @returns {Promise<PrepareCallsResult>} A Promise that resolves to the prepared calls result containing
|
|
26
|
+
* the user operation data and signature request
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Prepare a sponosored user operation call
|
|
30
|
+
* const result = await client.prepareCalls({
|
|
31
|
+
* calls: [{
|
|
32
|
+
* to: "0x1234...",
|
|
33
|
+
* data: "0xabcdef...",
|
|
34
|
+
* value: "0x0"
|
|
35
|
+
* }],
|
|
36
|
+
* capabilities: {
|
|
37
|
+
* paymasterService: { policyId: "your-policy-id" }
|
|
38
|
+
* }
|
|
39
|
+
* });
|
|
40
|
+
*/
|
|
15
41
|
export declare function prepareCalls<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined>(client: InnerWalletApiClient<TAccount>, params: PrepareCallsParams<TAccount>): Promise<PrepareCallsResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAIN,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAIN,MAAM,MAAM,CAAC;AAwDd,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA4B,EAC5B,MAA0B;IAE1B,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,gBAAgB,EAAE,CAAC;QAC9D,MAAM,CAAC,YAAY,GAAG;YACpB,GAAG,MAAM,CAAC,YAAY;YACtB,gBAAgB,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;SAChD,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACnC,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IACvC,CAAC;IAED,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;KACzD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n toHex,\n type Address,\n type IsUndefined,\n type JsonRpcAccount,\n} from \"viem\";\nimport type {\n PrepareCallsParams as IsomorphicPrepareCallsParams,\n PrepareCallsResult as IsomorphicPrepareCallsResult,\n} from \"../../isomorphic/actions/prepareCalls.ts\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\n\nexport type GetAccountParam<TAccount> =\n IsUndefined<TAccount> extends true\n ? { account: Address }\n : { account?: never };\n\nexport type PrepareCallsParams<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n> = Omit<IsomorphicPrepareCallsParams, \"from\" | \"chainId\"> &\n (IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });\n\nexport type PrepareCallsResult = IsomorphicPrepareCallsResult;\n\n/**\n * Prepares a set of contract calls for execution by building a user operation.\n * Returns the built user operation and a signature request that needs to be signed\n * before submitting to sendPreparedCalls.\n *\n * @param {InnerWalletApiClient<TAccount>} client - The wallet API client to use for the request\n * @param {PrepareCallsParams<TAccount>} params - Parameters for preparing 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\n * @returns {Promise<PrepareCallsResult>} A Promise that resolves to the prepared calls result containing\n * the user operation data and signature request\n *\n * @example\n * // Prepare a sponosored user operation call\n * const result = 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 */\nexport async function prepareCalls<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(\n client: InnerWalletApiClient<TAccount>,\n params: PrepareCallsParams<TAccount>,\n): Promise<PrepareCallsResult>;\n\nexport async function prepareCalls(\n client: InnerWalletApiClient,\n params: PrepareCallsParams,\n): Promise<PrepareCallsResult> {\n if (client.policyId && !params.capabilities?.paymasterService) {\n params.capabilities = {\n ...params.capabilities,\n paymasterService: { policyId: client.policyId },\n };\n }\n\n if (client.account && !params.from) {\n params.from = client.account.address;\n }\n\n return await client.request({\n method: \"wallet_prepareCalls\",\n params: [{ ...params, chainId: toHex(client.chain.id) }],\n });\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type SmartAccountSigner, type SmartContractAccount } from "@aa-sdk/core";
|
|
2
2
|
import type { Static } from "@sinclair/typebox";
|
|
3
3
|
import type { Address } from "abitype";
|
|
4
4
|
import { type IsUndefined, type JsonRpcAccount } from "viem";
|
|
@@ -6,6 +6,25 @@ import type { wallet_requestAccount } from "../../rpc/request.js";
|
|
|
6
6
|
import type { InnerWalletApiClient } from "../../types.js";
|
|
7
7
|
export type RequestAccountParams<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined> = IsUndefined<TAccount> extends true ? Omit<Extract<Static<typeof wallet_requestAccount>["Request"]["params"][0], {
|
|
8
8
|
signerAddress: Address;
|
|
9
|
-
}>, "signerAddress" | "includeCounterfactualInfo">
|
|
9
|
+
}>, "signerAddress" | "includeCounterfactualInfo"> & {
|
|
10
|
+
accountAddress?: Address;
|
|
11
|
+
} : never;
|
|
10
12
|
export type RequestAccountResult = SmartContractAccount;
|
|
13
|
+
/**
|
|
14
|
+
* Requests an account for the provided signer using the wallet API client.
|
|
15
|
+
* If an account already exists for the signer, it will always return that account unless a new ID is specified.
|
|
16
|
+
* If an account already exists, the creationHint will be ignored.
|
|
17
|
+
*
|
|
18
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
19
|
+
* @param {SmartAccountSigner} signer - The signer that will be associated with the account
|
|
20
|
+
* @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account
|
|
21
|
+
* @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
|
|
22
|
+
* @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists
|
|
23
|
+
* @returns {Promise<RequestAccountResult>} A Promise that resolves to a SmartContractAccount instance
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Request an account with default parameters using a local signer
|
|
27
|
+
* const signer = LocalAccountSigner.privateKeyToAccountSigner("0x...");
|
|
28
|
+
* const account = await client.requestAccount(signer);
|
|
29
|
+
*/
|
|
11
30
|
export declare function requestAccount<TAccount extends JsonRpcAccount<Address> | undefined = JsonRpcAccount<Address> | undefined>(client: InnerWalletApiClient<TAccount>, signer: SmartAccountSigner, params?: RequestAccountParams<TAccount>): Promise<RequestAccountResult>;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import {} from "@aa-sdk/core";
|
|
1
2
|
import { Value } from "@sinclair/typebox/value";
|
|
3
|
+
import deepEqual from "deep-equal";
|
|
2
4
|
import { custom } from "viem";
|
|
3
5
|
import { createAccount } from "../../isomorphic/utils/createAccount.js";
|
|
4
6
|
import { TypeSerializedInitcode } from "../../schemas.js";
|
|
5
7
|
export async function requestAccount(client, signer, params) {
|
|
6
|
-
const args = client.account && !params
|
|
8
|
+
const args = (client.account && !params) || params?.accountAddress
|
|
7
9
|
? {
|
|
8
|
-
accountAddress: client.account.address,
|
|
10
|
+
accountAddress: params?.accountAddress ?? client.account.address,
|
|
9
11
|
includeCounterfactualInfo: true,
|
|
10
12
|
}
|
|
11
13
|
: {
|
|
@@ -13,16 +15,25 @@ export async function requestAccount(client, signer, params) {
|
|
|
13
15
|
signerAddress: await signer.getAddress(),
|
|
14
16
|
includeCounterfactualInfo: true,
|
|
15
17
|
};
|
|
18
|
+
const cachedAccount = client.internal.getAccount();
|
|
19
|
+
if (cachedAccount &&
|
|
20
|
+
((args.accountAddress &&
|
|
21
|
+
cachedAccount.account.address === args.accountAddress) ||
|
|
22
|
+
deepEqual(cachedAccount.requestParams, args, { strict: true }))) {
|
|
23
|
+
return cachedAccount.account;
|
|
24
|
+
}
|
|
16
25
|
const { counterfactualInfo, accountAddress } = await client.request({
|
|
17
26
|
method: "wallet_requestAccount",
|
|
18
27
|
params: [args],
|
|
19
28
|
});
|
|
20
|
-
|
|
29
|
+
const account = await createAccount({
|
|
21
30
|
accountAddress: accountAddress,
|
|
22
31
|
counterfactualInfo: Value.Parse(TypeSerializedInitcode, counterfactualInfo),
|
|
23
32
|
chain: client.chain,
|
|
24
33
|
transport: custom(client.transport),
|
|
25
34
|
signer,
|
|
26
35
|
});
|
|
36
|
+
client.internal.setAccount({ account, requestParams: args });
|
|
37
|
+
return account;
|
|
27
38
|
}
|
|
28
39
|
//# sourceMappingURL=requestAccount.js.map
|
|
@@ -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":"AAAA,OAAO,EAGN,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAyC,MAAM,MAAM,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAExE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAgD1D,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA0B,EAC1B,MAA6B;IAE7B,MAAM,IAAI,GACR,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,MAAM,EAAE,cAAc;QACnD,CAAC,CAAC;YACE,cAAc,EAAE,MAAM,EAAE,cAAc,IAAI,MAAM,CAAC,OAAQ,CAAC,OAAO;YACjE,yBAAyB,EAAE,IAAI;SAChC;QACH,CAAC,CAAC;YACE,GAAG,MAAM;YACT,aAAa,EAAE,MAAM,MAAM,CAAC,UAAU,EAAE;YACxC,yBAAyB,EAAE,IAAI;SAChC,CAAC;IAER,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACnD,IACE,aAAa;QACb,CAAC,CAAC,IAAI,CAAC,cAAc;YACnB,aAAa,CAAC,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC,cAAc,CAAC;YACtD,SAAS,CAAC,aAAa,CAAC,aAAa,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EACjE,CAAC;QACD,OAAO,aAAa,CAAC,OAAO,CAAC;IAC/B,CAAC;IAED,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAClE,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,IAAI,CAAC;KACf,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC;QAClC,cAAc,EAAE,cAAc;QAC9B,kBAAkB,EAAE,KAAK,CAAC,KAAK,CAC7B,sBAAsB,EACtB,kBAAmB,CACpB;QACD,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,SAAS,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 {\n type SmartAccountSigner,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport type { Address } from \"abitype\";\nimport deepEqual from \"deep-equal\";\nimport { custom, type IsUndefined, type JsonRpcAccount } from \"viem\";\nimport { createAccount } from \"../../isomorphic/utils/createAccount.js\";\nimport type { wallet_requestAccount } from \"../../rpc/request.js\";\nimport { TypeSerializedInitcode } from \"../../schemas.js\";\nimport type { InnerWalletApiClient } from \"../../types.js\";\n\nexport type RequestAccountParams<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n> =\n IsUndefined<TAccount> extends true\n ? Omit<\n Extract<\n Static<typeof wallet_requestAccount>[\"Request\"][\"params\"][0],\n { signerAddress: Address }\n >,\n \"signerAddress\" | \"includeCounterfactualInfo\"\n > & { accountAddress?: Address }\n : never;\n\n// TODO: this could be more specific potentially :shrug:\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 * // Request an account with default parameters using a local signer\n * const signer = LocalAccountSigner.privateKeyToAccountSigner(\"0x...\");\n * const account = await client.requestAccount(signer);\n */\nexport function requestAccount<\n TAccount extends JsonRpcAccount<Address> | undefined =\n | JsonRpcAccount<Address>\n | undefined,\n>(\n client: InnerWalletApiClient<TAccount>,\n signer: SmartAccountSigner,\n params?: RequestAccountParams<TAccount>,\n): Promise<RequestAccountResult>;\n\nexport async function requestAccount(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params?: RequestAccountParams,\n): Promise<RequestAccountResult> {\n const args =\n (client.account && !params) || params?.accountAddress\n ? {\n accountAddress: params?.accountAddress ?? client.account!.address,\n includeCounterfactualInfo: true,\n }\n : {\n ...params,\n signerAddress: await signer.getAddress(),\n includeCounterfactualInfo: true,\n };\n\n const cachedAccount = client.internal.getAccount();\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 { counterfactualInfo, accountAddress } = await client.request({\n method: \"wallet_requestAccount\",\n params: [args],\n });\n\n const account = await createAccount({\n accountAddress: accountAddress,\n counterfactualInfo: Value.Parse(\n TypeSerializedInitcode,\n counterfactualInfo!,\n ),\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"]}
|
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
import type { Static, StaticDecode } from "@sinclair/typebox";
|
|
2
|
-
import type { wallet_sendPreparedCalls } from "../../rpc/request";
|
|
3
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
2
|
+
import type { wallet_sendPreparedCalls } from "../../rpc/request.ts";
|
|
3
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
4
4
|
export type SendPreparedCallsParams = Omit<StaticDecode<typeof wallet_sendPreparedCalls>["Request"]["params"][0], "chainId">;
|
|
5
5
|
export type SendPreparedCallsResult = Static<typeof wallet_sendPreparedCalls>["ReturnType"];
|
|
6
|
+
/**
|
|
7
|
+
* Sends prepared calls by submitting a signed user operation.
|
|
8
|
+
* This method is used after signing the signature request returned from prepareCalls.
|
|
9
|
+
*
|
|
10
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
11
|
+
* @param {SendPreparedCallsParams} params - Parameters for sending prepared calls
|
|
12
|
+
* @param {string} params.type - The user operation type ('user-operation-v060' or 'user-operation-v070')
|
|
13
|
+
* @param {object} params.data - The user operation data without signature
|
|
14
|
+
* @param {string} params.chainId - The chain ID in hex format
|
|
15
|
+
* @param {object} params.signature - The signature object
|
|
16
|
+
* @param {string} params.signature.type - The signature type (must be 'ecdsa')
|
|
17
|
+
* @param {string} params.signature.signature - The hex-encoded signature value
|
|
18
|
+
* @param {object} [params.capabilities] - Optional capabilities to include with the request
|
|
19
|
+
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // First prepare the calls
|
|
23
|
+
* const preparedCalls = await client.prepareCalls({
|
|
24
|
+
* calls: [{
|
|
25
|
+
* to: "0x1234...",
|
|
26
|
+
* data: "0xabcdef...",
|
|
27
|
+
* value: "0x0"
|
|
28
|
+
* }],
|
|
29
|
+
* capabilities: {
|
|
30
|
+
* paymasterService: { policyId: "your-policy-id" }
|
|
31
|
+
* }
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* // Sign the signature request using signSignatureRequest with your signer
|
|
35
|
+
* const signedRequest = await client.signSignatureRequest(preparedCalls.signatureRequest);
|
|
36
|
+
*
|
|
37
|
+
* // Then send the prepared calls with the signature
|
|
38
|
+
* const result = await client.sendPreparedCalls({
|
|
39
|
+
* ...preparedCalls,
|
|
40
|
+
* signature: signedRequest.signature,
|
|
41
|
+
* });
|
|
42
|
+
*/
|
|
6
43
|
export declare function sendPreparedCalls(client: InnerWalletApiClient, params: SendPreparedCallsParams): Promise<SendPreparedCallsResult>;
|
|
@@ -1,4 +1,41 @@
|
|
|
1
1
|
import { toHex } from "viem";
|
|
2
|
+
/**
|
|
3
|
+
* Sends prepared calls by submitting a signed user operation.
|
|
4
|
+
* This method is used after signing the signature request returned from prepareCalls.
|
|
5
|
+
*
|
|
6
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
7
|
+
* @param {SendPreparedCallsParams} params - Parameters for sending prepared calls
|
|
8
|
+
* @param {string} params.type - The user operation type ('user-operation-v060' or 'user-operation-v070')
|
|
9
|
+
* @param {object} params.data - The user operation data without signature
|
|
10
|
+
* @param {string} params.chainId - The chain ID in hex format
|
|
11
|
+
* @param {object} params.signature - The signature object
|
|
12
|
+
* @param {string} params.signature.type - The signature type (must be 'ecdsa')
|
|
13
|
+
* @param {string} params.signature.signature - The hex-encoded signature value
|
|
14
|
+
* @param {object} [params.capabilities] - Optional capabilities to include with the request
|
|
15
|
+
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // First prepare the calls
|
|
19
|
+
* const preparedCalls = await client.prepareCalls({
|
|
20
|
+
* calls: [{
|
|
21
|
+
* to: "0x1234...",
|
|
22
|
+
* data: "0xabcdef...",
|
|
23
|
+
* value: "0x0"
|
|
24
|
+
* }],
|
|
25
|
+
* capabilities: {
|
|
26
|
+
* paymasterService: { policyId: "your-policy-id" }
|
|
27
|
+
* }
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* // Sign the signature request using signSignatureRequest with your signer
|
|
31
|
+
* const signedRequest = await client.signSignatureRequest(preparedCalls.signatureRequest);
|
|
32
|
+
*
|
|
33
|
+
* // Then send the prepared calls with the signature
|
|
34
|
+
* const result = await client.sendPreparedCalls({
|
|
35
|
+
* ...preparedCalls,
|
|
36
|
+
* signature: signedRequest.signature,
|
|
37
|
+
* });
|
|
38
|
+
*/
|
|
2
39
|
export async function sendPreparedCalls(client, params) {
|
|
3
40
|
return client.request({
|
|
4
41
|
method: "wallet_sendPreparedCalls",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAa7B,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,MAA+B;IAE/B,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;KACzD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Static, StaticDecode } from \"@sinclair/typebox\";\nimport { toHex } from \"viem\";\nimport type { wallet_sendPreparedCalls } from \"../../rpc/request\";\nimport type { InnerWalletApiClient } from \"../../types\";\n\nexport type SendPreparedCallsParams = Omit<\n StaticDecode<typeof wallet_sendPreparedCalls>[\"Request\"][\"params\"][0],\n \"chainId\"\n>;\n\nexport type SendPreparedCallsResult = Static<\n typeof wallet_sendPreparedCalls\n>[\"ReturnType\"];\n\nexport async function sendPreparedCalls(\n client: InnerWalletApiClient,\n params: SendPreparedCallsParams,\n): Promise<SendPreparedCallsResult> {\n return client.request({\n method: \"wallet_sendPreparedCalls\",\n params: [{ ...params, chainId: toHex(client.chain.id) }],\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAa7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,MAA+B;IAE/B,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;KACzD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Static, StaticDecode } from \"@sinclair/typebox\";\nimport { toHex } from \"viem\";\nimport type { wallet_sendPreparedCalls } from \"../../rpc/request.ts\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\n\nexport type SendPreparedCallsParams = Omit<\n StaticDecode<typeof wallet_sendPreparedCalls>[\"Request\"][\"params\"][0],\n \"chainId\"\n>;\n\nexport type SendPreparedCallsResult = Static<\n typeof wallet_sendPreparedCalls\n>[\"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 * @param {string} params.type - The user operation type ('user-operation-v060' or 'user-operation-v070')\n * @param {object} params.data - The user operation data without signature\n * @param {string} params.chainId - The chain ID in hex format\n * @param {object} params.signature - The signature object\n * @param {string} params.signature.type - The signature type (must be 'ecdsa')\n * @param {string} params.signature.signature - The hex-encoded signature value\n * @param {object} [params.capabilities] - Optional capabilities to include with the request\n * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs\n *\n * @example\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 * // Sign the signature request using signSignatureRequest with your signer\n * const signedRequest = await client.signSignatureRequest(preparedCalls.signatureRequest);\n *\n * // Then send the prepared calls with the signature\n * const result = await client.sendPreparedCalls({\n * ...preparedCalls,\n * signature: signedRequest.signature,\n * });\n */\nexport async function sendPreparedCalls(\n client: InnerWalletApiClient,\n params: SendPreparedCallsParams,\n): Promise<SendPreparedCallsResult> {\n return client.request({\n method: \"wallet_sendPreparedCalls\",\n params: [{ ...params, chainId: toHex(client.chain.id) }],\n });\n}\n"]}
|