@fuel-ts/account 0.0.0-rc-2241-20240508114911 → 0.0.0-rc-2037-20240508123129
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/dist/index.global.js +197 -168
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +430 -387
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +337 -301
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +9 -2
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +552 -346
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +10 -4
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts +4 -0
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
- package/dist/providers/transaction-request/index.d.ts +1 -0
- package/dist/providers/transaction-request/index.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +2 -0
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +0 -4
- package/dist/providers/transaction-request/utils.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/types.d.ts +13 -5
- 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.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/seedTestWallet.d.ts +1 -1
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils.global.js +163 -175
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +373 -385
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +292 -304
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +15 -15
package/dist/index.mjs
CHANGED
@@ -73,7 +73,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
73
73
|
// src/providers/provider.ts
|
74
74
|
import { Address as Address2 } from "@fuel-ts/address";
|
75
75
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
76
|
-
import { BN, bn as
|
76
|
+
import { BN, bn as bn18 } from "@fuel-ts/math";
|
77
77
|
import {
|
78
78
|
InputType as InputType7,
|
79
79
|
TransactionType as TransactionType8,
|
@@ -88,7 +88,7 @@ import { clone as clone3 } from "ramda";
|
|
88
88
|
|
89
89
|
// src/providers/__generated__/operations.ts
|
90
90
|
import gql from "graphql-tag";
|
91
|
-
var
|
91
|
+
var TransactionStatusSubscriptionFragmentFragmentDoc = gql`
|
92
92
|
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
93
93
|
type: __typename
|
94
94
|
... on SqueezedOutStatus {
|
@@ -96,13 +96,7 @@ var TransactionStatusSubscriptionFragmentDoc = gql`
|
|
96
96
|
}
|
97
97
|
}
|
98
98
|
`;
|
99
|
-
var
|
100
|
-
fragment SubmittedStatusFragment on SubmittedStatus {
|
101
|
-
type: __typename
|
102
|
-
time
|
103
|
-
}
|
104
|
-
`;
|
105
|
-
var ReceiptFragmentDoc = gql`
|
99
|
+
var ReceiptFragmentFragmentDoc = gql`
|
106
100
|
fragment receiptFragment on Receipt {
|
107
101
|
id
|
108
102
|
pc
|
@@ -134,65 +128,45 @@ var ReceiptFragmentDoc = gql`
|
|
134
128
|
subId
|
135
129
|
}
|
136
130
|
`;
|
137
|
-
var
|
138
|
-
fragment SuccessStatusFragment on SuccessStatus {
|
139
|
-
type: __typename
|
140
|
-
block {
|
141
|
-
id
|
142
|
-
}
|
143
|
-
time
|
144
|
-
programState {
|
145
|
-
returnType
|
146
|
-
data
|
147
|
-
}
|
148
|
-
receipts {
|
149
|
-
...receiptFragment
|
150
|
-
}
|
151
|
-
totalGas
|
152
|
-
totalFee
|
153
|
-
}
|
154
|
-
${ReceiptFragmentDoc}`;
|
155
|
-
var FailureStatusFragmentDoc = gql`
|
156
|
-
fragment FailureStatusFragment on FailureStatus {
|
157
|
-
type: __typename
|
158
|
-
block {
|
159
|
-
id
|
160
|
-
}
|
161
|
-
totalGas
|
162
|
-
totalFee
|
163
|
-
time
|
164
|
-
reason
|
165
|
-
receipts {
|
166
|
-
...receiptFragment
|
167
|
-
}
|
168
|
-
}
|
169
|
-
${ReceiptFragmentDoc}`;
|
170
|
-
var SqueezedOutStatusFragmentDoc = gql`
|
171
|
-
fragment SqueezedOutStatusFragment on SqueezedOutStatus {
|
172
|
-
type: __typename
|
173
|
-
reason
|
174
|
-
}
|
175
|
-
`;
|
176
|
-
var TransactionStatusFragmentDoc = gql`
|
131
|
+
var TransactionStatusFragmentFragmentDoc = gql`
|
177
132
|
fragment transactionStatusFragment on TransactionStatus {
|
133
|
+
type: __typename
|
178
134
|
... on SubmittedStatus {
|
179
|
-
|
135
|
+
time
|
180
136
|
}
|
181
137
|
... on SuccessStatus {
|
182
|
-
|
138
|
+
block {
|
139
|
+
id
|
140
|
+
}
|
141
|
+
time
|
142
|
+
programState {
|
143
|
+
returnType
|
144
|
+
data
|
145
|
+
}
|
146
|
+
receipts {
|
147
|
+
...receiptFragment
|
148
|
+
}
|
149
|
+
totalGas
|
150
|
+
totalFee
|
183
151
|
}
|
184
152
|
... on FailureStatus {
|
185
|
-
|
153
|
+
block {
|
154
|
+
id
|
155
|
+
}
|
156
|
+
totalGas
|
157
|
+
totalFee
|
158
|
+
time
|
159
|
+
reason
|
160
|
+
receipts {
|
161
|
+
...receiptFragment
|
162
|
+
}
|
186
163
|
}
|
187
164
|
... on SqueezedOutStatus {
|
188
|
-
|
165
|
+
reason
|
189
166
|
}
|
190
167
|
}
|
191
|
-
${
|
192
|
-
|
193
|
-
${FailureStatusFragmentDoc}
|
194
|
-
${SqueezedOutStatusFragmentDoc}`;
|
195
|
-
var TransactionFragmentDoc = gql`
|
168
|
+
${ReceiptFragmentFragmentDoc}`;
|
169
|
+
var TransactionFragmentFragmentDoc = gql`
|
196
170
|
fragment transactionFragment on Transaction {
|
197
171
|
id
|
198
172
|
rawPayload
|
@@ -200,8 +174,8 @@ var TransactionFragmentDoc = gql`
|
|
200
174
|
...transactionStatusFragment
|
201
175
|
}
|
202
176
|
}
|
203
|
-
${
|
204
|
-
var
|
177
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
178
|
+
var InputEstimatePredicatesFragmentFragmentDoc = gql`
|
205
179
|
fragment inputEstimatePredicatesFragment on Input {
|
206
180
|
... on InputCoin {
|
207
181
|
predicateGasUsed
|
@@ -211,14 +185,14 @@ var InputEstimatePredicatesFragmentDoc = gql`
|
|
211
185
|
}
|
212
186
|
}
|
213
187
|
`;
|
214
|
-
var
|
188
|
+
var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
|
215
189
|
fragment transactionEstimatePredicatesFragment on Transaction {
|
216
190
|
inputs {
|
217
191
|
...inputEstimatePredicatesFragment
|
218
192
|
}
|
219
193
|
}
|
220
|
-
${
|
221
|
-
var
|
194
|
+
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
195
|
+
var DryRunFailureStatusFragmentFragmentDoc = gql`
|
222
196
|
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
223
197
|
totalGas
|
224
198
|
totalFee
|
@@ -229,7 +203,7 @@ var DryRunFailureStatusFragmentDoc = gql`
|
|
229
203
|
}
|
230
204
|
}
|
231
205
|
`;
|
232
|
-
var
|
206
|
+
var DryRunSuccessStatusFragmentFragmentDoc = gql`
|
233
207
|
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
234
208
|
totalGas
|
235
209
|
totalFee
|
@@ -239,7 +213,7 @@ var DryRunSuccessStatusFragmentDoc = gql`
|
|
239
213
|
}
|
240
214
|
}
|
241
215
|
`;
|
242
|
-
var
|
216
|
+
var DryRunTransactionStatusFragmentFragmentDoc = gql`
|
243
217
|
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
244
218
|
... on DryRunFailureStatus {
|
245
219
|
...dryRunFailureStatusFragment
|
@@ -248,9 +222,9 @@ var DryRunTransactionStatusFragmentDoc = gql`
|
|
248
222
|
...dryRunSuccessStatusFragment
|
249
223
|
}
|
250
224
|
}
|
251
|
-
${
|
252
|
-
${
|
253
|
-
var
|
225
|
+
${DryRunFailureStatusFragmentFragmentDoc}
|
226
|
+
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
227
|
+
var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
|
254
228
|
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
255
229
|
id
|
256
230
|
status {
|
@@ -260,11 +234,11 @@ var DryRunTransactionExecutionStatusFragmentDoc = gql`
|
|
260
234
|
...receiptFragment
|
261
235
|
}
|
262
236
|
}
|
263
|
-
${
|
264
|
-
${
|
265
|
-
var
|
237
|
+
${DryRunTransactionStatusFragmentFragmentDoc}
|
238
|
+
${ReceiptFragmentFragmentDoc}`;
|
239
|
+
var CoinFragmentFragmentDoc = gql`
|
266
240
|
fragment coinFragment on Coin {
|
267
|
-
|
241
|
+
__typename
|
268
242
|
utxoId
|
269
243
|
owner
|
270
244
|
amount
|
@@ -273,9 +247,9 @@ var CoinFragmentDoc = gql`
|
|
273
247
|
txCreatedIdx
|
274
248
|
}
|
275
249
|
`;
|
276
|
-
var
|
250
|
+
var MessageCoinFragmentFragmentDoc = gql`
|
277
251
|
fragment messageCoinFragment on MessageCoin {
|
278
|
-
|
252
|
+
__typename
|
279
253
|
sender
|
280
254
|
recipient
|
281
255
|
nonce
|
@@ -284,7 +258,7 @@ var MessageCoinFragmentDoc = gql`
|
|
284
258
|
daHeight
|
285
259
|
}
|
286
260
|
`;
|
287
|
-
var
|
261
|
+
var MessageFragmentFragmentDoc = gql`
|
288
262
|
fragment messageFragment on Message {
|
289
263
|
amount
|
290
264
|
sender
|
@@ -294,7 +268,7 @@ var MessageFragmentDoc = gql`
|
|
294
268
|
daHeight
|
295
269
|
}
|
296
270
|
`;
|
297
|
-
var
|
271
|
+
var MessageProofFragmentFragmentDoc = gql`
|
298
272
|
fragment messageProofFragment on MessageProof {
|
299
273
|
messageProof {
|
300
274
|
proofSet
|
@@ -341,14 +315,14 @@ var MessageProofFragmentDoc = gql`
|
|
341
315
|
data
|
342
316
|
}
|
343
317
|
`;
|
344
|
-
var
|
318
|
+
var BalanceFragmentFragmentDoc = gql`
|
345
319
|
fragment balanceFragment on Balance {
|
346
320
|
owner
|
347
321
|
amount
|
348
322
|
assetId
|
349
323
|
}
|
350
324
|
`;
|
351
|
-
var
|
325
|
+
var BlockFragmentFragmentDoc = gql`
|
352
326
|
fragment blockFragment on Block {
|
353
327
|
id
|
354
328
|
height
|
@@ -360,7 +334,7 @@ var BlockFragmentDoc = gql`
|
|
360
334
|
}
|
361
335
|
}
|
362
336
|
`;
|
363
|
-
var
|
337
|
+
var TxParametersFragmentFragmentDoc = gql`
|
364
338
|
fragment TxParametersFragment on TxParameters {
|
365
339
|
version
|
366
340
|
maxInputs
|
@@ -371,7 +345,7 @@ var TxParametersFragmentDoc = gql`
|
|
371
345
|
maxBytecodeSubsections
|
372
346
|
}
|
373
347
|
`;
|
374
|
-
var
|
348
|
+
var PredicateParametersFragmentFragmentDoc = gql`
|
375
349
|
fragment PredicateParametersFragment on PredicateParameters {
|
376
350
|
version
|
377
351
|
maxPredicateLength
|
@@ -380,42 +354,41 @@ var PredicateParametersFragmentDoc = gql`
|
|
380
354
|
maxMessageDataLength
|
381
355
|
}
|
382
356
|
`;
|
383
|
-
var
|
357
|
+
var ScriptParametersFragmentFragmentDoc = gql`
|
384
358
|
fragment ScriptParametersFragment on ScriptParameters {
|
385
359
|
version
|
386
360
|
maxScriptLength
|
387
361
|
maxScriptDataLength
|
388
362
|
}
|
389
363
|
`;
|
390
|
-
var
|
364
|
+
var ContractParametersFragmentFragmentDoc = gql`
|
391
365
|
fragment ContractParametersFragment on ContractParameters {
|
392
366
|
version
|
393
367
|
contractMaxSize
|
394
368
|
maxStorageSlots
|
395
369
|
}
|
396
370
|
`;
|
397
|
-
var
|
371
|
+
var FeeParametersFragmentFragmentDoc = gql`
|
398
372
|
fragment FeeParametersFragment on FeeParameters {
|
399
373
|
version
|
400
374
|
gasPriceFactor
|
401
375
|
gasPerByte
|
402
376
|
}
|
403
377
|
`;
|
404
|
-
var
|
378
|
+
var DependentCostFragmentFragmentDoc = gql`
|
405
379
|
fragment DependentCostFragment on DependentCost {
|
380
|
+
__typename
|
406
381
|
... on LightOperation {
|
407
|
-
type: __typename
|
408
382
|
base
|
409
383
|
unitsPerGas
|
410
384
|
}
|
411
385
|
... on HeavyOperation {
|
412
|
-
type: __typename
|
413
386
|
base
|
414
387
|
gasPerUnit
|
415
388
|
}
|
416
389
|
}
|
417
390
|
`;
|
418
|
-
var
|
391
|
+
var GasCostsFragmentFragmentDoc = gql`
|
419
392
|
fragment GasCostsFragment on GasCosts {
|
420
393
|
version
|
421
394
|
add
|
@@ -571,8 +544,8 @@ var GasCostsFragmentDoc = gql`
|
|
571
544
|
}
|
572
545
|
newStoragePerByte
|
573
546
|
}
|
574
|
-
${
|
575
|
-
var
|
547
|
+
${DependentCostFragmentFragmentDoc}`;
|
548
|
+
var ConsensusParametersFragmentFragmentDoc = gql`
|
576
549
|
fragment consensusParametersFragment on ConsensusParameters {
|
577
550
|
version
|
578
551
|
txParams {
|
@@ -596,13 +569,13 @@ var ConsensusParametersFragmentDoc = gql`
|
|
596
569
|
baseAssetId
|
597
570
|
chainId
|
598
571
|
}
|
599
|
-
${
|
600
|
-
${
|
601
|
-
${
|
602
|
-
${
|
603
|
-
${
|
604
|
-
${
|
605
|
-
var
|
572
|
+
${TxParametersFragmentFragmentDoc}
|
573
|
+
${PredicateParametersFragmentFragmentDoc}
|
574
|
+
${ScriptParametersFragmentFragmentDoc}
|
575
|
+
${ContractParametersFragmentFragmentDoc}
|
576
|
+
${FeeParametersFragmentFragmentDoc}
|
577
|
+
${GasCostsFragmentFragmentDoc}`;
|
578
|
+
var ChainInfoFragmentFragmentDoc = gql`
|
606
579
|
fragment chainInfoFragment on ChainInfo {
|
607
580
|
name
|
608
581
|
latestBlock {
|
@@ -613,16 +586,16 @@ var ChainInfoFragmentDoc = gql`
|
|
613
586
|
...consensusParametersFragment
|
614
587
|
}
|
615
588
|
}
|
616
|
-
${
|
617
|
-
${
|
618
|
-
var
|
589
|
+
${BlockFragmentFragmentDoc}
|
590
|
+
${ConsensusParametersFragmentFragmentDoc}`;
|
591
|
+
var ContractBalanceFragmentFragmentDoc = gql`
|
619
592
|
fragment contractBalanceFragment on ContractBalance {
|
620
593
|
contract
|
621
594
|
amount
|
622
595
|
assetId
|
623
596
|
}
|
624
597
|
`;
|
625
|
-
var
|
598
|
+
var PageInfoFragmentFragmentDoc = gql`
|
626
599
|
fragment pageInfoFragment on PageInfo {
|
627
600
|
hasPreviousPage
|
628
601
|
hasNextPage
|
@@ -630,7 +603,7 @@ var PageInfoFragmentDoc = gql`
|
|
630
603
|
endCursor
|
631
604
|
}
|
632
605
|
`;
|
633
|
-
var
|
606
|
+
var NodeInfoFragmentFragmentDoc = gql`
|
634
607
|
fragment nodeInfoFragment on NodeInfo {
|
635
608
|
utxoValidation
|
636
609
|
vmBacktrace
|
@@ -639,7 +612,7 @@ var NodeInfoFragmentDoc = gql`
|
|
639
612
|
nodeVersion
|
640
613
|
}
|
641
614
|
`;
|
642
|
-
var
|
615
|
+
var RelayedTransactionStatusFragmentFragmentDoc = gql`
|
643
616
|
fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
|
644
617
|
... on RelayedTransactionFailed {
|
645
618
|
blockHeight
|
@@ -660,28 +633,28 @@ var GetNodeInfoDocument = gql`
|
|
660
633
|
...nodeInfoFragment
|
661
634
|
}
|
662
635
|
}
|
663
|
-
${
|
636
|
+
${NodeInfoFragmentFragmentDoc}`;
|
664
637
|
var GetChainDocument = gql`
|
665
638
|
query getChain {
|
666
639
|
chain {
|
667
640
|
...chainInfoFragment
|
668
641
|
}
|
669
642
|
}
|
670
|
-
${
|
643
|
+
${ChainInfoFragmentFragmentDoc}`;
|
671
644
|
var GetTransactionDocument = gql`
|
672
645
|
query getTransaction($transactionId: TransactionId!) {
|
673
646
|
transaction(id: $transactionId) {
|
674
647
|
...transactionFragment
|
675
648
|
}
|
676
649
|
}
|
677
|
-
${
|
650
|
+
${TransactionFragmentFragmentDoc}`;
|
678
651
|
var GetTransactionWithReceiptsDocument = gql`
|
679
652
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
680
653
|
transaction(id: $transactionId) {
|
681
654
|
...transactionFragment
|
682
655
|
}
|
683
656
|
}
|
684
|
-
${
|
657
|
+
${TransactionFragmentFragmentDoc}`;
|
685
658
|
var GetTransactionsDocument = gql`
|
686
659
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
687
660
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -692,7 +665,7 @@ var GetTransactionsDocument = gql`
|
|
692
665
|
}
|
693
666
|
}
|
694
667
|
}
|
695
|
-
${
|
668
|
+
${TransactionFragmentFragmentDoc}`;
|
696
669
|
var GetTransactionsByOwnerDocument = gql`
|
697
670
|
query getTransactionsByOwner($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
698
671
|
transactionsByOwner(
|
@@ -712,22 +685,22 @@ var GetTransactionsByOwnerDocument = gql`
|
|
712
685
|
}
|
713
686
|
}
|
714
687
|
}
|
715
|
-
${
|
716
|
-
${
|
688
|
+
${PageInfoFragmentFragmentDoc}
|
689
|
+
${TransactionFragmentFragmentDoc}`;
|
717
690
|
var EstimatePredicatesDocument = gql`
|
718
691
|
query estimatePredicates($encodedTransaction: HexString!) {
|
719
692
|
estimatePredicates(tx: $encodedTransaction) {
|
720
693
|
...transactionEstimatePredicatesFragment
|
721
694
|
}
|
722
695
|
}
|
723
|
-
${
|
696
|
+
${TransactionEstimatePredicatesFragmentFragmentDoc}`;
|
724
697
|
var GetBlockDocument = gql`
|
725
698
|
query getBlock($blockId: BlockId, $height: U32) {
|
726
699
|
block(id: $blockId, height: $height) {
|
727
700
|
...blockFragment
|
728
701
|
}
|
729
702
|
}
|
730
|
-
${
|
703
|
+
${BlockFragmentFragmentDoc}`;
|
731
704
|
var GetBlockWithTransactionsDocument = gql`
|
732
705
|
query getBlockWithTransactions($blockId: BlockId, $blockHeight: U32) {
|
733
706
|
block(id: $blockId, height: $blockHeight) {
|
@@ -737,8 +710,8 @@ var GetBlockWithTransactionsDocument = gql`
|
|
737
710
|
}
|
738
711
|
}
|
739
712
|
}
|
740
|
-
${
|
741
|
-
${
|
713
|
+
${BlockFragmentFragmentDoc}
|
714
|
+
${TransactionFragmentFragmentDoc}`;
|
742
715
|
var GetBlocksDocument = gql`
|
743
716
|
query getBlocks($after: String, $before: String, $first: Int, $last: Int) {
|
744
717
|
blocks(after: $after, before: $before, first: $first, last: $last) {
|
@@ -749,14 +722,14 @@ var GetBlocksDocument = gql`
|
|
749
722
|
}
|
750
723
|
}
|
751
724
|
}
|
752
|
-
${
|
725
|
+
${BlockFragmentFragmentDoc}`;
|
753
726
|
var GetCoinDocument = gql`
|
754
727
|
query getCoin($coinId: UtxoId!) {
|
755
728
|
coin(utxoId: $coinId) {
|
756
729
|
...coinFragment
|
757
730
|
}
|
758
731
|
}
|
759
|
-
${
|
732
|
+
${CoinFragmentFragmentDoc}`;
|
760
733
|
var GetCoinsDocument = gql`
|
761
734
|
query getCoins($filter: CoinFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
762
735
|
coins(
|
@@ -773,7 +746,7 @@ var GetCoinsDocument = gql`
|
|
773
746
|
}
|
774
747
|
}
|
775
748
|
}
|
776
|
-
${
|
749
|
+
${CoinFragmentFragmentDoc}`;
|
777
750
|
var GetCoinsToSpendDocument = gql`
|
778
751
|
query getCoinsToSpend($owner: Address!, $queryPerAsset: [SpendQueryElementInput!]!, $excludedIds: ExcludeInput) {
|
779
752
|
coinsToSpend(
|
@@ -785,8 +758,8 @@ var GetCoinsToSpendDocument = gql`
|
|
785
758
|
...messageCoinFragment
|
786
759
|
}
|
787
760
|
}
|
788
|
-
${
|
789
|
-
${
|
761
|
+
${CoinFragmentFragmentDoc}
|
762
|
+
${MessageCoinFragmentFragmentDoc}`;
|
790
763
|
var GetContractDocument = gql`
|
791
764
|
query getContract($contractId: ContractId!) {
|
792
765
|
contract(id: $contractId) {
|
@@ -801,14 +774,14 @@ var GetContractBalanceDocument = gql`
|
|
801
774
|
...contractBalanceFragment
|
802
775
|
}
|
803
776
|
}
|
804
|
-
${
|
777
|
+
${ContractBalanceFragmentFragmentDoc}`;
|
805
778
|
var GetBalanceDocument = gql`
|
806
779
|
query getBalance($owner: Address!, $assetId: AssetId!) {
|
807
780
|
balance(owner: $owner, assetId: $assetId) {
|
808
781
|
...balanceFragment
|
809
782
|
}
|
810
783
|
}
|
811
|
-
${
|
784
|
+
${BalanceFragmentFragmentDoc}`;
|
812
785
|
var GetLatestGasPriceDocument = gql`
|
813
786
|
query getLatestGasPrice {
|
814
787
|
latestGasPrice {
|
@@ -839,7 +812,7 @@ var GetBalancesDocument = gql`
|
|
839
812
|
}
|
840
813
|
}
|
841
814
|
}
|
842
|
-
${
|
815
|
+
${BalanceFragmentFragmentDoc}`;
|
843
816
|
var GetMessagesDocument = gql`
|
844
817
|
query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
845
818
|
messages(
|
@@ -856,7 +829,7 @@ var GetMessagesDocument = gql`
|
|
856
829
|
}
|
857
830
|
}
|
858
831
|
}
|
859
|
-
${
|
832
|
+
${MessageFragmentFragmentDoc}`;
|
860
833
|
var GetMessageProofDocument = gql`
|
861
834
|
query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
|
862
835
|
messageProof(
|
@@ -868,7 +841,7 @@ var GetMessageProofDocument = gql`
|
|
868
841
|
...messageProofFragment
|
869
842
|
}
|
870
843
|
}
|
871
|
-
${
|
844
|
+
${MessageProofFragmentFragmentDoc}`;
|
872
845
|
var GetMessageStatusDocument = gql`
|
873
846
|
query getMessageStatus($nonce: Nonce!) {
|
874
847
|
messageStatus(nonce: $nonce) {
|
@@ -882,14 +855,14 @@ var GetRelayedTransactionStatusDocument = gql`
|
|
882
855
|
...relayedTransactionStatusFragment
|
883
856
|
}
|
884
857
|
}
|
885
|
-
${
|
858
|
+
${RelayedTransactionStatusFragmentFragmentDoc}`;
|
886
859
|
var DryRunDocument = gql`
|
887
860
|
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
888
861
|
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
889
862
|
...dryRunTransactionExecutionStatusFragment
|
890
863
|
}
|
891
864
|
}
|
892
|
-
${
|
865
|
+
${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
|
893
866
|
var SubmitDocument = gql`
|
894
867
|
mutation submit($encodedTransaction: HexString!) {
|
895
868
|
submit(tx: $encodedTransaction) {
|
@@ -911,21 +884,21 @@ var GetMessageByNonceDocument = gql`
|
|
911
884
|
...messageFragment
|
912
885
|
}
|
913
886
|
}
|
914
|
-
${
|
887
|
+
${MessageFragmentFragmentDoc}`;
|
915
888
|
var SubmitAndAwaitDocument = gql`
|
916
889
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
917
890
|
submitAndAwait(tx: $encodedTransaction) {
|
918
891
|
...transactionStatusSubscriptionFragment
|
919
892
|
}
|
920
893
|
}
|
921
|
-
${
|
894
|
+
${TransactionStatusSubscriptionFragmentFragmentDoc}`;
|
922
895
|
var StatusChangeDocument = gql`
|
923
896
|
subscription statusChange($transactionId: TransactionId!) {
|
924
897
|
statusChange(id: $transactionId) {
|
925
898
|
...transactionStatusSubscriptionFragment
|
926
899
|
}
|
927
900
|
}
|
928
|
-
${
|
901
|
+
${TransactionStatusSubscriptionFragmentFragmentDoc}`;
|
929
902
|
function getSdk(requester) {
|
930
903
|
return {
|
931
904
|
getVersion(variables, options) {
|
@@ -1296,11 +1269,11 @@ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
|
|
1296
1269
|
import { Address, addressify } from "@fuel-ts/address";
|
1297
1270
|
import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
|
1298
1271
|
import { randomBytes } from "@fuel-ts/crypto";
|
1299
|
-
import { bn as
|
1272
|
+
import { bn as bn8 } from "@fuel-ts/math";
|
1300
1273
|
import {
|
1301
1274
|
PolicyType,
|
1302
1275
|
TransactionCoder,
|
1303
|
-
InputType as
|
1276
|
+
InputType as InputType3,
|
1304
1277
|
OutputType as OutputType2,
|
1305
1278
|
TransactionType
|
1306
1279
|
} from "@fuel-ts/transactions";
|
@@ -1599,9 +1572,10 @@ var getGasUsedFromReceipts = (receipts) => {
|
|
1599
1572
|
function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
1600
1573
|
const base = bn5(gasDependentCost.base);
|
1601
1574
|
let dependentValue = bn5(0);
|
1602
|
-
if ("
|
1575
|
+
if (gasDependentCost.__typename === "LightOperation") {
|
1603
1576
|
dependentValue = bn5(byteSize).div(bn5(gasDependentCost.unitsPerGas));
|
1604
|
-
}
|
1577
|
+
}
|
1578
|
+
if (gasDependentCost.__typename === "HeavyOperation") {
|
1605
1579
|
dependentValue = bn5(byteSize).mul(bn5(gasDependentCost.gasPerUnit));
|
1606
1580
|
}
|
1607
1581
|
return base.add(dependentValue);
|
@@ -1823,6 +1797,52 @@ var NoWitnessByOwnerError = class extends Error {
|
|
1823
1797
|
name = "NoWitnessByOwnerError";
|
1824
1798
|
};
|
1825
1799
|
|
1800
|
+
// src/providers/transaction-request/helpers.ts
|
1801
|
+
import { bn as bn7 } from "@fuel-ts/math";
|
1802
|
+
import { InputType as InputType2 } from "@fuel-ts/transactions";
|
1803
|
+
var isRequestInputCoin = (input) => input.type === InputType2.Coin;
|
1804
|
+
var isRequestInputMessage = (input) => input.type === InputType2.Message;
|
1805
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
1806
|
+
var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
1807
|
+
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
1808
|
+
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
1809
|
+
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
1810
|
+
return acc.add(input.amount);
|
1811
|
+
}
|
1812
|
+
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
1813
|
+
return acc.add(input.amount);
|
1814
|
+
}
|
1815
|
+
return acc;
|
1816
|
+
}, bn7(0));
|
1817
|
+
var cacheRequestInputsResources = (inputs) => inputs.filter(isRequestInputResource).reduce(
|
1818
|
+
(cache2, input) => {
|
1819
|
+
if (isRequestInputCoin(input)) {
|
1820
|
+
cache2.utxos.push(input.id);
|
1821
|
+
} else {
|
1822
|
+
cache2.messages.push(input.nonce);
|
1823
|
+
}
|
1824
|
+
return cache2;
|
1825
|
+
},
|
1826
|
+
{
|
1827
|
+
utxos: [],
|
1828
|
+
messages: []
|
1829
|
+
}
|
1830
|
+
);
|
1831
|
+
var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
1832
|
+
(acc, input) => {
|
1833
|
+
if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
|
1834
|
+
acc.utxos.push(input.id);
|
1835
|
+
} else if (isRequestInputMessage(input) && input.recipient === owner.toB256()) {
|
1836
|
+
acc.messages.push(input.nonce);
|
1837
|
+
}
|
1838
|
+
return acc;
|
1839
|
+
},
|
1840
|
+
{
|
1841
|
+
utxos: [],
|
1842
|
+
messages: []
|
1843
|
+
}
|
1844
|
+
);
|
1845
|
+
|
1826
1846
|
// src/providers/transaction-request/witness.ts
|
1827
1847
|
import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
|
1828
1848
|
var witnessify = (value) => {
|
@@ -1863,10 +1883,10 @@ var BaseTransactionRequest = class {
|
|
1863
1883
|
outputs,
|
1864
1884
|
witnesses
|
1865
1885
|
} = {}) {
|
1866
|
-
this.tip = tip ?
|
1886
|
+
this.tip = tip ? bn8(tip) : void 0;
|
1867
1887
|
this.maturity = maturity && maturity > 0 ? maturity : void 0;
|
1868
|
-
this.witnessLimit = isDefined(witnessLimit) ?
|
1869
|
-
this.maxFee =
|
1888
|
+
this.witnessLimit = isDefined(witnessLimit) ? bn8(witnessLimit) : void 0;
|
1889
|
+
this.maxFee = bn8(maxFee);
|
1870
1890
|
this.inputs = inputs ?? [];
|
1871
1891
|
this.outputs = outputs ?? [];
|
1872
1892
|
this.witnesses = witnesses ?? [];
|
@@ -1875,13 +1895,13 @@ var BaseTransactionRequest = class {
|
|
1875
1895
|
let policyTypes = 0;
|
1876
1896
|
const policies = [];
|
1877
1897
|
const { tip, witnessLimit, maturity } = req;
|
1878
|
-
if (
|
1898
|
+
if (bn8(tip).gt(0)) {
|
1879
1899
|
policyTypes += PolicyType.Tip;
|
1880
|
-
policies.push({ data:
|
1900
|
+
policies.push({ data: bn8(tip), type: PolicyType.Tip });
|
1881
1901
|
}
|
1882
|
-
if (isDefined(witnessLimit) &&
|
1902
|
+
if (isDefined(witnessLimit) && bn8(witnessLimit).gte(0)) {
|
1883
1903
|
policyTypes += PolicyType.WitnessLimit;
|
1884
|
-
policies.push({ data:
|
1904
|
+
policies.push({ data: bn8(witnessLimit), type: PolicyType.WitnessLimit });
|
1885
1905
|
}
|
1886
1906
|
if (maturity && maturity > 0) {
|
1887
1907
|
policyTypes += PolicyType.Maturity;
|
@@ -2012,7 +2032,7 @@ var BaseTransactionRequest = class {
|
|
2012
2032
|
*/
|
2013
2033
|
getCoinInputs() {
|
2014
2034
|
return this.inputs.filter(
|
2015
|
-
(input) => input.type ===
|
2035
|
+
(input) => input.type === InputType3.Coin
|
2016
2036
|
);
|
2017
2037
|
}
|
2018
2038
|
/**
|
@@ -2044,9 +2064,9 @@ var BaseTransactionRequest = class {
|
|
2044
2064
|
const ownerAddress = addressify(owner);
|
2045
2065
|
const found = this.inputs.find((input) => {
|
2046
2066
|
switch (input.type) {
|
2047
|
-
case
|
2067
|
+
case InputType3.Coin:
|
2048
2068
|
return hexlify7(input.owner) === ownerAddress.toB256();
|
2049
|
-
case
|
2069
|
+
case InputType3.Message:
|
2050
2070
|
return hexlify7(input.recipient) === ownerAddress.toB256();
|
2051
2071
|
default:
|
2052
2072
|
return false;
|
@@ -2061,7 +2081,7 @@ var BaseTransactionRequest = class {
|
|
2061
2081
|
* @param coin - Coin resource.
|
2062
2082
|
*/
|
2063
2083
|
addCoinInput(coin) {
|
2064
|
-
const { assetId, owner, amount } = coin;
|
2084
|
+
const { assetId, owner, amount, id, predicate } = coin;
|
2065
2085
|
let witnessIndex;
|
2066
2086
|
if (coin.predicate) {
|
2067
2087
|
witnessIndex = 0;
|
@@ -2072,13 +2092,14 @@ var BaseTransactionRequest = class {
|
|
2072
2092
|
}
|
2073
2093
|
}
|
2074
2094
|
const input = {
|
2075
|
-
|
2076
|
-
type:
|
2095
|
+
id,
|
2096
|
+
type: InputType3.Coin,
|
2077
2097
|
owner: owner.toB256(),
|
2078
2098
|
amount,
|
2079
2099
|
assetId,
|
2080
2100
|
txPointer: "0x00000000000000000000000000000000",
|
2081
|
-
witnessIndex
|
2101
|
+
witnessIndex,
|
2102
|
+
predicate
|
2082
2103
|
};
|
2083
2104
|
this.pushInput(input);
|
2084
2105
|
this.addChangeOutput(owner, assetId);
|
@@ -2090,7 +2111,7 @@ var BaseTransactionRequest = class {
|
|
2090
2111
|
* @param message - Message resource.
|
2091
2112
|
*/
|
2092
2113
|
addMessageInput(message) {
|
2093
|
-
const { recipient, sender, amount, assetId } = message;
|
2114
|
+
const { recipient, sender, amount, predicate, nonce, assetId } = message;
|
2094
2115
|
let witnessIndex;
|
2095
2116
|
if (message.predicate) {
|
2096
2117
|
witnessIndex = 0;
|
@@ -2101,12 +2122,13 @@ var BaseTransactionRequest = class {
|
|
2101
2122
|
}
|
2102
2123
|
}
|
2103
2124
|
const input = {
|
2104
|
-
|
2105
|
-
type:
|
2125
|
+
nonce,
|
2126
|
+
type: InputType3.Message,
|
2106
2127
|
sender: sender.toB256(),
|
2107
2128
|
recipient: recipient.toB256(),
|
2108
2129
|
amount,
|
2109
|
-
witnessIndex
|
2130
|
+
witnessIndex,
|
2131
|
+
predicate
|
2110
2132
|
};
|
2111
2133
|
this.pushInput(input);
|
2112
2134
|
this.addChangeOutput(recipient, assetId);
|
@@ -2253,7 +2275,7 @@ var BaseTransactionRequest = class {
|
|
2253
2275
|
const assetInput = findAssetInput(assetId);
|
2254
2276
|
let usedQuantity = quantity;
|
2255
2277
|
if (assetId === baseAssetId) {
|
2256
|
-
usedQuantity =
|
2278
|
+
usedQuantity = bn8("1000000000000000000");
|
2257
2279
|
}
|
2258
2280
|
if (assetInput && "assetId" in assetInput) {
|
2259
2281
|
assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
|
@@ -2265,13 +2287,13 @@ var BaseTransactionRequest = class {
|
|
2265
2287
|
amount: usedQuantity,
|
2266
2288
|
assetId,
|
2267
2289
|
owner: resourcesOwner || Address.fromRandom(),
|
2268
|
-
blockCreated:
|
2269
|
-
txCreatedIdx:
|
2290
|
+
blockCreated: bn8(1),
|
2291
|
+
txCreatedIdx: bn8(1)
|
2270
2292
|
}
|
2271
2293
|
]);
|
2272
2294
|
}
|
2273
2295
|
};
|
2274
|
-
updateAssetInput(baseAssetId,
|
2296
|
+
updateAssetInput(baseAssetId, bn8(1e11));
|
2275
2297
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2276
2298
|
}
|
2277
2299
|
/**
|
@@ -2282,7 +2304,7 @@ var BaseTransactionRequest = class {
|
|
2282
2304
|
*/
|
2283
2305
|
getCoinOutputsQuantities() {
|
2284
2306
|
const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
|
2285
|
-
amount:
|
2307
|
+
amount: bn8(amount),
|
2286
2308
|
assetId: assetId.toString()
|
2287
2309
|
}));
|
2288
2310
|
return coinsQuantities;
|
@@ -2296,22 +2318,33 @@ var BaseTransactionRequest = class {
|
|
2296
2318
|
toJSON() {
|
2297
2319
|
return normalizeJSON(this);
|
2298
2320
|
}
|
2321
|
+
removeWitness(index) {
|
2322
|
+
this.witnesses.splice(index, 1);
|
2323
|
+
this.adjustWitnessIndexes(index);
|
2324
|
+
}
|
2325
|
+
adjustWitnessIndexes(removedIndex) {
|
2326
|
+
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
2327
|
+
if (input.witnessIndex > removedIndex) {
|
2328
|
+
input.witnessIndex -= 1;
|
2329
|
+
}
|
2330
|
+
});
|
2331
|
+
}
|
2299
2332
|
updatePredicateGasUsed(inputs) {
|
2300
2333
|
this.inputs.forEach((i) => {
|
2301
2334
|
let correspondingInput;
|
2302
2335
|
switch (i.type) {
|
2303
|
-
case
|
2304
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2336
|
+
case InputType3.Coin:
|
2337
|
+
correspondingInput = inputs.find((x) => x.type === InputType3.Coin && x.owner === i.owner);
|
2305
2338
|
break;
|
2306
|
-
case
|
2339
|
+
case InputType3.Message:
|
2307
2340
|
correspondingInput = inputs.find(
|
2308
|
-
(x) => x.type ===
|
2341
|
+
(x) => x.type === InputType3.Message && x.sender === i.sender
|
2309
2342
|
);
|
2310
2343
|
break;
|
2311
2344
|
default:
|
2312
2345
|
return;
|
2313
2346
|
}
|
2314
|
-
if (correspondingInput && "predicateGasUsed" in correspondingInput &&
|
2347
|
+
if (correspondingInput && "predicateGasUsed" in correspondingInput && bn8(correspondingInput.predicateGasUsed).gt(0)) {
|
2315
2348
|
i.predicate = correspondingInput.predicate;
|
2316
2349
|
i.predicateData = correspondingInput.predicateData;
|
2317
2350
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
@@ -2331,15 +2364,15 @@ var BaseTransactionRequest = class {
|
|
2331
2364
|
|
2332
2365
|
// src/providers/transaction-request/create-transaction-request.ts
|
2333
2366
|
import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
|
2334
|
-
import { bn as
|
2367
|
+
import { bn as bn10 } from "@fuel-ts/math";
|
2335
2368
|
import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
|
2336
2369
|
import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
2337
2370
|
|
2338
2371
|
// src/providers/transaction-request/hash-transaction.ts
|
2339
2372
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2340
2373
|
import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
|
2341
|
-
import { bn as
|
2342
|
-
import { TransactionType as TransactionType2, InputType as
|
2374
|
+
import { bn as bn9 } from "@fuel-ts/math";
|
2375
|
+
import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
|
2343
2376
|
import { concat as concat2 } from "@fuel-ts/utils";
|
2344
2377
|
import { clone as clone2 } from "ramda";
|
2345
2378
|
function hashTransaction(transactionRequest, chainId) {
|
@@ -2350,19 +2383,19 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2350
2383
|
transaction.inputs = transaction.inputs.map((input) => {
|
2351
2384
|
const inputClone = clone2(input);
|
2352
2385
|
switch (inputClone.type) {
|
2353
|
-
case
|
2386
|
+
case InputType4.Coin: {
|
2354
2387
|
inputClone.txPointer = {
|
2355
2388
|
blockHeight: 0,
|
2356
2389
|
txIndex: 0
|
2357
2390
|
};
|
2358
|
-
inputClone.predicateGasUsed =
|
2391
|
+
inputClone.predicateGasUsed = bn9(0);
|
2359
2392
|
return inputClone;
|
2360
2393
|
}
|
2361
|
-
case
|
2362
|
-
inputClone.predicateGasUsed =
|
2394
|
+
case InputType4.Message: {
|
2395
|
+
inputClone.predicateGasUsed = bn9(0);
|
2363
2396
|
return inputClone;
|
2364
2397
|
}
|
2365
|
-
case
|
2398
|
+
case InputType4.Contract: {
|
2366
2399
|
inputClone.txPointer = {
|
2367
2400
|
blockHeight: 0,
|
2368
2401
|
txIndex: 0
|
@@ -2386,12 +2419,12 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2386
2419
|
return outputClone;
|
2387
2420
|
}
|
2388
2421
|
case OutputType3.Change: {
|
2389
|
-
outputClone.amount =
|
2422
|
+
outputClone.amount = bn9(0);
|
2390
2423
|
return outputClone;
|
2391
2424
|
}
|
2392
2425
|
case OutputType3.Variable: {
|
2393
2426
|
outputClone.to = ZeroBytes325;
|
2394
|
-
outputClone.amount =
|
2427
|
+
outputClone.amount = bn9(0);
|
2395
2428
|
outputClone.assetId = ZeroBytes325;
|
2396
2429
|
return outputClone;
|
2397
2430
|
}
|
@@ -2469,7 +2502,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2469
2502
|
type: TransactionType3.Create,
|
2470
2503
|
...baseTransaction,
|
2471
2504
|
bytecodeWitnessIndex,
|
2472
|
-
storageSlotsCount:
|
2505
|
+
storageSlotsCount: bn10(storageSlots.length),
|
2473
2506
|
salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
|
2474
2507
|
storageSlots
|
2475
2508
|
};
|
@@ -2509,7 +2542,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2509
2542
|
}
|
2510
2543
|
metadataGas(gasCosts) {
|
2511
2544
|
return calculateMetadataGasForTxCreate({
|
2512
|
-
contractBytesSize:
|
2545
|
+
contractBytesSize: bn10(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2513
2546
|
gasCosts,
|
2514
2547
|
stateRootSize: this.storageSlots.length,
|
2515
2548
|
txBytesSize: this.byteSize()
|
@@ -2521,8 +2554,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2521
2554
|
import { Interface } from "@fuel-ts/abi-coder";
|
2522
2555
|
import { addressify as addressify2 } from "@fuel-ts/address";
|
2523
2556
|
import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
2524
|
-
import { bn as
|
2525
|
-
import { InputType as
|
2557
|
+
import { bn as bn11 } from "@fuel-ts/math";
|
2558
|
+
import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
2526
2559
|
import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
|
2527
2560
|
|
2528
2561
|
// src/providers/transaction-request/scripts.ts
|
@@ -2575,7 +2608,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2575
2608
|
*/
|
2576
2609
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2577
2610
|
super(rest);
|
2578
|
-
this.gasLimit =
|
2611
|
+
this.gasLimit = bn11(gasLimit);
|
2579
2612
|
this.script = arrayify8(script ?? returnZeroScript.bytes);
|
2580
2613
|
this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
|
2581
2614
|
this.abis = rest.abis;
|
@@ -2592,8 +2625,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2592
2625
|
type: TransactionType4.Script,
|
2593
2626
|
scriptGasLimit: this.gasLimit,
|
2594
2627
|
...super.getBaseTransaction(),
|
2595
|
-
scriptLength:
|
2596
|
-
scriptDataLength:
|
2628
|
+
scriptLength: bn11(script.length),
|
2629
|
+
scriptDataLength: bn11(scriptData.length),
|
2597
2630
|
receiptsRoot: ZeroBytes327,
|
2598
2631
|
script: hexlify10(script),
|
2599
2632
|
scriptData: hexlify10(scriptData)
|
@@ -2606,7 +2639,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2606
2639
|
*/
|
2607
2640
|
getContractInputs() {
|
2608
2641
|
return this.inputs.filter(
|
2609
|
-
(input) => input.type ===
|
2642
|
+
(input) => input.type === InputType5.Contract
|
2610
2643
|
);
|
2611
2644
|
}
|
2612
2645
|
/**
|
@@ -2686,7 +2719,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2686
2719
|
return this;
|
2687
2720
|
}
|
2688
2721
|
const inputIndex = super.pushInput({
|
2689
|
-
type:
|
2722
|
+
type: InputType5.Contract,
|
2690
2723
|
contractId: contractAddress.toB256(),
|
2691
2724
|
txPointer: "0x00000000000000000000000000000000"
|
2692
2725
|
});
|
@@ -2728,7 +2761,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2728
2761
|
|
2729
2762
|
// src/providers/transaction-request/utils.ts
|
2730
2763
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2731
|
-
import { TransactionType as TransactionType5
|
2764
|
+
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2732
2765
|
var transactionRequestify = (obj) => {
|
2733
2766
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2734
2767
|
return obj;
|
@@ -2746,35 +2779,20 @@ var transactionRequestify = (obj) => {
|
|
2746
2779
|
}
|
2747
2780
|
}
|
2748
2781
|
};
|
2749
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2750
|
-
(acc, input) => {
|
2751
|
-
if (input.type === InputType5.Coin && input.owner === owner.toB256()) {
|
2752
|
-
acc.utxos.push(input.id);
|
2753
|
-
}
|
2754
|
-
if (input.type === InputType5.Message && input.recipient === owner.toB256()) {
|
2755
|
-
acc.messages.push(input.nonce);
|
2756
|
-
}
|
2757
|
-
return acc;
|
2758
|
-
},
|
2759
|
-
{
|
2760
|
-
utxos: [],
|
2761
|
-
messages: []
|
2762
|
-
}
|
2763
|
-
);
|
2764
2782
|
|
2765
2783
|
// src/providers/transaction-response/transaction-response.ts
|
2766
2784
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2767
|
-
import { bn as
|
2785
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
2768
2786
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2769
2787
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2770
2788
|
|
2771
2789
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2772
|
-
import { bn as
|
2790
|
+
import { bn as bn16 } from "@fuel-ts/math";
|
2773
2791
|
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2774
2792
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2775
2793
|
|
2776
2794
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
2777
|
-
import { bn as
|
2795
|
+
import { bn as bn12 } from "@fuel-ts/math";
|
2778
2796
|
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
|
2779
2797
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2780
2798
|
var calculateTXFeeForSummary = (params) => {
|
@@ -2788,19 +2806,19 @@ var calculateTXFeeForSummary = (params) => {
|
|
2788
2806
|
if (totalFee) {
|
2789
2807
|
return totalFee;
|
2790
2808
|
}
|
2791
|
-
const gasPerByte =
|
2792
|
-
const gasPriceFactor =
|
2809
|
+
const gasPerByte = bn12(feeParams.gasPerByte);
|
2810
|
+
const gasPriceFactor = bn12(feeParams.gasPriceFactor);
|
2793
2811
|
const transactionBytes = arrayify9(rawPayload);
|
2794
2812
|
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
2795
2813
|
const { type, witnesses, inputs, policies } = transaction;
|
2796
|
-
let metadataGas =
|
2797
|
-
let gasLimit =
|
2814
|
+
let metadataGas = bn12(0);
|
2815
|
+
let gasLimit = bn12(0);
|
2798
2816
|
if (type !== TransactionType6.Create && type !== TransactionType6.Script) {
|
2799
|
-
return
|
2817
|
+
return bn12(0);
|
2800
2818
|
}
|
2801
2819
|
if (type === TransactionType6.Create) {
|
2802
2820
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2803
|
-
const contractBytesSize =
|
2821
|
+
const contractBytesSize = bn12(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
|
2804
2822
|
metadataGas = calculateMetadataGasForTxCreate({
|
2805
2823
|
contractBytesSize,
|
2806
2824
|
gasCosts,
|
@@ -2819,7 +2837,7 @@ var calculateTXFeeForSummary = (params) => {
|
|
2819
2837
|
}
|
2820
2838
|
const minGas = getMinGas({
|
2821
2839
|
gasCosts,
|
2822
|
-
gasPerByte:
|
2840
|
+
gasPerByte: bn12(gasPerByte),
|
2823
2841
|
inputs,
|
2824
2842
|
metadataGas,
|
2825
2843
|
txBytesSize: transactionBytes.length
|
@@ -2846,12 +2864,12 @@ var calculateTXFeeForSummary = (params) => {
|
|
2846
2864
|
// src/providers/transaction-summary/operations.ts
|
2847
2865
|
import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
|
2848
2866
|
import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
|
2849
|
-
import { bn as
|
2867
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
2850
2868
|
import { ReceiptType as ReceiptType4, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
2851
2869
|
|
2852
2870
|
// src/providers/transaction-summary/call.ts
|
2853
2871
|
import { Interface as Interface2, calculateVmTxMemory } from "@fuel-ts/abi-coder";
|
2854
|
-
import { bn as
|
2872
|
+
import { bn as bn13 } from "@fuel-ts/math";
|
2855
2873
|
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2856
2874
|
const abiInterface = new Interface2(abi);
|
2857
2875
|
const callFunctionSelector = receipt.param1.toHex(8);
|
@@ -2860,7 +2878,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2860
2878
|
let encodedArgs;
|
2861
2879
|
if (functionFragment.isInputDataPointer) {
|
2862
2880
|
if (rawPayload) {
|
2863
|
-
const argsOffset =
|
2881
|
+
const argsOffset = bn13(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2864
2882
|
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2865
2883
|
}
|
2866
2884
|
} else {
|
@@ -3068,7 +3086,7 @@ var mergeAssets = (op1, op2) => {
|
|
3068
3086
|
if (!matchingAsset) {
|
3069
3087
|
return asset1;
|
3070
3088
|
}
|
3071
|
-
const mergedAmount =
|
3089
|
+
const mergedAmount = bn14(asset1.amount).add(matchingAsset.amount);
|
3072
3090
|
return { ...asset1, amount: mergedAmount };
|
3073
3091
|
});
|
3074
3092
|
return mergedAssets.concat(filteredAssets);
|
@@ -3394,7 +3412,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3394
3412
|
|
3395
3413
|
// src/providers/transaction-summary/status.ts
|
3396
3414
|
import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
|
3397
|
-
import { bn as
|
3415
|
+
import { bn as bn15 } from "@fuel-ts/math";
|
3398
3416
|
var getTransactionStatusName = (gqlStatus) => {
|
3399
3417
|
switch (gqlStatus) {
|
3400
3418
|
case "FailureStatus":
|
@@ -3428,15 +3446,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3428
3446
|
time = gqlTransactionStatus.time;
|
3429
3447
|
blockId = gqlTransactionStatus.block.id;
|
3430
3448
|
isStatusSuccess = true;
|
3431
|
-
totalFee =
|
3432
|
-
totalGas =
|
3449
|
+
totalFee = bn15(gqlTransactionStatus.totalFee);
|
3450
|
+
totalGas = bn15(gqlTransactionStatus.totalGas);
|
3433
3451
|
break;
|
3434
3452
|
case "FailureStatus":
|
3435
3453
|
time = gqlTransactionStatus.time;
|
3436
3454
|
blockId = gqlTransactionStatus.block.id;
|
3437
3455
|
isStatusFailure = true;
|
3438
|
-
totalFee =
|
3439
|
-
totalGas =
|
3456
|
+
totalFee = bn15(gqlTransactionStatus.totalFee);
|
3457
|
+
totalGas = bn15(gqlTransactionStatus.totalGas);
|
3440
3458
|
break;
|
3441
3459
|
case "SubmittedStatus":
|
3442
3460
|
time = gqlTransactionStatus.time;
|
@@ -3486,7 +3504,7 @@ function assembleTransactionSummary(params) {
|
|
3486
3504
|
maxInputs
|
3487
3505
|
});
|
3488
3506
|
const typeName = getTransactionTypeName(transaction.type);
|
3489
|
-
const tip =
|
3507
|
+
const tip = bn16(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3490
3508
|
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3491
3509
|
const fee = calculateTXFeeForSummary({
|
3492
3510
|
totalFee,
|
@@ -3557,7 +3575,7 @@ var TransactionResponse = class {
|
|
3557
3575
|
/** Current provider */
|
3558
3576
|
provider;
|
3559
3577
|
/** Gas used on the transaction */
|
3560
|
-
gasUsed =
|
3578
|
+
gasUsed = bn17(0);
|
3561
3579
|
/** The graphql Transaction with receipts object. */
|
3562
3580
|
gqlTransaction;
|
3563
3581
|
abis;
|
@@ -3791,47 +3809,47 @@ var processGqlChain = (chain) => {
|
|
3791
3809
|
} = consensusParameters;
|
3792
3810
|
return {
|
3793
3811
|
name,
|
3794
|
-
baseChainHeight:
|
3812
|
+
baseChainHeight: bn18(daHeight),
|
3795
3813
|
consensusParameters: {
|
3796
3814
|
version,
|
3797
|
-
chainId:
|
3815
|
+
chainId: bn18(chainId),
|
3798
3816
|
baseAssetId,
|
3799
3817
|
feeParameters: {
|
3800
3818
|
version: feeParams.version,
|
3801
|
-
gasPerByte:
|
3802
|
-
gasPriceFactor:
|
3819
|
+
gasPerByte: bn18(feeParams.gasPerByte),
|
3820
|
+
gasPriceFactor: bn18(feeParams.gasPriceFactor)
|
3803
3821
|
},
|
3804
3822
|
contractParameters: {
|
3805
3823
|
version: contractParams.version,
|
3806
|
-
contractMaxSize:
|
3807
|
-
maxStorageSlots:
|
3824
|
+
contractMaxSize: bn18(contractParams.contractMaxSize),
|
3825
|
+
maxStorageSlots: bn18(contractParams.maxStorageSlots)
|
3808
3826
|
},
|
3809
3827
|
txParameters: {
|
3810
3828
|
version: txParams.version,
|
3811
|
-
maxInputs:
|
3812
|
-
maxOutputs:
|
3813
|
-
maxWitnesses:
|
3814
|
-
maxGasPerTx:
|
3815
|
-
maxSize:
|
3816
|
-
maxBytecodeSubsections:
|
3829
|
+
maxInputs: bn18(txParams.maxInputs),
|
3830
|
+
maxOutputs: bn18(txParams.maxOutputs),
|
3831
|
+
maxWitnesses: bn18(txParams.maxWitnesses),
|
3832
|
+
maxGasPerTx: bn18(txParams.maxGasPerTx),
|
3833
|
+
maxSize: bn18(txParams.maxSize),
|
3834
|
+
maxBytecodeSubsections: bn18(txParams.maxBytecodeSubsections)
|
3817
3835
|
},
|
3818
3836
|
predicateParameters: {
|
3819
3837
|
version: predicateParams.version,
|
3820
|
-
maxPredicateLength:
|
3821
|
-
maxPredicateDataLength:
|
3822
|
-
maxGasPerPredicate:
|
3823
|
-
maxMessageDataLength:
|
3838
|
+
maxPredicateLength: bn18(predicateParams.maxPredicateLength),
|
3839
|
+
maxPredicateDataLength: bn18(predicateParams.maxPredicateDataLength),
|
3840
|
+
maxGasPerPredicate: bn18(predicateParams.maxGasPerPredicate),
|
3841
|
+
maxMessageDataLength: bn18(predicateParams.maxMessageDataLength)
|
3824
3842
|
},
|
3825
3843
|
scriptParameters: {
|
3826
3844
|
version: scriptParams.version,
|
3827
|
-
maxScriptLength:
|
3828
|
-
maxScriptDataLength:
|
3845
|
+
maxScriptLength: bn18(scriptParams.maxScriptLength),
|
3846
|
+
maxScriptDataLength: bn18(scriptParams.maxScriptDataLength)
|
3829
3847
|
},
|
3830
3848
|
gasCosts
|
3831
3849
|
},
|
3832
3850
|
latestBlock: {
|
3833
3851
|
id: latestBlock.id,
|
3834
|
-
height:
|
3852
|
+
height: bn18(latestBlock.height),
|
3835
3853
|
time: latestBlock.header.time,
|
3836
3854
|
transactions: latestBlock.transactions.map((i) => ({
|
3837
3855
|
id: i.id
|
@@ -4027,7 +4045,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4027
4045
|
*/
|
4028
4046
|
async getBlockNumber() {
|
4029
4047
|
const { chain } = await this.operations.getChain();
|
4030
|
-
return
|
4048
|
+
return bn18(chain.latestBlock.height, 10);
|
4031
4049
|
}
|
4032
4050
|
/**
|
4033
4051
|
* Returns the chain information.
|
@@ -4037,8 +4055,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4037
4055
|
async fetchNode() {
|
4038
4056
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
4039
4057
|
const processedNodeInfo = {
|
4040
|
-
maxDepth:
|
4041
|
-
maxTx:
|
4058
|
+
maxDepth: bn18(nodeInfo.maxDepth),
|
4059
|
+
maxTx: bn18(nodeInfo.maxTx),
|
4042
4060
|
nodeVersion: nodeInfo.nodeVersion,
|
4043
4061
|
utxoValidation: nodeInfo.utxoValidation,
|
4044
4062
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -4170,7 +4188,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4170
4188
|
} = response;
|
4171
4189
|
if (inputs) {
|
4172
4190
|
inputs.forEach((input, index) => {
|
4173
|
-
if ("predicateGasUsed" in input &&
|
4191
|
+
if ("predicateGasUsed" in input && bn18(input.predicateGasUsed).gt(0)) {
|
4174
4192
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4175
4193
|
}
|
4176
4194
|
});
|
@@ -4328,12 +4346,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4328
4346
|
gasPrice = await this.estimateGasPrice(10);
|
4329
4347
|
}
|
4330
4348
|
const minFee = calculateGasFee({
|
4331
|
-
gasPrice:
|
4349
|
+
gasPrice: bn18(gasPrice),
|
4332
4350
|
gas: minGas,
|
4333
4351
|
priceFactor: gasPriceFactor,
|
4334
4352
|
tip: transactionRequest.tip
|
4335
4353
|
}).add(1);
|
4336
|
-
let gasLimit =
|
4354
|
+
let gasLimit = bn18(0);
|
4337
4355
|
if (transactionRequest.type === TransactionType8.Script) {
|
4338
4356
|
gasLimit = transactionRequest.gasLimit;
|
4339
4357
|
if (transactionRequest.gasLimit.eq(0)) {
|
@@ -4346,7 +4364,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4346
4364
|
}
|
4347
4365
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4348
4366
|
const maxFee = calculateGasFee({
|
4349
|
-
gasPrice:
|
4367
|
+
gasPrice: bn18(gasPrice),
|
4350
4368
|
gas: maxGas,
|
4351
4369
|
priceFactor: gasPriceFactor,
|
4352
4370
|
tip: transactionRequest.tip
|
@@ -4409,9 +4427,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4409
4427
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4410
4428
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4411
4429
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4412
|
-
txRequestClone.maxFee =
|
4430
|
+
txRequestClone.maxFee = bn18(0);
|
4413
4431
|
if (isScriptTransaction) {
|
4414
|
-
txRequestClone.gasLimit =
|
4432
|
+
txRequestClone.gasLimit = bn18(0);
|
4415
4433
|
}
|
4416
4434
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4417
4435
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4431,7 +4449,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4431
4449
|
let dryRunStatus;
|
4432
4450
|
let missingContractIds = [];
|
4433
4451
|
let outputVariables = 0;
|
4434
|
-
let gasUsed =
|
4452
|
+
let gasUsed = bn18(0);
|
4435
4453
|
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4436
4454
|
txRequestClone.maxFee = maxFee;
|
4437
4455
|
if (isScriptTransaction) {
|
@@ -4496,10 +4514,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4496
4514
|
return coins.map((coin) => ({
|
4497
4515
|
id: coin.utxoId,
|
4498
4516
|
assetId: coin.assetId,
|
4499
|
-
amount:
|
4517
|
+
amount: bn18(coin.amount),
|
4500
4518
|
owner: Address2.fromAddressOrString(coin.owner),
|
4501
|
-
blockCreated:
|
4502
|
-
txCreatedIdx:
|
4519
|
+
blockCreated: bn18(coin.blockCreated),
|
4520
|
+
txCreatedIdx: bn18(coin.txCreatedIdx)
|
4503
4521
|
}));
|
4504
4522
|
}
|
4505
4523
|
/**
|
@@ -4533,12 +4551,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4533
4551
|
};
|
4534
4552
|
const result = await this.operations.getCoinsToSpend(coinsQuery);
|
4535
4553
|
const coins = result.coinsToSpend.flat().map((coin) => {
|
4536
|
-
switch (coin.
|
4554
|
+
switch (coin.__typename) {
|
4537
4555
|
case "MessageCoin":
|
4538
4556
|
return {
|
4539
|
-
amount:
|
4557
|
+
amount: bn18(coin.amount),
|
4540
4558
|
assetId: coin.assetId,
|
4541
|
-
daHeight:
|
4559
|
+
daHeight: bn18(coin.daHeight),
|
4542
4560
|
sender: Address2.fromAddressOrString(coin.sender),
|
4543
4561
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4544
4562
|
nonce: coin.nonce
|
@@ -4546,11 +4564,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4546
4564
|
case "Coin":
|
4547
4565
|
return {
|
4548
4566
|
id: coin.utxoId,
|
4549
|
-
amount:
|
4567
|
+
amount: bn18(coin.amount),
|
4550
4568
|
assetId: coin.assetId,
|
4551
4569
|
owner: Address2.fromAddressOrString(coin.owner),
|
4552
|
-
blockCreated:
|
4553
|
-
txCreatedIdx:
|
4570
|
+
blockCreated: bn18(coin.blockCreated),
|
4571
|
+
txCreatedIdx: bn18(coin.txCreatedIdx)
|
4554
4572
|
};
|
4555
4573
|
default:
|
4556
4574
|
return null;
|
@@ -4567,13 +4585,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4567
4585
|
async getBlock(idOrHeight) {
|
4568
4586
|
let variables;
|
4569
4587
|
if (typeof idOrHeight === "number") {
|
4570
|
-
variables = { height:
|
4588
|
+
variables = { height: bn18(idOrHeight).toString(10) };
|
4571
4589
|
} else if (idOrHeight === "latest") {
|
4572
4590
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4573
4591
|
} else if (idOrHeight.length === 66) {
|
4574
4592
|
variables = { blockId: idOrHeight };
|
4575
4593
|
} else {
|
4576
|
-
variables = { blockId:
|
4594
|
+
variables = { blockId: bn18(idOrHeight).toString(10) };
|
4577
4595
|
}
|
4578
4596
|
const { block } = await this.operations.getBlock(variables);
|
4579
4597
|
if (!block) {
|
@@ -4581,7 +4599,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4581
4599
|
}
|
4582
4600
|
return {
|
4583
4601
|
id: block.id,
|
4584
|
-
height:
|
4602
|
+
height: bn18(block.height),
|
4585
4603
|
time: block.header.time,
|
4586
4604
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4587
4605
|
};
|
@@ -4596,7 +4614,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4596
4614
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4597
4615
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4598
4616
|
id: block.id,
|
4599
|
-
height:
|
4617
|
+
height: bn18(block.height),
|
4600
4618
|
time: block.header.time,
|
4601
4619
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4602
4620
|
}));
|
@@ -4611,7 +4629,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4611
4629
|
async getBlockWithTransactions(idOrHeight) {
|
4612
4630
|
let variables;
|
4613
4631
|
if (typeof idOrHeight === "number") {
|
4614
|
-
variables = { blockHeight:
|
4632
|
+
variables = { blockHeight: bn18(idOrHeight).toString(10) };
|
4615
4633
|
} else if (idOrHeight === "latest") {
|
4616
4634
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4617
4635
|
} else {
|
@@ -4623,7 +4641,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4623
4641
|
}
|
4624
4642
|
return {
|
4625
4643
|
id: block.id,
|
4626
|
-
height:
|
4644
|
+
height: bn18(block.height, 10),
|
4627
4645
|
time: block.header.time,
|
4628
4646
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4629
4647
|
transactions: block.transactions.map(
|
@@ -4672,7 +4690,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4672
4690
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4673
4691
|
asset: hexlify12(assetId)
|
4674
4692
|
});
|
4675
|
-
return
|
4693
|
+
return bn18(contractBalance.amount, 10);
|
4676
4694
|
}
|
4677
4695
|
/**
|
4678
4696
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4686,7 +4704,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4686
4704
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4687
4705
|
assetId: hexlify12(assetId)
|
4688
4706
|
});
|
4689
|
-
return
|
4707
|
+
return bn18(balance.amount, 10);
|
4690
4708
|
}
|
4691
4709
|
/**
|
4692
4710
|
* Returns balances for the given owner.
|
@@ -4704,7 +4722,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4704
4722
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4705
4723
|
return balances.map((balance) => ({
|
4706
4724
|
assetId: balance.assetId,
|
4707
|
-
amount:
|
4725
|
+
amount: bn18(balance.amount)
|
4708
4726
|
}));
|
4709
4727
|
}
|
4710
4728
|
/**
|
@@ -4726,15 +4744,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4726
4744
|
sender: message.sender,
|
4727
4745
|
recipient: message.recipient,
|
4728
4746
|
nonce: message.nonce,
|
4729
|
-
amount:
|
4747
|
+
amount: bn18(message.amount),
|
4730
4748
|
data: message.data
|
4731
4749
|
}),
|
4732
4750
|
sender: Address2.fromAddressOrString(message.sender),
|
4733
4751
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4734
4752
|
nonce: message.nonce,
|
4735
|
-
amount:
|
4753
|
+
amount: bn18(message.amount),
|
4736
4754
|
data: InputMessageCoder.decodeData(message.data),
|
4737
|
-
daHeight:
|
4755
|
+
daHeight: bn18(message.daHeight)
|
4738
4756
|
}));
|
4739
4757
|
}
|
4740
4758
|
/**
|
@@ -4787,19 +4805,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4787
4805
|
} = result.messageProof;
|
4788
4806
|
return {
|
4789
4807
|
messageProof: {
|
4790
|
-
proofIndex:
|
4808
|
+
proofIndex: bn18(messageProof.proofIndex),
|
4791
4809
|
proofSet: messageProof.proofSet
|
4792
4810
|
},
|
4793
4811
|
blockProof: {
|
4794
|
-
proofIndex:
|
4812
|
+
proofIndex: bn18(blockProof.proofIndex),
|
4795
4813
|
proofSet: blockProof.proofSet
|
4796
4814
|
},
|
4797
4815
|
messageBlockHeader: {
|
4798
4816
|
id: messageBlockHeader.id,
|
4799
|
-
daHeight:
|
4817
|
+
daHeight: bn18(messageBlockHeader.daHeight),
|
4800
4818
|
transactionsCount: Number(messageBlockHeader.transactionsCount),
|
4801
4819
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4802
|
-
height:
|
4820
|
+
height: bn18(messageBlockHeader.height),
|
4803
4821
|
prevRoot: messageBlockHeader.prevRoot,
|
4804
4822
|
time: messageBlockHeader.time,
|
4805
4823
|
applicationHash: messageBlockHeader.applicationHash,
|
@@ -4811,10 +4829,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4811
4829
|
},
|
4812
4830
|
commitBlockHeader: {
|
4813
4831
|
id: commitBlockHeader.id,
|
4814
|
-
daHeight:
|
4832
|
+
daHeight: bn18(commitBlockHeader.daHeight),
|
4815
4833
|
transactionsCount: Number(commitBlockHeader.transactionsCount),
|
4816
4834
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4817
|
-
height:
|
4835
|
+
height: bn18(commitBlockHeader.height),
|
4818
4836
|
prevRoot: commitBlockHeader.prevRoot,
|
4819
4837
|
time: commitBlockHeader.time,
|
4820
4838
|
applicationHash: commitBlockHeader.applicationHash,
|
@@ -4827,19 +4845,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4827
4845
|
sender: Address2.fromAddressOrString(sender),
|
4828
4846
|
recipient: Address2.fromAddressOrString(recipient),
|
4829
4847
|
nonce,
|
4830
|
-
amount:
|
4848
|
+
amount: bn18(amount),
|
4831
4849
|
data
|
4832
4850
|
};
|
4833
4851
|
}
|
4834
4852
|
async getLatestGasPrice() {
|
4835
4853
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4836
|
-
return
|
4854
|
+
return bn18(latestGasPrice.gasPrice);
|
4837
4855
|
}
|
4838
4856
|
async estimateGasPrice(blockHorizon) {
|
4839
4857
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4840
4858
|
blockHorizon: String(blockHorizon)
|
4841
4859
|
});
|
4842
|
-
return
|
4860
|
+
return bn18(estimateGasPrice.gasPrice);
|
4843
4861
|
}
|
4844
4862
|
/**
|
4845
4863
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4860,10 +4878,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4860
4878
|
*/
|
4861
4879
|
async produceBlocks(amount, startTime) {
|
4862
4880
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4863
|
-
blocksToProduce:
|
4881
|
+
blocksToProduce: bn18(amount).toString(10),
|
4864
4882
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4865
4883
|
});
|
4866
|
-
return
|
4884
|
+
return bn18(latestBlockHeight);
|
4867
4885
|
}
|
4868
4886
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4869
4887
|
async getTransactionResponse(transactionId) {
|
@@ -4909,7 +4927,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4909
4927
|
|
4910
4928
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4911
4929
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4912
|
-
import { bn as
|
4930
|
+
import { bn as bn19 } from "@fuel-ts/math";
|
4913
4931
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4914
4932
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4915
4933
|
async function getTransactionSummary(params) {
|
@@ -4946,8 +4964,8 @@ async function getTransactionSummary(params) {
|
|
4946
4964
|
transaction: decodedTransaction,
|
4947
4965
|
transactionBytes: arrayify12(gqlTransaction.rawPayload),
|
4948
4966
|
gqlTransactionStatus: gqlTransaction.status,
|
4949
|
-
gasPerByte:
|
4950
|
-
gasPriceFactor:
|
4967
|
+
gasPerByte: bn19(gasPerByte),
|
4968
|
+
gasPriceFactor: bn19(gasPriceFactor),
|
4951
4969
|
abiMap,
|
4952
4970
|
maxInputs,
|
4953
4971
|
gasCosts,
|
@@ -5149,22 +5167,6 @@ var assets = [
|
|
5149
5167
|
}
|
5150
5168
|
];
|
5151
5169
|
|
5152
|
-
// src/providers/transaction-request/helpers.ts
|
5153
|
-
import { bn as bn19 } from "@fuel-ts/math";
|
5154
|
-
import { InputType as InputType8 } from "@fuel-ts/transactions";
|
5155
|
-
var isRequestInputCoin = (input) => input.type === InputType8.Coin;
|
5156
|
-
var isRequestInputMessage = (input) => input.type === InputType8.Message;
|
5157
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
5158
|
-
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
5159
|
-
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
5160
|
-
return acc.add(input.amount);
|
5161
|
-
}
|
5162
|
-
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
5163
|
-
return acc.add(input.amount);
|
5164
|
-
}
|
5165
|
-
return acc;
|
5166
|
-
}, bn19(0));
|
5167
|
-
|
5168
5170
|
// src/utils/formatTransferToContractScriptData.ts
|
5169
5171
|
import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
5170
5172
|
import { BN as BN2 } from "@fuel-ts/math";
|
@@ -5402,7 +5404,7 @@ var Account = class extends AbstractAccount {
|
|
5402
5404
|
while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
|
5403
5405
|
const resources = await this.getResourcesToSpend(
|
5404
5406
|
missingQuantities,
|
5405
|
-
|
5407
|
+
cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
|
5406
5408
|
);
|
5407
5409
|
request.addResources(resources);
|
5408
5410
|
txRequest.shiftPredicateData();
|
@@ -9134,7 +9136,7 @@ import {
|
|
9134
9136
|
} from "@fuel-ts/abi-coder";
|
9135
9137
|
import { Address as Address9 } from "@fuel-ts/address";
|
9136
9138
|
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
9137
|
-
import { ByteArrayCoder
|
9139
|
+
import { ByteArrayCoder } from "@fuel-ts/transactions";
|
9138
9140
|
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
9139
9141
|
|
9140
9142
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -9193,10 +9195,15 @@ var Predicate = class extends Account {
|
|
9193
9195
|
populateTransactionPredicateData(transactionRequestLike) {
|
9194
9196
|
const request = transactionRequestify(transactionRequestLike);
|
9195
9197
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
9196
|
-
|
9197
|
-
|
9198
|
+
const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
|
9199
|
+
if (placeholderIndex !== -1) {
|
9200
|
+
request.removeWitness(placeholderIndex);
|
9201
|
+
}
|
9202
|
+
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
9203
|
+
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9198
9204
|
input.predicate = hexlify19(this.bytes);
|
9199
9205
|
input.predicateData = hexlify19(this.getPredicateData(policies.length));
|
9206
|
+
input.witnessIndex = 0;
|
9200
9207
|
}
|
9201
9208
|
});
|
9202
9209
|
return request;
|
@@ -9319,6 +9326,28 @@ var Predicate = class extends Account {
|
|
9319
9326
|
}
|
9320
9327
|
return mutatedBytes;
|
9321
9328
|
}
|
9329
|
+
/**
|
9330
|
+
* Returns the index of the witness placeholder that was added to this predicate.
|
9331
|
+
* If no witness placeholder was added, it returns -1.
|
9332
|
+
* @param request - The transaction request.
|
9333
|
+
* @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
|
9334
|
+
*/
|
9335
|
+
getIndexFromPlaceholderWitness(request) {
|
9336
|
+
const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
|
9337
|
+
let index = -1;
|
9338
|
+
const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
|
9339
|
+
if (hasEmptyPredicateInputs) {
|
9340
|
+
index = hasEmptyPredicateInputs.witnessIndex;
|
9341
|
+
const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
|
9342
|
+
if (!allInputsAreEmpty) {
|
9343
|
+
const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
|
9344
|
+
if (wasFilledInputAddedFirst) {
|
9345
|
+
index = -1;
|
9346
|
+
}
|
9347
|
+
}
|
9348
|
+
}
|
9349
|
+
return index;
|
9350
|
+
}
|
9322
9351
|
};
|
9323
9352
|
|
9324
9353
|
// src/connectors/fuel.ts
|
@@ -10041,7 +10070,8 @@ export {
|
|
10041
10070
|
assets,
|
10042
10071
|
buildBlockExplorerUrl,
|
10043
10072
|
cacheFor,
|
10044
|
-
|
10073
|
+
cacheRequestInputsResources,
|
10074
|
+
cacheRequestInputsResourcesFromOwner,
|
10045
10075
|
calculateGasFee,
|
10046
10076
|
calculateMetadataGasForTxCreate,
|
10047
10077
|
calculateMetadataGasForTxScript,
|
@@ -10054,6 +10084,7 @@ export {
|
|
10054
10084
|
extractMintedAssetsFromReceipts,
|
10055
10085
|
extractTxError,
|
10056
10086
|
gasUsedByInputs,
|
10087
|
+
getAssetAmountInRequestInputs,
|
10057
10088
|
getAssetEth,
|
10058
10089
|
getAssetFuel,
|
10059
10090
|
getAssetNetwork,
|
@@ -10088,6 +10119,7 @@ export {
|
|
10088
10119
|
getReceiptsMessageOut,
|
10089
10120
|
getReceiptsTransferOut,
|
10090
10121
|
getReceiptsWithMissingData,
|
10122
|
+
getRequestInputResourceOwner,
|
10091
10123
|
getTransactionStatusName,
|
10092
10124
|
getTransactionSummary,
|
10093
10125
|
getTransactionSummaryFromRequest,
|
@@ -10101,6 +10133,10 @@ export {
|
|
10101
10133
|
isMessage,
|
10102
10134
|
isRawCoin,
|
10103
10135
|
isRawMessage,
|
10136
|
+
isRequestInputCoin,
|
10137
|
+
isRequestInputMessage,
|
10138
|
+
isRequestInputResource,
|
10139
|
+
isRequestInputResourceFromOwner,
|
10104
10140
|
isType,
|
10105
10141
|
isTypeCreate,
|
10106
10142
|
isTypeMint,
|