@fuel-ts/account 0.83.0 → 0.85.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.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/README.md +15 -12
- package/dist/account.d.ts +6 -6
- package/dist/account.d.ts.map +1 -1
- package/dist/index.global.js +1800 -1753
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +619 -414
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +520 -319
- package/dist/index.mjs.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +532 -615
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/assets/assets.d.ts +9 -0
- package/dist/providers/assets/assets.d.ts.map +1 -0
- package/dist/providers/assets/index.d.ts +1 -2
- package/dist/providers/assets/index.d.ts.map +1 -1
- package/dist/providers/assets/utils/fuelAssetsBaseUrl.d.ts +2 -0
- package/dist/providers/assets/utils/fuelAssetsBaseUrl.d.ts.map +1 -0
- package/dist/providers/assets/utils/index.d.ts +1 -0
- package/dist/providers/assets/utils/index.d.ts.map +1 -1
- package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +1 -1
- package/dist/providers/message.d.ts +2 -2
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +28 -31
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/resource.d.ts +0 -1
- package/dist/providers/resource.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts +8 -0
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -0
- package/dist/providers/transaction-request/script-transaction-request.d.ts +2 -3
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +5 -6
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +2 -1
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -2
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts +20 -0
- package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts.map +1 -0
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/index.d.ts +1 -1
- package/dist/providers/transaction-summary/index.d.ts.map +1 -1
- package/dist/providers/transaction-summary/operations.d.ts +4 -0
- package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
- package/dist/providers/transaction-summary/receipt.d.ts +2 -2
- package/dist/providers/transaction-summary/receipt.d.ts.map +1 -1
- package/dist/providers/transaction-summary/status.d.ts +5 -1
- package/dist/providers/transaction-summary/status.d.ts.map +1 -1
- package/dist/providers/transaction-summary/types.d.ts +11 -14
- package/dist/providers/transaction-summary/types.d.ts.map +1 -1
- package/dist/providers/utils/extract-tx-error.d.ts +2 -2
- package/dist/providers/utils/extract-tx-error.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +7 -6
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/providers/utils/receipts.d.ts +2 -2
- package/dist/providers/utils/receipts.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/resources.d.ts +4 -0
- package/dist/test-utils/resources.d.ts.map +1 -0
- package/dist/test-utils/transactionRequest.d.ts +5 -0
- package/dist/test-utils/transactionRequest.d.ts.map +1 -0
- package/dist/test-utils.global.js +1826 -1756
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +609 -398
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +521 -310
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +17 -17
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +0 -22
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +0 -1
package/dist/test-utils.js
CHANGED
@@ -58,14 +58,14 @@ module.exports = __toCommonJS(test_utils_exports);
|
|
58
58
|
|
59
59
|
// src/wallet/base-wallet-unlocked.ts
|
60
60
|
var import_hasher3 = require("@fuel-ts/hasher");
|
61
|
-
var
|
61
|
+
var import_utils31 = require("@fuel-ts/utils");
|
62
62
|
|
63
63
|
// src/account.ts
|
64
64
|
var import_address4 = require("@fuel-ts/address");
|
65
65
|
var import_errors16 = require("@fuel-ts/errors");
|
66
66
|
var import_interfaces = require("@fuel-ts/interfaces");
|
67
|
-
var
|
68
|
-
var
|
67
|
+
var import_math21 = require("@fuel-ts/math");
|
68
|
+
var import_utils28 = require("@fuel-ts/utils");
|
69
69
|
var import_ramda4 = require("ramda");
|
70
70
|
|
71
71
|
// src/providers/coin-quantity.ts
|
@@ -106,18 +106,17 @@ var addAmountToCoinQuantities = (params) => {
|
|
106
106
|
// src/providers/provider.ts
|
107
107
|
var import_address3 = require("@fuel-ts/address");
|
108
108
|
var import_errors14 = require("@fuel-ts/errors");
|
109
|
-
var
|
109
|
+
var import_math17 = require("@fuel-ts/math");
|
110
110
|
var import_transactions19 = require("@fuel-ts/transactions");
|
111
111
|
var import_utils22 = require("@fuel-ts/utils");
|
112
112
|
var import_versions = require("@fuel-ts/versions");
|
113
113
|
var import_utils23 = require("@noble/curves/abstract/utils");
|
114
|
-
var import_ethers = require("ethers");
|
115
114
|
var import_graphql_request = require("graphql-request");
|
116
115
|
var import_ramda3 = require("ramda");
|
117
116
|
|
118
117
|
// src/providers/__generated__/operations.ts
|
119
118
|
var import_graphql_tag = __toESM(require("graphql-tag"));
|
120
|
-
var
|
119
|
+
var TransactionStatusSubscriptionFragmentDoc = import_graphql_tag.default`
|
121
120
|
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
122
121
|
type: __typename
|
123
122
|
... on SqueezedOutStatus {
|
@@ -125,7 +124,13 @@ var TransactionStatusSubscriptionFragmentFragmentDoc = import_graphql_tag.defaul
|
|
125
124
|
}
|
126
125
|
}
|
127
126
|
`;
|
128
|
-
var
|
127
|
+
var SubmittedStatusFragmentDoc = import_graphql_tag.default`
|
128
|
+
fragment SubmittedStatusFragment on SubmittedStatus {
|
129
|
+
type: __typename
|
130
|
+
time
|
131
|
+
}
|
132
|
+
`;
|
133
|
+
var ReceiptFragmentDoc = import_graphql_tag.default`
|
129
134
|
fragment receiptFragment on Receipt {
|
130
135
|
id
|
131
136
|
pc
|
@@ -157,44 +162,65 @@ var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
|
|
157
162
|
subId
|
158
163
|
}
|
159
164
|
`;
|
160
|
-
var
|
161
|
-
fragment
|
165
|
+
var SuccessStatusFragmentDoc = import_graphql_tag.default`
|
166
|
+
fragment SuccessStatusFragment on SuccessStatus {
|
167
|
+
type: __typename
|
168
|
+
block {
|
169
|
+
id
|
170
|
+
}
|
171
|
+
time
|
172
|
+
programState {
|
173
|
+
returnType
|
174
|
+
data
|
175
|
+
}
|
176
|
+
receipts {
|
177
|
+
...receiptFragment
|
178
|
+
}
|
179
|
+
totalGas
|
180
|
+
totalFee
|
181
|
+
}
|
182
|
+
${ReceiptFragmentDoc}`;
|
183
|
+
var FailureStatusFragmentDoc = import_graphql_tag.default`
|
184
|
+
fragment FailureStatusFragment on FailureStatus {
|
162
185
|
type: __typename
|
186
|
+
block {
|
187
|
+
id
|
188
|
+
}
|
189
|
+
totalGas
|
190
|
+
totalFee
|
191
|
+
time
|
192
|
+
reason
|
193
|
+
receipts {
|
194
|
+
...receiptFragment
|
195
|
+
}
|
196
|
+
}
|
197
|
+
${ReceiptFragmentDoc}`;
|
198
|
+
var SqueezedOutStatusFragmentDoc = import_graphql_tag.default`
|
199
|
+
fragment SqueezedOutStatusFragment on SqueezedOutStatus {
|
200
|
+
type: __typename
|
201
|
+
reason
|
202
|
+
}
|
203
|
+
`;
|
204
|
+
var TransactionStatusFragmentDoc = import_graphql_tag.default`
|
205
|
+
fragment transactionStatusFragment on TransactionStatus {
|
163
206
|
... on SubmittedStatus {
|
164
|
-
|
207
|
+
...SubmittedStatusFragment
|
165
208
|
}
|
166
209
|
... on SuccessStatus {
|
167
|
-
|
168
|
-
id
|
169
|
-
}
|
170
|
-
time
|
171
|
-
receipts {
|
172
|
-
...receiptFragment
|
173
|
-
}
|
174
|
-
programState {
|
175
|
-
returnType
|
176
|
-
data
|
177
|
-
}
|
178
|
-
receipts {
|
179
|
-
...receiptFragment
|
180
|
-
}
|
210
|
+
...SuccessStatusFragment
|
181
211
|
}
|
182
212
|
... on FailureStatus {
|
183
|
-
|
184
|
-
id
|
185
|
-
}
|
186
|
-
time
|
187
|
-
reason
|
188
|
-
receipts {
|
189
|
-
...receiptFragment
|
190
|
-
}
|
213
|
+
...FailureStatusFragment
|
191
214
|
}
|
192
215
|
... on SqueezedOutStatus {
|
193
|
-
|
216
|
+
...SqueezedOutStatusFragment
|
194
217
|
}
|
195
218
|
}
|
196
|
-
${
|
197
|
-
|
219
|
+
${SubmittedStatusFragmentDoc}
|
220
|
+
${SuccessStatusFragmentDoc}
|
221
|
+
${FailureStatusFragmentDoc}
|
222
|
+
${SqueezedOutStatusFragmentDoc}`;
|
223
|
+
var TransactionFragmentDoc = import_graphql_tag.default`
|
198
224
|
fragment transactionFragment on Transaction {
|
199
225
|
id
|
200
226
|
rawPayload
|
@@ -202,8 +228,8 @@ var TransactionFragmentFragmentDoc = import_graphql_tag.default`
|
|
202
228
|
...transactionStatusFragment
|
203
229
|
}
|
204
230
|
}
|
205
|
-
${
|
206
|
-
var
|
231
|
+
${TransactionStatusFragmentDoc}`;
|
232
|
+
var InputEstimatePredicatesFragmentDoc = import_graphql_tag.default`
|
207
233
|
fragment inputEstimatePredicatesFragment on Input {
|
208
234
|
... on InputCoin {
|
209
235
|
predicateGasUsed
|
@@ -213,15 +239,17 @@ var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
|
|
213
239
|
}
|
214
240
|
}
|
215
241
|
`;
|
216
|
-
var
|
242
|
+
var TransactionEstimatePredicatesFragmentDoc = import_graphql_tag.default`
|
217
243
|
fragment transactionEstimatePredicatesFragment on Transaction {
|
218
244
|
inputs {
|
219
245
|
...inputEstimatePredicatesFragment
|
220
246
|
}
|
221
247
|
}
|
222
|
-
${
|
223
|
-
var
|
248
|
+
${InputEstimatePredicatesFragmentDoc}`;
|
249
|
+
var DryRunFailureStatusFragmentDoc = import_graphql_tag.default`
|
224
250
|
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
251
|
+
totalGas
|
252
|
+
totalFee
|
225
253
|
reason
|
226
254
|
programState {
|
227
255
|
returnType
|
@@ -229,15 +257,17 @@ var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
229
257
|
}
|
230
258
|
}
|
231
259
|
`;
|
232
|
-
var
|
260
|
+
var DryRunSuccessStatusFragmentDoc = import_graphql_tag.default`
|
233
261
|
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
262
|
+
totalGas
|
263
|
+
totalFee
|
234
264
|
programState {
|
235
265
|
returnType
|
236
266
|
data
|
237
267
|
}
|
238
268
|
}
|
239
269
|
`;
|
240
|
-
var
|
270
|
+
var DryRunTransactionStatusFragmentDoc = import_graphql_tag.default`
|
241
271
|
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
242
272
|
... on DryRunFailureStatus {
|
243
273
|
...dryRunFailureStatusFragment
|
@@ -246,9 +276,9 @@ var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
246
276
|
...dryRunSuccessStatusFragment
|
247
277
|
}
|
248
278
|
}
|
249
|
-
${
|
250
|
-
${
|
251
|
-
var
|
279
|
+
${DryRunFailureStatusFragmentDoc}
|
280
|
+
${DryRunSuccessStatusFragmentDoc}`;
|
281
|
+
var DryRunTransactionExecutionStatusFragmentDoc = import_graphql_tag.default`
|
252
282
|
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
253
283
|
id
|
254
284
|
status {
|
@@ -258,11 +288,11 @@ var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.def
|
|
258
288
|
...receiptFragment
|
259
289
|
}
|
260
290
|
}
|
261
|
-
${
|
262
|
-
${
|
263
|
-
var
|
291
|
+
${DryRunTransactionStatusFragmentDoc}
|
292
|
+
${ReceiptFragmentDoc}`;
|
293
|
+
var CoinFragmentDoc = import_graphql_tag.default`
|
264
294
|
fragment coinFragment on Coin {
|
265
|
-
__typename
|
295
|
+
type: __typename
|
266
296
|
utxoId
|
267
297
|
owner
|
268
298
|
amount
|
@@ -271,9 +301,9 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
|
|
271
301
|
txCreatedIdx
|
272
302
|
}
|
273
303
|
`;
|
274
|
-
var
|
304
|
+
var MessageCoinFragmentDoc = import_graphql_tag.default`
|
275
305
|
fragment messageCoinFragment on MessageCoin {
|
276
|
-
__typename
|
306
|
+
type: __typename
|
277
307
|
sender
|
278
308
|
recipient
|
279
309
|
nonce
|
@@ -282,7 +312,7 @@ var MessageCoinFragmentFragmentDoc = import_graphql_tag.default`
|
|
282
312
|
daHeight
|
283
313
|
}
|
284
314
|
`;
|
285
|
-
var
|
315
|
+
var MessageFragmentDoc = import_graphql_tag.default`
|
286
316
|
fragment messageFragment on Message {
|
287
317
|
amount
|
288
318
|
sender
|
@@ -292,7 +322,7 @@ var MessageFragmentFragmentDoc = import_graphql_tag.default`
|
|
292
322
|
daHeight
|
293
323
|
}
|
294
324
|
`;
|
295
|
-
var
|
325
|
+
var MessageProofFragmentDoc = import_graphql_tag.default`
|
296
326
|
fragment messageProofFragment on MessageProof {
|
297
327
|
messageProof {
|
298
328
|
proofSet
|
@@ -339,14 +369,14 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
|
|
339
369
|
data
|
340
370
|
}
|
341
371
|
`;
|
342
|
-
var
|
372
|
+
var BalanceFragmentDoc = import_graphql_tag.default`
|
343
373
|
fragment balanceFragment on Balance {
|
344
374
|
owner
|
345
375
|
amount
|
346
376
|
assetId
|
347
377
|
}
|
348
378
|
`;
|
349
|
-
var
|
379
|
+
var BlockFragmentDoc = import_graphql_tag.default`
|
350
380
|
fragment blockFragment on Block {
|
351
381
|
id
|
352
382
|
height
|
@@ -358,7 +388,7 @@ var BlockFragmentFragmentDoc = import_graphql_tag.default`
|
|
358
388
|
}
|
359
389
|
}
|
360
390
|
`;
|
361
|
-
var
|
391
|
+
var TxParametersFragmentDoc = import_graphql_tag.default`
|
362
392
|
fragment TxParametersFragment on TxParameters {
|
363
393
|
version
|
364
394
|
maxInputs
|
@@ -366,9 +396,10 @@ var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
|
|
366
396
|
maxWitnesses
|
367
397
|
maxGasPerTx
|
368
398
|
maxSize
|
399
|
+
maxBytecodeSubsections
|
369
400
|
}
|
370
401
|
`;
|
371
|
-
var
|
402
|
+
var PredicateParametersFragmentDoc = import_graphql_tag.default`
|
372
403
|
fragment PredicateParametersFragment on PredicateParameters {
|
373
404
|
version
|
374
405
|
maxPredicateLength
|
@@ -377,41 +408,42 @@ var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
|
|
377
408
|
maxMessageDataLength
|
378
409
|
}
|
379
410
|
`;
|
380
|
-
var
|
411
|
+
var ScriptParametersFragmentDoc = import_graphql_tag.default`
|
381
412
|
fragment ScriptParametersFragment on ScriptParameters {
|
382
413
|
version
|
383
414
|
maxScriptLength
|
384
415
|
maxScriptDataLength
|
385
416
|
}
|
386
417
|
`;
|
387
|
-
var
|
418
|
+
var ContractParametersFragmentDoc = import_graphql_tag.default`
|
388
419
|
fragment ContractParametersFragment on ContractParameters {
|
389
420
|
version
|
390
421
|
contractMaxSize
|
391
422
|
maxStorageSlots
|
392
423
|
}
|
393
424
|
`;
|
394
|
-
var
|
425
|
+
var FeeParametersFragmentDoc = import_graphql_tag.default`
|
395
426
|
fragment FeeParametersFragment on FeeParameters {
|
396
427
|
version
|
397
428
|
gasPriceFactor
|
398
429
|
gasPerByte
|
399
430
|
}
|
400
431
|
`;
|
401
|
-
var
|
432
|
+
var DependentCostFragmentDoc = import_graphql_tag.default`
|
402
433
|
fragment DependentCostFragment on DependentCost {
|
403
|
-
__typename
|
404
434
|
... on LightOperation {
|
435
|
+
type: __typename
|
405
436
|
base
|
406
437
|
unitsPerGas
|
407
438
|
}
|
408
439
|
... on HeavyOperation {
|
440
|
+
type: __typename
|
409
441
|
base
|
410
442
|
gasPerUnit
|
411
443
|
}
|
412
444
|
}
|
413
445
|
`;
|
414
|
-
var
|
446
|
+
var GasCostsFragmentDoc = import_graphql_tag.default`
|
415
447
|
fragment GasCostsFragment on GasCosts {
|
416
448
|
version
|
417
449
|
add
|
@@ -567,8 +599,8 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
|
567
599
|
}
|
568
600
|
newStoragePerByte
|
569
601
|
}
|
570
|
-
${
|
571
|
-
var
|
602
|
+
${DependentCostFragmentDoc}`;
|
603
|
+
var ConsensusParametersFragmentDoc = import_graphql_tag.default`
|
572
604
|
fragment consensusParametersFragment on ConsensusParameters {
|
573
605
|
version
|
574
606
|
txParams {
|
@@ -592,13 +624,13 @@ var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
|
|
592
624
|
baseAssetId
|
593
625
|
chainId
|
594
626
|
}
|
595
|
-
${
|
596
|
-
${
|
597
|
-
${
|
598
|
-
${
|
599
|
-
${
|
600
|
-
${
|
601
|
-
var
|
627
|
+
${TxParametersFragmentDoc}
|
628
|
+
${PredicateParametersFragmentDoc}
|
629
|
+
${ScriptParametersFragmentDoc}
|
630
|
+
${ContractParametersFragmentDoc}
|
631
|
+
${FeeParametersFragmentDoc}
|
632
|
+
${GasCostsFragmentDoc}`;
|
633
|
+
var ChainInfoFragmentDoc = import_graphql_tag.default`
|
602
634
|
fragment chainInfoFragment on ChainInfo {
|
603
635
|
name
|
604
636
|
latestBlock {
|
@@ -609,16 +641,16 @@ var ChainInfoFragmentFragmentDoc = import_graphql_tag.default`
|
|
609
641
|
...consensusParametersFragment
|
610
642
|
}
|
611
643
|
}
|
612
|
-
${
|
613
|
-
${
|
614
|
-
var
|
644
|
+
${BlockFragmentDoc}
|
645
|
+
${ConsensusParametersFragmentDoc}`;
|
646
|
+
var ContractBalanceFragmentDoc = import_graphql_tag.default`
|
615
647
|
fragment contractBalanceFragment on ContractBalance {
|
616
648
|
contract
|
617
649
|
amount
|
618
650
|
assetId
|
619
651
|
}
|
620
652
|
`;
|
621
|
-
var
|
653
|
+
var PageInfoFragmentDoc = import_graphql_tag.default`
|
622
654
|
fragment pageInfoFragment on PageInfo {
|
623
655
|
hasPreviousPage
|
624
656
|
hasNextPage
|
@@ -626,7 +658,7 @@ var PageInfoFragmentFragmentDoc = import_graphql_tag.default`
|
|
626
658
|
endCursor
|
627
659
|
}
|
628
660
|
`;
|
629
|
-
var
|
661
|
+
var NodeInfoFragmentDoc = import_graphql_tag.default`
|
630
662
|
fragment nodeInfoFragment on NodeInfo {
|
631
663
|
utxoValidation
|
632
664
|
vmBacktrace
|
@@ -635,6 +667,14 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
|
|
635
667
|
nodeVersion
|
636
668
|
}
|
637
669
|
`;
|
670
|
+
var RelayedTransactionStatusFragmentDoc = import_graphql_tag.default`
|
671
|
+
fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
|
672
|
+
... on RelayedTransactionFailed {
|
673
|
+
blockHeight
|
674
|
+
failure
|
675
|
+
}
|
676
|
+
}
|
677
|
+
`;
|
638
678
|
var GetVersionDocument = import_graphql_tag.default`
|
639
679
|
query getVersion {
|
640
680
|
nodeInfo {
|
@@ -648,28 +688,28 @@ var GetNodeInfoDocument = import_graphql_tag.default`
|
|
648
688
|
...nodeInfoFragment
|
649
689
|
}
|
650
690
|
}
|
651
|
-
${
|
691
|
+
${NodeInfoFragmentDoc}`;
|
652
692
|
var GetChainDocument = import_graphql_tag.default`
|
653
693
|
query getChain {
|
654
694
|
chain {
|
655
695
|
...chainInfoFragment
|
656
696
|
}
|
657
697
|
}
|
658
|
-
${
|
698
|
+
${ChainInfoFragmentDoc}`;
|
659
699
|
var GetTransactionDocument = import_graphql_tag.default`
|
660
700
|
query getTransaction($transactionId: TransactionId!) {
|
661
701
|
transaction(id: $transactionId) {
|
662
702
|
...transactionFragment
|
663
703
|
}
|
664
704
|
}
|
665
|
-
${
|
705
|
+
${TransactionFragmentDoc}`;
|
666
706
|
var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
|
667
707
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
668
708
|
transaction(id: $transactionId) {
|
669
709
|
...transactionFragment
|
670
710
|
}
|
671
711
|
}
|
672
|
-
${
|
712
|
+
${TransactionFragmentDoc}`;
|
673
713
|
var GetTransactionsDocument = import_graphql_tag.default`
|
674
714
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
675
715
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -680,7 +720,7 @@ var GetTransactionsDocument = import_graphql_tag.default`
|
|
680
720
|
}
|
681
721
|
}
|
682
722
|
}
|
683
|
-
${
|
723
|
+
${TransactionFragmentDoc}`;
|
684
724
|
var GetTransactionsByOwnerDocument = import_graphql_tag.default`
|
685
725
|
query getTransactionsByOwner($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
686
726
|
transactionsByOwner(
|
@@ -700,22 +740,22 @@ var GetTransactionsByOwnerDocument = import_graphql_tag.default`
|
|
700
740
|
}
|
701
741
|
}
|
702
742
|
}
|
703
|
-
${
|
704
|
-
${
|
743
|
+
${PageInfoFragmentDoc}
|
744
|
+
${TransactionFragmentDoc}`;
|
705
745
|
var EstimatePredicatesDocument = import_graphql_tag.default`
|
706
746
|
query estimatePredicates($encodedTransaction: HexString!) {
|
707
747
|
estimatePredicates(tx: $encodedTransaction) {
|
708
748
|
...transactionEstimatePredicatesFragment
|
709
749
|
}
|
710
750
|
}
|
711
|
-
${
|
751
|
+
${TransactionEstimatePredicatesFragmentDoc}`;
|
712
752
|
var GetBlockDocument = import_graphql_tag.default`
|
713
753
|
query getBlock($blockId: BlockId, $height: U32) {
|
714
754
|
block(id: $blockId, height: $height) {
|
715
755
|
...blockFragment
|
716
756
|
}
|
717
757
|
}
|
718
|
-
${
|
758
|
+
${BlockFragmentDoc}`;
|
719
759
|
var GetBlockWithTransactionsDocument = import_graphql_tag.default`
|
720
760
|
query getBlockWithTransactions($blockId: BlockId, $blockHeight: U32) {
|
721
761
|
block(id: $blockId, height: $blockHeight) {
|
@@ -725,8 +765,8 @@ var GetBlockWithTransactionsDocument = import_graphql_tag.default`
|
|
725
765
|
}
|
726
766
|
}
|
727
767
|
}
|
728
|
-
${
|
729
|
-
${
|
768
|
+
${BlockFragmentDoc}
|
769
|
+
${TransactionFragmentDoc}`;
|
730
770
|
var GetBlocksDocument = import_graphql_tag.default`
|
731
771
|
query getBlocks($after: String, $before: String, $first: Int, $last: Int) {
|
732
772
|
blocks(after: $after, before: $before, first: $first, last: $last) {
|
@@ -737,14 +777,14 @@ var GetBlocksDocument = import_graphql_tag.default`
|
|
737
777
|
}
|
738
778
|
}
|
739
779
|
}
|
740
|
-
${
|
780
|
+
${BlockFragmentDoc}`;
|
741
781
|
var GetCoinDocument = import_graphql_tag.default`
|
742
782
|
query getCoin($coinId: UtxoId!) {
|
743
783
|
coin(utxoId: $coinId) {
|
744
784
|
...coinFragment
|
745
785
|
}
|
746
786
|
}
|
747
|
-
${
|
787
|
+
${CoinFragmentDoc}`;
|
748
788
|
var GetCoinsDocument = import_graphql_tag.default`
|
749
789
|
query getCoins($filter: CoinFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
750
790
|
coins(
|
@@ -761,7 +801,7 @@ var GetCoinsDocument = import_graphql_tag.default`
|
|
761
801
|
}
|
762
802
|
}
|
763
803
|
}
|
764
|
-
${
|
804
|
+
${CoinFragmentDoc}`;
|
765
805
|
var GetCoinsToSpendDocument = import_graphql_tag.default`
|
766
806
|
query getCoinsToSpend($owner: Address!, $queryPerAsset: [SpendQueryElementInput!]!, $excludedIds: ExcludeInput) {
|
767
807
|
coinsToSpend(
|
@@ -773,8 +813,8 @@ var GetCoinsToSpendDocument = import_graphql_tag.default`
|
|
773
813
|
...messageCoinFragment
|
774
814
|
}
|
775
815
|
}
|
776
|
-
${
|
777
|
-
${
|
816
|
+
${CoinFragmentDoc}
|
817
|
+
${MessageCoinFragmentDoc}`;
|
778
818
|
var GetContractDocument = import_graphql_tag.default`
|
779
819
|
query getContract($contractId: ContractId!) {
|
780
820
|
contract(id: $contractId) {
|
@@ -789,14 +829,14 @@ var GetContractBalanceDocument = import_graphql_tag.default`
|
|
789
829
|
...contractBalanceFragment
|
790
830
|
}
|
791
831
|
}
|
792
|
-
${
|
832
|
+
${ContractBalanceFragmentDoc}`;
|
793
833
|
var GetBalanceDocument = import_graphql_tag.default`
|
794
834
|
query getBalance($owner: Address!, $assetId: AssetId!) {
|
795
835
|
balance(owner: $owner, assetId: $assetId) {
|
796
836
|
...balanceFragment
|
797
837
|
}
|
798
838
|
}
|
799
|
-
${
|
839
|
+
${BalanceFragmentDoc}`;
|
800
840
|
var GetLatestGasPriceDocument = import_graphql_tag.default`
|
801
841
|
query getLatestGasPrice {
|
802
842
|
latestGasPrice {
|
@@ -827,7 +867,7 @@ var GetBalancesDocument = import_graphql_tag.default`
|
|
827
867
|
}
|
828
868
|
}
|
829
869
|
}
|
830
|
-
${
|
870
|
+
${BalanceFragmentDoc}`;
|
831
871
|
var GetMessagesDocument = import_graphql_tag.default`
|
832
872
|
query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
833
873
|
messages(
|
@@ -844,7 +884,7 @@ var GetMessagesDocument = import_graphql_tag.default`
|
|
844
884
|
}
|
845
885
|
}
|
846
886
|
}
|
847
|
-
${
|
887
|
+
${MessageFragmentDoc}`;
|
848
888
|
var GetMessageProofDocument = import_graphql_tag.default`
|
849
889
|
query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
|
850
890
|
messageProof(
|
@@ -856,7 +896,7 @@ var GetMessageProofDocument = import_graphql_tag.default`
|
|
856
896
|
...messageProofFragment
|
857
897
|
}
|
858
898
|
}
|
859
|
-
${
|
899
|
+
${MessageProofFragmentDoc}`;
|
860
900
|
var GetMessageStatusDocument = import_graphql_tag.default`
|
861
901
|
query getMessageStatus($nonce: Nonce!) {
|
862
902
|
messageStatus(nonce: $nonce) {
|
@@ -864,13 +904,20 @@ var GetMessageStatusDocument = import_graphql_tag.default`
|
|
864
904
|
}
|
865
905
|
}
|
866
906
|
`;
|
907
|
+
var GetRelayedTransactionStatusDocument = import_graphql_tag.default`
|
908
|
+
query getRelayedTransactionStatus($relayedTransactionId: RelayedTransactionId!) {
|
909
|
+
relayedTransactionStatus(id: $relayedTransactionId) {
|
910
|
+
...relayedTransactionStatusFragment
|
911
|
+
}
|
912
|
+
}
|
913
|
+
${RelayedTransactionStatusFragmentDoc}`;
|
867
914
|
var DryRunDocument = import_graphql_tag.default`
|
868
915
|
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
869
916
|
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
870
917
|
...dryRunTransactionExecutionStatusFragment
|
871
918
|
}
|
872
919
|
}
|
873
|
-
${
|
920
|
+
${DryRunTransactionExecutionStatusFragmentDoc}`;
|
874
921
|
var SubmitDocument = import_graphql_tag.default`
|
875
922
|
mutation submit($encodedTransaction: HexString!) {
|
876
923
|
submit(tx: $encodedTransaction) {
|
@@ -886,20 +933,27 @@ var ProduceBlocksDocument = import_graphql_tag.default`
|
|
886
933
|
)
|
887
934
|
}
|
888
935
|
`;
|
936
|
+
var GetMessageByNonceDocument = import_graphql_tag.default`
|
937
|
+
query getMessageByNonce($nonce: Nonce!) {
|
938
|
+
message(nonce: $nonce) {
|
939
|
+
...messageFragment
|
940
|
+
}
|
941
|
+
}
|
942
|
+
${MessageFragmentDoc}`;
|
889
943
|
var SubmitAndAwaitDocument = import_graphql_tag.default`
|
890
944
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
891
945
|
submitAndAwait(tx: $encodedTransaction) {
|
892
946
|
...transactionStatusSubscriptionFragment
|
893
947
|
}
|
894
948
|
}
|
895
|
-
${
|
949
|
+
${TransactionStatusSubscriptionFragmentDoc}`;
|
896
950
|
var StatusChangeDocument = import_graphql_tag.default`
|
897
951
|
subscription statusChange($transactionId: TransactionId!) {
|
898
952
|
statusChange(id: $transactionId) {
|
899
953
|
...transactionStatusSubscriptionFragment
|
900
954
|
}
|
901
955
|
}
|
902
|
-
${
|
956
|
+
${TransactionStatusSubscriptionFragmentDoc}`;
|
903
957
|
function getSdk(requester) {
|
904
958
|
return {
|
905
959
|
getVersion(variables, options) {
|
@@ -971,6 +1025,9 @@ function getSdk(requester) {
|
|
971
1025
|
getMessageStatus(variables, options) {
|
972
1026
|
return requester(GetMessageStatusDocument, variables, options);
|
973
1027
|
},
|
1028
|
+
getRelayedTransactionStatus(variables, options) {
|
1029
|
+
return requester(GetRelayedTransactionStatusDocument, variables, options);
|
1030
|
+
},
|
974
1031
|
dryRun(variables, options) {
|
975
1032
|
return requester(DryRunDocument, variables, options);
|
976
1033
|
},
|
@@ -980,6 +1037,9 @@ function getSdk(requester) {
|
|
980
1037
|
produceBlocks(variables, options) {
|
981
1038
|
return requester(ProduceBlocksDocument, variables, options);
|
982
1039
|
},
|
1040
|
+
getMessageByNonce(variables, options) {
|
1041
|
+
return requester(GetMessageByNonceDocument, variables, options);
|
1042
|
+
},
|
983
1043
|
submitAndAwait(variables, options) {
|
984
1044
|
return requester(SubmitAndAwaitDocument, variables, options);
|
985
1045
|
},
|
@@ -1494,10 +1554,9 @@ var getGasUsedFromReceipts = (receipts) => {
|
|
1494
1554
|
function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
1495
1555
|
const base = (0, import_math5.bn)(gasDependentCost.base);
|
1496
1556
|
let dependentValue = (0, import_math5.bn)(0);
|
1497
|
-
if (
|
1557
|
+
if ("unitsPerGas" in gasDependentCost) {
|
1498
1558
|
dependentValue = (0, import_math5.bn)(byteSize).div((0, import_math5.bn)(gasDependentCost.unitsPerGas));
|
1499
|
-
}
|
1500
|
-
if (gasDependentCost.__typename === "HeavyOperation") {
|
1559
|
+
} else {
|
1501
1560
|
dependentValue = (0, import_math5.bn)(byteSize).mul((0, import_math5.bn)(gasDependentCost.gasPerUnit));
|
1502
1561
|
}
|
1503
1562
|
return base.add(dependentValue);
|
@@ -1574,7 +1633,7 @@ function calculateMetadataGasForTxScript({
|
|
1574
1633
|
}
|
1575
1634
|
var calculateGasFee = (params) => {
|
1576
1635
|
const { gas, gasPrice, priceFactor, tip } = params;
|
1577
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1636
|
+
return gas.mul(gasPrice).div(priceFactor).add((0, import_math5.bn)(tip));
|
1578
1637
|
};
|
1579
1638
|
|
1580
1639
|
// src/providers/utils/json.ts
|
@@ -1739,10 +1798,10 @@ var BaseTransactionRequest = class {
|
|
1739
1798
|
outputs,
|
1740
1799
|
witnesses
|
1741
1800
|
} = {}) {
|
1742
|
-
this.tip = (0, import_math7.bn)(tip);
|
1743
|
-
this.maturity = maturity
|
1744
|
-
this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
|
1745
|
-
this.maxFee =
|
1801
|
+
this.tip = tip ? (0, import_math7.bn)(tip) : void 0;
|
1802
|
+
this.maturity = maturity && maturity > 0 ? maturity : void 0;
|
1803
|
+
this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0, import_math7.bn)(witnessLimit) : void 0;
|
1804
|
+
this.maxFee = (0, import_math7.bn)(maxFee);
|
1746
1805
|
this.inputs = inputs ?? [];
|
1747
1806
|
this.outputs = outputs ?? [];
|
1748
1807
|
this.witnesses = witnesses ?? [];
|
@@ -1750,22 +1809,21 @@ var BaseTransactionRequest = class {
|
|
1750
1809
|
static getPolicyMeta(req) {
|
1751
1810
|
let policyTypes = 0;
|
1752
1811
|
const policies = [];
|
1753
|
-
|
1812
|
+
const { tip, witnessLimit, maturity } = req;
|
1813
|
+
if ((0, import_math7.bn)(tip).gt(0)) {
|
1754
1814
|
policyTypes += import_transactions6.PolicyType.Tip;
|
1755
|
-
policies.push({ data:
|
1815
|
+
policies.push({ data: (0, import_math7.bn)(tip), type: import_transactions6.PolicyType.Tip });
|
1756
1816
|
}
|
1757
|
-
if (
|
1817
|
+
if ((0, import_utils9.isDefined)(witnessLimit) && (0, import_math7.bn)(witnessLimit).gte(0)) {
|
1758
1818
|
policyTypes += import_transactions6.PolicyType.WitnessLimit;
|
1759
|
-
policies.push({ data:
|
1819
|
+
policies.push({ data: (0, import_math7.bn)(witnessLimit), type: import_transactions6.PolicyType.WitnessLimit });
|
1760
1820
|
}
|
1761
|
-
if (
|
1821
|
+
if (maturity && maturity > 0) {
|
1762
1822
|
policyTypes += import_transactions6.PolicyType.Maturity;
|
1763
|
-
policies.push({ data:
|
1764
|
-
}
|
1765
|
-
if (req.maxFee) {
|
1766
|
-
policyTypes += import_transactions6.PolicyType.MaxFee;
|
1767
|
-
policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
|
1823
|
+
policies.push({ data: maturity, type: import_transactions6.PolicyType.Maturity });
|
1768
1824
|
}
|
1825
|
+
policyTypes += import_transactions6.PolicyType.MaxFee;
|
1826
|
+
policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
|
1769
1827
|
return {
|
1770
1828
|
policyTypes,
|
1771
1829
|
policies
|
@@ -2081,8 +2139,11 @@ var BaseTransactionRequest = class {
|
|
2081
2139
|
* @hidden
|
2082
2140
|
*/
|
2083
2141
|
calculateMinGas(chainInfo) {
|
2084
|
-
const {
|
2085
|
-
const {
|
2142
|
+
const { consensusParameters } = chainInfo;
|
2143
|
+
const {
|
2144
|
+
gasCosts,
|
2145
|
+
feeParameters: { gasPerByte }
|
2146
|
+
} = consensusParameters;
|
2086
2147
|
return getMinGas({
|
2087
2148
|
gasPerByte,
|
2088
2149
|
gasCosts,
|
@@ -2093,7 +2154,10 @@ var BaseTransactionRequest = class {
|
|
2093
2154
|
}
|
2094
2155
|
calculateMaxGas(chainInfo, minGas) {
|
2095
2156
|
const { consensusParameters } = chainInfo;
|
2096
|
-
const {
|
2157
|
+
const {
|
2158
|
+
feeParameters: { gasPerByte },
|
2159
|
+
txParameters: { maxGasPerTx }
|
2160
|
+
} = consensusParameters;
|
2097
2161
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2098
2162
|
(acc, wit) => acc + wit.dataLength,
|
2099
2163
|
0
|
@@ -2528,7 +2592,10 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2528
2592
|
}
|
2529
2593
|
calculateMaxGas(chainInfo, minGas) {
|
2530
2594
|
const { consensusParameters } = chainInfo;
|
2531
|
-
const {
|
2595
|
+
const {
|
2596
|
+
feeParameters: { gasPerByte },
|
2597
|
+
txParameters: { maxGasPerTx }
|
2598
|
+
} = consensusParameters;
|
2532
2599
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2533
2600
|
(acc, wit) => acc + wit.dataLength,
|
2534
2601
|
0
|
@@ -2616,10 +2683,10 @@ var transactionRequestify = (obj) => {
|
|
2616
2683
|
};
|
2617
2684
|
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2618
2685
|
(acc, input) => {
|
2619
|
-
if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
|
2686
|
+
if (input.type === import_transactions10.InputType.Coin && input.owner === owner.toB256()) {
|
2620
2687
|
acc.utxos.push(input.id);
|
2621
2688
|
}
|
2622
|
-
if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
|
2689
|
+
if (input.type === import_transactions10.InputType.Message && input.recipient === owner.toB256()) {
|
2623
2690
|
acc.messages.push(input.nonce);
|
2624
2691
|
}
|
2625
2692
|
return acc;
|
@@ -2632,40 +2699,40 @@ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
|
2632
2699
|
|
2633
2700
|
// src/providers/transaction-response/transaction-response.ts
|
2634
2701
|
var import_errors13 = require("@fuel-ts/errors");
|
2635
|
-
var
|
2702
|
+
var import_math16 = require("@fuel-ts/math");
|
2636
2703
|
var import_transactions18 = require("@fuel-ts/transactions");
|
2637
2704
|
var import_utils20 = require("@fuel-ts/utils");
|
2638
2705
|
|
2639
2706
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2640
|
-
var
|
2707
|
+
var import_math15 = require("@fuel-ts/math");
|
2641
2708
|
var import_transactions16 = require("@fuel-ts/transactions");
|
2642
2709
|
var import_utils18 = require("@fuel-ts/utils");
|
2643
2710
|
|
2644
|
-
// src/providers/transaction-summary/calculate-
|
2711
|
+
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
2645
2712
|
var import_math11 = require("@fuel-ts/math");
|
2646
2713
|
var import_transactions11 = require("@fuel-ts/transactions");
|
2647
2714
|
var import_utils16 = require("@fuel-ts/utils");
|
2648
|
-
var
|
2715
|
+
var calculateTXFeeForSummary = (params) => {
|
2649
2716
|
const {
|
2650
2717
|
gasPrice,
|
2651
2718
|
rawPayload,
|
2652
2719
|
tip,
|
2720
|
+
totalFee,
|
2653
2721
|
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2654
2722
|
} = params;
|
2723
|
+
if (totalFee) {
|
2724
|
+
return totalFee;
|
2725
|
+
}
|
2655
2726
|
const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
|
2656
2727
|
const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
|
2657
2728
|
const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
|
2658
2729
|
const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
|
2659
|
-
if (transaction.type === import_transactions11.TransactionType.Mint) {
|
2660
|
-
return {
|
2661
|
-
fee: (0, import_math11.bn)(0),
|
2662
|
-
minFee: (0, import_math11.bn)(0),
|
2663
|
-
maxFee: (0, import_math11.bn)(0)
|
2664
|
-
};
|
2665
|
-
}
|
2666
2730
|
const { type, witnesses, inputs, policies } = transaction;
|
2667
2731
|
let metadataGas = (0, import_math11.bn)(0);
|
2668
2732
|
let gasLimit = (0, import_math11.bn)(0);
|
2733
|
+
if (type !== import_transactions11.TransactionType.Create && type !== import_transactions11.TransactionType.Script) {
|
2734
|
+
return (0, import_math11.bn)(0);
|
2735
|
+
}
|
2669
2736
|
if (type === import_transactions11.TransactionType.Create) {
|
2670
2737
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2671
2738
|
const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
|
@@ -2702,23 +2769,13 @@ var calculateTransactionFee = (params) => {
|
|
2702
2769
|
witnessLimit,
|
2703
2770
|
maxGasPerTx
|
2704
2771
|
});
|
2705
|
-
const minFee = calculateGasFee({
|
2706
|
-
gasPrice,
|
2707
|
-
gas: minGas,
|
2708
|
-
priceFactor: gasPriceFactor,
|
2709
|
-
tip
|
2710
|
-
});
|
2711
2772
|
const maxFee = calculateGasFee({
|
2712
2773
|
gasPrice,
|
2713
2774
|
gas: maxGas,
|
2714
2775
|
priceFactor: gasPriceFactor,
|
2715
2776
|
tip
|
2716
2777
|
});
|
2717
|
-
return
|
2718
|
-
minFee,
|
2719
|
-
maxFee,
|
2720
|
-
fee: maxFee
|
2721
|
-
};
|
2778
|
+
return maxFee;
|
2722
2779
|
};
|
2723
2780
|
|
2724
2781
|
// src/providers/transaction-summary/operations.ts
|
@@ -2877,6 +2934,12 @@ function isTypeCreate(transactionType) {
|
|
2877
2934
|
function isTypeScript(transactionType) {
|
2878
2935
|
return isType(transactionType, "Script" /* Script */);
|
2879
2936
|
}
|
2937
|
+
function isTypeUpgrade(transactionType) {
|
2938
|
+
return isType(transactionType, "Upgrade" /* Upgrade */);
|
2939
|
+
}
|
2940
|
+
function isTypeUpload(transactionType) {
|
2941
|
+
return isType(transactionType, "Upload" /* Upload */);
|
2942
|
+
}
|
2880
2943
|
function getReceiptsCall(receipts) {
|
2881
2944
|
return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
|
2882
2945
|
}
|
@@ -3217,6 +3280,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3217
3280
|
|
3218
3281
|
// src/providers/transaction-summary/status.ts
|
3219
3282
|
var import_errors12 = require("@fuel-ts/errors");
|
3283
|
+
var import_math14 = require("@fuel-ts/math");
|
3220
3284
|
var getTransactionStatusName = (gqlStatus) => {
|
3221
3285
|
switch (gqlStatus) {
|
3222
3286
|
case "FailureStatus":
|
@@ -3238,6 +3302,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3238
3302
|
let time;
|
3239
3303
|
let blockId;
|
3240
3304
|
let status;
|
3305
|
+
let totalFee;
|
3306
|
+
let totalGas;
|
3241
3307
|
let isStatusFailure = false;
|
3242
3308
|
let isStatusSuccess = false;
|
3243
3309
|
let isStatusPending = false;
|
@@ -3248,11 +3314,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3248
3314
|
time = gqlTransactionStatus.time;
|
3249
3315
|
blockId = gqlTransactionStatus.block.id;
|
3250
3316
|
isStatusSuccess = true;
|
3317
|
+
totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
|
3318
|
+
totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
|
3251
3319
|
break;
|
3252
3320
|
case "FailureStatus":
|
3253
3321
|
time = gqlTransactionStatus.time;
|
3254
3322
|
blockId = gqlTransactionStatus.block.id;
|
3255
3323
|
isStatusFailure = true;
|
3324
|
+
totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
|
3325
|
+
totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
|
3256
3326
|
break;
|
3257
3327
|
case "SubmittedStatus":
|
3258
3328
|
time = gqlTransactionStatus.time;
|
@@ -3265,6 +3335,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3265
3335
|
time,
|
3266
3336
|
blockId,
|
3267
3337
|
status,
|
3338
|
+
totalFee,
|
3339
|
+
totalGas,
|
3268
3340
|
isStatusFailure,
|
3269
3341
|
isStatusSuccess,
|
3270
3342
|
isStatusPending
|
@@ -3300,8 +3372,10 @@ function assembleTransactionSummary(params) {
|
|
3300
3372
|
maxInputs
|
3301
3373
|
});
|
3302
3374
|
const typeName = getTransactionTypeName(transaction.type);
|
3303
|
-
const tip = (0,
|
3304
|
-
const {
|
3375
|
+
const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
|
3376
|
+
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3377
|
+
const fee = calculateTXFeeForSummary({
|
3378
|
+
totalFee,
|
3305
3379
|
gasPrice,
|
3306
3380
|
rawPayload,
|
3307
3381
|
tip,
|
@@ -3314,7 +3388,6 @@ function assembleTransactionSummary(params) {
|
|
3314
3388
|
}
|
3315
3389
|
}
|
3316
3390
|
});
|
3317
|
-
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time } = processGraphqlStatus(gqlTransactionStatus);
|
3318
3391
|
const mintedAssets = extractMintedAssetsFromReceipts(receipts);
|
3319
3392
|
const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
|
3320
3393
|
let date;
|
@@ -3323,6 +3396,7 @@ function assembleTransactionSummary(params) {
|
|
3323
3396
|
}
|
3324
3397
|
const transactionSummary = {
|
3325
3398
|
id,
|
3399
|
+
tip,
|
3326
3400
|
fee,
|
3327
3401
|
gasUsed,
|
3328
3402
|
operations,
|
@@ -3336,6 +3410,8 @@ function assembleTransactionSummary(params) {
|
|
3336
3410
|
isTypeMint: isTypeMint(transaction.type),
|
3337
3411
|
isTypeCreate: isTypeCreate(transaction.type),
|
3338
3412
|
isTypeScript: isTypeScript(transaction.type),
|
3413
|
+
isTypeUpgrade: isTypeUpgrade(transaction.type),
|
3414
|
+
isTypeUpload: isTypeUpload(transaction.type),
|
3339
3415
|
isStatusFailure,
|
3340
3416
|
isStatusSuccess,
|
3341
3417
|
isStatusPending,
|
@@ -3367,7 +3443,7 @@ var TransactionResponse = class {
|
|
3367
3443
|
/** Current provider */
|
3368
3444
|
provider;
|
3369
3445
|
/** Gas used on the transaction */
|
3370
|
-
gasUsed = (0,
|
3446
|
+
gasUsed = (0, import_math16.bn)(0);
|
3371
3447
|
/** The graphql Transaction with receipts object. */
|
3372
3448
|
gqlTransaction;
|
3373
3449
|
abis;
|
@@ -3452,7 +3528,7 @@ var TransactionResponse = class {
|
|
3452
3528
|
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3453
3529
|
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3454
3530
|
const gasPrice = await this.provider.getLatestGasPrice();
|
3455
|
-
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3531
|
+
const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
|
3456
3532
|
const transactionSummary = assembleTransactionSummary({
|
3457
3533
|
id: this.id,
|
3458
3534
|
receipts,
|
@@ -3588,33 +3664,60 @@ var mergeQuantities = (...coinQuantities) => {
|
|
3588
3664
|
var MAX_RETRIES = 10;
|
3589
3665
|
var processGqlChain = (chain) => {
|
3590
3666
|
const { name, daHeight, consensusParameters, latestBlock } = chain;
|
3591
|
-
const {
|
3667
|
+
const {
|
3668
|
+
contractParams,
|
3669
|
+
feeParams,
|
3670
|
+
predicateParams,
|
3671
|
+
scriptParams,
|
3672
|
+
txParams,
|
3673
|
+
gasCosts,
|
3674
|
+
baseAssetId,
|
3675
|
+
chainId,
|
3676
|
+
version
|
3677
|
+
} = consensusParameters;
|
3592
3678
|
return {
|
3593
3679
|
name,
|
3594
|
-
baseChainHeight: (0,
|
3680
|
+
baseChainHeight: (0, import_math17.bn)(daHeight),
|
3595
3681
|
consensusParameters: {
|
3596
|
-
|
3597
|
-
|
3598
|
-
|
3599
|
-
|
3600
|
-
|
3601
|
-
|
3602
|
-
|
3603
|
-
|
3604
|
-
|
3605
|
-
|
3606
|
-
|
3607
|
-
|
3608
|
-
|
3609
|
-
|
3610
|
-
|
3611
|
-
|
3682
|
+
version,
|
3683
|
+
chainId: (0, import_math17.bn)(chainId),
|
3684
|
+
baseAssetId,
|
3685
|
+
feeParameters: {
|
3686
|
+
version: feeParams.version,
|
3687
|
+
gasPerByte: (0, import_math17.bn)(feeParams.gasPerByte),
|
3688
|
+
gasPriceFactor: (0, import_math17.bn)(feeParams.gasPriceFactor)
|
3689
|
+
},
|
3690
|
+
contractParameters: {
|
3691
|
+
version: contractParams.version,
|
3692
|
+
contractMaxSize: (0, import_math17.bn)(contractParams.contractMaxSize),
|
3693
|
+
maxStorageSlots: (0, import_math17.bn)(contractParams.maxStorageSlots)
|
3694
|
+
},
|
3695
|
+
txParameters: {
|
3696
|
+
version: txParams.version,
|
3697
|
+
maxInputs: (0, import_math17.bn)(txParams.maxInputs),
|
3698
|
+
maxOutputs: (0, import_math17.bn)(txParams.maxOutputs),
|
3699
|
+
maxWitnesses: (0, import_math17.bn)(txParams.maxWitnesses),
|
3700
|
+
maxGasPerTx: (0, import_math17.bn)(txParams.maxGasPerTx),
|
3701
|
+
maxSize: (0, import_math17.bn)(txParams.maxSize),
|
3702
|
+
maxBytecodeSubsections: (0, import_math17.bn)(txParams.maxBytecodeSubsections)
|
3703
|
+
},
|
3704
|
+
predicateParameters: {
|
3705
|
+
version: predicateParams.version,
|
3706
|
+
maxPredicateLength: (0, import_math17.bn)(predicateParams.maxPredicateLength),
|
3707
|
+
maxPredicateDataLength: (0, import_math17.bn)(predicateParams.maxPredicateDataLength),
|
3708
|
+
maxGasPerPredicate: (0, import_math17.bn)(predicateParams.maxGasPerPredicate),
|
3709
|
+
maxMessageDataLength: (0, import_math17.bn)(predicateParams.maxMessageDataLength)
|
3710
|
+
},
|
3711
|
+
scriptParameters: {
|
3712
|
+
version: scriptParams.version,
|
3713
|
+
maxScriptLength: (0, import_math17.bn)(scriptParams.maxScriptLength),
|
3714
|
+
maxScriptDataLength: (0, import_math17.bn)(scriptParams.maxScriptDataLength)
|
3715
|
+
},
|
3612
3716
|
gasCosts
|
3613
3717
|
},
|
3614
|
-
gasCosts,
|
3615
3718
|
latestBlock: {
|
3616
3719
|
id: latestBlock.id,
|
3617
|
-
height: (0,
|
3720
|
+
height: (0, import_math17.bn)(latestBlock.height),
|
3618
3721
|
time: latestBlock.header.time,
|
3619
3722
|
transactions: latestBlock.transactions.map((i) => ({
|
3620
3723
|
id: i.id
|
@@ -3708,7 +3811,12 @@ var _Provider = class {
|
|
3708
3811
|
* Returns some helpful parameters related to gas fees.
|
3709
3812
|
*/
|
3710
3813
|
getGasConfig() {
|
3711
|
-
const {
|
3814
|
+
const {
|
3815
|
+
txParameters: { maxGasPerTx },
|
3816
|
+
predicateParameters: { maxGasPerPredicate },
|
3817
|
+
feeParameters: { gasPriceFactor, gasPerByte },
|
3818
|
+
gasCosts
|
3819
|
+
} = this.getChain().consensusParameters;
|
3712
3820
|
return {
|
3713
3821
|
maxGasPerTx,
|
3714
3822
|
maxGasPerPredicate,
|
@@ -3743,9 +3851,11 @@ var _Provider = class {
|
|
3743
3851
|
static ensureClientVersionIsSupported(nodeInfo) {
|
3744
3852
|
const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
|
3745
3853
|
if (!isMajorSupported || !isMinorSupported) {
|
3746
|
-
|
3747
|
-
|
3748
|
-
|
3854
|
+
console.warn(
|
3855
|
+
`The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion},
|
3856
|
+
which is not supported by the version of the TS SDK that you are using.
|
3857
|
+
Things may not work as expected.
|
3858
|
+
Supported fuel-core version: ${supportedVersion}.`
|
3749
3859
|
);
|
3750
3860
|
}
|
3751
3861
|
}
|
@@ -3757,7 +3867,18 @@ var _Provider = class {
|
|
3757
3867
|
createOperations() {
|
3758
3868
|
const fetchFn = _Provider.getFetchFn(this.options);
|
3759
3869
|
const gqlClient = new import_graphql_request.GraphQLClient(this.url, {
|
3760
|
-
fetch: (url, requestInit) => fetchFn(url, requestInit, this.options)
|
3870
|
+
fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
3871
|
+
responseMiddleware: (response) => {
|
3872
|
+
if ("response" in response) {
|
3873
|
+
const graphQlResponse = response.response;
|
3874
|
+
if (Array.isArray(graphQlResponse?.errors)) {
|
3875
|
+
throw new import_errors14.FuelError(
|
3876
|
+
import_errors14.FuelError.CODES.INVALID_REQUEST,
|
3877
|
+
graphQlResponse.errors.map((err) => err.message).join("\n\n")
|
3878
|
+
);
|
3879
|
+
}
|
3880
|
+
}
|
3881
|
+
}
|
3761
3882
|
});
|
3762
3883
|
const executeQuery = (query, vars) => {
|
3763
3884
|
const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
|
@@ -3785,21 +3906,6 @@ var _Provider = class {
|
|
3785
3906
|
} = await this.operations.getVersion();
|
3786
3907
|
return nodeVersion;
|
3787
3908
|
}
|
3788
|
-
/**
|
3789
|
-
* @hidden
|
3790
|
-
*
|
3791
|
-
* Returns the network configuration of the connected Fuel node.
|
3792
|
-
*
|
3793
|
-
* @returns A promise that resolves to the network configuration object
|
3794
|
-
*/
|
3795
|
-
async getNetwork() {
|
3796
|
-
const {
|
3797
|
-
name,
|
3798
|
-
consensusParameters: { chainId }
|
3799
|
-
} = await this.getChain();
|
3800
|
-
const network = new import_ethers.Network(name, chainId.toNumber());
|
3801
|
-
return Promise.resolve(network);
|
3802
|
-
}
|
3803
3909
|
/**
|
3804
3910
|
* Returns the block number.
|
3805
3911
|
*
|
@@ -3807,7 +3913,7 @@ var _Provider = class {
|
|
3807
3913
|
*/
|
3808
3914
|
async getBlockNumber() {
|
3809
3915
|
const { chain } = await this.operations.getChain();
|
3810
|
-
return (0,
|
3916
|
+
return (0, import_math17.bn)(chain.latestBlock.height, 10);
|
3811
3917
|
}
|
3812
3918
|
/**
|
3813
3919
|
* Returns the chain information.
|
@@ -3817,8 +3923,8 @@ var _Provider = class {
|
|
3817
3923
|
async fetchNode() {
|
3818
3924
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3819
3925
|
const processedNodeInfo = {
|
3820
|
-
maxDepth: (0,
|
3821
|
-
maxTx: (0,
|
3926
|
+
maxDepth: (0, import_math17.bn)(nodeInfo.maxDepth),
|
3927
|
+
maxTx: (0, import_math17.bn)(nodeInfo.maxTx),
|
3822
3928
|
nodeVersion: nodeInfo.nodeVersion,
|
3823
3929
|
utxoValidation: nodeInfo.utxoValidation,
|
3824
3930
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -3922,9 +4028,9 @@ var _Provider = class {
|
|
3922
4028
|
encodedTransactions: encodedTransaction,
|
3923
4029
|
utxoValidation: utxoValidation || false
|
3924
4030
|
});
|
3925
|
-
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
4031
|
+
const [{ receipts: rawReceipts, status: dryRunStatus }] = dryRunStatuses;
|
3926
4032
|
const receipts = rawReceipts.map(processGqlReceipt);
|
3927
|
-
return { receipts,
|
4033
|
+
return { receipts, dryRunStatus };
|
3928
4034
|
}
|
3929
4035
|
/**
|
3930
4036
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -3935,7 +4041,7 @@ var _Provider = class {
|
|
3935
4041
|
async estimatePredicates(transactionRequest) {
|
3936
4042
|
const shouldEstimatePredicates = Boolean(
|
3937
4043
|
transactionRequest.inputs.find(
|
3938
|
-
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new
|
4044
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math17.BN(input.predicateGasUsed).isZero()
|
3939
4045
|
)
|
3940
4046
|
);
|
3941
4047
|
if (!shouldEstimatePredicates) {
|
@@ -3950,7 +4056,7 @@ var _Provider = class {
|
|
3950
4056
|
} = response;
|
3951
4057
|
if (inputs) {
|
3952
4058
|
inputs.forEach((input, index) => {
|
3953
|
-
if ("predicateGasUsed" in input && (0,
|
4059
|
+
if ("predicateGasUsed" in input && (0, import_math17.bn)(input.predicateGasUsed).gt(0)) {
|
3954
4060
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3955
4061
|
}
|
3956
4062
|
});
|
@@ -3978,7 +4084,7 @@ var _Provider = class {
|
|
3978
4084
|
let receipts = [];
|
3979
4085
|
const missingContractIds = [];
|
3980
4086
|
let outputVariables = 0;
|
3981
|
-
let
|
4087
|
+
let dryRunStatus;
|
3982
4088
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3983
4089
|
const {
|
3984
4090
|
dryRun: [{ receipts: rawReceipts, status }]
|
@@ -3987,7 +4093,7 @@ var _Provider = class {
|
|
3987
4093
|
utxoValidation: false
|
3988
4094
|
});
|
3989
4095
|
receipts = rawReceipts.map(processGqlReceipt);
|
3990
|
-
|
4096
|
+
dryRunStatus = status;
|
3991
4097
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
3992
4098
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
3993
4099
|
if (hasMissingOutputs) {
|
@@ -4009,7 +4115,7 @@ var _Provider = class {
|
|
4009
4115
|
receipts,
|
4010
4116
|
outputVariables,
|
4011
4117
|
missingContractIds,
|
4012
|
-
|
4118
|
+
dryRunStatus
|
4013
4119
|
};
|
4014
4120
|
}
|
4015
4121
|
/**
|
@@ -4027,7 +4133,7 @@ var _Provider = class {
|
|
4027
4133
|
receipts: [],
|
4028
4134
|
outputVariables: 0,
|
4029
4135
|
missingContractIds: [],
|
4030
|
-
|
4136
|
+
dryRunStatus: void 0
|
4031
4137
|
}));
|
4032
4138
|
const allRequests = (0, import_ramda3.clone)(transactionRequests);
|
4033
4139
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
@@ -4052,7 +4158,7 @@ var _Provider = class {
|
|
4052
4158
|
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4053
4159
|
const result = results[requestIdx];
|
4054
4160
|
result.receipts = rawReceipts.map(processGqlReceipt);
|
4055
|
-
result.
|
4161
|
+
result.dryRunStatus = status;
|
4056
4162
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4057
4163
|
result.receipts
|
4058
4164
|
);
|
@@ -4089,7 +4195,7 @@ var _Provider = class {
|
|
4089
4195
|
});
|
4090
4196
|
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4091
4197
|
const receipts = rawReceipts.map(processGqlReceipt);
|
4092
|
-
return { receipts,
|
4198
|
+
return { receipts, dryRunStatus: status };
|
4093
4199
|
});
|
4094
4200
|
return results;
|
4095
4201
|
}
|
@@ -4108,12 +4214,12 @@ var _Provider = class {
|
|
4108
4214
|
gasPrice = await this.estimateGasPrice(10);
|
4109
4215
|
}
|
4110
4216
|
const minFee = calculateGasFee({
|
4111
|
-
gasPrice: (0,
|
4217
|
+
gasPrice: (0, import_math17.bn)(gasPrice),
|
4112
4218
|
gas: minGas,
|
4113
4219
|
priceFactor: gasPriceFactor,
|
4114
4220
|
tip: transactionRequest.tip
|
4115
4221
|
}).add(1);
|
4116
|
-
let gasLimit = (0,
|
4222
|
+
let gasLimit = (0, import_math17.bn)(0);
|
4117
4223
|
if (transactionRequest.type === import_transactions19.TransactionType.Script) {
|
4118
4224
|
gasLimit = transactionRequest.gasLimit;
|
4119
4225
|
if (transactionRequest.gasLimit.eq(0)) {
|
@@ -4126,7 +4232,7 @@ var _Provider = class {
|
|
4126
4232
|
}
|
4127
4233
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4128
4234
|
const maxFee = calculateGasFee({
|
4129
|
-
gasPrice: (0,
|
4235
|
+
gasPrice: (0, import_math17.bn)(gasPrice),
|
4130
4236
|
gas: maxGas,
|
4131
4237
|
priceFactor: gasPriceFactor,
|
4132
4238
|
tip: transactionRequest.tip
|
@@ -4186,12 +4292,12 @@ var _Provider = class {
|
|
4186
4292
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
4187
4293
|
const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
|
4188
4294
|
const baseAssetId = this.getBaseAssetId();
|
4295
|
+
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
4189
4296
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4190
4297
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4191
4298
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4192
|
-
txRequestClone.maxFee = (0, import_math16.bn)(0);
|
4193
4299
|
if (isScriptTransaction) {
|
4194
|
-
txRequestClone.gasLimit = (0,
|
4300
|
+
txRequestClone.gasLimit = (0, import_math17.bn)(0);
|
4195
4301
|
}
|
4196
4302
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4197
4303
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4204,24 +4310,22 @@ var _Provider = class {
|
|
4204
4310
|
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
4205
4311
|
}
|
4206
4312
|
await this.estimatePredicates(signedRequest);
|
4313
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4207
4314
|
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
4208
4315
|
transactionRequest: signedRequest
|
4209
4316
|
});
|
4210
4317
|
let receipts = [];
|
4318
|
+
let dryRunStatus;
|
4211
4319
|
let missingContractIds = [];
|
4212
4320
|
let outputVariables = 0;
|
4213
|
-
let gasUsed = (0,
|
4214
|
-
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4321
|
+
let gasUsed = (0, import_math17.bn)(0);
|
4215
4322
|
txRequestClone.maxFee = maxFee;
|
4216
4323
|
if (isScriptTransaction) {
|
4217
4324
|
txRequestClone.gasLimit = gasLimit;
|
4218
4325
|
if (signatureCallback) {
|
4219
4326
|
await signatureCallback(txRequestClone);
|
4220
4327
|
}
|
4221
|
-
|
4222
|
-
receipts = result.receipts;
|
4223
|
-
outputVariables = result.outputVariables;
|
4224
|
-
missingContractIds = result.missingContractIds;
|
4328
|
+
({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
|
4225
4329
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4226
4330
|
txRequestClone.gasLimit = gasUsed;
|
4227
4331
|
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
@@ -4241,7 +4345,9 @@ var _Provider = class {
|
|
4241
4345
|
outputVariables,
|
4242
4346
|
missingContractIds,
|
4243
4347
|
addedSignatures,
|
4244
|
-
estimatedPredicates: txRequestClone.inputs
|
4348
|
+
estimatedPredicates: txRequestClone.inputs,
|
4349
|
+
dryRunStatus,
|
4350
|
+
updateMaxFee
|
4245
4351
|
};
|
4246
4352
|
}
|
4247
4353
|
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
@@ -4277,10 +4383,10 @@ var _Provider = class {
|
|
4277
4383
|
return coins.map((coin) => ({
|
4278
4384
|
id: coin.utxoId,
|
4279
4385
|
assetId: coin.assetId,
|
4280
|
-
amount: (0,
|
4386
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4281
4387
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4282
|
-
blockCreated: (0,
|
4283
|
-
txCreatedIdx: (0,
|
4388
|
+
blockCreated: (0, import_math17.bn)(coin.blockCreated),
|
4389
|
+
txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
|
4284
4390
|
}));
|
4285
4391
|
}
|
4286
4392
|
/**
|
@@ -4314,12 +4420,12 @@ var _Provider = class {
|
|
4314
4420
|
};
|
4315
4421
|
const result = await this.operations.getCoinsToSpend(coinsQuery);
|
4316
4422
|
const coins = result.coinsToSpend.flat().map((coin) => {
|
4317
|
-
switch (coin.
|
4423
|
+
switch (coin.type) {
|
4318
4424
|
case "MessageCoin":
|
4319
4425
|
return {
|
4320
|
-
amount: (0,
|
4426
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4321
4427
|
assetId: coin.assetId,
|
4322
|
-
daHeight: (0,
|
4428
|
+
daHeight: (0, import_math17.bn)(coin.daHeight),
|
4323
4429
|
sender: import_address3.Address.fromAddressOrString(coin.sender),
|
4324
4430
|
recipient: import_address3.Address.fromAddressOrString(coin.recipient),
|
4325
4431
|
nonce: coin.nonce
|
@@ -4327,11 +4433,11 @@ var _Provider = class {
|
|
4327
4433
|
case "Coin":
|
4328
4434
|
return {
|
4329
4435
|
id: coin.utxoId,
|
4330
|
-
amount: (0,
|
4436
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4331
4437
|
assetId: coin.assetId,
|
4332
4438
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4333
|
-
blockCreated: (0,
|
4334
|
-
txCreatedIdx: (0,
|
4439
|
+
blockCreated: (0, import_math17.bn)(coin.blockCreated),
|
4440
|
+
txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
|
4335
4441
|
};
|
4336
4442
|
default:
|
4337
4443
|
return null;
|
@@ -4348,13 +4454,13 @@ var _Provider = class {
|
|
4348
4454
|
async getBlock(idOrHeight) {
|
4349
4455
|
let variables;
|
4350
4456
|
if (typeof idOrHeight === "number") {
|
4351
|
-
variables = { height: (0,
|
4457
|
+
variables = { height: (0, import_math17.bn)(idOrHeight).toString(10) };
|
4352
4458
|
} else if (idOrHeight === "latest") {
|
4353
4459
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4354
4460
|
} else if (idOrHeight.length === 66) {
|
4355
4461
|
variables = { blockId: idOrHeight };
|
4356
4462
|
} else {
|
4357
|
-
variables = { blockId: (0,
|
4463
|
+
variables = { blockId: (0, import_math17.bn)(idOrHeight).toString(10) };
|
4358
4464
|
}
|
4359
4465
|
const { block } = await this.operations.getBlock(variables);
|
4360
4466
|
if (!block) {
|
@@ -4362,7 +4468,7 @@ var _Provider = class {
|
|
4362
4468
|
}
|
4363
4469
|
return {
|
4364
4470
|
id: block.id,
|
4365
|
-
height: (0,
|
4471
|
+
height: (0, import_math17.bn)(block.height),
|
4366
4472
|
time: block.header.time,
|
4367
4473
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4368
4474
|
};
|
@@ -4377,7 +4483,7 @@ var _Provider = class {
|
|
4377
4483
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4378
4484
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4379
4485
|
id: block.id,
|
4380
|
-
height: (0,
|
4486
|
+
height: (0, import_math17.bn)(block.height),
|
4381
4487
|
time: block.header.time,
|
4382
4488
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4383
4489
|
}));
|
@@ -4392,7 +4498,7 @@ var _Provider = class {
|
|
4392
4498
|
async getBlockWithTransactions(idOrHeight) {
|
4393
4499
|
let variables;
|
4394
4500
|
if (typeof idOrHeight === "number") {
|
4395
|
-
variables = { blockHeight: (0,
|
4501
|
+
variables = { blockHeight: (0, import_math17.bn)(idOrHeight).toString(10) };
|
4396
4502
|
} else if (idOrHeight === "latest") {
|
4397
4503
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4398
4504
|
} else {
|
@@ -4404,7 +4510,7 @@ var _Provider = class {
|
|
4404
4510
|
}
|
4405
4511
|
return {
|
4406
4512
|
id: block.id,
|
4407
|
-
height: (0,
|
4513
|
+
height: (0, import_math17.bn)(block.height, 10),
|
4408
4514
|
time: block.header.time,
|
4409
4515
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4410
4516
|
transactions: block.transactions.map(
|
@@ -4453,7 +4559,7 @@ var _Provider = class {
|
|
4453
4559
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4454
4560
|
asset: (0, import_utils22.hexlify)(assetId)
|
4455
4561
|
});
|
4456
|
-
return (0,
|
4562
|
+
return (0, import_math17.bn)(contractBalance.amount, 10);
|
4457
4563
|
}
|
4458
4564
|
/**
|
4459
4565
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4467,7 +4573,7 @@ var _Provider = class {
|
|
4467
4573
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4468
4574
|
assetId: (0, import_utils22.hexlify)(assetId)
|
4469
4575
|
});
|
4470
|
-
return (0,
|
4576
|
+
return (0, import_math17.bn)(balance.amount, 10);
|
4471
4577
|
}
|
4472
4578
|
/**
|
4473
4579
|
* Returns balances for the given owner.
|
@@ -4485,7 +4591,7 @@ var _Provider = class {
|
|
4485
4591
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4486
4592
|
return balances.map((balance) => ({
|
4487
4593
|
assetId: balance.assetId,
|
4488
|
-
amount: (0,
|
4594
|
+
amount: (0, import_math17.bn)(balance.amount)
|
4489
4595
|
}));
|
4490
4596
|
}
|
4491
4597
|
/**
|
@@ -4507,15 +4613,15 @@ var _Provider = class {
|
|
4507
4613
|
sender: message.sender,
|
4508
4614
|
recipient: message.recipient,
|
4509
4615
|
nonce: message.nonce,
|
4510
|
-
amount: (0,
|
4616
|
+
amount: (0, import_math17.bn)(message.amount),
|
4511
4617
|
data: message.data
|
4512
4618
|
}),
|
4513
4619
|
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4514
4620
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4515
4621
|
nonce: message.nonce,
|
4516
|
-
amount: (0,
|
4622
|
+
amount: (0, import_math17.bn)(message.amount),
|
4517
4623
|
data: import_transactions19.InputMessageCoder.decodeData(message.data),
|
4518
|
-
daHeight: (0,
|
4624
|
+
daHeight: (0, import_math17.bn)(message.daHeight)
|
4519
4625
|
}));
|
4520
4626
|
}
|
4521
4627
|
/**
|
@@ -4568,59 +4674,59 @@ var _Provider = class {
|
|
4568
4674
|
} = result.messageProof;
|
4569
4675
|
return {
|
4570
4676
|
messageProof: {
|
4571
|
-
proofIndex: (0,
|
4677
|
+
proofIndex: (0, import_math17.bn)(messageProof.proofIndex),
|
4572
4678
|
proofSet: messageProof.proofSet
|
4573
4679
|
},
|
4574
4680
|
blockProof: {
|
4575
|
-
proofIndex: (0,
|
4681
|
+
proofIndex: (0, import_math17.bn)(blockProof.proofIndex),
|
4576
4682
|
proofSet: blockProof.proofSet
|
4577
4683
|
},
|
4578
4684
|
messageBlockHeader: {
|
4579
4685
|
id: messageBlockHeader.id,
|
4580
|
-
daHeight: (0,
|
4581
|
-
transactionsCount: (
|
4686
|
+
daHeight: (0, import_math17.bn)(messageBlockHeader.daHeight),
|
4687
|
+
transactionsCount: Number(messageBlockHeader.transactionsCount),
|
4582
4688
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4583
|
-
height: (0,
|
4689
|
+
height: (0, import_math17.bn)(messageBlockHeader.height),
|
4584
4690
|
prevRoot: messageBlockHeader.prevRoot,
|
4585
4691
|
time: messageBlockHeader.time,
|
4586
4692
|
applicationHash: messageBlockHeader.applicationHash,
|
4587
|
-
messageReceiptCount: (
|
4693
|
+
messageReceiptCount: Number(messageBlockHeader.messageReceiptCount),
|
4588
4694
|
messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
|
4589
|
-
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4695
|
+
consensusParametersVersion: Number(messageBlockHeader.consensusParametersVersion),
|
4590
4696
|
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4591
|
-
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4697
|
+
stateTransitionBytecodeVersion: Number(messageBlockHeader.stateTransitionBytecodeVersion)
|
4592
4698
|
},
|
4593
4699
|
commitBlockHeader: {
|
4594
4700
|
id: commitBlockHeader.id,
|
4595
|
-
daHeight: (0,
|
4596
|
-
transactionsCount: (
|
4701
|
+
daHeight: (0, import_math17.bn)(commitBlockHeader.daHeight),
|
4702
|
+
transactionsCount: Number(commitBlockHeader.transactionsCount),
|
4597
4703
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4598
|
-
height: (0,
|
4704
|
+
height: (0, import_math17.bn)(commitBlockHeader.height),
|
4599
4705
|
prevRoot: commitBlockHeader.prevRoot,
|
4600
4706
|
time: commitBlockHeader.time,
|
4601
4707
|
applicationHash: commitBlockHeader.applicationHash,
|
4602
|
-
messageReceiptCount: (
|
4708
|
+
messageReceiptCount: Number(commitBlockHeader.messageReceiptCount),
|
4603
4709
|
messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
|
4604
|
-
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4710
|
+
consensusParametersVersion: Number(commitBlockHeader.consensusParametersVersion),
|
4605
4711
|
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4606
|
-
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4712
|
+
stateTransitionBytecodeVersion: Number(commitBlockHeader.stateTransitionBytecodeVersion)
|
4607
4713
|
},
|
4608
4714
|
sender: import_address3.Address.fromAddressOrString(sender),
|
4609
4715
|
recipient: import_address3.Address.fromAddressOrString(recipient),
|
4610
4716
|
nonce,
|
4611
|
-
amount: (0,
|
4717
|
+
amount: (0, import_math17.bn)(amount),
|
4612
4718
|
data
|
4613
4719
|
};
|
4614
4720
|
}
|
4615
4721
|
async getLatestGasPrice() {
|
4616
4722
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4617
|
-
return (0,
|
4723
|
+
return (0, import_math17.bn)(latestGasPrice.gasPrice);
|
4618
4724
|
}
|
4619
4725
|
async estimateGasPrice(blockHorizon) {
|
4620
4726
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4621
4727
|
blockHorizon: String(blockHorizon)
|
4622
4728
|
});
|
4623
|
-
return (0,
|
4729
|
+
return (0, import_math17.bn)(estimateGasPrice.gasPrice);
|
4624
4730
|
}
|
4625
4731
|
/**
|
4626
4732
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4641,15 +4747,37 @@ var _Provider = class {
|
|
4641
4747
|
*/
|
4642
4748
|
async produceBlocks(amount, startTime) {
|
4643
4749
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4644
|
-
blocksToProduce: (0,
|
4750
|
+
blocksToProduce: (0, import_math17.bn)(amount).toString(10),
|
4645
4751
|
startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4646
4752
|
});
|
4647
|
-
return (0,
|
4753
|
+
return (0, import_math17.bn)(latestBlockHeight);
|
4648
4754
|
}
|
4649
4755
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4650
4756
|
async getTransactionResponse(transactionId) {
|
4651
4757
|
return new TransactionResponse(transactionId, this);
|
4652
4758
|
}
|
4759
|
+
/**
|
4760
|
+
* Returns Message for given nonce.
|
4761
|
+
*
|
4762
|
+
* @param nonce - The nonce of the message to retrieve.
|
4763
|
+
* @returns A promise that resolves to the Message object.
|
4764
|
+
*/
|
4765
|
+
async getMessageByNonce(nonce) {
|
4766
|
+
const { message } = await this.operations.getMessageByNonce({ nonce });
|
4767
|
+
if (!message) {
|
4768
|
+
return null;
|
4769
|
+
}
|
4770
|
+
return message;
|
4771
|
+
}
|
4772
|
+
async getRelayedTransactionStatus(relayedTransactionId) {
|
4773
|
+
const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
|
4774
|
+
relayedTransactionId
|
4775
|
+
});
|
4776
|
+
if (!relayedTransactionStatus) {
|
4777
|
+
return null;
|
4778
|
+
}
|
4779
|
+
return relayedTransactionStatus;
|
4780
|
+
}
|
4653
4781
|
};
|
4654
4782
|
var Provider = _Provider;
|
4655
4783
|
_cacheInputs = new WeakSet();
|
@@ -4668,7 +4796,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4668
4796
|
|
4669
4797
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4670
4798
|
var import_errors15 = require("@fuel-ts/errors");
|
4671
|
-
var
|
4799
|
+
var import_math18 = require("@fuel-ts/math");
|
4672
4800
|
var import_transactions20 = require("@fuel-ts/transactions");
|
4673
4801
|
var import_utils25 = require("@fuel-ts/utils");
|
4674
4802
|
|
@@ -4684,8 +4812,33 @@ var CHAIN_IDS = {
|
|
4684
4812
|
}
|
4685
4813
|
};
|
4686
4814
|
|
4687
|
-
// src/providers/assets/
|
4688
|
-
var
|
4815
|
+
// src/providers/assets/utils/url.ts
|
4816
|
+
var DELIMITER_PATH = "/";
|
4817
|
+
var trimRegex = /^\/|\/$/g;
|
4818
|
+
var trimPath = (path2 = "") => path2.replace(trimRegex, "");
|
4819
|
+
function urlJoin(baseUrl, ...paths) {
|
4820
|
+
const hasBaseUrl = baseUrl !== null && baseUrl !== void 0;
|
4821
|
+
const rootPath = baseUrl?.[0] === "/" && baseUrl.length > 1;
|
4822
|
+
const allPaths = [baseUrl, ...paths].filter(Boolean).map(trimPath);
|
4823
|
+
if (rootPath && hasBaseUrl) {
|
4824
|
+
allPaths.unshift("");
|
4825
|
+
}
|
4826
|
+
return allPaths.join(DELIMITER_PATH);
|
4827
|
+
}
|
4828
|
+
|
4829
|
+
// src/providers/assets/utils/resolveIconPaths.ts
|
4830
|
+
function resolveIconPaths(assets2, basePath = "./") {
|
4831
|
+
return assets2.map((asset) => ({
|
4832
|
+
...asset,
|
4833
|
+
icon: urlJoin(basePath, asset.icon)
|
4834
|
+
}));
|
4835
|
+
}
|
4836
|
+
|
4837
|
+
// src/providers/assets/utils/fuelAssetsBaseUrl.ts
|
4838
|
+
var fuelAssetsBaseUrl = "https://cdn.fuel.network/assets/";
|
4839
|
+
|
4840
|
+
// src/providers/assets/assets.ts
|
4841
|
+
var rawAssets = [
|
4689
4842
|
{
|
4690
4843
|
name: "Ethereum",
|
4691
4844
|
symbol: "ETH",
|
@@ -4716,20 +4869,37 @@ var assets = [
|
|
4716
4869
|
]
|
4717
4870
|
}
|
4718
4871
|
];
|
4872
|
+
var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
4873
|
+
|
4874
|
+
// src/providers/transaction-request/helpers.ts
|
4875
|
+
var import_math19 = require("@fuel-ts/math");
|
4876
|
+
var import_transactions21 = require("@fuel-ts/transactions");
|
4877
|
+
var isRequestInputCoin = (input) => input.type === import_transactions21.InputType.Coin;
|
4878
|
+
var isRequestInputMessage = (input) => input.type === import_transactions21.InputType.Message;
|
4879
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
4880
|
+
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
4881
|
+
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
4882
|
+
return acc.add(input.amount);
|
4883
|
+
}
|
4884
|
+
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
4885
|
+
return acc.add(input.amount);
|
4886
|
+
}
|
4887
|
+
return acc;
|
4888
|
+
}, (0, import_math19.bn)(0));
|
4719
4889
|
|
4720
4890
|
// src/utils/formatTransferToContractScriptData.ts
|
4721
4891
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
4722
|
-
var
|
4723
|
-
var
|
4892
|
+
var import_math20 = require("@fuel-ts/math");
|
4893
|
+
var import_utils27 = require("@fuel-ts/utils");
|
4724
4894
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4725
4895
|
var formatTransferToContractScriptData = (params) => {
|
4726
4896
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4727
4897
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
4728
|
-
const encoded = numberCoder.encode(new
|
4898
|
+
const encoded = numberCoder.encode(new import_math20.BN(amountToTransfer).toNumber());
|
4729
4899
|
const scriptData = Uint8Array.from([
|
4730
|
-
...(0,
|
4900
|
+
...(0, import_utils27.arrayify)(hexlifiedContractId),
|
4731
4901
|
...encoded,
|
4732
|
-
...(0,
|
4902
|
+
...(0, import_utils27.arrayify)(assetId)
|
4733
4903
|
]);
|
4734
4904
|
return scriptData;
|
4735
4905
|
};
|
@@ -4754,6 +4924,7 @@ var assembleTransferToContractScript = async (params) => {
|
|
4754
4924
|
};
|
4755
4925
|
|
4756
4926
|
// src/account.ts
|
4927
|
+
var MAX_FUNDING_ATTEMPTS = 2;
|
4757
4928
|
var Account = class extends import_interfaces.AbstractAccount {
|
4758
4929
|
/**
|
4759
4930
|
* The address associated with the account.
|
@@ -4908,19 +5079,20 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4908
5079
|
return balances;
|
4909
5080
|
}
|
4910
5081
|
/**
|
4911
|
-
*
|
5082
|
+
* Funds a transaction request by adding the necessary resources.
|
4912
5083
|
*
|
4913
|
-
* @
|
4914
|
-
* @param
|
4915
|
-
* @param
|
4916
|
-
* @returns
|
5084
|
+
* @typeParam T - The type of the TransactionRequest.
|
5085
|
+
* @param request - The transaction request to fund.
|
5086
|
+
* @param params - The estimated transaction parameters.
|
5087
|
+
* @returns The funded transaction request.
|
4917
5088
|
*/
|
4918
5089
|
async fund(request, params) {
|
4919
|
-
const { addedSignatures, estimatedPredicates,
|
5090
|
+
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
|
5091
|
+
const fee = request.maxFee;
|
4920
5092
|
const baseAssetId = this.provider.getBaseAssetId();
|
4921
|
-
const
|
5093
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
|
4922
5094
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
4923
|
-
amount: (0,
|
5095
|
+
amount: (0, import_math21.bn)(fee),
|
4924
5096
|
assetId: baseAssetId,
|
4925
5097
|
coinQuantities: requiredQuantities
|
4926
5098
|
});
|
@@ -4928,21 +5100,17 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4928
5100
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
4929
5101
|
quantitiesDict[assetId] = {
|
4930
5102
|
required: amount,
|
4931
|
-
owned: (0,
|
5103
|
+
owned: (0, import_math21.bn)(0)
|
4932
5104
|
};
|
4933
5105
|
});
|
4934
|
-
|
4935
|
-
const
|
4936
|
-
if (!isResource) {
|
4937
|
-
return;
|
4938
|
-
}
|
4939
|
-
const isCoin2 = "owner" in input;
|
5106
|
+
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
5107
|
+
const isCoin2 = isRequestInputCoin(input);
|
4940
5108
|
const assetId = isCoin2 ? String(input.assetId) : baseAssetId;
|
4941
5109
|
if (quantitiesDict[assetId]) {
|
4942
5110
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(input.amount);
|
4943
5111
|
}
|
4944
5112
|
});
|
4945
|
-
|
5113
|
+
let missingQuantities = [];
|
4946
5114
|
Object.entries(quantitiesDict).forEach(([assetId, { owned, required }]) => {
|
4947
5115
|
if (owned.lt(required)) {
|
4948
5116
|
missingQuantities.push({
|
@@ -4951,23 +5119,60 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4951
5119
|
});
|
4952
5120
|
}
|
4953
5121
|
});
|
4954
|
-
|
4955
|
-
|
4956
|
-
|
4957
|
-
const resources = await this.getResourcesToSpend(
|
4958
|
-
|
4959
|
-
|
4960
|
-
|
4961
|
-
|
4962
|
-
|
5122
|
+
let needsToBeFunded = missingQuantities.length > 0;
|
5123
|
+
let fundingAttempts = 0;
|
5124
|
+
while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
|
5125
|
+
const resources = await this.getResourcesToSpend(
|
5126
|
+
missingQuantities,
|
5127
|
+
cacheTxInputsFromOwner(request.inputs, this.address)
|
5128
|
+
);
|
5129
|
+
request.addResources(resources);
|
5130
|
+
request.shiftPredicateData();
|
5131
|
+
request.updatePredicateGasUsed(estimatedPredicates);
|
5132
|
+
const requestToReestimate2 = (0, import_ramda4.clone)(request);
|
5133
|
+
if (addedSignatures) {
|
5134
|
+
Array.from({ length: addedSignatures }).forEach(
|
5135
|
+
() => requestToReestimate2.addEmptyWitness()
|
5136
|
+
);
|
5137
|
+
}
|
5138
|
+
if (!updateMaxFee) {
|
5139
|
+
break;
|
5140
|
+
}
|
5141
|
+
const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
|
5142
|
+
transactionRequest: requestToReestimate2
|
5143
|
+
});
|
5144
|
+
const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
|
5145
|
+
request.inputs,
|
5146
|
+
baseAssetId,
|
5147
|
+
baseAssetId
|
5148
|
+
);
|
5149
|
+
const totalBaseAssetRequiredWithFee = requiredInBaseAsset.add(newFee);
|
5150
|
+
if (totalBaseAssetOnInputs.gt(totalBaseAssetRequiredWithFee)) {
|
5151
|
+
needsToBeFunded = false;
|
5152
|
+
} else {
|
5153
|
+
missingQuantities = [
|
5154
|
+
{
|
5155
|
+
amount: totalBaseAssetRequiredWithFee.sub(totalBaseAssetOnInputs),
|
5156
|
+
assetId: baseAssetId
|
5157
|
+
}
|
5158
|
+
];
|
5159
|
+
}
|
5160
|
+
fundingAttempts += 1;
|
5161
|
+
}
|
5162
|
+
request.shiftPredicateData();
|
5163
|
+
request.updatePredicateGasUsed(estimatedPredicates);
|
5164
|
+
const requestToReestimate = (0, import_ramda4.clone)(request);
|
4963
5165
|
if (addedSignatures) {
|
4964
5166
|
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
4965
5167
|
}
|
5168
|
+
if (!updateMaxFee) {
|
5169
|
+
return request;
|
5170
|
+
}
|
4966
5171
|
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
4967
5172
|
transactionRequest: requestToReestimate
|
4968
5173
|
});
|
4969
|
-
|
4970
|
-
return
|
5174
|
+
request.maxFee = maxFee;
|
5175
|
+
return request;
|
4971
5176
|
}
|
4972
5177
|
/**
|
4973
5178
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -4979,20 +5184,19 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4979
5184
|
* @returns A promise that resolves to the prepared transaction request.
|
4980
5185
|
*/
|
4981
5186
|
async createTransfer(destination, amount, assetId, txParams = {}) {
|
4982
|
-
|
5187
|
+
let request = new ScriptTransactionRequest(txParams);
|
4983
5188
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
4984
5189
|
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
4985
5190
|
const txCost = await this.provider.getTransactionCost(request, {
|
4986
5191
|
estimateTxDependencies: true,
|
4987
5192
|
resourcesOwner: this
|
4988
5193
|
});
|
4989
|
-
this.validateGasLimitAndMaxFee({
|
5194
|
+
request = this.validateGasLimitAndMaxFee({
|
5195
|
+
transactionRequest: request,
|
4990
5196
|
gasUsed: txCost.gasUsed,
|
4991
5197
|
maxFee: txCost.maxFee,
|
4992
5198
|
txParams
|
4993
5199
|
});
|
4994
|
-
request.gasLimit = txCost.gasUsed;
|
4995
|
-
request.maxFee = txCost.maxFee;
|
4996
5200
|
await this.fund(request, txCost);
|
4997
5201
|
return request;
|
4998
5202
|
}
|
@@ -5006,7 +5210,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5006
5210
|
* @returns A promise that resolves to the transaction response.
|
5007
5211
|
*/
|
5008
5212
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5009
|
-
if ((0,
|
5213
|
+
if ((0, import_math21.bn)(amount).lte(0)) {
|
5010
5214
|
throw new import_errors16.FuelError(
|
5011
5215
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5012
5216
|
"Transfer amount must be a positive number."
|
@@ -5026,7 +5230,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5026
5230
|
* @returns A promise that resolves to the transaction response.
|
5027
5231
|
*/
|
5028
5232
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5029
|
-
if ((0,
|
5233
|
+
if ((0, import_math21.bn)(amount).lte(0)) {
|
5030
5234
|
throw new import_errors16.FuelError(
|
5031
5235
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5032
5236
|
"Transfer amount must be a positive number."
|
@@ -5036,10 +5240,10 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5036
5240
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5037
5241
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5038
5242
|
hexlifiedContractId: contractAddress.toB256(),
|
5039
|
-
amountToTransfer: (0,
|
5243
|
+
amountToTransfer: (0, import_math21.bn)(amount),
|
5040
5244
|
assetId: assetIdToTransfer
|
5041
5245
|
});
|
5042
|
-
|
5246
|
+
let request = new ScriptTransactionRequest({
|
5043
5247
|
...txParams,
|
5044
5248
|
script,
|
5045
5249
|
scriptData
|
@@ -5047,15 +5251,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5047
5251
|
request.addContractInputAndOutput(contractAddress);
|
5048
5252
|
const txCost = await this.provider.getTransactionCost(request, {
|
5049
5253
|
resourcesOwner: this,
|
5050
|
-
quantitiesToContract: [{ amount: (0,
|
5254
|
+
quantitiesToContract: [{ amount: (0, import_math21.bn)(amount), assetId: String(assetIdToTransfer) }]
|
5051
5255
|
});
|
5052
|
-
this.validateGasLimitAndMaxFee({
|
5256
|
+
request = this.validateGasLimitAndMaxFee({
|
5257
|
+
transactionRequest: request,
|
5053
5258
|
gasUsed: txCost.gasUsed,
|
5054
5259
|
maxFee: txCost.maxFee,
|
5055
5260
|
txParams
|
5056
5261
|
});
|
5057
|
-
request.gasLimit = txCost.gasUsed;
|
5058
|
-
request.maxFee = txCost.maxFee;
|
5059
5262
|
await this.fund(request, txCost);
|
5060
5263
|
return this.sendTransaction(request);
|
5061
5264
|
}
|
@@ -5069,29 +5272,28 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5069
5272
|
*/
|
5070
5273
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5071
5274
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5072
|
-
const recipientDataArray = (0,
|
5275
|
+
const recipientDataArray = (0, import_utils28.arrayify)(
|
5073
5276
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5074
5277
|
);
|
5075
|
-
const amountDataArray = (0,
|
5076
|
-
"0x".concat((0,
|
5278
|
+
const amountDataArray = (0, import_utils28.arrayify)(
|
5279
|
+
"0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5077
5280
|
);
|
5078
5281
|
const script = new Uint8Array([
|
5079
|
-
...(0,
|
5282
|
+
...(0, import_utils28.arrayify)(withdrawScript.bytes),
|
5080
5283
|
...recipientDataArray,
|
5081
5284
|
...amountDataArray
|
5082
5285
|
]);
|
5083
5286
|
const params = { script, ...txParams };
|
5084
5287
|
const baseAssetId = this.provider.getBaseAssetId();
|
5085
|
-
|
5086
|
-
const quantitiesToContract = [{ amount: (0,
|
5288
|
+
let request = new ScriptTransactionRequest(params);
|
5289
|
+
const quantitiesToContract = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
|
5087
5290
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5088
|
-
this.validateGasLimitAndMaxFee({
|
5291
|
+
request = this.validateGasLimitAndMaxFee({
|
5292
|
+
transactionRequest: request,
|
5089
5293
|
gasUsed: txCost.gasUsed,
|
5090
5294
|
maxFee: txCost.maxFee,
|
5091
5295
|
txParams
|
5092
5296
|
});
|
5093
|
-
request.maxFee = txCost.maxFee;
|
5094
|
-
request.gasLimit = txCost.gasUsed;
|
5095
5297
|
await this.fund(request, txCost);
|
5096
5298
|
return this.sendTransaction(request);
|
5097
5299
|
}
|
@@ -5151,22 +5353,29 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5151
5353
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5152
5354
|
}
|
5153
5355
|
validateGasLimitAndMaxFee({
|
5154
|
-
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
|
5155
5356
|
gasUsed,
|
5156
|
-
maxFee
|
5357
|
+
maxFee,
|
5358
|
+
transactionRequest,
|
5359
|
+
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
5157
5360
|
}) {
|
5158
|
-
|
5361
|
+
const request = transactionRequestify(transactionRequest);
|
5362
|
+
if (!(0, import_utils28.isDefined)(setGasLimit)) {
|
5363
|
+
request.gasLimit = gasUsed;
|
5364
|
+
} else if (gasUsed.gt(setGasLimit)) {
|
5159
5365
|
throw new import_errors16.FuelError(
|
5160
5366
|
import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
|
5161
5367
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5162
5368
|
);
|
5163
5369
|
}
|
5164
|
-
if ((0,
|
5370
|
+
if (!(0, import_utils28.isDefined)(setMaxFee)) {
|
5371
|
+
request.maxFee = maxFee;
|
5372
|
+
} else if (maxFee.gt(setMaxFee)) {
|
5165
5373
|
throw new import_errors16.FuelError(
|
5166
5374
|
import_errors16.ErrorCode.MAX_FEE_TOO_LOW,
|
5167
5375
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
5168
5376
|
);
|
5169
5377
|
}
|
5378
|
+
return request;
|
5170
5379
|
}
|
5171
5380
|
};
|
5172
5381
|
|
@@ -5174,8 +5383,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5174
5383
|
var import_address5 = require("@fuel-ts/address");
|
5175
5384
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5176
5385
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5177
|
-
var
|
5178
|
-
var
|
5386
|
+
var import_math22 = require("@fuel-ts/math");
|
5387
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5179
5388
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5180
5389
|
var Signer = class {
|
5181
5390
|
address;
|
@@ -5194,10 +5403,10 @@ var Signer = class {
|
|
5194
5403
|
privateKey = `0x${privateKey}`;
|
5195
5404
|
}
|
5196
5405
|
}
|
5197
|
-
const privateKeyBytes = (0,
|
5198
|
-
this.privateKey = (0,
|
5199
|
-
this.publicKey = (0,
|
5200
|
-
this.compressedPublicKey = (0,
|
5406
|
+
const privateKeyBytes = (0, import_math22.toBytes)(privateKey, 32);
|
5407
|
+
this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
|
5408
|
+
this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5409
|
+
this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
5201
5410
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
5202
5411
|
}
|
5203
5412
|
/**
|
@@ -5211,11 +5420,11 @@ var Signer = class {
|
|
5211
5420
|
* @returns hashed signature
|
5212
5421
|
*/
|
5213
5422
|
sign(data) {
|
5214
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
5215
|
-
const r = (0,
|
5216
|
-
const s = (0,
|
5423
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
|
5424
|
+
const r = (0, import_math22.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5425
|
+
const s = (0, import_math22.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5217
5426
|
s[0] |= (signature.recovery || 0) << 7;
|
5218
|
-
return (0,
|
5427
|
+
return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
|
5219
5428
|
}
|
5220
5429
|
/**
|
5221
5430
|
* Add point on the current elliptic curve
|
@@ -5224,8 +5433,8 @@ var Signer = class {
|
|
5224
5433
|
* @returns compressed point on the curve
|
5225
5434
|
*/
|
5226
5435
|
addPoint(point) {
|
5227
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5228
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5436
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
|
5437
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
|
5229
5438
|
const result = p0.add(p1);
|
5230
5439
|
return `0x${result.toHex(true)}`;
|
5231
5440
|
}
|
@@ -5237,16 +5446,16 @@ var Signer = class {
|
|
5237
5446
|
* @returns public key from signature from the
|
5238
5447
|
*/
|
5239
5448
|
static recoverPublicKey(data, signature) {
|
5240
|
-
const signedMessageBytes = (0,
|
5449
|
+
const signedMessageBytes = (0, import_utils29.arrayify)(signature);
|
5241
5450
|
const r = signedMessageBytes.slice(0, 32);
|
5242
5451
|
const s = signedMessageBytes.slice(32, 64);
|
5243
5452
|
const recoveryParam = (s[0] & 128) >> 7;
|
5244
5453
|
s[0] &= 127;
|
5245
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5454
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
|
5246
5455
|
recoveryParam
|
5247
5456
|
);
|
5248
|
-
const publicKey = sig.recoverPublicKey((0,
|
5249
|
-
return (0,
|
5457
|
+
const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
|
5458
|
+
return (0, import_utils29.hexlify)(publicKey);
|
5250
5459
|
}
|
5251
5460
|
/**
|
5252
5461
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5265,7 +5474,7 @@ var Signer = class {
|
|
5265
5474
|
* @returns random 32-byte hashed
|
5266
5475
|
*/
|
5267
5476
|
static generatePrivateKey(entropy) {
|
5268
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5477
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
|
5269
5478
|
}
|
5270
5479
|
/**
|
5271
5480
|
* Extended publicKey from a compact publicKey
|
@@ -5274,8 +5483,8 @@ var Signer = class {
|
|
5274
5483
|
* @returns extended publicKey
|
5275
5484
|
*/
|
5276
5485
|
static extendPublicKey(publicKey) {
|
5277
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5278
|
-
return (0,
|
5486
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
|
5487
|
+
return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
|
5279
5488
|
}
|
5280
5489
|
};
|
5281
5490
|
|
@@ -5283,7 +5492,7 @@ var Signer = class {
|
|
5283
5492
|
var import_address6 = require("@fuel-ts/address");
|
5284
5493
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5285
5494
|
var import_errors17 = require("@fuel-ts/errors");
|
5286
|
-
var
|
5495
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5287
5496
|
var import_uuid = require("uuid");
|
5288
5497
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5289
5498
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5366,7 +5575,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5366
5575
|
);
|
5367
5576
|
}
|
5368
5577
|
const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
5369
|
-
const privateKey = (0,
|
5578
|
+
const privateKey = (0, import_utils30.hexlify)(buffer);
|
5370
5579
|
return privateKey;
|
5371
5580
|
}
|
5372
5581
|
|
@@ -5411,7 +5620,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5411
5620
|
*/
|
5412
5621
|
async signMessage(message) {
|
5413
5622
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
5414
|
-
return (0,
|
5623
|
+
return (0, import_utils31.hexlify)(signedMessage);
|
5415
5624
|
}
|
5416
5625
|
/**
|
5417
5626
|
* Signs a transaction with the wallet's private key.
|
@@ -5424,7 +5633,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5424
5633
|
const chainId = this.provider.getChainId();
|
5425
5634
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5426
5635
|
const signature = await this.signer().sign(hashedTransaction);
|
5427
|
-
return (0,
|
5636
|
+
return (0, import_utils31.hexlify)(signature);
|
5428
5637
|
}
|
5429
5638
|
/**
|
5430
5639
|
* Populates a transaction with the witnesses signature.
|
@@ -5485,16 +5694,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5485
5694
|
// src/hdwallet/hdwallet.ts
|
5486
5695
|
var import_errors20 = require("@fuel-ts/errors");
|
5487
5696
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5488
|
-
var
|
5489
|
-
var
|
5490
|
-
var
|
5697
|
+
var import_math23 = require("@fuel-ts/math");
|
5698
|
+
var import_utils35 = require("@fuel-ts/utils");
|
5699
|
+
var import_ethers2 = require("ethers");
|
5491
5700
|
|
5492
5701
|
// src/mnemonic/mnemonic.ts
|
5493
5702
|
var import_crypto4 = require("@fuel-ts/crypto");
|
5494
5703
|
var import_errors19 = require("@fuel-ts/errors");
|
5495
5704
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5496
|
-
var
|
5497
|
-
var
|
5705
|
+
var import_utils33 = require("@fuel-ts/utils");
|
5706
|
+
var import_ethers = require("ethers");
|
5498
5707
|
|
5499
5708
|
// src/wordlists/words/english.ts
|
5500
5709
|
var english = [
|
@@ -7551,7 +7760,7 @@ var english = [
|
|
7551
7760
|
// src/mnemonic/utils.ts
|
7552
7761
|
var import_errors18 = require("@fuel-ts/errors");
|
7553
7762
|
var import_hasher4 = require("@fuel-ts/hasher");
|
7554
|
-
var
|
7763
|
+
var import_utils32 = require("@fuel-ts/utils");
|
7555
7764
|
function toUtf8Bytes(stri) {
|
7556
7765
|
const str = stri.normalize("NFKD");
|
7557
7766
|
const result = [];
|
@@ -7618,14 +7827,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
7618
7827
|
}
|
7619
7828
|
}
|
7620
7829
|
const checksumBits = entropy.length / 4;
|
7621
|
-
const checksum = (0,
|
7830
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
7622
7831
|
indices[indices.length - 1] <<= checksumBits;
|
7623
7832
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7624
7833
|
return indices;
|
7625
7834
|
}
|
7626
7835
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7627
7836
|
const size = Math.ceil(11 * words.length / 8);
|
7628
|
-
const entropy = (0,
|
7837
|
+
const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
|
7629
7838
|
let offset = 0;
|
7630
7839
|
for (let i = 0; i < words.length; i += 1) {
|
7631
7840
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -7645,7 +7854,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7645
7854
|
const entropyBits = 32 * words.length / 3;
|
7646
7855
|
const checksumBits = words.length / 3;
|
7647
7856
|
const checksumMask = getUpperMask(checksumBits);
|
7648
|
-
const checksum = (0,
|
7857
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7649
7858
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7650
7859
|
throw new import_errors18.FuelError(
|
7651
7860
|
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
@@ -7720,7 +7929,7 @@ var Mnemonic = class {
|
|
7720
7929
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7721
7930
|
const words = getWords(phrase);
|
7722
7931
|
assertMnemonic(words);
|
7723
|
-
return (0,
|
7932
|
+
return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
7724
7933
|
}
|
7725
7934
|
/**
|
7726
7935
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7728,7 +7937,7 @@ var Mnemonic = class {
|
|
7728
7937
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7729
7938
|
*/
|
7730
7939
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7731
|
-
const entropyBytes = (0,
|
7940
|
+
const entropyBytes = (0, import_utils33.arrayify)(entropy);
|
7732
7941
|
assertWordList(wordlist);
|
7733
7942
|
assertEntropy(entropyBytes);
|
7734
7943
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7742,7 +7951,7 @@ var Mnemonic = class {
|
|
7742
7951
|
assertMnemonic(getWords(phrase));
|
7743
7952
|
const phraseBytes = toUtf8Bytes(getPhrase(phrase));
|
7744
7953
|
const salt = toUtf8Bytes(`mnemonic${passphrase}`);
|
7745
|
-
return (0,
|
7954
|
+
return (0, import_ethers.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
7746
7955
|
}
|
7747
7956
|
/**
|
7748
7957
|
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
|
@@ -7797,14 +8006,14 @@ var Mnemonic = class {
|
|
7797
8006
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7798
8007
|
*/
|
7799
8008
|
static masterKeysFromSeed(seed) {
|
7800
|
-
const seedArray = (0,
|
8009
|
+
const seedArray = (0, import_utils33.arrayify)(seed);
|
7801
8010
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7802
8011
|
throw new import_errors19.FuelError(
|
7803
8012
|
import_errors19.ErrorCode.INVALID_SEED,
|
7804
8013
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7805
8014
|
);
|
7806
8015
|
}
|
7807
|
-
return (0,
|
8016
|
+
return (0, import_utils33.arrayify)((0, import_ethers.computeHmac)("sha512", MasterSecret, seedArray));
|
7808
8017
|
}
|
7809
8018
|
/**
|
7810
8019
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7815,22 +8024,22 @@ var Mnemonic = class {
|
|
7815
8024
|
*/
|
7816
8025
|
static seedToExtendedKey(seed, testnet = false) {
|
7817
8026
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7818
|
-
const prefix = (0,
|
8027
|
+
const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
7819
8028
|
const depth = "0x00";
|
7820
8029
|
const fingerprint = "0x00000000";
|
7821
8030
|
const index = "0x00000000";
|
7822
8031
|
const chainCode = masterKey.slice(32);
|
7823
8032
|
const privateKey = masterKey.slice(0, 32);
|
7824
|
-
const extendedKey = (0,
|
8033
|
+
const extendedKey = (0, import_utils33.concat)([
|
7825
8034
|
prefix,
|
7826
8035
|
depth,
|
7827
8036
|
fingerprint,
|
7828
8037
|
index,
|
7829
8038
|
chainCode,
|
7830
|
-
(0,
|
8039
|
+
(0, import_utils33.concat)(["0x00", privateKey])
|
7831
8040
|
]);
|
7832
|
-
const checksum = (0,
|
7833
|
-
return (0,
|
8041
|
+
const checksum = (0, import_ethers.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
8042
|
+
return (0, import_ethers.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
|
7834
8043
|
}
|
7835
8044
|
/**
|
7836
8045
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -7845,7 +8054,7 @@ var Mnemonic = class {
|
|
7845
8054
|
* @returns A randomly generated mnemonic
|
7846
8055
|
*/
|
7847
8056
|
static generate(size = 32, extraEntropy = "") {
|
7848
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
8057
|
+
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
|
7849
8058
|
return Mnemonic.entropyToMnemonic(entropy);
|
7850
8059
|
}
|
7851
8060
|
};
|
@@ -7853,12 +8062,12 @@ var mnemonic_default = Mnemonic;
|
|
7853
8062
|
|
7854
8063
|
// src/hdwallet/hdwallet.ts
|
7855
8064
|
var HARDENED_INDEX = 2147483648;
|
7856
|
-
var MainnetPRV2 = (0,
|
7857
|
-
var MainnetPUB = (0,
|
7858
|
-
var TestnetPRV2 = (0,
|
7859
|
-
var TestnetPUB = (0,
|
8065
|
+
var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
|
8066
|
+
var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
|
8067
|
+
var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
|
8068
|
+
var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
|
7860
8069
|
function base58check(data) {
|
7861
|
-
return (0,
|
8070
|
+
return (0, import_ethers2.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers2.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
7862
8071
|
}
|
7863
8072
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
7864
8073
|
if (isPublic) {
|
@@ -7867,11 +8076,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
7867
8076
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
7868
8077
|
}
|
7869
8078
|
function isPublicExtendedKey(extendedKey) {
|
7870
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
8079
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
|
7871
8080
|
}
|
7872
8081
|
function isValidExtendedKey(extendedKey) {
|
7873
8082
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
7874
|
-
(0,
|
8083
|
+
(0, import_utils35.hexlify)(extendedKey.slice(0, 4))
|
7875
8084
|
);
|
7876
8085
|
}
|
7877
8086
|
function parsePath(path2, depth = 0) {
|
@@ -7889,8 +8098,8 @@ function parsePath(path2, depth = 0) {
|
|
7889
8098
|
var HDWallet = class {
|
7890
8099
|
depth = 0;
|
7891
8100
|
index = 0;
|
7892
|
-
fingerprint = (0,
|
7893
|
-
parentFingerprint = (0,
|
8101
|
+
fingerprint = (0, import_utils35.hexlify)("0x00000000");
|
8102
|
+
parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
|
7894
8103
|
privateKey;
|
7895
8104
|
publicKey;
|
7896
8105
|
chainCode;
|
@@ -7902,8 +8111,8 @@ var HDWallet = class {
|
|
7902
8111
|
constructor(config) {
|
7903
8112
|
if (config.privateKey) {
|
7904
8113
|
const signer = new Signer(config.privateKey);
|
7905
|
-
this.publicKey = (0,
|
7906
|
-
this.privateKey = (0,
|
8114
|
+
this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
|
8115
|
+
this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
|
7907
8116
|
} else {
|
7908
8117
|
if (!config.publicKey) {
|
7909
8118
|
throw new import_errors20.FuelError(
|
@@ -7911,10 +8120,10 @@ var HDWallet = class {
|
|
7911
8120
|
"Both public and private Key cannot be missing. At least one should be provided."
|
7912
8121
|
);
|
7913
8122
|
}
|
7914
|
-
this.publicKey = (0,
|
8123
|
+
this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
|
7915
8124
|
}
|
7916
8125
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
7917
|
-
this.fingerprint = (0,
|
8126
|
+
this.fingerprint = (0, import_ethers2.dataSlice)((0, import_ethers2.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
7918
8127
|
this.depth = config.depth || this.depth;
|
7919
8128
|
this.index = config.index || this.index;
|
7920
8129
|
this.chainCode = config.chainCode;
|
@@ -7930,9 +8139,9 @@ var HDWallet = class {
|
|
7930
8139
|
* @returns A new instance of HDWallet on the derived index
|
7931
8140
|
*/
|
7932
8141
|
deriveIndex(index) {
|
7933
|
-
const privateKey = this.privateKey && (0,
|
7934
|
-
const publicKey = (0,
|
7935
|
-
const chainCode = (0,
|
8142
|
+
const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
|
8143
|
+
const publicKey = (0, import_utils35.arrayify)(this.publicKey);
|
8144
|
+
const chainCode = (0, import_utils35.arrayify)(this.chainCode);
|
7936
8145
|
const data = new Uint8Array(37);
|
7937
8146
|
if (index & HARDENED_INDEX) {
|
7938
8147
|
if (!privateKey) {
|
@@ -7943,15 +8152,15 @@ var HDWallet = class {
|
|
7943
8152
|
}
|
7944
8153
|
data.set(privateKey, 1);
|
7945
8154
|
} else {
|
7946
|
-
data.set((0,
|
8155
|
+
data.set((0, import_utils35.arrayify)(this.publicKey));
|
7947
8156
|
}
|
7948
|
-
data.set((0,
|
7949
|
-
const bytes = (0,
|
8157
|
+
data.set((0, import_math23.toBytes)(index, 4), 33);
|
8158
|
+
const bytes = (0, import_utils35.arrayify)((0, import_ethers2.computeHmac)("sha512", chainCode, data));
|
7950
8159
|
const IL = bytes.slice(0, 32);
|
7951
8160
|
const IR = bytes.slice(32);
|
7952
8161
|
if (privateKey) {
|
7953
8162
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7954
|
-
const ki = (0,
|
8163
|
+
const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
7955
8164
|
return new HDWallet({
|
7956
8165
|
privateKey: ki,
|
7957
8166
|
chainCode: IR,
|
@@ -7960,7 +8169,7 @@ var HDWallet = class {
|
|
7960
8169
|
parentFingerprint: this.fingerprint
|
7961
8170
|
});
|
7962
8171
|
}
|
7963
|
-
const signer = new Signer((0,
|
8172
|
+
const signer = new Signer((0, import_utils35.hexlify)(IL));
|
7964
8173
|
const Ki = signer.addPoint(publicKey);
|
7965
8174
|
return new HDWallet({
|
7966
8175
|
publicKey: Ki,
|
@@ -7995,12 +8204,12 @@ var HDWallet = class {
|
|
7995
8204
|
);
|
7996
8205
|
}
|
7997
8206
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
7998
|
-
const depth = (0,
|
8207
|
+
const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
|
7999
8208
|
const parentFingerprint = this.parentFingerprint;
|
8000
|
-
const index = (0,
|
8209
|
+
const index = (0, import_math23.toHex)(this.index, 4);
|
8001
8210
|
const chainCode = this.chainCode;
|
8002
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
8003
|
-
const extendedKey = (0,
|
8211
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8212
|
+
const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
8004
8213
|
return base58check(extendedKey);
|
8005
8214
|
}
|
8006
8215
|
/**
|
@@ -8012,13 +8221,13 @@ var HDWallet = class {
|
|
8012
8221
|
static fromSeed(seed) {
|
8013
8222
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8014
8223
|
return new HDWallet({
|
8015
|
-
chainCode: (0,
|
8016
|
-
privateKey: (0,
|
8224
|
+
chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
|
8225
|
+
privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
|
8017
8226
|
});
|
8018
8227
|
}
|
8019
8228
|
static fromExtendedKey(extendedKey) {
|
8020
|
-
const decoded = (0,
|
8021
|
-
const bytes = (0,
|
8229
|
+
const decoded = (0, import_ethers2.toBeHex)((0, import_ethers2.decodeBase58)(extendedKey));
|
8230
|
+
const bytes = (0, import_utils35.arrayify)(decoded);
|
8022
8231
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8023
8232
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8024
8233
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -8027,9 +8236,9 @@ var HDWallet = class {
|
|
8027
8236
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8028
8237
|
}
|
8029
8238
|
const depth = bytes[4];
|
8030
|
-
const parentFingerprint = (0,
|
8031
|
-
const index = parseInt((0,
|
8032
|
-
const chainCode = (0,
|
8239
|
+
const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
|
8240
|
+
const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8241
|
+
const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
|
8033
8242
|
const key = bytes.slice(45, 78);
|
8034
8243
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8035
8244
|
throw new import_errors20.FuelError(
|
@@ -8246,7 +8455,7 @@ var generateTestWallet = async (provider, quantities) => {
|
|
8246
8455
|
// src/test-utils/launchNode.ts
|
8247
8456
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
8248
8457
|
var import_crypto6 = require("@fuel-ts/crypto");
|
8249
|
-
var
|
8458
|
+
var import_utils36 = require("@fuel-ts/utils");
|
8250
8459
|
var import_cli_utils = require("@fuel-ts/utils/cli-utils");
|
8251
8460
|
var import_child_process = require("child_process");
|
8252
8461
|
var import_crypto7 = require("crypto");
|
@@ -8304,7 +8513,7 @@ var launchNode = async ({
|
|
8304
8513
|
"--poa-instant"
|
8305
8514
|
]);
|
8306
8515
|
const snapshotDir = getFlagValueFromArgs(args, "--snapshot");
|
8307
|
-
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") ||
|
8516
|
+
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
|
8308
8517
|
const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
|
8309
8518
|
const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
|
8310
8519
|
const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
|
@@ -8329,8 +8538,8 @@ var launchNode = async ({
|
|
8329
8538
|
if (!(0, import_fs.existsSync)(tempDirPath)) {
|
8330
8539
|
(0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
|
8331
8540
|
}
|
8332
|
-
let { stateConfigJson } =
|
8333
|
-
const { chainConfigJson, metadataJson } =
|
8541
|
+
let { stateConfigJson } = import_utils36.defaultSnapshotConfigs;
|
8542
|
+
const { chainConfigJson, metadataJson } = import_utils36.defaultSnapshotConfigs;
|
8334
8543
|
stateConfigJson = {
|
8335
8544
|
...stateConfigJson,
|
8336
8545
|
coins: [
|
@@ -8348,9 +8557,9 @@ var launchNode = async ({
|
|
8348
8557
|
if (!process.env.GENESIS_SECRET) {
|
8349
8558
|
const pk = Signer.generatePrivateKey();
|
8350
8559
|
const signer = new Signer(pk);
|
8351
|
-
process.env.GENESIS_SECRET = (0,
|
8560
|
+
process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
|
8352
8561
|
stateConfigJson.coins.push({
|
8353
|
-
tx_id: (0,
|
8562
|
+
tx_id: (0, import_utils36.hexlify)((0, import_crypto6.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
|
8354
8563
|
owner: signer.address.toHexString(),
|
8355
8564
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8356
8565
|
amount: "18446744073709551615",
|
@@ -8366,9 +8575,11 @@ var launchNode = async ({
|
|
8366
8575
|
const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
|
8367
8576
|
const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
|
8368
8577
|
const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
|
8578
|
+
const stateTransitionWritePath = import_path.default.join(tempDirPath, "state_transition_bytecode.wasm");
|
8369
8579
|
(0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
|
8370
8580
|
(0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
|
8371
8581
|
(0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
|
8582
|
+
(0, import_fs.writeFileSync)(stateTransitionWritePath, JSON.stringify(""));
|
8372
8583
|
snapshotDirToUse = tempDirPath;
|
8373
8584
|
}
|
8374
8585
|
const child = (0, import_child_process.spawn)(
|