@fuel-ts/account 0.84.0 → 0.86.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/dist/account.d.ts +6 -6
- package/dist/account.d.ts.map +1 -1
- package/dist/hdwallet/hdwallet.d.ts.map +1 -1
- package/dist/index.global.js +1878 -2996
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +565 -512
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +380 -342
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/mnemonic/utils.d.ts +0 -1
- package/dist/mnemonic/utils.d.ts.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 +346 -552
- 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/coin.d.ts +0 -1
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +0 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +6 -10
- 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/input.d.ts +0 -2
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +2 -1
- 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/call.d.ts +1 -1
- package/dist/providers/transaction-summary/call.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 +5 -13
- 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 +1628 -2758
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +523 -499
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +353 -329
- 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 -16
package/dist/index.mjs
CHANGED
@@ -31,7 +31,7 @@ var __privateMethod = (obj, member, method) => {
|
|
31
31
|
import { Address as Address3 } from "@fuel-ts/address";
|
32
32
|
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
33
33
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
34
|
-
import { bn as
|
34
|
+
import { bn as bn19 } from "@fuel-ts/math";
|
35
35
|
import { arrayify as arrayify14, isDefined as isDefined2 } from "@fuel-ts/utils";
|
36
36
|
import { clone as clone4 } from "ramda";
|
37
37
|
|
@@ -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 TransactionStatusSubscriptionFragmentDoc = gql`
|
92
92
|
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
93
93
|
type: __typename
|
94
94
|
... on SqueezedOutStatus {
|
@@ -96,7 +96,13 @@ var TransactionStatusSubscriptionFragmentFragmentDoc = gql`
|
|
96
96
|
}
|
97
97
|
}
|
98
98
|
`;
|
99
|
-
var
|
99
|
+
var SubmittedStatusFragmentDoc = gql`
|
100
|
+
fragment SubmittedStatusFragment on SubmittedStatus {
|
101
|
+
type: __typename
|
102
|
+
time
|
103
|
+
}
|
104
|
+
`;
|
105
|
+
var ReceiptFragmentDoc = gql`
|
100
106
|
fragment receiptFragment on Receipt {
|
101
107
|
id
|
102
108
|
pc
|
@@ -128,45 +134,65 @@ var ReceiptFragmentFragmentDoc = gql`
|
|
128
134
|
subId
|
129
135
|
}
|
130
136
|
`;
|
131
|
-
var
|
132
|
-
fragment
|
137
|
+
var SuccessStatusFragmentDoc = gql`
|
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 {
|
133
172
|
type: __typename
|
173
|
+
reason
|
174
|
+
}
|
175
|
+
`;
|
176
|
+
var TransactionStatusFragmentDoc = gql`
|
177
|
+
fragment transactionStatusFragment on TransactionStatus {
|
134
178
|
... on SubmittedStatus {
|
135
|
-
|
179
|
+
...SubmittedStatusFragment
|
136
180
|
}
|
137
181
|
... on SuccessStatus {
|
138
|
-
|
139
|
-
id
|
140
|
-
}
|
141
|
-
time
|
142
|
-
programState {
|
143
|
-
returnType
|
144
|
-
data
|
145
|
-
}
|
146
|
-
receipts {
|
147
|
-
...receiptFragment
|
148
|
-
}
|
149
|
-
totalGas
|
150
|
-
totalFee
|
182
|
+
...SuccessStatusFragment
|
151
183
|
}
|
152
184
|
... on FailureStatus {
|
153
|
-
|
154
|
-
id
|
155
|
-
}
|
156
|
-
totalGas
|
157
|
-
totalFee
|
158
|
-
time
|
159
|
-
reason
|
160
|
-
receipts {
|
161
|
-
...receiptFragment
|
162
|
-
}
|
185
|
+
...FailureStatusFragment
|
163
186
|
}
|
164
187
|
... on SqueezedOutStatus {
|
165
|
-
|
188
|
+
...SqueezedOutStatusFragment
|
166
189
|
}
|
167
190
|
}
|
168
|
-
${
|
169
|
-
|
191
|
+
${SubmittedStatusFragmentDoc}
|
192
|
+
${SuccessStatusFragmentDoc}
|
193
|
+
${FailureStatusFragmentDoc}
|
194
|
+
${SqueezedOutStatusFragmentDoc}`;
|
195
|
+
var TransactionFragmentDoc = gql`
|
170
196
|
fragment transactionFragment on Transaction {
|
171
197
|
id
|
172
198
|
rawPayload
|
@@ -174,8 +200,8 @@ var TransactionFragmentFragmentDoc = gql`
|
|
174
200
|
...transactionStatusFragment
|
175
201
|
}
|
176
202
|
}
|
177
|
-
${
|
178
|
-
var
|
203
|
+
${TransactionStatusFragmentDoc}`;
|
204
|
+
var InputEstimatePredicatesFragmentDoc = gql`
|
179
205
|
fragment inputEstimatePredicatesFragment on Input {
|
180
206
|
... on InputCoin {
|
181
207
|
predicateGasUsed
|
@@ -185,14 +211,14 @@ var InputEstimatePredicatesFragmentFragmentDoc = gql`
|
|
185
211
|
}
|
186
212
|
}
|
187
213
|
`;
|
188
|
-
var
|
214
|
+
var TransactionEstimatePredicatesFragmentDoc = gql`
|
189
215
|
fragment transactionEstimatePredicatesFragment on Transaction {
|
190
216
|
inputs {
|
191
217
|
...inputEstimatePredicatesFragment
|
192
218
|
}
|
193
219
|
}
|
194
|
-
${
|
195
|
-
var
|
220
|
+
${InputEstimatePredicatesFragmentDoc}`;
|
221
|
+
var DryRunFailureStatusFragmentDoc = gql`
|
196
222
|
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
197
223
|
totalGas
|
198
224
|
totalFee
|
@@ -203,7 +229,7 @@ var DryRunFailureStatusFragmentFragmentDoc = gql`
|
|
203
229
|
}
|
204
230
|
}
|
205
231
|
`;
|
206
|
-
var
|
232
|
+
var DryRunSuccessStatusFragmentDoc = gql`
|
207
233
|
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
208
234
|
totalGas
|
209
235
|
totalFee
|
@@ -213,7 +239,7 @@ var DryRunSuccessStatusFragmentFragmentDoc = gql`
|
|
213
239
|
}
|
214
240
|
}
|
215
241
|
`;
|
216
|
-
var
|
242
|
+
var DryRunTransactionStatusFragmentDoc = gql`
|
217
243
|
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
218
244
|
... on DryRunFailureStatus {
|
219
245
|
...dryRunFailureStatusFragment
|
@@ -222,9 +248,9 @@ var DryRunTransactionStatusFragmentFragmentDoc = gql`
|
|
222
248
|
...dryRunSuccessStatusFragment
|
223
249
|
}
|
224
250
|
}
|
225
|
-
${
|
226
|
-
${
|
227
|
-
var
|
251
|
+
${DryRunFailureStatusFragmentDoc}
|
252
|
+
${DryRunSuccessStatusFragmentDoc}`;
|
253
|
+
var DryRunTransactionExecutionStatusFragmentDoc = gql`
|
228
254
|
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
229
255
|
id
|
230
256
|
status {
|
@@ -234,11 +260,11 @@ var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
|
|
234
260
|
...receiptFragment
|
235
261
|
}
|
236
262
|
}
|
237
|
-
${
|
238
|
-
${
|
239
|
-
var
|
263
|
+
${DryRunTransactionStatusFragmentDoc}
|
264
|
+
${ReceiptFragmentDoc}`;
|
265
|
+
var CoinFragmentDoc = gql`
|
240
266
|
fragment coinFragment on Coin {
|
241
|
-
__typename
|
267
|
+
type: __typename
|
242
268
|
utxoId
|
243
269
|
owner
|
244
270
|
amount
|
@@ -247,9 +273,9 @@ var CoinFragmentFragmentDoc = gql`
|
|
247
273
|
txCreatedIdx
|
248
274
|
}
|
249
275
|
`;
|
250
|
-
var
|
276
|
+
var MessageCoinFragmentDoc = gql`
|
251
277
|
fragment messageCoinFragment on MessageCoin {
|
252
|
-
__typename
|
278
|
+
type: __typename
|
253
279
|
sender
|
254
280
|
recipient
|
255
281
|
nonce
|
@@ -258,7 +284,7 @@ var MessageCoinFragmentFragmentDoc = gql`
|
|
258
284
|
daHeight
|
259
285
|
}
|
260
286
|
`;
|
261
|
-
var
|
287
|
+
var MessageFragmentDoc = gql`
|
262
288
|
fragment messageFragment on Message {
|
263
289
|
amount
|
264
290
|
sender
|
@@ -268,7 +294,7 @@ var MessageFragmentFragmentDoc = gql`
|
|
268
294
|
daHeight
|
269
295
|
}
|
270
296
|
`;
|
271
|
-
var
|
297
|
+
var MessageProofFragmentDoc = gql`
|
272
298
|
fragment messageProofFragment on MessageProof {
|
273
299
|
messageProof {
|
274
300
|
proofSet
|
@@ -315,14 +341,14 @@ var MessageProofFragmentFragmentDoc = gql`
|
|
315
341
|
data
|
316
342
|
}
|
317
343
|
`;
|
318
|
-
var
|
344
|
+
var BalanceFragmentDoc = gql`
|
319
345
|
fragment balanceFragment on Balance {
|
320
346
|
owner
|
321
347
|
amount
|
322
348
|
assetId
|
323
349
|
}
|
324
350
|
`;
|
325
|
-
var
|
351
|
+
var BlockFragmentDoc = gql`
|
326
352
|
fragment blockFragment on Block {
|
327
353
|
id
|
328
354
|
height
|
@@ -334,7 +360,7 @@ var BlockFragmentFragmentDoc = gql`
|
|
334
360
|
}
|
335
361
|
}
|
336
362
|
`;
|
337
|
-
var
|
363
|
+
var TxParametersFragmentDoc = gql`
|
338
364
|
fragment TxParametersFragment on TxParameters {
|
339
365
|
version
|
340
366
|
maxInputs
|
@@ -345,7 +371,7 @@ var TxParametersFragmentFragmentDoc = gql`
|
|
345
371
|
maxBytecodeSubsections
|
346
372
|
}
|
347
373
|
`;
|
348
|
-
var
|
374
|
+
var PredicateParametersFragmentDoc = gql`
|
349
375
|
fragment PredicateParametersFragment on PredicateParameters {
|
350
376
|
version
|
351
377
|
maxPredicateLength
|
@@ -354,41 +380,42 @@ var PredicateParametersFragmentFragmentDoc = gql`
|
|
354
380
|
maxMessageDataLength
|
355
381
|
}
|
356
382
|
`;
|
357
|
-
var
|
383
|
+
var ScriptParametersFragmentDoc = gql`
|
358
384
|
fragment ScriptParametersFragment on ScriptParameters {
|
359
385
|
version
|
360
386
|
maxScriptLength
|
361
387
|
maxScriptDataLength
|
362
388
|
}
|
363
389
|
`;
|
364
|
-
var
|
390
|
+
var ContractParametersFragmentDoc = gql`
|
365
391
|
fragment ContractParametersFragment on ContractParameters {
|
366
392
|
version
|
367
393
|
contractMaxSize
|
368
394
|
maxStorageSlots
|
369
395
|
}
|
370
396
|
`;
|
371
|
-
var
|
397
|
+
var FeeParametersFragmentDoc = gql`
|
372
398
|
fragment FeeParametersFragment on FeeParameters {
|
373
399
|
version
|
374
400
|
gasPriceFactor
|
375
401
|
gasPerByte
|
376
402
|
}
|
377
403
|
`;
|
378
|
-
var
|
404
|
+
var DependentCostFragmentDoc = gql`
|
379
405
|
fragment DependentCostFragment on DependentCost {
|
380
|
-
__typename
|
381
406
|
... on LightOperation {
|
407
|
+
type: __typename
|
382
408
|
base
|
383
409
|
unitsPerGas
|
384
410
|
}
|
385
411
|
... on HeavyOperation {
|
412
|
+
type: __typename
|
386
413
|
base
|
387
414
|
gasPerUnit
|
388
415
|
}
|
389
416
|
}
|
390
417
|
`;
|
391
|
-
var
|
418
|
+
var GasCostsFragmentDoc = gql`
|
392
419
|
fragment GasCostsFragment on GasCosts {
|
393
420
|
version
|
394
421
|
add
|
@@ -544,8 +571,8 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
544
571
|
}
|
545
572
|
newStoragePerByte
|
546
573
|
}
|
547
|
-
${
|
548
|
-
var
|
574
|
+
${DependentCostFragmentDoc}`;
|
575
|
+
var ConsensusParametersFragmentDoc = gql`
|
549
576
|
fragment consensusParametersFragment on ConsensusParameters {
|
550
577
|
version
|
551
578
|
txParams {
|
@@ -569,13 +596,13 @@ var ConsensusParametersFragmentFragmentDoc = gql`
|
|
569
596
|
baseAssetId
|
570
597
|
chainId
|
571
598
|
}
|
572
|
-
${
|
573
|
-
${
|
574
|
-
${
|
575
|
-
${
|
576
|
-
${
|
577
|
-
${
|
578
|
-
var
|
599
|
+
${TxParametersFragmentDoc}
|
600
|
+
${PredicateParametersFragmentDoc}
|
601
|
+
${ScriptParametersFragmentDoc}
|
602
|
+
${ContractParametersFragmentDoc}
|
603
|
+
${FeeParametersFragmentDoc}
|
604
|
+
${GasCostsFragmentDoc}`;
|
605
|
+
var ChainInfoFragmentDoc = gql`
|
579
606
|
fragment chainInfoFragment on ChainInfo {
|
580
607
|
name
|
581
608
|
latestBlock {
|
@@ -586,16 +613,16 @@ var ChainInfoFragmentFragmentDoc = gql`
|
|
586
613
|
...consensusParametersFragment
|
587
614
|
}
|
588
615
|
}
|
589
|
-
${
|
590
|
-
${
|
591
|
-
var
|
616
|
+
${BlockFragmentDoc}
|
617
|
+
${ConsensusParametersFragmentDoc}`;
|
618
|
+
var ContractBalanceFragmentDoc = gql`
|
592
619
|
fragment contractBalanceFragment on ContractBalance {
|
593
620
|
contract
|
594
621
|
amount
|
595
622
|
assetId
|
596
623
|
}
|
597
624
|
`;
|
598
|
-
var
|
625
|
+
var PageInfoFragmentDoc = gql`
|
599
626
|
fragment pageInfoFragment on PageInfo {
|
600
627
|
hasPreviousPage
|
601
628
|
hasNextPage
|
@@ -603,7 +630,7 @@ var PageInfoFragmentFragmentDoc = gql`
|
|
603
630
|
endCursor
|
604
631
|
}
|
605
632
|
`;
|
606
|
-
var
|
633
|
+
var NodeInfoFragmentDoc = gql`
|
607
634
|
fragment nodeInfoFragment on NodeInfo {
|
608
635
|
utxoValidation
|
609
636
|
vmBacktrace
|
@@ -612,7 +639,7 @@ var NodeInfoFragmentFragmentDoc = gql`
|
|
612
639
|
nodeVersion
|
613
640
|
}
|
614
641
|
`;
|
615
|
-
var
|
642
|
+
var RelayedTransactionStatusFragmentDoc = gql`
|
616
643
|
fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
|
617
644
|
... on RelayedTransactionFailed {
|
618
645
|
blockHeight
|
@@ -633,28 +660,28 @@ var GetNodeInfoDocument = gql`
|
|
633
660
|
...nodeInfoFragment
|
634
661
|
}
|
635
662
|
}
|
636
|
-
${
|
663
|
+
${NodeInfoFragmentDoc}`;
|
637
664
|
var GetChainDocument = gql`
|
638
665
|
query getChain {
|
639
666
|
chain {
|
640
667
|
...chainInfoFragment
|
641
668
|
}
|
642
669
|
}
|
643
|
-
${
|
670
|
+
${ChainInfoFragmentDoc}`;
|
644
671
|
var GetTransactionDocument = gql`
|
645
672
|
query getTransaction($transactionId: TransactionId!) {
|
646
673
|
transaction(id: $transactionId) {
|
647
674
|
...transactionFragment
|
648
675
|
}
|
649
676
|
}
|
650
|
-
${
|
677
|
+
${TransactionFragmentDoc}`;
|
651
678
|
var GetTransactionWithReceiptsDocument = gql`
|
652
679
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
653
680
|
transaction(id: $transactionId) {
|
654
681
|
...transactionFragment
|
655
682
|
}
|
656
683
|
}
|
657
|
-
${
|
684
|
+
${TransactionFragmentDoc}`;
|
658
685
|
var GetTransactionsDocument = gql`
|
659
686
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
660
687
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -665,7 +692,7 @@ var GetTransactionsDocument = gql`
|
|
665
692
|
}
|
666
693
|
}
|
667
694
|
}
|
668
|
-
${
|
695
|
+
${TransactionFragmentDoc}`;
|
669
696
|
var GetTransactionsByOwnerDocument = gql`
|
670
697
|
query getTransactionsByOwner($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
671
698
|
transactionsByOwner(
|
@@ -685,22 +712,22 @@ var GetTransactionsByOwnerDocument = gql`
|
|
685
712
|
}
|
686
713
|
}
|
687
714
|
}
|
688
|
-
${
|
689
|
-
${
|
715
|
+
${PageInfoFragmentDoc}
|
716
|
+
${TransactionFragmentDoc}`;
|
690
717
|
var EstimatePredicatesDocument = gql`
|
691
718
|
query estimatePredicates($encodedTransaction: HexString!) {
|
692
719
|
estimatePredicates(tx: $encodedTransaction) {
|
693
720
|
...transactionEstimatePredicatesFragment
|
694
721
|
}
|
695
722
|
}
|
696
|
-
${
|
723
|
+
${TransactionEstimatePredicatesFragmentDoc}`;
|
697
724
|
var GetBlockDocument = gql`
|
698
725
|
query getBlock($blockId: BlockId, $height: U32) {
|
699
726
|
block(id: $blockId, height: $height) {
|
700
727
|
...blockFragment
|
701
728
|
}
|
702
729
|
}
|
703
|
-
${
|
730
|
+
${BlockFragmentDoc}`;
|
704
731
|
var GetBlockWithTransactionsDocument = gql`
|
705
732
|
query getBlockWithTransactions($blockId: BlockId, $blockHeight: U32) {
|
706
733
|
block(id: $blockId, height: $blockHeight) {
|
@@ -710,8 +737,8 @@ var GetBlockWithTransactionsDocument = gql`
|
|
710
737
|
}
|
711
738
|
}
|
712
739
|
}
|
713
|
-
${
|
714
|
-
${
|
740
|
+
${BlockFragmentDoc}
|
741
|
+
${TransactionFragmentDoc}`;
|
715
742
|
var GetBlocksDocument = gql`
|
716
743
|
query getBlocks($after: String, $before: String, $first: Int, $last: Int) {
|
717
744
|
blocks(after: $after, before: $before, first: $first, last: $last) {
|
@@ -722,14 +749,14 @@ var GetBlocksDocument = gql`
|
|
722
749
|
}
|
723
750
|
}
|
724
751
|
}
|
725
|
-
${
|
752
|
+
${BlockFragmentDoc}`;
|
726
753
|
var GetCoinDocument = gql`
|
727
754
|
query getCoin($coinId: UtxoId!) {
|
728
755
|
coin(utxoId: $coinId) {
|
729
756
|
...coinFragment
|
730
757
|
}
|
731
758
|
}
|
732
|
-
${
|
759
|
+
${CoinFragmentDoc}`;
|
733
760
|
var GetCoinsDocument = gql`
|
734
761
|
query getCoins($filter: CoinFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
735
762
|
coins(
|
@@ -746,7 +773,7 @@ var GetCoinsDocument = gql`
|
|
746
773
|
}
|
747
774
|
}
|
748
775
|
}
|
749
|
-
${
|
776
|
+
${CoinFragmentDoc}`;
|
750
777
|
var GetCoinsToSpendDocument = gql`
|
751
778
|
query getCoinsToSpend($owner: Address!, $queryPerAsset: [SpendQueryElementInput!]!, $excludedIds: ExcludeInput) {
|
752
779
|
coinsToSpend(
|
@@ -758,8 +785,8 @@ var GetCoinsToSpendDocument = gql`
|
|
758
785
|
...messageCoinFragment
|
759
786
|
}
|
760
787
|
}
|
761
|
-
${
|
762
|
-
${
|
788
|
+
${CoinFragmentDoc}
|
789
|
+
${MessageCoinFragmentDoc}`;
|
763
790
|
var GetContractDocument = gql`
|
764
791
|
query getContract($contractId: ContractId!) {
|
765
792
|
contract(id: $contractId) {
|
@@ -774,14 +801,14 @@ var GetContractBalanceDocument = gql`
|
|
774
801
|
...contractBalanceFragment
|
775
802
|
}
|
776
803
|
}
|
777
|
-
${
|
804
|
+
${ContractBalanceFragmentDoc}`;
|
778
805
|
var GetBalanceDocument = gql`
|
779
806
|
query getBalance($owner: Address!, $assetId: AssetId!) {
|
780
807
|
balance(owner: $owner, assetId: $assetId) {
|
781
808
|
...balanceFragment
|
782
809
|
}
|
783
810
|
}
|
784
|
-
${
|
811
|
+
${BalanceFragmentDoc}`;
|
785
812
|
var GetLatestGasPriceDocument = gql`
|
786
813
|
query getLatestGasPrice {
|
787
814
|
latestGasPrice {
|
@@ -812,7 +839,7 @@ var GetBalancesDocument = gql`
|
|
812
839
|
}
|
813
840
|
}
|
814
841
|
}
|
815
|
-
${
|
842
|
+
${BalanceFragmentDoc}`;
|
816
843
|
var GetMessagesDocument = gql`
|
817
844
|
query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
818
845
|
messages(
|
@@ -829,7 +856,7 @@ var GetMessagesDocument = gql`
|
|
829
856
|
}
|
830
857
|
}
|
831
858
|
}
|
832
|
-
${
|
859
|
+
${MessageFragmentDoc}`;
|
833
860
|
var GetMessageProofDocument = gql`
|
834
861
|
query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
|
835
862
|
messageProof(
|
@@ -841,7 +868,7 @@ var GetMessageProofDocument = gql`
|
|
841
868
|
...messageProofFragment
|
842
869
|
}
|
843
870
|
}
|
844
|
-
${
|
871
|
+
${MessageProofFragmentDoc}`;
|
845
872
|
var GetMessageStatusDocument = gql`
|
846
873
|
query getMessageStatus($nonce: Nonce!) {
|
847
874
|
messageStatus(nonce: $nonce) {
|
@@ -855,14 +882,14 @@ var GetRelayedTransactionStatusDocument = gql`
|
|
855
882
|
...relayedTransactionStatusFragment
|
856
883
|
}
|
857
884
|
}
|
858
|
-
${
|
885
|
+
${RelayedTransactionStatusFragmentDoc}`;
|
859
886
|
var DryRunDocument = gql`
|
860
887
|
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
861
888
|
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
862
889
|
...dryRunTransactionExecutionStatusFragment
|
863
890
|
}
|
864
891
|
}
|
865
|
-
${
|
892
|
+
${DryRunTransactionExecutionStatusFragmentDoc}`;
|
866
893
|
var SubmitDocument = gql`
|
867
894
|
mutation submit($encodedTransaction: HexString!) {
|
868
895
|
submit(tx: $encodedTransaction) {
|
@@ -884,21 +911,21 @@ var GetMessageByNonceDocument = gql`
|
|
884
911
|
...messageFragment
|
885
912
|
}
|
886
913
|
}
|
887
|
-
${
|
914
|
+
${MessageFragmentDoc}`;
|
888
915
|
var SubmitAndAwaitDocument = gql`
|
889
916
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
890
917
|
submitAndAwait(tx: $encodedTransaction) {
|
891
918
|
...transactionStatusSubscriptionFragment
|
892
919
|
}
|
893
920
|
}
|
894
|
-
${
|
921
|
+
${TransactionStatusSubscriptionFragmentDoc}`;
|
895
922
|
var StatusChangeDocument = gql`
|
896
923
|
subscription statusChange($transactionId: TransactionId!) {
|
897
924
|
statusChange(id: $transactionId) {
|
898
925
|
...transactionStatusSubscriptionFragment
|
899
926
|
}
|
900
927
|
}
|
901
|
-
${
|
928
|
+
${TransactionStatusSubscriptionFragmentDoc}`;
|
902
929
|
function getSdk(requester) {
|
903
930
|
return {
|
904
931
|
getVersion(variables, options) {
|
@@ -1269,11 +1296,11 @@ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
|
|
1269
1296
|
import { Address, addressify } from "@fuel-ts/address";
|
1270
1297
|
import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
|
1271
1298
|
import { randomBytes } from "@fuel-ts/crypto";
|
1272
|
-
import { bn as
|
1299
|
+
import { bn as bn8 } from "@fuel-ts/math";
|
1273
1300
|
import {
|
1274
1301
|
PolicyType,
|
1275
1302
|
TransactionCoder,
|
1276
|
-
InputType as
|
1303
|
+
InputType as InputType3,
|
1277
1304
|
OutputType as OutputType2,
|
1278
1305
|
TransactionType
|
1279
1306
|
} from "@fuel-ts/transactions";
|
@@ -1572,10 +1599,9 @@ var getGasUsedFromReceipts = (receipts) => {
|
|
1572
1599
|
function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
1573
1600
|
const base = bn5(gasDependentCost.base);
|
1574
1601
|
let dependentValue = bn5(0);
|
1575
|
-
if (
|
1602
|
+
if ("unitsPerGas" in gasDependentCost) {
|
1576
1603
|
dependentValue = bn5(byteSize).div(bn5(gasDependentCost.unitsPerGas));
|
1577
|
-
}
|
1578
|
-
if (gasDependentCost.__typename === "HeavyOperation") {
|
1604
|
+
} else {
|
1579
1605
|
dependentValue = bn5(byteSize).mul(bn5(gasDependentCost.gasPerUnit));
|
1580
1606
|
}
|
1581
1607
|
return base.add(dependentValue);
|
@@ -1797,6 +1823,52 @@ var NoWitnessByOwnerError = class extends Error {
|
|
1797
1823
|
name = "NoWitnessByOwnerError";
|
1798
1824
|
};
|
1799
1825
|
|
1826
|
+
// src/providers/transaction-request/helpers.ts
|
1827
|
+
import { bn as bn7 } from "@fuel-ts/math";
|
1828
|
+
import { InputType as InputType2 } from "@fuel-ts/transactions";
|
1829
|
+
var isRequestInputCoin = (input) => input.type === InputType2.Coin;
|
1830
|
+
var isRequestInputMessage = (input) => input.type === InputType2.Message;
|
1831
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
1832
|
+
var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
1833
|
+
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
1834
|
+
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
1835
|
+
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
1836
|
+
return acc.add(input.amount);
|
1837
|
+
}
|
1838
|
+
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
1839
|
+
return acc.add(input.amount);
|
1840
|
+
}
|
1841
|
+
return acc;
|
1842
|
+
}, bn7(0));
|
1843
|
+
var cacheRequestInputsResources = (inputs) => inputs.filter(isRequestInputResource).reduce(
|
1844
|
+
(cache2, input) => {
|
1845
|
+
if (isRequestInputCoin(input)) {
|
1846
|
+
cache2.utxos.push(input.id);
|
1847
|
+
} else {
|
1848
|
+
cache2.messages.push(input.nonce);
|
1849
|
+
}
|
1850
|
+
return cache2;
|
1851
|
+
},
|
1852
|
+
{
|
1853
|
+
utxos: [],
|
1854
|
+
messages: []
|
1855
|
+
}
|
1856
|
+
);
|
1857
|
+
var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
1858
|
+
(acc, input) => {
|
1859
|
+
if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
|
1860
|
+
acc.utxos.push(input.id);
|
1861
|
+
} else if (isRequestInputMessage(input) && input.recipient === owner.toB256()) {
|
1862
|
+
acc.messages.push(input.nonce);
|
1863
|
+
}
|
1864
|
+
return acc;
|
1865
|
+
},
|
1866
|
+
{
|
1867
|
+
utxos: [],
|
1868
|
+
messages: []
|
1869
|
+
}
|
1870
|
+
);
|
1871
|
+
|
1800
1872
|
// src/providers/transaction-request/witness.ts
|
1801
1873
|
import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
|
1802
1874
|
var witnessify = (value) => {
|
@@ -1837,10 +1909,10 @@ var BaseTransactionRequest = class {
|
|
1837
1909
|
outputs,
|
1838
1910
|
witnesses
|
1839
1911
|
} = {}) {
|
1840
|
-
this.tip = tip ?
|
1912
|
+
this.tip = tip ? bn8(tip) : void 0;
|
1841
1913
|
this.maturity = maturity && maturity > 0 ? maturity : void 0;
|
1842
|
-
this.witnessLimit = isDefined(witnessLimit) ?
|
1843
|
-
this.maxFee =
|
1914
|
+
this.witnessLimit = isDefined(witnessLimit) ? bn8(witnessLimit) : void 0;
|
1915
|
+
this.maxFee = bn8(maxFee);
|
1844
1916
|
this.inputs = inputs ?? [];
|
1845
1917
|
this.outputs = outputs ?? [];
|
1846
1918
|
this.witnesses = witnesses ?? [];
|
@@ -1849,13 +1921,13 @@ var BaseTransactionRequest = class {
|
|
1849
1921
|
let policyTypes = 0;
|
1850
1922
|
const policies = [];
|
1851
1923
|
const { tip, witnessLimit, maturity } = req;
|
1852
|
-
if (
|
1924
|
+
if (bn8(tip).gt(0)) {
|
1853
1925
|
policyTypes += PolicyType.Tip;
|
1854
|
-
policies.push({ data:
|
1926
|
+
policies.push({ data: bn8(tip), type: PolicyType.Tip });
|
1855
1927
|
}
|
1856
|
-
if (isDefined(witnessLimit) &&
|
1928
|
+
if (isDefined(witnessLimit) && bn8(witnessLimit).gte(0)) {
|
1857
1929
|
policyTypes += PolicyType.WitnessLimit;
|
1858
|
-
policies.push({ data:
|
1930
|
+
policies.push({ data: bn8(witnessLimit), type: PolicyType.WitnessLimit });
|
1859
1931
|
}
|
1860
1932
|
if (maturity && maturity > 0) {
|
1861
1933
|
policyTypes += PolicyType.Maturity;
|
@@ -1986,7 +2058,7 @@ var BaseTransactionRequest = class {
|
|
1986
2058
|
*/
|
1987
2059
|
getCoinInputs() {
|
1988
2060
|
return this.inputs.filter(
|
1989
|
-
(input) => input.type ===
|
2061
|
+
(input) => input.type === InputType3.Coin
|
1990
2062
|
);
|
1991
2063
|
}
|
1992
2064
|
/**
|
@@ -2018,9 +2090,9 @@ var BaseTransactionRequest = class {
|
|
2018
2090
|
const ownerAddress = addressify(owner);
|
2019
2091
|
const found = this.inputs.find((input) => {
|
2020
2092
|
switch (input.type) {
|
2021
|
-
case
|
2093
|
+
case InputType3.Coin:
|
2022
2094
|
return hexlify7(input.owner) === ownerAddress.toB256();
|
2023
|
-
case
|
2095
|
+
case InputType3.Message:
|
2024
2096
|
return hexlify7(input.recipient) === ownerAddress.toB256();
|
2025
2097
|
default:
|
2026
2098
|
return false;
|
@@ -2035,7 +2107,7 @@ var BaseTransactionRequest = class {
|
|
2035
2107
|
* @param coin - Coin resource.
|
2036
2108
|
*/
|
2037
2109
|
addCoinInput(coin) {
|
2038
|
-
const { assetId, owner, amount } = coin;
|
2110
|
+
const { assetId, owner, amount, id, predicate } = coin;
|
2039
2111
|
let witnessIndex;
|
2040
2112
|
if (coin.predicate) {
|
2041
2113
|
witnessIndex = 0;
|
@@ -2046,13 +2118,14 @@ var BaseTransactionRequest = class {
|
|
2046
2118
|
}
|
2047
2119
|
}
|
2048
2120
|
const input = {
|
2049
|
-
|
2050
|
-
type:
|
2121
|
+
id,
|
2122
|
+
type: InputType3.Coin,
|
2051
2123
|
owner: owner.toB256(),
|
2052
2124
|
amount,
|
2053
2125
|
assetId,
|
2054
2126
|
txPointer: "0x00000000000000000000000000000000",
|
2055
|
-
witnessIndex
|
2127
|
+
witnessIndex,
|
2128
|
+
predicate
|
2056
2129
|
};
|
2057
2130
|
this.pushInput(input);
|
2058
2131
|
this.addChangeOutput(owner, assetId);
|
@@ -2064,7 +2137,7 @@ var BaseTransactionRequest = class {
|
|
2064
2137
|
* @param message - Message resource.
|
2065
2138
|
*/
|
2066
2139
|
addMessageInput(message) {
|
2067
|
-
const { recipient, sender, amount, assetId } = message;
|
2140
|
+
const { recipient, sender, amount, predicate, nonce, assetId } = message;
|
2068
2141
|
let witnessIndex;
|
2069
2142
|
if (message.predicate) {
|
2070
2143
|
witnessIndex = 0;
|
@@ -2075,12 +2148,13 @@ var BaseTransactionRequest = class {
|
|
2075
2148
|
}
|
2076
2149
|
}
|
2077
2150
|
const input = {
|
2078
|
-
|
2079
|
-
type:
|
2151
|
+
nonce,
|
2152
|
+
type: InputType3.Message,
|
2080
2153
|
sender: sender.toB256(),
|
2081
2154
|
recipient: recipient.toB256(),
|
2082
2155
|
amount,
|
2083
|
-
witnessIndex
|
2156
|
+
witnessIndex,
|
2157
|
+
predicate
|
2084
2158
|
};
|
2085
2159
|
this.pushInput(input);
|
2086
2160
|
this.addChangeOutput(recipient, assetId);
|
@@ -2227,7 +2301,7 @@ var BaseTransactionRequest = class {
|
|
2227
2301
|
const assetInput = findAssetInput(assetId);
|
2228
2302
|
let usedQuantity = quantity;
|
2229
2303
|
if (assetId === baseAssetId) {
|
2230
|
-
usedQuantity =
|
2304
|
+
usedQuantity = bn8("1000000000000000000");
|
2231
2305
|
}
|
2232
2306
|
if (assetInput && "assetId" in assetInput) {
|
2233
2307
|
assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
|
@@ -2239,13 +2313,13 @@ var BaseTransactionRequest = class {
|
|
2239
2313
|
amount: usedQuantity,
|
2240
2314
|
assetId,
|
2241
2315
|
owner: resourcesOwner || Address.fromRandom(),
|
2242
|
-
blockCreated:
|
2243
|
-
txCreatedIdx:
|
2316
|
+
blockCreated: bn8(1),
|
2317
|
+
txCreatedIdx: bn8(1)
|
2244
2318
|
}
|
2245
2319
|
]);
|
2246
2320
|
}
|
2247
2321
|
};
|
2248
|
-
updateAssetInput(baseAssetId,
|
2322
|
+
updateAssetInput(baseAssetId, bn8(1e11));
|
2249
2323
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2250
2324
|
}
|
2251
2325
|
/**
|
@@ -2256,7 +2330,7 @@ var BaseTransactionRequest = class {
|
|
2256
2330
|
*/
|
2257
2331
|
getCoinOutputsQuantities() {
|
2258
2332
|
const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
|
2259
|
-
amount:
|
2333
|
+
amount: bn8(amount),
|
2260
2334
|
assetId: assetId.toString()
|
2261
2335
|
}));
|
2262
2336
|
return coinsQuantities;
|
@@ -2270,50 +2344,52 @@ var BaseTransactionRequest = class {
|
|
2270
2344
|
toJSON() {
|
2271
2345
|
return normalizeJSON(this);
|
2272
2346
|
}
|
2347
|
+
removeWitness(index) {
|
2348
|
+
this.witnesses.splice(index, 1);
|
2349
|
+
this.adjustWitnessIndexes(index);
|
2350
|
+
}
|
2351
|
+
adjustWitnessIndexes(removedIndex) {
|
2352
|
+
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
2353
|
+
if (input.witnessIndex > removedIndex) {
|
2354
|
+
input.witnessIndex -= 1;
|
2355
|
+
}
|
2356
|
+
});
|
2357
|
+
}
|
2273
2358
|
updatePredicateGasUsed(inputs) {
|
2274
2359
|
this.inputs.forEach((i) => {
|
2275
2360
|
let correspondingInput;
|
2276
2361
|
switch (i.type) {
|
2277
|
-
case
|
2278
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2362
|
+
case InputType3.Coin:
|
2363
|
+
correspondingInput = inputs.find((x) => x.type === InputType3.Coin && x.owner === i.owner);
|
2279
2364
|
break;
|
2280
|
-
case
|
2365
|
+
case InputType3.Message:
|
2281
2366
|
correspondingInput = inputs.find(
|
2282
|
-
(x) => x.type ===
|
2367
|
+
(x) => x.type === InputType3.Message && x.sender === i.sender
|
2283
2368
|
);
|
2284
2369
|
break;
|
2285
2370
|
default:
|
2286
2371
|
return;
|
2287
2372
|
}
|
2288
|
-
if (correspondingInput && "predicateGasUsed" in correspondingInput &&
|
2373
|
+
if (correspondingInput && "predicateGasUsed" in correspondingInput && bn8(correspondingInput.predicateGasUsed).gt(0)) {
|
2289
2374
|
i.predicate = correspondingInput.predicate;
|
2290
2375
|
i.predicateData = correspondingInput.predicateData;
|
2291
2376
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
2292
2377
|
}
|
2293
2378
|
});
|
2294
2379
|
}
|
2295
|
-
shiftPredicateData() {
|
2296
|
-
this.inputs.forEach((input) => {
|
2297
|
-
if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
|
2298
|
-
input.predicateData = input.padPredicateData(
|
2299
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2300
|
-
);
|
2301
|
-
}
|
2302
|
-
});
|
2303
|
-
}
|
2304
2380
|
};
|
2305
2381
|
|
2306
2382
|
// src/providers/transaction-request/create-transaction-request.ts
|
2307
2383
|
import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
|
2308
|
-
import { bn as
|
2384
|
+
import { bn as bn10 } from "@fuel-ts/math";
|
2309
2385
|
import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
|
2310
2386
|
import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
2311
2387
|
|
2312
2388
|
// src/providers/transaction-request/hash-transaction.ts
|
2313
2389
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2314
2390
|
import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
|
2315
|
-
import { bn as
|
2316
|
-
import { TransactionType as TransactionType2, InputType as
|
2391
|
+
import { bn as bn9 } from "@fuel-ts/math";
|
2392
|
+
import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
|
2317
2393
|
import { concat as concat2 } from "@fuel-ts/utils";
|
2318
2394
|
import { clone as clone2 } from "ramda";
|
2319
2395
|
function hashTransaction(transactionRequest, chainId) {
|
@@ -2324,19 +2400,19 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2324
2400
|
transaction.inputs = transaction.inputs.map((input) => {
|
2325
2401
|
const inputClone = clone2(input);
|
2326
2402
|
switch (inputClone.type) {
|
2327
|
-
case
|
2403
|
+
case InputType4.Coin: {
|
2328
2404
|
inputClone.txPointer = {
|
2329
2405
|
blockHeight: 0,
|
2330
2406
|
txIndex: 0
|
2331
2407
|
};
|
2332
|
-
inputClone.predicateGasUsed =
|
2408
|
+
inputClone.predicateGasUsed = bn9(0);
|
2333
2409
|
return inputClone;
|
2334
2410
|
}
|
2335
|
-
case
|
2336
|
-
inputClone.predicateGasUsed =
|
2411
|
+
case InputType4.Message: {
|
2412
|
+
inputClone.predicateGasUsed = bn9(0);
|
2337
2413
|
return inputClone;
|
2338
2414
|
}
|
2339
|
-
case
|
2415
|
+
case InputType4.Contract: {
|
2340
2416
|
inputClone.txPointer = {
|
2341
2417
|
blockHeight: 0,
|
2342
2418
|
txIndex: 0
|
@@ -2360,12 +2436,12 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2360
2436
|
return outputClone;
|
2361
2437
|
}
|
2362
2438
|
case OutputType3.Change: {
|
2363
|
-
outputClone.amount =
|
2439
|
+
outputClone.amount = bn9(0);
|
2364
2440
|
return outputClone;
|
2365
2441
|
}
|
2366
2442
|
case OutputType3.Variable: {
|
2367
2443
|
outputClone.to = ZeroBytes325;
|
2368
|
-
outputClone.amount =
|
2444
|
+
outputClone.amount = bn9(0);
|
2369
2445
|
outputClone.assetId = ZeroBytes325;
|
2370
2446
|
return outputClone;
|
2371
2447
|
}
|
@@ -2443,7 +2519,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2443
2519
|
type: TransactionType3.Create,
|
2444
2520
|
...baseTransaction,
|
2445
2521
|
bytecodeWitnessIndex,
|
2446
|
-
storageSlotsCount:
|
2522
|
+
storageSlotsCount: bn10(storageSlots.length),
|
2447
2523
|
salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
|
2448
2524
|
storageSlots
|
2449
2525
|
};
|
@@ -2483,7 +2559,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2483
2559
|
}
|
2484
2560
|
metadataGas(gasCosts) {
|
2485
2561
|
return calculateMetadataGasForTxCreate({
|
2486
|
-
contractBytesSize:
|
2562
|
+
contractBytesSize: bn10(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2487
2563
|
gasCosts,
|
2488
2564
|
stateRootSize: this.storageSlots.length,
|
2489
2565
|
txBytesSize: this.byteSize()
|
@@ -2495,8 +2571,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2495
2571
|
import { Interface } from "@fuel-ts/abi-coder";
|
2496
2572
|
import { addressify as addressify2 } from "@fuel-ts/address";
|
2497
2573
|
import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
2498
|
-
import { bn as
|
2499
|
-
import { InputType as
|
2574
|
+
import { bn as bn11 } from "@fuel-ts/math";
|
2575
|
+
import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
2500
2576
|
import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
|
2501
2577
|
|
2502
2578
|
// src/providers/transaction-request/scripts.ts
|
@@ -2549,7 +2625,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2549
2625
|
*/
|
2550
2626
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2551
2627
|
super(rest);
|
2552
|
-
this.gasLimit =
|
2628
|
+
this.gasLimit = bn11(gasLimit);
|
2553
2629
|
this.script = arrayify8(script ?? returnZeroScript.bytes);
|
2554
2630
|
this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
|
2555
2631
|
this.abis = rest.abis;
|
@@ -2566,8 +2642,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2566
2642
|
type: TransactionType4.Script,
|
2567
2643
|
scriptGasLimit: this.gasLimit,
|
2568
2644
|
...super.getBaseTransaction(),
|
2569
|
-
scriptLength:
|
2570
|
-
scriptDataLength:
|
2645
|
+
scriptLength: bn11(script.length),
|
2646
|
+
scriptDataLength: bn11(scriptData.length),
|
2571
2647
|
receiptsRoot: ZeroBytes327,
|
2572
2648
|
script: hexlify10(script),
|
2573
2649
|
scriptData: hexlify10(scriptData)
|
@@ -2580,7 +2656,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2580
2656
|
*/
|
2581
2657
|
getContractInputs() {
|
2582
2658
|
return this.inputs.filter(
|
2583
|
-
(input) => input.type ===
|
2659
|
+
(input) => input.type === InputType5.Contract
|
2584
2660
|
);
|
2585
2661
|
}
|
2586
2662
|
/**
|
@@ -2660,7 +2736,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2660
2736
|
return this;
|
2661
2737
|
}
|
2662
2738
|
const inputIndex = super.pushInput({
|
2663
|
-
type:
|
2739
|
+
type: InputType5.Contract,
|
2664
2740
|
contractId: contractAddress.toB256(),
|
2665
2741
|
txPointer: "0x00000000000000000000000000000000"
|
2666
2742
|
});
|
@@ -2702,7 +2778,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2702
2778
|
|
2703
2779
|
// src/providers/transaction-request/utils.ts
|
2704
2780
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2705
|
-
import { TransactionType as TransactionType5
|
2781
|
+
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2706
2782
|
var transactionRequestify = (obj) => {
|
2707
2783
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2708
2784
|
return obj;
|
@@ -2720,21 +2796,6 @@ var transactionRequestify = (obj) => {
|
|
2720
2796
|
}
|
2721
2797
|
}
|
2722
2798
|
};
|
2723
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2724
|
-
(acc, input) => {
|
2725
|
-
if (input.type === InputType5.Coin && input.owner === owner.toB256()) {
|
2726
|
-
acc.utxos.push(input.id);
|
2727
|
-
}
|
2728
|
-
if (input.type === InputType5.Message && input.recipient === owner.toB256()) {
|
2729
|
-
acc.messages.push(input.nonce);
|
2730
|
-
}
|
2731
|
-
return acc;
|
2732
|
-
},
|
2733
|
-
{
|
2734
|
-
utxos: [],
|
2735
|
-
messages: []
|
2736
|
-
}
|
2737
|
-
);
|
2738
2799
|
|
2739
2800
|
// src/providers/transaction-response/transaction-response.ts
|
2740
2801
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
@@ -2748,7 +2809,7 @@ import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
|
2748
2809
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2749
2810
|
|
2750
2811
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
2751
|
-
import { bn as
|
2812
|
+
import { bn as bn12 } from "@fuel-ts/math";
|
2752
2813
|
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
|
2753
2814
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2754
2815
|
var calculateTXFeeForSummary = (params) => {
|
@@ -2762,19 +2823,19 @@ var calculateTXFeeForSummary = (params) => {
|
|
2762
2823
|
if (totalFee) {
|
2763
2824
|
return totalFee;
|
2764
2825
|
}
|
2765
|
-
const gasPerByte =
|
2766
|
-
const gasPriceFactor =
|
2826
|
+
const gasPerByte = bn12(feeParams.gasPerByte);
|
2827
|
+
const gasPriceFactor = bn12(feeParams.gasPriceFactor);
|
2767
2828
|
const transactionBytes = arrayify9(rawPayload);
|
2768
2829
|
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
2769
2830
|
const { type, witnesses, inputs, policies } = transaction;
|
2770
|
-
let metadataGas =
|
2771
|
-
let gasLimit =
|
2831
|
+
let metadataGas = bn12(0);
|
2832
|
+
let gasLimit = bn12(0);
|
2772
2833
|
if (type !== TransactionType6.Create && type !== TransactionType6.Script) {
|
2773
|
-
return
|
2834
|
+
return bn12(0);
|
2774
2835
|
}
|
2775
2836
|
if (type === TransactionType6.Create) {
|
2776
2837
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2777
|
-
const contractBytesSize =
|
2838
|
+
const contractBytesSize = bn12(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
|
2778
2839
|
metadataGas = calculateMetadataGasForTxCreate({
|
2779
2840
|
contractBytesSize,
|
2780
2841
|
gasCosts,
|
@@ -2793,7 +2854,7 @@ var calculateTXFeeForSummary = (params) => {
|
|
2793
2854
|
}
|
2794
2855
|
const minGas = getMinGas({
|
2795
2856
|
gasCosts,
|
2796
|
-
gasPerByte:
|
2857
|
+
gasPerByte: bn12(gasPerByte),
|
2797
2858
|
inputs,
|
2798
2859
|
metadataGas,
|
2799
2860
|
txBytesSize: transactionBytes.length
|
@@ -2824,39 +2885,28 @@ import { bn as bn13 } from "@fuel-ts/math";
|
|
2824
2885
|
import { ReceiptType as ReceiptType4, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
2825
2886
|
|
2826
2887
|
// src/providers/transaction-summary/call.ts
|
2827
|
-
import { Interface as Interface2
|
2828
|
-
|
2829
|
-
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2888
|
+
import { Interface as Interface2 } from "@fuel-ts/abi-coder";
|
2889
|
+
var getFunctionCall = ({ abi, receipt }) => {
|
2830
2890
|
const abiInterface = new Interface2(abi);
|
2831
2891
|
const callFunctionSelector = receipt.param1.toHex(8);
|
2832
2892
|
const functionFragment = abiInterface.getFunction(callFunctionSelector);
|
2833
2893
|
const inputs = functionFragment.jsonFn.inputs;
|
2834
|
-
|
2835
|
-
if (functionFragment.isInputDataPointer) {
|
2836
|
-
if (rawPayload) {
|
2837
|
-
const argsOffset = bn12(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2838
|
-
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2839
|
-
}
|
2840
|
-
} else {
|
2841
|
-
encodedArgs = receipt.param2.toHex();
|
2842
|
-
}
|
2894
|
+
const encodedArgs = receipt.param2.toHex();
|
2843
2895
|
let argumentsProvided;
|
2844
|
-
|
2845
|
-
|
2846
|
-
|
2847
|
-
|
2848
|
-
|
2849
|
-
|
2850
|
-
|
2851
|
-
|
2852
|
-
|
2853
|
-
|
2854
|
-
|
2855
|
-
|
2856
|
-
|
2857
|
-
|
2858
|
-
}, {});
|
2859
|
-
}
|
2896
|
+
const data = functionFragment.decodeArguments(encodedArgs);
|
2897
|
+
if (data) {
|
2898
|
+
argumentsProvided = inputs.reduce((prev, input, index) => {
|
2899
|
+
const value = data[index];
|
2900
|
+
const name = input.name;
|
2901
|
+
if (name) {
|
2902
|
+
return {
|
2903
|
+
...prev,
|
2904
|
+
// reparse to remove bn
|
2905
|
+
[name]: JSON.parse(JSON.stringify(value))
|
2906
|
+
};
|
2907
|
+
}
|
2908
|
+
return prev;
|
2909
|
+
}, {});
|
2860
2910
|
}
|
2861
2911
|
const call = {
|
2862
2912
|
functionSignature: functionFragment.signature,
|
@@ -3939,9 +3989,11 @@ var _Provider = class {
|
|
3939
3989
|
static ensureClientVersionIsSupported(nodeInfo) {
|
3940
3990
|
const { isMajorSupported, isMinorSupported, supportedVersion } = checkFuelCoreVersionCompatibility(nodeInfo.nodeVersion);
|
3941
3991
|
if (!isMajorSupported || !isMinorSupported) {
|
3942
|
-
|
3943
|
-
|
3944
|
-
|
3992
|
+
console.warn(
|
3993
|
+
`The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion},
|
3994
|
+
which is not supported by the version of the TS SDK that you are using.
|
3995
|
+
Things may not work as expected.
|
3996
|
+
Supported fuel-core version: ${supportedVersion}.`
|
3945
3997
|
);
|
3946
3998
|
}
|
3947
3999
|
}
|
@@ -4378,10 +4430,10 @@ var _Provider = class {
|
|
4378
4430
|
const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
|
4379
4431
|
const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
|
4380
4432
|
const baseAssetId = this.getBaseAssetId();
|
4433
|
+
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
4381
4434
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4382
4435
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4383
4436
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4384
|
-
txRequestClone.maxFee = bn17(0);
|
4385
4437
|
if (isScriptTransaction) {
|
4386
4438
|
txRequestClone.gasLimit = bn17(0);
|
4387
4439
|
}
|
@@ -4396,6 +4448,7 @@ var _Provider = class {
|
|
4396
4448
|
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
4397
4449
|
}
|
4398
4450
|
await this.estimatePredicates(signedRequest);
|
4451
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4399
4452
|
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
4400
4453
|
transactionRequest: signedRequest
|
4401
4454
|
});
|
@@ -4404,7 +4457,6 @@ var _Provider = class {
|
|
4404
4457
|
let missingContractIds = [];
|
4405
4458
|
let outputVariables = 0;
|
4406
4459
|
let gasUsed = bn17(0);
|
4407
|
-
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4408
4460
|
txRequestClone.maxFee = maxFee;
|
4409
4461
|
if (isScriptTransaction) {
|
4410
4462
|
txRequestClone.gasLimit = gasLimit;
|
@@ -4432,7 +4484,8 @@ var _Provider = class {
|
|
4432
4484
|
missingContractIds,
|
4433
4485
|
addedSignatures,
|
4434
4486
|
estimatedPredicates: txRequestClone.inputs,
|
4435
|
-
dryRunStatus
|
4487
|
+
dryRunStatus,
|
4488
|
+
updateMaxFee
|
4436
4489
|
};
|
4437
4490
|
}
|
4438
4491
|
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
@@ -4505,7 +4558,7 @@ var _Provider = class {
|
|
4505
4558
|
};
|
4506
4559
|
const result = await this.operations.getCoinsToSpend(coinsQuery);
|
4507
4560
|
const coins = result.coinsToSpend.flat().map((coin) => {
|
4508
|
-
switch (coin.
|
4561
|
+
switch (coin.type) {
|
4509
4562
|
case "MessageCoin":
|
4510
4563
|
return {
|
4511
4564
|
amount: bn17(coin.amount),
|
@@ -5088,8 +5141,11 @@ function resolveIconPaths(assets2, basePath = "./") {
|
|
5088
5141
|
}));
|
5089
5142
|
}
|
5090
5143
|
|
5091
|
-
// src/providers/assets/
|
5092
|
-
var
|
5144
|
+
// src/providers/assets/utils/fuelAssetsBaseUrl.ts
|
5145
|
+
var fuelAssetsBaseUrl = "https://cdn.fuel.network/assets/";
|
5146
|
+
|
5147
|
+
// src/providers/assets/assets.ts
|
5148
|
+
var rawAssets = [
|
5093
5149
|
{
|
5094
5150
|
name: "Ethereum",
|
5095
5151
|
symbol: "ETH",
|
@@ -5120,22 +5176,7 @@ var assets = [
|
|
5120
5176
|
]
|
5121
5177
|
}
|
5122
5178
|
];
|
5123
|
-
|
5124
|
-
// src/providers/transaction-request/helpers.ts
|
5125
|
-
import { bn as bn19 } from "@fuel-ts/math";
|
5126
|
-
import { InputType as InputType8 } from "@fuel-ts/transactions";
|
5127
|
-
var isRequestInputCoin = (input) => input.type === InputType8.Coin;
|
5128
|
-
var isRequestInputMessage = (input) => input.type === InputType8.Message;
|
5129
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
5130
|
-
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
5131
|
-
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
5132
|
-
return acc.add(input.amount);
|
5133
|
-
}
|
5134
|
-
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
5135
|
-
return acc.add(input.amount);
|
5136
|
-
}
|
5137
|
-
return acc;
|
5138
|
-
}, bn19(0));
|
5179
|
+
var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
5139
5180
|
|
5140
5181
|
// src/utils/formatTransferToContractScriptData.ts
|
5141
5182
|
import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
@@ -5329,20 +5370,20 @@ var Account = class extends AbstractAccount {
|
|
5329
5370
|
return balances;
|
5330
5371
|
}
|
5331
5372
|
/**
|
5332
|
-
*
|
5373
|
+
* Funds a transaction request by adding the necessary resources.
|
5333
5374
|
*
|
5334
|
-
* @
|
5335
|
-
* @param
|
5336
|
-
* @param
|
5337
|
-
* @returns
|
5375
|
+
* @typeParam T - The type of the TransactionRequest.
|
5376
|
+
* @param request - The transaction request to fund.
|
5377
|
+
* @param params - The estimated transaction parameters.
|
5378
|
+
* @returns The funded transaction request.
|
5338
5379
|
*/
|
5339
5380
|
async fund(request, params) {
|
5340
|
-
const { addedSignatures, estimatedPredicates,
|
5381
|
+
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
|
5382
|
+
const fee = request.maxFee;
|
5341
5383
|
const baseAssetId = this.provider.getBaseAssetId();
|
5342
|
-
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount ||
|
5343
|
-
const txRequest = request;
|
5384
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn19(0);
|
5344
5385
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5345
|
-
amount:
|
5386
|
+
amount: bn19(fee),
|
5346
5387
|
assetId: baseAssetId,
|
5347
5388
|
coinQuantities: requiredQuantities
|
5348
5389
|
});
|
@@ -5350,7 +5391,7 @@ var Account = class extends AbstractAccount {
|
|
5350
5391
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
5351
5392
|
quantitiesDict[assetId] = {
|
5352
5393
|
required: amount,
|
5353
|
-
owned:
|
5394
|
+
owned: bn19(0)
|
5354
5395
|
};
|
5355
5396
|
});
|
5356
5397
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
@@ -5374,17 +5415,19 @@ var Account = class extends AbstractAccount {
|
|
5374
5415
|
while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
|
5375
5416
|
const resources = await this.getResourcesToSpend(
|
5376
5417
|
missingQuantities,
|
5377
|
-
|
5418
|
+
cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
|
5378
5419
|
);
|
5379
5420
|
request.addResources(resources);
|
5380
|
-
|
5381
|
-
|
5382
|
-
const requestToReestimate2 = clone4(txRequest);
|
5421
|
+
request.updatePredicateGasUsed(estimatedPredicates);
|
5422
|
+
const requestToReestimate2 = clone4(request);
|
5383
5423
|
if (addedSignatures) {
|
5384
5424
|
Array.from({ length: addedSignatures }).forEach(
|
5385
5425
|
() => requestToReestimate2.addEmptyWitness()
|
5386
5426
|
);
|
5387
5427
|
}
|
5428
|
+
if (!updateMaxFee) {
|
5429
|
+
break;
|
5430
|
+
}
|
5388
5431
|
const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
|
5389
5432
|
transactionRequest: requestToReestimate2
|
5390
5433
|
});
|
@@ -5406,17 +5449,19 @@ var Account = class extends AbstractAccount {
|
|
5406
5449
|
}
|
5407
5450
|
fundingAttempts += 1;
|
5408
5451
|
}
|
5409
|
-
|
5410
|
-
|
5411
|
-
const requestToReestimate = clone4(txRequest);
|
5452
|
+
request.updatePredicateGasUsed(estimatedPredicates);
|
5453
|
+
const requestToReestimate = clone4(request);
|
5412
5454
|
if (addedSignatures) {
|
5413
5455
|
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
5414
5456
|
}
|
5457
|
+
if (!updateMaxFee) {
|
5458
|
+
return request;
|
5459
|
+
}
|
5415
5460
|
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
5416
5461
|
transactionRequest: requestToReestimate
|
5417
5462
|
});
|
5418
|
-
|
5419
|
-
return
|
5463
|
+
request.maxFee = maxFee;
|
5464
|
+
return request;
|
5420
5465
|
}
|
5421
5466
|
/**
|
5422
5467
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -5428,20 +5473,19 @@ var Account = class extends AbstractAccount {
|
|
5428
5473
|
* @returns A promise that resolves to the prepared transaction request.
|
5429
5474
|
*/
|
5430
5475
|
async createTransfer(destination, amount, assetId, txParams = {}) {
|
5431
|
-
|
5476
|
+
let request = new ScriptTransactionRequest(txParams);
|
5432
5477
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5433
5478
|
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
|
5434
5479
|
const txCost = await this.provider.getTransactionCost(request, {
|
5435
5480
|
estimateTxDependencies: true,
|
5436
5481
|
resourcesOwner: this
|
5437
5482
|
});
|
5438
|
-
this.validateGasLimitAndMaxFee({
|
5483
|
+
request = this.validateGasLimitAndMaxFee({
|
5484
|
+
transactionRequest: request,
|
5439
5485
|
gasUsed: txCost.gasUsed,
|
5440
5486
|
maxFee: txCost.maxFee,
|
5441
5487
|
txParams
|
5442
5488
|
});
|
5443
|
-
request.gasLimit = txCost.gasUsed;
|
5444
|
-
request.maxFee = txCost.maxFee;
|
5445
5489
|
await this.fund(request, txCost);
|
5446
5490
|
return request;
|
5447
5491
|
}
|
@@ -5455,7 +5499,7 @@ var Account = class extends AbstractAccount {
|
|
5455
5499
|
* @returns A promise that resolves to the transaction response.
|
5456
5500
|
*/
|
5457
5501
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5458
|
-
if (
|
5502
|
+
if (bn19(amount).lte(0)) {
|
5459
5503
|
throw new FuelError15(
|
5460
5504
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5461
5505
|
"Transfer amount must be a positive number."
|
@@ -5475,7 +5519,7 @@ var Account = class extends AbstractAccount {
|
|
5475
5519
|
* @returns A promise that resolves to the transaction response.
|
5476
5520
|
*/
|
5477
5521
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5478
|
-
if (
|
5522
|
+
if (bn19(amount).lte(0)) {
|
5479
5523
|
throw new FuelError15(
|
5480
5524
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5481
5525
|
"Transfer amount must be a positive number."
|
@@ -5485,10 +5529,10 @@ var Account = class extends AbstractAccount {
|
|
5485
5529
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5486
5530
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5487
5531
|
hexlifiedContractId: contractAddress.toB256(),
|
5488
|
-
amountToTransfer:
|
5532
|
+
amountToTransfer: bn19(amount),
|
5489
5533
|
assetId: assetIdToTransfer
|
5490
5534
|
});
|
5491
|
-
|
5535
|
+
let request = new ScriptTransactionRequest({
|
5492
5536
|
...txParams,
|
5493
5537
|
script,
|
5494
5538
|
scriptData
|
@@ -5496,15 +5540,14 @@ var Account = class extends AbstractAccount {
|
|
5496
5540
|
request.addContractInputAndOutput(contractAddress);
|
5497
5541
|
const txCost = await this.provider.getTransactionCost(request, {
|
5498
5542
|
resourcesOwner: this,
|
5499
|
-
quantitiesToContract: [{ amount:
|
5543
|
+
quantitiesToContract: [{ amount: bn19(amount), assetId: String(assetIdToTransfer) }]
|
5500
5544
|
});
|
5501
|
-
this.validateGasLimitAndMaxFee({
|
5545
|
+
request = this.validateGasLimitAndMaxFee({
|
5546
|
+
transactionRequest: request,
|
5502
5547
|
gasUsed: txCost.gasUsed,
|
5503
5548
|
maxFee: txCost.maxFee,
|
5504
5549
|
txParams
|
5505
5550
|
});
|
5506
|
-
request.gasLimit = txCost.gasUsed;
|
5507
|
-
request.maxFee = txCost.maxFee;
|
5508
5551
|
await this.fund(request, txCost);
|
5509
5552
|
return this.sendTransaction(request);
|
5510
5553
|
}
|
@@ -5522,7 +5565,7 @@ var Account = class extends AbstractAccount {
|
|
5522
5565
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5523
5566
|
);
|
5524
5567
|
const amountDataArray = arrayify14(
|
5525
|
-
"0x".concat(
|
5568
|
+
"0x".concat(bn19(amount).toHex().substring(2).padStart(16, "0"))
|
5526
5569
|
);
|
5527
5570
|
const script = new Uint8Array([
|
5528
5571
|
...arrayify14(withdrawScript.bytes),
|
@@ -5531,16 +5574,15 @@ var Account = class extends AbstractAccount {
|
|
5531
5574
|
]);
|
5532
5575
|
const params = { script, ...txParams };
|
5533
5576
|
const baseAssetId = this.provider.getBaseAssetId();
|
5534
|
-
|
5535
|
-
const quantitiesToContract = [{ amount:
|
5577
|
+
let request = new ScriptTransactionRequest(params);
|
5578
|
+
const quantitiesToContract = [{ amount: bn19(amount), assetId: baseAssetId }];
|
5536
5579
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5537
|
-
this.validateGasLimitAndMaxFee({
|
5580
|
+
request = this.validateGasLimitAndMaxFee({
|
5581
|
+
transactionRequest: request,
|
5538
5582
|
gasUsed: txCost.gasUsed,
|
5539
5583
|
maxFee: txCost.maxFee,
|
5540
5584
|
txParams
|
5541
5585
|
});
|
5542
|
-
request.maxFee = txCost.maxFee;
|
5543
|
-
request.gasLimit = txCost.gasUsed;
|
5544
5586
|
await this.fund(request, txCost);
|
5545
5587
|
return this.sendTransaction(request);
|
5546
5588
|
}
|
@@ -5600,22 +5642,29 @@ var Account = class extends AbstractAccount {
|
|
5600
5642
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5601
5643
|
}
|
5602
5644
|
validateGasLimitAndMaxFee({
|
5603
|
-
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
|
5604
5645
|
gasUsed,
|
5605
|
-
maxFee
|
5646
|
+
maxFee,
|
5647
|
+
transactionRequest,
|
5648
|
+
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
5606
5649
|
}) {
|
5607
|
-
|
5650
|
+
const request = transactionRequestify(transactionRequest);
|
5651
|
+
if (!isDefined2(setGasLimit)) {
|
5652
|
+
request.gasLimit = gasUsed;
|
5653
|
+
} else if (gasUsed.gt(setGasLimit)) {
|
5608
5654
|
throw new FuelError15(
|
5609
5655
|
ErrorCode15.GAS_LIMIT_TOO_LOW,
|
5610
5656
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5611
5657
|
);
|
5612
5658
|
}
|
5613
|
-
if (isDefined2(setMaxFee)
|
5659
|
+
if (!isDefined2(setMaxFee)) {
|
5660
|
+
request.maxFee = maxFee;
|
5661
|
+
} else if (maxFee.gt(setMaxFee)) {
|
5614
5662
|
throw new FuelError15(
|
5615
5663
|
ErrorCode15.MAX_FEE_TOO_LOW,
|
5616
5664
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
5617
5665
|
);
|
5618
5666
|
}
|
5667
|
+
return request;
|
5619
5668
|
}
|
5620
5669
|
};
|
5621
5670
|
|
@@ -5944,18 +5993,17 @@ var BaseWalletUnlocked = class extends Account {
|
|
5944
5993
|
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
5945
5994
|
|
5946
5995
|
// src/hdwallet/hdwallet.ts
|
5996
|
+
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
5947
5997
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5948
5998
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5949
|
-
import { bn as
|
5950
|
-
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5951
|
-
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5999
|
+
import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
6000
|
+
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
5952
6001
|
|
5953
6002
|
// src/mnemonic/mnemonic.ts
|
5954
|
-
import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
|
6003
|
+
import { randomBytes as randomBytes4, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
5955
6004
|
import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
|
5956
6005
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
5957
|
-
import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
|
5958
|
-
import { dataSlice, pbkdf2, computeHmac, encodeBase58 } from "ethers";
|
6006
|
+
import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
5959
6007
|
|
5960
6008
|
// src/wordlists/words/english.ts
|
5961
6009
|
var english = [
|
@@ -8019,38 +8067,6 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8019
8067
|
import { ErrorCode as ErrorCode17, FuelError as FuelError17 } from "@fuel-ts/errors";
|
8020
8068
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
8021
8069
|
import { arrayify as arrayify16 } from "@fuel-ts/utils";
|
8022
|
-
function toUtf8Bytes(stri) {
|
8023
|
-
const str = stri.normalize("NFKD");
|
8024
|
-
const result = [];
|
8025
|
-
for (let i = 0; i < str.length; i += 1) {
|
8026
|
-
const c = str.charCodeAt(i);
|
8027
|
-
if (c < 128) {
|
8028
|
-
result.push(c);
|
8029
|
-
} else if (c < 2048) {
|
8030
|
-
result.push(c >> 6 | 192);
|
8031
|
-
result.push(c & 63 | 128);
|
8032
|
-
} else if ((c & 64512) === 55296) {
|
8033
|
-
i += 1;
|
8034
|
-
const c2 = str.charCodeAt(i);
|
8035
|
-
if (i >= str.length || (c2 & 64512) !== 56320) {
|
8036
|
-
throw new FuelError17(
|
8037
|
-
ErrorCode17.INVALID_INPUT_PARAMETERS,
|
8038
|
-
"Invalid UTF-8 in the input string."
|
8039
|
-
);
|
8040
|
-
}
|
8041
|
-
const pair = 65536 + ((c & 1023) << 10) + (c2 & 1023);
|
8042
|
-
result.push(pair >> 18 | 240);
|
8043
|
-
result.push(pair >> 12 & 63 | 128);
|
8044
|
-
result.push(pair >> 6 & 63 | 128);
|
8045
|
-
result.push(pair & 63 | 128);
|
8046
|
-
} else {
|
8047
|
-
result.push(c >> 12 | 224);
|
8048
|
-
result.push(c >> 6 & 63 | 128);
|
8049
|
-
result.push(c & 63 | 128);
|
8050
|
-
}
|
8051
|
-
}
|
8052
|
-
return Uint8Array.from(result);
|
8053
|
-
}
|
8054
8070
|
function getLowerMask(bits) {
|
8055
8071
|
return (1 << bits) - 1;
|
8056
8072
|
}
|
@@ -8418,7 +8434,7 @@ var HDWallet = class {
|
|
8418
8434
|
const IR = bytes.slice(32);
|
8419
8435
|
if (privateKey) {
|
8420
8436
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8421
|
-
const ki =
|
8437
|
+
const ki = bn20(IL).add(privateKey).mod(N).toBytes(32);
|
8422
8438
|
return new HDWallet({
|
8423
8439
|
privateKey: ki,
|
8424
8440
|
chainCode: IR,
|
@@ -8484,7 +8500,7 @@ var HDWallet = class {
|
|
8484
8500
|
});
|
8485
8501
|
}
|
8486
8502
|
static fromExtendedKey(extendedKey) {
|
8487
|
-
const decoded =
|
8503
|
+
const decoded = hexlify17(toBytes2(decodeBase58(extendedKey)));
|
8488
8504
|
const bytes = arrayify18(decoded);
|
8489
8505
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8490
8506
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
@@ -9097,16 +9113,9 @@ var StorageAbstract = class {
|
|
9097
9113
|
};
|
9098
9114
|
|
9099
9115
|
// src/predicate/predicate.ts
|
9100
|
-
import {
|
9101
|
-
Interface as Interface4,
|
9102
|
-
INPUT_COIN_FIXED_SIZE,
|
9103
|
-
WORD_SIZE,
|
9104
|
-
calculateVmTxMemory as calculateVmTxMemory2,
|
9105
|
-
SCRIPT_FIXED_SIZE
|
9106
|
-
} from "@fuel-ts/abi-coder";
|
9116
|
+
import { Interface as Interface4 } from "@fuel-ts/abi-coder";
|
9107
9117
|
import { Address as Address9 } from "@fuel-ts/address";
|
9108
9118
|
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
9109
|
-
import { ByteArrayCoder, InputType as InputType9 } from "@fuel-ts/transactions";
|
9110
9119
|
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
9111
9120
|
|
9112
9121
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -9164,11 +9173,15 @@ var Predicate = class extends Account {
|
|
9164
9173
|
*/
|
9165
9174
|
populateTransactionPredicateData(transactionRequestLike) {
|
9166
9175
|
const request = transactionRequestify(transactionRequestLike);
|
9167
|
-
const
|
9168
|
-
|
9169
|
-
|
9176
|
+
const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
|
9177
|
+
if (placeholderIndex !== -1) {
|
9178
|
+
request.removeWitness(placeholderIndex);
|
9179
|
+
}
|
9180
|
+
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
9181
|
+
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9170
9182
|
input.predicate = hexlify19(this.bytes);
|
9171
|
-
input.predicateData = hexlify19(this.getPredicateData(
|
9183
|
+
input.predicateData = hexlify19(this.getPredicateData());
|
9184
|
+
input.witnessIndex = 0;
|
9172
9185
|
}
|
9173
9186
|
});
|
9174
9187
|
return request;
|
@@ -9193,17 +9206,12 @@ var Predicate = class extends Account {
|
|
9193
9206
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
9194
9207
|
return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
|
9195
9208
|
}
|
9196
|
-
getPredicateData(
|
9209
|
+
getPredicateData() {
|
9197
9210
|
if (!this.predicateData.length) {
|
9198
9211
|
return new Uint8Array();
|
9199
9212
|
}
|
9200
9213
|
const mainFn = this.interface?.functions.main;
|
9201
|
-
|
9202
|
-
const VM_TX_MEMORY = calculateVmTxMemory2({
|
9203
|
-
maxInputs: this.provider.getChain().consensusParameters.txParameters.maxInputs.toNumber()
|
9204
|
-
});
|
9205
|
-
const OFFSET = VM_TX_MEMORY + SCRIPT_FIXED_SIZE + INPUT_COIN_FIXED_SIZE + WORD_SIZE + paddedCode.byteLength + policiesLength * WORD_SIZE;
|
9206
|
-
return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
|
9214
|
+
return mainFn?.encodeArguments(this.predicateData) || new Uint8Array();
|
9207
9215
|
}
|
9208
9216
|
/**
|
9209
9217
|
* Processes the predicate data and returns the altered bytecode and interface.
|
@@ -9252,8 +9260,7 @@ var Predicate = class extends Account {
|
|
9252
9260
|
);
|
9253
9261
|
return resources.map((resource) => ({
|
9254
9262
|
...resource,
|
9255
|
-
predicate: hexlify19(this.bytes)
|
9256
|
-
padPredicateData: (policiesLength) => hexlify19(this.getPredicateData(policiesLength))
|
9263
|
+
predicate: hexlify19(this.bytes)
|
9257
9264
|
}));
|
9258
9265
|
}
|
9259
9266
|
/**
|
@@ -9291,6 +9298,28 @@ var Predicate = class extends Account {
|
|
9291
9298
|
}
|
9292
9299
|
return mutatedBytes;
|
9293
9300
|
}
|
9301
|
+
/**
|
9302
|
+
* Returns the index of the witness placeholder that was added to this predicate.
|
9303
|
+
* If no witness placeholder was added, it returns -1.
|
9304
|
+
* @param request - The transaction request.
|
9305
|
+
* @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
|
9306
|
+
*/
|
9307
|
+
getIndexFromPlaceholderWitness(request) {
|
9308
|
+
const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
|
9309
|
+
let index = -1;
|
9310
|
+
const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
|
9311
|
+
if (hasEmptyPredicateInputs) {
|
9312
|
+
index = hasEmptyPredicateInputs.witnessIndex;
|
9313
|
+
const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
|
9314
|
+
if (!allInputsAreEmpty) {
|
9315
|
+
const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
|
9316
|
+
if (wasFilledInputAddedFirst) {
|
9317
|
+
index = -1;
|
9318
|
+
}
|
9319
|
+
}
|
9320
|
+
}
|
9321
|
+
return index;
|
9322
|
+
}
|
9294
9323
|
};
|
9295
9324
|
|
9296
9325
|
// src/connectors/fuel.ts
|
@@ -10013,7 +10042,8 @@ export {
|
|
10013
10042
|
assets,
|
10014
10043
|
buildBlockExplorerUrl,
|
10015
10044
|
cacheFor,
|
10016
|
-
|
10045
|
+
cacheRequestInputsResources,
|
10046
|
+
cacheRequestInputsResourcesFromOwner,
|
10017
10047
|
calculateGasFee,
|
10018
10048
|
calculateMetadataGasForTxCreate,
|
10019
10049
|
calculateMetadataGasForTxScript,
|
@@ -10025,7 +10055,9 @@ export {
|
|
10025
10055
|
extractBurnedAssetsFromReceipts,
|
10026
10056
|
extractMintedAssetsFromReceipts,
|
10027
10057
|
extractTxError,
|
10058
|
+
fuelAssetsBaseUrl,
|
10028
10059
|
gasUsedByInputs,
|
10060
|
+
getAssetAmountInRequestInputs,
|
10029
10061
|
getAssetEth,
|
10030
10062
|
getAssetFuel,
|
10031
10063
|
getAssetNetwork,
|
@@ -10060,6 +10092,7 @@ export {
|
|
10060
10092
|
getReceiptsMessageOut,
|
10061
10093
|
getReceiptsTransferOut,
|
10062
10094
|
getReceiptsWithMissingData,
|
10095
|
+
getRequestInputResourceOwner,
|
10063
10096
|
getTransactionStatusName,
|
10064
10097
|
getTransactionSummary,
|
10065
10098
|
getTransactionSummaryFromRequest,
|
@@ -10073,6 +10106,10 @@ export {
|
|
10073
10106
|
isMessage,
|
10074
10107
|
isRawCoin,
|
10075
10108
|
isRawMessage,
|
10109
|
+
isRequestInputCoin,
|
10110
|
+
isRequestInputMessage,
|
10111
|
+
isRequestInputResource,
|
10112
|
+
isRequestInputResourceFromOwner,
|
10076
10113
|
isType,
|
10077
10114
|
isTypeCreate,
|
10078
10115
|
isTypeMint,
|
@@ -10083,6 +10120,7 @@ export {
|
|
10083
10120
|
outputify,
|
10084
10121
|
processGqlReceipt,
|
10085
10122
|
processGraphqlStatus,
|
10123
|
+
rawAssets,
|
10086
10124
|
resolveGasDependentCosts,
|
10087
10125
|
resolveIconPaths,
|
10088
10126
|
returnZeroScript,
|