@aa-sdk/core 4.0.0-beta.0 → 4.0.0-beta.10
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/actions/smartAccount/checkGasSponsorshipEligibility.d.ts +9 -4
- package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js +17 -12
- package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
- package/dist/esm/actions/smartAccount/signMessage.js +1 -1
- package/dist/esm/actions/smartAccount/signMessage.js.map +1 -1
- package/dist/esm/actions/smartAccount/signTypedData.js +1 -1
- package/dist/esm/actions/smartAccount/signTypedData.js.map +1 -1
- package/dist/esm/client/decorators/smartAccountClient.d.ts +2 -5
- package/dist/esm/client/decorators/smartAccountClient.js +1 -5
- package/dist/esm/client/decorators/smartAccountClient.js.map +1 -1
- package/dist/esm/middleware/erc7677middleware.d.ts +4 -4
- package/dist/esm/middleware/erc7677middleware.js.map +1 -1
- package/dist/esm/signer/local-account.d.ts +17 -5
- package/dist/esm/signer/local-account.js +19 -2
- package/dist/esm/signer/local-account.js.map +1 -1
- package/dist/esm/signer/types.d.ts +1 -3
- package/dist/esm/signer/types.js.map +1 -1
- package/dist/esm/signer/wallet-client.d.ts +2 -4
- package/dist/esm/signer/wallet-client.js +3 -2
- package/dist/esm/signer/wallet-client.js.map +1 -1
- package/dist/esm/types.d.ts +0 -30
- package/dist/esm/types.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/smartAccount/checkGasSponsorshipEligibility.d.ts +9 -4
- package/dist/types/actions/smartAccount/checkGasSponsorshipEligibility.d.ts.map +1 -1
- package/dist/types/client/decorators/smartAccountClient.d.ts +2 -5
- package/dist/types/client/decorators/smartAccountClient.d.ts.map +1 -1
- package/dist/types/middleware/erc7677middleware.d.ts +4 -4
- package/dist/types/middleware/erc7677middleware.d.ts.map +1 -1
- package/dist/types/signer/local-account.d.ts +17 -5
- package/dist/types/signer/local-account.d.ts.map +1 -1
- package/dist/types/signer/types.d.ts +1 -3
- package/dist/types/signer/types.d.ts.map +1 -1
- package/dist/types/signer/wallet-client.d.ts +2 -4
- package/dist/types/signer/wallet-client.d.ts.map +1 -1
- package/dist/types/types.d.ts +0 -30
- package/dist/types/types.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 +4 -6
- package/src/actions/smartAccount/checkGasSponsorshipEligibility.ts +33 -16
- package/src/actions/smartAccount/signMessage.ts +1 -1
- package/src/actions/smartAccount/signTypedData.ts +1 -1
- package/src/client/decorators/smartAccountClient.ts +9 -14
- package/src/middleware/erc7677middleware.ts +9 -9
- package/src/signer/local-account.ts +26 -4
- package/src/signer/types.ts +2 -2
- package/src/signer/wallet-client.ts +8 -4
- package/src/types.ts +0 -56
- package/src/version.ts +1 -1
- package/dist/esm/actions/smartAccount/signMessageWith6492.d.ts +0 -4
- package/dist/esm/actions/smartAccount/signMessageWith6492.js +0 -8
- package/dist/esm/actions/smartAccount/signMessageWith6492.js.map +0 -1
- package/dist/esm/actions/smartAccount/signTypedDataWith6492.d.ts +0 -6
- package/dist/esm/actions/smartAccount/signTypedDataWith6492.js +0 -8
- package/dist/esm/actions/smartAccount/signTypedDataWith6492.js.map +0 -1
- package/dist/types/actions/smartAccount/signMessageWith6492.d.ts +0 -5
- package/dist/types/actions/smartAccount/signMessageWith6492.d.ts.map +0 -1
- package/dist/types/actions/smartAccount/signTypedDataWith6492.d.ts +0 -7
- package/dist/types/actions/smartAccount/signTypedDataWith6492.d.ts.map +0 -1
- package/src/actions/smartAccount/signMessageWith6492.ts +0 -21
- package/src/actions/smartAccount/signTypedDataWith6492.ts +0 -23
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { Chain, Client, Transport } from "viem";
|
|
2
|
-
import type { SmartContractAccount } from "../../account/smartContractAccount.js";
|
|
2
|
+
import type { GetEntryPointFromAccount, SmartContractAccount } from "../../account/smartContractAccount.js";
|
|
3
|
+
import type { UserOperationStruct } from "../../types.js";
|
|
3
4
|
import type { SendUserOperationParameters, UserOperationContext } from "./types";
|
|
5
|
+
export type CheckGasSponsorshipEligibilityResult<TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>> = {
|
|
6
|
+
eligible: boolean;
|
|
7
|
+
request?: UserOperationStruct<TEntryPointVersion>;
|
|
8
|
+
};
|
|
4
9
|
/**
|
|
5
10
|
* This function verifies the eligibility of the connected account for gas sponsorship concerning the upcoming `UserOperation` (UO) that is intended to be sent.
|
|
6
11
|
* Internally, this method invokes `buildUserOperation`, which navigates through the middleware pipeline, including the `PaymasterMiddleware`. Its purpose is to construct the UO struct meant for transmission to the bundler. Following the construction of the UO struct, this function verifies if the resulting structure contains a non-empty `paymasterAndData` field.
|
|
@@ -10,7 +15,7 @@ import type { SendUserOperationParameters, UserOperationContext } from "./types"
|
|
|
10
15
|
* ```ts
|
|
11
16
|
* import { smartAccountClient } from "./smartAccountClient";
|
|
12
17
|
* // [!code focus:99]
|
|
13
|
-
* const eligible = await smartAccountClient.checkGasSponsorshipEligibility({
|
|
18
|
+
* const { eligible } = await smartAccountClient.checkGasSponsorshipEligibility({
|
|
14
19
|
* uo: {
|
|
15
20
|
* data: "0xCalldata",
|
|
16
21
|
* target: "0xTarget",
|
|
@@ -27,6 +32,6 @@ import type { SendUserOperationParameters, UserOperationContext } from "./types"
|
|
|
27
32
|
*
|
|
28
33
|
* @param {Client<TTransport, TChain, TAccount>} client the smart account client to use for making RPC calls
|
|
29
34
|
* @param {SendUserOperationParameters} args containing the user operation, account, context, and overrides
|
|
30
|
-
* @returns {Promise<
|
|
35
|
+
* @returns {Promise<CheckGasSponsorshipEligibilityResult<TAccount>>} a Promise containing a boolean indicating if the account is elgibile for sponsorship and the sponsored UO
|
|
31
36
|
*/
|
|
32
|
-
export declare function checkGasSponsorshipEligibility<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(client: Client<TTransport, TChain, TAccount>, args: SendUserOperationParameters<TAccount, TContext>): Promise<
|
|
37
|
+
export declare function checkGasSponsorshipEligibility<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(client: Client<TTransport, TChain, TAccount>, args: SendUserOperationParameters<TAccount, TContext>): Promise<CheckGasSponsorshipEligibilityResult<TAccount>>;
|
|
@@ -11,7 +11,7 @@ import { buildUserOperation } from "./buildUserOperation.js";
|
|
|
11
11
|
* ```ts
|
|
12
12
|
* import { smartAccountClient } from "./smartAccountClient";
|
|
13
13
|
* // [!code focus:99]
|
|
14
|
-
* const eligible = await smartAccountClient.checkGasSponsorshipEligibility({
|
|
14
|
+
* const { eligible } = await smartAccountClient.checkGasSponsorshipEligibility({
|
|
15
15
|
* uo: {
|
|
16
16
|
* data: "0xCalldata",
|
|
17
17
|
* target: "0xTarget",
|
|
@@ -28,7 +28,7 @@ import { buildUserOperation } from "./buildUserOperation.js";
|
|
|
28
28
|
*
|
|
29
29
|
* @param {Client<TTransport, TChain, TAccount>} client the smart account client to use for making RPC calls
|
|
30
30
|
* @param {SendUserOperationParameters} args containing the user operation, account, context, and overrides
|
|
31
|
-
* @returns {Promise<
|
|
31
|
+
* @returns {Promise<CheckGasSponsorshipEligibilityResult<TAccount>>} a Promise containing a boolean indicating if the account is elgibile for sponsorship and the sponsored UO
|
|
32
32
|
*/
|
|
33
33
|
export function checkGasSponsorshipEligibility(client, args) {
|
|
34
34
|
const { account = client.account, overrides, context } = args;
|
|
@@ -44,15 +44,20 @@ export function checkGasSponsorshipEligibility(client, args) {
|
|
|
44
44
|
overrides,
|
|
45
45
|
context,
|
|
46
46
|
})
|
|
47
|
-
.then((userOperationStruct) =>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
.then((userOperationStruct) => ({
|
|
48
|
+
eligible: account.getEntryPoint().version === "0.6.0"
|
|
49
|
+
? userOperationStruct
|
|
50
|
+
.paymasterAndData !== "0x" &&
|
|
51
|
+
userOperationStruct
|
|
52
|
+
.paymasterAndData !== null
|
|
53
|
+
: userOperationStruct
|
|
54
|
+
.paymasterData !== "0x" &&
|
|
55
|
+
userOperationStruct
|
|
56
|
+
.paymasterData !== null,
|
|
57
|
+
request: userOperationStruct,
|
|
58
|
+
}))
|
|
59
|
+
.catch(() => ({
|
|
60
|
+
eligible: false,
|
|
61
|
+
}));
|
|
57
62
|
}
|
|
58
63
|
//# sourceMappingURL=checkGasSponsorshipEligibility.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkGasSponsorshipEligibility.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/checkGasSponsorshipEligibility.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkGasSponsorshipEligibility.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/checkGasSponsorshipEligibility.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAgB7D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,8BAA8B,CAU5C,MAA4C,EAC5C,IAAqD;IAErD,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAE9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,gCAAgC,EAChC,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,EAAE;QAChC,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,OAAO;QACP,SAAS;QACT,OAAO;KACR,CAAC;SACC,IAAI,CAAC,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;QAC9B,QAAQ,EACN,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,KAAK,OAAO;YACzC,CAAC,CAAE,mBAAoD;iBAClD,gBAAgB,KAAK,IAAI;gBAC3B,mBAAoD;qBAClD,gBAAgB,KAAK,IAAI;YAC9B,CAAC,CAAE,mBAAoD;iBAClD,aAAa,KAAK,IAAI;gBACxB,mBAAoD;qBAClD,aAAa,KAAK,IAAI;QAC/B,OAAO,EAAE,mBAAmB;KAC7B,CAAC,CAAC;SACF,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;QACZ,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC,CAAC;AACR,CAAC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationStruct } from \"../../types.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type {\n SendUserOperationParameters,\n UserOperationContext,\n} from \"./types\";\n\nexport type CheckGasSponsorshipEligibilityResult<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n> = {\n eligible: boolean;\n request?: UserOperationStruct<TEntryPointVersion>;\n};\n\n/**\n * This function verifies the eligibility of the connected account for gas sponsorship concerning the upcoming `UserOperation` (UO) that is intended to be sent.\n * Internally, this method invokes `buildUserOperation`, which navigates through the middleware pipeline, including the `PaymasterMiddleware`. Its purpose is to construct the UO struct meant for transmission to the bundler. Following the construction of the UO struct, this function verifies if the resulting structure contains a non-empty `paymasterAndData` field.\n * You can utilize this method before sending the user operation to confirm its eligibility for gas sponsorship. Depending on the outcome, it allows you to tailor the user experience accordingly, based on eligibility.\n *\n * @example\n * ```ts\n * import { smartAccountClient } from \"./smartAccountClient\";\n * // [!code focus:99]\n * const { eligible } = await smartAccountClient.checkGasSponsorshipEligibility({\n * uo: {\n * data: \"0xCalldata\",\n * target: \"0xTarget\",\n * value: 0n,\n * },\n * });\n *\n * console.log(\n * `User Operation is ${\n * eligible ? \"eligible\" : \"ineligible\"\n * } for gas sponsorship.`\n * );\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client the smart account client to use for making RPC calls\n * @param {SendUserOperationParameters} args containing the user operation, account, context, and overrides\n * @returns {Promise<CheckGasSponsorshipEligibilityResult<TAccount>>} a Promise containing a boolean indicating if the account is elgibile for sponsorship and the sponsored UO\n */\nexport function checkGasSponsorshipEligibility<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: SendUserOperationParameters<TAccount, TContext>\n): Promise<CheckGasSponsorshipEligibilityResult<TAccount>> {\n const { account = client.account, overrides, context } = args;\n\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"checkGasSponsorshipEligibility\",\n client\n );\n }\n\n return buildUserOperation(client, {\n uo: args.uo,\n account,\n overrides,\n context,\n })\n .then((userOperationStruct) => ({\n eligible:\n account.getEntryPoint().version === \"0.6.0\"\n ? (userOperationStruct as UserOperationStruct<\"0.6.0\">)\n .paymasterAndData !== \"0x\" &&\n (userOperationStruct as UserOperationStruct<\"0.6.0\">)\n .paymasterAndData !== null\n : (userOperationStruct as UserOperationStruct<\"0.7.0\">)\n .paymasterData !== \"0x\" &&\n (userOperationStruct as UserOperationStruct<\"0.7.0\">)\n .paymasterData !== null,\n request: userOperationStruct,\n }))\n .catch(() => ({\n eligible: false,\n }));\n}\n"]}
|
|
@@ -3,6 +3,6 @@ export const signMessage = async (client, { account = client.account, message })
|
|
|
3
3
|
if (!account) {
|
|
4
4
|
throw new AccountNotFoundError();
|
|
5
5
|
}
|
|
6
|
-
return account.
|
|
6
|
+
return account.signMessageWith6492({ message });
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=signMessage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signMessage.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/signMessage.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAQ/D,MAAM,CAAC,MAAM,WAAW,GASJ,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE;IAC1E,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IACD,OAAO,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"signMessage.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/signMessage.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAQ/D,MAAM,CAAC,MAAM,WAAW,GASJ,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE;IAC1E,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IACD,OAAO,OAAO,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;AAClD,CAAC,CAAC","sourcesContent":["import type { Chain, Client, Hex, SignableMessage, Transport } from \"viem\";\nimport type {\n GetAccountParameter,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\n\nexport type SignMessageParameters<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n> = { message: SignableMessage } & GetAccountParameter<TAccount>;\n\nexport const signMessage: <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: SignMessageParameters<TAccount>\n) => Promise<Hex> = async (client, { account = client.account, message }) => {\n if (!account) {\n throw new AccountNotFoundError();\n }\n return account.signMessageWith6492({ message });\n};\n"]}
|
|
@@ -3,6 +3,6 @@ export const signTypedData = async (client, { account = client.account, typedDat
|
|
|
3
3
|
if (!account) {
|
|
4
4
|
throw new AccountNotFoundError();
|
|
5
5
|
}
|
|
6
|
-
return account.
|
|
6
|
+
return account.signTypedDataWith6492(typedData);
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=signTypedData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signTypedData.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/signTypedData.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAY/D,MAAM,CAAC,MAAM,aAAa,GAWN,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE;IAC5E,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"signTypedData.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/signTypedData.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAY/D,MAAM,CAAC,MAAM,aAAa,GAWN,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE;IAC5E,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;AAClD,CAAC,CAAC","sourcesContent":["import type {\n Chain,\n Client,\n Hex,\n Transport,\n TypedData,\n TypedDataDefinition,\n} from \"viem\";\nimport type {\n GetAccountParameter,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\n\nexport type SignTypedDataParameters<\n TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends string = string,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n> = {\n typedData: TypedDataDefinition<TTypedData, TPrimaryType>;\n} & GetAccountParameter<TAccount>;\n\nexport const signTypedData: <\n const TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends string = string,\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>,\n args: SignTypedDataParameters<TTypedData, TPrimaryType, TAccount>\n) => Promise<Hex> = async (client, { account = client.account, typedData }) => {\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n return account.signTypedDataWith6492(typedData);\n};\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Address, type Chain, type Client, type Hex, type SendTransactionParameters, type Transport, type TypedData } from "viem";
|
|
2
2
|
import type { GetAccountParameter, GetEntryPointFromAccount, SmartContractAccount } from "../../account/smartContractAccount";
|
|
3
|
+
import { type CheckGasSponsorshipEligibilityResult } from "../../actions/smartAccount/checkGasSponsorshipEligibility.js";
|
|
3
4
|
import { type SignMessageParameters } from "../../actions/smartAccount/signMessage.js";
|
|
4
5
|
import { type SignTypedDataParameters } from "../../actions/smartAccount/signTypedData.js";
|
|
5
6
|
import type { BuildTransactionParameters, BuildUserOperationFromTransactionsResult, BuildUserOperationParameters, DropAndReplaceUserOperationParameters, SendTransactionsParameters, SendUserOperationParameters, SignUserOperationParameters, UpgradeAccountParams, UserOperationContext, WaitForUserOperationTxParameters } from "../../actions/smartAccount/types";
|
|
@@ -10,7 +11,7 @@ export type BaseSmartAccountClientActions<TChain extends Chain | undefined = Cha
|
|
|
10
11
|
buildUserOperation: (args: BuildUserOperationParameters<TAccount, TContext>) => Promise<UserOperationStruct<TEntryPointVersion>>;
|
|
11
12
|
buildUserOperationFromTx: (args: SendTransactionParameters<TChain, TAccount>, overrides?: UserOperationOverrides<TEntryPointVersion>, context?: TContext) => Promise<UserOperationStruct<TEntryPointVersion>>;
|
|
12
13
|
buildUserOperationFromTxs: (args: BuildTransactionParameters<TAccount, TContext>) => Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>;
|
|
13
|
-
checkGasSponsorshipEligibility: <TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(args: SendUserOperationParameters<TAccount, TContext>) => Promise<
|
|
14
|
+
checkGasSponsorshipEligibility: <TContext extends UserOperationContext | undefined = UserOperationContext | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>>(args: SendUserOperationParameters<TAccount, TContext>) => Promise<CheckGasSponsorshipEligibilityResult<TAccount, TEntryPointVersion>>;
|
|
14
15
|
signUserOperation: (args: SignUserOperationParameters<TAccount, TEntryPointVersion, TContext>) => Promise<UserOperationRequest<TEntryPointVersion>>;
|
|
15
16
|
dropAndReplaceUserOperation: (args: DropAndReplaceUserOperationParameters<TAccount, TContext>) => Promise<SendUserOperationResult<TEntryPointVersion>>;
|
|
16
17
|
sendTransaction: <TChainOverride extends Chain | undefined = undefined>(args: SendTransactionParameters<TChain, TAccount, TChainOverride>, overrides?: UserOperationOverrides<TEntryPointVersion>, context?: TContext) => Promise<Hex>;
|
|
@@ -22,10 +23,6 @@ export type BaseSmartAccountClientActions<TChain extends Chain | undefined = Cha
|
|
|
22
23
|
signTypedData: <const TTypedData extends TypedData | {
|
|
23
24
|
[key: string]: unknown;
|
|
24
25
|
}, TPrimaryType extends string = string>(args: SignTypedDataParameters<TTypedData, TPrimaryType, TAccount>) => Promise<Hex>;
|
|
25
|
-
signMessageWith6492: (args: SignMessageParameters<TAccount>) => Promise<Hex>;
|
|
26
|
-
signTypedDataWith6492: <const TTypedData extends TypedData | {
|
|
27
|
-
[key: string]: unknown;
|
|
28
|
-
}, TPrimaryType extends string = string>(args: SignTypedDataParameters<TTypedData, TPrimaryType, TAccount>) => Promise<Hex>;
|
|
29
26
|
} & (IsUndefined<TAccount> extends false ? {
|
|
30
27
|
getAddress: () => Address;
|
|
31
28
|
} : {
|
|
@@ -2,16 +2,14 @@ import {} from "viem";
|
|
|
2
2
|
import { buildUserOperation } from "../../actions/smartAccount/buildUserOperation.js";
|
|
3
3
|
import { buildUserOperationFromTx } from "../../actions/smartAccount/buildUserOperationFromTx.js";
|
|
4
4
|
import { buildUserOperationFromTxs } from "../../actions/smartAccount/buildUserOperationFromTxs.js";
|
|
5
|
-
import { checkGasSponsorshipEligibility } from "../../actions/smartAccount/checkGasSponsorshipEligibility.js";
|
|
5
|
+
import { checkGasSponsorshipEligibility, } from "../../actions/smartAccount/checkGasSponsorshipEligibility.js";
|
|
6
6
|
import { dropAndReplaceUserOperation } from "../../actions/smartAccount/dropAndReplaceUserOperation.js";
|
|
7
7
|
import { getAddress } from "../../actions/smartAccount/getAddress.js";
|
|
8
8
|
import { sendTransaction } from "../../actions/smartAccount/sendTransaction.js";
|
|
9
9
|
import { sendTransactions } from "../../actions/smartAccount/sendTransactions.js";
|
|
10
10
|
import { sendUserOperation } from "../../actions/smartAccount/sendUserOperation.js";
|
|
11
11
|
import { signMessage, } from "../../actions/smartAccount/signMessage.js";
|
|
12
|
-
import { signMessageWith6492 } from "../../actions/smartAccount/signMessageWith6492.js";
|
|
13
12
|
import { signTypedData, } from "../../actions/smartAccount/signTypedData.js";
|
|
14
|
-
import { signTypedDataWith6492 } from "../../actions/smartAccount/signTypedDataWith6492.js";
|
|
15
13
|
import { signUserOperation } from "../../actions/smartAccount/signUserOperation.js";
|
|
16
14
|
import { upgradeAccount } from "../../actions/smartAccount/upgradeAccount.js";
|
|
17
15
|
import { waitForUserOperationTransaction } from "../../actions/smartAccount/waitForUserOperationTransacation.js";
|
|
@@ -39,8 +37,6 @@ export const smartAccountClientActions = (client) => ({
|
|
|
39
37
|
getAddress: (args) => getAddress(client, args),
|
|
40
38
|
signMessage: (args) => signMessage(client, args),
|
|
41
39
|
signTypedData: (args) => signTypedData(client, args),
|
|
42
|
-
signMessageWith6492: (args) => signMessageWith6492(client, args),
|
|
43
|
-
signTypedDataWith6492: (args) => signTypedDataWith6492(client, args),
|
|
44
40
|
});
|
|
45
41
|
export const smartAccountClientMethodKeys = Object.keys(
|
|
46
42
|
// @ts-expect-error we just want to get the keys
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartAccountClient.js","sourceRoot":"","sources":["../../../../src/client/decorators/smartAccountClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAQN,MAAM,MAAM,CAAC;AAMd,OAAO,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,wDAAwD,CAAC;AAClG,OAAO,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ChD,yBAAyB,CAAC,SAAS,CAAC,CACrC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IACvB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChB,OAAO,KAAK,CAAC;AACf,CAAC,EAAE,IAAI,GAAG,EAAU,CAAC,CAAC","sourcesContent":["import {\n type Address,\n type Chain,\n type Client,\n type Hex,\n type SendTransactionParameters,\n type Transport,\n type TypedData,\n} from \"viem\";\nimport type {\n GetAccountParameter,\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { buildUserOperation } from \"../../actions/smartAccount/buildUserOperation.js\";\nimport { buildUserOperationFromTx } from \"../../actions/smartAccount/buildUserOperationFromTx.js\";\nimport { buildUserOperationFromTxs } from \"../../actions/smartAccount/buildUserOperationFromTxs.js\";\nimport { checkGasSponsorshipEligibility } from \"../../actions/smartAccount/checkGasSponsorshipEligibility.js\";\nimport { dropAndReplaceUserOperation } from \"../../actions/smartAccount/dropAndReplaceUserOperation.js\";\nimport { getAddress } from \"../../actions/smartAccount/getAddress.js\";\nimport { sendTransaction } from \"../../actions/smartAccount/sendTransaction.js\";\nimport { sendTransactions } from \"../../actions/smartAccount/sendTransactions.js\";\nimport { sendUserOperation } from \"../../actions/smartAccount/sendUserOperation.js\";\nimport {\n signMessage,\n type SignMessageParameters,\n} from \"../../actions/smartAccount/signMessage.js\";\nimport { signMessageWith6492 } from \"../../actions/smartAccount/signMessageWith6492.js\";\nimport {\n signTypedData,\n type SignTypedDataParameters,\n} from \"../../actions/smartAccount/signTypedData.js\";\nimport { signTypedDataWith6492 } from \"../../actions/smartAccount/signTypedDataWith6492.js\";\nimport { signUserOperation } from \"../../actions/smartAccount/signUserOperation.js\";\nimport type {\n BuildTransactionParameters,\n BuildUserOperationFromTransactionsResult,\n BuildUserOperationParameters,\n DropAndReplaceUserOperationParameters,\n SendTransactionsParameters,\n SendUserOperationParameters,\n SignUserOperationParameters,\n UpgradeAccountParams,\n UserOperationContext,\n WaitForUserOperationTxParameters,\n} from \"../../actions/smartAccount/types\";\nimport { upgradeAccount } from \"../../actions/smartAccount/upgradeAccount.js\";\nimport { waitForUserOperationTransaction } from \"../../actions/smartAccount/waitForUserOperationTransacation.js\";\nimport type {\n UserOperationOverrides,\n UserOperationRequest,\n UserOperationStruct,\n} from \"../../types\";\nimport type { IsUndefined } from \"../../utils\";\nimport type { SendUserOperationResult } from \"../types\";\n\n//#region SmartAccountClientActions\nexport type BaseSmartAccountClientActions<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n> = {\n buildUserOperation: (\n args: BuildUserOperationParameters<TAccount, TContext>\n ) => Promise<UserOperationStruct<TEntryPointVersion>>;\n buildUserOperationFromTx: (\n args: SendTransactionParameters<TChain, TAccount>,\n overrides?: UserOperationOverrides<TEntryPointVersion>,\n context?: TContext\n ) => Promise<UserOperationStruct<TEntryPointVersion>>;\n buildUserOperationFromTxs: (\n args: BuildTransactionParameters<TAccount, TContext>\n ) => Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>;\n checkGasSponsorshipEligibility: <\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n >(\n args: SendUserOperationParameters<TAccount, TContext>\n ) => Promise<boolean>;\n signUserOperation: (\n args: SignUserOperationParameters<TAccount, TEntryPointVersion, TContext>\n ) => Promise<UserOperationRequest<TEntryPointVersion>>;\n dropAndReplaceUserOperation: (\n args: DropAndReplaceUserOperationParameters<TAccount, TContext>\n ) => Promise<SendUserOperationResult<TEntryPointVersion>>;\n // TODO: for v4 we should combine override and context into an `opts` parameter\n // which wraps both of these properties so we can use GetContextParameter\n sendTransaction: <TChainOverride extends Chain | undefined = undefined>(\n args: SendTransactionParameters<TChain, TAccount, TChainOverride>,\n overrides?: UserOperationOverrides<TEntryPointVersion>,\n context?: TContext\n ) => Promise<Hex>;\n sendTransactions: (\n args: SendTransactionsParameters<TAccount, TContext>\n ) => Promise<Hex>;\n sendUserOperation: (\n args: SendUserOperationParameters<\n TAccount,\n TContext,\n GetEntryPointFromAccount<TAccount>\n >\n ) => Promise<SendUserOperationResult<TEntryPointVersion>>;\n waitForUserOperationTransaction: (\n args: WaitForUserOperationTxParameters\n ) => Promise<Hex>;\n upgradeAccount: (\n args: UpgradeAccountParams<TAccount, TContext>\n ) => Promise<Hex>;\n signMessage: (args: SignMessageParameters<TAccount>) => Promise<Hex>;\n signTypedData: <\n const TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends string = string\n >(\n args: SignTypedDataParameters<TTypedData, TPrimaryType, TAccount>\n ) => Promise<Hex>;\n signMessageWith6492: (args: SignMessageParameters<TAccount>) => Promise<Hex>;\n signTypedDataWith6492: <\n const TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends string = string\n >(\n args: SignTypedDataParameters<TTypedData, TPrimaryType, TAccount>\n ) => Promise<Hex>;\n} & (IsUndefined<TAccount> extends false\n ? { getAddress: () => Address }\n : {\n getAddress: (args: GetAccountParameter<TAccount>) => Address;\n });\n// #endregion SmartAccountClientActions\n\n/**\n * Provides a set of smart account client actions to decorate the provided client. These actions include building and signing user operations, sending transactions, and more.\n *\n * NOTE: this is already added to clients returned from `createSmartAccountClient`\n *\n * @param {Client<TTransport, TChain, TAccount>} client The client to bind the smart account actions to\n * @returns {BaseSmartAccountClientActions<TChain, TAccount, TContext>} An object containing various smart account client actions\n */\nexport const smartAccountClientActions: <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>\n) => BaseSmartAccountClientActions<TChain, TAccount, TContext> = (client) => ({\n buildUserOperation: (args) => buildUserOperation(client, args),\n buildUserOperationFromTx: (args, overrides, context) =>\n buildUserOperationFromTx(client, args, overrides, context),\n buildUserOperationFromTxs: (args) => buildUserOperationFromTxs(client, args),\n checkGasSponsorshipEligibility: (args) =>\n checkGasSponsorshipEligibility(client, args),\n signUserOperation: (args) => signUserOperation(client, args),\n dropAndReplaceUserOperation: (args) =>\n dropAndReplaceUserOperation(client, args),\n sendTransaction: (args, overrides, context) =>\n sendTransaction(client, args, overrides, context),\n sendTransactions: (args) => sendTransactions(client, args),\n sendUserOperation: (args) => sendUserOperation(client, args),\n waitForUserOperationTransaction: (args) =>\n waitForUserOperationTransaction.bind(client)(client, args),\n upgradeAccount: (args) => upgradeAccount(client, args),\n getAddress: (args) => getAddress(client, args),\n signMessage: (args) => signMessage(client, args),\n signTypedData: (args) => signTypedData(client, args),\n signMessageWith6492: (args) => signMessageWith6492(client, args),\n signTypedDataWith6492: (args) => signTypedDataWith6492(client, args),\n});\n\nexport const smartAccountClientMethodKeys = Object.keys(\n // @ts-expect-error we just want to get the keys\n smartAccountClientActions(undefined)\n).reduce((accum, curr) => {\n accum.add(curr);\n return accum;\n}, new Set<string>());\n"]}
|
|
1
|
+
{"version":3,"file":"smartAccountClient.js","sourceRoot":"","sources":["../../../../src/client/decorators/smartAccountClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAQN,MAAM,MAAM,CAAC;AAMd,OAAO,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,wDAAwD,CAAC;AAClG,OAAO,EAAE,yBAAyB,EAAE,MAAM,yDAAyD,CAAC;AACpG,OAAO,EACL,8BAA8B,GAE/B,MAAM,8DAA8D,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,2DAA2D,CAAC;AACxG,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,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E,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC;IAC1D,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC;IAC5D,+BAA+B,EAAE,CAAC,IAAI,EAAE,EAAE,CACxC,+BAA+B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC;IAC5D,cAAc,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC;IACtD,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC;IAC9C,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC;IAChD,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC;CACrD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC,IAAI;AACrD,gDAAgD;AAChD,yBAAyB,CAAC,SAAS,CAAC,CACrC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IACvB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChB,OAAO,KAAK,CAAC;AACf,CAAC,EAAE,IAAI,GAAG,EAAU,CAAC,CAAC","sourcesContent":["import {\n type Address,\n type Chain,\n type Client,\n type Hex,\n type SendTransactionParameters,\n type Transport,\n type TypedData,\n} from \"viem\";\nimport type {\n GetAccountParameter,\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { buildUserOperation } from \"../../actions/smartAccount/buildUserOperation.js\";\nimport { buildUserOperationFromTx } from \"../../actions/smartAccount/buildUserOperationFromTx.js\";\nimport { buildUserOperationFromTxs } from \"../../actions/smartAccount/buildUserOperationFromTxs.js\";\nimport {\n checkGasSponsorshipEligibility,\n type CheckGasSponsorshipEligibilityResult,\n} from \"../../actions/smartAccount/checkGasSponsorshipEligibility.js\";\nimport { dropAndReplaceUserOperation } from \"../../actions/smartAccount/dropAndReplaceUserOperation.js\";\nimport { getAddress } from \"../../actions/smartAccount/getAddress.js\";\nimport { sendTransaction } from \"../../actions/smartAccount/sendTransaction.js\";\nimport { sendTransactions } from \"../../actions/smartAccount/sendTransactions.js\";\nimport { sendUserOperation } from \"../../actions/smartAccount/sendUserOperation.js\";\nimport {\n signMessage,\n type SignMessageParameters,\n} from \"../../actions/smartAccount/signMessage.js\";\nimport {\n signTypedData,\n type SignTypedDataParameters,\n} from \"../../actions/smartAccount/signTypedData.js\";\nimport { signUserOperation } from \"../../actions/smartAccount/signUserOperation.js\";\nimport type {\n BuildTransactionParameters,\n BuildUserOperationFromTransactionsResult,\n BuildUserOperationParameters,\n DropAndReplaceUserOperationParameters,\n SendTransactionsParameters,\n SendUserOperationParameters,\n SignUserOperationParameters,\n UpgradeAccountParams,\n UserOperationContext,\n WaitForUserOperationTxParameters,\n} from \"../../actions/smartAccount/types\";\nimport { upgradeAccount } from \"../../actions/smartAccount/upgradeAccount.js\";\nimport { waitForUserOperationTransaction } from \"../../actions/smartAccount/waitForUserOperationTransacation.js\";\nimport type {\n UserOperationOverrides,\n UserOperationRequest,\n UserOperationStruct,\n} from \"../../types\";\nimport type { IsUndefined } from \"../../utils\";\nimport type { SendUserOperationResult } from \"../types\";\n\n//#region SmartAccountClientActions\nexport type BaseSmartAccountClientActions<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n> = {\n buildUserOperation: (\n args: BuildUserOperationParameters<TAccount, TContext>\n ) => Promise<UserOperationStruct<TEntryPointVersion>>;\n buildUserOperationFromTx: (\n args: SendTransactionParameters<TChain, TAccount>,\n overrides?: UserOperationOverrides<TEntryPointVersion>,\n context?: TContext\n ) => Promise<UserOperationStruct<TEntryPointVersion>>;\n buildUserOperationFromTxs: (\n args: BuildTransactionParameters<TAccount, TContext>\n ) => Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>;\n checkGasSponsorshipEligibility: <\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n >(\n args: SendUserOperationParameters<TAccount, TContext>\n ) => Promise<\n CheckGasSponsorshipEligibilityResult<TAccount, TEntryPointVersion>\n >;\n signUserOperation: (\n args: SignUserOperationParameters<TAccount, TEntryPointVersion, TContext>\n ) => Promise<UserOperationRequest<TEntryPointVersion>>;\n dropAndReplaceUserOperation: (\n args: DropAndReplaceUserOperationParameters<TAccount, TContext>\n ) => Promise<SendUserOperationResult<TEntryPointVersion>>;\n // TODO: for v4 we should combine override and context into an `opts` parameter\n // which wraps both of these properties so we can use GetContextParameter\n sendTransaction: <TChainOverride extends Chain | undefined = undefined>(\n args: SendTransactionParameters<TChain, TAccount, TChainOverride>,\n overrides?: UserOperationOverrides<TEntryPointVersion>,\n context?: TContext\n ) => Promise<Hex>;\n sendTransactions: (\n args: SendTransactionsParameters<TAccount, TContext>\n ) => Promise<Hex>;\n sendUserOperation: (\n args: SendUserOperationParameters<\n TAccount,\n TContext,\n GetEntryPointFromAccount<TAccount>\n >\n ) => Promise<SendUserOperationResult<TEntryPointVersion>>;\n waitForUserOperationTransaction: (\n args: WaitForUserOperationTxParameters\n ) => Promise<Hex>;\n upgradeAccount: (\n args: UpgradeAccountParams<TAccount, TContext>\n ) => Promise<Hex>;\n signMessage: (args: SignMessageParameters<TAccount>) => Promise<Hex>;\n signTypedData: <\n const TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends string = string\n >(\n args: SignTypedDataParameters<TTypedData, TPrimaryType, TAccount>\n ) => Promise<Hex>;\n} & (IsUndefined<TAccount> extends false\n ? { getAddress: () => Address }\n : {\n getAddress: (args: GetAccountParameter<TAccount>) => Address;\n });\n// #endregion SmartAccountClientActions\n\n/**\n * Provides a set of smart account client actions to decorate the provided client. These actions include building and signing user operations, sending transactions, and more.\n *\n * NOTE: this is already added to clients returned from `createSmartAccountClient`\n *\n * @param {Client<TTransport, TChain, TAccount>} client The client to bind the smart account actions to\n * @returns {BaseSmartAccountClientActions<TChain, TAccount, TContext>} An object containing various smart account client actions\n */\nexport const smartAccountClientActions: <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>\n) => BaseSmartAccountClientActions<TChain, TAccount, TContext> = (client) => ({\n buildUserOperation: (args) => buildUserOperation(client, args),\n buildUserOperationFromTx: (args, overrides, context) =>\n buildUserOperationFromTx(client, args, overrides, context),\n buildUserOperationFromTxs: (args) => buildUserOperationFromTxs(client, args),\n checkGasSponsorshipEligibility: (args) =>\n checkGasSponsorshipEligibility(client, args),\n signUserOperation: (args) => signUserOperation(client, args),\n dropAndReplaceUserOperation: (args) =>\n dropAndReplaceUserOperation(client, args),\n sendTransaction: (args, overrides, context) =>\n sendTransaction(client, args, overrides, context),\n sendTransactions: (args) => sendTransactions(client, args),\n sendUserOperation: (args) => sendUserOperation(client, args),\n waitForUserOperationTransaction: (args) =>\n waitForUserOperationTransaction.bind(client)(client, args),\n upgradeAccount: (args) => upgradeAccount(client, args),\n getAddress: (args) => getAddress(client, args),\n signMessage: (args) => signMessage(client, args),\n signTypedData: (args) => signTypedData(client, args),\n});\n\nexport const smartAccountClientMethodKeys = Object.keys(\n // @ts-expect-error we just want to get the keys\n smartAccountClientActions(undefined)\n).reduce((accum, curr) => {\n accum.add(curr);\n return accum;\n}, new Set<string>());\n"]}
|
|
@@ -3,10 +3,10 @@ import type { ClientMiddlewareConfig } from "../client/types";
|
|
|
3
3
|
import type { EntryPointVersion } from "../entrypoint/types";
|
|
4
4
|
import type { UserOperationFeeOptions, UserOperationOverrides, UserOperationRequest, UserOperationStruct } from "../types";
|
|
5
5
|
import { type Deferrable } from "../utils/index.js";
|
|
6
|
-
export type Erc7677RpcSchema = [
|
|
6
|
+
export type Erc7677RpcSchema<TContext extends Record<string, any> = Record<string, any>> = [
|
|
7
7
|
{
|
|
8
8
|
Method: "pm_getPaymasterStubData";
|
|
9
|
-
Parameters: [UserOperationRequest, Address, Hex,
|
|
9
|
+
Parameters: [UserOperationRequest, Address, Hex, TContext];
|
|
10
10
|
ReturnType: {
|
|
11
11
|
sponsor?: {
|
|
12
12
|
name: string;
|
|
@@ -22,7 +22,7 @@ export type Erc7677RpcSchema = [
|
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
Method: "pm_getPaymasterData";
|
|
25
|
-
Parameters: [UserOperationRequest, Address, Hex,
|
|
25
|
+
Parameters: [UserOperationRequest, Address, Hex, TContext];
|
|
26
26
|
ReturnType: {
|
|
27
27
|
paymaster?: Address;
|
|
28
28
|
paymasterData?: Hex;
|
|
@@ -30,7 +30,7 @@ export type Erc7677RpcSchema = [
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
];
|
|
33
|
-
export type Erc7677Client<T extends Transport = Transport> = Client<T, Chain, undefined, Erc7677RpcSchema
|
|
33
|
+
export type Erc7677Client<T extends Transport = Transport, TContext extends Record<string, any> = Record<string, any>> = Client<T, Chain, undefined, Erc7677RpcSchema<TContext>>;
|
|
34
34
|
export type Erc7677MiddlewareParams<TContext extends Record<string, any> | undefined = Record<string, any> | undefined, TEntryPointVersion extends EntryPointVersion = EntryPointVersion> = {
|
|
35
35
|
context?: ((struct: Deferrable<UserOperationStruct<TEntryPointVersion>>, args: {
|
|
36
36
|
overrides?: UserOperationOverrides<TEntryPointVersion>;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M,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QAC3C,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,aAAa,EAAE,GAClD,MAAM,aAAa,CAAC,OAAO,CAAC;YAC1B,MAAM,EAAE,qBAAqB;YAC7B,MAAM,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC;SACtE,CAAC,CAAC;QAEL,IAAI,UAAU,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;YACnC,OAAO;gBACL,GAAG,EAAE;gBACL,gBAAgB;aACjB,CAAC;QACJ,CAAC;QAED,OAAO;YACL,GAAG,EAAE;YACL,SAAS;YACT,aAAa;SACd,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO;QACL,qBAAqB;QACrB,gBAAgB;KACjB,CAAC;AACJ,CAAC","sourcesContent":["import {\n toHex,\n type Address,\n type Chain,\n type Client,\n type Hex,\n type Transport,\n} from \"viem\";\nimport type { ClientMiddlewareConfig } from \"../client/types\";\nimport type { EntryPointVersion } from \"../entrypoint/types\";\nimport { ChainNotFoundError } from \"../errors/client.js\";\nimport type {\n UserOperationFeeOptions,\n UserOperationOverrides,\n UserOperationRequest,\n UserOperationStruct,\n} from \"../types\";\nimport {\n deepHexlify,\n resolveProperties,\n type Deferrable,\n} from \"../utils/index.js\";\nimport type { ClientMiddlewareFn } from \"./types\";\n\nexport type Erc7677RpcSchema = [\n {\n Method: \"pm_getPaymasterStubData\";\n Parameters: [UserOperationRequest, Address, Hex,
|
|
1
|
+
{"version":3,"file":"erc7677middleware.js","sourceRoot":"","sources":["../../../src/middleware/erc7677middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAMN,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAOzD,OAAO,EACL,WAAW,EACX,iBAAiB,GAElB,MAAM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C,EAAE,CAAC,EAAE,OAAO,CAAC;SACtE,CAAC,CAAC;QAEL,IAAI,UAAU,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;YACnC,OAAO;gBACL,GAAG,EAAE;gBACL,gBAAgB;aACjB,CAAC;QACJ,CAAC;QAED,OAAO;YACL,GAAG,EAAE;YACL,SAAS;YACT,aAAa;SACd,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO;QACL,qBAAqB;QACrB,gBAAgB;KACjB,CAAC;AACJ,CAAC","sourcesContent":["import {\n toHex,\n type Address,\n type Chain,\n type Client,\n type Hex,\n type Transport,\n} from \"viem\";\nimport type { ClientMiddlewareConfig } from \"../client/types\";\nimport type { EntryPointVersion } from \"../entrypoint/types\";\nimport { ChainNotFoundError } from \"../errors/client.js\";\nimport type {\n UserOperationFeeOptions,\n UserOperationOverrides,\n UserOperationRequest,\n UserOperationStruct,\n} from \"../types\";\nimport {\n deepHexlify,\n resolveProperties,\n type Deferrable,\n} from \"../utils/index.js\";\nimport type { ClientMiddlewareFn } from \"./types\";\n\nexport type Erc7677RpcSchema<\n TContext extends Record<string, any> = Record<string, any>\n> = [\n {\n Method: \"pm_getPaymasterStubData\";\n Parameters: [UserOperationRequest, Address, Hex, TContext];\n ReturnType: {\n sponsor?: { name: string; icon?: string }; // Sponsor info\n paymaster?: Address; // Paymaster address (entrypoint v0.7)\n paymasterData?: Hex; // Paymaster data (entrypoint v0.7)\n paymasterVerificationGasLimit?: Hex; // Paymaster validation gas (entrypoint v0.7)\n paymasterPostOpGasLimit?: Hex; // Paymaster post-op gas (entrypoint v0.7)\n paymasterAndData?: Hex; // Paymaster and data (entrypoint v0.6)\n isFinal?: boolean; // Indicates that the caller does not need to call pm_getPaymasterData\n };\n },\n {\n Method: \"pm_getPaymasterData\";\n Parameters: [UserOperationRequest, Address, Hex, TContext];\n ReturnType: {\n paymaster?: Address; // Paymaster address (entrypoint v0.7)\n paymasterData?: Hex; // Paymaster data (entrypoint v0.7)\n paymasterAndData?: Hex; // Paymaster and data (entrypoint v0.6)\n };\n }\n];\n\nexport type Erc7677Client<\n T extends Transport = Transport,\n TContext extends Record<string, any> = Record<string, any>\n> = Client<T, Chain, undefined, Erc7677RpcSchema<TContext>>;\n\nexport type Erc7677MiddlewareParams<\n TContext extends Record<string, any> | undefined =\n | Record<string, any>\n | undefined,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = {\n context?:\n | ((\n struct: Deferrable<UserOperationStruct<TEntryPointVersion>>,\n args: {\n overrides?: UserOperationOverrides<TEntryPointVersion>;\n feeOptions?: UserOperationFeeOptions;\n }\n ) => Promise<TContext>)\n | TContext;\n};\n\n/**\n * Middleware function for interacting with ERC-7677 enabled clients. It supports resolving paymaster and data fields for user operations.\n * This middleware assumes that your RPC provider supports the ERC-7677 methods (pm_getPaymasterStubData and pm_getPaymasterData).\n *\n * @example\n * ```ts\n * import { createSmartAccountClient, erc7677Middleware } from \"@aa-sdk/core\";\n * import { http } from \"viem\";\n * import { sepolia } from \"viem/chains\";\n *\n * const client = createSmartAccountClient({\n * transport: http(\"rpc-url\"),\n * chain: sepolia,\n * // this assumes that your RPC provider supports the ERC-7677 methods AND takes no context\n * ...erc7677Middleware(),\n * })\n * ```\n *\n * @param {Erc7677MiddlewareParams<TContext>} params Middleware parameters including context function or object. Context can be resolved dynamically by passing in a function which takes in the context at the time of sending a user op\n * @returns {Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\">} An object containing middleware functions `dummyPaymasterAndData` and `paymasterAndData` for processing user operations with the paymaster data\n */\nexport function erc7677Middleware<\n TContext extends Record<string, any> | undefined =\n | Record<string, any>\n | undefined\n>(\n params?: Erc7677MiddlewareParams<TContext>\n): Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\"> {\n const dummyPaymasterAndData: ClientMiddlewareFn = async (\n uo,\n { client, account, feeOptions, overrides }\n ) => {\n const userOp = deepHexlify(await resolveProperties(uo));\n\n // Those values will be set after fee estimation.\n userOp.maxFeePerGas = \"0x0\";\n userOp.maxPriorityFeePerGas = \"0x0\";\n userOp.callGasLimit = \"0x0\";\n userOp.verificationGasLimit = \"0x0\";\n userOp.preVerificationGas = \"0x0\";\n\n const entrypoint = account.getEntryPoint();\n\n if (entrypoint.version === \"0.7.0\") {\n userOp.paymasterVerificationGasLimit = \"0x0\";\n userOp.paymasterPostOpGasLimit = \"0x0\";\n }\n\n const context =\n (typeof params?.context === \"function\"\n ? await params?.context(userOp, { overrides, feeOptions })\n : params?.context) ?? {};\n\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const erc7677client = client as Erc7677Client;\n // TODO: probably need to handle the sponsor and isFinal fields\n const {\n paymaster,\n paymasterAndData,\n paymasterData,\n paymasterPostOpGasLimit,\n paymasterVerificationGasLimit,\n } = await erc7677client.request({\n method: \"pm_getPaymasterStubData\",\n params: [userOp, entrypoint.address, toHex(client.chain.id), context],\n });\n\n if (entrypoint.version === \"0.6.0\") {\n return {\n ...uo,\n paymasterAndData,\n };\n }\n\n return {\n ...uo,\n paymaster,\n paymasterData,\n paymasterPostOpGasLimit,\n paymasterVerificationGasLimit,\n };\n };\n\n const paymasterAndData: ClientMiddlewareFn = async (\n uo,\n { client, account, feeOptions, overrides }\n ) => {\n const userOp = deepHexlify(await resolveProperties(uo));\n const context =\n (typeof params?.context === \"function\"\n ? await params?.context(userOp, { overrides, feeOptions })\n : params?.context) ?? {};\n\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const erc7677client = client as Erc7677Client;\n\n const entrypoint = account.getEntryPoint();\n const { paymaster, paymasterAndData, paymasterData } =\n await erc7677client.request({\n method: \"pm_getPaymasterData\",\n params: [userOp, entrypoint.address, toHex(client.chain.id), context],\n });\n\n if (entrypoint.version === \"0.6.0\") {\n return {\n ...uo,\n paymasterAndData,\n };\n }\n\n return {\n ...uo,\n paymaster,\n paymasterData,\n };\n };\n\n return {\n dummyPaymasterAndData,\n paymasterAndData,\n };\n}\n"]}
|
|
@@ -58,7 +58,7 @@ export declare class LocalAccountSigner<T extends HDAccount | PrivateKeyAccount
|
|
|
58
58
|
* @param {TypedDataDefinition<TTypedData, TPrimaryType>} params The parameters defining the typed data and primary type
|
|
59
59
|
* @returns {Promise<Hex>} A promise that resolves to the signed data in hexadecimal format
|
|
60
60
|
*/
|
|
61
|
-
readonly signTypedData: <const TTypedData extends {
|
|
61
|
+
readonly signTypedData: <const TTypedData extends Record<string, unknown> | {
|
|
62
62
|
[x: string]: readonly import("viem").TypedDataParameter[];
|
|
63
63
|
[x: `string[${string}]`]: undefined;
|
|
64
64
|
[x: `function[${string}]`]: undefined;
|
|
@@ -263,9 +263,7 @@ export declare class LocalAccountSigner<T extends HDAccount | PrivateKeyAccount
|
|
|
263
263
|
uint232?: undefined;
|
|
264
264
|
uint240?: undefined;
|
|
265
265
|
uint248?: undefined;
|
|
266
|
-
} |
|
|
267
|
-
[key: string]: unknown;
|
|
268
|
-
}, TPrimaryType extends string = string>(params: TypedDataDefinition<TTypedData, TPrimaryType>) => Promise<Hex>;
|
|
266
|
+
}, TPrimaryType extends "EIP712Domain" | keyof TTypedData = keyof TTypedData>(params: TypedDataDefinition<TTypedData, TPrimaryType>) => Promise<Hex>;
|
|
269
267
|
/**
|
|
270
268
|
* Returns the address of the inner object in a specific hexadecimal format.
|
|
271
269
|
*
|
|
@@ -310,5 +308,19 @@ export declare class LocalAccountSigner<T extends HDAccount | PrivateKeyAccount
|
|
|
310
308
|
*
|
|
311
309
|
* @param {Hex} key The private key in hexadecimal format
|
|
312
310
|
* @returns {LocalAccountSigner<PrivateKeyAccount>} An instance of `LocalAccountSigner` initialized with the provided private key
|
|
313
|
-
*/
|
|
311
|
+
*/
|
|
312
|
+
static privateKeyToAccountSigner(key: Hex): LocalAccountSigner<PrivateKeyAccount>;
|
|
313
|
+
/**
|
|
314
|
+
* Generates a new private key and creates a `LocalAccountSigner` for a `PrivateKeyAccount`.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* ```ts
|
|
318
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
319
|
+
*
|
|
320
|
+
* const signer = LocalAccountSigner.generatePrivateKeySigner();
|
|
321
|
+
* ```
|
|
322
|
+
*
|
|
323
|
+
* @returns {LocalAccountSigner<PrivateKeyAccount>} A `LocalAccountSigner` instance initialized with the generated private key account
|
|
324
|
+
*/
|
|
325
|
+
static generatePrivateKeySigner(): LocalAccountSigner<PrivateKeyAccount>;
|
|
314
326
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {} from "viem";
|
|
2
|
-
import { mnemonicToAccount, privateKeyToAccount } from "viem/accounts";
|
|
2
|
+
import { generatePrivateKey, mnemonicToAccount, privateKeyToAccount, } from "viem/accounts";
|
|
3
3
|
/**
|
|
4
4
|
* Represents a local account signer and provides methods to sign messages and transactions, as well as static methods to create the signer from mnemonic or private key.
|
|
5
5
|
*/
|
|
@@ -140,9 +140,26 @@ export class LocalAccountSigner {
|
|
|
140
140
|
*
|
|
141
141
|
* @param {Hex} key The private key in hexadecimal format
|
|
142
142
|
* @returns {LocalAccountSigner<PrivateKeyAccount>} An instance of `LocalAccountSigner` initialized with the provided private key
|
|
143
|
-
*/
|
|
143
|
+
*/
|
|
144
|
+
static privateKeyToAccountSigner(key) {
|
|
144
145
|
const signer = privateKeyToAccount(key);
|
|
145
146
|
return new LocalAccountSigner(signer);
|
|
146
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Generates a new private key and creates a `LocalAccountSigner` for a `PrivateKeyAccount`.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
154
|
+
*
|
|
155
|
+
* const signer = LocalAccountSigner.generatePrivateKeySigner();
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @returns {LocalAccountSigner<PrivateKeyAccount>} A `LocalAccountSigner` instance initialized with the generated private key account
|
|
159
|
+
*/
|
|
160
|
+
static generatePrivateKeySigner() {
|
|
161
|
+
const signer = privateKeyToAccount(generatePrivateKey());
|
|
162
|
+
return new LocalAccountSigner(signer);
|
|
163
|
+
}
|
|
147
164
|
}
|
|
148
165
|
//# sourceMappingURL=local-account.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-account.js","sourceRoot":"","sources":["../../../src/signer/local-account.ts"],"names":[],"mappings":"AAAA,OAAO,EASN,MAAM,MAAM,CAAC;AACd,OAAO,
|
|
1
|
+
{"version":3,"file":"local-account.js","sourceRoot":"","sources":["../../../src/signer/local-account.ts"],"names":[],"mappings":"AAAA,OAAO,EASN,MAAM,MAAM,CAAC;AACd,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAGvB;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAO7B;;;;;;;;;;;;;;OAcG;IACH,YAAY,KAAQ;QAlBpB;;;;;WAAS;QACT;;;;;WAAmB;QAsBnB;;;;;;;;;;;;;;WAcG;QACM;;;;mBAAoE,CAC3E,OAAO,EACP,EAAE;gBACF,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;YAC7C,CAAC;WAAC;QAEF;;;;;;;;;;;;;;;;;;;WAmBG;QACM;;;;mBAAgB,KAAK,EAI5B,MAAqD,EACvC,EAAE;gBAChB,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YAC1C,CAAC;WAAC;QAEF;;;;;;;;;;;;;WAaG;QACM;;;;mBAAa,KAAK,IAA4B,EAAE;gBACvD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;YAC5B,CAAC;WAAC;QAtEA,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,iBAAiB;IACjD,CAAC;IAsED;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,uBAAuB,CAC5B,GAAW,EACX,IAAgB;QAEhB,MAAM,MAAM,GAAG,iBAAiB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC5C,OAAO,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,yBAAyB,CAC9B,GAAQ;QAER,MAAM,MAAM,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACxC,OAAO,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,wBAAwB;QAC7B,MAAM,MAAM,GAAG,mBAAmB,CAAC,kBAAkB,EAAE,CAAC,CAAC;QACzD,OAAO,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["import {\n type HDAccount,\n type HDOptions,\n type Hex,\n type LocalAccount,\n type PrivateKeyAccount,\n type SignableMessage,\n type TypedData,\n type TypedDataDefinition,\n} from \"viem\";\nimport {\n generatePrivateKey,\n mnemonicToAccount,\n privateKeyToAccount,\n} from \"viem/accounts\";\nimport type { SmartAccountSigner } from \"./types.js\";\n\n/**\n * Represents a local account signer and provides methods to sign messages and transactions, as well as static methods to create the signer from mnemonic or private key.\n */\nexport class LocalAccountSigner<\n T extends HDAccount | PrivateKeyAccount | LocalAccount\n> implements SmartAccountSigner<T>\n{\n inner: T;\n signerType: string;\n\n /**\n * A function to initialize an object with an inner parameter and derive a signerType from it.\n *\n * @example\n * ```ts\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { privateKeyToAccount, generatePrivateKey } from \"viem\";\n *\n * const signer = new LocalAccountSigner(\n * privateKeyToAccount(generatePrivateKey()),\n * );\n * ```\n *\n * @param {T} inner The inner parameter containing the necessary data\n */\n constructor(inner: T) {\n this.inner = inner;\n this.signerType = inner.type; // type: \"local\"\n }\n\n /**\n * Signs the provided message using the inner signMessage function.\n *\n * @example\n * ```ts\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\";\n *\n * const signer = LocalAccountSigner.mnemonicToAccountSigner(generatePrivateKey());\n * const signature = await signer.signMessage(\"Hello, world!\");\n * ```\n *\n * @param {string} message The message to be signed\n * @returns {Promise<any>} A promise that resolves to the signed message\n */\n readonly signMessage: (message: SignableMessage) => Promise<`0x${string}`> = (\n message\n ) => {\n return this.inner.signMessage({ message });\n };\n\n /**\n * Signs typed data using the given parameters.\n *\n * @example\n * ```ts\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\";\n *\n * const signer = LocalAccountSigner.mnemonicToAccountSigner(generatePrivateKey());\n * const signature = await signer.signTypedData({\n * domain: {},\n * types: {},\n * primaryType: \"\",\n * message: {},\n * });\n * ```\n *\n * @param {TypedDataDefinition<TTypedData, TPrimaryType>} params The parameters defining the typed data and primary type\n * @returns {Promise<Hex>} A promise that resolves to the signed data in hexadecimal format\n */\n readonly signTypedData = async <\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | \"EIP712Domain\" = keyof TTypedData\n >(\n params: TypedDataDefinition<TTypedData, TPrimaryType>\n ): Promise<Hex> => {\n return this.inner.signTypedData(params);\n };\n\n /**\n * Returns the address of the inner object in a specific hexadecimal format.\n *\n * @example\n * ```ts\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\";\n *\n * const signer = LocalAccountSigner.mnemonicToAccountSigner(generatePrivateKey());\n * const address = await signer.getAddress();\n * ```\n *\n * @returns {Promise<Hex>} A promise that resolves to the address in the format `0x{string}`\n */\n readonly getAddress = async (): Promise<`0x${string}`> => {\n return this.inner.address;\n };\n\n /**\n * Creates a LocalAccountSigner using the provided mnemonic key and optional HD options.\n *\n * @example\n * ```ts\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generateMnemonic } from \"viem\";\n *\n * const signer = LocalAccountSigner.mnemonicToAccountSigner(generateMnemonic());\n * ```\n *\n * @param {string} key The mnemonic key to derive the account from.\n * @param {HDOptions} [opts] Optional HD options for deriving the account.\n * @returns {LocalAccountSigner<HDAccount>} A LocalAccountSigner object for the derived account.\n */\n static mnemonicToAccountSigner(\n key: string,\n opts?: HDOptions\n ): LocalAccountSigner<HDAccount> {\n const signer = mnemonicToAccount(key, opts);\n return new LocalAccountSigner(signer);\n }\n\n /**\n * Creates a `LocalAccountSigner` instance using the provided private key.\n *\n * @example\n * ```ts\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\";\n *\n * const signer = LocalAccountSigner.mnemonicToAccountSigner(generatePrivateKey());\n * ```\n *\n * @param {Hex} key The private key in hexadecimal format\n * @returns {LocalAccountSigner<PrivateKeyAccount>} An instance of `LocalAccountSigner` initialized with the provided private key\n */\n static privateKeyToAccountSigner(\n key: Hex\n ): LocalAccountSigner<PrivateKeyAccount> {\n const signer = privateKeyToAccount(key);\n return new LocalAccountSigner(signer);\n }\n\n /**\n * Generates a new private key and creates a `LocalAccountSigner` for a `PrivateKeyAccount`.\n *\n * @example\n * ```ts\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n *\n * const signer = LocalAccountSigner.generatePrivateKeySigner();\n * ```\n *\n * @returns {LocalAccountSigner<PrivateKeyAccount>} A `LocalAccountSigner` instance initialized with the generated private key account\n */\n static generatePrivateKeySigner(): LocalAccountSigner<PrivateKeyAccount> {\n const signer = privateKeyToAccount(generatePrivateKey());\n return new LocalAccountSigner(signer);\n }\n}\n"]}
|
|
@@ -21,7 +21,5 @@ export interface SmartAccountSigner<Inner = any> {
|
|
|
21
21
|
inner: Inner;
|
|
22
22
|
getAddress: () => Promise<Address>;
|
|
23
23
|
signMessage: (message: SignableMessage) => Promise<Hex>;
|
|
24
|
-
signTypedData: <const TTypedData extends TypedData |
|
|
25
|
-
[key: string]: unknown;
|
|
26
|
-
}, TPrimaryType extends string = string>(params: TypedDataDefinition<TTypedData, TPrimaryType>) => Promise<Hex>;
|
|
24
|
+
signTypedData: <const TTypedData extends TypedData | Record<string, unknown>, TPrimaryType extends keyof TTypedData | "EIP712Domain" = keyof TTypedData>(params: TypedDataDefinition<TTypedData, TPrimaryType>) => Promise<Hex>;
|
|
27
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/signer/types.ts"],"names":[],"mappings":";AA6CA,kCAAkC","sourcesContent":["import type { Address } from \"abitype\";\nimport type {\n Hex,\n SignableMessage,\n TypedData,\n TypedDataDefinition,\n} from \"viem\";\n\n// [!region SmartAccountAuthenticator]\n/**\n * Extends the @interface SmartAccountSigner interface with authentication.\n *\n * @template AuthParams - the generic type of the authentication parameters\n * @template AuthDetails - the generic type of the authentication details\n * @template Inner - the generic type of the inner client that the signer wraps to provide functionality such as signing, etc.\n */\nexport interface SmartAccountAuthenticator<AuthParams, AuthDetails, Inner = any>\n extends SmartAccountSigner<Inner> {\n authenticate: (params: AuthParams) => Promise<AuthDetails>;\n\n getAuthDetails: () => Promise<AuthDetails>;\n}\n// [!endregion SmartAccountAuthenticator]\n\n// [!region SmartAccountSigner]\n/**\n * A signer that can sign messages and typed data.\n *\n * @template Inner - the generic type of the inner client that the signer wraps to provide functionality such as signing, etc.\n */\nexport interface SmartAccountSigner<Inner = any> {\n signerType: string;\n inner: Inner;\n\n getAddress: () => Promise<Address>;\n\n signMessage: (message: SignableMessage) => Promise<Hex>;\n\n signTypedData: <\n const TTypedData extends TypedData |
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/signer/types.ts"],"names":[],"mappings":";AA6CA,kCAAkC","sourcesContent":["import type { Address } from \"abitype\";\nimport type {\n Hex,\n SignableMessage,\n TypedData,\n TypedDataDefinition,\n} from \"viem\";\n\n// [!region SmartAccountAuthenticator]\n/**\n * Extends the @interface SmartAccountSigner interface with authentication.\n *\n * @template AuthParams - the generic type of the authentication parameters\n * @template AuthDetails - the generic type of the authentication details\n * @template Inner - the generic type of the inner client that the signer wraps to provide functionality such as signing, etc.\n */\nexport interface SmartAccountAuthenticator<AuthParams, AuthDetails, Inner = any>\n extends SmartAccountSigner<Inner> {\n authenticate: (params: AuthParams) => Promise<AuthDetails>;\n\n getAuthDetails: () => Promise<AuthDetails>;\n}\n// [!endregion SmartAccountAuthenticator]\n\n// [!region SmartAccountSigner]\n/**\n * A signer that can sign messages and typed data.\n *\n * @template Inner - the generic type of the inner client that the signer wraps to provide functionality such as signing, etc.\n */\nexport interface SmartAccountSigner<Inner = any> {\n signerType: string;\n inner: Inner;\n\n getAddress: () => Promise<Address>;\n\n signMessage: (message: SignableMessage) => Promise<Hex>;\n\n signTypedData: <\n const TTypedData extends TypedData | Record<string, unknown>,\n TPrimaryType extends keyof TTypedData | \"EIP712Domain\" = keyof TTypedData\n >(\n params: TypedDataDefinition<TTypedData, TPrimaryType>\n ) => Promise<Hex>;\n}\n// [!endregion SmartAccountSigner]\n"]}
|
|
@@ -98,7 +98,7 @@ export declare class WalletClientSigner implements SmartAccountSigner<WalletClie
|
|
|
98
98
|
* @param {TypedDataDefinition<TTypedData, TPrimaryType>} typedData The typed data to be signed
|
|
99
99
|
* @returns {Promise<Hex>} A promise that resolves to a hex string representing the signed data
|
|
100
100
|
*/
|
|
101
|
-
signTypedData: <const TTypedData extends {
|
|
101
|
+
signTypedData: <const TTypedData extends Record<string, unknown> | {
|
|
102
102
|
[x: string]: readonly import("viem").TypedDataParameter[];
|
|
103
103
|
[x: `string[${string}]`]: undefined;
|
|
104
104
|
[x: `function[${string}]`]: undefined;
|
|
@@ -303,7 +303,5 @@ export declare class WalletClientSigner implements SmartAccountSigner<WalletClie
|
|
|
303
303
|
uint232?: undefined;
|
|
304
304
|
uint240?: undefined;
|
|
305
305
|
uint248?: undefined;
|
|
306
|
-
} |
|
|
307
|
-
[key: string]: unknown;
|
|
308
|
-
}, TPrimaryType extends string = string>(typedData: TypedDataDefinition<TTypedData, TPrimaryType>) => Promise<Hex>;
|
|
306
|
+
}, TPrimaryType extends string | keyof TTypedData = string>(typedData: TypedDataDefinition<TTypedData, TPrimaryType>) => Promise<Hex>;
|
|
309
307
|
}
|
|
@@ -130,10 +130,11 @@ export class WalletClientSigner {
|
|
|
130
130
|
writable: true,
|
|
131
131
|
value: async (typedData) => {
|
|
132
132
|
const account = this.inner.account ?? (await this.getAddress());
|
|
133
|
-
|
|
133
|
+
const params = {
|
|
134
134
|
account,
|
|
135
135
|
...typedData,
|
|
136
|
-
}
|
|
136
|
+
};
|
|
137
|
+
return this.inner.signTypedData(params);
|
|
137
138
|
}
|
|
138
139
|
});
|
|
139
140
|
this.inner = client;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-client.js","sourceRoot":"","sources":["../../../src/signer/wallet-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,GAMX,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"wallet-client.js","sourceRoot":"","sources":["../../../src/signer/wallet-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,GAMX,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAG7D;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAI7B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAAY,MAAoB,EAAE,UAAkB;QAxBpD;;;;;WAAmB;QACnB;;;;;WAAoB;QA+BpB;;;;;;;;;;;;;;;;;;;WAmBG;QACH;;;;mBAA2C,KAAK,IAAI,EAAE;gBACpD,IAAI,SAAS,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;gBAChD,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YAClC,CAAC;WAAC;QAEF;;;;;;;;;;;;;;;;;;;;WAoBG;QACM;;;;mBACP,KAAK,EAAE,OAAO,EAAE,EAAE;gBAChB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;gBAEhE,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;YACtD,CAAC;WAAC;QAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;WA0BG;QACH;;;;mBAAgB,KAAK,EAInB,SAAwD,EAC1C,EAAE;gBAChB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;gBAEhE,MAAM,MAAM,GAAG;oBACb,OAAO;oBACP,GAAG,SAAS;iBACuD,CAAC;gBAEtE,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAqB,MAAM,CAAC,CAAC;YAC9D,CAAC;WAAC;QArGA,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;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/types.d.ts
CHANGED
|
@@ -112,36 +112,6 @@ export interface UserOperationReceipt {
|
|
|
112
112
|
logs: string[];
|
|
113
113
|
receipt: TransactionReceipt;
|
|
114
114
|
}
|
|
115
|
-
/** @deprecated use viem type TransactionReceipt instead */
|
|
116
|
-
export interface UserOperationReceiptObject {
|
|
117
|
-
blockHash: Hash;
|
|
118
|
-
blockNumber: BigNumberish;
|
|
119
|
-
transactionIndex: BigNumberish;
|
|
120
|
-
transactionHash: Hash;
|
|
121
|
-
from: Address;
|
|
122
|
-
to: Address;
|
|
123
|
-
cumulativeGasUsed: BigNumberish;
|
|
124
|
-
gasUsed: BigNumberish;
|
|
125
|
-
contractAddress: Address;
|
|
126
|
-
logs: UserOperationReceiptLog[];
|
|
127
|
-
logsBloom: Hex;
|
|
128
|
-
root: Hex;
|
|
129
|
-
status: number;
|
|
130
|
-
effectiveGasPrice: BigNumberish;
|
|
131
|
-
type: string;
|
|
132
|
-
}
|
|
133
|
-
/** @deprecated use viem type Log instead */
|
|
134
|
-
export interface UserOperationReceiptLog {
|
|
135
|
-
blockHash: Hash;
|
|
136
|
-
blockNumber: BigNumberish;
|
|
137
|
-
transactionIndex: BigNumberish;
|
|
138
|
-
address: Address;
|
|
139
|
-
logIndex: BigNumberish;
|
|
140
|
-
data: Hex;
|
|
141
|
-
removed: boolean;
|
|
142
|
-
topics: string[];
|
|
143
|
-
transactionHash: Hash;
|
|
144
|
-
}
|
|
145
115
|
export interface UserOperationStruct_v6 {
|
|
146
116
|
sender: string;
|
|
147
117
|
nonce: BigNumberish;
|