@aa-sdk/core 4.13.1-alpha.0 → 4.14.0
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/signer/wallet-client.js +2 -10
- package/dist/esm/signer/wallet-client.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/signer/wallet-client.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/signer/wallet-client.ts +1 -11
- package/src/version.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getAddress, } from "viem";
|
|
2
2
|
import { InvalidSignerTypeError } from "../errors/signer.js";
|
|
3
3
|
/**
|
|
4
4
|
* Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, and sign typed data.
|
|
@@ -94,15 +94,7 @@ export class WalletClientSigner {
|
|
|
94
94
|
writable: true,
|
|
95
95
|
value: async (message) => {
|
|
96
96
|
const account = this.inner.account ?? (await this.getAddress());
|
|
97
|
-
|
|
98
|
-
return this.inner.signMessage({
|
|
99
|
-
message: typeof message === "string"
|
|
100
|
-
? message
|
|
101
|
-
: typeof message.raw === "string"
|
|
102
|
-
? message.raw
|
|
103
|
-
: bytesToHex(message.raw),
|
|
104
|
-
account,
|
|
105
|
-
});
|
|
97
|
+
return this.inner.signMessage({ message, account });
|
|
106
98
|
}
|
|
107
99
|
});
|
|
108
100
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-client.js","sourceRoot":"","sources":["../../../src/signer/wallet-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,
|
|
1
|
+
{"version":3,"file":"wallet-client.js","sourceRoot":"","sources":["../../../src/signer/wallet-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,GAMX,MAAM,MAAM,CAAC;AA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IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CAiGF","sourcesContent":["import {\n getAddress,\n type Hex,\n type SignableMessage,\n type TypedData,\n type TypedDataDefinition,\n type WalletClient,\n} from \"viem\";\nimport type { Account } from \"viem/accounts\";\nimport type { SignTypedDataParameters } from \"viem/actions\";\nimport { InvalidSignerTypeError } from \"../errors/signer.js\";\nimport type { SmartAccountSigner } from \"./types\";\n\n/**\n * Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, and sign typed data.\n */\nexport class WalletClientSigner implements SmartAccountSigner<WalletClient> {\n signerType: string;\n inner: WalletClient;\n\n /**\n * Initializes a signer with a given wallet client and signer type.\n *\n * @example\n * ```ts\n * import { WalletClientSigner } from \"@aa-sdk/core\";\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum!)\n * });\n *\n * const signer = new WalletClientSigner(client, 'wallet');\n * ```\n *\n * @param {WalletClient} client The wallet client to interact with\n * @param {string} signerType The type of signer; must be a valid signer type, otherwise an error will be thrown\n * @throws {InvalidSignerTypeError} If the signer type is invalid\n */\n constructor(client: WalletClient, signerType: string) {\n this.inner = client;\n if (!signerType) {\n throw new InvalidSignerTypeError(signerType);\n }\n this.signerType = signerType;\n }\n\n /**\n * Asynchronously retrieves addresses from the inner object and returns the first address after applying the `getAddress` function.\n *\n * @example\n * ```ts\n * import { WalletClientSigner } from \"@aa-sdk/core\";\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum!)\n * });\n *\n * const signer = new WalletClientSigner(client, 'wallet');\n * console.log(await signer.getAddress());\n * ```\n *\n * @returns {Promise<string>} A promise that resolves to the first address after being processed by the `getAddress` function.\n */\n getAddress: () => Promise<`0x${string}`> = async () => {\n let addresses = await this.inner.getAddresses();\n return getAddress(addresses[0]);\n };\n\n /**\n * Signs a message using the account's signing method.\n *\n * @example\n * ```ts\n * import { WalletClientSigner } from \"@aa-sdk/core\";\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum!)\n * });\n *\n * const signer = new WalletClientSigner(client, 'wallet');\n * console.log(await signer.signMessage(\"hello\"));\n * ```\n *\n * @param {string} message the message string that needs to be signed\n * @returns {Promise<string>} a promise that resolves to the signed message\n */\n readonly signMessage: (message: SignableMessage) => Promise<`0x${string}`> =\n async (message) => {\n const account = this.inner.account ?? (await this.getAddress());\n\n return this.inner.signMessage({ message, account });\n };\n\n /**\n * Signs the provided typed data using the account's private key.\n *\n * @example\n * ```ts\n * import { WalletClientSigner } from \"@aa-sdk/core\";\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum!)\n * });\n *\n * const signer = new WalletClientSigner(client, 'wallet');\n * console.log(await signer.signTypedData({\n * types: {\n * \"Message\": [{ name: \"content\", type: \"string\" }]\n * },\n * primaryType: \"Message\",\n * message: { content: \"Hello\" },\n * }));\n * ```\n *\n * @param {TypedDataDefinition<TTypedData, TPrimaryType>} typedData The typed data to be signed\n * @returns {Promise<Hex>} A promise that resolves to a hex string representing the signed data\n */\n signTypedData = async <\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | \"EIP712Domain\" | string = string\n >(\n typedData: TypedDataDefinition<TTypedData, TPrimaryType>\n ): Promise<Hex> => {\n const account = this.inner.account ?? (await this.getAddress());\n\n const params = {\n account,\n ...typedData,\n } as SignTypedDataParameters<TTypedData, string, Account | undefined>;\n\n return this.inner.signTypedData<TTypedData, string>(params);\n };\n}\n"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.14.0";
|
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,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.14.0\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-client.d.ts","sourceRoot":"","sources":["../../../src/signer/wallet-client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"wallet-client.d.ts","sourceRoot":"","sources":["../../../src/signer/wallet-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,GAAG,EACR,KAAK,eAAe,EAEpB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AAId,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;GAEG;AACH,qBAAa,kBAAmB,YAAW,kBAAkB,CAAC,YAAY,CAAC;IACzE,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,YAAY,CAAC;IAEpB;;;;;;;;;;;;;;;;;;;;OAoBG;gBACS,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM;IAQpD;;;;;;;;;;;;;;;;;;;OAmBG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC,CAGtC;IAEF;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC,CAKtE;IAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6HAKV,QAAQ,GAAG,CAAC,CASb;CACH"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.14.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aa-sdk/core",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.14.0",
|
|
5
5
|
"description": "viem based SDK that enables interactions with ERC-4337 Smart Accounts. ABIs are based off the definitions generated in @account-abstraction/contracts",
|
|
6
6
|
"author": "Alchemy",
|
|
7
7
|
"type": "module",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
66
66
|
},
|
|
67
67
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "9230c8f9c9af7a9a7d90538ef6ec42dcca1c39db"
|
|
69
69
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
bytesToHex,
|
|
3
2
|
getAddress,
|
|
4
3
|
type Hex,
|
|
5
4
|
type SignableMessage,
|
|
@@ -98,16 +97,7 @@ export class WalletClientSigner implements SmartAccountSigner<WalletClient> {
|
|
|
98
97
|
async (message) => {
|
|
99
98
|
const account = this.inner.account ?? (await this.getAddress());
|
|
100
99
|
|
|
101
|
-
|
|
102
|
-
return this.inner.signMessage({
|
|
103
|
-
message:
|
|
104
|
-
typeof message === "string"
|
|
105
|
-
? message
|
|
106
|
-
: typeof message.raw === "string"
|
|
107
|
-
? message.raw
|
|
108
|
-
: bytesToHex(message.raw),
|
|
109
|
-
account,
|
|
110
|
-
});
|
|
100
|
+
return this.inner.signMessage({ message, account });
|
|
111
101
|
};
|
|
112
102
|
|
|
113
103
|
/**
|
package/src/version.ts
CHANGED