@aa-sdk/core 4.64.0 → 4.66.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.
@@ -1,7 +1,7 @@
1
- import { type Hex, type SignableMessage, type TypedData, type TypedDataDefinition, type WalletClient } from "viem";
2
- import type { SmartAccountSigner } from "./types";
1
+ import { type Hex, type SignableMessage, type TypedData, type TypedDataDefinition, type WalletClient, type SignedAuthorization } from "viem";
2
+ import type { SmartAccountSigner, AuthorizationRequest } from "./types";
3
3
  /**
4
- * Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, and sign typed data.
4
+ * Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, sign typed data, and sign 7702 authorizations.
5
5
  */
6
6
  export declare class WalletClientSigner implements SmartAccountSigner<WalletClient> {
7
7
  signerType: string;
@@ -99,4 +99,31 @@ export declare class WalletClientSigner implements SmartAccountSigner<WalletClie
99
99
  * @returns {Promise<Hex>} A promise that resolves to a hex string representing the signed data
100
100
  */
101
101
  signTypedData: <const TTypedData extends TypedData | Record<string, unknown>, TPrimaryType extends keyof TTypedData | "EIP712Domain" | string = string>(typedData: TypedDataDefinition<TTypedData, TPrimaryType>) => Promise<Hex>;
102
+ /**
103
+ * Signs an EIP-7702 Authorization
104
+ *
105
+ * @example
106
+ * ```ts twoslash
107
+ * import { WalletClientSigner } from "@aa-sdk/core";
108
+ * import { createWalletClient, custom } from 'viem';
109
+ * import { mainnet } from 'viem/chains';
110
+ *
111
+ * const client = createWalletClient({
112
+ * chain: mainnet,
113
+ * transport: custom(window.ethereum!)
114
+ * });
115
+ *
116
+ * const signer = new WalletClientSigner(client, 'wallet');
117
+ *
118
+ * const authorization = await signer.signAuthorization({
119
+ * contractAddress: "0x1234123412341234123412341234123412341234",
120
+ * chainId: 1,
121
+ * nonce: 0,
122
+ * });
123
+ * ```
124
+ *
125
+ * @param {AuthorizationRequest<number>} unsignedAuthorization the authorization to be signed
126
+ * @returns {Promise<SignedAuthorization<number>>} a promise that resolves to the signed authorization
127
+ */
128
+ signAuthorization: (unsignedAuthorization: AuthorizationRequest<number>) => Promise<SignedAuthorization<number>>;
102
129
  }
@@ -1,7 +1,7 @@
1
1
  import { getAddress, } from "viem";
2
2
  import { InvalidSignerTypeError } from "../errors/signer.js";
3
3
  /**
4
- * Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, and sign typed data.
4
+ * Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, sign typed data, and sign 7702 authorizations.
5
5
  */
6
6
  export class WalletClientSigner {
7
7
  /**
@@ -137,6 +137,41 @@ export class WalletClientSigner {
137
137
  return this.inner.signTypedData(params);
138
138
  }
139
139
  });
140
+ /**
141
+ * Signs an EIP-7702 Authorization
142
+ *
143
+ * @example
144
+ * ```ts twoslash
145
+ * import { WalletClientSigner } from "@aa-sdk/core";
146
+ * import { createWalletClient, custom } from 'viem';
147
+ * import { mainnet } from 'viem/chains';
148
+ *
149
+ * const client = createWalletClient({
150
+ * chain: mainnet,
151
+ * transport: custom(window.ethereum!)
152
+ * });
153
+ *
154
+ * const signer = new WalletClientSigner(client, 'wallet');
155
+ *
156
+ * const authorization = await signer.signAuthorization({
157
+ * contractAddress: "0x1234123412341234123412341234123412341234",
158
+ * chainId: 1,
159
+ * nonce: 0,
160
+ * });
161
+ * ```
162
+ *
163
+ * @param {AuthorizationRequest<number>} unsignedAuthorization the authorization to be signed
164
+ * @returns {Promise<SignedAuthorization<number>>} a promise that resolves to the signed authorization
165
+ */
166
+ Object.defineProperty(this, "signAuthorization", {
167
+ enumerable: true,
168
+ configurable: true,
169
+ writable: true,
170
+ value: async (unsignedAuthorization) => {
171
+ const account = this.inner.account ?? (await this.getAddress());
172
+ return this.inner.signAuthorization({ ...unsignedAuthorization, account });
173
+ }
174
+ });
140
175
  this.inner = client;
141
176
  if (!signerType) {
142
177
  throw new InvalidSignerTypeError(signerType);
@@ -1 +1 @@
1
- {"version":3,"file":"wallet-client.js","sourceRoot":"","sources":["../../../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EAAE,CAAC;YAChB,MAAM,IAAI,sBAAsB,CAAC,UAAU,CAAC,CAAC;QAC/C,CAAC;QACD,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"]}
1
+ {"version":3,"file":"wallet-client.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H;;;;mBAAoB,KAAK,EACvB,qBAAmD,EACb,EAAE;gBACxC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;gBAChE,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,GAAG,qBAAqB,EAAE,OAAO,EAAE,CAAC,CAAC;YAC7E,CAAC;WAAC;QAtIA,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;QACpB,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,sBAAsB,CAAC,UAAU,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CAkIF","sourcesContent":["import {\n getAddress,\n type Hex,\n type SignableMessage,\n type TypedData,\n type TypedDataDefinition,\n type WalletClient,\n type SignedAuthorization,\n} from \"viem\";\nimport type { Account } from \"viem/accounts\";\nimport type { SignTypedDataParameters } from \"viem/actions\";\nimport { InvalidSignerTypeError } from \"../errors/signer.js\";\nimport type { SmartAccountSigner, AuthorizationRequest } from \"./types\";\n\n/**\n * Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, sign typed data, and sign 7702 authorizations.\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 /**\n * Signs an EIP-7702 Authorization\n *\n * @example\n * ```ts twoslash\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 * const authorization = await signer.signAuthorization({\n * contractAddress: \"0x1234123412341234123412341234123412341234\",\n * chainId: 1,\n * nonce: 0,\n * });\n * ```\n *\n * @param {AuthorizationRequest<number>} unsignedAuthorization the authorization to be signed\n * @returns {Promise<SignedAuthorization<number>>} a promise that resolves to the signed authorization\n */\n signAuthorization = async (\n unsignedAuthorization: AuthorizationRequest<number>,\n ): Promise<SignedAuthorization<number>> => {\n const account = this.inner.account ?? (await this.getAddress());\n return this.inner.signAuthorization({ ...unsignedAuthorization, account });\n };\n}\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "4.64.0";
1
+ export declare const VERSION = "4.66.0";
@@ -1,4 +1,4 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "4.64.0";
3
+ export const VERSION = "4.66.0";
4
4
  //# sourceMappingURL=version.js.map
@@ -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,QAAQ,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.64.0\";\n"]}
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.66.0\";\n"]}
@@ -1,7 +1,7 @@
1
- import { type Hex, type SignableMessage, type TypedData, type TypedDataDefinition, type WalletClient } from "viem";
2
- import type { SmartAccountSigner } from "./types";
1
+ import { type Hex, type SignableMessage, type TypedData, type TypedDataDefinition, type WalletClient, type SignedAuthorization } from "viem";
2
+ import type { SmartAccountSigner, AuthorizationRequest } from "./types";
3
3
  /**
4
- * Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, and sign typed data.
4
+ * Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, sign typed data, and sign 7702 authorizations.
5
5
  */
6
6
  export declare class WalletClientSigner implements SmartAccountSigner<WalletClient> {
7
7
  signerType: string;
@@ -99,5 +99,32 @@ export declare class WalletClientSigner implements SmartAccountSigner<WalletClie
99
99
  * @returns {Promise<Hex>} A promise that resolves to a hex string representing the signed data
100
100
  */
101
101
  signTypedData: <const TTypedData extends TypedData | Record<string, unknown>, TPrimaryType extends keyof TTypedData | "EIP712Domain" | string = string>(typedData: TypedDataDefinition<TTypedData, TPrimaryType>) => Promise<Hex>;
102
+ /**
103
+ * Signs an EIP-7702 Authorization
104
+ *
105
+ * @example
106
+ * ```ts twoslash
107
+ * import { WalletClientSigner } from "@aa-sdk/core";
108
+ * import { createWalletClient, custom } from 'viem';
109
+ * import { mainnet } from 'viem/chains';
110
+ *
111
+ * const client = createWalletClient({
112
+ * chain: mainnet,
113
+ * transport: custom(window.ethereum!)
114
+ * });
115
+ *
116
+ * const signer = new WalletClientSigner(client, 'wallet');
117
+ *
118
+ * const authorization = await signer.signAuthorization({
119
+ * contractAddress: "0x1234123412341234123412341234123412341234",
120
+ * chainId: 1,
121
+ * nonce: 0,
122
+ * });
123
+ * ```
124
+ *
125
+ * @param {AuthorizationRequest<number>} unsignedAuthorization the authorization to be signed
126
+ * @returns {Promise<SignedAuthorization<number>>} a promise that resolves to the signed authorization
127
+ */
128
+ signAuthorization: (unsignedAuthorization: AuthorizationRequest<number>) => Promise<SignedAuthorization<number>>;
102
129
  }
103
130
  //# sourceMappingURL=wallet-client.d.ts.map
@@ -1 +1 @@
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,EACpB,KAAK,SAAS,EACd,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,GACX,KAAK,CAAC,UAAU,SAAS,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO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;;;;;OAyBG;IACH,iBAAiB,GACf,uBAAuB,oBAAoB,CAAC,MAAM,CAAC,KAClD,OAAO,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAGrC;CACH"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "4.64.0";
1
+ export declare const VERSION = "4.66.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aa-sdk/core",
3
3
  "license": "MIT",
4
- "version": "4.64.0",
4
+ "version": "4.66.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",
@@ -37,7 +37,6 @@
37
37
  "build": "yarn clean && yarn build:esm && yarn build:types",
38
38
  "build:esm": "tsc --project tsconfig.build.json --outDir ./dist/esm",
39
39
  "build:types": "tsc --project tsconfig.build.json --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
40
- "fern:gen": "node ../../doc-gen/dist/esm/cli.js generate --in ./src/index.ts --out ../../docs/pages/reference/aa-sdk/core",
41
40
  "clean": "rm -rf ./dist",
42
41
  "test": "vitest",
43
42
  "test:run": "vitest run"
@@ -62,5 +61,5 @@
62
61
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
63
62
  },
64
63
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
65
- "gitHead": "4ebd04aa0b6567b665453112489260950f0a4896"
64
+ "gitHead": "e82c14b7d477a925e7340d614f321affb7cda782"
66
65
  }
@@ -5,14 +5,15 @@ import {
5
5
  type TypedData,
6
6
  type TypedDataDefinition,
7
7
  type WalletClient,
8
+ type SignedAuthorization,
8
9
  } from "viem";
9
10
  import type { Account } from "viem/accounts";
10
11
  import type { SignTypedDataParameters } from "viem/actions";
11
12
  import { InvalidSignerTypeError } from "../errors/signer.js";
12
- import type { SmartAccountSigner } from "./types";
13
+ import type { SmartAccountSigner, AuthorizationRequest } from "./types";
13
14
 
14
15
  /**
15
- * Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, and sign typed data.
16
+ * Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, sign typed data, and sign 7702 authorizations.
16
17
  */
17
18
  export class WalletClientSigner implements SmartAccountSigner<WalletClient> {
18
19
  signerType: string;
@@ -142,4 +143,37 @@ export class WalletClientSigner implements SmartAccountSigner<WalletClient> {
142
143
 
143
144
  return this.inner.signTypedData<TTypedData, string>(params);
144
145
  };
146
+
147
+ /**
148
+ * Signs an EIP-7702 Authorization
149
+ *
150
+ * @example
151
+ * ```ts twoslash
152
+ * import { WalletClientSigner } from "@aa-sdk/core";
153
+ * import { createWalletClient, custom } from 'viem';
154
+ * import { mainnet } from 'viem/chains';
155
+ *
156
+ * const client = createWalletClient({
157
+ * chain: mainnet,
158
+ * transport: custom(window.ethereum!)
159
+ * });
160
+ *
161
+ * const signer = new WalletClientSigner(client, 'wallet');
162
+ *
163
+ * const authorization = await signer.signAuthorization({
164
+ * contractAddress: "0x1234123412341234123412341234123412341234",
165
+ * chainId: 1,
166
+ * nonce: 0,
167
+ * });
168
+ * ```
169
+ *
170
+ * @param {AuthorizationRequest<number>} unsignedAuthorization the authorization to be signed
171
+ * @returns {Promise<SignedAuthorization<number>>} a promise that resolves to the signed authorization
172
+ */
173
+ signAuthorization = async (
174
+ unsignedAuthorization: AuthorizationRequest<number>,
175
+ ): Promise<SignedAuthorization<number>> => {
176
+ const account = this.inner.account ?? (await this.getAddress());
177
+ return this.inner.signAuthorization({ ...unsignedAuthorization, account });
178
+ };
145
179
  }
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "4.64.0";
3
+ export const VERSION = "4.66.0";