@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
|
@@ -18,7 +18,6 @@ import { ChainNotFoundError } from "../errors/client.js";
|
|
|
18
18
|
import { middlewareActions } from "../middleware/actions.js";
|
|
19
19
|
import type { ClientMiddleware } from "../middleware/types.js";
|
|
20
20
|
import type { Prettify } from "../utils/index.js";
|
|
21
|
-
import { ADD_BREADCRUMB } from "./addBreadcrumb.js";
|
|
22
21
|
import { createBundlerClient, type BundlerClient } from "./bundlerClient.js";
|
|
23
22
|
import {
|
|
24
23
|
type BundlerActions,
|
|
@@ -30,6 +29,7 @@ import {
|
|
|
30
29
|
} from "./decorators/smartAccountClient.js";
|
|
31
30
|
import { SmartAccountClientOptsSchema } from "./schema.js";
|
|
32
31
|
import type { ClientMiddlewareConfig } from "./types.js";
|
|
32
|
+
import { ADD_BREADCRUMB } from "./addBreadcrumb.js";
|
|
33
33
|
|
|
34
34
|
type SmartAccountClientOpts = z.output<typeof SmartAccountClientOptsSchema>;
|
|
35
35
|
|
|
@@ -41,7 +41,7 @@ export type SmartAccountClientConfig<
|
|
|
41
41
|
| undefined,
|
|
42
42
|
context extends UserOperationContext | undefined =
|
|
43
43
|
| UserOperationContext
|
|
44
|
-
| undefined
|
|
44
|
+
| undefined,
|
|
45
45
|
> = Prettify<
|
|
46
46
|
Pick<
|
|
47
47
|
ClientConfig<transport, chain, account>,
|
|
@@ -69,7 +69,7 @@ export type SmartAccountClientConfig<
|
|
|
69
69
|
|
|
70
70
|
export type SmartAccountClientRpcSchema = [
|
|
71
71
|
...BundlerRpcSchema,
|
|
72
|
-
...PublicRpcSchema
|
|
72
|
+
...PublicRpcSchema,
|
|
73
73
|
];
|
|
74
74
|
|
|
75
75
|
// [!region SmartAccountClientActions]
|
|
@@ -80,7 +80,7 @@ export type SmartAccountClientActions<
|
|
|
80
80
|
| undefined,
|
|
81
81
|
context extends UserOperationContext | undefined =
|
|
82
82
|
| UserOperationContext
|
|
83
|
-
| undefined
|
|
83
|
+
| undefined,
|
|
84
84
|
> = BaseSmartAccountClientActions<chain, account, context> &
|
|
85
85
|
BundlerActions &
|
|
86
86
|
PublicActions;
|
|
@@ -97,7 +97,7 @@ export type SmartAccountClient<
|
|
|
97
97
|
rpcSchema extends RpcSchema = SmartAccountClientRpcSchema,
|
|
98
98
|
context extends UserOperationContext | undefined =
|
|
99
99
|
| UserOperationContext
|
|
100
|
-
| undefined
|
|
100
|
+
| undefined,
|
|
101
101
|
> = Prettify<
|
|
102
102
|
Client<
|
|
103
103
|
transport,
|
|
@@ -117,7 +117,7 @@ export type BaseSmartAccountClient<
|
|
|
117
117
|
| undefined,
|
|
118
118
|
context extends UserOperationContext | undefined =
|
|
119
119
|
| UserOperationContext
|
|
120
|
-
| undefined
|
|
120
|
+
| undefined,
|
|
121
121
|
> = Prettify<
|
|
122
122
|
Client<
|
|
123
123
|
transport,
|
|
@@ -140,9 +140,9 @@ export function createSmartAccountClient<
|
|
|
140
140
|
| undefined,
|
|
141
141
|
TContext extends UserOperationContext | undefined =
|
|
142
142
|
| UserOperationContext
|
|
143
|
-
| undefined
|
|
143
|
+
| undefined,
|
|
144
144
|
>(
|
|
145
|
-
config: SmartAccountClientConfig<TTransport, TChain, TAccount, TContext
|
|
145
|
+
config: SmartAccountClientConfig<TTransport, TChain, TAccount, TContext>,
|
|
146
146
|
): SmartAccountClient<TTransport, TChain, TAccount>;
|
|
147
147
|
|
|
148
148
|
/**
|
|
@@ -166,7 +166,7 @@ export function createSmartAccountClient<
|
|
|
166
166
|
* @returns {SmartAccountClient} A smart account client capable of handling transactions, message signing, and other operations on a smart account
|
|
167
167
|
*/
|
|
168
168
|
export function createSmartAccountClient(
|
|
169
|
-
config: SmartAccountClientConfig
|
|
169
|
+
config: SmartAccountClientConfig,
|
|
170
170
|
): SmartAccountClient {
|
|
171
171
|
const {
|
|
172
172
|
key = "account",
|
|
@@ -189,106 +189,100 @@ export function createSmartAccountClient(
|
|
|
189
189
|
transport: (opts) => {
|
|
190
190
|
const rpcTransport = transport(opts);
|
|
191
191
|
|
|
192
|
-
return custom(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
192
|
+
return custom({
|
|
193
|
+
name: "SmartAccountClientTransport",
|
|
194
|
+
async request({ method, params }) {
|
|
195
|
+
switch (method) {
|
|
196
|
+
case "eth_accounts": {
|
|
197
|
+
if (!client.account) {
|
|
198
|
+
throw new AccountNotFoundError();
|
|
199
|
+
}
|
|
201
200
|
|
|
202
|
-
|
|
201
|
+
return [client.account.address];
|
|
202
|
+
}
|
|
203
|
+
case "eth_sendTransaction":
|
|
204
|
+
if (!client.account) {
|
|
205
|
+
throw new AccountNotFoundError();
|
|
203
206
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
207
|
+
if (!client.chain) {
|
|
208
|
+
throw new ChainNotFoundError();
|
|
209
|
+
}
|
|
210
|
+
const [tx] = params as [FormattedTransactionRequest];
|
|
211
|
+
return client.sendTransaction({
|
|
212
|
+
...tx,
|
|
213
|
+
account: client.account,
|
|
214
|
+
chain: client.chain,
|
|
215
|
+
});
|
|
216
|
+
case "eth_sign":
|
|
217
|
+
if (!client.account) {
|
|
218
|
+
throw new AccountNotFoundError();
|
|
219
|
+
}
|
|
220
|
+
const [address, data] = params!;
|
|
221
|
+
if (
|
|
222
|
+
address?.toLowerCase() !== client.account.address.toLowerCase()
|
|
223
|
+
) {
|
|
224
|
+
throw new Error(
|
|
225
|
+
"cannot sign for address that is not the current account",
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
return client.signMessage({
|
|
229
|
+
message: data,
|
|
230
|
+
account: client.account,
|
|
231
|
+
});
|
|
232
|
+
case "personal_sign": {
|
|
233
|
+
if (!client.account) {
|
|
234
|
+
throw new AccountNotFoundError();
|
|
235
|
+
}
|
|
236
|
+
const [data, address] = params!;
|
|
237
|
+
if (
|
|
238
|
+
address?.toLowerCase() !== client.account.address.toLowerCase()
|
|
239
|
+
) {
|
|
240
|
+
throw new Error(
|
|
241
|
+
"cannot sign for address that is not the current account",
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
return client.signMessage({
|
|
245
|
+
message: data,
|
|
246
|
+
account: client.account,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
case "eth_signTypedData_v4": {
|
|
250
|
+
if (!client.account) {
|
|
251
|
+
throw new AccountNotFoundError();
|
|
252
|
+
}
|
|
253
|
+
const [address, dataParams] = params!;
|
|
254
|
+
if (
|
|
255
|
+
address?.toLowerCase() !== client.account.address.toLowerCase()
|
|
256
|
+
) {
|
|
257
|
+
throw new Error(
|
|
258
|
+
"cannot sign for address that is not the current account",
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
try {
|
|
262
|
+
return client.signTypedData({
|
|
249
263
|
account: client.account,
|
|
264
|
+
typedData:
|
|
265
|
+
typeof dataParams === "string"
|
|
266
|
+
? JSON.parse(dataParams)
|
|
267
|
+
: dataParams,
|
|
250
268
|
});
|
|
269
|
+
} catch {
|
|
270
|
+
throw new Error("invalid JSON data params");
|
|
251
271
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
const [address, dataParams] = params!;
|
|
257
|
-
if (
|
|
258
|
-
address?.toLowerCase() !==
|
|
259
|
-
client.account.address.toLowerCase()
|
|
260
|
-
) {
|
|
261
|
-
throw new Error(
|
|
262
|
-
"cannot sign for address that is not the current account"
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
try {
|
|
266
|
-
return client.signTypedData({
|
|
267
|
-
account: client.account,
|
|
268
|
-
typedData:
|
|
269
|
-
typeof dataParams === "string"
|
|
270
|
-
? JSON.parse(dataParams)
|
|
271
|
-
: dataParams,
|
|
272
|
-
});
|
|
273
|
-
} catch {
|
|
274
|
-
throw new Error("invalid JSON data params");
|
|
275
|
-
}
|
|
272
|
+
}
|
|
273
|
+
case "eth_chainId":
|
|
274
|
+
if (!opts.chain) {
|
|
275
|
+
throw new ChainNotFoundError();
|
|
276
276
|
}
|
|
277
|
-
case "eth_chainId":
|
|
278
|
-
if (!opts.chain) {
|
|
279
|
-
throw new ChainNotFoundError();
|
|
280
|
-
}
|
|
281
277
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
},
|
|
278
|
+
return opts.chain.id;
|
|
279
|
+
default:
|
|
280
|
+
// TODO: there's probably a number of methods we just don't support, will need to test most of them out
|
|
281
|
+
// first let's get something working though
|
|
282
|
+
return rpcTransport.request({ method, params });
|
|
283
|
+
}
|
|
289
284
|
},
|
|
290
|
-
|
|
291
|
-
)(opts);
|
|
285
|
+
})(opts);
|
|
292
286
|
},
|
|
293
287
|
})
|
|
294
288
|
.extend(() => {
|
|
@@ -323,12 +317,12 @@ export function createSmartAccountClientFromExisting<
|
|
|
323
317
|
TRpcSchema extends SmartAccountClientRpcSchema = SmartAccountClientRpcSchema,
|
|
324
318
|
TContext extends UserOperationContext | undefined =
|
|
325
319
|
| UserOperationContext
|
|
326
|
-
| undefined
|
|
320
|
+
| undefined,
|
|
327
321
|
>(
|
|
328
322
|
config: Omit<
|
|
329
323
|
SmartAccountClientConfig<Transport, TChain, TAccount, TContext>,
|
|
330
324
|
"transport" | "chain"
|
|
331
|
-
> & { client: TClient }
|
|
325
|
+
> & { client: TClient },
|
|
332
326
|
): SmartAccountClient<
|
|
333
327
|
CustomTransport,
|
|
334
328
|
TChain,
|
|
@@ -362,7 +356,7 @@ export function createSmartAccountClientFromExisting<
|
|
|
362
356
|
export function createSmartAccountClientFromExisting(
|
|
363
357
|
config: Omit<SmartAccountClientConfig, "transport" | "chain"> & {
|
|
364
358
|
client: BundlerClient;
|
|
365
|
-
}
|
|
359
|
+
},
|
|
366
360
|
): SmartAccountClient {
|
|
367
361
|
return createSmartAccountClient({
|
|
368
362
|
...config,
|
package/src/client/types.ts
CHANGED
|
@@ -15,7 +15,7 @@ export type ConnectionConfig = z.input<typeof ConnectionConfigSchema>;
|
|
|
15
15
|
|
|
16
16
|
// [!region SendUserOperationResult]
|
|
17
17
|
export type SendUserOperationResult<
|
|
18
|
-
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
18
|
+
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
19
19
|
> = {
|
|
20
20
|
hash: Hash;
|
|
21
21
|
request: UserOperationRequest<TEntryPointVersion>;
|
|
@@ -33,6 +33,6 @@ export type UpgradeToData = {
|
|
|
33
33
|
export type ClientMiddlewareConfig<
|
|
34
34
|
TContext extends UserOperationContext | undefined =
|
|
35
35
|
| UserOperationContext
|
|
36
|
-
| undefined
|
|
36
|
+
| undefined,
|
|
37
37
|
> = Partial<ClientMiddleware<TContext>>;
|
|
38
38
|
// [!endregion ClientMiddlewareConfig]
|
package/src/ens/utils.ts
CHANGED
package/src/entrypoint/0.6.ts
CHANGED
|
@@ -40,7 +40,7 @@ const packUserOperation = (request: UserOperationRequest<"0.6.0">): Hex => {
|
|
|
40
40
|
hexToBigInt(request.maxFeePerGas),
|
|
41
41
|
hexToBigInt(request.maxPriorityFeePerGas),
|
|
42
42
|
hashedPaymasterAndData,
|
|
43
|
-
]
|
|
43
|
+
],
|
|
44
44
|
);
|
|
45
45
|
};
|
|
46
46
|
|
|
@@ -56,7 +56,7 @@ export default {
|
|
|
56
56
|
getUserOperationHash: (
|
|
57
57
|
request: UserOperationRequest<"0.6.0">,
|
|
58
58
|
entryPointAddress: Address,
|
|
59
|
-
chainId: number
|
|
59
|
+
chainId: number,
|
|
60
60
|
): Hash => {
|
|
61
61
|
const encoded = encodeAbiParameters(
|
|
62
62
|
[{ type: "bytes32" }, { type: "address" }, { type: "uint256" }],
|
|
@@ -64,7 +64,7 @@ export default {
|
|
|
64
64
|
keccak256(packUserOperation(request)),
|
|
65
65
|
entryPointAddress,
|
|
66
66
|
BigInt(chainId),
|
|
67
|
-
]
|
|
67
|
+
],
|
|
68
68
|
);
|
|
69
69
|
|
|
70
70
|
return keccak256(encoded);
|
package/src/entrypoint/0.7.ts
CHANGED
|
@@ -62,7 +62,7 @@ const packUserOperation = (request: UserOperationRequest<"0.7.0">): Hex => {
|
|
|
62
62
|
hexToBigInt(request.preVerificationGas),
|
|
63
63
|
gasFees,
|
|
64
64
|
keccak256(paymasterAndData),
|
|
65
|
-
]
|
|
65
|
+
],
|
|
66
66
|
);
|
|
67
67
|
};
|
|
68
68
|
|
|
@@ -78,7 +78,7 @@ export default {
|
|
|
78
78
|
getUserOperationHash: (
|
|
79
79
|
request: UserOperationRequest<"0.7.0">,
|
|
80
80
|
entryPointAddress: Address,
|
|
81
|
-
chainId: number
|
|
81
|
+
chainId: number,
|
|
82
82
|
): Hash => {
|
|
83
83
|
const encoded = encodeAbiParameters(
|
|
84
84
|
[{ type: "bytes32" }, { type: "address" }, { type: "uint256" }],
|
|
@@ -86,7 +86,7 @@ export default {
|
|
|
86
86
|
keccak256(packUserOperation(request)),
|
|
87
87
|
entryPointAddress,
|
|
88
88
|
BigInt(chainId),
|
|
89
|
-
]
|
|
89
|
+
],
|
|
90
90
|
);
|
|
91
91
|
|
|
92
92
|
return keccak256(encoded);
|
|
@@ -98,7 +98,7 @@ export default {
|
|
|
98
98
|
export function packAccountGasLimits(
|
|
99
99
|
data:
|
|
100
100
|
| Pick<UserOperationRequest_v7, "verificationGasLimit" | "callGasLimit">
|
|
101
|
-
| Pick<UserOperationRequest_v7, "maxPriorityFeePerGas" | "maxFeePerGas"
|
|
101
|
+
| Pick<UserOperationRequest_v7, "maxPriorityFeePerGas" | "maxFeePerGas">,
|
|
102
102
|
): Hex {
|
|
103
103
|
return concat(Object.values(data).map((v) => pad(v, { size: 16 })));
|
|
104
104
|
}
|
package/src/entrypoint/index.ts
CHANGED
|
@@ -32,30 +32,31 @@ export const entryPointRegistry: EntryPointRegistry = {
|
|
|
32
32
|
* @returns {boolean} true if the value is a valid key of EntryPointRegistry, false otherwise
|
|
33
33
|
*/
|
|
34
34
|
export const isEntryPointVersion = (
|
|
35
|
-
value: any
|
|
35
|
+
value: any,
|
|
36
36
|
): value is keyof EntryPointRegistry => {
|
|
37
37
|
return Object.keys(entryPointRegistry).includes(value);
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
export function getEntryPoint<
|
|
41
41
|
TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion,
|
|
42
|
-
TChain extends Chain = Chain
|
|
42
|
+
TChain extends Chain = Chain,
|
|
43
43
|
>(
|
|
44
44
|
chain: TChain,
|
|
45
|
-
options: GetEntryPointOptions<TEntryPointVersion
|
|
45
|
+
options: GetEntryPointOptions<TEntryPointVersion>,
|
|
46
46
|
): EntryPointDefRegistry<TChain>[TEntryPointVersion];
|
|
47
47
|
|
|
48
48
|
export function getEntryPoint<
|
|
49
|
-
TEntryPointVersion extends
|
|
50
|
-
|
|
49
|
+
TEntryPointVersion extends
|
|
50
|
+
DefaultEntryPointVersion = DefaultEntryPointVersion,
|
|
51
|
+
TChain extends Chain = Chain,
|
|
51
52
|
>(
|
|
52
53
|
chain: TChain,
|
|
53
|
-
options?: GetEntryPointOptions<TEntryPointVersion
|
|
54
|
+
options?: GetEntryPointOptions<TEntryPointVersion>,
|
|
54
55
|
): EntryPointDefRegistry<TChain>[TEntryPointVersion];
|
|
55
56
|
|
|
56
57
|
export function getEntryPoint<TChain extends Chain = Chain>(
|
|
57
58
|
chain: TChain,
|
|
58
|
-
options?: GetEntryPointOptions<DefaultEntryPointVersion
|
|
59
|
+
options?: GetEntryPointOptions<DefaultEntryPointVersion>,
|
|
59
60
|
): EntryPointDefRegistry<TChain>[DefaultEntryPointVersion];
|
|
60
61
|
|
|
61
62
|
/**
|
|
@@ -76,10 +77,10 @@ export function getEntryPoint<TChain extends Chain = Chain>(
|
|
|
76
77
|
*/
|
|
77
78
|
export function getEntryPoint<
|
|
78
79
|
TEntryPointVersion extends EntryPointVersion,
|
|
79
|
-
TChain extends Chain = Chain
|
|
80
|
+
TChain extends Chain = Chain,
|
|
80
81
|
>(
|
|
81
82
|
chain: TChain,
|
|
82
|
-
options: GetEntryPointOptions<TEntryPointVersion
|
|
83
|
+
options: GetEntryPointOptions<TEntryPointVersion>,
|
|
83
84
|
): EntryPointDefRegistry<TChain>[EntryPointVersion] {
|
|
84
85
|
const { version = defaultEntryPointVersion, addressOverride } = options ?? {
|
|
85
86
|
version: defaultEntryPointVersion,
|
package/src/entrypoint/types.ts
CHANGED
|
@@ -23,7 +23,7 @@ export type DefaultEntryPointVersion = OneOf<"0.6.0", EntryPointVersion>;
|
|
|
23
23
|
export type SupportedEntryPoint<
|
|
24
24
|
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
25
25
|
TChain extends Chain = Chain,
|
|
26
|
-
TAbi extends Abi | readonly unknown[] = Abi
|
|
26
|
+
TAbi extends Abi | readonly unknown[] = Abi,
|
|
27
27
|
> = {
|
|
28
28
|
version: TEntryPointVersion;
|
|
29
29
|
address: Record<TChain["id"] | "default", Address>;
|
|
@@ -40,7 +40,7 @@ export type SupportedEntryPoint<
|
|
|
40
40
|
getUserOperationHash: (
|
|
41
41
|
request: UserOperationRequest<TEntryPointVersion>,
|
|
42
42
|
entryPointAddress: Address,
|
|
43
|
-
chainId: number
|
|
43
|
+
chainId: number,
|
|
44
44
|
) => Hash;
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -53,7 +53,7 @@ export type SupportedEntryPoint<
|
|
|
53
53
|
* @returns the hash of the UserOperation
|
|
54
54
|
*/
|
|
55
55
|
packUserOperation: (
|
|
56
|
-
userOperation: UserOperationRequest<TEntryPointVersion
|
|
56
|
+
userOperation: UserOperationRequest<TEntryPointVersion>,
|
|
57
57
|
) => Hex;
|
|
58
58
|
};
|
|
59
59
|
|
|
@@ -69,17 +69,17 @@ export interface EntryPointRegistry<TChain extends Chain = Chain>
|
|
|
69
69
|
export type EntryPointDef<
|
|
70
70
|
TEntryPointVersion extends EntryPointVersion = EntryPointVersion,
|
|
71
71
|
TChain extends Chain = Chain,
|
|
72
|
-
TAbi extends Abi | readonly unknown[] = Abi
|
|
72
|
+
TAbi extends Abi | readonly unknown[] = Abi,
|
|
73
73
|
> = {
|
|
74
74
|
version: TEntryPointVersion;
|
|
75
75
|
address: Address;
|
|
76
76
|
chain: TChain;
|
|
77
77
|
abi: GetContractParameters<Transport, TChain, Account, TAbi>["abi"];
|
|
78
78
|
getUserOperationHash: (
|
|
79
|
-
request: UserOperationRequest<TEntryPointVersion
|
|
79
|
+
request: UserOperationRequest<TEntryPointVersion>,
|
|
80
80
|
) => Hex;
|
|
81
81
|
packUserOperation: (
|
|
82
|
-
userOperation: UserOperationRequest<TEntryPointVersion
|
|
82
|
+
userOperation: UserOperationRequest<TEntryPointVersion>,
|
|
83
83
|
) => Hex;
|
|
84
84
|
};
|
|
85
85
|
// [!endregion EntryPointDef]
|
|
@@ -93,28 +93,30 @@ export interface EntryPointDefRegistry<TChain extends Chain = Chain>
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
export type GetEntryPointOptions<
|
|
96
|
-
TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion
|
|
97
|
-
> =
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
96
|
+
TEntryPointVersion extends EntryPointVersion = DefaultEntryPointVersion,
|
|
97
|
+
> =
|
|
98
|
+
EQ<TEntryPointVersion, DefaultEntryPointVersion> extends true
|
|
99
|
+
?
|
|
100
|
+
| {
|
|
101
|
+
addressOverride?: Address;
|
|
102
|
+
version?: OneOf<TEntryPointVersion, EntryPointVersion>;
|
|
103
|
+
}
|
|
104
|
+
| undefined
|
|
105
|
+
: {
|
|
106
|
+
addressOverride?: Address;
|
|
107
|
+
version: OneOf<TEntryPointVersion, EntryPointVersion>;
|
|
108
|
+
};
|
|
108
109
|
|
|
109
110
|
export type EntryPointParameter<
|
|
110
111
|
TEntryPointVersion extends EntryPointVersion,
|
|
111
|
-
TChain extends Chain = Chain
|
|
112
|
-
> =
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
112
|
+
TChain extends Chain = Chain,
|
|
113
|
+
> =
|
|
114
|
+
EQ<TEntryPointVersion, DefaultEntryPointVersion> extends true
|
|
115
|
+
? {
|
|
116
|
+
entryPoint?: EntryPointDef<TEntryPointVersion, TChain>;
|
|
117
|
+
}
|
|
118
|
+
: {
|
|
119
|
+
entryPoint: IsOneOf<TEntryPointVersion, EntryPointVersion> extends true
|
|
120
|
+
? EntryPointDef<TEntryPointVersion, TChain>
|
|
121
|
+
: never;
|
|
122
|
+
};
|
package/src/errors/account.ts
CHANGED
|
@@ -36,7 +36,7 @@ export class DefaultFactoryNotDefinedError extends BaseError {
|
|
|
36
36
|
[
|
|
37
37
|
`No default factory for ${accountType} found on chain ${chain.name} for entrypoint version ${version}`,
|
|
38
38
|
"Supply an override via the `factoryAddress` parameter when creating an account",
|
|
39
|
-
].join("\n")
|
|
39
|
+
].join("\n"),
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/errors/client.ts
CHANGED
|
@@ -19,7 +19,7 @@ export class IncompatibleClientError extends BaseError {
|
|
|
19
19
|
[
|
|
20
20
|
`Client of type (${client.type}) is not a ${expectedClient}.`,
|
|
21
21
|
`Create one with \`createSmartAccountClient\` first before using \`${method}\``,
|
|
22
|
-
].join("\n")
|
|
22
|
+
].join("\n"),
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -67,7 +67,7 @@ export class InvalidEntityIdError extends BaseError {
|
|
|
67
67
|
*/
|
|
68
68
|
constructor(entityId: number) {
|
|
69
69
|
super(
|
|
70
|
-
`Entity ID used is ${entityId}, but must be less than or equal to uint32.max
|
|
70
|
+
`Entity ID used is ${entityId}, but must be less than or equal to uint32.max`,
|
|
71
71
|
);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -85,7 +85,7 @@ export class InvalidNonceKeyError extends BaseError {
|
|
|
85
85
|
*/
|
|
86
86
|
constructor(nonceKey: bigint) {
|
|
87
87
|
super(
|
|
88
|
-
`Nonce key is ${nonceKey} but has to be less than or equal to 2**152
|
|
88
|
+
`Nonce key is ${nonceKey} but has to be less than or equal to 2**152`,
|
|
89
89
|
);
|
|
90
90
|
}
|
|
91
91
|
}
|
package/src/errors/entrypoint.ts
CHANGED
|
@@ -18,7 +18,7 @@ export class EntryPointNotFoundError extends BaseError {
|
|
|
18
18
|
[
|
|
19
19
|
`No default entry point v${entryPointVersion} exists for ${chain.name}.`,
|
|
20
20
|
`Supply an override.`,
|
|
21
|
-
].join("\n")
|
|
21
|
+
].join("\n"),
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -37,7 +37,7 @@ export class InvalidEntryPointError extends BaseError {
|
|
|
37
37
|
*/
|
|
38
38
|
constructor(chain: Chain, entryPointVersion: any) {
|
|
39
39
|
super(
|
|
40
|
-
`Invalid entry point: unexpected version ${entryPointVersion} for ${chain.name}
|
|
40
|
+
`Invalid entry point: unexpected version ${entryPointVersion} for ${chain.name}.`,
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
43
|
}
|
package/src/errors/signer.ts
CHANGED
|
@@ -30,8 +30,8 @@ export class InvalidUserOperationError extends BaseError {
|
|
|
30
30
|
value: value.toString(),
|
|
31
31
|
}
|
|
32
32
|
: value,
|
|
33
|
-
2
|
|
34
|
-
)}
|
|
33
|
+
2,
|
|
34
|
+
)}`,
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -47,7 +47,10 @@ export class WaitForUserOperationError extends BaseError {
|
|
|
47
47
|
* @param {UserOperationRequest} request the user operation request that failed
|
|
48
48
|
* @param {Error} error the underlying error that caused the failure
|
|
49
49
|
*/
|
|
50
|
-
constructor(
|
|
50
|
+
constructor(
|
|
51
|
+
public request: UserOperationRequest,
|
|
52
|
+
error: Error,
|
|
53
|
+
) {
|
|
51
54
|
super(`Failed to find User Operation: ${error.message}`);
|
|
52
55
|
}
|
|
53
56
|
}
|
|
@@ -30,7 +30,7 @@ export type MiddlewareClient<
|
|
|
30
30
|
TChain extends Chain | undefined = Chain | undefined,
|
|
31
31
|
TAccount extends SmartContractAccount | undefined =
|
|
32
32
|
| SmartContractAccount
|
|
33
|
-
| undefined
|
|
33
|
+
| undefined,
|
|
34
34
|
> = Client<
|
|
35
35
|
TTransport,
|
|
36
36
|
TChain,
|
|
@@ -53,9 +53,9 @@ export const middlewareActions =
|
|
|
53
53
|
TChain extends Chain | undefined = Chain | undefined,
|
|
54
54
|
TAccount extends SmartContractAccount | undefined =
|
|
55
55
|
| SmartContractAccount
|
|
56
|
-
| undefined
|
|
56
|
+
| undefined,
|
|
57
57
|
>(
|
|
58
|
-
client: MiddlewareClient<TTransport, TChain, TAccount
|
|
58
|
+
client: MiddlewareClient<TTransport, TChain, TAccount>,
|
|
59
59
|
): { middleware: ClientMiddleware } => ({
|
|
60
60
|
middleware: {
|
|
61
61
|
customMiddleware: overrides.customMiddleware ?? noopMiddleware,
|