viem 2.39.3 → 2.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/_cjs/accounts/mnemonicToAccount.js +3 -3
- package/_cjs/accounts/mnemonicToAccount.js.map +1 -1
- package/_cjs/actions/index.js +5 -3
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/public/fillTransaction.js +118 -0
- package/_cjs/actions/public/fillTransaction.js.map +1 -0
- package/_cjs/actions/wallet/prepareTransactionRequest.js +45 -11
- package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_cjs/chains/definitions/monad.js +15 -3
- package/_cjs/chains/definitions/monad.js.map +1 -1
- package/_cjs/clients/decorators/public.js +2 -0
- package/_cjs/clients/decorators/public.js.map +1 -1
- package/_cjs/clients/decorators/wallet.js +2 -0
- package/_cjs/clients/decorators/wallet.js.map +1 -1
- package/_cjs/errors/request.js +28 -0
- package/_cjs/errors/request.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/utils/transaction/assertRequest.js +1 -6
- package/_cjs/utils/transaction/assertRequest.js.map +1 -1
- package/_esm/accounts/mnemonicToAccount.js +3 -3
- package/_esm/accounts/mnemonicToAccount.js.map +1 -1
- package/_esm/actions/index.js +1 -0
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/public/fillTransaction.js +145 -0
- package/_esm/actions/public/fillTransaction.js.map +1 -0
- package/_esm/actions/wallet/prepareTransactionRequest.js +49 -11
- package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_esm/chains/definitions/monad.js +15 -3
- package/_esm/chains/definitions/monad.js.map +1 -1
- package/_esm/clients/decorators/public.js +2 -0
- package/_esm/clients/decorators/public.js.map +1 -1
- package/_esm/clients/decorators/wallet.js +2 -0
- package/_esm/clients/decorators/wallet.js.map +1 -1
- package/_esm/errors/request.js +28 -0
- package/_esm/errors/request.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/utils/transaction/assertRequest.js +1 -6
- package/_esm/utils/transaction/assertRequest.js.map +1 -1
- package/_types/accounts/mnemonicToAccount.d.ts +4 -2
- package/_types/accounts/mnemonicToAccount.d.ts.map +1 -1
- package/_types/actions/index.d.ts +1 -0
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/public/fillTransaction.d.ts +49 -0
- package/_types/actions/public/fillTransaction.d.ts.map +1 -0
- package/_types/actions/wallet/prepareTransactionRequest.d.ts +1 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
- package/_types/chains/definitions/monad.d.ts +15 -12
- package/_types/chains/definitions/monad.d.ts.map +1 -1
- package/_types/clients/decorators/public.d.ts +25 -0
- package/_types/clients/decorators/public.d.ts.map +1 -1
- package/_types/clients/decorators/wallet.d.ts +25 -0
- package/_types/clients/decorators/wallet.d.ts.map +1 -1
- package/_types/errors/request.d.ts +4 -0
- package/_types/errors/request.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +1 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/types/eip1193.d.ts +30 -0
- package/_types/types/eip1193.d.ts.map +1 -1
- package/_types/utils/transaction/assertRequest.d.ts +1 -1
- package/_types/utils/transaction/assertRequest.d.ts.map +1 -1
- package/accounts/mnemonicToAccount.ts +6 -4
- package/actions/index.ts +6 -0
- package/actions/public/fillTransaction.ts +250 -0
- package/actions/wallet/prepareTransactionRequest.ts +76 -10
- package/chains/definitions/monad.ts +15 -3
- package/clients/decorators/public.ts +40 -0
- package/clients/decorators/wallet.ts +40 -0
- package/errors/request.ts +8 -1
- package/errors/version.ts +1 -1
- package/index.ts +5 -0
- package/package.json +1 -1
- package/types/eip1193.ts +30 -0
- package/utils/transaction/assertRequest.ts +2 -17
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
import type { Client } from '../../clients/createClient.js'
|
|
25
25
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
|
26
26
|
import type { AccountNotFoundErrorType } from '../../errors/account.js'
|
|
27
|
+
import type { BaseError } from '../../errors/base.js'
|
|
27
28
|
import {
|
|
28
29
|
Eip1559FeesNotSupportedError,
|
|
29
30
|
MaxFeePerGasTooLowError,
|
|
@@ -58,6 +59,7 @@ import { commitmentsToVersionedHashes } from '../../utils/blob/commitmentsToVers
|
|
|
58
59
|
import { toBlobSidecars } from '../../utils/blob/toBlobSidecars.js'
|
|
59
60
|
import type { FormattedTransactionRequest } from '../../utils/formatters/transactionRequest.js'
|
|
60
61
|
import { getAction } from '../../utils/getAction.js'
|
|
62
|
+
import { LruMap } from '../../utils/lru.js'
|
|
61
63
|
import type { NonceManager } from '../../utils/nonceManager.js'
|
|
62
64
|
import {
|
|
63
65
|
type AssertRequestErrorType,
|
|
@@ -68,6 +70,10 @@ import {
|
|
|
68
70
|
type GetTransactionType,
|
|
69
71
|
getTransactionType,
|
|
70
72
|
} from '../../utils/transaction/getTransactionType.js'
|
|
73
|
+
import {
|
|
74
|
+
type FillTransactionParameters,
|
|
75
|
+
fillTransaction,
|
|
76
|
+
} from '../public/fillTransaction.js'
|
|
71
77
|
import { getChainId as getChainId_ } from '../public/getChainId.js'
|
|
72
78
|
|
|
73
79
|
export const defaultParameters = [
|
|
@@ -82,6 +88,8 @@ export const defaultParameters = [
|
|
|
82
88
|
/** @internal */
|
|
83
89
|
export const eip1559NetworkCache = /*#__PURE__*/ new Map<string, boolean>()
|
|
84
90
|
|
|
91
|
+
const supportsFillTransaction = /*#__PURE__*/ new LruMap<boolean>(128)
|
|
92
|
+
|
|
85
93
|
export type PrepareTransactionRequestParameterType =
|
|
86
94
|
| 'blobVersionedHashes'
|
|
87
95
|
| 'chainId'
|
|
@@ -241,7 +249,7 @@ export async function prepareTransactionRequest<
|
|
|
241
249
|
chainOverride extends Chain | undefined = undefined,
|
|
242
250
|
>(
|
|
243
251
|
client: Client<Transport, chain, account>,
|
|
244
|
-
|
|
252
|
+
args_: PrepareTransactionRequestParameters<
|
|
245
253
|
chain,
|
|
246
254
|
account,
|
|
247
255
|
chainOverride,
|
|
@@ -257,6 +265,60 @@ export async function prepareTransactionRequest<
|
|
|
257
265
|
request
|
|
258
266
|
>
|
|
259
267
|
> {
|
|
268
|
+
const attemptFill =
|
|
269
|
+
// Do not attempt if `eth_fillTransaction` is not supported.
|
|
270
|
+
supportsFillTransaction.get(client.uid) !== false &&
|
|
271
|
+
// Should attempt `eth_fillTransaction` if "fees" or "gas" are required to be populated,
|
|
272
|
+
// otherwise, can just use the other individual calls.
|
|
273
|
+
['fees', 'gas'].some((parameter) =>
|
|
274
|
+
args_.parameters?.includes(
|
|
275
|
+
parameter as PrepareTransactionRequestParameterType,
|
|
276
|
+
),
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
const fillResult = attemptFill
|
|
280
|
+
? await getAction(
|
|
281
|
+
client,
|
|
282
|
+
fillTransaction,
|
|
283
|
+
'fillTransaction',
|
|
284
|
+
)(args_ as FillTransactionParameters)
|
|
285
|
+
.then((result) => {
|
|
286
|
+
const {
|
|
287
|
+
chainId,
|
|
288
|
+
from,
|
|
289
|
+
gas,
|
|
290
|
+
gasPrice,
|
|
291
|
+
nonce,
|
|
292
|
+
maxFeePerBlobGas,
|
|
293
|
+
maxFeePerGas,
|
|
294
|
+
maxPriorityFeePerGas,
|
|
295
|
+
type,
|
|
296
|
+
} = result.transaction
|
|
297
|
+
supportsFillTransaction.set(client.uid, true)
|
|
298
|
+
return {
|
|
299
|
+
...args_,
|
|
300
|
+
chainId,
|
|
301
|
+
from,
|
|
302
|
+
gas,
|
|
303
|
+
gasPrice,
|
|
304
|
+
nonce,
|
|
305
|
+
maxFeePerBlobGas,
|
|
306
|
+
maxFeePerGas,
|
|
307
|
+
maxPriorityFeePerGas,
|
|
308
|
+
type,
|
|
309
|
+
}
|
|
310
|
+
})
|
|
311
|
+
.catch((e) => {
|
|
312
|
+
const error = e as BaseError & { cause: BaseError }
|
|
313
|
+
if (
|
|
314
|
+
error.cause.name === 'MethodNotFoundRpcError' ||
|
|
315
|
+
error.cause.name === 'MethodNotSupportedRpcError'
|
|
316
|
+
)
|
|
317
|
+
supportsFillTransaction.set(client.uid, false)
|
|
318
|
+
return args_
|
|
319
|
+
})
|
|
320
|
+
: args_
|
|
321
|
+
|
|
260
322
|
const {
|
|
261
323
|
account: account_ = client.account,
|
|
262
324
|
blobs,
|
|
@@ -267,10 +329,14 @@ export async function prepareTransactionRequest<
|
|
|
267
329
|
nonceManager,
|
|
268
330
|
parameters = defaultParameters,
|
|
269
331
|
type,
|
|
270
|
-
} =
|
|
332
|
+
} = fillResult
|
|
333
|
+
|
|
271
334
|
const account = account_ ? parseAccount(account_) : account_
|
|
272
335
|
|
|
273
|
-
const request = {
|
|
336
|
+
const request = {
|
|
337
|
+
...fillResult,
|
|
338
|
+
...(account ? { from: account?.address } : {}),
|
|
339
|
+
}
|
|
274
340
|
|
|
275
341
|
let block: Block | undefined
|
|
276
342
|
async function getBlock(): Promise<Block> {
|
|
@@ -287,7 +353,7 @@ export async function prepareTransactionRequest<
|
|
|
287
353
|
async function getChainId(): Promise<number> {
|
|
288
354
|
if (chainId) return chainId
|
|
289
355
|
if (chain) return chain.id
|
|
290
|
-
if (typeof
|
|
356
|
+
if (typeof request.chainId !== 'undefined') return request.chainId
|
|
291
357
|
const chainId_ = await getAction(client, getChainId_, 'getChainId')({})
|
|
292
358
|
chainId = chainId_
|
|
293
359
|
return chainId
|
|
@@ -379,9 +445,9 @@ export async function prepareTransactionRequest<
|
|
|
379
445
|
})
|
|
380
446
|
|
|
381
447
|
if (
|
|
382
|
-
typeof
|
|
383
|
-
|
|
384
|
-
|
|
448
|
+
typeof request.maxPriorityFeePerGas === 'undefined' &&
|
|
449
|
+
request.maxFeePerGas &&
|
|
450
|
+
request.maxFeePerGas < maxPriorityFeePerGas
|
|
385
451
|
)
|
|
386
452
|
throw new MaxFeePerGasTooLowError({
|
|
387
453
|
maxPriorityFeePerGas,
|
|
@@ -393,12 +459,12 @@ export async function prepareTransactionRequest<
|
|
|
393
459
|
} else {
|
|
394
460
|
// Legacy fees
|
|
395
461
|
if (
|
|
396
|
-
typeof
|
|
397
|
-
typeof
|
|
462
|
+
typeof request.maxFeePerGas !== 'undefined' ||
|
|
463
|
+
typeof request.maxPriorityFeePerGas !== 'undefined'
|
|
398
464
|
)
|
|
399
465
|
throw new Eip1559FeesNotSupportedError()
|
|
400
466
|
|
|
401
|
-
if (typeof
|
|
467
|
+
if (typeof request.gasPrice === 'undefined') {
|
|
402
468
|
const block = await getBlock()
|
|
403
469
|
const { gasPrice: gasPrice_ } = await internal_estimateFeesPerGas(
|
|
404
470
|
client,
|
|
@@ -11,14 +11,26 @@ export const monad = /*#__PURE__*/ defineChain({
|
|
|
11
11
|
},
|
|
12
12
|
rpcUrls: {
|
|
13
13
|
default: {
|
|
14
|
-
http: ['https://rpc.monad.xyz'],
|
|
14
|
+
http: ['https://rpc.monad.xyz', 'https://rpc1.monad.xyz'],
|
|
15
|
+
webSocket: ['wss://rpc.monad.xyz', 'wss://rpc1.monad.xyz'],
|
|
15
16
|
},
|
|
16
17
|
},
|
|
17
18
|
blockExplorers: {
|
|
18
19
|
default: {
|
|
19
|
-
name: '
|
|
20
|
-
url: 'https://
|
|
20
|
+
name: 'MonadVision',
|
|
21
|
+
url: 'https://monadvision.com',
|
|
22
|
+
},
|
|
23
|
+
monadscan: {
|
|
24
|
+
name: 'Monadscan',
|
|
25
|
+
url: 'https://monadscan.com',
|
|
26
|
+
apiUrl: 'https://api.monadscan.com/api',
|
|
21
27
|
},
|
|
22
28
|
},
|
|
23
29
|
testnet: false,
|
|
30
|
+
contracts: {
|
|
31
|
+
multicall3: {
|
|
32
|
+
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
33
|
+
blockCreated: 9248132,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
24
36
|
})
|
|
@@ -73,6 +73,11 @@ import {
|
|
|
73
73
|
type EstimateMaxPriorityFeePerGasReturnType,
|
|
74
74
|
estimateMaxPriorityFeePerGas,
|
|
75
75
|
} from '../../actions/public/estimateMaxPriorityFeePerGas.js'
|
|
76
|
+
import {
|
|
77
|
+
type FillTransactionParameters,
|
|
78
|
+
type FillTransactionReturnType,
|
|
79
|
+
fillTransaction,
|
|
80
|
+
} from '../../actions/public/fillTransaction.js'
|
|
76
81
|
import {
|
|
77
82
|
type GetBalanceParameters,
|
|
78
83
|
type GetBalanceReturnType,
|
|
@@ -543,6 +548,40 @@ export type PublicActions<
|
|
|
543
548
|
estimateGas: (
|
|
544
549
|
args: EstimateGasParameters<chain>,
|
|
545
550
|
) => Promise<EstimateGasReturnType>
|
|
551
|
+
/**
|
|
552
|
+
* Fills a transaction request with the necessary fields to be signed over.
|
|
553
|
+
*
|
|
554
|
+
* - Docs: https://viem.sh/docs/actions/public/fillTransaction
|
|
555
|
+
*
|
|
556
|
+
* @param client - Client to use
|
|
557
|
+
* @param parameters - {@link FillTransactionParameters}
|
|
558
|
+
* @returns The filled transaction. {@link FillTransactionReturnType}
|
|
559
|
+
*
|
|
560
|
+
* @example
|
|
561
|
+
* import { createPublicClient, http } from 'viem'
|
|
562
|
+
* import { mainnet } from 'viem/chains'
|
|
563
|
+
*
|
|
564
|
+
* const client = createPublicClient({
|
|
565
|
+
* chain: mainnet,
|
|
566
|
+
* transport: http(),
|
|
567
|
+
* })
|
|
568
|
+
* const result = await client.fillTransaction({
|
|
569
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
570
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
571
|
+
* value: parseEther('1'),
|
|
572
|
+
* })
|
|
573
|
+
*/
|
|
574
|
+
fillTransaction: <
|
|
575
|
+
chainOverride extends Chain | undefined = undefined,
|
|
576
|
+
accountOverride extends Account | Address | undefined = undefined,
|
|
577
|
+
>(
|
|
578
|
+
args: FillTransactionParameters<
|
|
579
|
+
chain,
|
|
580
|
+
account,
|
|
581
|
+
chainOverride,
|
|
582
|
+
accountOverride
|
|
583
|
+
>,
|
|
584
|
+
) => Promise<FillTransactionReturnType<chain, chainOverride>>
|
|
546
585
|
/**
|
|
547
586
|
* Returns the balance of an address in wei.
|
|
548
587
|
*
|
|
@@ -2039,6 +2078,7 @@ export function publicActions<
|
|
|
2039
2078
|
getProof: (args) => getProof(client, args),
|
|
2040
2079
|
estimateMaxPriorityFeePerGas: (args) =>
|
|
2041
2080
|
estimateMaxPriorityFeePerGas(client, args),
|
|
2081
|
+
fillTransaction: (args) => fillTransaction(client, args),
|
|
2042
2082
|
getStorageAt: (args) => getStorageAt(client, args),
|
|
2043
2083
|
getTransaction: (args) => getTransaction(client, args),
|
|
2044
2084
|
getTransactionConfirmations: (args) =>
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { Abi, Address, TypedData } from 'abitype'
|
|
2
2
|
|
|
3
3
|
import type { Account } from '../../accounts/types.js'
|
|
4
|
+
import {
|
|
5
|
+
type FillTransactionParameters,
|
|
6
|
+
type FillTransactionReturnType,
|
|
7
|
+
fillTransaction,
|
|
8
|
+
} from '../../actions/public/fillTransaction.js'
|
|
4
9
|
import {
|
|
5
10
|
type GetChainIdReturnType,
|
|
6
11
|
getChainId,
|
|
@@ -195,6 +200,40 @@ export type WalletActions<
|
|
|
195
200
|
>(
|
|
196
201
|
args: DeployContractParameters<abi, chain, account, chainOverride>,
|
|
197
202
|
) => Promise<DeployContractReturnType>
|
|
203
|
+
/**
|
|
204
|
+
* Fills a transaction request with the necessary fields to be signed over.
|
|
205
|
+
*
|
|
206
|
+
* - Docs: https://viem.sh/docs/actions/public/fillTransaction
|
|
207
|
+
*
|
|
208
|
+
* @param client - Client to use
|
|
209
|
+
* @param parameters - {@link FillTransactionParameters}
|
|
210
|
+
* @returns The filled transaction. {@link FillTransactionReturnType}
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* import { createWalletClient, custom } from 'viem'
|
|
214
|
+
* import { mainnet } from 'viem/chains'
|
|
215
|
+
*
|
|
216
|
+
* const client = createWalletClient({
|
|
217
|
+
* chain: mainnet,
|
|
218
|
+
* transport: custom(window.ethereum),
|
|
219
|
+
* })
|
|
220
|
+
* const result = await client.fillTransaction({
|
|
221
|
+
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
|
222
|
+
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
|
|
223
|
+
* value: parseEther('1'),
|
|
224
|
+
* })
|
|
225
|
+
*/
|
|
226
|
+
fillTransaction: <
|
|
227
|
+
chainOverride extends Chain | undefined = undefined,
|
|
228
|
+
accountOverride extends Account | Address | undefined = undefined,
|
|
229
|
+
>(
|
|
230
|
+
args: FillTransactionParameters<
|
|
231
|
+
chain,
|
|
232
|
+
account,
|
|
233
|
+
chainOverride,
|
|
234
|
+
accountOverride
|
|
235
|
+
>,
|
|
236
|
+
) => Promise<FillTransactionReturnType<chain, chainOverride>>
|
|
198
237
|
/**
|
|
199
238
|
* Returns a list of account addresses owned by the wallet or client.
|
|
200
239
|
*
|
|
@@ -1146,6 +1185,7 @@ export function walletActions<
|
|
|
1146
1185
|
return {
|
|
1147
1186
|
addChain: (args) => addChain(client, args),
|
|
1148
1187
|
deployContract: (args) => deployContract(client, args),
|
|
1188
|
+
fillTransaction: (args) => fillTransaction(client, args),
|
|
1149
1189
|
getAddresses: () => getAddresses(client),
|
|
1150
1190
|
getCallsStatus: (args) => getCallsStatus(client, args),
|
|
1151
1191
|
getCapabilities: (args) => getCapabilities(client, args),
|
package/errors/request.ts
CHANGED
|
@@ -48,6 +48,7 @@ export type WebSocketRequestErrorType = WebSocketRequestError & {
|
|
|
48
48
|
name: 'WebSocketRequestError'
|
|
49
49
|
}
|
|
50
50
|
export class WebSocketRequestError extends BaseError {
|
|
51
|
+
url: string
|
|
51
52
|
constructor({
|
|
52
53
|
body,
|
|
53
54
|
cause,
|
|
@@ -68,6 +69,7 @@ export class WebSocketRequestError extends BaseError {
|
|
|
68
69
|
].filter(Boolean) as string[],
|
|
69
70
|
name: 'WebSocketRequestError',
|
|
70
71
|
})
|
|
72
|
+
this.url = url
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
|
|
@@ -77,7 +79,7 @@ export type RpcRequestErrorType = RpcRequestError & {
|
|
|
77
79
|
export class RpcRequestError extends BaseError {
|
|
78
80
|
code: number
|
|
79
81
|
data?: unknown
|
|
80
|
-
|
|
82
|
+
url: string
|
|
81
83
|
constructor({
|
|
82
84
|
body,
|
|
83
85
|
error,
|
|
@@ -95,6 +97,7 @@ export class RpcRequestError extends BaseError {
|
|
|
95
97
|
})
|
|
96
98
|
this.code = error.code
|
|
97
99
|
this.data = error.data
|
|
100
|
+
this.url = url
|
|
98
101
|
}
|
|
99
102
|
}
|
|
100
103
|
|
|
@@ -102,6 +105,7 @@ export type SocketClosedErrorType = SocketClosedError & {
|
|
|
102
105
|
name: 'SocketClosedError'
|
|
103
106
|
}
|
|
104
107
|
export class SocketClosedError extends BaseError {
|
|
108
|
+
url: string | undefined
|
|
105
109
|
constructor({
|
|
106
110
|
url,
|
|
107
111
|
}: {
|
|
@@ -111,6 +115,7 @@ export class SocketClosedError extends BaseError {
|
|
|
111
115
|
metaMessages: [url && `URL: ${getUrl(url)}`].filter(Boolean) as string[],
|
|
112
116
|
name: 'SocketClosedError',
|
|
113
117
|
})
|
|
118
|
+
this.url = url
|
|
114
119
|
}
|
|
115
120
|
}
|
|
116
121
|
|
|
@@ -118,6 +123,7 @@ export type TimeoutErrorType = TimeoutError & {
|
|
|
118
123
|
name: 'TimeoutError'
|
|
119
124
|
}
|
|
120
125
|
export class TimeoutError extends BaseError {
|
|
126
|
+
url: string
|
|
121
127
|
constructor({
|
|
122
128
|
body,
|
|
123
129
|
url,
|
|
@@ -130,5 +136,6 @@ export class TimeoutError extends BaseError {
|
|
|
130
136
|
metaMessages: [`URL: ${getUrl(url)}`, `Request body: ${stringify(body)}`],
|
|
131
137
|
name: 'TimeoutError',
|
|
132
138
|
})
|
|
139
|
+
this.url = url
|
|
133
140
|
}
|
|
134
141
|
}
|
package/errors/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.40.0'
|
package/index.ts
CHANGED
|
@@ -135,6 +135,11 @@ export type {
|
|
|
135
135
|
EstimateMaxPriorityFeePerGasParameters,
|
|
136
136
|
EstimateMaxPriorityFeePerGasReturnType,
|
|
137
137
|
} from './actions/public/estimateMaxPriorityFeePerGas.js'
|
|
138
|
+
export type {
|
|
139
|
+
FillTransactionErrorType,
|
|
140
|
+
FillTransactionParameters,
|
|
141
|
+
FillTransactionReturnType,
|
|
142
|
+
} from './actions/public/fillTransaction.js'
|
|
138
143
|
export type {
|
|
139
144
|
GetBalanceErrorType,
|
|
140
145
|
GetBalanceParameters,
|
package/package.json
CHANGED
package/types/eip1193.ts
CHANGED
|
@@ -753,6 +753,21 @@ export type PublicRpcSchema = [
|
|
|
753
753
|
]
|
|
754
754
|
ReturnType: Quantity
|
|
755
755
|
},
|
|
756
|
+
/**
|
|
757
|
+
* @description Fills a transaction with the necessary data to be signed.
|
|
758
|
+
*
|
|
759
|
+
* @example
|
|
760
|
+
* provider.request({ method: 'eth_fillTransaction', params: [{ from: '0x...', to: '0x...', value: '0x...' }] })
|
|
761
|
+
* // => '0x...'
|
|
762
|
+
*/
|
|
763
|
+
{
|
|
764
|
+
Method: 'eth_fillTransaction'
|
|
765
|
+
Parameters: [transaction: TransactionRequest]
|
|
766
|
+
ReturnType: {
|
|
767
|
+
raw: Hex
|
|
768
|
+
tx: Transaction
|
|
769
|
+
}
|
|
770
|
+
},
|
|
756
771
|
/**
|
|
757
772
|
* @description Returns a collection of historical gas information
|
|
758
773
|
*
|
|
@@ -1701,6 +1716,21 @@ export type WalletRpcSchema = [
|
|
|
1701
1716
|
]
|
|
1702
1717
|
ReturnType: Quantity
|
|
1703
1718
|
},
|
|
1719
|
+
/**
|
|
1720
|
+
* @description Fills a transaction with the necessary data to be signed.
|
|
1721
|
+
*
|
|
1722
|
+
* @example
|
|
1723
|
+
* provider.request({ method: 'eth_fillTransaction', params: [{ from: '0x...', to: '0x...', value: '0x...' }] })
|
|
1724
|
+
* // => '0x...'
|
|
1725
|
+
*/
|
|
1726
|
+
{
|
|
1727
|
+
Method: 'eth_fillTransaction'
|
|
1728
|
+
Parameters: [transaction: TransactionRequest]
|
|
1729
|
+
ReturnType: {
|
|
1730
|
+
raw: Hex
|
|
1731
|
+
tx: Transaction
|
|
1732
|
+
}
|
|
1733
|
+
},
|
|
1704
1734
|
/**
|
|
1705
1735
|
* @description Requests that the user provides an Ethereum address to be identified by. Typically causes a browser extension popup to appear.
|
|
1706
1736
|
* @link https://eips.ethereum.org/EIPS/eip-1102
|
|
@@ -14,10 +14,7 @@ import {
|
|
|
14
14
|
TipAboveFeeCapError,
|
|
15
15
|
type TipAboveFeeCapErrorType,
|
|
16
16
|
} from '../../errors/node.js'
|
|
17
|
-
import {
|
|
18
|
-
FeeConflictError,
|
|
19
|
-
type FeeConflictErrorType,
|
|
20
|
-
} from '../../errors/transaction.js'
|
|
17
|
+
import type { FeeConflictErrorType } from '../../errors/transaction.js'
|
|
21
18
|
import type { ErrorType } from '../../errors/utils.js'
|
|
22
19
|
import type { Chain } from '../../types/chain.js'
|
|
23
20
|
import type { ExactPartial } from '../../types/utils.js'
|
|
@@ -36,23 +33,11 @@ export type AssertRequestErrorType =
|
|
|
36
33
|
| ErrorType
|
|
37
34
|
|
|
38
35
|
export function assertRequest(args: AssertRequestParameters) {
|
|
39
|
-
const {
|
|
40
|
-
account: account_,
|
|
41
|
-
gasPrice,
|
|
42
|
-
maxFeePerGas,
|
|
43
|
-
maxPriorityFeePerGas,
|
|
44
|
-
to,
|
|
45
|
-
} = args
|
|
36
|
+
const { account: account_, maxFeePerGas, maxPriorityFeePerGas, to } = args
|
|
46
37
|
const account = account_ ? parseAccount(account_) : undefined
|
|
47
38
|
if (account && !isAddress(account.address))
|
|
48
39
|
throw new InvalidAddressError({ address: account.address })
|
|
49
40
|
if (to && !isAddress(to)) throw new InvalidAddressError({ address: to })
|
|
50
|
-
if (
|
|
51
|
-
typeof gasPrice !== 'undefined' &&
|
|
52
|
-
(typeof maxFeePerGas !== 'undefined' ||
|
|
53
|
-
typeof maxPriorityFeePerGas !== 'undefined')
|
|
54
|
-
)
|
|
55
|
-
throw new FeeConflictError()
|
|
56
41
|
|
|
57
42
|
if (maxFeePerGas && maxFeePerGas > maxUint256)
|
|
58
43
|
throw new FeeCapTooHighError({ maxFeePerGas })
|