@alchemy/wallet-apis 5.0.0-beta.23 → 5.0.0-beta.25
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/README.md +2 -0
- package/dist/esm/actions/signTypedData.d.ts +2 -2
- package/dist/esm/actions/signTypedData.js.map +1 -1
- package/dist/esm/utils/format.d.ts +2 -2
- package/dist/esm/utils/format.js +3 -2
- package/dist/esm/utils/format.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/actions/signTypedData.d.ts +2 -2
- package/dist/types/actions/signTypedData.d.ts.map +1 -1
- package/dist/types/utils/format.d.ts +2 -2
- package/dist/types/utils/format.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/actions/signTypedData.ts +7 -2
- package/src/utils/format.ts +7 -2
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @alchemy/wallet-apis
|
|
2
2
|
|
|
3
|
+
**Beta** — This package replaces `@account-kit/wallet-client`. See the [migration guide](https://www.alchemy.com/docs/wallets/resources/migration-v5).
|
|
4
|
+
|
|
3
5
|
High-level viem-style client for Alchemy's Smart Wallet APIs. Provides EIP-7702 smart wallet support with signing, transaction preparation, and call sending.
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type Hex, type Prettify, type TypedDataDefinition } from "viem";
|
|
1
|
+
import { type Hex, type Prettify, type TypedData, type TypedDataDefinition } from "viem";
|
|
2
2
|
import type { InnerWalletApiClient } from "../types.ts";
|
|
3
3
|
import { type AccountParam } from "../utils/resolve.js";
|
|
4
|
-
export type SignTypedDataParams = Prettify<TypedDataDefinition & {
|
|
4
|
+
export type SignTypedDataParams = Prettify<TypedDataDefinition<TypedData | Record<string, unknown>> & {
|
|
5
5
|
account?: AccountParam;
|
|
6
6
|
}>;
|
|
7
7
|
export type SignTypedDataResult = Prettify<Hex>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signTypedData.js","sourceRoot":"","sources":["../../../src/actions/signTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"signTypedData.js","sourceRoot":"","sources":["../../../src/actions/signTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AAUxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA4B,EAC5B,MAA2B;IAE3B,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE;QAClC,kBAAkB,EAAE,MAAM,CAAC,OAAO,IAAI,IAAI;QAC1C,WAAW,EAAE,MAAM,CAAC,WAAW;KAChC,CAAC,CAAC;IACH,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO;QACnC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAE3B,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE;QACzC,OAAO,EAAE,cAAc;QACvB,gBAAgB,EAAE;YAChB,IAAI,EAAE,sBAAsB;YAC5B,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC;SAClC;KACF,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IAE7E,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE;QACzC,OAAO,EAAE,cAAc;QACvB,SAAS,EAAE;YACT,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB;KACF,CAAC,CAAC;IACH,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;IAC7D,OAAO,SAAS,CAAC,SAAS,CAAC;AAC7B,CAAC","sourcesContent":["import {\n type Hex,\n type Prettify,\n type TypedData,\n type TypedDataDefinition,\n} from \"viem\";\nimport type { InnerWalletApiClient } from \"../types.ts\";\nimport { prepareSign } from \"./prepareSign.js\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport { formatSign } from \"./formatSign.js\";\nimport { typedDataToJsonSafe } from \"../utils/format.js\";\nimport { LOGGER } from \"../logger.js\";\nimport { resolveAddress, type AccountParam } from \"../utils/resolve.js\";\n\nexport type SignTypedDataParams = Prettify<\n TypedDataDefinition<TypedData | Record<string, unknown>> & {\n account?: AccountParam;\n }\n>;\n\nexport type SignTypedDataResult = Prettify<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 {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 * ```ts\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 * ```\n */\n\nexport async function signTypedData(\n client: InnerWalletApiClient,\n params: SignTypedDataParams,\n): Promise<SignTypedDataResult> {\n LOGGER.debug(\"signTypedData:start\", {\n hasExplicitAccount: params.account != null,\n primaryType: params.primaryType,\n });\n const accountAddress = params.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n const prepared = await prepareSign(client, {\n account: accountAddress,\n signatureRequest: {\n type: \"eth_signTypedData_v4\",\n data: typedDataToJsonSafe(params),\n },\n });\n\n const signed = await signSignatureRequest(client, prepared.signatureRequest);\n\n const formatted = await formatSign(client, {\n account: accountAddress,\n signature: {\n type: \"ecdsa\",\n data: signed.data,\n },\n });\n LOGGER.debug(\"signTypedData:done\", { from: accountAddress });\n return formatted.signature;\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type Hex, type SignableMessage, type TypedDataDefinition } from "viem";
|
|
1
|
+
import { type Hex, type SignableMessage, type TypedData, type TypedDataDefinition } from "viem";
|
|
2
2
|
import type { TypedDataDefinition as WalletServerTypedDataDefinition } from "@alchemy/wallet-api-types";
|
|
3
3
|
export declare const castToHex: (val: string | number | bigint | Hex) => Hex;
|
|
4
4
|
export declare const signableMessageToJsonSafe: (message: SignableMessage) => string | {
|
|
5
5
|
raw: Hex;
|
|
6
6
|
};
|
|
7
|
-
export declare const typedDataToJsonSafe: ({ domain, primaryType, message, types, }: TypedDataDefinition) => WalletServerTypedDataDefinition;
|
|
7
|
+
export declare const typedDataToJsonSafe: ({ domain, primaryType, message, types, }: TypedDataDefinition<TypedData | Record<string, unknown>>) => WalletServerTypedDataDefinition;
|
package/dist/esm/utils/format.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isHex, toHex, bytesToHex, getTypesForEIP712Domain, } from "viem";
|
|
1
|
+
import { isHex, toHex, bytesToHex, getTypesForEIP712Domain, validateTypedData, } from "viem";
|
|
2
2
|
export const castToHex = (val) => {
|
|
3
3
|
if (isHex(val)) {
|
|
4
4
|
return val;
|
|
@@ -16,6 +16,7 @@ export const signableMessageToJsonSafe = (message) => {
|
|
|
16
16
|
// Purposefully not using `formatTypedData` from the wallet server types pkg
|
|
17
17
|
// here, since that would require typebox at runtime (which breaks RN).
|
|
18
18
|
export const typedDataToJsonSafe = ({ domain, primaryType, message, types, }) => {
|
|
19
|
+
validateTypedData({ domain, primaryType, message, types });
|
|
19
20
|
return {
|
|
20
21
|
domain: {
|
|
21
22
|
...domain,
|
|
@@ -26,7 +27,7 @@ export const typedDataToJsonSafe = ({ domain, primaryType, message, types, }) =>
|
|
|
26
27
|
types: {
|
|
27
28
|
...Object.fromEntries(Object.entries(types).map(([key, value]) => [
|
|
28
29
|
key,
|
|
29
|
-
value ? [...value] : [],
|
|
30
|
+
Array.isArray(value) ? [...value] : [],
|
|
30
31
|
])),
|
|
31
32
|
EIP712Domain: [...getTypesForEIP712Domain({ domain })],
|
|
32
33
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/utils/format.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,KAAK,EAGL,UAAU,
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/utils/format.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,KAAK,EAGL,UAAU,EAGV,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,MAAM,CAAC;AAGd,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAmC,EAAO,EAAE;IACpE,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACf,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,OAAwB,EACD,EAAE;IACzB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO;QACL,GAAG,EACD,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC;KAC1E,CAAC;AACJ,CAAC,CAAC;AAEF,4EAA4E;AAC5E,uEAAuE;AACvE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAClC,MAAM,EACN,WAAW,EACX,OAAO,EACP,KAAK,GAGN,EAAmC,EAAE;IACpC,iBAAiB,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3D,OAAO;QACL,MAAM,EAAE;YACN,GAAG,MAAM;YACT,OAAO,EACL,OAAO,MAAM,EAAE,OAAO,KAAK,QAAQ;gBACjC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;gBACxB,CAAC,CAAC,MAAM,EAAE,OAAO;SACtB;QACD,KAAK,EAAE;YACL,GAAG,MAAM,CAAC,WAAW,CACnB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;gBAC1C,GAAG;gBACH,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;aACvC,CAAC,CACH;YACD,YAAY,EAAE,CAAC,GAAG,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;SACvD;QACD,WAAW;QACX,OAAO,EAAE,IAAI,CAAC,KAAK,CACjB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC1E;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n isHex,\n toHex,\n type Hex,\n type SignableMessage,\n bytesToHex,\n type TypedData,\n type TypedDataDefinition,\n getTypesForEIP712Domain,\n validateTypedData,\n} from \"viem\";\nimport type { TypedDataDefinition as WalletServerTypedDataDefinition } from \"@alchemy/wallet-api-types\";\n\nexport const castToHex = (val: string | number | bigint | Hex): Hex => {\n if (isHex(val)) {\n return val;\n }\n return toHex(val);\n};\n\nexport const signableMessageToJsonSafe = (\n message: SignableMessage,\n): string | { raw: Hex } => {\n if (typeof message === \"string\") {\n return message;\n }\n return {\n raw:\n typeof message.raw === \"string\" ? message.raw : bytesToHex(message.raw),\n };\n};\n\n// Purposefully not using `formatTypedData` from the wallet server types pkg\n// here, since that would require typebox at runtime (which breaks RN).\nexport const typedDataToJsonSafe = ({\n domain,\n primaryType,\n message,\n types,\n}: TypedDataDefinition<\n TypedData | Record<string, unknown>\n>): WalletServerTypedDataDefinition => {\n validateTypedData({ domain, primaryType, message, types });\n return {\n domain: {\n ...domain,\n chainId:\n typeof domain?.chainId === \"bigint\"\n ? Number(domain.chainId)\n : domain?.chainId,\n },\n types: {\n ...Object.fromEntries(\n Object.entries(types).map(([key, value]) => [\n key,\n Array.isArray(value) ? [...value] : [],\n ]),\n ),\n EIP712Domain: [...getTypesForEIP712Domain({ domain })],\n },\n primaryType,\n message: JSON.parse(\n JSON.stringify(message, (_, v) => (typeof v === \"bigint\" ? toHex(v) : v)),\n ),\n };\n};\n"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "5.0.0-beta.
|
|
1
|
+
export declare const VERSION = "5.0.0-beta.24";
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"5.0.0-beta.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"5.0.0-beta.24\";\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type Hex, type Prettify, type TypedDataDefinition } from "viem";
|
|
1
|
+
import { type Hex, type Prettify, type TypedData, type TypedDataDefinition } from "viem";
|
|
2
2
|
import type { InnerWalletApiClient } from "../types.ts";
|
|
3
3
|
import { type AccountParam } from "../utils/resolve.js";
|
|
4
|
-
export type SignTypedDataParams = Prettify<TypedDataDefinition & {
|
|
4
|
+
export type SignTypedDataParams = Prettify<TypedDataDefinition<TypedData | Record<string, unknown>> & {
|
|
5
5
|
account?: AccountParam;
|
|
6
6
|
}>;
|
|
7
7
|
export type SignTypedDataResult = Prettify<Hex>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signTypedData.d.ts","sourceRoot":"","sources":["../../../src/actions/signTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"signTypedData.d.ts","sourceRoot":"","sources":["../../../src/actions/signTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,mBAAmB,EACzB,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAMxD,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExE,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CACxC,mBAAmB,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG;IACzD,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB,CACF,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,wBAAsB,aAAa,CACjC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,mBAAmB,CAAC,CA4B9B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type Hex, type SignableMessage, type TypedDataDefinition } from "viem";
|
|
1
|
+
import { type Hex, type SignableMessage, type TypedData, type TypedDataDefinition } from "viem";
|
|
2
2
|
import type { TypedDataDefinition as WalletServerTypedDataDefinition } from "@alchemy/wallet-api-types";
|
|
3
3
|
export declare const castToHex: (val: string | number | bigint | Hex) => Hex;
|
|
4
4
|
export declare const signableMessageToJsonSafe: (message: SignableMessage) => string | {
|
|
5
5
|
raw: Hex;
|
|
6
6
|
};
|
|
7
|
-
export declare const typedDataToJsonSafe: ({ domain, primaryType, message, types, }: TypedDataDefinition) => WalletServerTypedDataDefinition;
|
|
7
|
+
export declare const typedDataToJsonSafe: ({ domain, primaryType, message, types, }: TypedDataDefinition<TypedData | Record<string, unknown>>) => WalletServerTypedDataDefinition;
|
|
8
8
|
//# sourceMappingURL=format.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/utils/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,GAAG,EACR,KAAK,eAAe,EAEpB,KAAK,mBAAmB,
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/utils/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,GAAG,EACR,KAAK,eAAe,EAEpB,KAAK,SAAS,EACd,KAAK,mBAAmB,EAGzB,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,mBAAmB,IAAI,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAExG,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,GAAG,KAAG,GAK/D,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,SAAS,eAAe,KACvB,MAAM,GAAG;IAAE,GAAG,EAAE,GAAG,CAAA;CAQrB,CAAC;AAIF,eAAO,MAAM,mBAAmB,GAAI,0CAKjC,mBAAmB,CACpB,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACpC,KAAG,+BAwBH,CAAC"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "5.0.0-beta.
|
|
1
|
+
export declare const VERSION = "5.0.0-beta.24";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alchemy/wallet-apis",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.25",
|
|
4
4
|
"description": "Alchemy Wallet APIs",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"viem": "^2.45.0"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@alchemy/common": "5.0.0-beta.
|
|
58
|
+
"@alchemy/common": "5.0.0-beta.25",
|
|
59
59
|
"@alchemy/wallet-api-types": "^0.1.0-alpha.27",
|
|
60
60
|
"deep-equal": "^2.2.3",
|
|
61
61
|
"ox": "^0.11.1",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
77
77
|
},
|
|
78
78
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "0eb4e1f1d586317a5f2c189e2ddef139d7348412"
|
|
80
80
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type Hex,
|
|
3
|
+
type Prettify,
|
|
4
|
+
type TypedData,
|
|
5
|
+
type TypedDataDefinition,
|
|
6
|
+
} from "viem";
|
|
2
7
|
import type { InnerWalletApiClient } from "../types.ts";
|
|
3
8
|
import { prepareSign } from "./prepareSign.js";
|
|
4
9
|
import { signSignatureRequest } from "./signSignatureRequest.js";
|
|
@@ -8,7 +13,7 @@ import { LOGGER } from "../logger.js";
|
|
|
8
13
|
import { resolveAddress, type AccountParam } from "../utils/resolve.js";
|
|
9
14
|
|
|
10
15
|
export type SignTypedDataParams = Prettify<
|
|
11
|
-
TypedDataDefinition & {
|
|
16
|
+
TypedDataDefinition<TypedData | Record<string, unknown>> & {
|
|
12
17
|
account?: AccountParam;
|
|
13
18
|
}
|
|
14
19
|
>;
|
package/src/utils/format.ts
CHANGED
|
@@ -4,8 +4,10 @@ import {
|
|
|
4
4
|
type Hex,
|
|
5
5
|
type SignableMessage,
|
|
6
6
|
bytesToHex,
|
|
7
|
+
type TypedData,
|
|
7
8
|
type TypedDataDefinition,
|
|
8
9
|
getTypesForEIP712Domain,
|
|
10
|
+
validateTypedData,
|
|
9
11
|
} from "viem";
|
|
10
12
|
import type { TypedDataDefinition as WalletServerTypedDataDefinition } from "@alchemy/wallet-api-types";
|
|
11
13
|
|
|
@@ -35,7 +37,10 @@ export const typedDataToJsonSafe = ({
|
|
|
35
37
|
primaryType,
|
|
36
38
|
message,
|
|
37
39
|
types,
|
|
38
|
-
}: TypedDataDefinition
|
|
40
|
+
}: TypedDataDefinition<
|
|
41
|
+
TypedData | Record<string, unknown>
|
|
42
|
+
>): WalletServerTypedDataDefinition => {
|
|
43
|
+
validateTypedData({ domain, primaryType, message, types });
|
|
39
44
|
return {
|
|
40
45
|
domain: {
|
|
41
46
|
...domain,
|
|
@@ -48,7 +53,7 @@ export const typedDataToJsonSafe = ({
|
|
|
48
53
|
...Object.fromEntries(
|
|
49
54
|
Object.entries(types).map(([key, value]) => [
|
|
50
55
|
key,
|
|
51
|
-
value ? [...value] : [],
|
|
56
|
+
Array.isArray(value) ? [...value] : [],
|
|
52
57
|
]),
|
|
53
58
|
),
|
|
54
59
|
EIP712Domain: [...getTypesForEIP712Domain({ domain })],
|
package/src/version.ts
CHANGED