@account-kit/wallet-client 0.1.0-alpha.1 → 0.1.0-alpha.11
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 +249 -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 +40 -11
- 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 +38 -27
- 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 +165 -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 +408 -127
- 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 +56 -13
- package/src/isomorphic/actions/formatSign.ts +76 -0
- package/src/isomorphic/actions/getCallsStatus.ts +47 -33
- package/src/isomorphic/actions/prepareCalls.ts +95 -23
- package/src/isomorphic/actions/prepareSign.ts +88 -0
- package/src/isomorphic/actions/sendPreparedCalls.ts +218 -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
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { toHex } from "viem";
|
|
2
|
+
import { AccountNotFoundError } from "@aa-sdk/core";
|
|
3
|
+
/**
|
|
4
|
+
* Prepares a signature request for signing messages or transactions.
|
|
5
|
+
*
|
|
6
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
7
|
+
* @param {PrepareSignParams} params - Parameters for preparing the signature request
|
|
8
|
+
* @returns {Promise<PrepareSignResult>} A Promise that resolves to the prepare sign result containing a signature request
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Prepare a message to be signed
|
|
12
|
+
* const result = await client.prepareSign({
|
|
13
|
+
* from: "0x1234...",
|
|
14
|
+
* type: "personal_sign",
|
|
15
|
+
* data: "Hello, world!",
|
|
16
|
+
* });
|
|
17
|
+
*/
|
|
18
|
+
export async function prepareSign(client, params) {
|
|
19
|
+
const from = params.from ?? client.account?.address;
|
|
20
|
+
if (!from) {
|
|
21
|
+
throw new AccountNotFoundError();
|
|
22
|
+
}
|
|
23
|
+
return client.request({
|
|
24
|
+
method: "wallet_prepareSign",
|
|
25
|
+
params: [{ ...params, from, chainId: toHex(client.chain.id) }],
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=prepareSign.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareSign.js","sourceRoot":"","sources":["../../../../src/client/actions/prepareSign.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAkC,MAAM,MAAM,CAAC;AAK7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AASpD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAG/B,MAA4B,EAC5B,MAAmC;IAEnC,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,oBAAoB;QAC5B,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 { InnerWalletApiClient } from \"../../types.ts\";\nimport { toHex, type Address, type IsUndefined } from \"viem\";\nimport type {\n PrepareSignParams as IsomorphicPrepareSignParams,\n PrepareSignResult as IsomorphicPrepareSignResult,\n} from \"../../isomorphic/actions/prepareSign.ts\";\nimport { AccountNotFoundError } from \"@aa-sdk/core\";\n\nexport type PrepareSignParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Omit<IsomorphicPrepareSignParams, \"from\" | \"chainId\"> &\n (IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });\n\nexport type PrepareSignResult = IsomorphicPrepareSignResult;\n\n/**\n * Prepares a signature request for signing messages or transactions.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {PrepareSignParams} params - Parameters for preparing the signature request\n * @returns {Promise<PrepareSignResult>} A Promise that resolves to the prepare sign result containing a signature request\n *\n * @example\n * // Prepare a message to be signed\n * const result = await client.prepareSign({\n * from: \"0x1234...\",\n * type: \"personal_sign\",\n * data: \"Hello, world!\",\n * });\n */\nexport async function prepareSign<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n params: PrepareSignParams<TAccount>,\n): Promise<PrepareSignResult> {\n const from = params.from ?? client.account?.address;\n if (!from) {\n throw new AccountNotFoundError();\n }\n\n return client.request({\n method: \"wallet_prepareSign\",\n params: [{ ...params, from, chainId: toHex(client.chain.id) }],\n });\n}\n"]}
|
|
@@ -1,11 +1,29 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type SmartAccountSigner, type SmartContractAccount } from "@aa-sdk/core";
|
|
2
2
|
import type { Static } from "@sinclair/typebox";
|
|
3
3
|
import type { Address } from "abitype";
|
|
4
|
-
import
|
|
5
|
-
import type { wallet_requestAccount } from "../../rpc/request.js";
|
|
4
|
+
import type { wallet_requestAccount } from "@alchemy/wallet-api-types/rpc";
|
|
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
|
-
}>, "signerAddress" | "includeCounterfactualInfo">
|
|
8
|
+
}>, "signerAddress" | "includeCounterfactualInfo"> & {
|
|
9
|
+
accountAddress?: Address;
|
|
10
|
+
};
|
|
10
11
|
export type RequestAccountResult = SmartContractAccount;
|
|
11
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Requests an account for the provided signer using the wallet API client.
|
|
14
|
+
* If an account already exists for the signer, it will always return that account unless a new ID is specified.
|
|
15
|
+
* If an account already exists, the creationHint will be ignored.
|
|
16
|
+
*
|
|
17
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
18
|
+
* @param {SmartAccountSigner} signer - The signer that will be associated with the account
|
|
19
|
+
* @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account
|
|
20
|
+
* @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
|
|
21
|
+
* @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists
|
|
22
|
+
* @returns {Promise<RequestAccountResult>} A Promise that resolves to a SmartContractAccount instance
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Request an account with default parameters using a local signer
|
|
26
|
+
* const signer = LocalAccountSigner.privateKeyToAccountSigner("0x...");
|
|
27
|
+
* const account = await client.requestAccount(signer);
|
|
28
|
+
*/
|
|
29
|
+
export declare function requestAccount(client: InnerWalletApiClient, signer: SmartAccountSigner, params?: RequestAccountParams): Promise<RequestAccountResult>;
|
|
@@ -1,11 +1,30 @@
|
|
|
1
|
+
import {} from "@aa-sdk/core";
|
|
1
2
|
import { Value } from "@sinclair/typebox/value";
|
|
3
|
+
import deepEqual from "deep-equal";
|
|
2
4
|
import { custom } from "viem";
|
|
3
5
|
import { createAccount } from "../../isomorphic/utils/createAccount.js";
|
|
4
|
-
import {
|
|
6
|
+
import { SerializedInitcode } from "@alchemy/wallet-api-types";
|
|
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
|
+
*/
|
|
5
24
|
export async function requestAccount(client, signer, params) {
|
|
6
|
-
const args = client.account && !params
|
|
25
|
+
const args = (client.account && !params) || params?.accountAddress
|
|
7
26
|
? {
|
|
8
|
-
accountAddress: client.account.address,
|
|
27
|
+
accountAddress: params?.accountAddress ?? client.account.address,
|
|
9
28
|
includeCounterfactualInfo: true,
|
|
10
29
|
}
|
|
11
30
|
: {
|
|
@@ -13,16 +32,28 @@ export async function requestAccount(client, signer, params) {
|
|
|
13
32
|
signerAddress: await signer.getAddress(),
|
|
14
33
|
includeCounterfactualInfo: true,
|
|
15
34
|
};
|
|
16
|
-
const
|
|
35
|
+
const cachedAccount = client.internal.getAccount();
|
|
36
|
+
if (cachedAccount &&
|
|
37
|
+
((args.accountAddress &&
|
|
38
|
+
cachedAccount.account.address === args.accountAddress) ||
|
|
39
|
+
deepEqual(cachedAccount.requestParams, args, { strict: true }))) {
|
|
40
|
+
return cachedAccount.account;
|
|
41
|
+
}
|
|
42
|
+
const { accountAddress, counterfactualInfo, delegation } = await client.request({
|
|
17
43
|
method: "wallet_requestAccount",
|
|
18
44
|
params: [args],
|
|
19
45
|
});
|
|
20
|
-
|
|
21
|
-
accountAddress
|
|
22
|
-
counterfactualInfo:
|
|
46
|
+
const account = await createAccount({
|
|
47
|
+
accountAddress,
|
|
48
|
+
counterfactualInfo: counterfactualInfo
|
|
49
|
+
? Value.Parse(SerializedInitcode, counterfactualInfo)
|
|
50
|
+
: undefined,
|
|
51
|
+
delegation,
|
|
23
52
|
chain: client.chain,
|
|
24
53
|
transport: custom(client.transport),
|
|
25
54
|
signer,
|
|
26
55
|
});
|
|
56
|
+
client.internal.setAccount({ account, requestParams: args });
|
|
57
|
+
return account;
|
|
27
58
|
}
|
|
28
59
|
//# sourceMappingURL=requestAccount.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/requestAccount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"requestAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/requestAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAExE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAa/D;;;;;;;;;;;;;;;;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;IAEnD,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,cAAc,EAAE,kBAAkB,EAAE,UAAU,EAAE,GACtD,MAAM,MAAM,CAAC,OAAO,CAAC;QACnB,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,IAAI,CAAC;KACf,CAAC,CAAC;IAEL,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC;QAClC,cAAc;QACd,kBAAkB,EAAE,kBAAkB;YACpC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;YACrD,CAAC,CAAC,SAAS;QACb,UAAU;QACV,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 \"@alchemy/wallet-api-types/rpc\";\nimport { SerializedInitcode } from \"@alchemy/wallet-api-types\";\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\n if (\n cachedAccount &&\n ((args.accountAddress &&\n cachedAccount.account.address === args.accountAddress) ||\n deepEqual(cachedAccount.requestParams, args, { strict: true }))\n ) {\n return cachedAccount.account;\n }\n\n const { accountAddress, counterfactualInfo, delegation } =\n await client.request({\n method: \"wallet_requestAccount\",\n params: [args],\n });\n\n const account = await createAccount({\n accountAddress,\n counterfactualInfo: counterfactualInfo\n ? Value.Parse(SerializedInitcode, counterfactualInfo)\n : undefined,\n delegation,\n chain: client.chain,\n transport: custom(client.transport),\n signer,\n });\n\n client.internal.setAccount({ account, requestParams: args });\n\n return account;\n}\n"]}
|
|
@@ -1,6 +1,35 @@
|
|
|
1
|
-
import type { Static
|
|
2
|
-
import type { wallet_sendPreparedCalls } from "
|
|
3
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
4
|
-
export type SendPreparedCallsParams =
|
|
1
|
+
import type { Static } from "@sinclair/typebox";
|
|
2
|
+
import type { wallet_sendPreparedCalls } from "@alchemy/wallet-api-types/rpc";
|
|
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
|
+
/**
|
|
7
|
+
* Sends prepared calls by submitting a signed user operation.
|
|
8
|
+
* This method is used after signing the signature request returned from prepareCalls.
|
|
9
|
+
*
|
|
10
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
11
|
+
* @param {SendPreparedCallsParams} params - Parameters for sending prepared calls
|
|
12
|
+
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // First prepare the calls
|
|
16
|
+
* const preparedCalls = await client.prepareCalls({
|
|
17
|
+
* calls: [{
|
|
18
|
+
* to: "0x1234...",
|
|
19
|
+
* data: "0xabcdef...",
|
|
20
|
+
* value: "0x0"
|
|
21
|
+
* }],
|
|
22
|
+
* capabilities: {
|
|
23
|
+
* paymasterService: { policyId: "your-policy-id" }
|
|
24
|
+
* }
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Then sign the calls
|
|
28
|
+
* const signedCalls = await client.signPreparedCalls(preparedCalls);
|
|
29
|
+
*
|
|
30
|
+
* // Then send the prepared calls with the signature
|
|
31
|
+
* const result = await client.sendPreparedCalls({
|
|
32
|
+
* signedCalls,
|
|
33
|
+
* });
|
|
34
|
+
*/
|
|
6
35
|
export declare function sendPreparedCalls(client: InnerWalletApiClient, params: SendPreparedCallsParams): Promise<SendPreparedCallsResult>;
|
|
@@ -1,8 +1,44 @@
|
|
|
1
1
|
import { toHex } from "viem";
|
|
2
|
+
/**
|
|
3
|
+
* Sends prepared calls by submitting a signed user operation.
|
|
4
|
+
* This method is used after signing the signature request returned from prepareCalls.
|
|
5
|
+
*
|
|
6
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
7
|
+
* @param {SendPreparedCallsParams} params - Parameters for sending prepared calls
|
|
8
|
+
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // First prepare the calls
|
|
12
|
+
* const preparedCalls = await client.prepareCalls({
|
|
13
|
+
* calls: [{
|
|
14
|
+
* to: "0x1234...",
|
|
15
|
+
* data: "0xabcdef...",
|
|
16
|
+
* value: "0x0"
|
|
17
|
+
* }],
|
|
18
|
+
* capabilities: {
|
|
19
|
+
* paymasterService: { policyId: "your-policy-id" }
|
|
20
|
+
* }
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Then sign the calls
|
|
24
|
+
* const signedCalls = await client.signPreparedCalls(preparedCalls);
|
|
25
|
+
*
|
|
26
|
+
* // Then send the prepared calls with the signature
|
|
27
|
+
* const result = await client.sendPreparedCalls({
|
|
28
|
+
* signedCalls,
|
|
29
|
+
* });
|
|
30
|
+
*/
|
|
2
31
|
export async function sendPreparedCalls(client, params) {
|
|
3
32
|
return client.request({
|
|
4
33
|
method: "wallet_sendPreparedCalls",
|
|
5
|
-
params: [
|
|
34
|
+
params: [
|
|
35
|
+
params.type === "array"
|
|
36
|
+
? params
|
|
37
|
+
: {
|
|
38
|
+
...params,
|
|
39
|
+
chainId: toHex(client.chain.id),
|
|
40
|
+
},
|
|
41
|
+
],
|
|
6
42
|
});
|
|
7
43
|
}
|
|
8
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 \"@alchemy/wallet-api-types/rpc\";\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,6 +1,26 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { type Address, type Hex, type
|
|
3
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
4
|
-
export type SignMessageParams =
|
|
1
|
+
import { type SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
+
import { type Address, type Hex, type SignableMessage } from "viem";
|
|
3
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
4
|
+
export type SignMessageParams = {
|
|
5
|
+
message: SignableMessage;
|
|
6
|
+
account?: Address;
|
|
7
|
+
};
|
|
5
8
|
export type SignMessageResult = Hex;
|
|
6
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Signs a message using the smart account.
|
|
11
|
+
* This method requests the account associated with the signer and uses it to sign the message.
|
|
12
|
+
*
|
|
13
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
14
|
+
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
15
|
+
* @param {SignableMessage} message - The message to sign
|
|
16
|
+
* @returns {Promise<SignMessageResult>} A Promise that resolves to the signed message as a hex string
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Sign a simple text message
|
|
20
|
+
* const signature = await client.signMessage("Hello, world!");
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Sign a raw hex message
|
|
24
|
+
* const signature = await client.signMessage({ raw: "0x48656c6c6f2c20776f726c6421" });
|
|
25
|
+
*/
|
|
26
|
+
export declare function signMessage(client: InnerWalletApiClient, signer: SmartAccountSigner, params: SignMessageParams): Promise<SignMessageResult>;
|
|
@@ -1,7 +1,27 @@
|
|
|
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
|
-
const account = await requestAccount(client, signer
|
|
5
|
-
|
|
22
|
+
const account = await requestAccount(client, signer, {
|
|
23
|
+
accountAddress: params.account ?? client.account?.address,
|
|
24
|
+
});
|
|
25
|
+
return account.signMessageWith6492({ message: params.message });
|
|
6
26
|
}
|
|
7
27
|
//# sourceMappingURL=signMessage.js.map
|
|
@@ -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 "@alchemy/wallet-api-types/rpc";
|
|
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,43 @@
|
|
|
1
|
+
import { signSignatureRequest } from "./signSignatureRequest.js";
|
|
2
|
+
import { wallet_sendPreparedCalls } from "@alchemy/wallet-api-types/rpc";
|
|
3
|
+
import {} from "@alchemy/wallet-api-types";
|
|
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
|
+
const signAuthorizationCall = async (call) => {
|
|
13
|
+
const { signatureRequest: _signatureRequest, ...rest } = call;
|
|
14
|
+
const signature = await signSignatureRequest(signer, {
|
|
15
|
+
type: "eip7702Auth",
|
|
16
|
+
data: {
|
|
17
|
+
...rest.data,
|
|
18
|
+
chainId: call.chainId,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
...rest,
|
|
23
|
+
signature,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const signUserOperationCall = async (call) => {
|
|
27
|
+
const { signatureRequest, ...rest } = call;
|
|
28
|
+
const signature = await signSignatureRequest(signer, signatureRequest);
|
|
29
|
+
return {
|
|
30
|
+
...rest,
|
|
31
|
+
signature,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
return params.type === "array"
|
|
35
|
+
? {
|
|
36
|
+
type: "array",
|
|
37
|
+
data: await Promise.all(params.data.map((call) => call.type === "authorization"
|
|
38
|
+
? signAuthorizationCall(call)
|
|
39
|
+
: signUserOperationCall(call))),
|
|
40
|
+
}
|
|
41
|
+
: signUserOperationCall(params);
|
|
42
|
+
}
|
|
43
|
+
//# 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,+BAA+B,CAAC;AACzE,OAAO,EAIN,MAAM,2BAA2B,CAAC;AAQnC;;;;;;IAMI;AACJ,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA0B,EAC1B,MAA+B;IAE/B,MAAM,qBAAqB,GAAG,KAAK,EAAE,IAAgC,EAAE,EAAE;QACvE,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QAC9D,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE;YACnD,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE;gBACJ,GAAG,IAAI,CAAC,IAAI;gBACZ,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB;SACF,CAAC,CAAC;QACH,OAAO;YACL,GAAG,IAAI;YACP,SAAS;SACV,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,qBAAqB,GAAG,KAAK,EACjC,IAAuD,EACvD,EAAE;QACF,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QAC3C,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACvE,OAAO;YACL,GAAG,IAAI;YACP,SAAS;SACV,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC,IAAI,KAAK,OAAO;QAC5B,CAAC,CAAC;YACE,IAAI,EAAE,OAAgB;YACtB,IAAI,EAAE,MAAM,OAAO,CAAC,GAAG,CACrB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACvB,IAAI,CAAC,IAAI,KAAK,eAAe;gBAC3B,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC;gBAC7B,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAChC,CACF;SACF;QACH,CAAC,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACpC,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 \"@alchemy/wallet-api-types/rpc\";\nimport {\n type PreparedCall_Authorization,\n type PreparedCall_UserOpV060,\n type PreparedCall_UserOpV070,\n} from \"@alchemy/wallet-api-types\";\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 const signAuthorizationCall = async (call: PreparedCall_Authorization) => {\n const { signatureRequest: _signatureRequest, ...rest } = call;\n const signature = await signSignatureRequest(signer, {\n type: \"eip7702Auth\",\n data: {\n ...rest.data,\n chainId: call.chainId,\n },\n });\n return {\n ...rest,\n signature,\n };\n };\n\n const signUserOperationCall = async (\n call: PreparedCall_UserOpV060 | PreparedCall_UserOpV070,\n ) => {\n const { signatureRequest, ...rest } = call;\n const signature = await signSignatureRequest(signer, signatureRequest);\n return {\n ...rest,\n signature,\n };\n };\n\n return params.type === \"array\"\n ? {\n type: \"array\" as const,\n data: await Promise.all(\n params.data.map((call) =>\n call.type === \"authorization\"\n ? signAuthorizationCall(call)\n : signUserOperationCall(call),\n ),\n ),\n }\n : signUserOperationCall(params);\n}\n"]}
|
|
@@ -1,10 +1,44 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
-
import type { Static } from "@sinclair/typebox";
|
|
3
2
|
import { type Hex } from "viem";
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import { type PersonalSignSignatureRequest, type TypedDataSignatureRequest, type AuthorizationSignatureRequest, type Eip7702UnsignedAuth } from "@alchemy/wallet-api-types";
|
|
4
|
+
import type { WithoutRawPayload } from "../../types.ts";
|
|
5
|
+
export type SignSignatureRequestParams = WithoutRawPayload<PersonalSignSignatureRequest | TypedDataSignatureRequest | (AuthorizationSignatureRequest & {
|
|
6
|
+
data: Eip7702UnsignedAuth;
|
|
7
|
+
})>;
|
|
6
8
|
export type SignSignatureRequestResult = {
|
|
7
|
-
type: "
|
|
8
|
-
|
|
9
|
+
type: "secp256k1";
|
|
10
|
+
data: Hex;
|
|
9
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Signs a signature request using the provided signer.
|
|
14
|
+
* This method handles different types of signature requests including personal_sign, eth_signTypedData_v4, and authorization.
|
|
15
|
+
*
|
|
16
|
+
* @param {SmartAccountSigner} signer - The signer to use for signing the request
|
|
17
|
+
* @param {SignSignatureRequestParams} params - The signature request parameters
|
|
18
|
+
* @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')
|
|
19
|
+
* @param {any} params.data - The data to sign, format depends on the signature type
|
|
20
|
+
* @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result
|
|
21
|
+
* @returns {string} result.type - The signature type (currently only 'secp256k1' is supported)
|
|
22
|
+
* @returns {Hex} result.signature - The hex-encoded signature
|
|
23
|
+
* @returns {Eip7702ExtendedFields["eip7702Auth"]} result.signedAuthorization - The signed EIP-7702 authorization, if applicable
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Sign a personal message
|
|
27
|
+
* const result = await client.signSignatureRequest({
|
|
28
|
+
* type: 'personal_sign',
|
|
29
|
+
* data: 'Hello, world!'
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // Sign typed data (EIP-712)
|
|
34
|
+
* const result = await client.signSignatureRequest({
|
|
35
|
+
* type: 'eth_signTypedData_v4',
|
|
36
|
+
* data: {
|
|
37
|
+
* domain: { ... },
|
|
38
|
+
* types: { ... },
|
|
39
|
+
* primaryType: '...',
|
|
40
|
+
* message: { ... }
|
|
41
|
+
* }
|
|
42
|
+
* });
|
|
43
|
+
*/
|
|
10
44
|
export declare function signSignatureRequest(signer: SmartAccountSigner, params: SignSignatureRequestParams): Promise<SignSignatureRequestResult>;
|
|
@@ -1,15 +1,73 @@
|
|
|
1
|
-
import {} from "viem";
|
|
2
|
-
import { TypeSignatureRequest } from "../../schemas.js";
|
|
1
|
+
import { hexToNumber, serializeSignature } from "viem";
|
|
3
2
|
import { assertNever } from "../../utils.js";
|
|
3
|
+
import {} from "@alchemy/wallet-api-types";
|
|
4
|
+
import { vToYParity } from "ox/Signature";
|
|
5
|
+
/**
|
|
6
|
+
* Signs a signature request using the provided signer.
|
|
7
|
+
* This method handles different types of signature requests including personal_sign, eth_signTypedData_v4, and authorization.
|
|
8
|
+
*
|
|
9
|
+
* @param {SmartAccountSigner} signer - The signer to use for signing the request
|
|
10
|
+
* @param {SignSignatureRequestParams} params - The signature request parameters
|
|
11
|
+
* @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')
|
|
12
|
+
* @param {any} params.data - The data to sign, format depends on the signature type
|
|
13
|
+
* @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result
|
|
14
|
+
* @returns {string} result.type - The signature type (currently only 'secp256k1' is supported)
|
|
15
|
+
* @returns {Hex} result.signature - The hex-encoded signature
|
|
16
|
+
* @returns {Eip7702ExtendedFields["eip7702Auth"]} result.signedAuthorization - The signed EIP-7702 authorization, if applicable
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Sign a personal message
|
|
20
|
+
* const result = await client.signSignatureRequest({
|
|
21
|
+
* type: 'personal_sign',
|
|
22
|
+
* data: 'Hello, world!'
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Sign typed data (EIP-712)
|
|
27
|
+
* const result = await client.signSignatureRequest({
|
|
28
|
+
* type: 'eth_signTypedData_v4',
|
|
29
|
+
* data: {
|
|
30
|
+
* domain: { ... },
|
|
31
|
+
* types: { ... },
|
|
32
|
+
* primaryType: '...',
|
|
33
|
+
* message: { ... }
|
|
34
|
+
* }
|
|
35
|
+
* });
|
|
36
|
+
*/
|
|
4
37
|
export async function signSignatureRequest(signer, params) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
38
|
+
switch (params.type) {
|
|
39
|
+
case "personal_sign": {
|
|
40
|
+
return {
|
|
41
|
+
type: "secp256k1",
|
|
42
|
+
data: await signer.signMessage(params.data),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
case "eth_signTypedData_v4": {
|
|
46
|
+
return {
|
|
47
|
+
type: "secp256k1",
|
|
48
|
+
data: await signer.signTypedData(params.data),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
case "eip7702Auth": {
|
|
52
|
+
if (!signer.signAuthorization) {
|
|
53
|
+
throw new Error("Signer does not implement signAuthorization");
|
|
54
|
+
}
|
|
55
|
+
const { r, s, v, yParity } = await signer.signAuthorization({
|
|
56
|
+
...params.data,
|
|
57
|
+
chainId: hexToNumber(params.data.chainId),
|
|
58
|
+
nonce: hexToNumber(params.data.nonce),
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
type: "secp256k1",
|
|
62
|
+
data: serializeSignature({
|
|
63
|
+
r,
|
|
64
|
+
s,
|
|
65
|
+
yParity: yParity ?? vToYParity(Number(v)),
|
|
66
|
+
}),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
default:
|
|
70
|
+
return assertNever(params, `Unexpected signature request type.`);
|
|
71
|
+
}
|
|
14
72
|
}
|
|
15
73
|
//# sourceMappingURL=signSignatureRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signSignatureRequest.js","sourceRoot":"","sources":["../../../../src/client/actions/signSignatureRequest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signSignatureRequest.js","sourceRoot":"","sources":["../../../../src/client/actions/signSignatureRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,WAAW,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAKN,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAgB1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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 Hex, hexToNumber, serializeSignature } from \"viem\";\nimport { assertNever } from \"../../utils.js\";\nimport {\n type PersonalSignSignatureRequest,\n type TypedDataSignatureRequest,\n type AuthorizationSignatureRequest,\n type Eip7702UnsignedAuth,\n} from \"@alchemy/wallet-api-types\";\nimport { vToYParity } from \"ox/Signature\";\nimport type { WithoutRawPayload } from \"../../types.ts\";\n\nexport type SignSignatureRequestParams = WithoutRawPayload<\n | PersonalSignSignatureRequest\n | TypedDataSignatureRequest\n | (AuthorizationSignatureRequest & {\n data: Eip7702UnsignedAuth;\n })\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,6 +1,39 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
-
import { type Address, type Hex, type
|
|
3
|
-
import type { InnerWalletApiClient } from "../../types";
|
|
4
|
-
export type SignTypedDataParams = TypedDataDefinition
|
|
2
|
+
import { type Address, type Hex, type TypedDataDefinition } from "viem";
|
|
3
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
4
|
+
export type SignTypedDataParams = TypedDataDefinition & {
|
|
5
|
+
account?: Address;
|
|
6
|
+
};
|
|
5
7
|
export type SignTypedDataResult = Hex;
|
|
6
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Signs typed data (EIP-712) using the smart account.
|
|
10
|
+
* This method requests the account associated with the signer and uses it to sign the typed data.
|
|
11
|
+
*
|
|
12
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
13
|
+
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
14
|
+
* @param {TypedDataDefinition} params - The typed data to sign, following EIP-712 format
|
|
15
|
+
* @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Sign typed data
|
|
19
|
+
* const signature = await client.signTypedData({
|
|
20
|
+
* domain: {
|
|
21
|
+
* name: 'Example DApp',
|
|
22
|
+
* version: '1',
|
|
23
|
+
* chainId: 1,
|
|
24
|
+
* verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'
|
|
25
|
+
* },
|
|
26
|
+
* types: {
|
|
27
|
+
* Person: [
|
|
28
|
+
* { name: 'name', type: 'string' },
|
|
29
|
+
* { name: 'wallet', type: 'address' }
|
|
30
|
+
* ]
|
|
31
|
+
* },
|
|
32
|
+
* primaryType: 'Person',
|
|
33
|
+
* message: {
|
|
34
|
+
* name: 'John Doe',
|
|
35
|
+
* wallet: '0xAaAaAaAaAaAaAaAaAaAAAAAAAAaaaAaAaAaaAaAa'
|
|
36
|
+
* }
|
|
37
|
+
* });
|
|
38
|
+
*/
|
|
39
|
+
export declare function signTypedData(client: InnerWalletApiClient, signer: SmartAccountSigner, params: SignTypedDataParams): Promise<SignTypedDataResult>;
|