@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/test-utils.mjs
CHANGED
@@ -26,7 +26,7 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
|
|
26
26
|
import { Address as Address3 } from "@fuel-ts/address";
|
27
27
|
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
28
28
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
29
|
-
import { bn as
|
29
|
+
import { bn as bn19 } from "@fuel-ts/math";
|
30
30
|
import { arrayify as arrayify14, isDefined as isDefined2 } from "@fuel-ts/utils";
|
31
31
|
import { clone as clone4 } from "ramda";
|
32
32
|
|
@@ -83,7 +83,7 @@ import { clone as clone3 } from "ramda";
|
|
83
83
|
|
84
84
|
// src/providers/__generated__/operations.ts
|
85
85
|
import gql from "graphql-tag";
|
86
|
-
var
|
86
|
+
var TransactionStatusSubscriptionFragmentDoc = gql`
|
87
87
|
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
88
88
|
type: __typename
|
89
89
|
... on SqueezedOutStatus {
|
@@ -91,7 +91,13 @@ var TransactionStatusSubscriptionFragmentFragmentDoc = gql`
|
|
91
91
|
}
|
92
92
|
}
|
93
93
|
`;
|
94
|
-
var
|
94
|
+
var SubmittedStatusFragmentDoc = gql`
|
95
|
+
fragment SubmittedStatusFragment on SubmittedStatus {
|
96
|
+
type: __typename
|
97
|
+
time
|
98
|
+
}
|
99
|
+
`;
|
100
|
+
var ReceiptFragmentDoc = gql`
|
95
101
|
fragment receiptFragment on Receipt {
|
96
102
|
id
|
97
103
|
pc
|
@@ -123,45 +129,65 @@ var ReceiptFragmentFragmentDoc = gql`
|
|
123
129
|
subId
|
124
130
|
}
|
125
131
|
`;
|
126
|
-
var
|
127
|
-
fragment
|
132
|
+
var SuccessStatusFragmentDoc = gql`
|
133
|
+
fragment SuccessStatusFragment on SuccessStatus {
|
134
|
+
type: __typename
|
135
|
+
block {
|
136
|
+
id
|
137
|
+
}
|
138
|
+
time
|
139
|
+
programState {
|
140
|
+
returnType
|
141
|
+
data
|
142
|
+
}
|
143
|
+
receipts {
|
144
|
+
...receiptFragment
|
145
|
+
}
|
146
|
+
totalGas
|
147
|
+
totalFee
|
148
|
+
}
|
149
|
+
${ReceiptFragmentDoc}`;
|
150
|
+
var FailureStatusFragmentDoc = gql`
|
151
|
+
fragment FailureStatusFragment on FailureStatus {
|
128
152
|
type: __typename
|
153
|
+
block {
|
154
|
+
id
|
155
|
+
}
|
156
|
+
totalGas
|
157
|
+
totalFee
|
158
|
+
time
|
159
|
+
reason
|
160
|
+
receipts {
|
161
|
+
...receiptFragment
|
162
|
+
}
|
163
|
+
}
|
164
|
+
${ReceiptFragmentDoc}`;
|
165
|
+
var SqueezedOutStatusFragmentDoc = gql`
|
166
|
+
fragment SqueezedOutStatusFragment on SqueezedOutStatus {
|
167
|
+
type: __typename
|
168
|
+
reason
|
169
|
+
}
|
170
|
+
`;
|
171
|
+
var TransactionStatusFragmentDoc = gql`
|
172
|
+
fragment transactionStatusFragment on TransactionStatus {
|
129
173
|
... on SubmittedStatus {
|
130
|
-
|
174
|
+
...SubmittedStatusFragment
|
131
175
|
}
|
132
176
|
... on SuccessStatus {
|
133
|
-
|
134
|
-
id
|
135
|
-
}
|
136
|
-
time
|
137
|
-
programState {
|
138
|
-
returnType
|
139
|
-
data
|
140
|
-
}
|
141
|
-
receipts {
|
142
|
-
...receiptFragment
|
143
|
-
}
|
144
|
-
totalGas
|
145
|
-
totalFee
|
177
|
+
...SuccessStatusFragment
|
146
178
|
}
|
147
179
|
... on FailureStatus {
|
148
|
-
|
149
|
-
id
|
150
|
-
}
|
151
|
-
totalGas
|
152
|
-
totalFee
|
153
|
-
time
|
154
|
-
reason
|
155
|
-
receipts {
|
156
|
-
...receiptFragment
|
157
|
-
}
|
180
|
+
...FailureStatusFragment
|
158
181
|
}
|
159
182
|
... on SqueezedOutStatus {
|
160
|
-
|
183
|
+
...SqueezedOutStatusFragment
|
161
184
|
}
|
162
185
|
}
|
163
|
-
${
|
164
|
-
|
186
|
+
${SubmittedStatusFragmentDoc}
|
187
|
+
${SuccessStatusFragmentDoc}
|
188
|
+
${FailureStatusFragmentDoc}
|
189
|
+
${SqueezedOutStatusFragmentDoc}`;
|
190
|
+
var TransactionFragmentDoc = gql`
|
165
191
|
fragment transactionFragment on Transaction {
|
166
192
|
id
|
167
193
|
rawPayload
|
@@ -169,8 +195,8 @@ var TransactionFragmentFragmentDoc = gql`
|
|
169
195
|
...transactionStatusFragment
|
170
196
|
}
|
171
197
|
}
|
172
|
-
${
|
173
|
-
var
|
198
|
+
${TransactionStatusFragmentDoc}`;
|
199
|
+
var InputEstimatePredicatesFragmentDoc = gql`
|
174
200
|
fragment inputEstimatePredicatesFragment on Input {
|
175
201
|
... on InputCoin {
|
176
202
|
predicateGasUsed
|
@@ -180,14 +206,14 @@ var InputEstimatePredicatesFragmentFragmentDoc = gql`
|
|
180
206
|
}
|
181
207
|
}
|
182
208
|
`;
|
183
|
-
var
|
209
|
+
var TransactionEstimatePredicatesFragmentDoc = gql`
|
184
210
|
fragment transactionEstimatePredicatesFragment on Transaction {
|
185
211
|
inputs {
|
186
212
|
...inputEstimatePredicatesFragment
|
187
213
|
}
|
188
214
|
}
|
189
|
-
${
|
190
|
-
var
|
215
|
+
${InputEstimatePredicatesFragmentDoc}`;
|
216
|
+
var DryRunFailureStatusFragmentDoc = gql`
|
191
217
|
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
192
218
|
totalGas
|
193
219
|
totalFee
|
@@ -198,7 +224,7 @@ var DryRunFailureStatusFragmentFragmentDoc = gql`
|
|
198
224
|
}
|
199
225
|
}
|
200
226
|
`;
|
201
|
-
var
|
227
|
+
var DryRunSuccessStatusFragmentDoc = gql`
|
202
228
|
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
203
229
|
totalGas
|
204
230
|
totalFee
|
@@ -208,7 +234,7 @@ var DryRunSuccessStatusFragmentFragmentDoc = gql`
|
|
208
234
|
}
|
209
235
|
}
|
210
236
|
`;
|
211
|
-
var
|
237
|
+
var DryRunTransactionStatusFragmentDoc = gql`
|
212
238
|
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
213
239
|
... on DryRunFailureStatus {
|
214
240
|
...dryRunFailureStatusFragment
|
@@ -217,9 +243,9 @@ var DryRunTransactionStatusFragmentFragmentDoc = gql`
|
|
217
243
|
...dryRunSuccessStatusFragment
|
218
244
|
}
|
219
245
|
}
|
220
|
-
${
|
221
|
-
${
|
222
|
-
var
|
246
|
+
${DryRunFailureStatusFragmentDoc}
|
247
|
+
${DryRunSuccessStatusFragmentDoc}`;
|
248
|
+
var DryRunTransactionExecutionStatusFragmentDoc = gql`
|
223
249
|
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
224
250
|
id
|
225
251
|
status {
|
@@ -229,11 +255,11 @@ var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
|
|
229
255
|
...receiptFragment
|
230
256
|
}
|
231
257
|
}
|
232
|
-
${
|
233
|
-
${
|
234
|
-
var
|
258
|
+
${DryRunTransactionStatusFragmentDoc}
|
259
|
+
${ReceiptFragmentDoc}`;
|
260
|
+
var CoinFragmentDoc = gql`
|
235
261
|
fragment coinFragment on Coin {
|
236
|
-
__typename
|
262
|
+
type: __typename
|
237
263
|
utxoId
|
238
264
|
owner
|
239
265
|
amount
|
@@ -242,9 +268,9 @@ var CoinFragmentFragmentDoc = gql`
|
|
242
268
|
txCreatedIdx
|
243
269
|
}
|
244
270
|
`;
|
245
|
-
var
|
271
|
+
var MessageCoinFragmentDoc = gql`
|
246
272
|
fragment messageCoinFragment on MessageCoin {
|
247
|
-
__typename
|
273
|
+
type: __typename
|
248
274
|
sender
|
249
275
|
recipient
|
250
276
|
nonce
|
@@ -253,7 +279,7 @@ var MessageCoinFragmentFragmentDoc = gql`
|
|
253
279
|
daHeight
|
254
280
|
}
|
255
281
|
`;
|
256
|
-
var
|
282
|
+
var MessageFragmentDoc = gql`
|
257
283
|
fragment messageFragment on Message {
|
258
284
|
amount
|
259
285
|
sender
|
@@ -263,7 +289,7 @@ var MessageFragmentFragmentDoc = gql`
|
|
263
289
|
daHeight
|
264
290
|
}
|
265
291
|
`;
|
266
|
-
var
|
292
|
+
var MessageProofFragmentDoc = gql`
|
267
293
|
fragment messageProofFragment on MessageProof {
|
268
294
|
messageProof {
|
269
295
|
proofSet
|
@@ -310,14 +336,14 @@ var MessageProofFragmentFragmentDoc = gql`
|
|
310
336
|
data
|
311
337
|
}
|
312
338
|
`;
|
313
|
-
var
|
339
|
+
var BalanceFragmentDoc = gql`
|
314
340
|
fragment balanceFragment on Balance {
|
315
341
|
owner
|
316
342
|
amount
|
317
343
|
assetId
|
318
344
|
}
|
319
345
|
`;
|
320
|
-
var
|
346
|
+
var BlockFragmentDoc = gql`
|
321
347
|
fragment blockFragment on Block {
|
322
348
|
id
|
323
349
|
height
|
@@ -329,7 +355,7 @@ var BlockFragmentFragmentDoc = gql`
|
|
329
355
|
}
|
330
356
|
}
|
331
357
|
`;
|
332
|
-
var
|
358
|
+
var TxParametersFragmentDoc = gql`
|
333
359
|
fragment TxParametersFragment on TxParameters {
|
334
360
|
version
|
335
361
|
maxInputs
|
@@ -340,7 +366,7 @@ var TxParametersFragmentFragmentDoc = gql`
|
|
340
366
|
maxBytecodeSubsections
|
341
367
|
}
|
342
368
|
`;
|
343
|
-
var
|
369
|
+
var PredicateParametersFragmentDoc = gql`
|
344
370
|
fragment PredicateParametersFragment on PredicateParameters {
|
345
371
|
version
|
346
372
|
maxPredicateLength
|
@@ -349,41 +375,42 @@ var PredicateParametersFragmentFragmentDoc = gql`
|
|
349
375
|
maxMessageDataLength
|
350
376
|
}
|
351
377
|
`;
|
352
|
-
var
|
378
|
+
var ScriptParametersFragmentDoc = gql`
|
353
379
|
fragment ScriptParametersFragment on ScriptParameters {
|
354
380
|
version
|
355
381
|
maxScriptLength
|
356
382
|
maxScriptDataLength
|
357
383
|
}
|
358
384
|
`;
|
359
|
-
var
|
385
|
+
var ContractParametersFragmentDoc = gql`
|
360
386
|
fragment ContractParametersFragment on ContractParameters {
|
361
387
|
version
|
362
388
|
contractMaxSize
|
363
389
|
maxStorageSlots
|
364
390
|
}
|
365
391
|
`;
|
366
|
-
var
|
392
|
+
var FeeParametersFragmentDoc = gql`
|
367
393
|
fragment FeeParametersFragment on FeeParameters {
|
368
394
|
version
|
369
395
|
gasPriceFactor
|
370
396
|
gasPerByte
|
371
397
|
}
|
372
398
|
`;
|
373
|
-
var
|
399
|
+
var DependentCostFragmentDoc = gql`
|
374
400
|
fragment DependentCostFragment on DependentCost {
|
375
|
-
__typename
|
376
401
|
... on LightOperation {
|
402
|
+
type: __typename
|
377
403
|
base
|
378
404
|
unitsPerGas
|
379
405
|
}
|
380
406
|
... on HeavyOperation {
|
407
|
+
type: __typename
|
381
408
|
base
|
382
409
|
gasPerUnit
|
383
410
|
}
|
384
411
|
}
|
385
412
|
`;
|
386
|
-
var
|
413
|
+
var GasCostsFragmentDoc = gql`
|
387
414
|
fragment GasCostsFragment on GasCosts {
|
388
415
|
version
|
389
416
|
add
|
@@ -539,8 +566,8 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
539
566
|
}
|
540
567
|
newStoragePerByte
|
541
568
|
}
|
542
|
-
${
|
543
|
-
var
|
569
|
+
${DependentCostFragmentDoc}`;
|
570
|
+
var ConsensusParametersFragmentDoc = gql`
|
544
571
|
fragment consensusParametersFragment on ConsensusParameters {
|
545
572
|
version
|
546
573
|
txParams {
|
@@ -564,13 +591,13 @@ var ConsensusParametersFragmentFragmentDoc = gql`
|
|
564
591
|
baseAssetId
|
565
592
|
chainId
|
566
593
|
}
|
567
|
-
${
|
568
|
-
${
|
569
|
-
${
|
570
|
-
${
|
571
|
-
${
|
572
|
-
${
|
573
|
-
var
|
594
|
+
${TxParametersFragmentDoc}
|
595
|
+
${PredicateParametersFragmentDoc}
|
596
|
+
${ScriptParametersFragmentDoc}
|
597
|
+
${ContractParametersFragmentDoc}
|
598
|
+
${FeeParametersFragmentDoc}
|
599
|
+
${GasCostsFragmentDoc}`;
|
600
|
+
var ChainInfoFragmentDoc = gql`
|
574
601
|
fragment chainInfoFragment on ChainInfo {
|
575
602
|
name
|
576
603
|
latestBlock {
|
@@ -581,16 +608,16 @@ var ChainInfoFragmentFragmentDoc = gql`
|
|
581
608
|
...consensusParametersFragment
|
582
609
|
}
|
583
610
|
}
|
584
|
-
${
|
585
|
-
${
|
586
|
-
var
|
611
|
+
${BlockFragmentDoc}
|
612
|
+
${ConsensusParametersFragmentDoc}`;
|
613
|
+
var ContractBalanceFragmentDoc = gql`
|
587
614
|
fragment contractBalanceFragment on ContractBalance {
|
588
615
|
contract
|
589
616
|
amount
|
590
617
|
assetId
|
591
618
|
}
|
592
619
|
`;
|
593
|
-
var
|
620
|
+
var PageInfoFragmentDoc = gql`
|
594
621
|
fragment pageInfoFragment on PageInfo {
|
595
622
|
hasPreviousPage
|
596
623
|
hasNextPage
|
@@ -598,7 +625,7 @@ var PageInfoFragmentFragmentDoc = gql`
|
|
598
625
|
endCursor
|
599
626
|
}
|
600
627
|
`;
|
601
|
-
var
|
628
|
+
var NodeInfoFragmentDoc = gql`
|
602
629
|
fragment nodeInfoFragment on NodeInfo {
|
603
630
|
utxoValidation
|
604
631
|
vmBacktrace
|
@@ -607,7 +634,7 @@ var NodeInfoFragmentFragmentDoc = gql`
|
|
607
634
|
nodeVersion
|
608
635
|
}
|
609
636
|
`;
|
610
|
-
var
|
637
|
+
var RelayedTransactionStatusFragmentDoc = gql`
|
611
638
|
fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
|
612
639
|
... on RelayedTransactionFailed {
|
613
640
|
blockHeight
|
@@ -628,28 +655,28 @@ var GetNodeInfoDocument = gql`
|
|
628
655
|
...nodeInfoFragment
|
629
656
|
}
|
630
657
|
}
|
631
|
-
${
|
658
|
+
${NodeInfoFragmentDoc}`;
|
632
659
|
var GetChainDocument = gql`
|
633
660
|
query getChain {
|
634
661
|
chain {
|
635
662
|
...chainInfoFragment
|
636
663
|
}
|
637
664
|
}
|
638
|
-
${
|
665
|
+
${ChainInfoFragmentDoc}`;
|
639
666
|
var GetTransactionDocument = gql`
|
640
667
|
query getTransaction($transactionId: TransactionId!) {
|
641
668
|
transaction(id: $transactionId) {
|
642
669
|
...transactionFragment
|
643
670
|
}
|
644
671
|
}
|
645
|
-
${
|
672
|
+
${TransactionFragmentDoc}`;
|
646
673
|
var GetTransactionWithReceiptsDocument = gql`
|
647
674
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
648
675
|
transaction(id: $transactionId) {
|
649
676
|
...transactionFragment
|
650
677
|
}
|
651
678
|
}
|
652
|
-
${
|
679
|
+
${TransactionFragmentDoc}`;
|
653
680
|
var GetTransactionsDocument = gql`
|
654
681
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
655
682
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -660,7 +687,7 @@ var GetTransactionsDocument = gql`
|
|
660
687
|
}
|
661
688
|
}
|
662
689
|
}
|
663
|
-
${
|
690
|
+
${TransactionFragmentDoc}`;
|
664
691
|
var GetTransactionsByOwnerDocument = gql`
|
665
692
|
query getTransactionsByOwner($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
666
693
|
transactionsByOwner(
|
@@ -680,22 +707,22 @@ var GetTransactionsByOwnerDocument = gql`
|
|
680
707
|
}
|
681
708
|
}
|
682
709
|
}
|
683
|
-
${
|
684
|
-
${
|
710
|
+
${PageInfoFragmentDoc}
|
711
|
+
${TransactionFragmentDoc}`;
|
685
712
|
var EstimatePredicatesDocument = gql`
|
686
713
|
query estimatePredicates($encodedTransaction: HexString!) {
|
687
714
|
estimatePredicates(tx: $encodedTransaction) {
|
688
715
|
...transactionEstimatePredicatesFragment
|
689
716
|
}
|
690
717
|
}
|
691
|
-
${
|
718
|
+
${TransactionEstimatePredicatesFragmentDoc}`;
|
692
719
|
var GetBlockDocument = gql`
|
693
720
|
query getBlock($blockId: BlockId, $height: U32) {
|
694
721
|
block(id: $blockId, height: $height) {
|
695
722
|
...blockFragment
|
696
723
|
}
|
697
724
|
}
|
698
|
-
${
|
725
|
+
${BlockFragmentDoc}`;
|
699
726
|
var GetBlockWithTransactionsDocument = gql`
|
700
727
|
query getBlockWithTransactions($blockId: BlockId, $blockHeight: U32) {
|
701
728
|
block(id: $blockId, height: $blockHeight) {
|
@@ -705,8 +732,8 @@ var GetBlockWithTransactionsDocument = gql`
|
|
705
732
|
}
|
706
733
|
}
|
707
734
|
}
|
708
|
-
${
|
709
|
-
${
|
735
|
+
${BlockFragmentDoc}
|
736
|
+
${TransactionFragmentDoc}`;
|
710
737
|
var GetBlocksDocument = gql`
|
711
738
|
query getBlocks($after: String, $before: String, $first: Int, $last: Int) {
|
712
739
|
blocks(after: $after, before: $before, first: $first, last: $last) {
|
@@ -717,14 +744,14 @@ var GetBlocksDocument = gql`
|
|
717
744
|
}
|
718
745
|
}
|
719
746
|
}
|
720
|
-
${
|
747
|
+
${BlockFragmentDoc}`;
|
721
748
|
var GetCoinDocument = gql`
|
722
749
|
query getCoin($coinId: UtxoId!) {
|
723
750
|
coin(utxoId: $coinId) {
|
724
751
|
...coinFragment
|
725
752
|
}
|
726
753
|
}
|
727
|
-
${
|
754
|
+
${CoinFragmentDoc}`;
|
728
755
|
var GetCoinsDocument = gql`
|
729
756
|
query getCoins($filter: CoinFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
730
757
|
coins(
|
@@ -741,7 +768,7 @@ var GetCoinsDocument = gql`
|
|
741
768
|
}
|
742
769
|
}
|
743
770
|
}
|
744
|
-
${
|
771
|
+
${CoinFragmentDoc}`;
|
745
772
|
var GetCoinsToSpendDocument = gql`
|
746
773
|
query getCoinsToSpend($owner: Address!, $queryPerAsset: [SpendQueryElementInput!]!, $excludedIds: ExcludeInput) {
|
747
774
|
coinsToSpend(
|
@@ -753,8 +780,8 @@ var GetCoinsToSpendDocument = gql`
|
|
753
780
|
...messageCoinFragment
|
754
781
|
}
|
755
782
|
}
|
756
|
-
${
|
757
|
-
${
|
783
|
+
${CoinFragmentDoc}
|
784
|
+
${MessageCoinFragmentDoc}`;
|
758
785
|
var GetContractDocument = gql`
|
759
786
|
query getContract($contractId: ContractId!) {
|
760
787
|
contract(id: $contractId) {
|
@@ -769,14 +796,14 @@ var GetContractBalanceDocument = gql`
|
|
769
796
|
...contractBalanceFragment
|
770
797
|
}
|
771
798
|
}
|
772
|
-
${
|
799
|
+
${ContractBalanceFragmentDoc}`;
|
773
800
|
var GetBalanceDocument = gql`
|
774
801
|
query getBalance($owner: Address!, $assetId: AssetId!) {
|
775
802
|
balance(owner: $owner, assetId: $assetId) {
|
776
803
|
...balanceFragment
|
777
804
|
}
|
778
805
|
}
|
779
|
-
${
|
806
|
+
${BalanceFragmentDoc}`;
|
780
807
|
var GetLatestGasPriceDocument = gql`
|
781
808
|
query getLatestGasPrice {
|
782
809
|
latestGasPrice {
|
@@ -807,7 +834,7 @@ var GetBalancesDocument = gql`
|
|
807
834
|
}
|
808
835
|
}
|
809
836
|
}
|
810
|
-
${
|
837
|
+
${BalanceFragmentDoc}`;
|
811
838
|
var GetMessagesDocument = gql`
|
812
839
|
query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
813
840
|
messages(
|
@@ -824,7 +851,7 @@ var GetMessagesDocument = gql`
|
|
824
851
|
}
|
825
852
|
}
|
826
853
|
}
|
827
|
-
${
|
854
|
+
${MessageFragmentDoc}`;
|
828
855
|
var GetMessageProofDocument = gql`
|
829
856
|
query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
|
830
857
|
messageProof(
|
@@ -836,7 +863,7 @@ var GetMessageProofDocument = gql`
|
|
836
863
|
...messageProofFragment
|
837
864
|
}
|
838
865
|
}
|
839
|
-
${
|
866
|
+
${MessageProofFragmentDoc}`;
|
840
867
|
var GetMessageStatusDocument = gql`
|
841
868
|
query getMessageStatus($nonce: Nonce!) {
|
842
869
|
messageStatus(nonce: $nonce) {
|
@@ -850,14 +877,14 @@ var GetRelayedTransactionStatusDocument = gql`
|
|
850
877
|
...relayedTransactionStatusFragment
|
851
878
|
}
|
852
879
|
}
|
853
|
-
${
|
880
|
+
${RelayedTransactionStatusFragmentDoc}`;
|
854
881
|
var DryRunDocument = gql`
|
855
882
|
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
856
883
|
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
857
884
|
...dryRunTransactionExecutionStatusFragment
|
858
885
|
}
|
859
886
|
}
|
860
|
-
${
|
887
|
+
${DryRunTransactionExecutionStatusFragmentDoc}`;
|
861
888
|
var SubmitDocument = gql`
|
862
889
|
mutation submit($encodedTransaction: HexString!) {
|
863
890
|
submit(tx: $encodedTransaction) {
|
@@ -879,21 +906,21 @@ var GetMessageByNonceDocument = gql`
|
|
879
906
|
...messageFragment
|
880
907
|
}
|
881
908
|
}
|
882
|
-
${
|
909
|
+
${MessageFragmentDoc}`;
|
883
910
|
var SubmitAndAwaitDocument = gql`
|
884
911
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
885
912
|
submitAndAwait(tx: $encodedTransaction) {
|
886
913
|
...transactionStatusSubscriptionFragment
|
887
914
|
}
|
888
915
|
}
|
889
|
-
${
|
916
|
+
${TransactionStatusSubscriptionFragmentDoc}`;
|
890
917
|
var StatusChangeDocument = gql`
|
891
918
|
subscription statusChange($transactionId: TransactionId!) {
|
892
919
|
statusChange(id: $transactionId) {
|
893
920
|
...transactionStatusSubscriptionFragment
|
894
921
|
}
|
895
922
|
}
|
896
|
-
${
|
923
|
+
${TransactionStatusSubscriptionFragmentDoc}`;
|
897
924
|
function getSdk(requester) {
|
898
925
|
return {
|
899
926
|
getVersion(variables, options) {
|
@@ -1264,11 +1291,11 @@ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
|
|
1264
1291
|
import { Address, addressify } from "@fuel-ts/address";
|
1265
1292
|
import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
|
1266
1293
|
import { randomBytes } from "@fuel-ts/crypto";
|
1267
|
-
import { bn as
|
1294
|
+
import { bn as bn8 } from "@fuel-ts/math";
|
1268
1295
|
import {
|
1269
1296
|
PolicyType,
|
1270
1297
|
TransactionCoder,
|
1271
|
-
InputType as
|
1298
|
+
InputType as InputType3,
|
1272
1299
|
OutputType as OutputType2,
|
1273
1300
|
TransactionType
|
1274
1301
|
} from "@fuel-ts/transactions";
|
@@ -1505,10 +1532,9 @@ var getGasUsedFromReceipts = (receipts) => {
|
|
1505
1532
|
function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
1506
1533
|
const base = bn5(gasDependentCost.base);
|
1507
1534
|
let dependentValue = bn5(0);
|
1508
|
-
if (
|
1535
|
+
if ("unitsPerGas" in gasDependentCost) {
|
1509
1536
|
dependentValue = bn5(byteSize).div(bn5(gasDependentCost.unitsPerGas));
|
1510
|
-
}
|
1511
|
-
if (gasDependentCost.__typename === "HeavyOperation") {
|
1537
|
+
} else {
|
1512
1538
|
dependentValue = bn5(byteSize).mul(bn5(gasDependentCost.gasPerUnit));
|
1513
1539
|
}
|
1514
1540
|
return base.add(dependentValue);
|
@@ -1718,6 +1744,36 @@ var NoWitnessAtIndexError = class extends Error {
|
|
1718
1744
|
name = "NoWitnessAtIndexError";
|
1719
1745
|
};
|
1720
1746
|
|
1747
|
+
// src/providers/transaction-request/helpers.ts
|
1748
|
+
import { bn as bn7 } from "@fuel-ts/math";
|
1749
|
+
import { InputType as InputType2 } from "@fuel-ts/transactions";
|
1750
|
+
var isRequestInputCoin = (input) => input.type === InputType2.Coin;
|
1751
|
+
var isRequestInputMessage = (input) => input.type === InputType2.Message;
|
1752
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
1753
|
+
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
1754
|
+
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
1755
|
+
return acc.add(input.amount);
|
1756
|
+
}
|
1757
|
+
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
1758
|
+
return acc.add(input.amount);
|
1759
|
+
}
|
1760
|
+
return acc;
|
1761
|
+
}, bn7(0));
|
1762
|
+
var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
1763
|
+
(acc, input) => {
|
1764
|
+
if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
|
1765
|
+
acc.utxos.push(input.id);
|
1766
|
+
} else if (isRequestInputMessage(input) && input.recipient === owner.toB256()) {
|
1767
|
+
acc.messages.push(input.nonce);
|
1768
|
+
}
|
1769
|
+
return acc;
|
1770
|
+
},
|
1771
|
+
{
|
1772
|
+
utxos: [],
|
1773
|
+
messages: []
|
1774
|
+
}
|
1775
|
+
);
|
1776
|
+
|
1721
1777
|
// src/providers/transaction-request/witness.ts
|
1722
1778
|
import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
|
1723
1779
|
var witnessify = (value) => {
|
@@ -1758,10 +1814,10 @@ var BaseTransactionRequest = class {
|
|
1758
1814
|
outputs,
|
1759
1815
|
witnesses
|
1760
1816
|
} = {}) {
|
1761
|
-
this.tip = tip ?
|
1817
|
+
this.tip = tip ? bn8(tip) : void 0;
|
1762
1818
|
this.maturity = maturity && maturity > 0 ? maturity : void 0;
|
1763
|
-
this.witnessLimit = isDefined(witnessLimit) ?
|
1764
|
-
this.maxFee =
|
1819
|
+
this.witnessLimit = isDefined(witnessLimit) ? bn8(witnessLimit) : void 0;
|
1820
|
+
this.maxFee = bn8(maxFee);
|
1765
1821
|
this.inputs = inputs ?? [];
|
1766
1822
|
this.outputs = outputs ?? [];
|
1767
1823
|
this.witnesses = witnesses ?? [];
|
@@ -1770,13 +1826,13 @@ var BaseTransactionRequest = class {
|
|
1770
1826
|
let policyTypes = 0;
|
1771
1827
|
const policies = [];
|
1772
1828
|
const { tip, witnessLimit, maturity } = req;
|
1773
|
-
if (
|
1829
|
+
if (bn8(tip).gt(0)) {
|
1774
1830
|
policyTypes += PolicyType.Tip;
|
1775
|
-
policies.push({ data:
|
1831
|
+
policies.push({ data: bn8(tip), type: PolicyType.Tip });
|
1776
1832
|
}
|
1777
|
-
if (isDefined(witnessLimit) &&
|
1833
|
+
if (isDefined(witnessLimit) && bn8(witnessLimit).gte(0)) {
|
1778
1834
|
policyTypes += PolicyType.WitnessLimit;
|
1779
|
-
policies.push({ data:
|
1835
|
+
policies.push({ data: bn8(witnessLimit), type: PolicyType.WitnessLimit });
|
1780
1836
|
}
|
1781
1837
|
if (maturity && maturity > 0) {
|
1782
1838
|
policyTypes += PolicyType.Maturity;
|
@@ -1907,7 +1963,7 @@ var BaseTransactionRequest = class {
|
|
1907
1963
|
*/
|
1908
1964
|
getCoinInputs() {
|
1909
1965
|
return this.inputs.filter(
|
1910
|
-
(input) => input.type ===
|
1966
|
+
(input) => input.type === InputType3.Coin
|
1911
1967
|
);
|
1912
1968
|
}
|
1913
1969
|
/**
|
@@ -1939,9 +1995,9 @@ var BaseTransactionRequest = class {
|
|
1939
1995
|
const ownerAddress = addressify(owner);
|
1940
1996
|
const found = this.inputs.find((input) => {
|
1941
1997
|
switch (input.type) {
|
1942
|
-
case
|
1998
|
+
case InputType3.Coin:
|
1943
1999
|
return hexlify7(input.owner) === ownerAddress.toB256();
|
1944
|
-
case
|
2000
|
+
case InputType3.Message:
|
1945
2001
|
return hexlify7(input.recipient) === ownerAddress.toB256();
|
1946
2002
|
default:
|
1947
2003
|
return false;
|
@@ -1956,7 +2012,7 @@ var BaseTransactionRequest = class {
|
|
1956
2012
|
* @param coin - Coin resource.
|
1957
2013
|
*/
|
1958
2014
|
addCoinInput(coin) {
|
1959
|
-
const { assetId, owner, amount } = coin;
|
2015
|
+
const { assetId, owner, amount, id, predicate } = coin;
|
1960
2016
|
let witnessIndex;
|
1961
2017
|
if (coin.predicate) {
|
1962
2018
|
witnessIndex = 0;
|
@@ -1967,13 +2023,14 @@ var BaseTransactionRequest = class {
|
|
1967
2023
|
}
|
1968
2024
|
}
|
1969
2025
|
const input = {
|
1970
|
-
|
1971
|
-
type:
|
2026
|
+
id,
|
2027
|
+
type: InputType3.Coin,
|
1972
2028
|
owner: owner.toB256(),
|
1973
2029
|
amount,
|
1974
2030
|
assetId,
|
1975
2031
|
txPointer: "0x00000000000000000000000000000000",
|
1976
|
-
witnessIndex
|
2032
|
+
witnessIndex,
|
2033
|
+
predicate
|
1977
2034
|
};
|
1978
2035
|
this.pushInput(input);
|
1979
2036
|
this.addChangeOutput(owner, assetId);
|
@@ -1985,7 +2042,7 @@ var BaseTransactionRequest = class {
|
|
1985
2042
|
* @param message - Message resource.
|
1986
2043
|
*/
|
1987
2044
|
addMessageInput(message) {
|
1988
|
-
const { recipient, sender, amount, assetId } = message;
|
2045
|
+
const { recipient, sender, amount, predicate, nonce, assetId } = message;
|
1989
2046
|
let witnessIndex;
|
1990
2047
|
if (message.predicate) {
|
1991
2048
|
witnessIndex = 0;
|
@@ -1996,12 +2053,13 @@ var BaseTransactionRequest = class {
|
|
1996
2053
|
}
|
1997
2054
|
}
|
1998
2055
|
const input = {
|
1999
|
-
|
2000
|
-
type:
|
2056
|
+
nonce,
|
2057
|
+
type: InputType3.Message,
|
2001
2058
|
sender: sender.toB256(),
|
2002
2059
|
recipient: recipient.toB256(),
|
2003
2060
|
amount,
|
2004
|
-
witnessIndex
|
2061
|
+
witnessIndex,
|
2062
|
+
predicate
|
2005
2063
|
};
|
2006
2064
|
this.pushInput(input);
|
2007
2065
|
this.addChangeOutput(recipient, assetId);
|
@@ -2148,7 +2206,7 @@ var BaseTransactionRequest = class {
|
|
2148
2206
|
const assetInput = findAssetInput(assetId);
|
2149
2207
|
let usedQuantity = quantity;
|
2150
2208
|
if (assetId === baseAssetId) {
|
2151
|
-
usedQuantity =
|
2209
|
+
usedQuantity = bn8("1000000000000000000");
|
2152
2210
|
}
|
2153
2211
|
if (assetInput && "assetId" in assetInput) {
|
2154
2212
|
assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
|
@@ -2160,13 +2218,13 @@ var BaseTransactionRequest = class {
|
|
2160
2218
|
amount: usedQuantity,
|
2161
2219
|
assetId,
|
2162
2220
|
owner: resourcesOwner || Address.fromRandom(),
|
2163
|
-
blockCreated:
|
2164
|
-
txCreatedIdx:
|
2221
|
+
blockCreated: bn8(1),
|
2222
|
+
txCreatedIdx: bn8(1)
|
2165
2223
|
}
|
2166
2224
|
]);
|
2167
2225
|
}
|
2168
2226
|
};
|
2169
|
-
updateAssetInput(baseAssetId,
|
2227
|
+
updateAssetInput(baseAssetId, bn8(1e11));
|
2170
2228
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2171
2229
|
}
|
2172
2230
|
/**
|
@@ -2177,7 +2235,7 @@ var BaseTransactionRequest = class {
|
|
2177
2235
|
*/
|
2178
2236
|
getCoinOutputsQuantities() {
|
2179
2237
|
const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
|
2180
|
-
amount:
|
2238
|
+
amount: bn8(amount),
|
2181
2239
|
assetId: assetId.toString()
|
2182
2240
|
}));
|
2183
2241
|
return coinsQuantities;
|
@@ -2191,50 +2249,52 @@ var BaseTransactionRequest = class {
|
|
2191
2249
|
toJSON() {
|
2192
2250
|
return normalizeJSON(this);
|
2193
2251
|
}
|
2252
|
+
removeWitness(index) {
|
2253
|
+
this.witnesses.splice(index, 1);
|
2254
|
+
this.adjustWitnessIndexes(index);
|
2255
|
+
}
|
2256
|
+
adjustWitnessIndexes(removedIndex) {
|
2257
|
+
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
2258
|
+
if (input.witnessIndex > removedIndex) {
|
2259
|
+
input.witnessIndex -= 1;
|
2260
|
+
}
|
2261
|
+
});
|
2262
|
+
}
|
2194
2263
|
updatePredicateGasUsed(inputs) {
|
2195
2264
|
this.inputs.forEach((i) => {
|
2196
2265
|
let correspondingInput;
|
2197
2266
|
switch (i.type) {
|
2198
|
-
case
|
2199
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2267
|
+
case InputType3.Coin:
|
2268
|
+
correspondingInput = inputs.find((x) => x.type === InputType3.Coin && x.owner === i.owner);
|
2200
2269
|
break;
|
2201
|
-
case
|
2270
|
+
case InputType3.Message:
|
2202
2271
|
correspondingInput = inputs.find(
|
2203
|
-
(x) => x.type ===
|
2272
|
+
(x) => x.type === InputType3.Message && x.sender === i.sender
|
2204
2273
|
);
|
2205
2274
|
break;
|
2206
2275
|
default:
|
2207
2276
|
return;
|
2208
2277
|
}
|
2209
|
-
if (correspondingInput && "predicateGasUsed" in correspondingInput &&
|
2278
|
+
if (correspondingInput && "predicateGasUsed" in correspondingInput && bn8(correspondingInput.predicateGasUsed).gt(0)) {
|
2210
2279
|
i.predicate = correspondingInput.predicate;
|
2211
2280
|
i.predicateData = correspondingInput.predicateData;
|
2212
2281
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
2213
2282
|
}
|
2214
2283
|
});
|
2215
2284
|
}
|
2216
|
-
shiftPredicateData() {
|
2217
|
-
this.inputs.forEach((input) => {
|
2218
|
-
if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
|
2219
|
-
input.predicateData = input.padPredicateData(
|
2220
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2221
|
-
);
|
2222
|
-
}
|
2223
|
-
});
|
2224
|
-
}
|
2225
2285
|
};
|
2226
2286
|
|
2227
2287
|
// src/providers/transaction-request/create-transaction-request.ts
|
2228
2288
|
import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
|
2229
|
-
import { bn as
|
2289
|
+
import { bn as bn10 } from "@fuel-ts/math";
|
2230
2290
|
import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
|
2231
2291
|
import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
2232
2292
|
|
2233
2293
|
// src/providers/transaction-request/hash-transaction.ts
|
2234
2294
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2235
2295
|
import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
|
2236
|
-
import { bn as
|
2237
|
-
import { TransactionType as TransactionType2, InputType as
|
2296
|
+
import { bn as bn9 } from "@fuel-ts/math";
|
2297
|
+
import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
|
2238
2298
|
import { concat as concat2 } from "@fuel-ts/utils";
|
2239
2299
|
import { clone as clone2 } from "ramda";
|
2240
2300
|
function hashTransaction(transactionRequest, chainId) {
|
@@ -2245,19 +2305,19 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2245
2305
|
transaction.inputs = transaction.inputs.map((input) => {
|
2246
2306
|
const inputClone = clone2(input);
|
2247
2307
|
switch (inputClone.type) {
|
2248
|
-
case
|
2308
|
+
case InputType4.Coin: {
|
2249
2309
|
inputClone.txPointer = {
|
2250
2310
|
blockHeight: 0,
|
2251
2311
|
txIndex: 0
|
2252
2312
|
};
|
2253
|
-
inputClone.predicateGasUsed =
|
2313
|
+
inputClone.predicateGasUsed = bn9(0);
|
2254
2314
|
return inputClone;
|
2255
2315
|
}
|
2256
|
-
case
|
2257
|
-
inputClone.predicateGasUsed =
|
2316
|
+
case InputType4.Message: {
|
2317
|
+
inputClone.predicateGasUsed = bn9(0);
|
2258
2318
|
return inputClone;
|
2259
2319
|
}
|
2260
|
-
case
|
2320
|
+
case InputType4.Contract: {
|
2261
2321
|
inputClone.txPointer = {
|
2262
2322
|
blockHeight: 0,
|
2263
2323
|
txIndex: 0
|
@@ -2281,12 +2341,12 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2281
2341
|
return outputClone;
|
2282
2342
|
}
|
2283
2343
|
case OutputType3.Change: {
|
2284
|
-
outputClone.amount =
|
2344
|
+
outputClone.amount = bn9(0);
|
2285
2345
|
return outputClone;
|
2286
2346
|
}
|
2287
2347
|
case OutputType3.Variable: {
|
2288
2348
|
outputClone.to = ZeroBytes325;
|
2289
|
-
outputClone.amount =
|
2349
|
+
outputClone.amount = bn9(0);
|
2290
2350
|
outputClone.assetId = ZeroBytes325;
|
2291
2351
|
return outputClone;
|
2292
2352
|
}
|
@@ -2364,7 +2424,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2364
2424
|
type: TransactionType3.Create,
|
2365
2425
|
...baseTransaction,
|
2366
2426
|
bytecodeWitnessIndex,
|
2367
|
-
storageSlotsCount:
|
2427
|
+
storageSlotsCount: bn10(storageSlots.length),
|
2368
2428
|
salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
|
2369
2429
|
storageSlots
|
2370
2430
|
};
|
@@ -2404,7 +2464,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2404
2464
|
}
|
2405
2465
|
metadataGas(gasCosts) {
|
2406
2466
|
return calculateMetadataGasForTxCreate({
|
2407
|
-
contractBytesSize:
|
2467
|
+
contractBytesSize: bn10(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2408
2468
|
gasCosts,
|
2409
2469
|
stateRootSize: this.storageSlots.length,
|
2410
2470
|
txBytesSize: this.byteSize()
|
@@ -2416,8 +2476,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2416
2476
|
import { Interface } from "@fuel-ts/abi-coder";
|
2417
2477
|
import { addressify as addressify2 } from "@fuel-ts/address";
|
2418
2478
|
import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
2419
|
-
import { bn as
|
2420
|
-
import { InputType as
|
2479
|
+
import { bn as bn11 } from "@fuel-ts/math";
|
2480
|
+
import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
2421
2481
|
import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
|
2422
2482
|
|
2423
2483
|
// src/providers/transaction-request/scripts.ts
|
@@ -2470,7 +2530,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2470
2530
|
*/
|
2471
2531
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2472
2532
|
super(rest);
|
2473
|
-
this.gasLimit =
|
2533
|
+
this.gasLimit = bn11(gasLimit);
|
2474
2534
|
this.script = arrayify8(script ?? returnZeroScript.bytes);
|
2475
2535
|
this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
|
2476
2536
|
this.abis = rest.abis;
|
@@ -2487,8 +2547,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2487
2547
|
type: TransactionType4.Script,
|
2488
2548
|
scriptGasLimit: this.gasLimit,
|
2489
2549
|
...super.getBaseTransaction(),
|
2490
|
-
scriptLength:
|
2491
|
-
scriptDataLength:
|
2550
|
+
scriptLength: bn11(script.length),
|
2551
|
+
scriptDataLength: bn11(scriptData.length),
|
2492
2552
|
receiptsRoot: ZeroBytes327,
|
2493
2553
|
script: hexlify10(script),
|
2494
2554
|
scriptData: hexlify10(scriptData)
|
@@ -2501,7 +2561,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2501
2561
|
*/
|
2502
2562
|
getContractInputs() {
|
2503
2563
|
return this.inputs.filter(
|
2504
|
-
(input) => input.type ===
|
2564
|
+
(input) => input.type === InputType5.Contract
|
2505
2565
|
);
|
2506
2566
|
}
|
2507
2567
|
/**
|
@@ -2581,7 +2641,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2581
2641
|
return this;
|
2582
2642
|
}
|
2583
2643
|
const inputIndex = super.pushInput({
|
2584
|
-
type:
|
2644
|
+
type: InputType5.Contract,
|
2585
2645
|
contractId: contractAddress.toB256(),
|
2586
2646
|
txPointer: "0x00000000000000000000000000000000"
|
2587
2647
|
});
|
@@ -2623,7 +2683,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2623
2683
|
|
2624
2684
|
// src/providers/transaction-request/utils.ts
|
2625
2685
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2626
|
-
import { TransactionType as TransactionType5
|
2686
|
+
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2627
2687
|
var transactionRequestify = (obj) => {
|
2628
2688
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2629
2689
|
return obj;
|
@@ -2641,21 +2701,6 @@ var transactionRequestify = (obj) => {
|
|
2641
2701
|
}
|
2642
2702
|
}
|
2643
2703
|
};
|
2644
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2645
|
-
(acc, input) => {
|
2646
|
-
if (input.type === InputType5.Coin && input.owner === owner.toB256()) {
|
2647
|
-
acc.utxos.push(input.id);
|
2648
|
-
}
|
2649
|
-
if (input.type === InputType5.Message && input.recipient === owner.toB256()) {
|
2650
|
-
acc.messages.push(input.nonce);
|
2651
|
-
}
|
2652
|
-
return acc;
|
2653
|
-
},
|
2654
|
-
{
|
2655
|
-
utxos: [],
|
2656
|
-
messages: []
|
2657
|
-
}
|
2658
|
-
);
|
2659
2704
|
|
2660
2705
|
// src/providers/transaction-response/transaction-response.ts
|
2661
2706
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
@@ -2669,7 +2714,7 @@ import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
|
2669
2714
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2670
2715
|
|
2671
2716
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
2672
|
-
import { bn as
|
2717
|
+
import { bn as bn12 } from "@fuel-ts/math";
|
2673
2718
|
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
|
2674
2719
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2675
2720
|
var calculateTXFeeForSummary = (params) => {
|
@@ -2683,19 +2728,19 @@ var calculateTXFeeForSummary = (params) => {
|
|
2683
2728
|
if (totalFee) {
|
2684
2729
|
return totalFee;
|
2685
2730
|
}
|
2686
|
-
const gasPerByte =
|
2687
|
-
const gasPriceFactor =
|
2731
|
+
const gasPerByte = bn12(feeParams.gasPerByte);
|
2732
|
+
const gasPriceFactor = bn12(feeParams.gasPriceFactor);
|
2688
2733
|
const transactionBytes = arrayify9(rawPayload);
|
2689
2734
|
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
2690
2735
|
const { type, witnesses, inputs, policies } = transaction;
|
2691
|
-
let metadataGas =
|
2692
|
-
let gasLimit =
|
2736
|
+
let metadataGas = bn12(0);
|
2737
|
+
let gasLimit = bn12(0);
|
2693
2738
|
if (type !== TransactionType6.Create && type !== TransactionType6.Script) {
|
2694
|
-
return
|
2739
|
+
return bn12(0);
|
2695
2740
|
}
|
2696
2741
|
if (type === TransactionType6.Create) {
|
2697
2742
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2698
|
-
const contractBytesSize =
|
2743
|
+
const contractBytesSize = bn12(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
|
2699
2744
|
metadataGas = calculateMetadataGasForTxCreate({
|
2700
2745
|
contractBytesSize,
|
2701
2746
|
gasCosts,
|
@@ -2714,7 +2759,7 @@ var calculateTXFeeForSummary = (params) => {
|
|
2714
2759
|
}
|
2715
2760
|
const minGas = getMinGas({
|
2716
2761
|
gasCosts,
|
2717
|
-
gasPerByte:
|
2762
|
+
gasPerByte: bn12(gasPerByte),
|
2718
2763
|
inputs,
|
2719
2764
|
metadataGas,
|
2720
2765
|
txBytesSize: transactionBytes.length
|
@@ -2745,39 +2790,28 @@ import { bn as bn13 } from "@fuel-ts/math";
|
|
2745
2790
|
import { ReceiptType as ReceiptType4, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
2746
2791
|
|
2747
2792
|
// src/providers/transaction-summary/call.ts
|
2748
|
-
import { Interface as Interface2
|
2749
|
-
|
2750
|
-
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2793
|
+
import { Interface as Interface2 } from "@fuel-ts/abi-coder";
|
2794
|
+
var getFunctionCall = ({ abi, receipt }) => {
|
2751
2795
|
const abiInterface = new Interface2(abi);
|
2752
2796
|
const callFunctionSelector = receipt.param1.toHex(8);
|
2753
2797
|
const functionFragment = abiInterface.getFunction(callFunctionSelector);
|
2754
2798
|
const inputs = functionFragment.jsonFn.inputs;
|
2755
|
-
|
2756
|
-
if (functionFragment.isInputDataPointer) {
|
2757
|
-
if (rawPayload) {
|
2758
|
-
const argsOffset = bn12(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2759
|
-
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2760
|
-
}
|
2761
|
-
} else {
|
2762
|
-
encodedArgs = receipt.param2.toHex();
|
2763
|
-
}
|
2799
|
+
const encodedArgs = receipt.param2.toHex();
|
2764
2800
|
let argumentsProvided;
|
2765
|
-
|
2766
|
-
|
2767
|
-
|
2768
|
-
|
2769
|
-
|
2770
|
-
|
2771
|
-
|
2772
|
-
|
2773
|
-
|
2774
|
-
|
2775
|
-
|
2776
|
-
|
2777
|
-
|
2778
|
-
|
2779
|
-
}, {});
|
2780
|
-
}
|
2801
|
+
const data = functionFragment.decodeArguments(encodedArgs);
|
2802
|
+
if (data) {
|
2803
|
+
argumentsProvided = inputs.reduce((prev, input, index) => {
|
2804
|
+
const value = data[index];
|
2805
|
+
const name = input.name;
|
2806
|
+
if (name) {
|
2807
|
+
return {
|
2808
|
+
...prev,
|
2809
|
+
// reparse to remove bn
|
2810
|
+
[name]: JSON.parse(JSON.stringify(value))
|
2811
|
+
};
|
2812
|
+
}
|
2813
|
+
return prev;
|
2814
|
+
}, {});
|
2781
2815
|
}
|
2782
2816
|
const call = {
|
2783
2817
|
functionSignature: functionFragment.signature,
|
@@ -3811,9 +3845,11 @@ var _Provider = class {
|
|
3811
3845
|
static ensureClientVersionIsSupported(nodeInfo) {
|
3812
3846
|
const { isMajorSupported, isMinorSupported, supportedVersion } = checkFuelCoreVersionCompatibility(nodeInfo.nodeVersion);
|
3813
3847
|
if (!isMajorSupported || !isMinorSupported) {
|
3814
|
-
|
3815
|
-
|
3816
|
-
|
3848
|
+
console.warn(
|
3849
|
+
`The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion},
|
3850
|
+
which is not supported by the version of the TS SDK that you are using.
|
3851
|
+
Things may not work as expected.
|
3852
|
+
Supported fuel-core version: ${supportedVersion}.`
|
3817
3853
|
);
|
3818
3854
|
}
|
3819
3855
|
}
|
@@ -4250,10 +4286,10 @@ var _Provider = class {
|
|
4250
4286
|
const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
|
4251
4287
|
const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
|
4252
4288
|
const baseAssetId = this.getBaseAssetId();
|
4289
|
+
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
4253
4290
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4254
4291
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4255
4292
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4256
|
-
txRequestClone.maxFee = bn17(0);
|
4257
4293
|
if (isScriptTransaction) {
|
4258
4294
|
txRequestClone.gasLimit = bn17(0);
|
4259
4295
|
}
|
@@ -4268,6 +4304,7 @@ var _Provider = class {
|
|
4268
4304
|
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
4269
4305
|
}
|
4270
4306
|
await this.estimatePredicates(signedRequest);
|
4307
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4271
4308
|
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
4272
4309
|
transactionRequest: signedRequest
|
4273
4310
|
});
|
@@ -4276,7 +4313,6 @@ var _Provider = class {
|
|
4276
4313
|
let missingContractIds = [];
|
4277
4314
|
let outputVariables = 0;
|
4278
4315
|
let gasUsed = bn17(0);
|
4279
|
-
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4280
4316
|
txRequestClone.maxFee = maxFee;
|
4281
4317
|
if (isScriptTransaction) {
|
4282
4318
|
txRequestClone.gasLimit = gasLimit;
|
@@ -4304,7 +4340,8 @@ var _Provider = class {
|
|
4304
4340
|
missingContractIds,
|
4305
4341
|
addedSignatures,
|
4306
4342
|
estimatedPredicates: txRequestClone.inputs,
|
4307
|
-
dryRunStatus
|
4343
|
+
dryRunStatus,
|
4344
|
+
updateMaxFee
|
4308
4345
|
};
|
4309
4346
|
}
|
4310
4347
|
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
@@ -4377,7 +4414,7 @@ var _Provider = class {
|
|
4377
4414
|
};
|
4378
4415
|
const result = await this.operations.getCoinsToSpend(coinsQuery);
|
4379
4416
|
const coins = result.coinsToSpend.flat().map((coin) => {
|
4380
|
-
switch (coin.
|
4417
|
+
switch (coin.type) {
|
4381
4418
|
case "MessageCoin":
|
4382
4419
|
return {
|
4383
4420
|
amount: bn17(coin.amount),
|
@@ -4769,8 +4806,33 @@ var CHAIN_IDS = {
|
|
4769
4806
|
}
|
4770
4807
|
};
|
4771
4808
|
|
4772
|
-
// src/providers/assets/
|
4773
|
-
var
|
4809
|
+
// src/providers/assets/utils/url.ts
|
4810
|
+
var DELIMITER_PATH = "/";
|
4811
|
+
var trimRegex = /^\/|\/$/g;
|
4812
|
+
var trimPath = (path2 = "") => path2.replace(trimRegex, "");
|
4813
|
+
function urlJoin(baseUrl, ...paths) {
|
4814
|
+
const hasBaseUrl = baseUrl !== null && baseUrl !== void 0;
|
4815
|
+
const rootPath = baseUrl?.[0] === "/" && baseUrl.length > 1;
|
4816
|
+
const allPaths = [baseUrl, ...paths].filter(Boolean).map(trimPath);
|
4817
|
+
if (rootPath && hasBaseUrl) {
|
4818
|
+
allPaths.unshift("");
|
4819
|
+
}
|
4820
|
+
return allPaths.join(DELIMITER_PATH);
|
4821
|
+
}
|
4822
|
+
|
4823
|
+
// src/providers/assets/utils/resolveIconPaths.ts
|
4824
|
+
function resolveIconPaths(assets2, basePath = "./") {
|
4825
|
+
return assets2.map((asset) => ({
|
4826
|
+
...asset,
|
4827
|
+
icon: urlJoin(basePath, asset.icon)
|
4828
|
+
}));
|
4829
|
+
}
|
4830
|
+
|
4831
|
+
// src/providers/assets/utils/fuelAssetsBaseUrl.ts
|
4832
|
+
var fuelAssetsBaseUrl = "https://cdn.fuel.network/assets/";
|
4833
|
+
|
4834
|
+
// src/providers/assets/assets.ts
|
4835
|
+
var rawAssets = [
|
4774
4836
|
{
|
4775
4837
|
name: "Ethereum",
|
4776
4838
|
symbol: "ETH",
|
@@ -4801,22 +4863,7 @@ var assets = [
|
|
4801
4863
|
]
|
4802
4864
|
}
|
4803
4865
|
];
|
4804
|
-
|
4805
|
-
// src/providers/transaction-request/helpers.ts
|
4806
|
-
import { bn as bn19 } from "@fuel-ts/math";
|
4807
|
-
import { InputType as InputType8 } from "@fuel-ts/transactions";
|
4808
|
-
var isRequestInputCoin = (input) => input.type === InputType8.Coin;
|
4809
|
-
var isRequestInputMessage = (input) => input.type === InputType8.Message;
|
4810
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
4811
|
-
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
4812
|
-
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
4813
|
-
return acc.add(input.amount);
|
4814
|
-
}
|
4815
|
-
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
4816
|
-
return acc.add(input.amount);
|
4817
|
-
}
|
4818
|
-
return acc;
|
4819
|
-
}, bn19(0));
|
4866
|
+
var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
4820
4867
|
|
4821
4868
|
// src/utils/formatTransferToContractScriptData.ts
|
4822
4869
|
import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
@@ -5010,20 +5057,20 @@ var Account = class extends AbstractAccount {
|
|
5010
5057
|
return balances;
|
5011
5058
|
}
|
5012
5059
|
/**
|
5013
|
-
*
|
5060
|
+
* Funds a transaction request by adding the necessary resources.
|
5014
5061
|
*
|
5015
|
-
* @
|
5016
|
-
* @param
|
5017
|
-
* @param
|
5018
|
-
* @returns
|
5062
|
+
* @typeParam T - The type of the TransactionRequest.
|
5063
|
+
* @param request - The transaction request to fund.
|
5064
|
+
* @param params - The estimated transaction parameters.
|
5065
|
+
* @returns The funded transaction request.
|
5019
5066
|
*/
|
5020
5067
|
async fund(request, params) {
|
5021
|
-
const { addedSignatures, estimatedPredicates,
|
5068
|
+
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
|
5069
|
+
const fee = request.maxFee;
|
5022
5070
|
const baseAssetId = this.provider.getBaseAssetId();
|
5023
|
-
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount ||
|
5024
|
-
const txRequest = request;
|
5071
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn19(0);
|
5025
5072
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5026
|
-
amount:
|
5073
|
+
amount: bn19(fee),
|
5027
5074
|
assetId: baseAssetId,
|
5028
5075
|
coinQuantities: requiredQuantities
|
5029
5076
|
});
|
@@ -5031,7 +5078,7 @@ var Account = class extends AbstractAccount {
|
|
5031
5078
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
5032
5079
|
quantitiesDict[assetId] = {
|
5033
5080
|
required: amount,
|
5034
|
-
owned:
|
5081
|
+
owned: bn19(0)
|
5035
5082
|
};
|
5036
5083
|
});
|
5037
5084
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
@@ -5055,17 +5102,19 @@ var Account = class extends AbstractAccount {
|
|
5055
5102
|
while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
|
5056
5103
|
const resources = await this.getResourcesToSpend(
|
5057
5104
|
missingQuantities,
|
5058
|
-
|
5105
|
+
cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
|
5059
5106
|
);
|
5060
5107
|
request.addResources(resources);
|
5061
|
-
|
5062
|
-
|
5063
|
-
const requestToReestimate2 = clone4(txRequest);
|
5108
|
+
request.updatePredicateGasUsed(estimatedPredicates);
|
5109
|
+
const requestToReestimate2 = clone4(request);
|
5064
5110
|
if (addedSignatures) {
|
5065
5111
|
Array.from({ length: addedSignatures }).forEach(
|
5066
5112
|
() => requestToReestimate2.addEmptyWitness()
|
5067
5113
|
);
|
5068
5114
|
}
|
5115
|
+
if (!updateMaxFee) {
|
5116
|
+
break;
|
5117
|
+
}
|
5069
5118
|
const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
|
5070
5119
|
transactionRequest: requestToReestimate2
|
5071
5120
|
});
|
@@ -5087,17 +5136,19 @@ var Account = class extends AbstractAccount {
|
|
5087
5136
|
}
|
5088
5137
|
fundingAttempts += 1;
|
5089
5138
|
}
|
5090
|
-
|
5091
|
-
|
5092
|
-
const requestToReestimate = clone4(txRequest);
|
5139
|
+
request.updatePredicateGasUsed(estimatedPredicates);
|
5140
|
+
const requestToReestimate = clone4(request);
|
5093
5141
|
if (addedSignatures) {
|
5094
5142
|
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
5095
5143
|
}
|
5144
|
+
if (!updateMaxFee) {
|
5145
|
+
return request;
|
5146
|
+
}
|
5096
5147
|
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
5097
5148
|
transactionRequest: requestToReestimate
|
5098
5149
|
});
|
5099
|
-
|
5100
|
-
return
|
5150
|
+
request.maxFee = maxFee;
|
5151
|
+
return request;
|
5101
5152
|
}
|
5102
5153
|
/**
|
5103
5154
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -5109,20 +5160,19 @@ var Account = class extends AbstractAccount {
|
|
5109
5160
|
* @returns A promise that resolves to the prepared transaction request.
|
5110
5161
|
*/
|
5111
5162
|
async createTransfer(destination, amount, assetId, txParams = {}) {
|
5112
|
-
|
5163
|
+
let request = new ScriptTransactionRequest(txParams);
|
5113
5164
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5114
5165
|
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
|
5115
5166
|
const txCost = await this.provider.getTransactionCost(request, {
|
5116
5167
|
estimateTxDependencies: true,
|
5117
5168
|
resourcesOwner: this
|
5118
5169
|
});
|
5119
|
-
this.validateGasLimitAndMaxFee({
|
5170
|
+
request = this.validateGasLimitAndMaxFee({
|
5171
|
+
transactionRequest: request,
|
5120
5172
|
gasUsed: txCost.gasUsed,
|
5121
5173
|
maxFee: txCost.maxFee,
|
5122
5174
|
txParams
|
5123
5175
|
});
|
5124
|
-
request.gasLimit = txCost.gasUsed;
|
5125
|
-
request.maxFee = txCost.maxFee;
|
5126
5176
|
await this.fund(request, txCost);
|
5127
5177
|
return request;
|
5128
5178
|
}
|
@@ -5136,7 +5186,7 @@ var Account = class extends AbstractAccount {
|
|
5136
5186
|
* @returns A promise that resolves to the transaction response.
|
5137
5187
|
*/
|
5138
5188
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5139
|
-
if (
|
5189
|
+
if (bn19(amount).lte(0)) {
|
5140
5190
|
throw new FuelError15(
|
5141
5191
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5142
5192
|
"Transfer amount must be a positive number."
|
@@ -5156,7 +5206,7 @@ var Account = class extends AbstractAccount {
|
|
5156
5206
|
* @returns A promise that resolves to the transaction response.
|
5157
5207
|
*/
|
5158
5208
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5159
|
-
if (
|
5209
|
+
if (bn19(amount).lte(0)) {
|
5160
5210
|
throw new FuelError15(
|
5161
5211
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5162
5212
|
"Transfer amount must be a positive number."
|
@@ -5166,10 +5216,10 @@ var Account = class extends AbstractAccount {
|
|
5166
5216
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5167
5217
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5168
5218
|
hexlifiedContractId: contractAddress.toB256(),
|
5169
|
-
amountToTransfer:
|
5219
|
+
amountToTransfer: bn19(amount),
|
5170
5220
|
assetId: assetIdToTransfer
|
5171
5221
|
});
|
5172
|
-
|
5222
|
+
let request = new ScriptTransactionRequest({
|
5173
5223
|
...txParams,
|
5174
5224
|
script,
|
5175
5225
|
scriptData
|
@@ -5177,15 +5227,14 @@ var Account = class extends AbstractAccount {
|
|
5177
5227
|
request.addContractInputAndOutput(contractAddress);
|
5178
5228
|
const txCost = await this.provider.getTransactionCost(request, {
|
5179
5229
|
resourcesOwner: this,
|
5180
|
-
quantitiesToContract: [{ amount:
|
5230
|
+
quantitiesToContract: [{ amount: bn19(amount), assetId: String(assetIdToTransfer) }]
|
5181
5231
|
});
|
5182
|
-
this.validateGasLimitAndMaxFee({
|
5232
|
+
request = this.validateGasLimitAndMaxFee({
|
5233
|
+
transactionRequest: request,
|
5183
5234
|
gasUsed: txCost.gasUsed,
|
5184
5235
|
maxFee: txCost.maxFee,
|
5185
5236
|
txParams
|
5186
5237
|
});
|
5187
|
-
request.gasLimit = txCost.gasUsed;
|
5188
|
-
request.maxFee = txCost.maxFee;
|
5189
5238
|
await this.fund(request, txCost);
|
5190
5239
|
return this.sendTransaction(request);
|
5191
5240
|
}
|
@@ -5203,7 +5252,7 @@ var Account = class extends AbstractAccount {
|
|
5203
5252
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5204
5253
|
);
|
5205
5254
|
const amountDataArray = arrayify14(
|
5206
|
-
"0x".concat(
|
5255
|
+
"0x".concat(bn19(amount).toHex().substring(2).padStart(16, "0"))
|
5207
5256
|
);
|
5208
5257
|
const script = new Uint8Array([
|
5209
5258
|
...arrayify14(withdrawScript.bytes),
|
@@ -5212,16 +5261,15 @@ var Account = class extends AbstractAccount {
|
|
5212
5261
|
]);
|
5213
5262
|
const params = { script, ...txParams };
|
5214
5263
|
const baseAssetId = this.provider.getBaseAssetId();
|
5215
|
-
|
5216
|
-
const quantitiesToContract = [{ amount:
|
5264
|
+
let request = new ScriptTransactionRequest(params);
|
5265
|
+
const quantitiesToContract = [{ amount: bn19(amount), assetId: baseAssetId }];
|
5217
5266
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5218
|
-
this.validateGasLimitAndMaxFee({
|
5267
|
+
request = this.validateGasLimitAndMaxFee({
|
5268
|
+
transactionRequest: request,
|
5219
5269
|
gasUsed: txCost.gasUsed,
|
5220
5270
|
maxFee: txCost.maxFee,
|
5221
5271
|
txParams
|
5222
5272
|
});
|
5223
|
-
request.maxFee = txCost.maxFee;
|
5224
|
-
request.gasLimit = txCost.gasUsed;
|
5225
5273
|
await this.fund(request, txCost);
|
5226
5274
|
return this.sendTransaction(request);
|
5227
5275
|
}
|
@@ -5281,22 +5329,29 @@ var Account = class extends AbstractAccount {
|
|
5281
5329
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5282
5330
|
}
|
5283
5331
|
validateGasLimitAndMaxFee({
|
5284
|
-
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
|
5285
5332
|
gasUsed,
|
5286
|
-
maxFee
|
5333
|
+
maxFee,
|
5334
|
+
transactionRequest,
|
5335
|
+
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
5287
5336
|
}) {
|
5288
|
-
|
5337
|
+
const request = transactionRequestify(transactionRequest);
|
5338
|
+
if (!isDefined2(setGasLimit)) {
|
5339
|
+
request.gasLimit = gasUsed;
|
5340
|
+
} else if (gasUsed.gt(setGasLimit)) {
|
5289
5341
|
throw new FuelError15(
|
5290
5342
|
ErrorCode15.GAS_LIMIT_TOO_LOW,
|
5291
5343
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5292
5344
|
);
|
5293
5345
|
}
|
5294
|
-
if (isDefined2(setMaxFee)
|
5346
|
+
if (!isDefined2(setMaxFee)) {
|
5347
|
+
request.maxFee = maxFee;
|
5348
|
+
} else if (maxFee.gt(setMaxFee)) {
|
5295
5349
|
throw new FuelError15(
|
5296
5350
|
ErrorCode15.MAX_FEE_TOO_LOW,
|
5297
5351
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
5298
5352
|
);
|
5299
5353
|
}
|
5354
|
+
return request;
|
5300
5355
|
}
|
5301
5356
|
};
|
5302
5357
|
|
@@ -5621,18 +5676,17 @@ var BaseWalletUnlocked = class extends Account {
|
|
5621
5676
|
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
5622
5677
|
|
5623
5678
|
// src/hdwallet/hdwallet.ts
|
5679
|
+
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
5624
5680
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5625
5681
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5626
|
-
import { bn as
|
5627
|
-
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5628
|
-
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5682
|
+
import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5683
|
+
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
5629
5684
|
|
5630
5685
|
// src/mnemonic/mnemonic.ts
|
5631
|
-
import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
|
5686
|
+
import { randomBytes as randomBytes4, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
5632
5687
|
import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
|
5633
5688
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
5634
|
-
import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
|
5635
|
-
import { dataSlice, pbkdf2, computeHmac, encodeBase58 } from "ethers";
|
5689
|
+
import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
5636
5690
|
|
5637
5691
|
// src/wordlists/words/english.ts
|
5638
5692
|
var english = [
|
@@ -7690,38 +7744,6 @@ var english = [
|
|
7690
7744
|
import { ErrorCode as ErrorCode17, FuelError as FuelError17 } from "@fuel-ts/errors";
|
7691
7745
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
7692
7746
|
import { arrayify as arrayify16 } from "@fuel-ts/utils";
|
7693
|
-
function toUtf8Bytes(stri) {
|
7694
|
-
const str = stri.normalize("NFKD");
|
7695
|
-
const result = [];
|
7696
|
-
for (let i = 0; i < str.length; i += 1) {
|
7697
|
-
const c = str.charCodeAt(i);
|
7698
|
-
if (c < 128) {
|
7699
|
-
result.push(c);
|
7700
|
-
} else if (c < 2048) {
|
7701
|
-
result.push(c >> 6 | 192);
|
7702
|
-
result.push(c & 63 | 128);
|
7703
|
-
} else if ((c & 64512) === 55296) {
|
7704
|
-
i += 1;
|
7705
|
-
const c2 = str.charCodeAt(i);
|
7706
|
-
if (i >= str.length || (c2 & 64512) !== 56320) {
|
7707
|
-
throw new FuelError17(
|
7708
|
-
ErrorCode17.INVALID_INPUT_PARAMETERS,
|
7709
|
-
"Invalid UTF-8 in the input string."
|
7710
|
-
);
|
7711
|
-
}
|
7712
|
-
const pair = 65536 + ((c & 1023) << 10) + (c2 & 1023);
|
7713
|
-
result.push(pair >> 18 | 240);
|
7714
|
-
result.push(pair >> 12 & 63 | 128);
|
7715
|
-
result.push(pair >> 6 & 63 | 128);
|
7716
|
-
result.push(pair & 63 | 128);
|
7717
|
-
} else {
|
7718
|
-
result.push(c >> 12 | 224);
|
7719
|
-
result.push(c >> 6 & 63 | 128);
|
7720
|
-
result.push(c & 63 | 128);
|
7721
|
-
}
|
7722
|
-
}
|
7723
|
-
return Uint8Array.from(result);
|
7724
|
-
}
|
7725
7747
|
function getLowerMask(bits) {
|
7726
7748
|
return (1 << bits) - 1;
|
7727
7749
|
}
|
@@ -8089,7 +8111,7 @@ var HDWallet = class {
|
|
8089
8111
|
const IR = bytes.slice(32);
|
8090
8112
|
if (privateKey) {
|
8091
8113
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8092
|
-
const ki =
|
8114
|
+
const ki = bn20(IL).add(privateKey).mod(N).toBytes(32);
|
8093
8115
|
return new HDWallet({
|
8094
8116
|
privateKey: ki,
|
8095
8117
|
chainCode: IR,
|
@@ -8155,7 +8177,7 @@ var HDWallet = class {
|
|
8155
8177
|
});
|
8156
8178
|
}
|
8157
8179
|
static fromExtendedKey(extendedKey) {
|
8158
|
-
const decoded =
|
8180
|
+
const decoded = hexlify17(toBytes2(decodeBase58(extendedKey)));
|
8159
8181
|
const bytes = arrayify18(decoded);
|
8160
8182
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8161
8183
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
@@ -8355,16 +8377,18 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
8355
8377
|
|
8356
8378
|
// src/test-utils/seedTestWallet.ts
|
8357
8379
|
import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
|
8358
|
-
var seedTestWallet = async (wallet, quantities) => {
|
8359
|
-
const
|
8360
|
-
|
8361
|
-
|
8362
|
-
);
|
8380
|
+
var seedTestWallet = async (wallet, quantities, utxosAmount = 1) => {
|
8381
|
+
const accountsToBeFunded = Array.isArray(wallet) ? wallet : [wallet];
|
8382
|
+
const [{ provider }] = accountsToBeFunded;
|
8383
|
+
const genesisWallet = new WalletUnlocked(process.env.GENESIS_SECRET || randomBytes5(32), provider);
|
8363
8384
|
const request = new ScriptTransactionRequest();
|
8364
|
-
quantities.forEach(
|
8365
|
-
|
8366
|
-
|
8367
|
-
|
8385
|
+
quantities.map(coinQuantityfy).forEach(
|
8386
|
+
({ amount, assetId }) => accountsToBeFunded.forEach(({ address }) => {
|
8387
|
+
for (let i = 0; i < utxosAmount; i++) {
|
8388
|
+
request.addCoinOutput(address, amount.div(utxosAmount), assetId);
|
8389
|
+
}
|
8390
|
+
})
|
8391
|
+
);
|
8368
8392
|
const txCost = await genesisWallet.provider.getTransactionCost(request);
|
8369
8393
|
request.gasLimit = txCost.gasUsed;
|
8370
8394
|
request.maxFee = txCost.maxFee;
|