@aa-sdk/core 4.34.1 → 4.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/esm/account/smartContractAccount.d.ts +1 -1
- package/dist/esm/account/smartContractAccount.js.map +1 -1
- package/dist/esm/actions/bundler/estimateUserOperationGas.d.ts +3 -2
- package/dist/esm/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/dist/esm/actions/bundler/getSupportedEntryPoints.js.map +1 -1
- package/dist/esm/actions/bundler/getUserOperationByHash.js.map +1 -1
- package/dist/esm/actions/bundler/getUserOperationReceipt.js.map +1 -1
- package/dist/esm/actions/bundler/sendRawUserOperation.d.ts +2 -1
- package/dist/esm/actions/bundler/sendRawUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
- package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
- package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
- package/dist/esm/actions/smartAccount/getAddress.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/initUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/sendUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendTransaction.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendTransactions.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/signMessage.js.map +1 -1
- package/dist/esm/actions/smartAccount/signTypedData.js.map +1 -1
- package/dist/esm/actions/smartAccount/signUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/types.js.map +1 -1
- package/dist/esm/actions/smartAccount/upgradeAccount.js.map +1 -1
- package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.js.map +1 -1
- package/dist/esm/client/addBreadcrumb.js.map +1 -1
- package/dist/esm/client/bundlerClient.js.map +1 -1
- package/dist/esm/client/decorators/bundlerClient.js.map +1 -1
- package/dist/esm/client/decorators/smartAccountClient.js.map +1 -1
- package/dist/esm/client/isSmartAccountClient.js.map +1 -1
- package/dist/esm/client/schema.d.ts +25 -25
- package/dist/esm/client/schema.js.map +1 -1
- package/dist/esm/client/smartAccountClient.js +5 -8
- package/dist/esm/client/smartAccountClient.js.map +1 -1
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/ens/utils.js.map +1 -1
- package/dist/esm/entrypoint/0.6.d.ts +2 -2
- package/dist/esm/entrypoint/0.6.js.map +1 -1
- package/dist/esm/entrypoint/0.7.d.ts +1 -1
- package/dist/esm/entrypoint/0.7.js.map +1 -1
- package/dist/esm/entrypoint/index.d.ts +1 -1
- package/dist/esm/entrypoint/index.js.map +1 -1
- package/dist/esm/entrypoint/types.js.map +1 -1
- package/dist/esm/errors/account.js.map +1 -1
- package/dist/esm/errors/client.js.map +1 -1
- package/dist/esm/errors/entrypoint.js.map +1 -1
- package/dist/esm/errors/signer.js.map +1 -1
- package/dist/esm/errors/useroperation.js.map +1 -1
- package/dist/esm/middleware/actions.js.map +1 -1
- package/dist/esm/middleware/defaults/7702gasEstimator.d.ts +2 -2
- package/dist/esm/middleware/defaults/7702gasEstimator.js +2 -2
- package/dist/esm/middleware/defaults/7702gasEstimator.js.map +1 -1
- package/dist/esm/middleware/defaults/7702signer.d.ts +1 -1
- package/dist/esm/middleware/defaults/7702signer.js +1 -1
- package/dist/esm/middleware/defaults/7702signer.js.map +1 -1
- package/dist/esm/middleware/defaults/feeEstimator.js.map +1 -1
- package/dist/esm/middleware/defaults/gasEstimator.js.map +1 -1
- package/dist/esm/middleware/defaults/paymasterAndData.js.map +1 -1
- package/dist/esm/middleware/defaults/userOpSigner.js.map +1 -1
- package/dist/esm/middleware/erc7677middleware.js.map +1 -1
- package/dist/esm/middleware/types.js.map +1 -1
- package/dist/esm/signer/local-account.d.ts +2 -207
- package/dist/esm/signer/local-account.js.map +1 -1
- package/dist/esm/signer/schema.d.ts +1 -1
- package/dist/esm/signer/types.js.map +1 -1
- package/dist/esm/signer/wallet-client.d.ts +2 -207
- package/dist/esm/signer/wallet-client.js.map +1 -1
- package/dist/esm/transport/split.js +1 -1
- package/dist/esm/transport/split.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/bigint.js.map +1 -1
- package/dist/esm/utils/defaults.js.map +1 -1
- package/dist/esm/utils/index.d.ts +2 -2
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/schema.js.map +1 -1
- package/dist/esm/utils/stateOverride.js.map +1 -1
- package/dist/esm/utils/testUtils.js.map +1 -1
- package/dist/esm/utils/traceHeader.js.map +1 -1
- package/dist/esm/utils/types.js.map +1 -1
- package/dist/esm/utils/userop.d.ts +2 -2
- package/dist/esm/utils/userop.js +1 -1
- package/dist/esm/utils/userop.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/account/smartContractAccount.d.ts +1 -1
- package/dist/types/account/smartContractAccount.d.ts.map +1 -1
- package/dist/types/actions/bundler/estimateUserOperationGas.d.ts +3 -2
- package/dist/types/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
- package/dist/types/actions/bundler/getSupportedEntryPoints.d.ts.map +1 -1
- package/dist/types/actions/bundler/getUserOperationByHash.d.ts.map +1 -1
- package/dist/types/actions/bundler/getUserOperationReceipt.d.ts.map +1 -1
- package/dist/types/actions/bundler/sendRawUserOperation.d.ts +2 -1
- package/dist/types/actions/bundler/sendRawUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/buildUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/buildUserOperationFromTx.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/checkGasSponsorshipEligibility.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/estimateUserOperationGas.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/internal/initUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/internal/runMiddlewareStack.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/internal/sendUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/sendTransaction.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/sendUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/signUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/types.d.ts.map +1 -1
- package/dist/types/client/decorators/smartAccountClient.d.ts.map +1 -1
- package/dist/types/client/schema.d.ts +25 -25
- package/dist/types/client/schema.d.ts.map +1 -1
- package/dist/types/client/smartAccountClient.d.ts.map +1 -1
- package/dist/types/ens/utils.d.ts.map +1 -1
- package/dist/types/entrypoint/0.6.d.ts +2 -2
- package/dist/types/entrypoint/0.6.d.ts.map +1 -1
- package/dist/types/entrypoint/0.7.d.ts +1 -1
- package/dist/types/entrypoint/0.7.d.ts.map +1 -1
- package/dist/types/entrypoint/index.d.ts +1 -1
- package/dist/types/entrypoint/index.d.ts.map +1 -1
- package/dist/types/entrypoint/types.d.ts.map +1 -1
- package/dist/types/errors/useroperation.d.ts.map +1 -1
- package/dist/types/middleware/actions.d.ts.map +1 -1
- package/dist/types/middleware/defaults/7702gasEstimator.d.ts +2 -2
- package/dist/types/middleware/defaults/7702signer.d.ts +1 -1
- package/dist/types/middleware/types.d.ts.map +1 -1
- package/dist/types/signer/local-account.d.ts +2 -207
- package/dist/types/signer/local-account.d.ts.map +1 -1
- package/dist/types/signer/schema.d.ts +1 -1
- package/dist/types/signer/schema.d.ts.map +1 -1
- package/dist/types/signer/utils.d.ts.map +1 -1
- package/dist/types/signer/wallet-client.d.ts +2 -207
- package/dist/types/signer/wallet-client.d.ts.map +1 -1
- package/dist/types/transport/split.d.ts.map +1 -1
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/bigint.d.ts.map +1 -1
- package/dist/types/utils/bytes.d.ts.map +1 -1
- package/dist/types/utils/defaults.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +2 -2
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/testUtils.d.ts.map +1 -1
- package/dist/types/utils/traceHeader.d.ts.map +1 -1
- package/dist/types/utils/userop.d.ts +2 -2
- package/dist/types/utils/userop.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -6
- package/src/account/smartContractAccount.ts +27 -25
- package/src/actions/bundler/estimateUserOperationGas.ts +2 -2
- package/src/actions/bundler/getSupportedEntryPoints.ts +2 -2
- package/src/actions/bundler/getUserOperationByHash.ts +2 -2
- package/src/actions/bundler/getUserOperationReceipt.ts +2 -2
- package/src/actions/bundler/sendRawUserOperation.ts +2 -2
- package/src/actions/smartAccount/buildUserOperation.ts +5 -4
- package/src/actions/smartAccount/buildUserOperationFromTx.ts +4 -3
- package/src/actions/smartAccount/buildUserOperationFromTxs.ts +9 -8
- package/src/actions/smartAccount/checkGasSponsorshipEligibility.ts +5 -4
- package/src/actions/smartAccount/dropAndReplaceUserOperation.ts +7 -6
- package/src/actions/smartAccount/estimateUserOperationGas.ts +5 -4
- package/src/actions/smartAccount/getAddress.ts +2 -2
- package/src/actions/smartAccount/internal/initUserOperation.ts +7 -6
- package/src/actions/smartAccount/internal/runMiddlewareStack.ts +13 -12
- package/src/actions/smartAccount/internal/sendUserOperation.ts +3 -2
- package/src/actions/smartAccount/sendTransaction.ts +5 -4
- package/src/actions/smartAccount/sendTransactions.ts +3 -3
- package/src/actions/smartAccount/sendUserOperation.ts +4 -3
- package/src/actions/smartAccount/signMessage.ts +3 -3
- package/src/actions/smartAccount/signTypedData.ts +3 -3
- package/src/actions/smartAccount/signUserOperation.ts +4 -3
- package/src/actions/smartAccount/types.ts +23 -15
- package/src/actions/smartAccount/upgradeAccount.ts +3 -3
- package/src/actions/smartAccount/waitForUserOperationTransacation.ts +5 -5
- package/src/client/addBreadcrumb.ts +1 -1
- package/src/client/bundlerClient.ts +5 -5
- package/src/client/decorators/bundlerClient.ts +7 -7
- package/src/client/decorators/smartAccountClient.ts +20 -18
- package/src/client/isSmartAccountClient.ts +4 -4
- package/src/client/schema.ts +2 -2
- package/src/client/smartAccountClient.ts +98 -104
- package/src/client/types.ts +2 -2
- package/src/ens/utils.ts +1 -1
- package/src/entrypoint/0.6.ts +3 -3
- package/src/entrypoint/0.7.ts +4 -4
- package/src/entrypoint/index.ts +10 -9
- package/src/entrypoint/types.ts +30 -28
- package/src/errors/account.ts +1 -1
- package/src/errors/client.ts +3 -3
- package/src/errors/entrypoint.ts +2 -2
- package/src/errors/signer.ts +1 -1
- package/src/errors/useroperation.ts +6 -3
- package/src/middleware/actions.ts +3 -3
- package/src/middleware/defaults/7702gasEstimator.ts +4 -4
- package/src/middleware/defaults/7702signer.ts +3 -3
- package/src/middleware/defaults/feeEstimator.ts +4 -4
- package/src/middleware/defaults/gasEstimator.ts +6 -6
- package/src/middleware/defaults/paymasterAndData.ts +1 -1
- package/src/middleware/defaults/userOpSigner.ts +2 -2
- package/src/middleware/erc7677middleware.ts +9 -9
- package/src/middleware/types.ts +7 -5
- package/src/signer/local-account.ts +7 -7
- package/src/signer/types.ts +3 -3
- package/src/signer/wallet-client.ts +2 -2
- package/src/transport/split.ts +9 -12
- package/src/types.ts +29 -29
- package/src/utils/bigint.ts +4 -4
- package/src/utils/defaults.ts +1 -1
- package/src/utils/index.ts +12 -9
- package/src/utils/schema.ts +2 -2
- package/src/utils/stateOverride.ts +4 -4
- package/src/utils/testUtils.ts +2 -2
- package/src/utils/traceHeader.ts +14 -11
- package/src/utils/types.ts +1 -1
- package/src/utils/userop.ts +17 -17
- package/src/version.ts +1 -1
|
@@ -35,11 +35,11 @@ import { defaultGasEstimator } from "./gasEstimator.js";
|
|
|
35
35
|
* }
|
|
36
36
|
* ```
|
|
37
37
|
*
|
|
38
|
-
* @param {ClientMiddlewareFn}
|
|
39
|
-
* @returns {
|
|
38
|
+
* @param {ClientMiddlewareFn} gasEstimator Optional custom gas estimator function
|
|
39
|
+
* @returns {ClientMiddlewareFn} A function that takes user operation struct and parameters, estimates gas usage, and returns the user operation with gas limits.
|
|
40
40
|
*/
|
|
41
41
|
export const default7702GasEstimator: (
|
|
42
|
-
gasEstimator?: ClientMiddlewareFn
|
|
42
|
+
gasEstimator?: ClientMiddlewareFn,
|
|
43
43
|
) => ClientMiddlewareFn =
|
|
44
44
|
(gasEstimator?: ClientMiddlewareFn) => async (struct, params) => {
|
|
45
45
|
const gasEstimator_ = gasEstimator ?? defaultGasEstimator(params.client);
|
|
@@ -52,7 +52,7 @@ export const default7702GasEstimator: (
|
|
|
52
52
|
const entryPoint = account.getEntryPoint();
|
|
53
53
|
if (entryPoint.version !== "0.7.0") {
|
|
54
54
|
throw new Error(
|
|
55
|
-
"This middleware is only compatible with EntryPoint v0.7.0"
|
|
55
|
+
"This middleware is only compatible with EntryPoint v0.7.0",
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -38,10 +38,10 @@ import { defaultUserOpSigner } from "./userOpSigner.js";
|
|
|
38
38
|
* ```
|
|
39
39
|
*
|
|
40
40
|
* @param {ClientMiddlewareFn} [userOpSigner] Optional user operation signer function
|
|
41
|
-
* @returns {
|
|
41
|
+
* @returns {ClientMiddlewareFn} A middleware function that signs EIP-7702 authorization tuples if necessary, and also uses the provided or default user operation signer to generate the user op signature.
|
|
42
42
|
*/
|
|
43
43
|
export const default7702UserOpSigner: (
|
|
44
|
-
userOpSigner?: ClientMiddlewareFn
|
|
44
|
+
userOpSigner?: ClientMiddlewareFn,
|
|
45
45
|
) => ClientMiddlewareFn =
|
|
46
46
|
(userOpSigner?: ClientMiddlewareFn) => async (struct, params) => {
|
|
47
47
|
const userOpSigner_ = userOpSigner ?? defaultUserOpSigner;
|
|
@@ -52,7 +52,7 @@ export const default7702UserOpSigner: (
|
|
|
52
52
|
// Strip out the dummy eip7702 fields.
|
|
53
53
|
eip7702Auth: undefined,
|
|
54
54
|
},
|
|
55
|
-
params
|
|
55
|
+
params,
|
|
56
56
|
);
|
|
57
57
|
|
|
58
58
|
const account = params.account ?? params.client.account;
|
|
@@ -24,7 +24,7 @@ import type { ClientMiddlewareFn } from "../types";
|
|
|
24
24
|
* @returns {ClientMiddlewareFn} A middleware function that takes in the struct and options, estimates the fees, and updates the struct with the estimated fees
|
|
25
25
|
*/
|
|
26
26
|
export function defaultFeeEstimator<C extends MiddlewareClient>(
|
|
27
|
-
client: C
|
|
27
|
+
client: C,
|
|
28
28
|
): ClientMiddlewareFn {
|
|
29
29
|
return async (struct, { overrides, feeOptions }) => {
|
|
30
30
|
// maxFeePerGas must be at least the sum of maxPriorityFeePerGas and baseFee
|
|
@@ -39,7 +39,7 @@ export function defaultFeeEstimator<C extends MiddlewareClient>(
|
|
|
39
39
|
const feeData = await client.estimateFeesPerGas();
|
|
40
40
|
if (!feeData.maxFeePerGas || feeData.maxPriorityFeePerGas == null) {
|
|
41
41
|
throw new Error(
|
|
42
|
-
"feeData is missing maxFeePerGas or maxPriorityFeePerGas"
|
|
42
|
+
"feeData is missing maxFeePerGas or maxPriorityFeePerGas",
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -49,7 +49,7 @@ export function defaultFeeEstimator<C extends MiddlewareClient>(
|
|
|
49
49
|
maxPriorityFeePerGas = applyUserOpOverrideOrFeeOption(
|
|
50
50
|
maxPriorityFeePerGas,
|
|
51
51
|
overrides?.maxPriorityFeePerGas,
|
|
52
|
-
feeOptions?.maxPriorityFeePerGas
|
|
52
|
+
feeOptions?.maxPriorityFeePerGas,
|
|
53
53
|
);
|
|
54
54
|
|
|
55
55
|
let maxFeePerGas: BigNumberish =
|
|
@@ -60,7 +60,7 @@ export function defaultFeeEstimator<C extends MiddlewareClient>(
|
|
|
60
60
|
maxFeePerGas = applyUserOpOverrideOrFeeOption(
|
|
61
61
|
maxFeePerGas,
|
|
62
62
|
overrides?.maxFeePerGas,
|
|
63
|
-
feeOptions?.maxFeePerGas
|
|
63
|
+
feeOptions?.maxFeePerGas,
|
|
64
64
|
);
|
|
65
65
|
|
|
66
66
|
struct.maxFeePerGas = maxFeePerGas;
|
|
@@ -17,7 +17,7 @@ import type { ClientMiddlewareFn } from "../types.js";
|
|
|
17
17
|
* @returns {ClientMiddlewareFn} middleware execution function used to estimate gas for user operations
|
|
18
18
|
*/
|
|
19
19
|
export const defaultGasEstimator: <C extends MiddlewareClient>(
|
|
20
|
-
client: C
|
|
20
|
+
client: C,
|
|
21
21
|
) => ClientMiddlewareFn =
|
|
22
22
|
(client: MiddlewareClient): ClientMiddlewareFn =>
|
|
23
23
|
async (struct, { account, overrides, feeOptions }) => {
|
|
@@ -26,23 +26,23 @@ export const defaultGasEstimator: <C extends MiddlewareClient>(
|
|
|
26
26
|
const estimates = await client.estimateUserOperationGas(
|
|
27
27
|
request,
|
|
28
28
|
account.getEntryPoint().address,
|
|
29
|
-
overrides?.stateOverride
|
|
29
|
+
overrides?.stateOverride,
|
|
30
30
|
);
|
|
31
31
|
|
|
32
32
|
const callGasLimit = applyUserOpOverrideOrFeeOption(
|
|
33
33
|
estimates.callGasLimit,
|
|
34
34
|
overrides?.callGasLimit,
|
|
35
|
-
feeOptions?.callGasLimit
|
|
35
|
+
feeOptions?.callGasLimit,
|
|
36
36
|
);
|
|
37
37
|
const verificationGasLimit = applyUserOpOverrideOrFeeOption(
|
|
38
38
|
estimates.verificationGasLimit,
|
|
39
39
|
overrides?.verificationGasLimit,
|
|
40
|
-
feeOptions?.verificationGasLimit
|
|
40
|
+
feeOptions?.verificationGasLimit,
|
|
41
41
|
);
|
|
42
42
|
const preVerificationGas = applyUserOpOverrideOrFeeOption(
|
|
43
43
|
estimates.preVerificationGas,
|
|
44
44
|
overrides?.preVerificationGas,
|
|
45
|
-
feeOptions?.preVerificationGas
|
|
45
|
+
feeOptions?.preVerificationGas,
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
struct.callGasLimit = callGasLimit;
|
|
@@ -56,7 +56,7 @@ export const defaultGasEstimator: <C extends MiddlewareClient>(
|
|
|
56
56
|
(overrides as UserOperationOverrides<"0.7.0">)
|
|
57
57
|
?.paymasterVerificationGasLimit,
|
|
58
58
|
(feeOptions as UserOperationFeeOptions<"0.7.0">)
|
|
59
|
-
?.paymasterVerificationGasLimit
|
|
59
|
+
?.paymasterVerificationGasLimit,
|
|
60
60
|
);
|
|
61
61
|
const uo_v7 = struct as UserOperationStruct<"0.7.0">;
|
|
62
62
|
|
|
@@ -11,7 +11,7 @@ import type { ClientMiddlewareFn } from "../types";
|
|
|
11
11
|
*/
|
|
12
12
|
export const defaultPaymasterAndData: ClientMiddlewareFn = async (
|
|
13
13
|
struct,
|
|
14
|
-
{ account }
|
|
14
|
+
{ account },
|
|
15
15
|
) => {
|
|
16
16
|
const entryPoint = account.getEntryPoint();
|
|
17
17
|
if (entryPoint.version === "0.6.0") {
|
|
@@ -20,7 +20,7 @@ import type { ClientMiddlewareFn } from "../types";
|
|
|
20
20
|
*/
|
|
21
21
|
export const defaultUserOpSigner: ClientMiddlewareFn = async (
|
|
22
22
|
struct,
|
|
23
|
-
{ client, account = client.account }
|
|
23
|
+
{ client, account = client.account },
|
|
24
24
|
) => {
|
|
25
25
|
if (!account) {
|
|
26
26
|
throw new AccountNotFoundError();
|
|
@@ -39,7 +39,7 @@ export const defaultUserOpSigner: ClientMiddlewareFn = async (
|
|
|
39
39
|
return {
|
|
40
40
|
...resolvedStruct,
|
|
41
41
|
signature: await account.signUserOperationHash(
|
|
42
|
-
account.getEntryPoint().getUserOperationHash(request)
|
|
42
|
+
account.getEntryPoint().getUserOperationHash(request),
|
|
43
43
|
),
|
|
44
44
|
};
|
|
45
45
|
};
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
import type { ClientMiddlewareFn } from "./types";
|
|
24
24
|
|
|
25
25
|
export type Erc7677RpcSchema<
|
|
26
|
-
TContext extends Record<string, any> = Record<string, any
|
|
26
|
+
TContext extends Record<string, any> = Record<string, any>,
|
|
27
27
|
> = [
|
|
28
28
|
{
|
|
29
29
|
Method: "pm_getPaymasterStubData";
|
|
@@ -46,19 +46,19 @@ export type Erc7677RpcSchema<
|
|
|
46
46
|
paymasterData?: Hex; // Paymaster data (entrypoint v0.7)
|
|
47
47
|
paymasterAndData?: Hex; // Paymaster and data (entrypoint v0.6)
|
|
48
48
|
};
|
|
49
|
-
}
|
|
49
|
+
},
|
|
50
50
|
];
|
|
51
51
|
|
|
52
52
|
export type Erc7677Client<
|
|
53
53
|
T extends Transport = Transport,
|
|
54
|
-
TContext extends Record<string, any> = Record<string, any
|
|
54
|
+
TContext extends Record<string, any> = Record<string, any>,
|
|
55
55
|
> = Client<T, Chain, undefined, Erc7677RpcSchema<TContext>>;
|
|
56
56
|
|
|
57
57
|
export type Erc7677MiddlewareParams<
|
|
58
58
|
TContext extends Record<string, any> | undefined =
|
|
59
59
|
| Record<string, any>
|
|
60
60
|
| undefined,
|
|
61
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
61
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
62
62
|
> = {
|
|
63
63
|
context?:
|
|
64
64
|
| ((
|
|
@@ -66,7 +66,7 @@ export type Erc7677MiddlewareParams<
|
|
|
66
66
|
args: {
|
|
67
67
|
overrides?: UserOperationOverrides<TEntryPointVersion>;
|
|
68
68
|
feeOptions?: UserOperationFeeOptions;
|
|
69
|
-
}
|
|
69
|
+
},
|
|
70
70
|
) => Promise<TContext>)
|
|
71
71
|
| TContext;
|
|
72
72
|
};
|
|
@@ -95,15 +95,15 @@ export type Erc7677MiddlewareParams<
|
|
|
95
95
|
export function erc7677Middleware<
|
|
96
96
|
TContext extends Record<string, any> | undefined =
|
|
97
97
|
| Record<string, any>
|
|
98
|
-
| undefined
|
|
98
|
+
| undefined,
|
|
99
99
|
>(
|
|
100
|
-
params?: Erc7677MiddlewareParams<TContext
|
|
100
|
+
params?: Erc7677MiddlewareParams<TContext>,
|
|
101
101
|
): Required<
|
|
102
102
|
Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">
|
|
103
103
|
> {
|
|
104
104
|
const dummyPaymasterAndData: ClientMiddlewareFn = async (
|
|
105
105
|
uo,
|
|
106
|
-
{ client, account, feeOptions, overrides }
|
|
106
|
+
{ client, account, feeOptions, overrides },
|
|
107
107
|
) => {
|
|
108
108
|
const userOp = deepHexlify(await resolveProperties(uo));
|
|
109
109
|
|
|
@@ -161,7 +161,7 @@ export function erc7677Middleware<
|
|
|
161
161
|
|
|
162
162
|
const paymasterAndData: ClientMiddlewareFn = async (
|
|
163
163
|
uo,
|
|
164
|
-
{ client, account, feeOptions, overrides }
|
|
164
|
+
{ client, account, feeOptions, overrides },
|
|
165
165
|
) => {
|
|
166
166
|
const userOp = deepHexlify(await resolveProperties(uo));
|
|
167
167
|
const context =
|
package/src/middleware/types.ts
CHANGED
|
@@ -17,7 +17,8 @@ export type ClientMiddlewareArgs<
|
|
|
17
17
|
TContext extends UserOperationContext | undefined =
|
|
18
18
|
| UserOperationContext
|
|
19
19
|
| undefined,
|
|
20
|
-
TEntryPointVersion extends
|
|
20
|
+
TEntryPointVersion extends
|
|
21
|
+
GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,
|
|
21
22
|
> = {
|
|
22
23
|
overrides?: UserOperationOverrides<TEntryPointVersion>;
|
|
23
24
|
context?: TContext;
|
|
@@ -30,14 +31,15 @@ export type ClientMiddlewareArgs<
|
|
|
30
31
|
export type ClientMiddlewareFn<
|
|
31
32
|
TContext extends UserOperationContext | undefined =
|
|
32
33
|
| UserOperationContext
|
|
33
|
-
| undefined
|
|
34
|
+
| undefined,
|
|
34
35
|
> = <
|
|
35
36
|
TAccount extends SmartContractAccount,
|
|
36
37
|
C extends MiddlewareClient,
|
|
37
|
-
TEntryPointVersion extends
|
|
38
|
+
TEntryPointVersion extends
|
|
39
|
+
GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,
|
|
38
40
|
>(
|
|
39
41
|
struct: Deferrable<UserOperationStruct<TEntryPointVersion>>,
|
|
40
|
-
args: ClientMiddlewareArgs<TAccount, C, TContext, TEntryPointVersion
|
|
42
|
+
args: ClientMiddlewareArgs<TAccount, C, TContext, TEntryPointVersion>,
|
|
41
43
|
) => Promise<Deferrable<UserOperationStruct<TEntryPointVersion>>>;
|
|
42
44
|
// [!endregion ClientMiddlewareFn]
|
|
43
45
|
|
|
@@ -45,7 +47,7 @@ export type ClientMiddlewareFn<
|
|
|
45
47
|
export type ClientMiddleware<
|
|
46
48
|
TContext extends UserOperationContext | undefined =
|
|
47
49
|
| UserOperationContext
|
|
48
|
-
| undefined
|
|
50
|
+
| undefined,
|
|
49
51
|
> = {
|
|
50
52
|
dummyPaymasterAndData: ClientMiddlewareFn<TContext>;
|
|
51
53
|
feeEstimator: ClientMiddlewareFn<TContext>;
|
|
@@ -20,7 +20,7 @@ import type { AuthorizationRequest, SmartAccountSigner } from "./types.js";
|
|
|
20
20
|
* 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.
|
|
21
21
|
*/
|
|
22
22
|
export class LocalAccountSigner<
|
|
23
|
-
T extends HDAccount | PrivateKeyAccount | LocalAccount
|
|
23
|
+
T extends HDAccount | PrivateKeyAccount | LocalAccount,
|
|
24
24
|
> implements SmartAccountSigner<T>
|
|
25
25
|
{
|
|
26
26
|
inner: T;
|
|
@@ -62,7 +62,7 @@ export class LocalAccountSigner<
|
|
|
62
62
|
* @returns {Promise<any>} A promise that resolves to the signed message
|
|
63
63
|
*/
|
|
64
64
|
readonly signMessage: (message: SignableMessage) => Promise<`0x${string}`> = (
|
|
65
|
-
message
|
|
65
|
+
message,
|
|
66
66
|
) => {
|
|
67
67
|
return this.inner.signMessage({ message });
|
|
68
68
|
};
|
|
@@ -89,9 +89,9 @@ export class LocalAccountSigner<
|
|
|
89
89
|
*/
|
|
90
90
|
readonly signTypedData = async <
|
|
91
91
|
const TTypedData extends TypedData | Record<string, unknown>,
|
|
92
|
-
TPrimaryType extends keyof TTypedData | "EIP712Domain" = keyof TTypedData
|
|
92
|
+
TPrimaryType extends keyof TTypedData | "EIP712Domain" = keyof TTypedData,
|
|
93
93
|
>(
|
|
94
|
-
params: TypedDataDefinition<TTypedData, TPrimaryType
|
|
94
|
+
params: TypedDataDefinition<TTypedData, TPrimaryType>,
|
|
95
95
|
): Promise<Hex> => {
|
|
96
96
|
return this.inner.signTypedData(params);
|
|
97
97
|
};
|
|
@@ -118,7 +118,7 @@ export class LocalAccountSigner<
|
|
|
118
118
|
|
|
119
119
|
signAuthorization(
|
|
120
120
|
this: LocalAccountSigner<PrivateKeyAccount>,
|
|
121
|
-
unsignedAuthorization: AuthorizationRequest<number
|
|
121
|
+
unsignedAuthorization: AuthorizationRequest<number>,
|
|
122
122
|
): Promise<SignedAuthorization<number>> {
|
|
123
123
|
return this.inner.signAuthorization(unsignedAuthorization);
|
|
124
124
|
}
|
|
@@ -158,7 +158,7 @@ export class LocalAccountSigner<
|
|
|
158
158
|
*/
|
|
159
159
|
static mnemonicToAccountSigner(
|
|
160
160
|
key: string,
|
|
161
|
-
opts?: HDOptions
|
|
161
|
+
opts?: HDOptions,
|
|
162
162
|
): LocalAccountSigner<HDAccount> {
|
|
163
163
|
const signer = mnemonicToAccount(key, opts);
|
|
164
164
|
return new LocalAccountSigner(signer);
|
|
@@ -179,7 +179,7 @@ export class LocalAccountSigner<
|
|
|
179
179
|
* @returns {LocalAccountSigner<PrivateKeyAccount>} An instance of `LocalAccountSigner` initialized with the provided private key
|
|
180
180
|
*/
|
|
181
181
|
static privateKeyToAccountSigner(
|
|
182
|
-
key: Hex
|
|
182
|
+
key: Hex,
|
|
183
183
|
): LocalAccountSigner<PrivateKeyAccount> {
|
|
184
184
|
const signer = privateKeyToAccount(key);
|
|
185
185
|
return new LocalAccountSigner(signer);
|
package/src/signer/types.ts
CHANGED
|
@@ -55,13 +55,13 @@ export interface SmartAccountSigner<Inner = any> {
|
|
|
55
55
|
|
|
56
56
|
signTypedData: <
|
|
57
57
|
const TTypedData extends TypedData | Record<string, unknown>,
|
|
58
|
-
TPrimaryType extends keyof TTypedData | "EIP712Domain" = keyof TTypedData
|
|
58
|
+
TPrimaryType extends keyof TTypedData | "EIP712Domain" = keyof TTypedData,
|
|
59
59
|
>(
|
|
60
|
-
params: TypedDataDefinition<TTypedData, TPrimaryType
|
|
60
|
+
params: TypedDataDefinition<TTypedData, TPrimaryType>,
|
|
61
61
|
) => Promise<Hex>;
|
|
62
62
|
|
|
63
63
|
signAuthorization?: (
|
|
64
|
-
unsignedAuthorization: AuthorizationRequest<number
|
|
64
|
+
unsignedAuthorization: AuthorizationRequest<number>,
|
|
65
65
|
) => Promise<SignedAuthorization<number>>;
|
|
66
66
|
}
|
|
67
67
|
// [!endregion SmartAccountSigner]
|
|
@@ -129,9 +129,9 @@ export class WalletClientSigner implements SmartAccountSigner<WalletClient> {
|
|
|
129
129
|
*/
|
|
130
130
|
signTypedData = async <
|
|
131
131
|
const TTypedData extends TypedData | Record<string, unknown>,
|
|
132
|
-
TPrimaryType extends keyof TTypedData | "EIP712Domain" | string = string
|
|
132
|
+
TPrimaryType extends keyof TTypedData | "EIP712Domain" | string = string,
|
|
133
133
|
>(
|
|
134
|
-
typedData: TypedDataDefinition<TTypedData, TPrimaryType
|
|
134
|
+
typedData: TypedDataDefinition<TTypedData, TPrimaryType>,
|
|
135
135
|
): Promise<Hex> => {
|
|
136
136
|
const account = this.inner.account ?? (await this.getAddress());
|
|
137
137
|
|
package/src/transport/split.ts
CHANGED
|
@@ -45,7 +45,7 @@ export const split = (params: SplitTransportParams): CustomTransport => {
|
|
|
45
45
|
curr.methods.forEach((method) => {
|
|
46
46
|
if (accum.has(method) && accum.get(method) !== curr.transport) {
|
|
47
47
|
throw new Error(
|
|
48
|
-
"A method cannot be handled by more than one transport"
|
|
48
|
+
"A method cannot be handled by more than one transport",
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -56,17 +56,14 @@ export const split = (params: SplitTransportParams): CustomTransport => {
|
|
|
56
56
|
}, new Map<string, Transport>());
|
|
57
57
|
|
|
58
58
|
return (opts) =>
|
|
59
|
-
custom(
|
|
60
|
-
{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
59
|
+
custom({
|
|
60
|
+
request: async (args) => {
|
|
61
|
+
const transportOverride = overrideMap.get(args.method);
|
|
62
|
+
if (transportOverride != null) {
|
|
63
|
+
return transportOverride(opts).request(args);
|
|
64
|
+
}
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
},
|
|
66
|
+
return params.fallback(opts).request(args);
|
|
69
67
|
},
|
|
70
|
-
|
|
71
|
-
)(opts);
|
|
68
|
+
})(opts);
|
|
72
69
|
};
|
package/src/types.ts
CHANGED
|
@@ -53,49 +53,49 @@ export type UserOperationFeeOptionsField = z.input<
|
|
|
53
53
|
>;
|
|
54
54
|
|
|
55
55
|
export type UserOperationFeeOptions<
|
|
56
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
56
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
57
57
|
> = TEntryPointVersion extends "0.6.0"
|
|
58
58
|
? z.input<typeof UserOperationFeeOptionsSchema_v6>
|
|
59
59
|
: TEntryPointVersion extends "0.7.0"
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
? z.input<typeof UserOperationFeeOptionsSchema_v7>
|
|
61
|
+
: z.input<typeof UserOperationFeeOptionsSchema>;
|
|
62
62
|
|
|
63
63
|
export type UserOperationOverridesParameter<
|
|
64
64
|
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
65
|
-
Required extends boolean = false
|
|
65
|
+
Required extends boolean = false,
|
|
66
66
|
> = Required extends true
|
|
67
67
|
? { overrides: UserOperationOverrides<TEntryPointVersion> }
|
|
68
68
|
: { overrides?: UserOperationOverrides<TEntryPointVersion> };
|
|
69
69
|
|
|
70
70
|
// [!region UserOperationPaymasterOverrides]
|
|
71
71
|
export type UserOperationPaymasterOverrides<
|
|
72
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
72
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
73
73
|
> = TEntryPointVersion extends "0.6.0"
|
|
74
74
|
? {
|
|
75
75
|
// paymasterData overrides to bypass paymaster middleware
|
|
76
76
|
paymasterAndData: Hex;
|
|
77
77
|
}
|
|
78
78
|
: TEntryPointVersion extends "0.7.0"
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
79
|
+
? {
|
|
80
|
+
// paymasterData overrides to bypass paymaster middleware
|
|
81
|
+
// if set to '0x', all paymaster related fields are omitted from the user op request
|
|
82
|
+
paymasterData: Hex;
|
|
83
|
+
paymaster: Address;
|
|
84
|
+
paymasterVerificationGasLimit:
|
|
85
|
+
| NoUndefined<
|
|
86
|
+
UserOperationStruct<"0.7.0">["paymasterVerificationGasLimit"]
|
|
87
|
+
>
|
|
88
|
+
| Multiplier;
|
|
89
|
+
paymasterPostOpGasLimit:
|
|
90
|
+
| NoUndefined<UserOperationStruct<"0.7.0">["paymasterPostOpGasLimit"]>
|
|
91
|
+
| Multiplier;
|
|
92
|
+
}
|
|
93
|
+
: {};
|
|
94
94
|
// [!endregion UserOperationOverridesParameter]
|
|
95
95
|
|
|
96
96
|
// [!region UserOperationOverrides]
|
|
97
97
|
export type UserOperationOverrides<
|
|
98
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
98
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
99
99
|
> = Partial<
|
|
100
100
|
{
|
|
101
101
|
callGasLimit:
|
|
@@ -221,19 +221,19 @@ export type Eip7702ExtendedFields = {
|
|
|
221
221
|
// [!region UserOperationRequest]
|
|
222
222
|
// Reference: https://eips.ethereum.org/EIPS/eip-4337#definitions
|
|
223
223
|
export type UserOperationRequest<
|
|
224
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
224
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
225
225
|
> = (TEntryPointVersion extends "0.6.0"
|
|
226
226
|
? UserOperationRequest_v6
|
|
227
227
|
: TEntryPointVersion extends "0.7.0"
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
? UserOperationRequest_v7
|
|
229
|
+
: never) &
|
|
230
230
|
Eip7702ExtendedFields;
|
|
231
231
|
|
|
232
232
|
// [!endregion UserOperationRequest]
|
|
233
233
|
|
|
234
234
|
// [!region UserOperationEstimateGasResponse]
|
|
235
235
|
export interface UserOperationEstimateGasResponse<
|
|
236
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
236
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
237
237
|
> {
|
|
238
238
|
/* Gas overhead of this UserOperation */
|
|
239
239
|
preVerificationGas: BigNumberish;
|
|
@@ -254,7 +254,7 @@ export interface UserOperationEstimateGasResponse<
|
|
|
254
254
|
|
|
255
255
|
// [!region UserOperationResponse]
|
|
256
256
|
export interface UserOperationResponse<
|
|
257
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
257
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
258
258
|
> {
|
|
259
259
|
/* the User Operation */
|
|
260
260
|
userOperation: UserOperationRequest<TEntryPointVersion>;
|
|
@@ -364,11 +364,11 @@ export interface UserOperationStruct_v7 {
|
|
|
364
364
|
|
|
365
365
|
// [!region UserOperationStruct]
|
|
366
366
|
export type UserOperationStruct<
|
|
367
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
367
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
368
368
|
> = (TEntryPointVersion extends "0.6.0"
|
|
369
369
|
? UserOperationStruct_v6
|
|
370
370
|
: TEntryPointVersion extends "0.7.0"
|
|
371
|
-
|
|
372
|
-
|
|
371
|
+
? UserOperationStruct_v7
|
|
372
|
+
: never) &
|
|
373
373
|
Eip7702ExtendedFields;
|
|
374
374
|
// [!endregion UserOperationStruct]
|
package/src/utils/bigint.ts
CHANGED
|
@@ -41,14 +41,14 @@ export const bigIntMin = (...args: bigint[]): bigint => {
|
|
|
41
41
|
export const bigIntClamp = (
|
|
42
42
|
value: BigNumberish,
|
|
43
43
|
lower: BigNumberish | null | undefined,
|
|
44
|
-
upper: BigNumberish | null | undefined
|
|
44
|
+
upper: BigNumberish | null | undefined,
|
|
45
45
|
): bigint => {
|
|
46
46
|
lower = lower != null ? BigInt(lower) : null;
|
|
47
47
|
upper = upper != null ? BigInt(upper) : null;
|
|
48
48
|
|
|
49
49
|
if (upper != null && lower != null && upper < lower) {
|
|
50
50
|
throw new Error(
|
|
51
|
-
`invalid range: upper bound ${upper} is less than lower bound ${lower}
|
|
51
|
+
`invalid range: upper bound ${upper} is less than lower bound ${lower}`,
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -79,11 +79,11 @@ export enum RoundingMode {
|
|
|
79
79
|
export const bigIntMultiply = (
|
|
80
80
|
base: BigNumberish,
|
|
81
81
|
multiplier: Multiplier["multiplier"],
|
|
82
|
-
roundingMode: RoundingMode = RoundingMode.ROUND_UP
|
|
82
|
+
roundingMode: RoundingMode = RoundingMode.ROUND_UP,
|
|
83
83
|
) => {
|
|
84
84
|
if (!isMultiplier({ multiplier })) {
|
|
85
85
|
throw new Error(
|
|
86
|
-
"bigIntMultiply requires a multiplier validated number as the second argument"
|
|
86
|
+
"bigIntMultiply requires a multiplier validated number as the second argument",
|
|
87
87
|
);
|
|
88
88
|
}
|
|
89
89
|
|
package/src/utils/defaults.ts
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -46,7 +46,7 @@ export async function resolveProperties<T>(object: Deferrable<T>): Promise<T> {
|
|
|
46
46
|
results.reduce((accum, curr) => {
|
|
47
47
|
accum[curr.key as keyof T] = curr.value;
|
|
48
48
|
return accum;
|
|
49
|
-
}, {} as T)
|
|
49
|
+
}, {} as T),
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -75,7 +75,7 @@ export function deepHexlify(obj: any): any {
|
|
|
75
75
|
...set,
|
|
76
76
|
[key]: deepHexlify(obj[key]),
|
|
77
77
|
}),
|
|
78
|
-
{}
|
|
78
|
+
{},
|
|
79
79
|
);
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -151,7 +151,7 @@ export const allEqual = (...params: any[]): boolean => {
|
|
|
151
151
|
*/
|
|
152
152
|
export const conditionalReturn = <T>(
|
|
153
153
|
condition: Promise<boolean>,
|
|
154
|
-
value: () => Promise<T
|
|
154
|
+
value: () => Promise<T>,
|
|
155
155
|
): Promise<T | undefined> => condition.then((t) => (t ? value() : undefined));
|
|
156
156
|
|
|
157
157
|
/**
|
|
@@ -177,16 +177,19 @@ export const conditionalReturn = <T>(
|
|
|
177
177
|
export const toRecord = <
|
|
178
178
|
T extends { [K in RecordableKeys<T>]: string | number | symbol },
|
|
179
179
|
K extends RecordableKeys<T>,
|
|
180
|
-
V
|
|
180
|
+
V,
|
|
181
181
|
>(
|
|
182
182
|
array: T[],
|
|
183
183
|
selector: K,
|
|
184
|
-
fn: (item: T) => V
|
|
184
|
+
fn: (item: T) => V,
|
|
185
185
|
): Record<T[K], V> =>
|
|
186
|
-
array.reduce(
|
|
187
|
-
acc
|
|
188
|
-
|
|
189
|
-
|
|
186
|
+
array.reduce(
|
|
187
|
+
(acc, item) => {
|
|
188
|
+
acc[item[selector]] = fn(item);
|
|
189
|
+
return acc;
|
|
190
|
+
},
|
|
191
|
+
{} as Record<T[K], V>,
|
|
192
|
+
);
|
|
190
193
|
|
|
191
194
|
export * from "./bigint.js";
|
|
192
195
|
export * from "./bytes.js";
|
package/src/utils/schema.ts
CHANGED
|
@@ -7,7 +7,7 @@ export const ChainSchema = z.custom<Chain>(
|
|
|
7
7
|
chain != null &&
|
|
8
8
|
typeof chain === "object" &&
|
|
9
9
|
"id" in chain &&
|
|
10
|
-
typeof chain.id === "number"
|
|
10
|
+
typeof chain.id === "number",
|
|
11
11
|
);
|
|
12
12
|
|
|
13
13
|
export const HexSchema = z.custom<`0x${string}` | "0x">((val) => {
|
|
@@ -37,7 +37,7 @@ export const MultiplierSchema = z
|
|
|
37
37
|
(n) => {
|
|
38
38
|
return (n.toString().split(".")[1]?.length ?? 0) <= 4;
|
|
39
39
|
},
|
|
40
|
-
{ message: "Max precision is 4 decimal places" }
|
|
40
|
+
{ message: "Max precision is 4 decimal places" },
|
|
41
41
|
),
|
|
42
42
|
})
|
|
43
43
|
.strict();
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
type SerializeStateMappingParameters = StateMapping | undefined;
|
|
19
19
|
|
|
20
20
|
function serializeStateMapping(
|
|
21
|
-
stateMapping: SerializeStateMappingParameters
|
|
21
|
+
stateMapping: SerializeStateMappingParameters,
|
|
22
22
|
): RpcStateMapping | undefined {
|
|
23
23
|
if (!stateMapping || stateMapping.length === 0) return undefined;
|
|
24
24
|
return stateMapping.reduce((acc, { slot, value }) => {
|
|
@@ -33,7 +33,7 @@ function validateBytes32HexLength(value: Address): void {
|
|
|
33
33
|
if (value.length !== 66) {
|
|
34
34
|
// This is the error message from Viem's non-exported InvalidBytesLengthError.
|
|
35
35
|
throw new Error(
|
|
36
|
-
`Hex is expected to be 66 hex long, but is ${value.length} hex long
|
|
36
|
+
`Hex is expected to be 66 hex long, but is ${value.length} hex long.`,
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -44,7 +44,7 @@ type SerializeAccountStateOverrideParameters = Omit<
|
|
|
44
44
|
>;
|
|
45
45
|
|
|
46
46
|
function serializeAccountStateOverride(
|
|
47
|
-
parameters: SerializeAccountStateOverrideParameters
|
|
47
|
+
parameters: SerializeAccountStateOverrideParameters,
|
|
48
48
|
): RpcAccountStateOverride {
|
|
49
49
|
const { balance, nonce, state, stateDiff, code } = parameters;
|
|
50
50
|
const rpcAccountStateOverride: RpcAccountStateOverride = {};
|
|
@@ -65,7 +65,7 @@ type SerializeStateOverrideParameters = StateOverride | undefined;
|
|
|
65
65
|
|
|
66
66
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
67
67
|
export function serializeStateOverride(
|
|
68
|
-
parameters?: SerializeStateOverrideParameters
|
|
68
|
+
parameters?: SerializeStateOverrideParameters,
|
|
69
69
|
): RpcStateOverride | undefined {
|
|
70
70
|
if (!parameters) return undefined;
|
|
71
71
|
const rpcStateOverride: RpcStateOverride = {};
|