@account-kit/wallet-client 0.1.0-alpha.1 → 0.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/client/actions/createAccount.d.ts +27 -2
- package/dist/esm/client/actions/createAccount.js +25 -0
- package/dist/esm/client/actions/createAccount.js.map +1 -1
- package/dist/esm/client/actions/formatSign.d.ts +28 -0
- package/dist/esm/client/actions/formatSign.js +30 -0
- package/dist/esm/client/actions/formatSign.js.map +1 -0
- package/dist/esm/client/actions/getCallsStatus.d.ts +22 -4
- package/dist/esm/client/actions/getCallsStatus.js +19 -0
- package/dist/esm/client/actions/getCallsStatus.js.map +1 -1
- package/dist/esm/client/actions/grantPermissions.d.ts +63 -6
- package/dist/esm/client/actions/grantPermissions.js +63 -3
- package/dist/esm/client/actions/grantPermissions.js.map +1 -1
- package/dist/esm/client/actions/listAccounts.d.ts +32 -4
- package/dist/esm/client/actions/listAccounts.js +35 -2
- package/dist/esm/client/actions/listAccounts.js.map +1 -1
- package/dist/esm/client/actions/prepareCalls.d.ts +32 -6
- package/dist/esm/client/actions/prepareCalls.js +39 -5
- package/dist/esm/client/actions/prepareCalls.js.map +1 -1
- package/dist/esm/client/actions/prepareSign.d.ts +25 -0
- package/dist/esm/client/actions/prepareSign.js +28 -0
- package/dist/esm/client/actions/prepareSign.js.map +1 -0
- package/dist/esm/client/actions/requestAccount.d.ts +24 -6
- package/dist/esm/client/actions/requestAccount.js +38 -7
- package/dist/esm/client/actions/requestAccount.js.map +1 -1
- package/dist/esm/client/actions/sendPreparedCalls.d.ts +33 -4
- package/dist/esm/client/actions/sendPreparedCalls.js +37 -1
- package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/client/actions/signMessage.d.ts +25 -5
- package/dist/esm/client/actions/signMessage.js +22 -2
- package/dist/esm/client/actions/signMessage.js.map +1 -1
- package/dist/esm/client/actions/signPreparedCalls.d.ts +14 -0
- package/dist/esm/client/actions/signPreparedCalls.js +43 -0
- package/dist/esm/client/actions/signPreparedCalls.js.map +1 -0
- package/dist/esm/client/actions/signSignatureRequest.d.ts +39 -5
- package/dist/esm/client/actions/signSignatureRequest.js +69 -11
- package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
- package/dist/esm/client/actions/signTypedData.d.ts +37 -4
- package/dist/esm/client/actions/signTypedData.js +34 -1
- package/dist/esm/client/actions/signTypedData.js.map +1 -1
- package/dist/esm/client/client.e2e-test.js +210 -45
- package/dist/esm/client/client.e2e-test.js.map +1 -1
- package/dist/esm/client/decorator.d.ts +12 -8
- package/dist/esm/client/decorator.js +5 -3
- package/dist/esm/client/decorator.js.map +1 -1
- package/dist/esm/client/index.d.ts +38 -12
- package/dist/esm/client/index.js +0 -3
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/exports/index.d.ts +5 -6
- package/dist/esm/exports/index.js +4 -6
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/internal.d.ts +1 -10
- package/dist/esm/exports/internal.js +0 -12
- package/dist/esm/exports/internal.js.map +1 -1
- package/dist/esm/internal/decorator.d.ts +2 -0
- package/dist/esm/internal/decorator.js +10 -0
- package/dist/esm/internal/decorator.js.map +1 -0
- package/dist/esm/isomorphic/actions/createSession.d.ts +1 -2
- package/dist/esm/isomorphic/actions/createSession.js +39 -10
- package/dist/esm/isomorphic/actions/createSession.js.map +1 -1
- package/dist/esm/isomorphic/actions/formatSign.d.ts +8 -0
- package/dist/esm/isomorphic/actions/formatSign.js +42 -0
- package/dist/esm/isomorphic/actions/formatSign.js.map +1 -0
- package/dist/esm/isomorphic/actions/getCallsStatus.d.ts +1 -15
- package/dist/esm/isomorphic/actions/getCallsStatus.js +37 -26
- package/dist/esm/isomorphic/actions/getCallsStatus.js.map +1 -1
- package/dist/esm/isomorphic/actions/prepareCalls.d.ts +1 -2
- package/dist/esm/isomorphic/actions/prepareCalls.js +78 -20
- package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -1
- package/dist/esm/isomorphic/actions/prepareSign.d.ts +7 -0
- package/dist/esm/isomorphic/actions/prepareSign.js +49 -0
- package/dist/esm/isomorphic/actions/prepareSign.js.map +1 -0
- package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +3 -4
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js +138 -25
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/isomorphic/client.d.ts +204 -27
- package/dist/esm/isomorphic/client.js +6 -2
- package/dist/esm/isomorphic/client.js.map +1 -1
- package/dist/esm/isomorphic/utils/7702.d.ts +19 -0
- package/dist/esm/isomorphic/utils/7702.js +70 -0
- package/dist/esm/isomorphic/utils/7702.js.map +1 -0
- package/dist/esm/isomorphic/utils/createAccount.d.ts +5 -4
- package/dist/esm/isomorphic/utils/createAccount.js +84 -10
- package/dist/esm/isomorphic/utils/createAccount.js.map +1 -1
- package/dist/esm/isomorphic/utils/createDummySigner.js +3 -3
- package/dist/esm/isomorphic/utils/createDummySigner.js.map +1 -1
- package/dist/esm/isomorphic/utils/decodeSignature.d.ts +3 -0
- package/dist/esm/isomorphic/utils/decodeSignature.js +15 -0
- package/dist/esm/isomorphic/utils/decodeSignature.js.map +1 -0
- package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +6 -5
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js +19 -6
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +1 -1
- package/dist/esm/isomorphic/utils/supportsFeature.d.ts +4 -0
- package/dist/esm/isomorphic/utils/supportsFeature.js +21 -0
- package/dist/esm/isomorphic/utils/supportsFeature.js.map +1 -0
- package/dist/esm/local/client.d.ts +3 -3
- package/dist/esm/local/client.js +11 -4
- package/dist/esm/local/client.js.map +1 -1
- package/dist/esm/remote/client.d.ts +9 -3
- package/dist/esm/remote/client.js +10 -11
- package/dist/esm/remote/client.js.map +1 -1
- package/dist/esm/types.d.ts +27 -13
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils.d.ts +1 -0
- package/dist/esm/utils.js.map +1 -1
- package/dist/types/client/actions/createAccount.d.ts +27 -2
- package/dist/types/client/actions/createAccount.d.ts.map +1 -1
- package/dist/types/client/actions/formatSign.d.ts +29 -0
- package/dist/types/client/actions/formatSign.d.ts.map +1 -0
- package/dist/types/client/actions/getCallsStatus.d.ts +22 -4
- package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
- package/dist/types/client/actions/grantPermissions.d.ts +63 -6
- package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
- package/dist/types/client/actions/listAccounts.d.ts +32 -4
- package/dist/types/client/actions/listAccounts.d.ts.map +1 -1
- package/dist/types/client/actions/prepareCalls.d.ts +32 -6
- package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/client/actions/prepareSign.d.ts +26 -0
- package/dist/types/client/actions/prepareSign.d.ts.map +1 -0
- package/dist/types/client/actions/requestAccount.d.ts +24 -6
- package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
- package/dist/types/client/actions/sendPreparedCalls.d.ts +33 -4
- package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/client/actions/signMessage.d.ts +25 -5
- package/dist/types/client/actions/signMessage.d.ts.map +1 -1
- package/dist/types/client/actions/signPreparedCalls.d.ts +15 -0
- package/dist/types/client/actions/signPreparedCalls.d.ts.map +1 -0
- package/dist/types/client/actions/signSignatureRequest.d.ts +39 -5
- package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
- package/dist/types/client/actions/signTypedData.d.ts +37 -4
- package/dist/types/client/actions/signTypedData.d.ts.map +1 -1
- package/dist/types/client/decorator.d.ts +12 -8
- package/dist/types/client/decorator.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +38 -12
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +5 -6
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/exports/internal.d.ts +1 -10
- package/dist/types/exports/internal.d.ts.map +1 -1
- package/dist/types/internal/decorator.d.ts +3 -0
- package/dist/types/internal/decorator.d.ts.map +1 -0
- package/dist/types/isomorphic/actions/createSession.d.ts +1 -2
- package/dist/types/isomorphic/actions/createSession.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/formatSign.d.ts +9 -0
- package/dist/types/isomorphic/actions/formatSign.d.ts.map +1 -0
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts +1 -15
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/prepareCalls.d.ts +1 -2
- package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/prepareSign.d.ts +8 -0
- package/dist/types/isomorphic/actions/prepareSign.d.ts.map +1 -0
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +3 -4
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/isomorphic/client.d.ts +204 -27
- package/dist/types/isomorphic/client.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/7702.d.ts +20 -0
- package/dist/types/isomorphic/utils/7702.d.ts.map +1 -0
- package/dist/types/isomorphic/utils/createAccount.d.ts +5 -4
- package/dist/types/isomorphic/utils/createAccount.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/createDummySigner.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/decodeSignature.d.ts +4 -0
- package/dist/types/isomorphic/utils/decodeSignature.d.ts.map +1 -0
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +6 -5
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/supportsFeature.d.ts +5 -0
- package/dist/types/isomorphic/utils/supportsFeature.d.ts.map +1 -0
- package/dist/types/local/client.d.ts +3 -3
- package/dist/types/local/client.d.ts.map +1 -1
- package/dist/types/remote/client.d.ts +9 -3
- package/dist/types/remote/client.d.ts.map +1 -1
- package/dist/types/types.d.ts +27 -13
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +1 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +9 -6
- package/src/client/actions/createAccount.ts +27 -2
- package/src/client/actions/formatSign.ts +53 -0
- package/src/client/actions/getCallsStatus.ts +21 -12
- package/src/client/actions/grantPermissions.ts +69 -26
- package/src/client/actions/listAccounts.ts +44 -6
- package/src/client/actions/prepareCalls.ts +46 -26
- package/src/client/actions/prepareSign.ts +46 -0
- package/src/client/actions/requestAccount.ts +60 -41
- package/src/client/actions/sendPreparedCalls.ts +44 -7
- package/src/client/actions/signMessage.ts +26 -21
- package/src/client/actions/signPreparedCalls.ts +67 -0
- package/src/client/actions/signSignatureRequest.ts +84 -20
- package/src/client/actions/signTypedData.ts +40 -19
- package/src/client/client.e2e-test.ts +256 -54
- package/src/client/decorator.ts +28 -26
- package/src/client/index.ts +50 -40
- package/src/exports/index.ts +5 -13
- package/src/exports/internal.ts +2 -10
- package/src/internal/decorator.ts +12 -0
- package/src/isomorphic/actions/createSession.ts +55 -12
- package/src/isomorphic/actions/formatSign.ts +76 -0
- package/src/isomorphic/actions/getCallsStatus.ts +46 -32
- package/src/isomorphic/actions/prepareCalls.ts +95 -23
- package/src/isomorphic/actions/prepareSign.ts +91 -0
- package/src/isomorphic/actions/sendPreparedCalls.ts +181 -42
- package/src/isomorphic/client.ts +10 -2
- package/src/isomorphic/utils/7702.ts +135 -0
- package/src/isomorphic/utils/createAccount.ts +101 -13
- package/src/isomorphic/utils/createDummySigner.ts +3 -2
- package/src/isomorphic/utils/decodeSignature.ts +21 -0
- package/src/isomorphic/utils/parsePermissionsContext.ts +29 -11
- package/src/isomorphic/utils/supportsFeature.ts +34 -0
- package/src/local/client.ts +58 -55
- package/src/remote/client.ts +19 -19
- package/src/types.ts +29 -23
- package/src/utils.ts +2 -0
- package/dist/esm/capabilities/index.d.ts +0 -31
- package/dist/esm/capabilities/index.js +0 -10
- package/dist/esm/capabilities/index.js.map +0 -1
- package/dist/esm/capabilities/overrides.d.ts +0 -26
- package/dist/esm/capabilities/overrides.js +0 -14
- package/dist/esm/capabilities/overrides.js.map +0 -1
- package/dist/esm/capabilities/paymaster.d.ts +0 -3
- package/dist/esm/capabilities/paymaster.js +0 -5
- package/dist/esm/capabilities/paymaster.js.map +0 -1
- package/dist/esm/capabilities/permissions/index.d.ts +0 -138
- package/dist/esm/capabilities/permissions/index.js +0 -71
- package/dist/esm/capabilities/permissions/index.js.map +0 -1
- package/dist/esm/capabilities/permissions/mav2.d.ts +0 -36
- package/dist/esm/capabilities/permissions/mav2.js +0 -79
- package/dist/esm/capabilities/permissions/mav2.js.map +0 -1
- package/dist/esm/rpc/request.d.ts +0 -352
- package/dist/esm/rpc/request.js +0 -204
- package/dist/esm/rpc/request.js.map +0 -1
- package/dist/esm/rpc/schema.d.ts +0 -342
- package/dist/esm/rpc/schema.js +0 -5
- package/dist/esm/rpc/schema.js.map +0 -1
- package/dist/esm/schemas.d.ts +0 -216
- package/dist/esm/schemas.js +0 -211
- package/dist/esm/schemas.js.map +0 -1
- package/dist/types/capabilities/index.d.ts +0 -32
- package/dist/types/capabilities/index.d.ts.map +0 -1
- package/dist/types/capabilities/overrides.d.ts +0 -27
- package/dist/types/capabilities/overrides.d.ts.map +0 -1
- package/dist/types/capabilities/paymaster.d.ts +0 -4
- package/dist/types/capabilities/paymaster.d.ts.map +0 -1
- package/dist/types/capabilities/permissions/index.d.ts +0 -139
- package/dist/types/capabilities/permissions/index.d.ts.map +0 -1
- package/dist/types/capabilities/permissions/mav2.d.ts +0 -37
- package/dist/types/capabilities/permissions/mav2.d.ts.map +0 -1
- package/dist/types/rpc/request.d.ts +0 -353
- package/dist/types/rpc/request.d.ts.map +0 -1
- package/dist/types/rpc/schema.d.ts +0 -343
- package/dist/types/rpc/schema.d.ts.map +0 -1
- package/dist/types/schemas.d.ts +0 -217
- package/dist/types/schemas.d.ts.map +0 -1
- package/src/capabilities/index.ts +0 -13
- package/src/capabilities/overrides.ts +0 -20
- package/src/capabilities/paymaster.ts +0 -5
- package/src/capabilities/permissions/index.ts +0 -142
- package/src/capabilities/permissions/mav2.ts +0 -127
- package/src/rpc/request.ts +0 -273
- package/src/rpc/schema.ts +0 -40
- package/src/schemas.ts +0 -257
|
@@ -1,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 "
|
|
5
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
4
|
+
import type { wallet_createAccount } from "@alchemy/wallet-api-types/rpc";
|
|
5
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
6
6
|
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 \"
|
|
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 \"@alchemy/wallet-api-types/rpc\";\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"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Static } from "@sinclair/typebox";
|
|
2
|
+
import type { wallet_formatSign } from "@alchemy/wallet-api-types/rpc";
|
|
3
|
+
import type { InnerWalletApiClient, WithoutChainId } from "../../types.ts";
|
|
4
|
+
import { type Address, type IsUndefined } from "viem";
|
|
5
|
+
export type FormatSignParams<TAccount extends Address | undefined = Address | undefined> = Omit<WithoutChainId<Static<(typeof wallet_formatSign)["properties"]["Request"]["properties"]["params"]>[0]>, "from"> & (IsUndefined<TAccount> extends true ? {
|
|
6
|
+
from: Address;
|
|
7
|
+
} : {
|
|
8
|
+
from?: never;
|
|
9
|
+
});
|
|
10
|
+
export type FormatSignResult = Static<typeof wallet_formatSign>["ReturnType"];
|
|
11
|
+
/**
|
|
12
|
+
* Formats a signature request for signing messages or transactions.
|
|
13
|
+
*
|
|
14
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
15
|
+
* @param {FormatSignParams} params - Parameters for formatting the signature
|
|
16
|
+
* @returns {Promise<FormatSignResult>} A Promise that resolves to the formatSign result containing the formatted signature.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Formats a signature
|
|
20
|
+
* const result = await client.formatSign({
|
|
21
|
+
* from: "0x1234...",
|
|
22
|
+
* signature: {
|
|
23
|
+
* type: "ecdsa",
|
|
24
|
+
* data: "0xabcd..."
|
|
25
|
+
* },
|
|
26
|
+
* });
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatSign<TAccount extends Address | undefined = Address | undefined>(client: InnerWalletApiClient, params: FormatSignParams<TAccount>): Promise<FormatSignResult>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { toHex } from "viem";
|
|
2
|
+
import { AccountNotFoundError } from "@aa-sdk/core";
|
|
3
|
+
/**
|
|
4
|
+
* Formats a signature request for signing messages or transactions.
|
|
5
|
+
*
|
|
6
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
7
|
+
* @param {FormatSignParams} params - Parameters for formatting the signature
|
|
8
|
+
* @returns {Promise<FormatSignResult>} A Promise that resolves to the formatSign result containing the formatted signature.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Formats a signature
|
|
12
|
+
* const result = await client.formatSign({
|
|
13
|
+
* from: "0x1234...",
|
|
14
|
+
* signature: {
|
|
15
|
+
* type: "ecdsa",
|
|
16
|
+
* data: "0xabcd..."
|
|
17
|
+
* },
|
|
18
|
+
* });
|
|
19
|
+
*/
|
|
20
|
+
export async function formatSign(client, params) {
|
|
21
|
+
const from = params.from ?? client.account?.address;
|
|
22
|
+
if (!from) {
|
|
23
|
+
throw new AccountNotFoundError();
|
|
24
|
+
}
|
|
25
|
+
return client.request({
|
|
26
|
+
method: "wallet_formatSign",
|
|
27
|
+
params: [{ ...params, from, chainId: toHex(client.chain.id) }],
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=formatSign.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatSign.js","sourceRoot":"","sources":["../../../../src/client/actions/formatSign.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAkC,MAAM,MAAM,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAgBpD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAG9B,MAA4B,EAC5B,MAAkC;IAElC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;IACpD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,mBAAmB;QAC3B,MAAM,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;KAC/D,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Static } from \"@sinclair/typebox\";\nimport type { wallet_formatSign } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClient, WithoutChainId } from \"../../types.ts\";\nimport { toHex, type Address, type IsUndefined } from \"viem\";\nimport { AccountNotFoundError } from \"@aa-sdk/core\";\n\nexport type FormatSignParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Omit<\n WithoutChainId<\n Static<\n (typeof wallet_formatSign)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0]\n >,\n \"from\"\n> &\n (IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });\n\nexport type FormatSignResult = Static<typeof wallet_formatSign>[\"ReturnType\"];\n\n/**\n * Formats a signature request for signing messages or transactions.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {FormatSignParams} params - Parameters for formatting the signature\n * @returns {Promise<FormatSignResult>} A Promise that resolves to the formatSign result containing the formatted signature.\n *\n * @example\n * // Formats a signature\n * const result = await client.formatSign({\n * from: \"0x1234...\",\n * signature: {\n * type: \"ecdsa\",\n * data: \"0xabcd...\"\n * },\n * });\n */\nexport async function formatSign<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n params: FormatSignParams<TAccount>,\n): Promise<FormatSignResult> {\n const from = params.from ?? client.account?.address;\n if (!from) {\n throw new AccountNotFoundError();\n }\n\n return client.request({\n method: \"wallet_formatSign\",\n params: [{ ...params, from, chainId: toHex(client.chain.id) }],\n });\n}\n"]}
|
|
@@ -1,6 +1,24 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
1
|
+
import type { GetCallsStatusParams as IsomorphicGetCallsStatusParams, GetCallsStatusResponse as IsomorphicGetCallsStatusResult } from "../../isomorphic/actions/getCallsStatus.ts";
|
|
2
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
4
3
|
export type GetCallsStatusParams = IsomorphicGetCallsStatusParams;
|
|
5
4
|
export type GetCallsStatusResult = IsomorphicGetCallsStatusResult;
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Gets the status of a prepared call by its ID.
|
|
7
|
+
* This method is used to check the execution status of calls sent via sendPreparedCalls.
|
|
8
|
+
*
|
|
9
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
10
|
+
* @param {GetCallsStatusParams} params - The ID of the prepared call to check
|
|
11
|
+
* @returns {Promise<GetCallsStatusResult>} A Promise that resolves to the status information including:
|
|
12
|
+
* - id: The hex ID of the call
|
|
13
|
+
* - chainId: The chain ID in hex format
|
|
14
|
+
* - status: The current status of the batch execution
|
|
15
|
+
* - receipts: Optional array of transaction receipts if the batch has been executed
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // After sending prepared calls
|
|
19
|
+
* const sendResult = await client.sendPreparedCalls({...});
|
|
20
|
+
*
|
|
21
|
+
* // Check the status of the first call ID
|
|
22
|
+
* const status = await client.getCallsStatus(sendResult.preparedCallIds[0]);
|
|
23
|
+
*/
|
|
24
|
+
export declare function getCallsStatus(client: InnerWalletApiClient, params: GetCallsStatusParams): Promise<GetCallsStatusResult>;
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the status of a prepared call by its ID.
|
|
3
|
+
* This method is used to check the execution status of calls sent via sendPreparedCalls.
|
|
4
|
+
*
|
|
5
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
6
|
+
* @param {GetCallsStatusParams} params - The ID of the prepared call to check
|
|
7
|
+
* @returns {Promise<GetCallsStatusResult>} A Promise that resolves to the status information including:
|
|
8
|
+
* - id: The hex ID of the call
|
|
9
|
+
* - chainId: The chain ID in hex format
|
|
10
|
+
* - status: The current status of the batch execution
|
|
11
|
+
* - receipts: Optional array of transaction receipts if the batch has been executed
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // After sending prepared calls
|
|
15
|
+
* const sendResult = await client.sendPreparedCalls({...});
|
|
16
|
+
*
|
|
17
|
+
* // Check the status of the first call ID
|
|
18
|
+
* const status = await client.getCallsStatus(sendResult.preparedCallIds[0]);
|
|
19
|
+
*/
|
|
1
20
|
export async function getCallsStatus(client, params) {
|
|
2
21
|
return await client.request({
|
|
3
22
|
method: "wallet_getCallsStatus",
|
|
@@ -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":"AAUA;;;;;;;;;;;;;;;;;;GAkBG;AACH,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 {\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 client: InnerWalletApiClient,\n params: GetCallsStatusParams,\n): Promise<GetCallsStatusResult> {\n return await client.request({\n method: \"wallet_getCallsStatus\",\n params: [params],\n });\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
export type GrantPermissionsParams<TAccount extends
|
|
1
|
+
import { type SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
+
import { type Address, type Hex, type IsUndefined } from "viem";
|
|
3
|
+
import type { CreateSessionParams } from "../../isomorphic/actions/createSession.ts";
|
|
4
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
5
|
+
export type GrantPermissionsParams<TAccount extends Address | undefined = Address | undefined> = Omit<CreateSessionParams, "account" | "chainId" | "entityId"> & (IsUndefined<TAccount> extends true ? {
|
|
6
6
|
account: Address;
|
|
7
7
|
} : {
|
|
8
8
|
account?: never;
|
|
@@ -10,4 +10,61 @@ export type GrantPermissionsParams<TAccount extends JsonRpcAccount<Address> | un
|
|
|
10
10
|
export type GrantPermissionsResult = {
|
|
11
11
|
context: Hex;
|
|
12
12
|
};
|
|
13
|
-
|
|
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.expirySec - 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 preparedCalls = 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 signedCalls = await client.signPreparedCalls(
|
|
58
|
+
* sessionKey,
|
|
59
|
+
* preparedCalls,
|
|
60
|
+
* );
|
|
61
|
+
*
|
|
62
|
+
* // Send the prepared call using the session key
|
|
63
|
+
* const result = await client.sendPreparedCalls({
|
|
64
|
+
* ...signedCalls,
|
|
65
|
+
* capabilities: {
|
|
66
|
+
* permissions,
|
|
67
|
+
* },
|
|
68
|
+
* });
|
|
69
|
+
*/
|
|
70
|
+
export declare function grantPermissions<TAccount extends Address | undefined = Address | undefined>(client: InnerWalletApiClient, signer: SmartAccountSigner, params: GrantPermissionsParams<TAccount>): Promise<GrantPermissionsResult>;
|
|
@@ -1,10 +1,70 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AccountNotFoundError } from "@aa-sdk/core";
|
|
2
|
+
import { toHex } from "viem";
|
|
3
|
+
/**
|
|
4
|
+
* Grants permissions to a smart account by creating a session.
|
|
5
|
+
* This allows another key to perform operations on behalf of the account.
|
|
6
|
+
*
|
|
7
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
8
|
+
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
9
|
+
* @param {GrantPermissionsParams} params - The parameters for granting permissions
|
|
10
|
+
* @param {Address} [params.account] - The account address (required if client was not initialized with an account)
|
|
11
|
+
* @param {number} params.expirySec - Unix timestamp when the permissions expire
|
|
12
|
+
* @param {object} params.key - The session key information
|
|
13
|
+
* @param {string} params.key.publicKey - The public key of the session key
|
|
14
|
+
* @param {string} params.key.type - The type of the key (e.g., "secp256k1")
|
|
15
|
+
* @param {Array} params.permissions - Array of permission objects defining what the session key can do
|
|
16
|
+
* @returns {Promise<GrantPermissionsResult>} A Promise that resolves to the result containing a context identifier
|
|
17
|
+
* @returns {Hex} result.context - A hex identifier for the granted permissions context
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Create a session key and grant root permissions
|
|
21
|
+
* const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
|
|
22
|
+
* const account = await client.requestAccount();
|
|
23
|
+
*
|
|
24
|
+
* const permissions = await client.grantPermissions({
|
|
25
|
+
* account: account.address,
|
|
26
|
+
* expiry: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour from now
|
|
27
|
+
* key: {
|
|
28
|
+
* publicKey: await sessionKey.getAddress(),
|
|
29
|
+
* type: "secp256k1",
|
|
30
|
+
* },
|
|
31
|
+
* permissions: [{ type: "root" }],
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* // Use the permissions to prepare a call
|
|
35
|
+
* const preparedCalls = await client.prepareCalls({
|
|
36
|
+
* calls: [{ to: zeroAddress, value: "0x0" }],
|
|
37
|
+
* from: account.address,
|
|
38
|
+
* capabilities: {
|
|
39
|
+
* paymasterService: {
|
|
40
|
+
* policyId: "your-paymaster-policy-id",
|
|
41
|
+
* },
|
|
42
|
+
* permissions,
|
|
43
|
+
* },
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* // Sign with the session key
|
|
47
|
+
* const signedCalls = await client.signPreparedCalls(
|
|
48
|
+
* sessionKey,
|
|
49
|
+
* preparedCalls,
|
|
50
|
+
* );
|
|
51
|
+
*
|
|
52
|
+
* // Send the prepared call using the session key
|
|
53
|
+
* const result = await client.sendPreparedCalls({
|
|
54
|
+
* ...signedCalls,
|
|
55
|
+
* capabilities: {
|
|
56
|
+
* permissions,
|
|
57
|
+
* },
|
|
58
|
+
* });
|
|
59
|
+
*/
|
|
2
60
|
export async function grantPermissions(client, signer, params) {
|
|
3
|
-
|
|
4
|
-
|
|
61
|
+
const account = params.account ?? client.account?.address;
|
|
62
|
+
if (!account) {
|
|
63
|
+
throw new AccountNotFoundError();
|
|
5
64
|
}
|
|
6
65
|
return client.grantPermissions(signer, {
|
|
7
66
|
...params,
|
|
67
|
+
account,
|
|
8
68
|
chainId: toHex(client.chain.id),
|
|
9
69
|
});
|
|
10
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grantPermissions.js","sourceRoot":"","sources":["../../../../src/client/actions/grantPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"grantPermissions.js","sourceRoot":"","sources":["../../../../src/client/actions/grantPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAA2B,MAAM,cAAc,CAAC;AAC7E,OAAO,EAA4C,KAAK,EAAE,MAAM,MAAM,CAAC;AAevE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAGpC,MAA4B,EAC5B,MAA0B,EAC1B,MAAwC;IAExC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE;QACrC,GAAG,MAAM;QACT,OAAO;QACP,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;KAChC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { AccountNotFoundError, type SmartAccountSigner } from \"@aa-sdk/core\";\nimport { type Address, type Hex, type IsUndefined, toHex } from \"viem\";\nimport type { CreateSessionParams } from \"../../isomorphic/actions/createSession.ts\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\n\nexport type GrantPermissionsParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Omit<CreateSessionParams, \"account\" | \"chainId\" | \"entityId\"> &\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.expirySec - 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 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 client.signPreparedCalls(\n * sessionKey,\n * preparedCalls,\n * );\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 */\nexport async function grantPermissions<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params: GrantPermissionsParams<TAccount>,\n): Promise<GrantPermissionsResult> {\n const account = params.account ?? client.account?.address;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n return client.grantPermissions(signer, {\n ...params,\n account,\n chainId: toHex(client.chain.id),\n });\n}\n"]}
|
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
import type { Static } from "@sinclair/typebox";
|
|
2
|
-
import type { wallet_listAccounts } from "
|
|
3
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
4
|
-
|
|
2
|
+
import type { wallet_listAccounts } from "@alchemy/wallet-api-types/rpc";
|
|
3
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
4
|
+
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
5
|
+
import type { Address } from "viem";
|
|
6
|
+
export type ListAccountsParams = Omit<Static<typeof wallet_listAccounts>["Request"]["params"][0], "signerAddress"> & {
|
|
7
|
+
signerAddress?: Address;
|
|
8
|
+
};
|
|
5
9
|
export type ListAccountsResult = Static<typeof wallet_listAccounts>["ReturnType"];
|
|
6
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Lists all smart accounts for a given signer using the wallet API client.
|
|
12
|
+
*
|
|
13
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
14
|
+
* @param {ListAccountsParams} params - Parameters for listing accounts
|
|
15
|
+
* @param {string} params.signerAddress - The address of the signer to list accounts for
|
|
16
|
+
* @param {number} [params.limit] - Optional maximum number of accounts to return (default: 100, max: 100)
|
|
17
|
+
* @param {string} [params.after] - Optional pagination cursor for fetching subsequent pages
|
|
18
|
+
* @returns {Promise<ListAccountsResult>} A Promise that resolves to the list of accounts and pagination metadata
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Fetch the first page of accounts
|
|
22
|
+
* const firstPage = await client.listAccounts({
|
|
23
|
+
* signerAddress: "0x123...",
|
|
24
|
+
* limit: 10
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // If an 'after' cursor exists, use it to fetch the next page
|
|
28
|
+
* const nextPage = await client.listAccounts({
|
|
29
|
+
* signerAddress: "0x123...",
|
|
30
|
+
* limit: 10,
|
|
31
|
+
* after: firstPage.meta.after
|
|
32
|
+
* });
|
|
33
|
+
*/
|
|
34
|
+
export declare function listAccounts(client: InnerWalletApiClient, signer: SmartAccountSigner, params: ListAccountsParams): Promise<ListAccountsResult>;
|
|
@@ -1,4 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
*/
|
|
25
|
+
export async function listAccounts(client, signer, params) {
|
|
26
|
+
const signerAddress = params.signerAddress ?? (await signer.getAddress());
|
|
27
|
+
return client.request({
|
|
28
|
+
method: "wallet_listAccounts",
|
|
29
|
+
params: [
|
|
30
|
+
{
|
|
31
|
+
...params,
|
|
32
|
+
signerAddress,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
});
|
|
3
36
|
}
|
|
4
37
|
//# sourceMappingURL=listAccounts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listAccounts.js","sourceRoot":"","sources":["../../../../src/client/actions/listAccounts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"listAccounts.js","sourceRoot":"","sources":["../../../../src/client/actions/listAccounts.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA4B,EAC5B,MAA0B,EAC1B,MAA0B;IAE1B,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,CAAC,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IAE1E,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE;YACN;gBACE,GAAG,MAAM;gBACT,aAAa;aACd;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Static } from \"@sinclair/typebox\";\nimport type { wallet_listAccounts } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { Address } from \"viem\";\n\nexport type ListAccountsParams = Omit<\n Static<typeof wallet_listAccounts>[\"Request\"][\"params\"][0],\n \"signerAddress\"\n> & { signerAddress?: Address };\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 signer: SmartAccountSigner,\n params: ListAccountsParams,\n): Promise<ListAccountsResult> {\n const signerAddress = params.signerAddress ?? (await signer.getAddress());\n\n return client.request({\n method: \"wallet_listAccounts\",\n params: [\n {\n ...params,\n signerAddress,\n },\n ],\n });\n}\n"]}
|
|
@@ -1,15 +1,41 @@
|
|
|
1
|
-
import { type Address, type IsUndefined
|
|
2
|
-
import type { PrepareCallsParams as IsomorphicPrepareCallsParams, PrepareCallsResult as IsomorphicPrepareCallsResult } from "../../isomorphic/actions/prepareCalls";
|
|
3
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
1
|
+
import { type Address, type IsUndefined } from "viem";
|
|
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
|
} : {
|
|
7
|
-
account?:
|
|
7
|
+
account?: Address;
|
|
8
8
|
};
|
|
9
|
-
export type PrepareCallsParams<TAccount extends
|
|
9
|
+
export type PrepareCallsParams<TAccount extends Address | undefined = Address | undefined> = Omit<IsomorphicPrepareCallsParams, "from" | "chainId"> & (IsUndefined<TAccount> extends true ? {
|
|
10
10
|
from: Address;
|
|
11
11
|
} : {
|
|
12
12
|
from?: never;
|
|
13
13
|
});
|
|
14
14
|
export type PrepareCallsResult = IsomorphicPrepareCallsResult;
|
|
15
|
-
|
|
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 sponsored 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
|
+
*/
|
|
41
|
+
export declare function prepareCalls<TAccount extends Address | undefined = Address | undefined>(client: InnerWalletApiClient, params: PrepareCallsParams<TAccount>): Promise<PrepareCallsResult>;
|
|
@@ -1,17 +1,51 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AccountNotFoundError } from "@aa-sdk/core";
|
|
2
|
+
import { toHex } from "viem";
|
|
3
|
+
/**
|
|
4
|
+
* Prepares a set of contract calls for execution by building a user operation.
|
|
5
|
+
* Returns the built user operation and a signature request that needs to be signed
|
|
6
|
+
* before submitting to sendPreparedCalls.
|
|
7
|
+
*
|
|
8
|
+
* @param {InnerWalletApiClient<TAccount>} client - The wallet API client to use for the request
|
|
9
|
+
* @param {PrepareCallsParams<TAccount>} params - Parameters for preparing calls
|
|
10
|
+
* @param {Array<{to: Address, data?: Hex, value?: Hex}>} params.calls - Array of contract calls to execute
|
|
11
|
+
* @param {Address} [params.from] - The address to execute the calls from (required if the client wasn't initialized with an account)
|
|
12
|
+
* @param {object} [params.capabilities] - Optional capabilities to include with the request
|
|
13
|
+
* @returns {Promise<PrepareCallsResult>} A Promise that resolves to the prepared calls result containing
|
|
14
|
+
* the user operation data and signature request
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Prepare a sponsored user operation call
|
|
18
|
+
* const result = await client.prepareCalls({
|
|
19
|
+
* calls: [{
|
|
20
|
+
* to: "0x1234...",
|
|
21
|
+
* data: "0xabcdef...",
|
|
22
|
+
* value: "0x0"
|
|
23
|
+
* }],
|
|
24
|
+
* capabilities: {
|
|
25
|
+
* paymasterService: { policyId: "your-policy-id" }
|
|
26
|
+
* }
|
|
27
|
+
* });
|
|
28
|
+
*/
|
|
2
29
|
export async function prepareCalls(client, params) {
|
|
30
|
+
const from = params.from ?? client.account?.address;
|
|
31
|
+
if (!from) {
|
|
32
|
+
throw new AccountNotFoundError();
|
|
33
|
+
}
|
|
3
34
|
if (client.policyId && !params.capabilities?.paymasterService) {
|
|
4
35
|
params.capabilities = {
|
|
5
36
|
...params.capabilities,
|
|
6
37
|
paymasterService: { policyId: client.policyId },
|
|
7
38
|
};
|
|
8
39
|
}
|
|
9
|
-
if (client.account && !params.from) {
|
|
10
|
-
params.from = client.account.address;
|
|
11
|
-
}
|
|
12
40
|
return await client.request({
|
|
13
41
|
method: "wallet_prepareCalls",
|
|
14
|
-
params: [
|
|
42
|
+
params: [
|
|
43
|
+
{
|
|
44
|
+
...params,
|
|
45
|
+
chainId: toHex(client.chain.id),
|
|
46
|
+
from,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
15
49
|
});
|
|
16
50
|
}
|
|
17
51
|
//# sourceMappingURL=prepareCalls.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,KAAK,EAAkC,MAAM,MAAM,CAAC;AAmB7D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAGhC,MAA4B,EAC5B,MAAoC;IAEpC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;IACpD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,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,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE;YACN;gBACE,GAAG,MAAM;gBACT,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC/B,IAAI;aACL;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { AccountNotFoundError } from \"@aa-sdk/core\";\nimport { toHex, type Address, type IsUndefined } 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?: Address };\n\nexport type PrepareCallsParams<\n TAccount extends Address | undefined = Address | 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 sponsored 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 Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n params: PrepareCallsParams<TAccount>,\n): Promise<PrepareCallsResult> {\n const from = params.from ?? client.account?.address;\n if (!from) {\n throw new AccountNotFoundError();\n }\n\n if (client.policyId && !params.capabilities?.paymasterService) {\n params.capabilities = {\n ...params.capabilities,\n paymasterService: { policyId: client.policyId },\n };\n }\n\n return await client.request({\n method: \"wallet_prepareCalls\",\n params: [\n {\n ...params,\n chainId: toHex(client.chain.id),\n from,\n },\n ],\n });\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
2
|
+
import { type Address, type IsUndefined } from "viem";
|
|
3
|
+
import type { PrepareSignParams as IsomorphicPrepareSignParams, PrepareSignResult as IsomorphicPrepareSignResult } from "../../isomorphic/actions/prepareSign.ts";
|
|
4
|
+
export type PrepareSignParams<TAccount extends Address | undefined = Address | undefined> = Omit<IsomorphicPrepareSignParams, "from" | "chainId"> & (IsUndefined<TAccount> extends true ? {
|
|
5
|
+
from: Address;
|
|
6
|
+
} : {
|
|
7
|
+
from?: never;
|
|
8
|
+
});
|
|
9
|
+
export type PrepareSignResult = IsomorphicPrepareSignResult;
|
|
10
|
+
/**
|
|
11
|
+
* Prepares a signature request for signing messages or transactions.
|
|
12
|
+
*
|
|
13
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
14
|
+
* @param {PrepareSignParams} params - Parameters for preparing the signature request
|
|
15
|
+
* @returns {Promise<PrepareSignResult>} A Promise that resolves to the prepare sign result containing a signature request
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Prepare a message to be signed
|
|
19
|
+
* const result = await client.prepareSign({
|
|
20
|
+
* from: "0x1234...",
|
|
21
|
+
* type: "personal_sign",
|
|
22
|
+
* data: "Hello, world!",
|
|
23
|
+
* });
|
|
24
|
+
*/
|
|
25
|
+
export declare function prepareSign<TAccount extends Address | undefined = Address | undefined>(client: InnerWalletApiClient, params: PrepareSignParams<TAccount>): Promise<PrepareSignResult>;
|