@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.mjs
CHANGED
@@ -26,8 +26,8 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
|
|
26
26
|
import { Address as Address3 } from "@fuel-ts/address";
|
27
27
|
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
28
28
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
29
|
-
import { bn as
|
30
|
-
import { arrayify as arrayify14, isDefined } from "@fuel-ts/utils";
|
29
|
+
import { bn as bn20 } from "@fuel-ts/math";
|
30
|
+
import { arrayify as arrayify14, isDefined as isDefined2 } from "@fuel-ts/utils";
|
31
31
|
import { clone as clone4 } from "ramda";
|
32
32
|
|
33
33
|
// src/providers/coin-quantity.ts
|
@@ -68,7 +68,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
68
68
|
// src/providers/provider.ts
|
69
69
|
import { Address as Address2 } from "@fuel-ts/address";
|
70
70
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
71
|
-
import { BN, bn as
|
71
|
+
import { BN, bn as bn17 } from "@fuel-ts/math";
|
72
72
|
import {
|
73
73
|
InputType as InputType7,
|
74
74
|
TransactionType as TransactionType8,
|
@@ -78,13 +78,12 @@ import {
|
|
78
78
|
import { arrayify as arrayify11, hexlify as hexlify12, DateTime as DateTime2 } from "@fuel-ts/utils";
|
79
79
|
import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
|
80
80
|
import { equalBytes } from "@noble/curves/abstract/utils";
|
81
|
-
import { Network } from "ethers";
|
82
81
|
import { GraphQLClient } from "graphql-request";
|
83
82
|
import { clone as clone3 } from "ramda";
|
84
83
|
|
85
84
|
// src/providers/__generated__/operations.ts
|
86
85
|
import gql from "graphql-tag";
|
87
|
-
var
|
86
|
+
var TransactionStatusSubscriptionFragmentDoc = gql`
|
88
87
|
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
89
88
|
type: __typename
|
90
89
|
... on SqueezedOutStatus {
|
@@ -92,7 +91,13 @@ var TransactionStatusSubscriptionFragmentFragmentDoc = gql`
|
|
92
91
|
}
|
93
92
|
}
|
94
93
|
`;
|
95
|
-
var
|
94
|
+
var SubmittedStatusFragmentDoc = gql`
|
95
|
+
fragment SubmittedStatusFragment on SubmittedStatus {
|
96
|
+
type: __typename
|
97
|
+
time
|
98
|
+
}
|
99
|
+
`;
|
100
|
+
var ReceiptFragmentDoc = gql`
|
96
101
|
fragment receiptFragment on Receipt {
|
97
102
|
id
|
98
103
|
pc
|
@@ -124,44 +129,65 @@ var ReceiptFragmentFragmentDoc = gql`
|
|
124
129
|
subId
|
125
130
|
}
|
126
131
|
`;
|
127
|
-
var
|
128
|
-
fragment
|
132
|
+
var SuccessStatusFragmentDoc = gql`
|
133
|
+
fragment SuccessStatusFragment on SuccessStatus {
|
134
|
+
type: __typename
|
135
|
+
block {
|
136
|
+
id
|
137
|
+
}
|
138
|
+
time
|
139
|
+
programState {
|
140
|
+
returnType
|
141
|
+
data
|
142
|
+
}
|
143
|
+
receipts {
|
144
|
+
...receiptFragment
|
145
|
+
}
|
146
|
+
totalGas
|
147
|
+
totalFee
|
148
|
+
}
|
149
|
+
${ReceiptFragmentDoc}`;
|
150
|
+
var FailureStatusFragmentDoc = gql`
|
151
|
+
fragment FailureStatusFragment on FailureStatus {
|
129
152
|
type: __typename
|
153
|
+
block {
|
154
|
+
id
|
155
|
+
}
|
156
|
+
totalGas
|
157
|
+
totalFee
|
158
|
+
time
|
159
|
+
reason
|
160
|
+
receipts {
|
161
|
+
...receiptFragment
|
162
|
+
}
|
163
|
+
}
|
164
|
+
${ReceiptFragmentDoc}`;
|
165
|
+
var SqueezedOutStatusFragmentDoc = gql`
|
166
|
+
fragment SqueezedOutStatusFragment on SqueezedOutStatus {
|
167
|
+
type: __typename
|
168
|
+
reason
|
169
|
+
}
|
170
|
+
`;
|
171
|
+
var TransactionStatusFragmentDoc = gql`
|
172
|
+
fragment transactionStatusFragment on TransactionStatus {
|
130
173
|
... on SubmittedStatus {
|
131
|
-
|
174
|
+
...SubmittedStatusFragment
|
132
175
|
}
|
133
176
|
... on SuccessStatus {
|
134
|
-
|
135
|
-
id
|
136
|
-
}
|
137
|
-
time
|
138
|
-
receipts {
|
139
|
-
...receiptFragment
|
140
|
-
}
|
141
|
-
programState {
|
142
|
-
returnType
|
143
|
-
data
|
144
|
-
}
|
145
|
-
receipts {
|
146
|
-
...receiptFragment
|
147
|
-
}
|
177
|
+
...SuccessStatusFragment
|
148
178
|
}
|
149
179
|
... on FailureStatus {
|
150
|
-
|
151
|
-
id
|
152
|
-
}
|
153
|
-
time
|
154
|
-
reason
|
155
|
-
receipts {
|
156
|
-
...receiptFragment
|
157
|
-
}
|
180
|
+
...FailureStatusFragment
|
158
181
|
}
|
159
182
|
... on SqueezedOutStatus {
|
160
|
-
|
183
|
+
...SqueezedOutStatusFragment
|
161
184
|
}
|
162
185
|
}
|
163
|
-
${
|
164
|
-
|
186
|
+
${SubmittedStatusFragmentDoc}
|
187
|
+
${SuccessStatusFragmentDoc}
|
188
|
+
${FailureStatusFragmentDoc}
|
189
|
+
${SqueezedOutStatusFragmentDoc}`;
|
190
|
+
var TransactionFragmentDoc = gql`
|
165
191
|
fragment transactionFragment on Transaction {
|
166
192
|
id
|
167
193
|
rawPayload
|
@@ -169,8 +195,8 @@ var TransactionFragmentFragmentDoc = gql`
|
|
169
195
|
...transactionStatusFragment
|
170
196
|
}
|
171
197
|
}
|
172
|
-
${
|
173
|
-
var
|
198
|
+
${TransactionStatusFragmentDoc}`;
|
199
|
+
var InputEstimatePredicatesFragmentDoc = gql`
|
174
200
|
fragment inputEstimatePredicatesFragment on Input {
|
175
201
|
... on InputCoin {
|
176
202
|
predicateGasUsed
|
@@ -180,15 +206,17 @@ var InputEstimatePredicatesFragmentFragmentDoc = gql`
|
|
180
206
|
}
|
181
207
|
}
|
182
208
|
`;
|
183
|
-
var
|
209
|
+
var TransactionEstimatePredicatesFragmentDoc = gql`
|
184
210
|
fragment transactionEstimatePredicatesFragment on Transaction {
|
185
211
|
inputs {
|
186
212
|
...inputEstimatePredicatesFragment
|
187
213
|
}
|
188
214
|
}
|
189
|
-
${
|
190
|
-
var
|
215
|
+
${InputEstimatePredicatesFragmentDoc}`;
|
216
|
+
var DryRunFailureStatusFragmentDoc = gql`
|
191
217
|
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
218
|
+
totalGas
|
219
|
+
totalFee
|
192
220
|
reason
|
193
221
|
programState {
|
194
222
|
returnType
|
@@ -196,15 +224,17 @@ var DryRunFailureStatusFragmentFragmentDoc = gql`
|
|
196
224
|
}
|
197
225
|
}
|
198
226
|
`;
|
199
|
-
var
|
227
|
+
var DryRunSuccessStatusFragmentDoc = gql`
|
200
228
|
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
229
|
+
totalGas
|
230
|
+
totalFee
|
201
231
|
programState {
|
202
232
|
returnType
|
203
233
|
data
|
204
234
|
}
|
205
235
|
}
|
206
236
|
`;
|
207
|
-
var
|
237
|
+
var DryRunTransactionStatusFragmentDoc = gql`
|
208
238
|
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
209
239
|
... on DryRunFailureStatus {
|
210
240
|
...dryRunFailureStatusFragment
|
@@ -213,9 +243,9 @@ var DryRunTransactionStatusFragmentFragmentDoc = gql`
|
|
213
243
|
...dryRunSuccessStatusFragment
|
214
244
|
}
|
215
245
|
}
|
216
|
-
${
|
217
|
-
${
|
218
|
-
var
|
246
|
+
${DryRunFailureStatusFragmentDoc}
|
247
|
+
${DryRunSuccessStatusFragmentDoc}`;
|
248
|
+
var DryRunTransactionExecutionStatusFragmentDoc = gql`
|
219
249
|
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
220
250
|
id
|
221
251
|
status {
|
@@ -225,11 +255,11 @@ var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
|
|
225
255
|
...receiptFragment
|
226
256
|
}
|
227
257
|
}
|
228
|
-
${
|
229
|
-
${
|
230
|
-
var
|
258
|
+
${DryRunTransactionStatusFragmentDoc}
|
259
|
+
${ReceiptFragmentDoc}`;
|
260
|
+
var CoinFragmentDoc = gql`
|
231
261
|
fragment coinFragment on Coin {
|
232
|
-
__typename
|
262
|
+
type: __typename
|
233
263
|
utxoId
|
234
264
|
owner
|
235
265
|
amount
|
@@ -238,9 +268,9 @@ var CoinFragmentFragmentDoc = gql`
|
|
238
268
|
txCreatedIdx
|
239
269
|
}
|
240
270
|
`;
|
241
|
-
var
|
271
|
+
var MessageCoinFragmentDoc = gql`
|
242
272
|
fragment messageCoinFragment on MessageCoin {
|
243
|
-
__typename
|
273
|
+
type: __typename
|
244
274
|
sender
|
245
275
|
recipient
|
246
276
|
nonce
|
@@ -249,7 +279,7 @@ var MessageCoinFragmentFragmentDoc = gql`
|
|
249
279
|
daHeight
|
250
280
|
}
|
251
281
|
`;
|
252
|
-
var
|
282
|
+
var MessageFragmentDoc = gql`
|
253
283
|
fragment messageFragment on Message {
|
254
284
|
amount
|
255
285
|
sender
|
@@ -259,7 +289,7 @@ var MessageFragmentFragmentDoc = gql`
|
|
259
289
|
daHeight
|
260
290
|
}
|
261
291
|
`;
|
262
|
-
var
|
292
|
+
var MessageProofFragmentDoc = gql`
|
263
293
|
fragment messageProofFragment on MessageProof {
|
264
294
|
messageProof {
|
265
295
|
proofSet
|
@@ -306,14 +336,14 @@ var MessageProofFragmentFragmentDoc = gql`
|
|
306
336
|
data
|
307
337
|
}
|
308
338
|
`;
|
309
|
-
var
|
339
|
+
var BalanceFragmentDoc = gql`
|
310
340
|
fragment balanceFragment on Balance {
|
311
341
|
owner
|
312
342
|
amount
|
313
343
|
assetId
|
314
344
|
}
|
315
345
|
`;
|
316
|
-
var
|
346
|
+
var BlockFragmentDoc = gql`
|
317
347
|
fragment blockFragment on Block {
|
318
348
|
id
|
319
349
|
height
|
@@ -325,7 +355,7 @@ var BlockFragmentFragmentDoc = gql`
|
|
325
355
|
}
|
326
356
|
}
|
327
357
|
`;
|
328
|
-
var
|
358
|
+
var TxParametersFragmentDoc = gql`
|
329
359
|
fragment TxParametersFragment on TxParameters {
|
330
360
|
version
|
331
361
|
maxInputs
|
@@ -333,9 +363,10 @@ var TxParametersFragmentFragmentDoc = gql`
|
|
333
363
|
maxWitnesses
|
334
364
|
maxGasPerTx
|
335
365
|
maxSize
|
366
|
+
maxBytecodeSubsections
|
336
367
|
}
|
337
368
|
`;
|
338
|
-
var
|
369
|
+
var PredicateParametersFragmentDoc = gql`
|
339
370
|
fragment PredicateParametersFragment on PredicateParameters {
|
340
371
|
version
|
341
372
|
maxPredicateLength
|
@@ -344,41 +375,42 @@ var PredicateParametersFragmentFragmentDoc = gql`
|
|
344
375
|
maxMessageDataLength
|
345
376
|
}
|
346
377
|
`;
|
347
|
-
var
|
378
|
+
var ScriptParametersFragmentDoc = gql`
|
348
379
|
fragment ScriptParametersFragment on ScriptParameters {
|
349
380
|
version
|
350
381
|
maxScriptLength
|
351
382
|
maxScriptDataLength
|
352
383
|
}
|
353
384
|
`;
|
354
|
-
var
|
385
|
+
var ContractParametersFragmentDoc = gql`
|
355
386
|
fragment ContractParametersFragment on ContractParameters {
|
356
387
|
version
|
357
388
|
contractMaxSize
|
358
389
|
maxStorageSlots
|
359
390
|
}
|
360
391
|
`;
|
361
|
-
var
|
392
|
+
var FeeParametersFragmentDoc = gql`
|
362
393
|
fragment FeeParametersFragment on FeeParameters {
|
363
394
|
version
|
364
395
|
gasPriceFactor
|
365
396
|
gasPerByte
|
366
397
|
}
|
367
398
|
`;
|
368
|
-
var
|
399
|
+
var DependentCostFragmentDoc = gql`
|
369
400
|
fragment DependentCostFragment on DependentCost {
|
370
|
-
__typename
|
371
401
|
... on LightOperation {
|
402
|
+
type: __typename
|
372
403
|
base
|
373
404
|
unitsPerGas
|
374
405
|
}
|
375
406
|
... on HeavyOperation {
|
407
|
+
type: __typename
|
376
408
|
base
|
377
409
|
gasPerUnit
|
378
410
|
}
|
379
411
|
}
|
380
412
|
`;
|
381
|
-
var
|
413
|
+
var GasCostsFragmentDoc = gql`
|
382
414
|
fragment GasCostsFragment on GasCosts {
|
383
415
|
version
|
384
416
|
add
|
@@ -534,8 +566,8 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
534
566
|
}
|
535
567
|
newStoragePerByte
|
536
568
|
}
|
537
|
-
${
|
538
|
-
var
|
569
|
+
${DependentCostFragmentDoc}`;
|
570
|
+
var ConsensusParametersFragmentDoc = gql`
|
539
571
|
fragment consensusParametersFragment on ConsensusParameters {
|
540
572
|
version
|
541
573
|
txParams {
|
@@ -559,13 +591,13 @@ var ConsensusParametersFragmentFragmentDoc = gql`
|
|
559
591
|
baseAssetId
|
560
592
|
chainId
|
561
593
|
}
|
562
|
-
${
|
563
|
-
${
|
564
|
-
${
|
565
|
-
${
|
566
|
-
${
|
567
|
-
${
|
568
|
-
var
|
594
|
+
${TxParametersFragmentDoc}
|
595
|
+
${PredicateParametersFragmentDoc}
|
596
|
+
${ScriptParametersFragmentDoc}
|
597
|
+
${ContractParametersFragmentDoc}
|
598
|
+
${FeeParametersFragmentDoc}
|
599
|
+
${GasCostsFragmentDoc}`;
|
600
|
+
var ChainInfoFragmentDoc = gql`
|
569
601
|
fragment chainInfoFragment on ChainInfo {
|
570
602
|
name
|
571
603
|
latestBlock {
|
@@ -576,16 +608,16 @@ var ChainInfoFragmentFragmentDoc = gql`
|
|
576
608
|
...consensusParametersFragment
|
577
609
|
}
|
578
610
|
}
|
579
|
-
${
|
580
|
-
${
|
581
|
-
var
|
611
|
+
${BlockFragmentDoc}
|
612
|
+
${ConsensusParametersFragmentDoc}`;
|
613
|
+
var ContractBalanceFragmentDoc = gql`
|
582
614
|
fragment contractBalanceFragment on ContractBalance {
|
583
615
|
contract
|
584
616
|
amount
|
585
617
|
assetId
|
586
618
|
}
|
587
619
|
`;
|
588
|
-
var
|
620
|
+
var PageInfoFragmentDoc = gql`
|
589
621
|
fragment pageInfoFragment on PageInfo {
|
590
622
|
hasPreviousPage
|
591
623
|
hasNextPage
|
@@ -593,7 +625,7 @@ var PageInfoFragmentFragmentDoc = gql`
|
|
593
625
|
endCursor
|
594
626
|
}
|
595
627
|
`;
|
596
|
-
var
|
628
|
+
var NodeInfoFragmentDoc = gql`
|
597
629
|
fragment nodeInfoFragment on NodeInfo {
|
598
630
|
utxoValidation
|
599
631
|
vmBacktrace
|
@@ -602,6 +634,14 @@ var NodeInfoFragmentFragmentDoc = gql`
|
|
602
634
|
nodeVersion
|
603
635
|
}
|
604
636
|
`;
|
637
|
+
var RelayedTransactionStatusFragmentDoc = gql`
|
638
|
+
fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
|
639
|
+
... on RelayedTransactionFailed {
|
640
|
+
blockHeight
|
641
|
+
failure
|
642
|
+
}
|
643
|
+
}
|
644
|
+
`;
|
605
645
|
var GetVersionDocument = gql`
|
606
646
|
query getVersion {
|
607
647
|
nodeInfo {
|
@@ -615,28 +655,28 @@ var GetNodeInfoDocument = gql`
|
|
615
655
|
...nodeInfoFragment
|
616
656
|
}
|
617
657
|
}
|
618
|
-
${
|
658
|
+
${NodeInfoFragmentDoc}`;
|
619
659
|
var GetChainDocument = gql`
|
620
660
|
query getChain {
|
621
661
|
chain {
|
622
662
|
...chainInfoFragment
|
623
663
|
}
|
624
664
|
}
|
625
|
-
${
|
665
|
+
${ChainInfoFragmentDoc}`;
|
626
666
|
var GetTransactionDocument = gql`
|
627
667
|
query getTransaction($transactionId: TransactionId!) {
|
628
668
|
transaction(id: $transactionId) {
|
629
669
|
...transactionFragment
|
630
670
|
}
|
631
671
|
}
|
632
|
-
${
|
672
|
+
${TransactionFragmentDoc}`;
|
633
673
|
var GetTransactionWithReceiptsDocument = gql`
|
634
674
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
635
675
|
transaction(id: $transactionId) {
|
636
676
|
...transactionFragment
|
637
677
|
}
|
638
678
|
}
|
639
|
-
${
|
679
|
+
${TransactionFragmentDoc}`;
|
640
680
|
var GetTransactionsDocument = gql`
|
641
681
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
642
682
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -647,7 +687,7 @@ var GetTransactionsDocument = gql`
|
|
647
687
|
}
|
648
688
|
}
|
649
689
|
}
|
650
|
-
${
|
690
|
+
${TransactionFragmentDoc}`;
|
651
691
|
var GetTransactionsByOwnerDocument = gql`
|
652
692
|
query getTransactionsByOwner($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
653
693
|
transactionsByOwner(
|
@@ -667,22 +707,22 @@ var GetTransactionsByOwnerDocument = gql`
|
|
667
707
|
}
|
668
708
|
}
|
669
709
|
}
|
670
|
-
${
|
671
|
-
${
|
710
|
+
${PageInfoFragmentDoc}
|
711
|
+
${TransactionFragmentDoc}`;
|
672
712
|
var EstimatePredicatesDocument = gql`
|
673
713
|
query estimatePredicates($encodedTransaction: HexString!) {
|
674
714
|
estimatePredicates(tx: $encodedTransaction) {
|
675
715
|
...transactionEstimatePredicatesFragment
|
676
716
|
}
|
677
717
|
}
|
678
|
-
${
|
718
|
+
${TransactionEstimatePredicatesFragmentDoc}`;
|
679
719
|
var GetBlockDocument = gql`
|
680
720
|
query getBlock($blockId: BlockId, $height: U32) {
|
681
721
|
block(id: $blockId, height: $height) {
|
682
722
|
...blockFragment
|
683
723
|
}
|
684
724
|
}
|
685
|
-
${
|
725
|
+
${BlockFragmentDoc}`;
|
686
726
|
var GetBlockWithTransactionsDocument = gql`
|
687
727
|
query getBlockWithTransactions($blockId: BlockId, $blockHeight: U32) {
|
688
728
|
block(id: $blockId, height: $blockHeight) {
|
@@ -692,8 +732,8 @@ var GetBlockWithTransactionsDocument = gql`
|
|
692
732
|
}
|
693
733
|
}
|
694
734
|
}
|
695
|
-
${
|
696
|
-
${
|
735
|
+
${BlockFragmentDoc}
|
736
|
+
${TransactionFragmentDoc}`;
|
697
737
|
var GetBlocksDocument = gql`
|
698
738
|
query getBlocks($after: String, $before: String, $first: Int, $last: Int) {
|
699
739
|
blocks(after: $after, before: $before, first: $first, last: $last) {
|
@@ -704,14 +744,14 @@ var GetBlocksDocument = gql`
|
|
704
744
|
}
|
705
745
|
}
|
706
746
|
}
|
707
|
-
${
|
747
|
+
${BlockFragmentDoc}`;
|
708
748
|
var GetCoinDocument = gql`
|
709
749
|
query getCoin($coinId: UtxoId!) {
|
710
750
|
coin(utxoId: $coinId) {
|
711
751
|
...coinFragment
|
712
752
|
}
|
713
753
|
}
|
714
|
-
${
|
754
|
+
${CoinFragmentDoc}`;
|
715
755
|
var GetCoinsDocument = gql`
|
716
756
|
query getCoins($filter: CoinFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
717
757
|
coins(
|
@@ -728,7 +768,7 @@ var GetCoinsDocument = gql`
|
|
728
768
|
}
|
729
769
|
}
|
730
770
|
}
|
731
|
-
${
|
771
|
+
${CoinFragmentDoc}`;
|
732
772
|
var GetCoinsToSpendDocument = gql`
|
733
773
|
query getCoinsToSpend($owner: Address!, $queryPerAsset: [SpendQueryElementInput!]!, $excludedIds: ExcludeInput) {
|
734
774
|
coinsToSpend(
|
@@ -740,8 +780,8 @@ var GetCoinsToSpendDocument = gql`
|
|
740
780
|
...messageCoinFragment
|
741
781
|
}
|
742
782
|
}
|
743
|
-
${
|
744
|
-
${
|
783
|
+
${CoinFragmentDoc}
|
784
|
+
${MessageCoinFragmentDoc}`;
|
745
785
|
var GetContractDocument = gql`
|
746
786
|
query getContract($contractId: ContractId!) {
|
747
787
|
contract(id: $contractId) {
|
@@ -756,14 +796,14 @@ var GetContractBalanceDocument = gql`
|
|
756
796
|
...contractBalanceFragment
|
757
797
|
}
|
758
798
|
}
|
759
|
-
${
|
799
|
+
${ContractBalanceFragmentDoc}`;
|
760
800
|
var GetBalanceDocument = gql`
|
761
801
|
query getBalance($owner: Address!, $assetId: AssetId!) {
|
762
802
|
balance(owner: $owner, assetId: $assetId) {
|
763
803
|
...balanceFragment
|
764
804
|
}
|
765
805
|
}
|
766
|
-
${
|
806
|
+
${BalanceFragmentDoc}`;
|
767
807
|
var GetLatestGasPriceDocument = gql`
|
768
808
|
query getLatestGasPrice {
|
769
809
|
latestGasPrice {
|
@@ -794,7 +834,7 @@ var GetBalancesDocument = gql`
|
|
794
834
|
}
|
795
835
|
}
|
796
836
|
}
|
797
|
-
${
|
837
|
+
${BalanceFragmentDoc}`;
|
798
838
|
var GetMessagesDocument = gql`
|
799
839
|
query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
800
840
|
messages(
|
@@ -811,7 +851,7 @@ var GetMessagesDocument = gql`
|
|
811
851
|
}
|
812
852
|
}
|
813
853
|
}
|
814
|
-
${
|
854
|
+
${MessageFragmentDoc}`;
|
815
855
|
var GetMessageProofDocument = gql`
|
816
856
|
query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
|
817
857
|
messageProof(
|
@@ -823,7 +863,7 @@ var GetMessageProofDocument = gql`
|
|
823
863
|
...messageProofFragment
|
824
864
|
}
|
825
865
|
}
|
826
|
-
${
|
866
|
+
${MessageProofFragmentDoc}`;
|
827
867
|
var GetMessageStatusDocument = gql`
|
828
868
|
query getMessageStatus($nonce: Nonce!) {
|
829
869
|
messageStatus(nonce: $nonce) {
|
@@ -831,13 +871,20 @@ var GetMessageStatusDocument = gql`
|
|
831
871
|
}
|
832
872
|
}
|
833
873
|
`;
|
874
|
+
var GetRelayedTransactionStatusDocument = gql`
|
875
|
+
query getRelayedTransactionStatus($relayedTransactionId: RelayedTransactionId!) {
|
876
|
+
relayedTransactionStatus(id: $relayedTransactionId) {
|
877
|
+
...relayedTransactionStatusFragment
|
878
|
+
}
|
879
|
+
}
|
880
|
+
${RelayedTransactionStatusFragmentDoc}`;
|
834
881
|
var DryRunDocument = gql`
|
835
882
|
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
836
883
|
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
837
884
|
...dryRunTransactionExecutionStatusFragment
|
838
885
|
}
|
839
886
|
}
|
840
|
-
${
|
887
|
+
${DryRunTransactionExecutionStatusFragmentDoc}`;
|
841
888
|
var SubmitDocument = gql`
|
842
889
|
mutation submit($encodedTransaction: HexString!) {
|
843
890
|
submit(tx: $encodedTransaction) {
|
@@ -853,20 +900,27 @@ var ProduceBlocksDocument = gql`
|
|
853
900
|
)
|
854
901
|
}
|
855
902
|
`;
|
903
|
+
var GetMessageByNonceDocument = gql`
|
904
|
+
query getMessageByNonce($nonce: Nonce!) {
|
905
|
+
message(nonce: $nonce) {
|
906
|
+
...messageFragment
|
907
|
+
}
|
908
|
+
}
|
909
|
+
${MessageFragmentDoc}`;
|
856
910
|
var SubmitAndAwaitDocument = gql`
|
857
911
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
858
912
|
submitAndAwait(tx: $encodedTransaction) {
|
859
913
|
...transactionStatusSubscriptionFragment
|
860
914
|
}
|
861
915
|
}
|
862
|
-
${
|
916
|
+
${TransactionStatusSubscriptionFragmentDoc}`;
|
863
917
|
var StatusChangeDocument = gql`
|
864
918
|
subscription statusChange($transactionId: TransactionId!) {
|
865
919
|
statusChange(id: $transactionId) {
|
866
920
|
...transactionStatusSubscriptionFragment
|
867
921
|
}
|
868
922
|
}
|
869
|
-
${
|
923
|
+
${TransactionStatusSubscriptionFragmentDoc}`;
|
870
924
|
function getSdk(requester) {
|
871
925
|
return {
|
872
926
|
getVersion(variables, options) {
|
@@ -938,6 +992,9 @@ function getSdk(requester) {
|
|
938
992
|
getMessageStatus(variables, options) {
|
939
993
|
return requester(GetMessageStatusDocument, variables, options);
|
940
994
|
},
|
995
|
+
getRelayedTransactionStatus(variables, options) {
|
996
|
+
return requester(GetRelayedTransactionStatusDocument, variables, options);
|
997
|
+
},
|
941
998
|
dryRun(variables, options) {
|
942
999
|
return requester(DryRunDocument, variables, options);
|
943
1000
|
},
|
@@ -947,6 +1004,9 @@ function getSdk(requester) {
|
|
947
1004
|
produceBlocks(variables, options) {
|
948
1005
|
return requester(ProduceBlocksDocument, variables, options);
|
949
1006
|
},
|
1007
|
+
getMessageByNonce(variables, options) {
|
1008
|
+
return requester(GetMessageByNonceDocument, variables, options);
|
1009
|
+
},
|
950
1010
|
submitAndAwait(variables, options) {
|
951
1011
|
return requester(SubmitAndAwaitDocument, variables, options);
|
952
1012
|
},
|
@@ -1239,7 +1299,7 @@ import {
|
|
1239
1299
|
OutputType as OutputType2,
|
1240
1300
|
TransactionType
|
1241
1301
|
} from "@fuel-ts/transactions";
|
1242
|
-
import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
|
1302
|
+
import { concat, hexlify as hexlify7, isDefined } from "@fuel-ts/utils";
|
1243
1303
|
|
1244
1304
|
// src/providers/resource.ts
|
1245
1305
|
var isCoin = (resource) => "id" in resource;
|
@@ -1472,10 +1532,9 @@ var getGasUsedFromReceipts = (receipts) => {
|
|
1472
1532
|
function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
1473
1533
|
const base = bn5(gasDependentCost.base);
|
1474
1534
|
let dependentValue = bn5(0);
|
1475
|
-
if (
|
1535
|
+
if ("unitsPerGas" in gasDependentCost) {
|
1476
1536
|
dependentValue = bn5(byteSize).div(bn5(gasDependentCost.unitsPerGas));
|
1477
|
-
}
|
1478
|
-
if (gasDependentCost.__typename === "HeavyOperation") {
|
1537
|
+
} else {
|
1479
1538
|
dependentValue = bn5(byteSize).mul(bn5(gasDependentCost.gasPerUnit));
|
1480
1539
|
}
|
1481
1540
|
return base.add(dependentValue);
|
@@ -1552,7 +1611,7 @@ function calculateMetadataGasForTxScript({
|
|
1552
1611
|
}
|
1553
1612
|
var calculateGasFee = (params) => {
|
1554
1613
|
const { gas, gasPrice, priceFactor, tip } = params;
|
1555
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1614
|
+
return gas.mul(gasPrice).div(priceFactor).add(bn5(tip));
|
1556
1615
|
};
|
1557
1616
|
|
1558
1617
|
// src/providers/utils/json.ts
|
@@ -1725,10 +1784,10 @@ var BaseTransactionRequest = class {
|
|
1725
1784
|
outputs,
|
1726
1785
|
witnesses
|
1727
1786
|
} = {}) {
|
1728
|
-
this.tip = bn7(tip);
|
1729
|
-
this.maturity = maturity
|
1730
|
-
this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
|
1731
|
-
this.maxFee =
|
1787
|
+
this.tip = tip ? bn7(tip) : void 0;
|
1788
|
+
this.maturity = maturity && maturity > 0 ? maturity : void 0;
|
1789
|
+
this.witnessLimit = isDefined(witnessLimit) ? bn7(witnessLimit) : void 0;
|
1790
|
+
this.maxFee = bn7(maxFee);
|
1732
1791
|
this.inputs = inputs ?? [];
|
1733
1792
|
this.outputs = outputs ?? [];
|
1734
1793
|
this.witnesses = witnesses ?? [];
|
@@ -1736,22 +1795,21 @@ var BaseTransactionRequest = class {
|
|
1736
1795
|
static getPolicyMeta(req) {
|
1737
1796
|
let policyTypes = 0;
|
1738
1797
|
const policies = [];
|
1739
|
-
|
1798
|
+
const { tip, witnessLimit, maturity } = req;
|
1799
|
+
if (bn7(tip).gt(0)) {
|
1740
1800
|
policyTypes += PolicyType.Tip;
|
1741
|
-
policies.push({ data:
|
1801
|
+
policies.push({ data: bn7(tip), type: PolicyType.Tip });
|
1742
1802
|
}
|
1743
|
-
if (
|
1803
|
+
if (isDefined(witnessLimit) && bn7(witnessLimit).gte(0)) {
|
1744
1804
|
policyTypes += PolicyType.WitnessLimit;
|
1745
|
-
policies.push({ data:
|
1805
|
+
policies.push({ data: bn7(witnessLimit), type: PolicyType.WitnessLimit });
|
1746
1806
|
}
|
1747
|
-
if (
|
1807
|
+
if (maturity && maturity > 0) {
|
1748
1808
|
policyTypes += PolicyType.Maturity;
|
1749
|
-
policies.push({ data:
|
1750
|
-
}
|
1751
|
-
if (req.maxFee) {
|
1752
|
-
policyTypes += PolicyType.MaxFee;
|
1753
|
-
policies.push({ data: req.maxFee, type: PolicyType.MaxFee });
|
1809
|
+
policies.push({ data: maturity, type: PolicyType.Maturity });
|
1754
1810
|
}
|
1811
|
+
policyTypes += PolicyType.MaxFee;
|
1812
|
+
policies.push({ data: req.maxFee, type: PolicyType.MaxFee });
|
1755
1813
|
return {
|
1756
1814
|
policyTypes,
|
1757
1815
|
policies
|
@@ -2067,8 +2125,11 @@ var BaseTransactionRequest = class {
|
|
2067
2125
|
* @hidden
|
2068
2126
|
*/
|
2069
2127
|
calculateMinGas(chainInfo) {
|
2070
|
-
const {
|
2071
|
-
const {
|
2128
|
+
const { consensusParameters } = chainInfo;
|
2129
|
+
const {
|
2130
|
+
gasCosts,
|
2131
|
+
feeParameters: { gasPerByte }
|
2132
|
+
} = consensusParameters;
|
2072
2133
|
return getMinGas({
|
2073
2134
|
gasPerByte,
|
2074
2135
|
gasCosts,
|
@@ -2079,7 +2140,10 @@ var BaseTransactionRequest = class {
|
|
2079
2140
|
}
|
2080
2141
|
calculateMaxGas(chainInfo, minGas) {
|
2081
2142
|
const { consensusParameters } = chainInfo;
|
2082
|
-
const {
|
2143
|
+
const {
|
2144
|
+
feeParameters: { gasPerByte },
|
2145
|
+
txParameters: { maxGasPerTx }
|
2146
|
+
} = consensusParameters;
|
2083
2147
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2084
2148
|
(acc, wit) => acc + wit.dataLength,
|
2085
2149
|
0
|
@@ -2514,7 +2578,10 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2514
2578
|
}
|
2515
2579
|
calculateMaxGas(chainInfo, minGas) {
|
2516
2580
|
const { consensusParameters } = chainInfo;
|
2517
|
-
const {
|
2581
|
+
const {
|
2582
|
+
feeParameters: { gasPerByte },
|
2583
|
+
txParameters: { maxGasPerTx }
|
2584
|
+
} = consensusParameters;
|
2518
2585
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2519
2586
|
(acc, wit) => acc + wit.dataLength,
|
2520
2587
|
0
|
@@ -2602,10 +2669,10 @@ var transactionRequestify = (obj) => {
|
|
2602
2669
|
};
|
2603
2670
|
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2604
2671
|
(acc, input) => {
|
2605
|
-
if (input.type === InputType5.Coin && input.owner === owner) {
|
2672
|
+
if (input.type === InputType5.Coin && input.owner === owner.toB256()) {
|
2606
2673
|
acc.utxos.push(input.id);
|
2607
2674
|
}
|
2608
|
-
if (input.type === InputType5.Message && input.recipient === owner) {
|
2675
|
+
if (input.type === InputType5.Message && input.recipient === owner.toB256()) {
|
2609
2676
|
acc.messages.push(input.nonce);
|
2610
2677
|
}
|
2611
2678
|
return acc;
|
@@ -2618,40 +2685,40 @@ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
|
2618
2685
|
|
2619
2686
|
// src/providers/transaction-response/transaction-response.ts
|
2620
2687
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2621
|
-
import { bn as
|
2688
|
+
import { bn as bn16 } from "@fuel-ts/math";
|
2622
2689
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2623
2690
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2624
2691
|
|
2625
2692
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2626
|
-
import { bn as
|
2693
|
+
import { bn as bn15 } from "@fuel-ts/math";
|
2627
2694
|
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2628
2695
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2629
2696
|
|
2630
|
-
// src/providers/transaction-summary/calculate-
|
2697
|
+
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
2631
2698
|
import { bn as bn11 } from "@fuel-ts/math";
|
2632
2699
|
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
|
2633
2700
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2634
|
-
var
|
2701
|
+
var calculateTXFeeForSummary = (params) => {
|
2635
2702
|
const {
|
2636
2703
|
gasPrice,
|
2637
2704
|
rawPayload,
|
2638
2705
|
tip,
|
2706
|
+
totalFee,
|
2639
2707
|
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2640
2708
|
} = params;
|
2709
|
+
if (totalFee) {
|
2710
|
+
return totalFee;
|
2711
|
+
}
|
2641
2712
|
const gasPerByte = bn11(feeParams.gasPerByte);
|
2642
2713
|
const gasPriceFactor = bn11(feeParams.gasPriceFactor);
|
2643
2714
|
const transactionBytes = arrayify9(rawPayload);
|
2644
2715
|
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
2645
|
-
if (transaction.type === TransactionType6.Mint) {
|
2646
|
-
return {
|
2647
|
-
fee: bn11(0),
|
2648
|
-
minFee: bn11(0),
|
2649
|
-
maxFee: bn11(0)
|
2650
|
-
};
|
2651
|
-
}
|
2652
2716
|
const { type, witnesses, inputs, policies } = transaction;
|
2653
2717
|
let metadataGas = bn11(0);
|
2654
2718
|
let gasLimit = bn11(0);
|
2719
|
+
if (type !== TransactionType6.Create && type !== TransactionType6.Script) {
|
2720
|
+
return bn11(0);
|
2721
|
+
}
|
2655
2722
|
if (type === TransactionType6.Create) {
|
2656
2723
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2657
2724
|
const contractBytesSize = bn11(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
|
@@ -2688,23 +2755,13 @@ var calculateTransactionFee = (params) => {
|
|
2688
2755
|
witnessLimit,
|
2689
2756
|
maxGasPerTx
|
2690
2757
|
});
|
2691
|
-
const minFee = calculateGasFee({
|
2692
|
-
gasPrice,
|
2693
|
-
gas: minGas,
|
2694
|
-
priceFactor: gasPriceFactor,
|
2695
|
-
tip
|
2696
|
-
});
|
2697
2758
|
const maxFee = calculateGasFee({
|
2698
2759
|
gasPrice,
|
2699
2760
|
gas: maxGas,
|
2700
2761
|
priceFactor: gasPriceFactor,
|
2701
2762
|
tip
|
2702
2763
|
});
|
2703
|
-
return
|
2704
|
-
minFee,
|
2705
|
-
maxFee,
|
2706
|
-
fee: maxFee
|
2707
|
-
};
|
2764
|
+
return maxFee;
|
2708
2765
|
};
|
2709
2766
|
|
2710
2767
|
// src/providers/transaction-summary/operations.ts
|
@@ -2863,6 +2920,12 @@ function isTypeCreate(transactionType) {
|
|
2863
2920
|
function isTypeScript(transactionType) {
|
2864
2921
|
return isType(transactionType, "Script" /* Script */);
|
2865
2922
|
}
|
2923
|
+
function isTypeUpgrade(transactionType) {
|
2924
|
+
return isType(transactionType, "Upgrade" /* Upgrade */);
|
2925
|
+
}
|
2926
|
+
function isTypeUpload(transactionType) {
|
2927
|
+
return isType(transactionType, "Upload" /* Upload */);
|
2928
|
+
}
|
2866
2929
|
function getReceiptsCall(receipts) {
|
2867
2930
|
return getReceiptsByType(receipts, ReceiptType4.Call);
|
2868
2931
|
}
|
@@ -3203,6 +3266,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3203
3266
|
|
3204
3267
|
// src/providers/transaction-summary/status.ts
|
3205
3268
|
import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
|
3269
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
3206
3270
|
var getTransactionStatusName = (gqlStatus) => {
|
3207
3271
|
switch (gqlStatus) {
|
3208
3272
|
case "FailureStatus":
|
@@ -3224,6 +3288,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3224
3288
|
let time;
|
3225
3289
|
let blockId;
|
3226
3290
|
let status;
|
3291
|
+
let totalFee;
|
3292
|
+
let totalGas;
|
3227
3293
|
let isStatusFailure = false;
|
3228
3294
|
let isStatusSuccess = false;
|
3229
3295
|
let isStatusPending = false;
|
@@ -3234,11 +3300,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3234
3300
|
time = gqlTransactionStatus.time;
|
3235
3301
|
blockId = gqlTransactionStatus.block.id;
|
3236
3302
|
isStatusSuccess = true;
|
3303
|
+
totalFee = bn14(gqlTransactionStatus.totalFee);
|
3304
|
+
totalGas = bn14(gqlTransactionStatus.totalGas);
|
3237
3305
|
break;
|
3238
3306
|
case "FailureStatus":
|
3239
3307
|
time = gqlTransactionStatus.time;
|
3240
3308
|
blockId = gqlTransactionStatus.block.id;
|
3241
3309
|
isStatusFailure = true;
|
3310
|
+
totalFee = bn14(gqlTransactionStatus.totalFee);
|
3311
|
+
totalGas = bn14(gqlTransactionStatus.totalGas);
|
3242
3312
|
break;
|
3243
3313
|
case "SubmittedStatus":
|
3244
3314
|
time = gqlTransactionStatus.time;
|
@@ -3251,6 +3321,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3251
3321
|
time,
|
3252
3322
|
blockId,
|
3253
3323
|
status,
|
3324
|
+
totalFee,
|
3325
|
+
totalGas,
|
3254
3326
|
isStatusFailure,
|
3255
3327
|
isStatusSuccess,
|
3256
3328
|
isStatusPending
|
@@ -3286,8 +3358,10 @@ function assembleTransactionSummary(params) {
|
|
3286
3358
|
maxInputs
|
3287
3359
|
});
|
3288
3360
|
const typeName = getTransactionTypeName(transaction.type);
|
3289
|
-
const tip =
|
3290
|
-
const {
|
3361
|
+
const tip = bn15(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3362
|
+
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3363
|
+
const fee = calculateTXFeeForSummary({
|
3364
|
+
totalFee,
|
3291
3365
|
gasPrice,
|
3292
3366
|
rawPayload,
|
3293
3367
|
tip,
|
@@ -3300,7 +3374,6 @@ function assembleTransactionSummary(params) {
|
|
3300
3374
|
}
|
3301
3375
|
}
|
3302
3376
|
});
|
3303
|
-
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time } = processGraphqlStatus(gqlTransactionStatus);
|
3304
3377
|
const mintedAssets = extractMintedAssetsFromReceipts(receipts);
|
3305
3378
|
const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
|
3306
3379
|
let date;
|
@@ -3309,6 +3382,7 @@ function assembleTransactionSummary(params) {
|
|
3309
3382
|
}
|
3310
3383
|
const transactionSummary = {
|
3311
3384
|
id,
|
3385
|
+
tip,
|
3312
3386
|
fee,
|
3313
3387
|
gasUsed,
|
3314
3388
|
operations,
|
@@ -3322,6 +3396,8 @@ function assembleTransactionSummary(params) {
|
|
3322
3396
|
isTypeMint: isTypeMint(transaction.type),
|
3323
3397
|
isTypeCreate: isTypeCreate(transaction.type),
|
3324
3398
|
isTypeScript: isTypeScript(transaction.type),
|
3399
|
+
isTypeUpgrade: isTypeUpgrade(transaction.type),
|
3400
|
+
isTypeUpload: isTypeUpload(transaction.type),
|
3325
3401
|
isStatusFailure,
|
3326
3402
|
isStatusSuccess,
|
3327
3403
|
isStatusPending,
|
@@ -3353,7 +3429,7 @@ var TransactionResponse = class {
|
|
3353
3429
|
/** Current provider */
|
3354
3430
|
provider;
|
3355
3431
|
/** Gas used on the transaction */
|
3356
|
-
gasUsed =
|
3432
|
+
gasUsed = bn16(0);
|
3357
3433
|
/** The graphql Transaction with receipts object. */
|
3358
3434
|
gqlTransaction;
|
3359
3435
|
abis;
|
@@ -3438,7 +3514,7 @@ var TransactionResponse = class {
|
|
3438
3514
|
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3439
3515
|
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3440
3516
|
const gasPrice = await this.provider.getLatestGasPrice();
|
3441
|
-
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3517
|
+
const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
|
3442
3518
|
const transactionSummary = assembleTransactionSummary({
|
3443
3519
|
id: this.id,
|
3444
3520
|
receipts,
|
@@ -3574,33 +3650,60 @@ var mergeQuantities = (...coinQuantities) => {
|
|
3574
3650
|
var MAX_RETRIES = 10;
|
3575
3651
|
var processGqlChain = (chain) => {
|
3576
3652
|
const { name, daHeight, consensusParameters, latestBlock } = chain;
|
3577
|
-
const {
|
3653
|
+
const {
|
3654
|
+
contractParams,
|
3655
|
+
feeParams,
|
3656
|
+
predicateParams,
|
3657
|
+
scriptParams,
|
3658
|
+
txParams,
|
3659
|
+
gasCosts,
|
3660
|
+
baseAssetId,
|
3661
|
+
chainId,
|
3662
|
+
version
|
3663
|
+
} = consensusParameters;
|
3578
3664
|
return {
|
3579
3665
|
name,
|
3580
|
-
baseChainHeight:
|
3666
|
+
baseChainHeight: bn17(daHeight),
|
3581
3667
|
consensusParameters: {
|
3582
|
-
|
3583
|
-
|
3584
|
-
|
3585
|
-
|
3586
|
-
|
3587
|
-
|
3588
|
-
|
3589
|
-
|
3590
|
-
|
3591
|
-
|
3592
|
-
|
3593
|
-
|
3594
|
-
|
3595
|
-
|
3596
|
-
|
3597
|
-
|
3668
|
+
version,
|
3669
|
+
chainId: bn17(chainId),
|
3670
|
+
baseAssetId,
|
3671
|
+
feeParameters: {
|
3672
|
+
version: feeParams.version,
|
3673
|
+
gasPerByte: bn17(feeParams.gasPerByte),
|
3674
|
+
gasPriceFactor: bn17(feeParams.gasPriceFactor)
|
3675
|
+
},
|
3676
|
+
contractParameters: {
|
3677
|
+
version: contractParams.version,
|
3678
|
+
contractMaxSize: bn17(contractParams.contractMaxSize),
|
3679
|
+
maxStorageSlots: bn17(contractParams.maxStorageSlots)
|
3680
|
+
},
|
3681
|
+
txParameters: {
|
3682
|
+
version: txParams.version,
|
3683
|
+
maxInputs: bn17(txParams.maxInputs),
|
3684
|
+
maxOutputs: bn17(txParams.maxOutputs),
|
3685
|
+
maxWitnesses: bn17(txParams.maxWitnesses),
|
3686
|
+
maxGasPerTx: bn17(txParams.maxGasPerTx),
|
3687
|
+
maxSize: bn17(txParams.maxSize),
|
3688
|
+
maxBytecodeSubsections: bn17(txParams.maxBytecodeSubsections)
|
3689
|
+
},
|
3690
|
+
predicateParameters: {
|
3691
|
+
version: predicateParams.version,
|
3692
|
+
maxPredicateLength: bn17(predicateParams.maxPredicateLength),
|
3693
|
+
maxPredicateDataLength: bn17(predicateParams.maxPredicateDataLength),
|
3694
|
+
maxGasPerPredicate: bn17(predicateParams.maxGasPerPredicate),
|
3695
|
+
maxMessageDataLength: bn17(predicateParams.maxMessageDataLength)
|
3696
|
+
},
|
3697
|
+
scriptParameters: {
|
3698
|
+
version: scriptParams.version,
|
3699
|
+
maxScriptLength: bn17(scriptParams.maxScriptLength),
|
3700
|
+
maxScriptDataLength: bn17(scriptParams.maxScriptDataLength)
|
3701
|
+
},
|
3598
3702
|
gasCosts
|
3599
3703
|
},
|
3600
|
-
gasCosts,
|
3601
3704
|
latestBlock: {
|
3602
3705
|
id: latestBlock.id,
|
3603
|
-
height:
|
3706
|
+
height: bn17(latestBlock.height),
|
3604
3707
|
time: latestBlock.header.time,
|
3605
3708
|
transactions: latestBlock.transactions.map((i) => ({
|
3606
3709
|
id: i.id
|
@@ -3694,7 +3797,12 @@ var _Provider = class {
|
|
3694
3797
|
* Returns some helpful parameters related to gas fees.
|
3695
3798
|
*/
|
3696
3799
|
getGasConfig() {
|
3697
|
-
const {
|
3800
|
+
const {
|
3801
|
+
txParameters: { maxGasPerTx },
|
3802
|
+
predicateParameters: { maxGasPerPredicate },
|
3803
|
+
feeParameters: { gasPriceFactor, gasPerByte },
|
3804
|
+
gasCosts
|
3805
|
+
} = this.getChain().consensusParameters;
|
3698
3806
|
return {
|
3699
3807
|
maxGasPerTx,
|
3700
3808
|
maxGasPerPredicate,
|
@@ -3729,9 +3837,11 @@ var _Provider = class {
|
|
3729
3837
|
static ensureClientVersionIsSupported(nodeInfo) {
|
3730
3838
|
const { isMajorSupported, isMinorSupported, supportedVersion } = checkFuelCoreVersionCompatibility(nodeInfo.nodeVersion);
|
3731
3839
|
if (!isMajorSupported || !isMinorSupported) {
|
3732
|
-
|
3733
|
-
|
3734
|
-
|
3840
|
+
console.warn(
|
3841
|
+
`The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion},
|
3842
|
+
which is not supported by the version of the TS SDK that you are using.
|
3843
|
+
Things may not work as expected.
|
3844
|
+
Supported fuel-core version: ${supportedVersion}.`
|
3735
3845
|
);
|
3736
3846
|
}
|
3737
3847
|
}
|
@@ -3743,7 +3853,18 @@ var _Provider = class {
|
|
3743
3853
|
createOperations() {
|
3744
3854
|
const fetchFn = _Provider.getFetchFn(this.options);
|
3745
3855
|
const gqlClient = new GraphQLClient(this.url, {
|
3746
|
-
fetch: (url, requestInit) => fetchFn(url, requestInit, this.options)
|
3856
|
+
fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
3857
|
+
responseMiddleware: (response) => {
|
3858
|
+
if ("response" in response) {
|
3859
|
+
const graphQlResponse = response.response;
|
3860
|
+
if (Array.isArray(graphQlResponse?.errors)) {
|
3861
|
+
throw new FuelError13(
|
3862
|
+
FuelError13.CODES.INVALID_REQUEST,
|
3863
|
+
graphQlResponse.errors.map((err) => err.message).join("\n\n")
|
3864
|
+
);
|
3865
|
+
}
|
3866
|
+
}
|
3867
|
+
}
|
3747
3868
|
});
|
3748
3869
|
const executeQuery = (query, vars) => {
|
3749
3870
|
const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
|
@@ -3771,21 +3892,6 @@ var _Provider = class {
|
|
3771
3892
|
} = await this.operations.getVersion();
|
3772
3893
|
return nodeVersion;
|
3773
3894
|
}
|
3774
|
-
/**
|
3775
|
-
* @hidden
|
3776
|
-
*
|
3777
|
-
* Returns the network configuration of the connected Fuel node.
|
3778
|
-
*
|
3779
|
-
* @returns A promise that resolves to the network configuration object
|
3780
|
-
*/
|
3781
|
-
async getNetwork() {
|
3782
|
-
const {
|
3783
|
-
name,
|
3784
|
-
consensusParameters: { chainId }
|
3785
|
-
} = await this.getChain();
|
3786
|
-
const network = new Network(name, chainId.toNumber());
|
3787
|
-
return Promise.resolve(network);
|
3788
|
-
}
|
3789
3895
|
/**
|
3790
3896
|
* Returns the block number.
|
3791
3897
|
*
|
@@ -3793,7 +3899,7 @@ var _Provider = class {
|
|
3793
3899
|
*/
|
3794
3900
|
async getBlockNumber() {
|
3795
3901
|
const { chain } = await this.operations.getChain();
|
3796
|
-
return
|
3902
|
+
return bn17(chain.latestBlock.height, 10);
|
3797
3903
|
}
|
3798
3904
|
/**
|
3799
3905
|
* Returns the chain information.
|
@@ -3803,8 +3909,8 @@ var _Provider = class {
|
|
3803
3909
|
async fetchNode() {
|
3804
3910
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3805
3911
|
const processedNodeInfo = {
|
3806
|
-
maxDepth:
|
3807
|
-
maxTx:
|
3912
|
+
maxDepth: bn17(nodeInfo.maxDepth),
|
3913
|
+
maxTx: bn17(nodeInfo.maxTx),
|
3808
3914
|
nodeVersion: nodeInfo.nodeVersion,
|
3809
3915
|
utxoValidation: nodeInfo.utxoValidation,
|
3810
3916
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -3908,9 +4014,9 @@ var _Provider = class {
|
|
3908
4014
|
encodedTransactions: encodedTransaction,
|
3909
4015
|
utxoValidation: utxoValidation || false
|
3910
4016
|
});
|
3911
|
-
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
4017
|
+
const [{ receipts: rawReceipts, status: dryRunStatus }] = dryRunStatuses;
|
3912
4018
|
const receipts = rawReceipts.map(processGqlReceipt);
|
3913
|
-
return { receipts,
|
4019
|
+
return { receipts, dryRunStatus };
|
3914
4020
|
}
|
3915
4021
|
/**
|
3916
4022
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -3936,7 +4042,7 @@ var _Provider = class {
|
|
3936
4042
|
} = response;
|
3937
4043
|
if (inputs) {
|
3938
4044
|
inputs.forEach((input, index) => {
|
3939
|
-
if ("predicateGasUsed" in input &&
|
4045
|
+
if ("predicateGasUsed" in input && bn17(input.predicateGasUsed).gt(0)) {
|
3940
4046
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3941
4047
|
}
|
3942
4048
|
});
|
@@ -3964,7 +4070,7 @@ var _Provider = class {
|
|
3964
4070
|
let receipts = [];
|
3965
4071
|
const missingContractIds = [];
|
3966
4072
|
let outputVariables = 0;
|
3967
|
-
let
|
4073
|
+
let dryRunStatus;
|
3968
4074
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3969
4075
|
const {
|
3970
4076
|
dryRun: [{ receipts: rawReceipts, status }]
|
@@ -3973,7 +4079,7 @@ var _Provider = class {
|
|
3973
4079
|
utxoValidation: false
|
3974
4080
|
});
|
3975
4081
|
receipts = rawReceipts.map(processGqlReceipt);
|
3976
|
-
|
4082
|
+
dryRunStatus = status;
|
3977
4083
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
3978
4084
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
3979
4085
|
if (hasMissingOutputs) {
|
@@ -3995,7 +4101,7 @@ var _Provider = class {
|
|
3995
4101
|
receipts,
|
3996
4102
|
outputVariables,
|
3997
4103
|
missingContractIds,
|
3998
|
-
|
4104
|
+
dryRunStatus
|
3999
4105
|
};
|
4000
4106
|
}
|
4001
4107
|
/**
|
@@ -4013,7 +4119,7 @@ var _Provider = class {
|
|
4013
4119
|
receipts: [],
|
4014
4120
|
outputVariables: 0,
|
4015
4121
|
missingContractIds: [],
|
4016
|
-
|
4122
|
+
dryRunStatus: void 0
|
4017
4123
|
}));
|
4018
4124
|
const allRequests = clone3(transactionRequests);
|
4019
4125
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
@@ -4038,7 +4144,7 @@ var _Provider = class {
|
|
4038
4144
|
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4039
4145
|
const result = results[requestIdx];
|
4040
4146
|
result.receipts = rawReceipts.map(processGqlReceipt);
|
4041
|
-
result.
|
4147
|
+
result.dryRunStatus = status;
|
4042
4148
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4043
4149
|
result.receipts
|
4044
4150
|
);
|
@@ -4075,7 +4181,7 @@ var _Provider = class {
|
|
4075
4181
|
});
|
4076
4182
|
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4077
4183
|
const receipts = rawReceipts.map(processGqlReceipt);
|
4078
|
-
return { receipts,
|
4184
|
+
return { receipts, dryRunStatus: status };
|
4079
4185
|
});
|
4080
4186
|
return results;
|
4081
4187
|
}
|
@@ -4094,12 +4200,12 @@ var _Provider = class {
|
|
4094
4200
|
gasPrice = await this.estimateGasPrice(10);
|
4095
4201
|
}
|
4096
4202
|
const minFee = calculateGasFee({
|
4097
|
-
gasPrice:
|
4203
|
+
gasPrice: bn17(gasPrice),
|
4098
4204
|
gas: minGas,
|
4099
4205
|
priceFactor: gasPriceFactor,
|
4100
4206
|
tip: transactionRequest.tip
|
4101
4207
|
}).add(1);
|
4102
|
-
let gasLimit =
|
4208
|
+
let gasLimit = bn17(0);
|
4103
4209
|
if (transactionRequest.type === TransactionType8.Script) {
|
4104
4210
|
gasLimit = transactionRequest.gasLimit;
|
4105
4211
|
if (transactionRequest.gasLimit.eq(0)) {
|
@@ -4112,7 +4218,7 @@ var _Provider = class {
|
|
4112
4218
|
}
|
4113
4219
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4114
4220
|
const maxFee = calculateGasFee({
|
4115
|
-
gasPrice:
|
4221
|
+
gasPrice: bn17(gasPrice),
|
4116
4222
|
gas: maxGas,
|
4117
4223
|
priceFactor: gasPriceFactor,
|
4118
4224
|
tip: transactionRequest.tip
|
@@ -4172,12 +4278,12 @@ var _Provider = class {
|
|
4172
4278
|
const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
|
4173
4279
|
const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
|
4174
4280
|
const baseAssetId = this.getBaseAssetId();
|
4281
|
+
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
4175
4282
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4176
4283
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4177
4284
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4178
|
-
txRequestClone.maxFee = bn16(0);
|
4179
4285
|
if (isScriptTransaction) {
|
4180
|
-
txRequestClone.gasLimit =
|
4286
|
+
txRequestClone.gasLimit = bn17(0);
|
4181
4287
|
}
|
4182
4288
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4183
4289
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4190,24 +4296,22 @@ var _Provider = class {
|
|
4190
4296
|
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
4191
4297
|
}
|
4192
4298
|
await this.estimatePredicates(signedRequest);
|
4299
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4193
4300
|
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
4194
4301
|
transactionRequest: signedRequest
|
4195
4302
|
});
|
4196
4303
|
let receipts = [];
|
4304
|
+
let dryRunStatus;
|
4197
4305
|
let missingContractIds = [];
|
4198
4306
|
let outputVariables = 0;
|
4199
|
-
let gasUsed =
|
4200
|
-
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4307
|
+
let gasUsed = bn17(0);
|
4201
4308
|
txRequestClone.maxFee = maxFee;
|
4202
4309
|
if (isScriptTransaction) {
|
4203
4310
|
txRequestClone.gasLimit = gasLimit;
|
4204
4311
|
if (signatureCallback) {
|
4205
4312
|
await signatureCallback(txRequestClone);
|
4206
4313
|
}
|
4207
|
-
|
4208
|
-
receipts = result.receipts;
|
4209
|
-
outputVariables = result.outputVariables;
|
4210
|
-
missingContractIds = result.missingContractIds;
|
4314
|
+
({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
|
4211
4315
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4212
4316
|
txRequestClone.gasLimit = gasUsed;
|
4213
4317
|
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
@@ -4227,7 +4331,9 @@ var _Provider = class {
|
|
4227
4331
|
outputVariables,
|
4228
4332
|
missingContractIds,
|
4229
4333
|
addedSignatures,
|
4230
|
-
estimatedPredicates: txRequestClone.inputs
|
4334
|
+
estimatedPredicates: txRequestClone.inputs,
|
4335
|
+
dryRunStatus,
|
4336
|
+
updateMaxFee
|
4231
4337
|
};
|
4232
4338
|
}
|
4233
4339
|
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
@@ -4263,10 +4369,10 @@ var _Provider = class {
|
|
4263
4369
|
return coins.map((coin) => ({
|
4264
4370
|
id: coin.utxoId,
|
4265
4371
|
assetId: coin.assetId,
|
4266
|
-
amount:
|
4372
|
+
amount: bn17(coin.amount),
|
4267
4373
|
owner: Address2.fromAddressOrString(coin.owner),
|
4268
|
-
blockCreated:
|
4269
|
-
txCreatedIdx:
|
4374
|
+
blockCreated: bn17(coin.blockCreated),
|
4375
|
+
txCreatedIdx: bn17(coin.txCreatedIdx)
|
4270
4376
|
}));
|
4271
4377
|
}
|
4272
4378
|
/**
|
@@ -4300,12 +4406,12 @@ var _Provider = class {
|
|
4300
4406
|
};
|
4301
4407
|
const result = await this.operations.getCoinsToSpend(coinsQuery);
|
4302
4408
|
const coins = result.coinsToSpend.flat().map((coin) => {
|
4303
|
-
switch (coin.
|
4409
|
+
switch (coin.type) {
|
4304
4410
|
case "MessageCoin":
|
4305
4411
|
return {
|
4306
|
-
amount:
|
4412
|
+
amount: bn17(coin.amount),
|
4307
4413
|
assetId: coin.assetId,
|
4308
|
-
daHeight:
|
4414
|
+
daHeight: bn17(coin.daHeight),
|
4309
4415
|
sender: Address2.fromAddressOrString(coin.sender),
|
4310
4416
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4311
4417
|
nonce: coin.nonce
|
@@ -4313,11 +4419,11 @@ var _Provider = class {
|
|
4313
4419
|
case "Coin":
|
4314
4420
|
return {
|
4315
4421
|
id: coin.utxoId,
|
4316
|
-
amount:
|
4422
|
+
amount: bn17(coin.amount),
|
4317
4423
|
assetId: coin.assetId,
|
4318
4424
|
owner: Address2.fromAddressOrString(coin.owner),
|
4319
|
-
blockCreated:
|
4320
|
-
txCreatedIdx:
|
4425
|
+
blockCreated: bn17(coin.blockCreated),
|
4426
|
+
txCreatedIdx: bn17(coin.txCreatedIdx)
|
4321
4427
|
};
|
4322
4428
|
default:
|
4323
4429
|
return null;
|
@@ -4334,13 +4440,13 @@ var _Provider = class {
|
|
4334
4440
|
async getBlock(idOrHeight) {
|
4335
4441
|
let variables;
|
4336
4442
|
if (typeof idOrHeight === "number") {
|
4337
|
-
variables = { height:
|
4443
|
+
variables = { height: bn17(idOrHeight).toString(10) };
|
4338
4444
|
} else if (idOrHeight === "latest") {
|
4339
4445
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4340
4446
|
} else if (idOrHeight.length === 66) {
|
4341
4447
|
variables = { blockId: idOrHeight };
|
4342
4448
|
} else {
|
4343
|
-
variables = { blockId:
|
4449
|
+
variables = { blockId: bn17(idOrHeight).toString(10) };
|
4344
4450
|
}
|
4345
4451
|
const { block } = await this.operations.getBlock(variables);
|
4346
4452
|
if (!block) {
|
@@ -4348,7 +4454,7 @@ var _Provider = class {
|
|
4348
4454
|
}
|
4349
4455
|
return {
|
4350
4456
|
id: block.id,
|
4351
|
-
height:
|
4457
|
+
height: bn17(block.height),
|
4352
4458
|
time: block.header.time,
|
4353
4459
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4354
4460
|
};
|
@@ -4363,7 +4469,7 @@ var _Provider = class {
|
|
4363
4469
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4364
4470
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4365
4471
|
id: block.id,
|
4366
|
-
height:
|
4472
|
+
height: bn17(block.height),
|
4367
4473
|
time: block.header.time,
|
4368
4474
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4369
4475
|
}));
|
@@ -4378,7 +4484,7 @@ var _Provider = class {
|
|
4378
4484
|
async getBlockWithTransactions(idOrHeight) {
|
4379
4485
|
let variables;
|
4380
4486
|
if (typeof idOrHeight === "number") {
|
4381
|
-
variables = { blockHeight:
|
4487
|
+
variables = { blockHeight: bn17(idOrHeight).toString(10) };
|
4382
4488
|
} else if (idOrHeight === "latest") {
|
4383
4489
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4384
4490
|
} else {
|
@@ -4390,7 +4496,7 @@ var _Provider = class {
|
|
4390
4496
|
}
|
4391
4497
|
return {
|
4392
4498
|
id: block.id,
|
4393
|
-
height:
|
4499
|
+
height: bn17(block.height, 10),
|
4394
4500
|
time: block.header.time,
|
4395
4501
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4396
4502
|
transactions: block.transactions.map(
|
@@ -4439,7 +4545,7 @@ var _Provider = class {
|
|
4439
4545
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4440
4546
|
asset: hexlify12(assetId)
|
4441
4547
|
});
|
4442
|
-
return
|
4548
|
+
return bn17(contractBalance.amount, 10);
|
4443
4549
|
}
|
4444
4550
|
/**
|
4445
4551
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4453,7 +4559,7 @@ var _Provider = class {
|
|
4453
4559
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4454
4560
|
assetId: hexlify12(assetId)
|
4455
4561
|
});
|
4456
|
-
return
|
4562
|
+
return bn17(balance.amount, 10);
|
4457
4563
|
}
|
4458
4564
|
/**
|
4459
4565
|
* Returns balances for the given owner.
|
@@ -4471,7 +4577,7 @@ var _Provider = class {
|
|
4471
4577
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4472
4578
|
return balances.map((balance) => ({
|
4473
4579
|
assetId: balance.assetId,
|
4474
|
-
amount:
|
4580
|
+
amount: bn17(balance.amount)
|
4475
4581
|
}));
|
4476
4582
|
}
|
4477
4583
|
/**
|
@@ -4493,15 +4599,15 @@ var _Provider = class {
|
|
4493
4599
|
sender: message.sender,
|
4494
4600
|
recipient: message.recipient,
|
4495
4601
|
nonce: message.nonce,
|
4496
|
-
amount:
|
4602
|
+
amount: bn17(message.amount),
|
4497
4603
|
data: message.data
|
4498
4604
|
}),
|
4499
4605
|
sender: Address2.fromAddressOrString(message.sender),
|
4500
4606
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4501
4607
|
nonce: message.nonce,
|
4502
|
-
amount:
|
4608
|
+
amount: bn17(message.amount),
|
4503
4609
|
data: InputMessageCoder.decodeData(message.data),
|
4504
|
-
daHeight:
|
4610
|
+
daHeight: bn17(message.daHeight)
|
4505
4611
|
}));
|
4506
4612
|
}
|
4507
4613
|
/**
|
@@ -4554,59 +4660,59 @@ var _Provider = class {
|
|
4554
4660
|
} = result.messageProof;
|
4555
4661
|
return {
|
4556
4662
|
messageProof: {
|
4557
|
-
proofIndex:
|
4663
|
+
proofIndex: bn17(messageProof.proofIndex),
|
4558
4664
|
proofSet: messageProof.proofSet
|
4559
4665
|
},
|
4560
4666
|
blockProof: {
|
4561
|
-
proofIndex:
|
4667
|
+
proofIndex: bn17(blockProof.proofIndex),
|
4562
4668
|
proofSet: blockProof.proofSet
|
4563
4669
|
},
|
4564
4670
|
messageBlockHeader: {
|
4565
4671
|
id: messageBlockHeader.id,
|
4566
|
-
daHeight:
|
4567
|
-
transactionsCount:
|
4672
|
+
daHeight: bn17(messageBlockHeader.daHeight),
|
4673
|
+
transactionsCount: Number(messageBlockHeader.transactionsCount),
|
4568
4674
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4569
|
-
height:
|
4675
|
+
height: bn17(messageBlockHeader.height),
|
4570
4676
|
prevRoot: messageBlockHeader.prevRoot,
|
4571
4677
|
time: messageBlockHeader.time,
|
4572
4678
|
applicationHash: messageBlockHeader.applicationHash,
|
4573
|
-
messageReceiptCount:
|
4679
|
+
messageReceiptCount: Number(messageBlockHeader.messageReceiptCount),
|
4574
4680
|
messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
|
4575
|
-
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4681
|
+
consensusParametersVersion: Number(messageBlockHeader.consensusParametersVersion),
|
4576
4682
|
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4577
|
-
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4683
|
+
stateTransitionBytecodeVersion: Number(messageBlockHeader.stateTransitionBytecodeVersion)
|
4578
4684
|
},
|
4579
4685
|
commitBlockHeader: {
|
4580
4686
|
id: commitBlockHeader.id,
|
4581
|
-
daHeight:
|
4582
|
-
transactionsCount:
|
4687
|
+
daHeight: bn17(commitBlockHeader.daHeight),
|
4688
|
+
transactionsCount: Number(commitBlockHeader.transactionsCount),
|
4583
4689
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4584
|
-
height:
|
4690
|
+
height: bn17(commitBlockHeader.height),
|
4585
4691
|
prevRoot: commitBlockHeader.prevRoot,
|
4586
4692
|
time: commitBlockHeader.time,
|
4587
4693
|
applicationHash: commitBlockHeader.applicationHash,
|
4588
|
-
messageReceiptCount:
|
4694
|
+
messageReceiptCount: Number(commitBlockHeader.messageReceiptCount),
|
4589
4695
|
messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
|
4590
|
-
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4696
|
+
consensusParametersVersion: Number(commitBlockHeader.consensusParametersVersion),
|
4591
4697
|
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4592
|
-
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4698
|
+
stateTransitionBytecodeVersion: Number(commitBlockHeader.stateTransitionBytecodeVersion)
|
4593
4699
|
},
|
4594
4700
|
sender: Address2.fromAddressOrString(sender),
|
4595
4701
|
recipient: Address2.fromAddressOrString(recipient),
|
4596
4702
|
nonce,
|
4597
|
-
amount:
|
4703
|
+
amount: bn17(amount),
|
4598
4704
|
data
|
4599
4705
|
};
|
4600
4706
|
}
|
4601
4707
|
async getLatestGasPrice() {
|
4602
4708
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4603
|
-
return
|
4709
|
+
return bn17(latestGasPrice.gasPrice);
|
4604
4710
|
}
|
4605
4711
|
async estimateGasPrice(blockHorizon) {
|
4606
4712
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4607
4713
|
blockHorizon: String(blockHorizon)
|
4608
4714
|
});
|
4609
|
-
return
|
4715
|
+
return bn17(estimateGasPrice.gasPrice);
|
4610
4716
|
}
|
4611
4717
|
/**
|
4612
4718
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4627,15 +4733,37 @@ var _Provider = class {
|
|
4627
4733
|
*/
|
4628
4734
|
async produceBlocks(amount, startTime) {
|
4629
4735
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4630
|
-
blocksToProduce:
|
4736
|
+
blocksToProduce: bn17(amount).toString(10),
|
4631
4737
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4632
4738
|
});
|
4633
|
-
return
|
4739
|
+
return bn17(latestBlockHeight);
|
4634
4740
|
}
|
4635
4741
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4636
4742
|
async getTransactionResponse(transactionId) {
|
4637
4743
|
return new TransactionResponse(transactionId, this);
|
4638
4744
|
}
|
4745
|
+
/**
|
4746
|
+
* Returns Message for given nonce.
|
4747
|
+
*
|
4748
|
+
* @param nonce - The nonce of the message to retrieve.
|
4749
|
+
* @returns A promise that resolves to the Message object.
|
4750
|
+
*/
|
4751
|
+
async getMessageByNonce(nonce) {
|
4752
|
+
const { message } = await this.operations.getMessageByNonce({ nonce });
|
4753
|
+
if (!message) {
|
4754
|
+
return null;
|
4755
|
+
}
|
4756
|
+
return message;
|
4757
|
+
}
|
4758
|
+
async getRelayedTransactionStatus(relayedTransactionId) {
|
4759
|
+
const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
|
4760
|
+
relayedTransactionId
|
4761
|
+
});
|
4762
|
+
if (!relayedTransactionStatus) {
|
4763
|
+
return null;
|
4764
|
+
}
|
4765
|
+
return relayedTransactionStatus;
|
4766
|
+
}
|
4639
4767
|
};
|
4640
4768
|
var Provider = _Provider;
|
4641
4769
|
_cacheInputs = new WeakSet();
|
@@ -4654,7 +4782,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4654
4782
|
|
4655
4783
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4656
4784
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4657
|
-
import { bn as
|
4785
|
+
import { bn as bn18 } from "@fuel-ts/math";
|
4658
4786
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4659
4787
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4660
4788
|
|
@@ -4670,8 +4798,33 @@ var CHAIN_IDS = {
|
|
4670
4798
|
}
|
4671
4799
|
};
|
4672
4800
|
|
4673
|
-
// src/providers/assets/
|
4674
|
-
var
|
4801
|
+
// src/providers/assets/utils/url.ts
|
4802
|
+
var DELIMITER_PATH = "/";
|
4803
|
+
var trimRegex = /^\/|\/$/g;
|
4804
|
+
var trimPath = (path2 = "") => path2.replace(trimRegex, "");
|
4805
|
+
function urlJoin(baseUrl, ...paths) {
|
4806
|
+
const hasBaseUrl = baseUrl !== null && baseUrl !== void 0;
|
4807
|
+
const rootPath = baseUrl?.[0] === "/" && baseUrl.length > 1;
|
4808
|
+
const allPaths = [baseUrl, ...paths].filter(Boolean).map(trimPath);
|
4809
|
+
if (rootPath && hasBaseUrl) {
|
4810
|
+
allPaths.unshift("");
|
4811
|
+
}
|
4812
|
+
return allPaths.join(DELIMITER_PATH);
|
4813
|
+
}
|
4814
|
+
|
4815
|
+
// src/providers/assets/utils/resolveIconPaths.ts
|
4816
|
+
function resolveIconPaths(assets2, basePath = "./") {
|
4817
|
+
return assets2.map((asset) => ({
|
4818
|
+
...asset,
|
4819
|
+
icon: urlJoin(basePath, asset.icon)
|
4820
|
+
}));
|
4821
|
+
}
|
4822
|
+
|
4823
|
+
// src/providers/assets/utils/fuelAssetsBaseUrl.ts
|
4824
|
+
var fuelAssetsBaseUrl = "https://cdn.fuel.network/assets/";
|
4825
|
+
|
4826
|
+
// src/providers/assets/assets.ts
|
4827
|
+
var rawAssets = [
|
4675
4828
|
{
|
4676
4829
|
name: "Ethereum",
|
4677
4830
|
symbol: "ETH",
|
@@ -4702,6 +4855,23 @@ var assets = [
|
|
4702
4855
|
]
|
4703
4856
|
}
|
4704
4857
|
];
|
4858
|
+
var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
4859
|
+
|
4860
|
+
// src/providers/transaction-request/helpers.ts
|
4861
|
+
import { bn as bn19 } from "@fuel-ts/math";
|
4862
|
+
import { InputType as InputType8 } from "@fuel-ts/transactions";
|
4863
|
+
var isRequestInputCoin = (input) => input.type === InputType8.Coin;
|
4864
|
+
var isRequestInputMessage = (input) => input.type === InputType8.Message;
|
4865
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
4866
|
+
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
4867
|
+
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
4868
|
+
return acc.add(input.amount);
|
4869
|
+
}
|
4870
|
+
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
4871
|
+
return acc.add(input.amount);
|
4872
|
+
}
|
4873
|
+
return acc;
|
4874
|
+
}, bn19(0));
|
4705
4875
|
|
4706
4876
|
// src/utils/formatTransferToContractScriptData.ts
|
4707
4877
|
import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
@@ -4740,6 +4910,7 @@ var assembleTransferToContractScript = async (params) => {
|
|
4740
4910
|
};
|
4741
4911
|
|
4742
4912
|
// src/account.ts
|
4913
|
+
var MAX_FUNDING_ATTEMPTS = 2;
|
4743
4914
|
var Account = class extends AbstractAccount {
|
4744
4915
|
/**
|
4745
4916
|
* The address associated with the account.
|
@@ -4894,19 +5065,20 @@ var Account = class extends AbstractAccount {
|
|
4894
5065
|
return balances;
|
4895
5066
|
}
|
4896
5067
|
/**
|
4897
|
-
*
|
5068
|
+
* Funds a transaction request by adding the necessary resources.
|
4898
5069
|
*
|
4899
|
-
* @
|
4900
|
-
* @param
|
4901
|
-
* @param
|
4902
|
-
* @returns
|
5070
|
+
* @typeParam T - The type of the TransactionRequest.
|
5071
|
+
* @param request - The transaction request to fund.
|
5072
|
+
* @param params - The estimated transaction parameters.
|
5073
|
+
* @returns The funded transaction request.
|
4903
5074
|
*/
|
4904
5075
|
async fund(request, params) {
|
4905
|
-
const { addedSignatures, estimatedPredicates,
|
5076
|
+
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
|
5077
|
+
const fee = request.maxFee;
|
4906
5078
|
const baseAssetId = this.provider.getBaseAssetId();
|
4907
|
-
const
|
5079
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn20(0);
|
4908
5080
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
4909
|
-
amount:
|
5081
|
+
amount: bn20(fee),
|
4910
5082
|
assetId: baseAssetId,
|
4911
5083
|
coinQuantities: requiredQuantities
|
4912
5084
|
});
|
@@ -4914,21 +5086,17 @@ var Account = class extends AbstractAccount {
|
|
4914
5086
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
4915
5087
|
quantitiesDict[assetId] = {
|
4916
5088
|
required: amount,
|
4917
|
-
owned:
|
5089
|
+
owned: bn20(0)
|
4918
5090
|
};
|
4919
5091
|
});
|
4920
|
-
|
4921
|
-
const
|
4922
|
-
if (!isResource) {
|
4923
|
-
return;
|
4924
|
-
}
|
4925
|
-
const isCoin2 = "owner" in input;
|
5092
|
+
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
5093
|
+
const isCoin2 = isRequestInputCoin(input);
|
4926
5094
|
const assetId = isCoin2 ? String(input.assetId) : baseAssetId;
|
4927
5095
|
if (quantitiesDict[assetId]) {
|
4928
5096
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(input.amount);
|
4929
5097
|
}
|
4930
5098
|
});
|
4931
|
-
|
5099
|
+
let missingQuantities = [];
|
4932
5100
|
Object.entries(quantitiesDict).forEach(([assetId, { owned, required }]) => {
|
4933
5101
|
if (owned.lt(required)) {
|
4934
5102
|
missingQuantities.push({
|
@@ -4937,23 +5105,60 @@ var Account = class extends AbstractAccount {
|
|
4937
5105
|
});
|
4938
5106
|
}
|
4939
5107
|
});
|
4940
|
-
|
4941
|
-
|
4942
|
-
|
4943
|
-
const resources = await this.getResourcesToSpend(
|
4944
|
-
|
4945
|
-
|
4946
|
-
|
4947
|
-
|
4948
|
-
|
5108
|
+
let needsToBeFunded = missingQuantities.length > 0;
|
5109
|
+
let fundingAttempts = 0;
|
5110
|
+
while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
|
5111
|
+
const resources = await this.getResourcesToSpend(
|
5112
|
+
missingQuantities,
|
5113
|
+
cacheTxInputsFromOwner(request.inputs, this.address)
|
5114
|
+
);
|
5115
|
+
request.addResources(resources);
|
5116
|
+
request.shiftPredicateData();
|
5117
|
+
request.updatePredicateGasUsed(estimatedPredicates);
|
5118
|
+
const requestToReestimate2 = clone4(request);
|
5119
|
+
if (addedSignatures) {
|
5120
|
+
Array.from({ length: addedSignatures }).forEach(
|
5121
|
+
() => requestToReestimate2.addEmptyWitness()
|
5122
|
+
);
|
5123
|
+
}
|
5124
|
+
if (!updateMaxFee) {
|
5125
|
+
break;
|
5126
|
+
}
|
5127
|
+
const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
|
5128
|
+
transactionRequest: requestToReestimate2
|
5129
|
+
});
|
5130
|
+
const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
|
5131
|
+
request.inputs,
|
5132
|
+
baseAssetId,
|
5133
|
+
baseAssetId
|
5134
|
+
);
|
5135
|
+
const totalBaseAssetRequiredWithFee = requiredInBaseAsset.add(newFee);
|
5136
|
+
if (totalBaseAssetOnInputs.gt(totalBaseAssetRequiredWithFee)) {
|
5137
|
+
needsToBeFunded = false;
|
5138
|
+
} else {
|
5139
|
+
missingQuantities = [
|
5140
|
+
{
|
5141
|
+
amount: totalBaseAssetRequiredWithFee.sub(totalBaseAssetOnInputs),
|
5142
|
+
assetId: baseAssetId
|
5143
|
+
}
|
5144
|
+
];
|
5145
|
+
}
|
5146
|
+
fundingAttempts += 1;
|
5147
|
+
}
|
5148
|
+
request.shiftPredicateData();
|
5149
|
+
request.updatePredicateGasUsed(estimatedPredicates);
|
5150
|
+
const requestToReestimate = clone4(request);
|
4949
5151
|
if (addedSignatures) {
|
4950
5152
|
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
4951
5153
|
}
|
5154
|
+
if (!updateMaxFee) {
|
5155
|
+
return request;
|
5156
|
+
}
|
4952
5157
|
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
4953
5158
|
transactionRequest: requestToReestimate
|
4954
5159
|
});
|
4955
|
-
|
4956
|
-
return
|
5160
|
+
request.maxFee = maxFee;
|
5161
|
+
return request;
|
4957
5162
|
}
|
4958
5163
|
/**
|
4959
5164
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -4965,20 +5170,19 @@ var Account = class extends AbstractAccount {
|
|
4965
5170
|
* @returns A promise that resolves to the prepared transaction request.
|
4966
5171
|
*/
|
4967
5172
|
async createTransfer(destination, amount, assetId, txParams = {}) {
|
4968
|
-
|
5173
|
+
let request = new ScriptTransactionRequest(txParams);
|
4969
5174
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
4970
5175
|
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
|
4971
5176
|
const txCost = await this.provider.getTransactionCost(request, {
|
4972
5177
|
estimateTxDependencies: true,
|
4973
5178
|
resourcesOwner: this
|
4974
5179
|
});
|
4975
|
-
this.validateGasLimitAndMaxFee({
|
5180
|
+
request = this.validateGasLimitAndMaxFee({
|
5181
|
+
transactionRequest: request,
|
4976
5182
|
gasUsed: txCost.gasUsed,
|
4977
5183
|
maxFee: txCost.maxFee,
|
4978
5184
|
txParams
|
4979
5185
|
});
|
4980
|
-
request.gasLimit = txCost.gasUsed;
|
4981
|
-
request.maxFee = txCost.maxFee;
|
4982
5186
|
await this.fund(request, txCost);
|
4983
5187
|
return request;
|
4984
5188
|
}
|
@@ -4992,7 +5196,7 @@ var Account = class extends AbstractAccount {
|
|
4992
5196
|
* @returns A promise that resolves to the transaction response.
|
4993
5197
|
*/
|
4994
5198
|
async transfer(destination, amount, assetId, txParams = {}) {
|
4995
|
-
if (
|
5199
|
+
if (bn20(amount).lte(0)) {
|
4996
5200
|
throw new FuelError15(
|
4997
5201
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
4998
5202
|
"Transfer amount must be a positive number."
|
@@ -5012,7 +5216,7 @@ var Account = class extends AbstractAccount {
|
|
5012
5216
|
* @returns A promise that resolves to the transaction response.
|
5013
5217
|
*/
|
5014
5218
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5015
|
-
if (
|
5219
|
+
if (bn20(amount).lte(0)) {
|
5016
5220
|
throw new FuelError15(
|
5017
5221
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5018
5222
|
"Transfer amount must be a positive number."
|
@@ -5022,10 +5226,10 @@ var Account = class extends AbstractAccount {
|
|
5022
5226
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5023
5227
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5024
5228
|
hexlifiedContractId: contractAddress.toB256(),
|
5025
|
-
amountToTransfer:
|
5229
|
+
amountToTransfer: bn20(amount),
|
5026
5230
|
assetId: assetIdToTransfer
|
5027
5231
|
});
|
5028
|
-
|
5232
|
+
let request = new ScriptTransactionRequest({
|
5029
5233
|
...txParams,
|
5030
5234
|
script,
|
5031
5235
|
scriptData
|
@@ -5033,15 +5237,14 @@ var Account = class extends AbstractAccount {
|
|
5033
5237
|
request.addContractInputAndOutput(contractAddress);
|
5034
5238
|
const txCost = await this.provider.getTransactionCost(request, {
|
5035
5239
|
resourcesOwner: this,
|
5036
|
-
quantitiesToContract: [{ amount:
|
5240
|
+
quantitiesToContract: [{ amount: bn20(amount), assetId: String(assetIdToTransfer) }]
|
5037
5241
|
});
|
5038
|
-
this.validateGasLimitAndMaxFee({
|
5242
|
+
request = this.validateGasLimitAndMaxFee({
|
5243
|
+
transactionRequest: request,
|
5039
5244
|
gasUsed: txCost.gasUsed,
|
5040
5245
|
maxFee: txCost.maxFee,
|
5041
5246
|
txParams
|
5042
5247
|
});
|
5043
|
-
request.gasLimit = txCost.gasUsed;
|
5044
|
-
request.maxFee = txCost.maxFee;
|
5045
5248
|
await this.fund(request, txCost);
|
5046
5249
|
return this.sendTransaction(request);
|
5047
5250
|
}
|
@@ -5059,7 +5262,7 @@ var Account = class extends AbstractAccount {
|
|
5059
5262
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5060
5263
|
);
|
5061
5264
|
const amountDataArray = arrayify14(
|
5062
|
-
"0x".concat(
|
5265
|
+
"0x".concat(bn20(amount).toHex().substring(2).padStart(16, "0"))
|
5063
5266
|
);
|
5064
5267
|
const script = new Uint8Array([
|
5065
5268
|
...arrayify14(withdrawScript.bytes),
|
@@ -5068,16 +5271,15 @@ var Account = class extends AbstractAccount {
|
|
5068
5271
|
]);
|
5069
5272
|
const params = { script, ...txParams };
|
5070
5273
|
const baseAssetId = this.provider.getBaseAssetId();
|
5071
|
-
|
5072
|
-
const quantitiesToContract = [{ amount:
|
5274
|
+
let request = new ScriptTransactionRequest(params);
|
5275
|
+
const quantitiesToContract = [{ amount: bn20(amount), assetId: baseAssetId }];
|
5073
5276
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5074
|
-
this.validateGasLimitAndMaxFee({
|
5277
|
+
request = this.validateGasLimitAndMaxFee({
|
5278
|
+
transactionRequest: request,
|
5075
5279
|
gasUsed: txCost.gasUsed,
|
5076
5280
|
maxFee: txCost.maxFee,
|
5077
5281
|
txParams
|
5078
5282
|
});
|
5079
|
-
request.maxFee = txCost.maxFee;
|
5080
|
-
request.gasLimit = txCost.gasUsed;
|
5081
5283
|
await this.fund(request, txCost);
|
5082
5284
|
return this.sendTransaction(request);
|
5083
5285
|
}
|
@@ -5137,22 +5339,29 @@ var Account = class extends AbstractAccount {
|
|
5137
5339
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5138
5340
|
}
|
5139
5341
|
validateGasLimitAndMaxFee({
|
5140
|
-
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
|
5141
5342
|
gasUsed,
|
5142
|
-
maxFee
|
5343
|
+
maxFee,
|
5344
|
+
transactionRequest,
|
5345
|
+
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
5143
5346
|
}) {
|
5144
|
-
|
5347
|
+
const request = transactionRequestify(transactionRequest);
|
5348
|
+
if (!isDefined2(setGasLimit)) {
|
5349
|
+
request.gasLimit = gasUsed;
|
5350
|
+
} else if (gasUsed.gt(setGasLimit)) {
|
5145
5351
|
throw new FuelError15(
|
5146
5352
|
ErrorCode15.GAS_LIMIT_TOO_LOW,
|
5147
5353
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5148
5354
|
);
|
5149
5355
|
}
|
5150
|
-
if (
|
5356
|
+
if (!isDefined2(setMaxFee)) {
|
5357
|
+
request.maxFee = maxFee;
|
5358
|
+
} else if (maxFee.gt(setMaxFee)) {
|
5151
5359
|
throw new FuelError15(
|
5152
5360
|
ErrorCode15.MAX_FEE_TOO_LOW,
|
5153
5361
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
5154
5362
|
);
|
5155
5363
|
}
|
5364
|
+
return request;
|
5156
5365
|
}
|
5157
5366
|
};
|
5158
5367
|
|
@@ -5479,7 +5688,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5479
5688
|
// src/hdwallet/hdwallet.ts
|
5480
5689
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5481
5690
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5482
|
-
import { bn as
|
5691
|
+
import { bn as bn21, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5483
5692
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5484
5693
|
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5485
5694
|
|
@@ -7945,7 +8154,7 @@ var HDWallet = class {
|
|
7945
8154
|
const IR = bytes.slice(32);
|
7946
8155
|
if (privateKey) {
|
7947
8156
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7948
|
-
const ki =
|
8157
|
+
const ki = bn21(IL).add(privateKey).mod(N).toBytes(32);
|
7949
8158
|
return new HDWallet({
|
7950
8159
|
privateKey: ki,
|
7951
8160
|
chainCode: IR,
|
@@ -8360,9 +8569,11 @@ var launchNode = async ({
|
|
8360
8569
|
const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
|
8361
8570
|
const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
|
8362
8571
|
const metadataWritePath = path.join(tempDirPath, "metadata.json");
|
8572
|
+
const stateTransitionWritePath = path.join(tempDirPath, "state_transition_bytecode.wasm");
|
8363
8573
|
writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
|
8364
8574
|
writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
|
8365
8575
|
writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
|
8576
|
+
writeFileSync(stateTransitionWritePath, JSON.stringify(""));
|
8366
8577
|
snapshotDirToUse = tempDirPath;
|
8367
8578
|
}
|
8368
8579
|
const child = spawn(
|