viem 0.0.0-main.20240408T061242 → 0.0.0-main.20240408T210957
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/_cjs/actions/index.js +1 -2
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/public/estimateGas.js +3 -5
- package/_cjs/actions/public/estimateGas.js.map +1 -1
- package/_cjs/actions/wallet/prepareTransactionRequest.js +7 -47
- package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_cjs/actions/wallet/sendTransaction.js +0 -1
- package/_cjs/actions/wallet/sendTransaction.js.map +1 -1
- package/_cjs/chains/definitions/filecoinCalibration.js +1 -0
- package/_cjs/chains/definitions/filecoinCalibration.js.map +1 -1
- package/_cjs/chains/definitions/filecoinHyperspace.js +1 -0
- package/_cjs/chains/definitions/filecoinHyperspace.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/utils/blob/blobsToCommitments.js.map +1 -1
- package/_cjs/utils/blob/commitmentsToVersionedHashes.js.map +1 -1
- package/_cjs/utils/blob/sidecarsToVersionedHashes.js.map +1 -1
- package/_cjs/utils/blob/toBlobSidecars.js.map +1 -1
- package/_cjs/utils/blob/toBlobs.js.map +1 -1
- package/_cjs/utils/formatters/transactionRequest.js +0 -2
- package/_cjs/utils/formatters/transactionRequest.js.map +1 -1
- package/_cjs/utils/transaction/serializeTransaction.js +6 -10
- package/_cjs/utils/transaction/serializeTransaction.js.map +1 -1
- package/_esm/actions/index.js +1 -1
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/public/estimateGas.js +3 -8
- package/_esm/actions/public/estimateGas.js.map +1 -1
- package/_esm/actions/wallet/prepareTransactionRequest.js +9 -49
- package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_esm/actions/wallet/sendTransaction.js +1 -2
- package/_esm/actions/wallet/sendTransaction.js.map +1 -1
- package/_esm/chains/definitions/filecoinCalibration.js +1 -0
- package/_esm/chains/definitions/filecoinCalibration.js.map +1 -1
- package/_esm/chains/definitions/filecoinHyperspace.js +1 -0
- package/_esm/chains/definitions/filecoinHyperspace.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/utils/blob/blobsToCommitments.js.map +1 -1
- package/_esm/utils/blob/commitmentsToVersionedHashes.js.map +1 -1
- package/_esm/utils/blob/sidecarsToVersionedHashes.js.map +1 -1
- package/_esm/utils/blob/toBlobSidecars.js.map +1 -1
- package/_esm/utils/blob/toBlobs.js.map +1 -1
- package/_esm/utils/formatters/transactionRequest.js +0 -2
- package/_esm/utils/formatters/transactionRequest.js.map +1 -1
- package/_esm/utils/transaction/serializeTransaction.js +6 -10
- package/_esm/utils/transaction/serializeTransaction.js.map +1 -1
- package/_types/actions/index.d.ts +1 -1
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/public/estimateGas.d.ts.map +1 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts +6 -7
- package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
- package/_types/actions/wallet/sendTransaction.d.ts.map +1 -1
- package/_types/celo/chainConfig.d.ts +341 -1837
- package/_types/celo/chainConfig.d.ts.map +1 -1
- package/_types/celo/formatters.d.ts +97 -845
- package/_types/celo/formatters.d.ts.map +1 -1
- package/_types/chains/definitions/ancient8.d.ts +15 -15
- package/_types/chains/definitions/ancient8Sepolia.d.ts +15 -15
- package/_types/chains/definitions/base.d.ts +15 -15
- package/_types/chains/definitions/baseGoerli.d.ts +15 -15
- package/_types/chains/definitions/baseSepolia.d.ts +15 -15
- package/_types/chains/definitions/celo.d.ts +341 -1837
- package/_types/chains/definitions/celo.d.ts.map +1 -1
- package/_types/chains/definitions/celoAlfajores.d.ts +341 -1837
- package/_types/chains/definitions/celoAlfajores.d.ts.map +1 -1
- package/_types/chains/definitions/filecoinCalibration.d.ts +1 -1
- package/_types/chains/definitions/filecoinCalibration.d.ts.map +1 -1
- package/_types/chains/definitions/filecoinHyperspace.d.ts +1 -1
- package/_types/chains/definitions/filecoinHyperspace.d.ts.map +1 -1
- package/_types/chains/definitions/fraxtal.d.ts +15 -15
- package/_types/chains/definitions/fraxtalTestnet.d.ts +15 -15
- package/_types/chains/definitions/liskSepolia.d.ts +15 -15
- package/_types/chains/definitions/optimism.d.ts +15 -15
- package/_types/chains/definitions/optimismGoerli.d.ts +15 -15
- package/_types/chains/definitions/optimismSepolia.d.ts +15 -15
- package/_types/chains/definitions/pgn.d.ts +15 -15
- package/_types/chains/definitions/pgnTestnet.d.ts +15 -15
- package/_types/chains/definitions/rss3.d.ts +15 -15
- package/_types/chains/definitions/rss3Sepolia.d.ts +15 -15
- package/_types/chains/definitions/zkSync.d.ts +101 -817
- package/_types/chains/definitions/zkSync.d.ts.map +1 -1
- package/_types/chains/definitions/zkSyncInMemoryNode.d.ts +101 -817
- package/_types/chains/definitions/zkSyncInMemoryNode.d.ts.map +1 -1
- package/_types/chains/definitions/zkSyncLocalNode.d.ts +101 -817
- package/_types/chains/definitions/zkSyncLocalNode.d.ts.map +1 -1
- package/_types/chains/definitions/zkSyncSepoliaTestnet.d.ts +101 -817
- package/_types/chains/definitions/zkSyncSepoliaTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/zkSyncTestnet.d.ts +101 -817
- package/_types/chains/definitions/zkSyncTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/zora.d.ts +15 -15
- package/_types/chains/definitions/zoraSepolia.d.ts +15 -15
- package/_types/chains/definitions/zoraTestnet.d.ts +15 -15
- package/_types/errors/version.d.ts +1 -1
- package/_types/op-stack/chainConfig.d.ts +15 -15
- package/_types/op-stack/formatters.d.ts +15 -15
- package/_types/types/transaction.d.ts +3 -22
- package/_types/types/transaction.d.ts.map +1 -1
- package/_types/utils/blob/blobsToCommitments.d.ts +4 -4
- package/_types/utils/blob/blobsToCommitments.d.ts.map +1 -1
- package/_types/utils/blob/blobsToProofs.d.ts +2 -2
- package/_types/utils/blob/blobsToProofs.d.ts.map +1 -1
- package/_types/utils/blob/commitmentsToVersionedHashes.d.ts +4 -4
- package/_types/utils/blob/commitmentsToVersionedHashes.d.ts.map +1 -1
- package/_types/utils/blob/sidecarsToVersionedHashes.d.ts +1 -1
- package/_types/utils/blob/sidecarsToVersionedHashes.d.ts.map +1 -1
- package/_types/utils/blob/toBlobSidecars.d.ts +5 -5
- package/_types/utils/blob/toBlobSidecars.d.ts.map +1 -1
- package/_types/utils/blob/toBlobs.d.ts +1 -1
- package/_types/utils/blob/toBlobs.d.ts.map +1 -1
- package/_types/utils/formatters/transaction.d.ts +1 -1
- package/_types/utils/formatters/transactionRequest.d.ts +2 -186
- package/_types/utils/formatters/transactionRequest.d.ts.map +1 -1
- package/_types/utils/transaction/getTransactionType.d.ts +3 -3
- package/_types/utils/transaction/getTransactionType.d.ts.map +1 -1
- package/_types/utils/transaction/serializeTransaction.d.ts.map +1 -1
- package/_types/zksync/chainConfig.d.ts +101 -817
- package/_types/zksync/chainConfig.d.ts.map +1 -1
- package/_types/zksync/formatters.d.ts +101 -817
- package/_types/zksync/formatters.d.ts.map +1 -1
- package/actions/index.ts +0 -1
- package/actions/public/estimateGas.ts +7 -9
- package/actions/wallet/prepareTransactionRequest.ts +17 -73
- package/actions/wallet/sendTransaction.ts +0 -2
- package/chains/definitions/filecoinCalibration.ts +1 -0
- package/chains/definitions/filecoinHyperspace.ts +1 -0
- package/errors/version.ts +1 -1
- package/package.json +1 -1
- package/types/transaction.ts +3 -28
- package/utils/blob/blobsToCommitments.ts +7 -9
- package/utils/blob/blobsToProofs.ts +10 -10
- package/utils/blob/commitmentsToVersionedHashes.ts +8 -10
- package/utils/blob/sidecarsToVersionedHashes.ts +3 -3
- package/utils/blob/toBlobSidecars.ts +11 -14
- package/utils/blob/toBlobs.ts +3 -3
- package/utils/formatters/transactionRequest.ts +0 -2
- package/utils/transaction/getTransactionType.ts +3 -3
- package/utils/transaction/serializeTransaction.ts +6 -12
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../zksync/formatters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAS5C,OAAO,KAAK,EAEV,uBAAuB,EACxB,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,KAAK,EACV,oBAAoB,EACpB,oCAAoC,EAEpC,iBAAiB,EAGlB,MAAM,wBAAwB,CAAA;AAE/B,eAAO,MAAM,UAAU;;;;0BAID,IAAI,EAAE,GAAG,oBAAoB,EAAE;;;;;;;;;;;;;;;;;;;;;;;0BAGjC,IAAI,EAAE,GAAG,iBAAiB,EAAE
|
1
|
+
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../zksync/formatters.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAS5C,OAAO,KAAK,EAEV,uBAAuB,EACxB,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,KAAK,EACV,oBAAoB,EACpB,oCAAoC,EAEpC,iBAAiB,EAGlB,MAAM,wBAAwB,CAAA;AAE/B,eAAO,MAAM,UAAU;;;;0BAID,IAAI,EAAE,GAAG,oBAAoB,EAAE;;;;;;;;;;;;;;;;;;;;;;;0BAGjC,IAAI,EAAE,GAAG,iBAAiB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2HZ,CAAA"}
|
package/actions/index.ts
CHANGED
@@ -343,7 +343,6 @@ export {
|
|
343
343
|
type PrepareTransactionRequestParameters,
|
344
344
|
type PrepareTransactionRequestReturnType,
|
345
345
|
prepareTransactionRequest,
|
346
|
-
defaultParameters as defaultPrepareTransactionRequestParameters,
|
347
346
|
} from './wallet/prepareTransactionRequest.js'
|
348
347
|
export {
|
349
348
|
type SendTransactionErrorType,
|
@@ -107,7 +107,6 @@ export async function estimateGas<
|
|
107
107
|
const {
|
108
108
|
accessList,
|
109
109
|
blobs,
|
110
|
-
blobVersionedHashes,
|
111
110
|
blockNumber,
|
112
111
|
blockTag,
|
113
112
|
data,
|
@@ -120,13 +119,13 @@ export async function estimateGas<
|
|
120
119
|
to,
|
121
120
|
value,
|
122
121
|
...rest
|
123
|
-
} =
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
122
|
+
} =
|
123
|
+
account?.type === 'local'
|
124
|
+
? ((await prepareTransactionRequest(
|
125
|
+
client,
|
126
|
+
args as PrepareTransactionRequestParameters,
|
127
|
+
)) as EstimateGasParameters)
|
128
|
+
: args
|
130
129
|
|
131
130
|
const blockNumberHex = blockNumber ? numberToHex(blockNumber) : undefined
|
132
131
|
const block = blockNumberHex || blockTag
|
@@ -142,7 +141,6 @@ export async function estimateGas<
|
|
142
141
|
from: account?.address,
|
143
142
|
accessList,
|
144
143
|
blobs,
|
145
|
-
blobVersionedHashes,
|
146
144
|
data,
|
147
145
|
gas,
|
148
146
|
gasPrice,
|
@@ -15,7 +15,7 @@ import {
|
|
15
15
|
} from '../../actions/public/estimateGas.js'
|
16
16
|
import {
|
17
17
|
type GetBlockErrorType,
|
18
|
-
getBlock
|
18
|
+
getBlock,
|
19
19
|
} from '../../actions/public/getBlock.js'
|
20
20
|
import {
|
21
21
|
type GetTransactionCountErrorType,
|
@@ -28,8 +28,8 @@ import {
|
|
28
28
|
Eip1559FeesNotSupportedError,
|
29
29
|
MaxFeePerGasTooLowError,
|
30
30
|
} from '../../errors/fee.js'
|
31
|
+
import type { Block, GetTransactionType } from '../../index.js'
|
31
32
|
import type { DeriveAccount, GetAccountParameter } from '../../types/account.js'
|
32
|
-
import type { Block } from '../../types/block.js'
|
33
33
|
import type { Chain, DeriveChain } from '../../types/chain.js'
|
34
34
|
import type { GetChainParameter } from '../../types/chain.js'
|
35
35
|
import type { GetTransactionRequestKzgParameter } from '../../types/kzg.js'
|
@@ -48,39 +48,21 @@ import type {
|
|
48
48
|
UnionOmit,
|
49
49
|
UnionRequiredBy,
|
50
50
|
} from '../../types/utils.js'
|
51
|
-
import { blobsToCommitments } from '../../utils/blob/blobsToCommitments.js'
|
52
|
-
import { blobsToProofs } from '../../utils/blob/blobsToProofs.js'
|
53
|
-
import { commitmentsToVersionedHashes } from '../../utils/blob/commitmentsToVersionedHashes.js'
|
54
|
-
import { toBlobSidecars } from '../../utils/blob/toBlobSidecars.js'
|
55
51
|
import type { FormattedTransactionRequest } from '../../utils/formatters/transactionRequest.js'
|
56
52
|
import { getAction } from '../../utils/getAction.js'
|
57
|
-
import {
|
58
|
-
|
59
|
-
|
60
|
-
assertRequest,
|
53
|
+
import type {
|
54
|
+
AssertRequestErrorType,
|
55
|
+
AssertRequestParameters,
|
61
56
|
} from '../../utils/transaction/assertRequest.js'
|
62
|
-
import {
|
63
|
-
|
64
|
-
getTransactionType,
|
65
|
-
} from '../../utils/transaction/getTransactionType.js'
|
57
|
+
import { assertRequest } from '../../utils/transaction/assertRequest.js'
|
58
|
+
import { getTransactionType } from '../../utils/transaction/getTransactionType.js'
|
66
59
|
import { getChainId } from '../public/getChainId.js'
|
67
60
|
|
68
|
-
export const defaultParameters = [
|
69
|
-
'blobVersionedHashes',
|
70
|
-
'chainId',
|
71
|
-
'fees',
|
72
|
-
'gas',
|
73
|
-
'nonce',
|
74
|
-
'type',
|
75
|
-
] as const
|
76
|
-
|
77
61
|
export type PrepareTransactionRequestParameterType =
|
78
|
-
| 'blobVersionedHashes'
|
79
62
|
| 'chainId'
|
80
63
|
| 'fees'
|
81
64
|
| 'gas'
|
82
65
|
| 'nonce'
|
83
|
-
| 'sidecars'
|
84
66
|
| 'type'
|
85
67
|
type ParameterTypeToParameters<
|
86
68
|
parameterType extends PrepareTransactionRequestParameterType,
|
@@ -95,7 +77,7 @@ export type PrepareTransactionRequestRequest<
|
|
95
77
|
_derivedChain extends Chain | undefined = DeriveChain<chain, chainOverride>,
|
96
78
|
> = UnionOmit<FormattedTransactionRequest<_derivedChain>, 'from'> &
|
97
79
|
GetTransactionRequestKzgParameter & {
|
98
|
-
parameters?:
|
80
|
+
parameters?: PrepareTransactionRequestParameterType[] | undefined
|
99
81
|
}
|
100
82
|
|
101
83
|
export type PrepareTransactionRequestParameters<
|
@@ -153,7 +135,7 @@ export type PrepareTransactionRequestReturnType<
|
|
153
135
|
accountOverride
|
154
136
|
>,
|
155
137
|
_derivedChain extends Chain | undefined = DeriveChain<chain, chainOverride>,
|
156
|
-
_transactionType = request['type'] extends string
|
138
|
+
_transactionType = request['type'] extends string
|
157
139
|
? request['type']
|
158
140
|
: GetTransactionType<request> extends 'legacy'
|
159
141
|
? unknown
|
@@ -178,9 +160,9 @@ export type PrepareTransactionRequestReturnType<
|
|
178
160
|
: ExactPartial<_transactionRequest>
|
179
161
|
> & { chainId?: number | undefined },
|
180
162
|
ParameterTypeToParameters<
|
181
|
-
request['parameters'] extends
|
163
|
+
request['parameters'] extends PrepareTransactionRequestParameterType[]
|
182
164
|
? request['parameters'][number]
|
183
|
-
:
|
165
|
+
: PrepareTransactionRequestParameterType
|
184
166
|
>
|
185
167
|
> &
|
186
168
|
(unknown extends request['kzg'] ? {} : Pick<request, 'kzg'>)
|
@@ -261,57 +243,17 @@ export async function prepareTransactionRequest<
|
|
261
243
|
> {
|
262
244
|
const {
|
263
245
|
account: account_ = client.account,
|
264
|
-
blobs,
|
265
246
|
chain,
|
266
247
|
chainId,
|
267
248
|
gas,
|
268
|
-
kzg,
|
269
249
|
nonce,
|
270
|
-
parameters =
|
250
|
+
parameters = ['chainId', 'fees', 'gas', 'nonce', 'type'],
|
271
251
|
type,
|
272
252
|
} = args
|
273
253
|
const account = account_ ? parseAccount(account_) : undefined
|
274
254
|
|
275
255
|
const request = { ...args, ...(account ? { from: account?.address } : {}) }
|
276
256
|
|
277
|
-
let block: Block | undefined
|
278
|
-
async function getBlock(): Promise<Block> {
|
279
|
-
if (block) return block
|
280
|
-
block = await getAction(
|
281
|
-
client,
|
282
|
-
getBlock_,
|
283
|
-
'getBlock',
|
284
|
-
)({ blockTag: 'latest' })
|
285
|
-
return block
|
286
|
-
}
|
287
|
-
|
288
|
-
if (
|
289
|
-
(parameters.includes('blobVersionedHashes') ||
|
290
|
-
parameters.includes('sidecars')) &&
|
291
|
-
blobs &&
|
292
|
-
kzg
|
293
|
-
) {
|
294
|
-
const commitments = blobsToCommitments({ blobs, kzg })
|
295
|
-
|
296
|
-
if (parameters.includes('blobVersionedHashes')) {
|
297
|
-
const versionedHashes = commitmentsToVersionedHashes({
|
298
|
-
commitments,
|
299
|
-
to: 'hex',
|
300
|
-
})
|
301
|
-
request.blobVersionedHashes = versionedHashes
|
302
|
-
}
|
303
|
-
if (parameters.includes('sidecars')) {
|
304
|
-
const proofs = blobsToProofs({ blobs, commitments, kzg })
|
305
|
-
const sidecars = toBlobSidecars({
|
306
|
-
blobs,
|
307
|
-
commitments,
|
308
|
-
proofs,
|
309
|
-
to: 'hex',
|
310
|
-
})
|
311
|
-
request.sidecars = sidecars
|
312
|
-
}
|
313
|
-
}
|
314
|
-
|
315
257
|
if (parameters.includes('chainId')) {
|
316
258
|
if (chain) request.chainId = chain.id
|
317
259
|
else if (typeof chainId !== 'undefined') request.chainId = chainId
|
@@ -328,6 +270,11 @@ export async function prepareTransactionRequest<
|
|
328
270
|
blockTag: 'pending',
|
329
271
|
})
|
330
272
|
|
273
|
+
const block = await (() => {
|
274
|
+
if (typeof request.type !== 'undefined') return
|
275
|
+
return getAction(client, getBlock, 'getBlock')({ blockTag: 'latest' })
|
276
|
+
})()
|
277
|
+
|
331
278
|
if (
|
332
279
|
(parameters.includes('fees') || parameters.includes('type')) &&
|
333
280
|
typeof type === 'undefined'
|
@@ -338,7 +285,6 @@ export async function prepareTransactionRequest<
|
|
338
285
|
) as any
|
339
286
|
} catch {
|
340
287
|
// infer type from block
|
341
|
-
const block = await getBlock()
|
342
288
|
request.type =
|
343
289
|
typeof block?.baseFeePerGas === 'bigint' ? 'eip1559' : 'legacy'
|
344
290
|
}
|
@@ -353,7 +299,6 @@ export async function prepareTransactionRequest<
|
|
353
299
|
typeof request.maxFeePerGas === 'undefined' ||
|
354
300
|
typeof request.maxPriorityFeePerGas === 'undefined'
|
355
301
|
) {
|
356
|
-
const block = await getBlock()
|
357
302
|
const { maxFeePerGas, maxPriorityFeePerGas } =
|
358
303
|
await internal_estimateFeesPerGas(client, {
|
359
304
|
block: block as Block,
|
@@ -381,7 +326,6 @@ export async function prepareTransactionRequest<
|
|
381
326
|
)
|
382
327
|
throw new Eip1559FeesNotSupportedError()
|
383
328
|
|
384
|
-
const block = await getBlock()
|
385
329
|
const { gasPrice: gasPrice_ } = await internal_estimateFeesPerGas(
|
386
330
|
client,
|
387
331
|
{
|
@@ -39,7 +39,6 @@ import {
|
|
39
39
|
import { type GetChainIdErrorType, getChainId } from '../public/getChainId.js'
|
40
40
|
import {
|
41
41
|
type PrepareTransactionRequestErrorType,
|
42
|
-
defaultParameters,
|
43
42
|
prepareTransactionRequest,
|
44
43
|
} from './prepareTransactionRequest.js'
|
45
44
|
import {
|
@@ -191,7 +190,6 @@ export async function sendTransaction<
|
|
191
190
|
maxFeePerGas,
|
192
191
|
maxPriorityFeePerGas,
|
193
192
|
nonce,
|
194
|
-
parameters: [...defaultParameters, 'sidecars'],
|
195
193
|
to,
|
196
194
|
value,
|
197
195
|
...rest,
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '0.0.0-main.
|
1
|
+
export const version = '0.0.0-main.20240408T210957'
|
package/package.json
CHANGED
package/types/transaction.ts
CHANGED
@@ -227,17 +227,7 @@ export type TransactionRequestEIP4844<
|
|
227
227
|
/** The blobs associated with this transaction. */
|
228
228
|
blobs: readonly Hex[] | readonly ByteArray[]
|
229
229
|
type?: TTransactionType | undefined
|
230
|
-
}
|
231
|
-
| { kzg: Kzg | undefined }
|
232
|
-
| {
|
233
|
-
blobVersionedHashes: readonly Hex[]
|
234
|
-
kzg?: Kzg | undefined
|
235
|
-
}
|
236
|
-
| {
|
237
|
-
kzg?: Kzg | undefined
|
238
|
-
sidecars: readonly BlobSidecar<Hex>[]
|
239
|
-
}
|
240
|
-
>
|
230
|
+
}
|
241
231
|
export type TransactionRequest<TQuantity = bigint, TIndex = number> = OneOf<
|
242
232
|
| TransactionRequestLegacy<TQuantity, TIndex>
|
243
233
|
| TransactionRequestEIP2930<TQuantity, TIndex>
|
@@ -245,20 +235,6 @@ export type TransactionRequest<TQuantity = bigint, TIndex = number> = OneOf<
|
|
245
235
|
| TransactionRequestEIP4844<TQuantity, TIndex>
|
246
236
|
>
|
247
237
|
|
248
|
-
export type TransactionRequestGeneric<
|
249
|
-
TQuantity = bigint,
|
250
|
-
TIndex = number,
|
251
|
-
> = TransactionRequestBase<TQuantity, TIndex> & {
|
252
|
-
accessList?: AccessList | undefined
|
253
|
-
blobs?: readonly Hex[] | readonly ByteArray[] | undefined
|
254
|
-
blobVersionedHashes?: readonly Hex[] | undefined
|
255
|
-
gasPrice?: TQuantity | undefined
|
256
|
-
maxFeePerBlobGas?: TQuantity | undefined
|
257
|
-
maxFeePerGas?: TQuantity | undefined
|
258
|
-
maxPriorityFeePerGas?: TQuantity | undefined
|
259
|
-
type?: string | undefined
|
260
|
-
}
|
261
|
-
|
262
238
|
export type TransactionSerializedEIP1559 = `0x02${string}`
|
263
239
|
export type TransactionSerializedEIP2930 = `0x01${string}`
|
264
240
|
export type TransactionSerializedEIP4844 = `0x03${string}`
|
@@ -324,18 +300,17 @@ export type TransactionSerializableEIP4844<
|
|
324
300
|
ExactPartial<FeeValuesEIP4844<TQuantity>> & {
|
325
301
|
accessList?: AccessList | undefined
|
326
302
|
chainId: number
|
327
|
-
sidecars?: readonly BlobSidecar<Hex>[] | false | undefined
|
328
303
|
type?: 'eip4844' | undefined
|
329
304
|
yParity?: number | undefined
|
330
305
|
} & OneOf<
|
331
306
|
| {
|
332
|
-
blobs?: readonly Hex[] | readonly ByteArray[] | undefined
|
333
307
|
blobVersionedHashes: readonly Hex[]
|
308
|
+
sidecars?: readonly BlobSidecar<Hex>[] | false | undefined
|
334
309
|
}
|
335
310
|
| {
|
336
311
|
blobs: readonly Hex[] | readonly ByteArray[]
|
337
|
-
blobVersionedHashes?: readonly Hex[] | undefined
|
338
312
|
kzg: Kzg
|
313
|
+
sidecars?: false | undefined
|
339
314
|
}
|
340
315
|
>
|
341
316
|
|
@@ -7,13 +7,11 @@ import { type BytesToHexErrorType, bytesToHex } from '../encoding/toHex.js'
|
|
7
7
|
type To = 'hex' | 'bytes'
|
8
8
|
|
9
9
|
export type BlobsToCommitmentsParameters<
|
10
|
-
blobs extends
|
11
|
-
| readonly ByteArray[]
|
12
|
-
| readonly Hex[],
|
10
|
+
blobs extends ByteArray[] | Hex[] = ByteArray[] | Hex[],
|
13
11
|
to extends To | undefined = undefined,
|
14
12
|
> = {
|
15
13
|
/** Blobs to transform into commitments. */
|
16
|
-
blobs: blobs |
|
14
|
+
blobs: blobs | ByteArray[] | Hex[]
|
17
15
|
/** KZG implementation. */
|
18
16
|
kzg: Pick<Kzg, 'blobToKzgCommitment'>
|
19
17
|
/** Return type. */
|
@@ -21,8 +19,8 @@ export type BlobsToCommitmentsParameters<
|
|
21
19
|
}
|
22
20
|
|
23
21
|
export type BlobsToCommitmentsReturnType<to extends To> =
|
24
|
-
| (to extends 'bytes' ?
|
25
|
-
| (to extends 'hex' ?
|
22
|
+
| (to extends 'bytes' ? ByteArray[] : never)
|
23
|
+
| (to extends 'hex' ? Hex[] : never)
|
26
24
|
|
27
25
|
export type BlobsToCommitmentsErrorType =
|
28
26
|
| HexToBytesErrorType
|
@@ -42,10 +40,10 @@ export type BlobsToCommitmentsErrorType =
|
|
42
40
|
* ```
|
43
41
|
*/
|
44
42
|
export function blobsToCommitments<
|
45
|
-
const blobs extends
|
43
|
+
const blobs extends ByteArray[] | Hex[],
|
46
44
|
to extends To =
|
47
|
-
| (blobs extends
|
48
|
-
| (blobs extends
|
45
|
+
| (blobs extends Hex[] ? 'hex' : never)
|
46
|
+
| (blobs extends ByteArray[] ? 'bytes' : never),
|
49
47
|
>(
|
50
48
|
parameters: BlobsToCommitmentsParameters<blobs, to>,
|
51
49
|
): BlobsToCommitmentsReturnType<to> {
|
@@ -7,15 +7,15 @@ import { type BytesToHexErrorType, bytesToHex } from '../encoding/toHex.js'
|
|
7
7
|
type To = 'hex' | 'bytes'
|
8
8
|
|
9
9
|
export type blobsToProofsParameters<
|
10
|
-
blobs extends
|
11
|
-
commitments extends
|
10
|
+
blobs extends ByteArray[] | Hex[],
|
11
|
+
commitments extends ByteArray[] | Hex[],
|
12
12
|
to extends To =
|
13
|
-
| (blobs extends
|
14
|
-
| (blobs extends
|
13
|
+
| (blobs extends Hex[] ? 'hex' : never)
|
14
|
+
| (blobs extends ByteArray[] ? 'bytes' : never),
|
15
15
|
///
|
16
16
|
_blobsType =
|
17
|
-
| (blobs extends
|
18
|
-
| (blobs extends
|
17
|
+
| (blobs extends Hex[] ? Hex[] : never)
|
18
|
+
| (blobs extends ByteArray[] ? ByteArray[] : never),
|
19
19
|
> = {
|
20
20
|
/** Blobs to transform into proofs. */
|
21
21
|
blobs: blobs
|
@@ -56,11 +56,11 @@ export type blobsToProofsErrorType =
|
|
56
56
|
* ```
|
57
57
|
*/
|
58
58
|
export function blobsToProofs<
|
59
|
-
const blobs extends
|
60
|
-
const commitments extends
|
59
|
+
const blobs extends ByteArray[] | Hex[],
|
60
|
+
const commitments extends ByteArray[] | Hex[],
|
61
61
|
to extends To =
|
62
|
-
| (blobs extends
|
63
|
-
| (blobs extends
|
62
|
+
| (blobs extends Hex[] ? 'hex' : never)
|
63
|
+
| (blobs extends ByteArray[] ? 'bytes' : never),
|
64
64
|
>(
|
65
65
|
parameters: blobsToProofsParameters<blobs, commitments, to>,
|
66
66
|
): blobsToProofsReturnType<to> {
|
@@ -8,13 +8,11 @@ import {
|
|
8
8
|
type To = 'hex' | 'bytes'
|
9
9
|
|
10
10
|
export type CommitmentsToVersionedHashesParameters<
|
11
|
-
commitments extends
|
12
|
-
| readonly Uint8Array[]
|
13
|
-
| readonly Hex[],
|
11
|
+
commitments extends Uint8Array[] | Hex[] = Uint8Array[] | Hex[],
|
14
12
|
to extends To | undefined = undefined,
|
15
13
|
> = {
|
16
14
|
/** Commitments from blobs. */
|
17
|
-
commitments: commitments |
|
15
|
+
commitments: commitments | Uint8Array[] | Hex[]
|
18
16
|
/** Return type. */
|
19
17
|
to?: to | To | undefined
|
20
18
|
/** Version to tag onto the hashes. */
|
@@ -22,8 +20,8 @@ export type CommitmentsToVersionedHashesParameters<
|
|
22
20
|
}
|
23
21
|
|
24
22
|
export type CommitmentsToVersionedHashesReturnType<to extends To> =
|
25
|
-
| (to extends 'bytes' ?
|
26
|
-
| (to extends 'hex' ?
|
23
|
+
| (to extends 'bytes' ? ByteArray[] : never)
|
24
|
+
| (to extends 'hex' ? Hex[] : never)
|
27
25
|
|
28
26
|
export type CommitmentsToVersionedHashesErrorType =
|
29
27
|
| CommitmentToVersionedHashErrorType
|
@@ -47,10 +45,10 @@ export type CommitmentsToVersionedHashesErrorType =
|
|
47
45
|
* ```
|
48
46
|
*/
|
49
47
|
export function commitmentsToVersionedHashes<
|
50
|
-
const commitments extends
|
48
|
+
const commitments extends Uint8Array[] | Hex[],
|
51
49
|
to extends To =
|
52
|
-
| (commitments extends
|
53
|
-
| (commitments extends
|
50
|
+
| (commitments extends Hex[] ? 'hex' : never)
|
51
|
+
| (commitments extends ByteArray[] ? 'bytes' : never),
|
54
52
|
>(
|
55
53
|
parameters: CommitmentsToVersionedHashesParameters<commitments, to>,
|
56
54
|
): CommitmentsToVersionedHashesReturnType<to> {
|
@@ -69,5 +67,5 @@ export function commitmentsToVersionedHashes<
|
|
69
67
|
}) as any,
|
70
68
|
)
|
71
69
|
}
|
72
|
-
return hashes as
|
70
|
+
return hashes as CommitmentsToVersionedHashesReturnType<to>
|
73
71
|
}
|
@@ -21,8 +21,8 @@ export type SidecarsToVersionedHashesParameters<
|
|
21
21
|
}
|
22
22
|
|
23
23
|
export type SidecarsToVersionedHashesReturnType<to extends To> =
|
24
|
-
| (to extends 'bytes' ?
|
25
|
-
| (to extends 'hex' ?
|
24
|
+
| (to extends 'bytes' ? ByteArray[] : never)
|
25
|
+
| (to extends 'hex' ? Hex[] : never)
|
26
26
|
|
27
27
|
export type SidecarsToVersionedHashesErrorType =
|
28
28
|
| CommitmentToVersionedHashErrorType
|
@@ -62,5 +62,5 @@ export function sidecarsToVersionedHashes<
|
|
62
62
|
}) as any,
|
63
63
|
)
|
64
64
|
}
|
65
|
-
return hashes as
|
65
|
+
return hashes as SidecarsToVersionedHashesReturnType<to>
|
66
66
|
}
|
@@ -14,14 +14,14 @@ type To = 'hex' | 'bytes'
|
|
14
14
|
|
15
15
|
export type ToBlobSidecarsParameters<
|
16
16
|
data extends Hex | ByteArray | undefined = undefined,
|
17
|
-
blobs extends
|
17
|
+
blobs extends Hex[] | ByteArray[] | undefined = undefined,
|
18
18
|
to extends To =
|
19
|
-
| (blobs extends
|
20
|
-
| (blobs extends
|
19
|
+
| (blobs extends Hex[] ? 'hex' : never)
|
20
|
+
| (blobs extends ByteArray[] ? 'bytes' : never),
|
21
21
|
///
|
22
22
|
_blobsType =
|
23
|
-
| (blobs extends
|
24
|
-
| (blobs extends
|
23
|
+
| (blobs extends Hex[] ? Hex[] : never)
|
24
|
+
| (blobs extends ByteArray[] ? ByteArray[] : never),
|
25
25
|
> = {
|
26
26
|
/** Return type. */
|
27
27
|
to?: to | To | undefined
|
@@ -34,11 +34,11 @@ export type ToBlobSidecarsParameters<
|
|
34
34
|
}
|
35
35
|
| {
|
36
36
|
/** Blobs. */
|
37
|
-
blobs: blobs |
|
37
|
+
blobs: blobs | Hex[] | ByteArray[]
|
38
38
|
/** Commitment for each blob. */
|
39
|
-
commitments: _blobsType |
|
39
|
+
commitments: _blobsType | Hex[] | ByteArray[]
|
40
40
|
/** Proof for each blob. */
|
41
|
-
proofs: _blobsType |
|
41
|
+
proofs: _blobsType | Hex[] | ByteArray[]
|
42
42
|
}
|
43
43
|
>
|
44
44
|
|
@@ -81,15 +81,12 @@ export type ToBlobSidecarsErrorType =
|
|
81
81
|
*/
|
82
82
|
export function toBlobSidecars<
|
83
83
|
const data extends Hex | ByteArray | undefined = undefined,
|
84
|
-
const blobs extends
|
85
|
-
| readonly Hex[]
|
86
|
-
| readonly ByteArray[]
|
87
|
-
| undefined = undefined,
|
84
|
+
const blobs extends Hex[] | ByteArray[] | undefined = undefined,
|
88
85
|
to extends To =
|
89
86
|
| (data extends Hex ? 'hex' : never)
|
90
87
|
| (data extends ByteArray ? 'bytes' : never)
|
91
|
-
| (blobs extends
|
92
|
-
| (blobs extends
|
88
|
+
| (blobs extends Hex[] ? 'hex' : never)
|
89
|
+
| (blobs extends ByteArray[] ? 'bytes' : never),
|
93
90
|
>(
|
94
91
|
parameters: ToBlobSidecarsParameters<data, blobs, to>,
|
95
92
|
): ToBlobSidecarsReturnType<to> {
|
package/utils/blob/toBlobs.ts
CHANGED
@@ -30,8 +30,8 @@ export type ToBlobsParameters<
|
|
30
30
|
}
|
31
31
|
|
32
32
|
export type ToBlobsReturnType<to extends To> =
|
33
|
-
| (to extends 'bytes' ?
|
34
|
-
| (to extends 'hex' ?
|
33
|
+
| (to extends 'bytes' ? ByteArray[] : never)
|
34
|
+
| (to extends 'hex' ? Hex[] : never)
|
35
35
|
|
36
36
|
export type ToBlobsErrorType =
|
37
37
|
| BlobSizeTooLargeErrorType
|
@@ -109,5 +109,5 @@ export function toBlobs<
|
|
109
109
|
to === 'bytes'
|
110
110
|
? blobs.map((x) => x.bytes)
|
111
111
|
: blobs.map((x) => bytesToHex(x.bytes))
|
112
|
-
) as
|
112
|
+
) as ToBlobsReturnType<to>
|
113
113
|
}
|
@@ -34,8 +34,6 @@ export function formatTransactionRequest(
|
|
34
34
|
|
35
35
|
if (typeof request.accessList !== 'undefined')
|
36
36
|
rpcRequest.accessList = request.accessList
|
37
|
-
if (typeof request.blobVersionedHashes !== 'undefined')
|
38
|
-
rpcRequest.blobVersionedHashes = request.blobVersionedHashes
|
39
37
|
if (typeof request.blobs !== 'undefined') {
|
40
38
|
if (typeof request.blobs[0] !== 'string')
|
41
39
|
rpcRequest.blobs = (request.blobs as ByteArray[]).map((x) =>
|
@@ -9,10 +9,10 @@ import type {
|
|
9
9
|
FeeValuesLegacy,
|
10
10
|
} from '../../index.js'
|
11
11
|
import type {
|
12
|
+
TransactionRequest,
|
12
13
|
TransactionRequestEIP1559,
|
13
14
|
TransactionRequestEIP2930,
|
14
15
|
TransactionRequestEIP4844,
|
15
|
-
TransactionRequestGeneric,
|
16
16
|
TransactionRequestLegacy,
|
17
17
|
TransactionSerializableEIP1559,
|
18
18
|
TransactionSerializableEIP2930,
|
@@ -79,7 +79,7 @@ type EIP4844Properties = Assign<
|
|
79
79
|
|
80
80
|
export type GetTransactionType<
|
81
81
|
transaction extends OneOf<
|
82
|
-
TransactionSerializableGeneric |
|
82
|
+
TransactionSerializableGeneric | TransactionRequest
|
83
83
|
> = TransactionSerializableGeneric,
|
84
84
|
result =
|
85
85
|
| (transaction extends
|
@@ -115,7 +115,7 @@ export type GetTransationTypeErrorType =
|
|
115
115
|
|
116
116
|
export function getTransactionType<
|
117
117
|
const transaction extends OneOf<
|
118
|
-
TransactionSerializableGeneric |
|
118
|
+
TransactionSerializableGeneric | TransactionRequest
|
119
119
|
>,
|
120
120
|
>(transaction: transaction): GetTransactionType<transaction> {
|
121
121
|
if (transaction.type)
|
@@ -157,11 +157,7 @@ function serializeTransactionEIP4844(
|
|
157
157
|
let blobVersionedHashes = transaction.blobVersionedHashes
|
158
158
|
let sidecars = transaction.sidecars
|
159
159
|
// If `blobs` are passed, we will need to compute the KZG commitments & proofs.
|
160
|
-
if (
|
161
|
-
transaction.blobs &&
|
162
|
-
(typeof blobVersionedHashes === 'undefined' ||
|
163
|
-
typeof sidecars === 'undefined')
|
164
|
-
) {
|
160
|
+
if (transaction.blobs) {
|
165
161
|
const blobs = (
|
166
162
|
typeof transaction.blobs[0] === 'string'
|
167
163
|
? transaction.blobs
|
@@ -172,15 +168,13 @@ function serializeTransactionEIP4844(
|
|
172
168
|
blobs,
|
173
169
|
kzg,
|
174
170
|
})
|
171
|
+
const proofs = blobsToProofs({ blobs, commitments, kzg })
|
172
|
+
blobVersionedHashes = commitmentsToVersionedHashes({
|
173
|
+
commitments,
|
174
|
+
})
|
175
175
|
|
176
|
-
if (
|
177
|
-
blobVersionedHashes = commitmentsToVersionedHashes({
|
178
|
-
commitments,
|
179
|
-
})
|
180
|
-
if (typeof sidecars === 'undefined') {
|
181
|
-
const proofs = blobsToProofs({ blobs, commitments, kzg })
|
176
|
+
if (sidecars !== false)
|
182
177
|
sidecars = toBlobSidecars({ blobs, commitments, proofs })
|
183
|
-
}
|
184
178
|
}
|
185
179
|
|
186
180
|
const serializedAccessList = serializeAccessList(accessList)
|