@account-kit/wallet-client 0.1.0-alpha.4 → 0.1.0-alpha.6
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/eip7702Auth.d.ts +4 -0
- package/dist/esm/capabilities/eip7702Auth.js +18 -0
- package/dist/esm/capabilities/eip7702Auth.js.map +1 -0
- package/dist/esm/capabilities/index.d.ts +4 -0
- package/dist/esm/capabilities/index.js +2 -0
- package/dist/esm/capabilities/index.js.map +1 -1
- package/dist/esm/capabilities/overrides.js +8 -8
- package/dist/esm/capabilities/overrides.js.map +1 -1
- package/dist/esm/capabilities/permissions/index.d.ts +2 -2
- package/dist/esm/capabilities/permissions/index.js +6 -3
- package/dist/esm/capabilities/permissions/index.js.map +1 -1
- package/dist/esm/capabilities/permissions/mav2.js +1 -0
- package/dist/esm/capabilities/permissions/mav2.js.map +1 -1
- package/dist/esm/client/actions/getCallsStatus.d.ts +1 -2
- 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 +10 -65
- package/dist/esm/client/actions/grantPermissions.js +63 -4
- package/dist/esm/client/actions/grantPermissions.js.map +1 -1
- package/dist/esm/client/actions/prepareCalls.d.ts +4 -4
- package/dist/esm/client/actions/prepareCalls.js +38 -5
- package/dist/esm/client/actions/prepareCalls.js.map +1 -1
- package/dist/esm/client/actions/requestAccount.d.ts +3 -4
- package/dist/esm/client/actions/requestAccount.js +18 -1
- package/dist/esm/client/actions/requestAccount.js.map +1 -1
- package/dist/esm/client/actions/sendPreparedCalls.d.ts +6 -14
- package/dist/esm/client/actions/sendPreparedCalls.js +11 -12
- package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/client/actions/signMessage.d.ts +3 -3
- package/dist/esm/client/actions/signMessage.js +18 -0
- 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 +53 -0
- package/dist/esm/client/actions/signPreparedCalls.js.map +1 -0
- package/dist/esm/client/actions/signSignatureRequest.d.ts +9 -8
- package/dist/esm/client/actions/signSignatureRequest.js +69 -31
- package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
- package/dist/esm/client/actions/signTypedData.d.ts +2 -2
- package/dist/esm/client/actions/signTypedData.js +31 -0
- package/dist/esm/client/actions/signTypedData.js.map +1 -1
- package/dist/esm/client/client.e2e-test.js +47 -44
- 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 +3 -1
- package/dist/esm/client/decorator.js.map +1 -1
- package/dist/esm/client/index.d.ts +35 -10
- package/dist/esm/client/index.js +0 -29
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/exports/index.d.ts +2 -1
- package/dist/esm/exports/index.js +2 -1
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/isomorphic/actions/createSession.js +15 -18
- package/dist/esm/isomorphic/actions/createSession.js.map +1 -1
- package/dist/esm/isomorphic/actions/getCallsStatus.js +62 -9
- package/dist/esm/isomorphic/actions/getCallsStatus.js.map +1 -1
- package/dist/esm/isomorphic/actions/prepareCalls.js +39 -26
- package/dist/esm/isomorphic/actions/prepareCalls.js.map +1 -1
- package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +3 -3
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js +77 -37
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/isomorphic/client.d.ts +139 -13
- package/dist/esm/isomorphic/utils/7702.d.ts +13 -6
- package/dist/esm/isomorphic/utils/7702.js +48 -13
- package/dist/esm/isomorphic/utils/7702.js.map +1 -1
- package/dist/esm/isomorphic/utils/createAccount.d.ts +2 -2
- package/dist/esm/isomorphic/utils/createAccount.js +4 -3
- package/dist/esm/isomorphic/utils/createAccount.js.map +1 -1
- package/dist/esm/isomorphic/utils/decodeSignature.d.ts +3 -0
- package/dist/esm/isomorphic/utils/decodeSignature.js +13 -0
- package/dist/esm/isomorphic/utils/decodeSignature.js.map +1 -0
- package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +2 -2
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js +8 -7
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +1 -1
- package/dist/esm/local/client.d.ts +2 -2
- package/dist/esm/local/client.js +2 -3
- package/dist/esm/local/client.js.map +1 -1
- package/dist/esm/remote/client.d.ts +8 -2
- package/dist/esm/remote/client.js +3 -13
- package/dist/esm/remote/client.js.map +1 -1
- package/dist/esm/rpc/examples.d.ts +3 -3
- package/dist/esm/rpc/examples.js +3 -3
- package/dist/esm/rpc/examples.js.map +1 -1
- package/dist/esm/rpc/request.d.ts +362 -44
- package/dist/esm/rpc/request.js +26 -56
- package/dist/esm/rpc/request.js.map +1 -1
- package/dist/esm/rpc/schema.d.ts +325 -49
- package/dist/esm/rpc/schema.js.map +1 -1
- package/dist/esm/schemas.d.ts +454 -14
- package/dist/esm/schemas.js +168 -53
- package/dist/esm/schemas.js.map +1 -1
- package/dist/esm/types.d.ts +10 -10
- package/dist/esm/types.js.map +1 -1
- package/dist/types/capabilities/eip7702Auth.d.ts +5 -0
- package/dist/types/capabilities/eip7702Auth.d.ts.map +1 -0
- package/dist/types/capabilities/index.d.ts +4 -0
- package/dist/types/capabilities/index.d.ts.map +1 -1
- package/dist/types/capabilities/permissions/index.d.ts +2 -2
- package/dist/types/capabilities/permissions/index.d.ts.map +1 -1
- package/dist/types/capabilities/permissions/mav2.d.ts.map +1 -1
- package/dist/types/client/actions/getCallsStatus.d.ts +1 -2
- package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
- package/dist/types/client/actions/grantPermissions.d.ts +10 -65
- package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
- package/dist/types/client/actions/prepareCalls.d.ts +4 -4
- package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/client/actions/requestAccount.d.ts +3 -4
- package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
- package/dist/types/client/actions/sendPreparedCalls.d.ts +6 -14
- package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/client/actions/signMessage.d.ts +3 -3
- 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 +9 -8
- package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
- package/dist/types/client/actions/signTypedData.d.ts +2 -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 +35 -10
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +2 -1
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/createSession.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +3 -3
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/isomorphic/client.d.ts +139 -13
- package/dist/types/isomorphic/client.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/7702.d.ts +13 -6
- package/dist/types/isomorphic/utils/7702.d.ts.map +1 -1
- package/dist/types/isomorphic/utils/createAccount.d.ts +2 -2
- package/dist/types/isomorphic/utils/createAccount.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 +2 -2
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +1 -1
- package/dist/types/local/client.d.ts +2 -2
- package/dist/types/local/client.d.ts.map +1 -1
- package/dist/types/remote/client.d.ts +8 -2
- package/dist/types/remote/client.d.ts.map +1 -1
- package/dist/types/rpc/examples.d.ts +3 -3
- package/dist/types/rpc/examples.d.ts.map +1 -1
- package/dist/types/rpc/request.d.ts +362 -44
- package/dist/types/rpc/request.d.ts.map +1 -1
- package/dist/types/rpc/schema.d.ts +325 -49
- package/dist/types/rpc/schema.d.ts.map +1 -1
- package/dist/types/schemas.d.ts +454 -14
- package/dist/types/schemas.d.ts.map +1 -1
- package/dist/types/types.d.ts +10 -10
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/capabilities/eip7702Auth.ts +26 -0
- package/src/capabilities/index.ts +2 -0
- package/src/capabilities/overrides.ts +8 -8
- package/src/capabilities/permissions/index.ts +8 -3
- package/src/capabilities/permissions/mav2.ts +1 -0
- package/src/client/actions/getCallsStatus.ts +0 -10
- package/src/client/actions/grantPermissions.ts +16 -84
- package/src/client/actions/prepareCalls.ts +18 -23
- package/src/client/actions/requestAccount.ts +9 -26
- package/src/client/actions/sendPreparedCalls.ts +17 -17
- package/src/client/actions/signMessage.ts +2 -17
- package/src/client/actions/signPreparedCalls.ts +71 -0
- package/src/client/actions/signSignatureRequest.ts +51 -47
- package/src/client/actions/signTypedData.ts +1 -16
- package/src/client/client.e2e-test.ts +54 -57
- package/src/client/decorator.ts +19 -15
- package/src/client/index.ts +16 -39
- package/src/exports/index.ts +2 -1
- package/src/isomorphic/actions/createSession.ts +17 -20
- package/src/isomorphic/actions/getCallsStatus.ts +82 -10
- package/src/isomorphic/actions/prepareCalls.ts +43 -27
- package/src/isomorphic/actions/sendPreparedCalls.ts +105 -55
- package/src/isomorphic/utils/7702.ts +79 -21
- package/src/isomorphic/utils/createAccount.ts +5 -5
- package/src/isomorphic/utils/decodeSignature.ts +18 -0
- package/src/isomorphic/utils/parsePermissionsContext.ts +9 -9
- package/src/local/client.ts +5 -11
- package/src/remote/client.ts +7 -22
- package/src/rpc/examples.ts +3 -4
- package/src/rpc/request.ts +41 -64
- package/src/rpc/schema.ts +2 -2
- package/src/schemas.ts +232 -54
- package/src/types.ts +9 -21
|
@@ -1,14 +1,13 @@
|
|
|
1
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
|
-
import { type IsUndefined, type JsonRpcAccount } from "viem";
|
|
5
4
|
import type { wallet_requestAccount } from "../../rpc/request.js";
|
|
6
5
|
import type { InnerWalletApiClient } from "../../types.js";
|
|
7
|
-
export type RequestAccountParams
|
|
6
|
+
export type RequestAccountParams = Omit<Extract<Static<typeof wallet_requestAccount>["Request"]["params"][0], {
|
|
8
7
|
signerAddress: Address;
|
|
9
8
|
}>, "signerAddress" | "includeCounterfactualInfo"> & {
|
|
10
9
|
accountAddress?: Address;
|
|
11
|
-
}
|
|
10
|
+
};
|
|
12
11
|
export type RequestAccountResult = SmartContractAccount;
|
|
13
12
|
/**
|
|
14
13
|
* Requests an account for the provided signer using the wallet API client.
|
|
@@ -27,4 +26,4 @@ export type RequestAccountResult = SmartContractAccount;
|
|
|
27
26
|
* const signer = LocalAccountSigner.privateKeyToAccountSigner("0x...");
|
|
28
27
|
* const account = await client.requestAccount(signer);
|
|
29
28
|
*/
|
|
30
|
-
export declare function requestAccount
|
|
29
|
+
export declare function requestAccount(client: InnerWalletApiClient, signer: SmartAccountSigner, params?: RequestAccountParams): Promise<RequestAccountResult>;
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
import {} from "@aa-sdk/core";
|
|
2
2
|
import { Value } from "@sinclair/typebox/value";
|
|
3
|
+
import deepEqual from "deep-equal";
|
|
3
4
|
import { custom } from "viem";
|
|
4
5
|
import { createAccount } from "../../isomorphic/utils/createAccount.js";
|
|
5
6
|
import { TypeSerializedInitcode } from "../../schemas.js";
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Requests an account for the provided signer using the wallet API client.
|
|
9
|
+
* If an account already exists for the signer, it will always return that account unless a new ID is specified.
|
|
10
|
+
* If an account already exists, the creationHint will be ignored.
|
|
11
|
+
*
|
|
12
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
13
|
+
* @param {SmartAccountSigner} signer - The signer that will be associated with the account
|
|
14
|
+
* @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account
|
|
15
|
+
* @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
|
|
16
|
+
* @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists
|
|
17
|
+
* @returns {Promise<RequestAccountResult>} A Promise that resolves to a SmartContractAccount instance
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Request an account with default parameters using a local signer
|
|
21
|
+
* const signer = LocalAccountSigner.privateKeyToAccountSigner("0x...");
|
|
22
|
+
* const account = await client.requestAccount(signer);
|
|
23
|
+
*/
|
|
7
24
|
export async function requestAccount(client, signer, params) {
|
|
8
25
|
const args = (client.account && !params) || params?.accountAddress
|
|
9
26
|
? {
|
|
@@ -1 +1 @@
|
|
|
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,EAAE,MAAM,
|
|
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,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAExE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAa1D;;;;;;;;;;;;;;;;GAgBG;AACH,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;QACd,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 } 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 = Omit<\n Extract<\n Static<typeof wallet_requestAccount>[\"Request\"][\"params\"][0],\n { signerAddress: Address }\n >,\n \"signerAddress\" | \"includeCounterfactualInfo\"\n> & { accountAddress?: Address };\n\nexport type RequestAccountResult = SmartContractAccount;\n\n/**\n * Requests an account for the provided signer using the wallet API client.\n * If an account already exists for the signer, it will always return that account unless a new ID is specified.\n * If an account already exists, the creationHint will be ignored.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer that will be associated with the account\n * @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account\n * @param {string} [params.id] - Optional identifier for the account. If specified, a new account with this ID will be created even if one already exists for the signer\n * @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists\n * @returns {Promise<RequestAccountResult>} A Promise that resolves to a SmartContractAccount instance\n *\n * @example\n * // 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 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,\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,7 +1,7 @@
|
|
|
1
|
-
import type { Static
|
|
1
|
+
import type { Static } from "@sinclair/typebox";
|
|
2
2
|
import type { wallet_sendPreparedCalls } from "../../rpc/request.ts";
|
|
3
|
-
import type { InnerWalletApiClient } from "../../types.ts";
|
|
4
|
-
export type SendPreparedCallsParams =
|
|
3
|
+
import type { InnerWalletApiClient, WithoutChainId } from "../../types.ts";
|
|
4
|
+
export type SendPreparedCallsParams = WithoutChainId<Static<(typeof wallet_sendPreparedCalls)["properties"]["Request"]["properties"]["params"]>[0]>;
|
|
5
5
|
export type SendPreparedCallsResult = Static<typeof wallet_sendPreparedCalls>["ReturnType"];
|
|
6
6
|
/**
|
|
7
7
|
* Sends prepared calls by submitting a signed user operation.
|
|
@@ -9,13 +9,6 @@ export type SendPreparedCallsResult = Static<typeof wallet_sendPreparedCalls>["R
|
|
|
9
9
|
*
|
|
10
10
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
11
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
12
|
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs
|
|
20
13
|
*
|
|
21
14
|
* @example
|
|
@@ -31,13 +24,12 @@ export type SendPreparedCallsResult = Static<typeof wallet_sendPreparedCalls>["R
|
|
|
31
24
|
* }
|
|
32
25
|
* });
|
|
33
26
|
*
|
|
34
|
-
* //
|
|
35
|
-
* const
|
|
27
|
+
* // Then sign the calls
|
|
28
|
+
* const signedCalls = await client.signPreparedCalls(preparedCalls);
|
|
36
29
|
*
|
|
37
30
|
* // Then send the prepared calls with the signature
|
|
38
31
|
* const result = await client.sendPreparedCalls({
|
|
39
|
-
*
|
|
40
|
-
* signature: signedRequest.signature,
|
|
32
|
+
* signedCalls,
|
|
41
33
|
* });
|
|
42
34
|
*/
|
|
43
35
|
export declare function sendPreparedCalls(client: InnerWalletApiClient, params: SendPreparedCallsParams): Promise<SendPreparedCallsResult>;
|
|
@@ -5,13 +5,6 @@ import { toHex } from "viem";
|
|
|
5
5
|
*
|
|
6
6
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
7
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
8
|
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs
|
|
16
9
|
*
|
|
17
10
|
* @example
|
|
@@ -27,19 +20,25 @@ import { toHex } from "viem";
|
|
|
27
20
|
* }
|
|
28
21
|
* });
|
|
29
22
|
*
|
|
30
|
-
* //
|
|
31
|
-
* const
|
|
23
|
+
* // Then sign the calls
|
|
24
|
+
* const signedCalls = await client.signPreparedCalls(preparedCalls);
|
|
32
25
|
*
|
|
33
26
|
* // Then send the prepared calls with the signature
|
|
34
27
|
* const result = await client.sendPreparedCalls({
|
|
35
|
-
*
|
|
36
|
-
* signature: signedRequest.signature,
|
|
28
|
+
* signedCalls,
|
|
37
29
|
* });
|
|
38
30
|
*/
|
|
39
31
|
export async function sendPreparedCalls(client, params) {
|
|
40
32
|
return client.request({
|
|
41
33
|
method: "wallet_sendPreparedCalls",
|
|
42
|
-
params: [
|
|
34
|
+
params: [
|
|
35
|
+
params.type === "array"
|
|
36
|
+
? params
|
|
37
|
+
: {
|
|
38
|
+
...params,
|
|
39
|
+
chainId: toHex(client.chain.id),
|
|
40
|
+
},
|
|
41
|
+
],
|
|
43
42
|
});
|
|
44
43
|
}
|
|
45
44
|
//# sourceMappingURL=sendPreparedCalls.js.map
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAc7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;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;YACN,MAAM,CAAC,IAAI,KAAK,OAAO;gBACrB,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC;oBACE,GAAG,MAAM;oBACT,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;iBAChC;SACN;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Static } from \"@sinclair/typebox\";\nimport { toHex } from \"viem\";\nimport type { wallet_sendPreparedCalls } from \"../../rpc/request.ts\";\nimport type { InnerWalletApiClient, WithoutChainId } from \"../../types.ts\";\n\nexport type SendPreparedCallsParams = WithoutChainId<\n Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0]\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 * @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 * // Then sign the calls\n * const signedCalls = await client.signPreparedCalls(preparedCalls);\n *\n * // Then send the prepared calls with the signature\n * const result = await client.sendPreparedCalls({\n * signedCalls,\n * });\n */\nexport async function sendPreparedCalls(\n client: InnerWalletApiClient,\n params: SendPreparedCallsParams,\n): Promise<SendPreparedCallsResult> {\n return client.request({\n method: \"wallet_sendPreparedCalls\",\n params: [\n params.type === \"array\"\n ? params\n : {\n ...params,\n chainId: toHex(client.chain.id),\n },\n ],\n });\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { type Address, type Hex, type
|
|
1
|
+
import { type SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
+
import { type Address, type Hex, type SignableMessage } from "viem";
|
|
3
3
|
import type { InnerWalletApiClient } from "../../types.ts";
|
|
4
4
|
export type SignMessageParams = {
|
|
5
5
|
message: SignableMessage;
|
|
@@ -23,4 +23,4 @@ export type SignMessageResult = Hex;
|
|
|
23
23
|
* // Sign a raw hex message
|
|
24
24
|
* const signature = await client.signMessage({ raw: "0x48656c6c6f2c20776f726c6421" });
|
|
25
25
|
*/
|
|
26
|
-
export declare function signMessage
|
|
26
|
+
export declare function signMessage(client: InnerWalletApiClient, signer: SmartAccountSigner, params: SignMessageParams): Promise<SignMessageResult>;
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
+
import {} from "@aa-sdk/core";
|
|
1
2
|
import {} from "viem";
|
|
2
3
|
import { requestAccount } from "./requestAccount.js";
|
|
4
|
+
/**
|
|
5
|
+
* Signs a message using the smart account.
|
|
6
|
+
* This method requests the account associated with the signer and uses it to sign the message.
|
|
7
|
+
*
|
|
8
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
9
|
+
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
10
|
+
* @param {SignableMessage} message - The message to sign
|
|
11
|
+
* @returns {Promise<SignMessageResult>} A Promise that resolves to the signed message as a hex string
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Sign a simple text message
|
|
15
|
+
* const signature = await client.signMessage("Hello, world!");
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Sign a raw hex message
|
|
19
|
+
* const signature = await client.signMessage({ raw: "0x48656c6c6f2c20776f726c6421" });
|
|
20
|
+
*/
|
|
3
21
|
export async function signMessage(client, signer, params) {
|
|
4
22
|
const account = await requestAccount(client, signer, {
|
|
5
23
|
accountAddress: params.account ?? client.account?.address,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signMessage.js","sourceRoot":"","sources":["../../../../src/client/actions/signMessage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signMessage.js","sourceRoot":"","sources":["../../../../src/client/actions/signMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,MAAM,cAAc,CAAC;AACvD,OAAO,EAAgD,MAAM,MAAM,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAMrD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAA4B,EAC5B,MAA0B,EAC1B,MAAyB;IAEzB,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE;QACnD,cAAc,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO;KAC1D,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import { type SmartAccountSigner } from \"@aa-sdk/core\";\nimport { type Address, type Hex, type SignableMessage } from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport { requestAccount } from \"./requestAccount.js\";\n\nexport type SignMessageParams = { message: SignableMessage; account?: Address };\n\nexport type SignMessageResult = Hex;\n\n/**\n * Signs a message using the smart account.\n * This method requests the account associated with the signer and uses it to sign the message.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer of the smart account\n * @param {SignableMessage} message - The message to sign\n * @returns {Promise<SignMessageResult>} A Promise that resolves to the signed message as a hex string\n *\n * @example\n * // Sign a simple text message\n * const signature = await client.signMessage(\"Hello, world!\");\n *\n * @example\n * // Sign a raw hex message\n * const signature = await client.signMessage({ raw: \"0x48656c6c6f2c20776f726c6421\" });\n */\nexport async function signMessage(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params: SignMessageParams,\n): Promise<SignMessageResult> {\n const account = await requestAccount(client, signer, {\n accountAddress: params.account ?? client.account?.address,\n });\n\n return account.signMessageWith6492({ message: params.message });\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PrepareCallsResult } from "./prepareCalls.ts";
|
|
2
|
+
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
3
|
+
import type { Static } from "@sinclair/typebox";
|
|
4
|
+
import { wallet_sendPreparedCalls } from "../../rpc/request.js";
|
|
5
|
+
export type SignPreparedCallsParams = PrepareCallsResult;
|
|
6
|
+
export type SignPreparedCallsResult = Static<(typeof wallet_sendPreparedCalls)["properties"]["Request"]["properties"]["params"]>[0];
|
|
7
|
+
/**
|
|
8
|
+
* Signs prepared calls using the provided signer.
|
|
9
|
+
*
|
|
10
|
+
* @param {SmartAccountSigner} signer - The signer to use
|
|
11
|
+
* @param {SignPreparedCallsParams} params - The prepared calls with signature requests
|
|
12
|
+
* @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls
|
|
13
|
+
**/
|
|
14
|
+
export declare function signPreparedCalls(signer: SmartAccountSigner, params: SignPreparedCallsParams): Promise<SignPreparedCallsResult>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { signSignatureRequest } from "./signSignatureRequest.js";
|
|
2
|
+
import { wallet_sendPreparedCalls } from "../../rpc/request.js";
|
|
3
|
+
import { assertNever } from "../../utils.js";
|
|
4
|
+
/**
|
|
5
|
+
* Signs prepared calls using the provided signer.
|
|
6
|
+
*
|
|
7
|
+
* @param {SmartAccountSigner} signer - The signer to use
|
|
8
|
+
* @param {SignPreparedCallsParams} params - The prepared calls with signature requests
|
|
9
|
+
* @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls
|
|
10
|
+
**/
|
|
11
|
+
export async function signPreparedCalls(signer, params) {
|
|
12
|
+
if (params.type !== "array") {
|
|
13
|
+
const { signatureRequest, ...call } = params;
|
|
14
|
+
const signature = await signSignatureRequest(signer, signatureRequest);
|
|
15
|
+
return {
|
|
16
|
+
...call,
|
|
17
|
+
signature,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
type: "array",
|
|
22
|
+
data: await Promise.all(params.data.map(async (call) => {
|
|
23
|
+
switch (call.type) {
|
|
24
|
+
case "authorization": {
|
|
25
|
+
const signature = await signSignatureRequest(signer, {
|
|
26
|
+
type: "eip7702Auth",
|
|
27
|
+
data: {
|
|
28
|
+
...call.data,
|
|
29
|
+
chainId: call.chainId,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
...call,
|
|
34
|
+
signature,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
case "user-operation-v060":
|
|
38
|
+
case "user-operation-v070": {
|
|
39
|
+
const { signatureRequest, ...rest } = call;
|
|
40
|
+
const signature = await signSignatureRequest(signer, signatureRequest);
|
|
41
|
+
return {
|
|
42
|
+
...rest,
|
|
43
|
+
signature,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
default: {
|
|
47
|
+
return assertNever(call, "Unexpected call type");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
})),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=signPreparedCalls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/signPreparedCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAQ7C;;;;;;IAMI;AACJ,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA0B,EAC1B,MAA+B;IAE/B,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC5B,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC7C,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACvE,OAAO;YACL,GAAG,IAAI;YACP,SAAS;SACV,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,OAAgB;QACtB,IAAI,EAAE,MAAM,OAAO,CAAC,GAAG,CACrB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAC7B,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;gBAClB,KAAK,eAAe,CAAC,CAAC,CAAC;oBACrB,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE;wBACnD,IAAI,EAAE,aAAa;wBACnB,IAAI,EAAE;4BACJ,GAAG,IAAI,CAAC,IAAI;4BACZ,OAAO,EAAE,IAAI,CAAC,OAAO;yBACtB;qBACF,CAAC,CAAC;oBACH,OAAO;wBACL,GAAG,IAAI;wBACP,SAAS;qBACV,CAAC;gBACJ,CAAC;gBACD,KAAK,qBAAqB,CAAC;gBAC3B,KAAK,qBAAqB,CAAC,CAAC,CAAC;oBAC3B,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;oBAC3C,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAC1C,MAAM,EACN,gBAAgB,CACjB,CAAC;oBACF,OAAO;wBACL,GAAG,IAAI;wBACP,SAAS;qBACV,CAAC;gBACJ,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACR,OAAO,WAAW,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;gBACnD,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CACH;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { PrepareCallsResult } from \"./prepareCalls.ts\";\nimport type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { wallet_sendPreparedCalls } from \"../../rpc/request.js\";\nimport { assertNever } from \"../../utils.js\";\n\nexport type SignPreparedCallsParams = PrepareCallsResult;\n\nexport type SignPreparedCallsResult = Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n>[0];\n\n/**\n * Signs prepared calls using the provided signer.\n *\n * @param {SmartAccountSigner} signer - The signer to use\n * @param {SignPreparedCallsParams} params - The prepared calls with signature requests\n * @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls\n **/\nexport async function signPreparedCalls(\n signer: SmartAccountSigner,\n params: SignPreparedCallsParams,\n): Promise<SignPreparedCallsResult> {\n if (params.type !== \"array\") {\n const { signatureRequest, ...call } = params;\n const signature = await signSignatureRequest(signer, signatureRequest);\n return {\n ...call,\n signature,\n };\n }\n\n return {\n type: \"array\" as const,\n data: await Promise.all(\n params.data.map(async (call) => {\n switch (call.type) {\n case \"authorization\": {\n const signature = await signSignatureRequest(signer, {\n type: \"eip7702Auth\",\n data: {\n ...call.data,\n chainId: call.chainId,\n },\n });\n return {\n ...call,\n signature,\n };\n }\n case \"user-operation-v060\":\n case \"user-operation-v070\": {\n const { signatureRequest, ...rest } = call;\n const signature = await signSignatureRequest(\n signer,\n signatureRequest,\n );\n return {\n ...rest,\n signature,\n };\n }\n default: {\n return assertNever(call, \"Unexpected call type\");\n }\n }\n }),\n ),\n };\n}\n"]}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import type { Static } from "@sinclair/typebox";
|
|
3
3
|
import { type Hex } from "viem";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
export type SignSignatureRequestParams = Static<typeof
|
|
4
|
+
import { TypeAuthorizationSignatureRequest, TypePersonalSignSignatureRequest, TypeTypedDataSignatureRequest } from "../../schemas.js";
|
|
5
|
+
import { TypeEip7702UnsignedAuth } from "../../schemas.js";
|
|
6
|
+
export type SignSignatureRequestParams = Static<typeof TypePersonalSignSignatureRequest> | Static<typeof TypeTypedDataSignatureRequest> | (Static<typeof TypeAuthorizationSignatureRequest> & {
|
|
7
|
+
data: Static<typeof TypeEip7702UnsignedAuth>;
|
|
8
|
+
});
|
|
7
9
|
export type SignSignatureRequestResult = {
|
|
8
|
-
type: "
|
|
9
|
-
|
|
10
|
-
signedAuthorization?: Eip7702ExtendedFields["eip7702Auth"];
|
|
10
|
+
type: "secp256k1";
|
|
11
|
+
data: Hex;
|
|
11
12
|
};
|
|
12
13
|
/**
|
|
13
14
|
* Signs a signature request using the provided signer.
|
|
14
|
-
* This method handles different types of signature requests including personal_sign and
|
|
15
|
+
* This method handles different types of signature requests including personal_sign, eth_signTypedData_v4, and authorization.
|
|
15
16
|
*
|
|
16
17
|
* @param {SmartAccountSigner} signer - The signer to use for signing the request
|
|
17
18
|
* @param {SignSignatureRequestParams} params - The signature request parameters
|
|
18
19
|
* @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')
|
|
19
20
|
* @param {any} params.data - The data to sign, format depends on the signature type
|
|
20
21
|
* @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result
|
|
21
|
-
* @returns {string} result.type - The signature type (currently only '
|
|
22
|
+
* @returns {string} result.type - The signature type (currently only 'secp256k1' is supported)
|
|
22
23
|
* @returns {Hex} result.signature - The hex-encoded signature
|
|
23
24
|
* @returns {Eip7702ExtendedFields["eip7702Auth"]} result.signedAuthorization - The signed EIP-7702 authorization, if applicable
|
|
24
25
|
*
|
|
@@ -1,36 +1,74 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TypeSignatureRequest } from "../../schemas.js";
|
|
1
|
+
import { hexToNumber, serializeSignature } from "viem";
|
|
3
2
|
import { assertNever } from "../../utils.js";
|
|
3
|
+
import { TypeAuthorizationSignatureRequest, TypePersonalSignSignatureRequest, TypeTypedDataSignatureRequest, } from "../../schemas.js";
|
|
4
|
+
import { TypeEip7702UnsignedAuth } from "../../schemas.js";
|
|
5
|
+
import { vToYParity } from "ox/Signature";
|
|
6
|
+
/**
|
|
7
|
+
* Signs a signature request using the provided signer.
|
|
8
|
+
* This method handles different types of signature requests including personal_sign, eth_signTypedData_v4, and authorization.
|
|
9
|
+
*
|
|
10
|
+
* @param {SmartAccountSigner} signer - The signer to use for signing the request
|
|
11
|
+
* @param {SignSignatureRequestParams} params - The signature request parameters
|
|
12
|
+
* @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')
|
|
13
|
+
* @param {any} params.data - The data to sign, format depends on the signature type
|
|
14
|
+
* @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result
|
|
15
|
+
* @returns {string} result.type - The signature type (currently only 'secp256k1' is supported)
|
|
16
|
+
* @returns {Hex} result.signature - The hex-encoded signature
|
|
17
|
+
* @returns {Eip7702ExtendedFields["eip7702Auth"]} result.signedAuthorization - The signed EIP-7702 authorization, if applicable
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Sign a personal message
|
|
21
|
+
* const result = await client.signSignatureRequest({
|
|
22
|
+
* type: 'personal_sign',
|
|
23
|
+
* data: 'Hello, world!'
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Sign typed data (EIP-712)
|
|
28
|
+
* const result = await client.signSignatureRequest({
|
|
29
|
+
* type: 'eth_signTypedData_v4',
|
|
30
|
+
* data: {
|
|
31
|
+
* domain: { ... },
|
|
32
|
+
* types: { ... },
|
|
33
|
+
* primaryType: '...',
|
|
34
|
+
* message: { ... }
|
|
35
|
+
* }
|
|
36
|
+
* });
|
|
37
|
+
*/
|
|
4
38
|
export async function signSignatureRequest(signer, params) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
39
|
+
switch (params.type) {
|
|
40
|
+
case "personal_sign": {
|
|
41
|
+
return {
|
|
42
|
+
type: "secp256k1",
|
|
43
|
+
data: await signer.signMessage(params.data),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
case "eth_signTypedData_v4": {
|
|
47
|
+
return {
|
|
48
|
+
type: "secp256k1",
|
|
49
|
+
data: await signer.signTypedData(params.data),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
case "eip7702Auth": {
|
|
53
|
+
if (!signer.signAuthorization) {
|
|
54
|
+
throw new Error("Signer does not implement signAuthorization");
|
|
55
|
+
}
|
|
56
|
+
const { r, s, v, yParity } = await signer.signAuthorization({
|
|
57
|
+
...params.data,
|
|
58
|
+
chainId: hexToNumber(params.data.chainId),
|
|
59
|
+
nonce: hexToNumber(params.data.nonce),
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
type: "secp256k1",
|
|
63
|
+
data: serializeSignature({
|
|
64
|
+
r,
|
|
65
|
+
s,
|
|
66
|
+
yParity: yParity ?? vToYParity(Number(v)),
|
|
67
|
+
}),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
default:
|
|
71
|
+
return assertNever(params, `Unexpected signature request type.`);
|
|
15
72
|
}
|
|
16
|
-
if (!signer.signAuthorization) {
|
|
17
|
-
throw new Error("Signer does not implement signAuthorization");
|
|
18
|
-
}
|
|
19
|
-
const authSig = await signer.signAuthorization(params.authorizationRequest);
|
|
20
|
-
const { r, s } = authSig;
|
|
21
|
-
const yParity = toHex(authSig.yParity ?? authSig.v - 27n);
|
|
22
|
-
const signedAuthorization = {
|
|
23
|
-
chainId: toHex(params.authorizationRequest.chainId),
|
|
24
|
-
nonce: toHex(params.authorizationRequest.nonce),
|
|
25
|
-
address: params.authorizationRequest.address,
|
|
26
|
-
r,
|
|
27
|
-
s,
|
|
28
|
-
yParity,
|
|
29
|
-
};
|
|
30
|
-
return {
|
|
31
|
-
type: "ecdsa",
|
|
32
|
-
signature,
|
|
33
|
-
signedAuthorization,
|
|
34
|
-
};
|
|
35
73
|
}
|
|
36
74
|
//# sourceMappingURL=signSignatureRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signSignatureRequest.js","sourceRoot":"","sources":["../../../../src/client/actions/signSignatureRequest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,
|
|
1
|
+
{"version":3,"file":"signSignatureRequest.js","sourceRoot":"","sources":["../../../../src/client/actions/signSignatureRequest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,WAAW,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EACL,iCAAiC,EACjC,gCAAgC,EAChC,6BAA6B,GAC9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAc1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAA0B,EAC1B,MAAkC;IAElC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,eAAe,CAAC,CAAC,CAAC;YACrB,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;aAC5C,CAAC;QACJ,CAAC;QACD,KAAK,sBAAsB,CAAC,CAAC,CAAC;YAC5B,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,MAAM,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC;aAC9C,CAAC;QACJ,CAAC;QACD,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;YACjE,CAAC;YACD,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC;gBAC1D,GAAG,MAAM,CAAC,IAAI;gBACd,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;gBACzC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aACtC,CAAC,CAAC;YAEH,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,kBAAkB,CAAC;oBACvB,CAAC;oBACD,CAAC;oBACD,OAAO,EAAE,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;iBAC1C,CAAC;aACH,CAAC;QACJ,CAAC;QACD;YACE,OAAO,WAAW,CAAC,MAAM,EAAE,oCAAoC,CAAC,CAAC;IACrE,CAAC;AACH,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { type Hex, hexToNumber, serializeSignature } from \"viem\";\nimport { assertNever } from \"../../utils.js\";\nimport {\n TypeAuthorizationSignatureRequest,\n TypePersonalSignSignatureRequest,\n TypeTypedDataSignatureRequest,\n} from \"../../schemas.js\";\nimport { TypeEip7702UnsignedAuth } from \"../../schemas.js\";\nimport { vToYParity } from \"ox/Signature\";\n\nexport type SignSignatureRequestParams =\n | Static<typeof TypePersonalSignSignatureRequest>\n | Static<typeof TypeTypedDataSignatureRequest>\n | (Static<typeof TypeAuthorizationSignatureRequest> & {\n data: Static<typeof TypeEip7702UnsignedAuth>;\n });\n\nexport type SignSignatureRequestResult = {\n type: \"secp256k1\";\n data: Hex;\n};\n\n/**\n * Signs a signature request using the provided signer.\n * This method handles different types of signature requests including personal_sign, eth_signTypedData_v4, and authorization.\n *\n * @param {SmartAccountSigner} signer - The signer to use for signing the request\n * @param {SignSignatureRequestParams} params - The signature request parameters\n * @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')\n * @param {any} params.data - The data to sign, format depends on the signature type\n * @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result\n * @returns {string} result.type - The signature type (currently only 'secp256k1' is supported)\n * @returns {Hex} result.signature - The hex-encoded signature\n * @returns {Eip7702ExtendedFields[\"eip7702Auth\"]} result.signedAuthorization - The signed EIP-7702 authorization, if applicable\n *\n * @example\n * // Sign a personal message\n * const result = await client.signSignatureRequest({\n * type: 'personal_sign',\n * data: 'Hello, world!'\n * });\n *\n * @example\n * // Sign typed data (EIP-712)\n * const result = await client.signSignatureRequest({\n * type: 'eth_signTypedData_v4',\n * data: {\n * domain: { ... },\n * types: { ... },\n * primaryType: '...',\n * message: { ... }\n * }\n * });\n */\n\nexport async function signSignatureRequest(\n signer: SmartAccountSigner,\n params: SignSignatureRequestParams,\n): Promise<SignSignatureRequestResult> {\n switch (params.type) {\n case \"personal_sign\": {\n return {\n type: \"secp256k1\",\n data: await signer.signMessage(params.data),\n };\n }\n case \"eth_signTypedData_v4\": {\n return {\n type: \"secp256k1\",\n data: await signer.signTypedData(params.data),\n };\n }\n case \"eip7702Auth\": {\n if (!signer.signAuthorization) {\n throw new Error(\"Signer does not implement signAuthorization\");\n }\n const { r, s, v, yParity } = await signer.signAuthorization({\n ...params.data,\n chainId: hexToNumber(params.data.chainId),\n nonce: hexToNumber(params.data.nonce),\n });\n\n return {\n type: \"secp256k1\",\n data: serializeSignature({\n r,\n s,\n yParity: yParity ?? vToYParity(Number(v)),\n }),\n };\n }\n default:\n return assertNever(params, `Unexpected signature request type.`);\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
-
import { type Address, type Hex, type
|
|
2
|
+
import { type Address, type Hex, type TypedDataDefinition } from "viem";
|
|
3
3
|
import type { InnerWalletApiClient } from "../../types.ts";
|
|
4
4
|
export type SignTypedDataParams = TypedDataDefinition & {
|
|
5
5
|
account?: Address;
|
|
@@ -36,4 +36,4 @@ export type SignTypedDataResult = Hex;
|
|
|
36
36
|
* }
|
|
37
37
|
* });
|
|
38
38
|
*/
|
|
39
|
-
export declare function signTypedData
|
|
39
|
+
export declare function signTypedData(client: InnerWalletApiClient, signer: SmartAccountSigner, params: SignTypedDataParams): Promise<SignTypedDataResult>;
|
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
import {} from "viem";
|
|
2
2
|
import { requestAccount } from "./requestAccount.js";
|
|
3
|
+
/**
|
|
4
|
+
* Signs typed data (EIP-712) using the smart account.
|
|
5
|
+
* This method requests the account associated with the signer and uses it to sign the typed data.
|
|
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 {TypedDataDefinition} params - The typed data to sign, following EIP-712 format
|
|
10
|
+
* @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Sign typed data
|
|
14
|
+
* const signature = await client.signTypedData({
|
|
15
|
+
* domain: {
|
|
16
|
+
* name: 'Example DApp',
|
|
17
|
+
* version: '1',
|
|
18
|
+
* chainId: 1,
|
|
19
|
+
* verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'
|
|
20
|
+
* },
|
|
21
|
+
* types: {
|
|
22
|
+
* Person: [
|
|
23
|
+
* { name: 'name', type: 'string' },
|
|
24
|
+
* { name: 'wallet', type: 'address' }
|
|
25
|
+
* ]
|
|
26
|
+
* },
|
|
27
|
+
* primaryType: 'Person',
|
|
28
|
+
* message: {
|
|
29
|
+
* name: 'John Doe',
|
|
30
|
+
* wallet: '0xAaAaAaAaAaAaAaAaAaAAAAAAAAaaaAaAaAaaAaAa'
|
|
31
|
+
* }
|
|
32
|
+
* });
|
|
33
|
+
*/
|
|
3
34
|
export async function signTypedData(client, signer, params) {
|
|
4
35
|
const account = await requestAccount(client, signer, {
|
|
5
36
|
accountAddress: params.account ?? client.account?.address,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signTypedData.js","sourceRoot":"","sources":["../../../../src/client/actions/signTypedData.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"signTypedData.js","sourceRoot":"","sources":["../../../../src/client/actions/signTypedData.ts"],"names":[],"mappings":"AACA,OAAO,EAAoD,MAAM,MAAM,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAQrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA4B,EAC5B,MAA0B,EAC1B,MAA2B;IAE3B,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE;QACnD,cAAc,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO;KAC1D,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport { type Address, type Hex, type TypedDataDefinition } from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport { requestAccount } from \"./requestAccount.js\";\n\nexport type SignTypedDataParams = TypedDataDefinition & {\n account?: Address;\n};\n\nexport type SignTypedDataResult = Hex;\n\n/**\n * Signs typed data (EIP-712) using the smart account.\n * This method requests the account associated with the signer and uses it to sign the typed data.\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 {TypedDataDefinition} params - The typed data to sign, following EIP-712 format\n * @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string\n *\n * @example\n * // Sign typed data\n * const signature = await client.signTypedData({\n * domain: {\n * name: 'Example DApp',\n * version: '1',\n * chainId: 1,\n * verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'\n * },\n * types: {\n * Person: [\n * { name: 'name', type: 'string' },\n * { name: 'wallet', type: 'address' }\n * ]\n * },\n * primaryType: 'Person',\n * message: {\n * name: 'John Doe',\n * wallet: '0xAaAaAaAaAaAaAaAaAaAAAAAAAAaaaAaAaAaaAaAa'\n * }\n * });\n */\nexport async function signTypedData(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params: SignTypedDataParams,\n): Promise<SignTypedDataResult> {\n const account = await requestAccount(client, signer, {\n accountAddress: params.account ?? client.account?.address,\n });\n\n return account.signTypedDataWith6492(params);\n}\n"]}
|