@fuel-ts/account 0.0.0-rc-2143-20240424161332 → 0.0.0-rc-2021-20240424162616
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/README.md +1 -1
- package/dist/account.d.ts +6 -5
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +808 -553
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +769 -514
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +650 -396
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +10 -2
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +810 -359
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +4 -2
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +7 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +37 -27
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +2 -2
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +8 -29
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +3 -0
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +8 -2
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +2 -4
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +1527 -1056
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +751 -514
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +644 -407
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +16 -16
package/dist/test-utils.mjs
CHANGED
@@ -27,8 +27,9 @@ import { Address as Address3 } from "@fuel-ts/address";
|
|
27
27
|
import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
|
28
28
|
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
29
29
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
30
|
-
import { bn as
|
31
|
-
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
30
|
+
import { bn as bn18 } from "@fuel-ts/math";
|
31
|
+
import { arrayify as arrayify14, isDefined } from "@fuel-ts/utils";
|
32
|
+
import { clone as clone4 } from "ramda";
|
32
33
|
|
33
34
|
// src/providers/coin-quantity.ts
|
34
35
|
import { BaseAssetId } from "@fuel-ts/address/configs";
|
@@ -37,24 +38,24 @@ import { hexlify } from "@fuel-ts/utils";
|
|
37
38
|
var coinQuantityfy = (coinQuantityLike) => {
|
38
39
|
let assetId;
|
39
40
|
let amount;
|
40
|
-
let
|
41
|
+
let max;
|
41
42
|
if (Array.isArray(coinQuantityLike)) {
|
42
43
|
amount = coinQuantityLike[0];
|
43
44
|
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
44
|
-
|
45
|
+
max = coinQuantityLike[2] ?? void 0;
|
45
46
|
} else {
|
46
47
|
amount = coinQuantityLike.amount;
|
47
48
|
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
48
|
-
|
49
|
+
max = coinQuantityLike.max ?? void 0;
|
49
50
|
}
|
50
51
|
const bnAmount = bn(amount);
|
51
52
|
return {
|
52
53
|
assetId: hexlify(assetId),
|
53
54
|
amount: bnAmount.lt(1) ? bn(1) : bnAmount,
|
54
|
-
max:
|
55
|
+
max: max ? bn(max) : void 0
|
55
56
|
};
|
56
57
|
};
|
57
|
-
var
|
58
|
+
var addAmountToCoinQuantities = (params) => {
|
58
59
|
const { amount, assetId } = params;
|
59
60
|
const coinQuantities = [...params.coinQuantities];
|
60
61
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -69,9 +70,9 @@ var addAmountToAsset = (params) => {
|
|
69
70
|
// src/providers/provider.ts
|
70
71
|
import { Address as Address2 } from "@fuel-ts/address";
|
71
72
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
72
|
-
import { BN, bn as
|
73
|
+
import { BN, bn as bn16 } from "@fuel-ts/math";
|
73
74
|
import {
|
74
|
-
InputType as
|
75
|
+
InputType as InputType7,
|
75
76
|
TransactionType as TransactionType8,
|
76
77
|
InputMessageCoder,
|
77
78
|
TransactionCoder as TransactionCoder5
|
@@ -85,16 +86,20 @@ import { clone as clone3 } from "ramda";
|
|
85
86
|
|
86
87
|
// src/providers/__generated__/operations.ts
|
87
88
|
import gql from "graphql-tag";
|
89
|
+
var TransactionStatusSubscriptionFragmentFragmentDoc = gql`
|
90
|
+
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
91
|
+
type: __typename
|
92
|
+
... on SqueezedOutStatus {
|
93
|
+
reason
|
94
|
+
}
|
95
|
+
}
|
96
|
+
`;
|
88
97
|
var ReceiptFragmentFragmentDoc = gql`
|
89
98
|
fragment receiptFragment on Receipt {
|
90
|
-
|
91
|
-
id
|
92
|
-
}
|
99
|
+
id
|
93
100
|
pc
|
94
101
|
is
|
95
|
-
to
|
96
|
-
id
|
97
|
-
}
|
102
|
+
to
|
98
103
|
toAddress
|
99
104
|
amount
|
100
105
|
assetId
|
@@ -132,10 +137,16 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
132
137
|
id
|
133
138
|
}
|
134
139
|
time
|
140
|
+
receipts {
|
141
|
+
...receiptFragment
|
142
|
+
}
|
135
143
|
programState {
|
136
144
|
returnType
|
137
145
|
data
|
138
146
|
}
|
147
|
+
receipts {
|
148
|
+
...receiptFragment
|
149
|
+
}
|
139
150
|
}
|
140
151
|
... on FailureStatus {
|
141
152
|
block {
|
@@ -143,26 +154,24 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
143
154
|
}
|
144
155
|
time
|
145
156
|
reason
|
157
|
+
receipts {
|
158
|
+
...receiptFragment
|
159
|
+
}
|
146
160
|
}
|
147
161
|
... on SqueezedOutStatus {
|
148
162
|
reason
|
149
163
|
}
|
150
164
|
}
|
151
|
-
`;
|
165
|
+
${ReceiptFragmentFragmentDoc}`;
|
152
166
|
var TransactionFragmentFragmentDoc = gql`
|
153
167
|
fragment transactionFragment on Transaction {
|
154
168
|
id
|
155
169
|
rawPayload
|
156
|
-
gasPrice
|
157
|
-
receipts {
|
158
|
-
...receiptFragment
|
159
|
-
}
|
160
170
|
status {
|
161
171
|
...transactionStatusFragment
|
162
172
|
}
|
163
173
|
}
|
164
|
-
${
|
165
|
-
${TransactionStatusFragmentFragmentDoc}`;
|
174
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
166
175
|
var InputEstimatePredicatesFragmentFragmentDoc = gql`
|
167
176
|
fragment inputEstimatePredicatesFragment on Input {
|
168
177
|
... on InputCoin {
|
@@ -180,6 +189,46 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
|
|
180
189
|
}
|
181
190
|
}
|
182
191
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
192
|
+
var DryRunFailureStatusFragmentFragmentDoc = gql`
|
193
|
+
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
194
|
+
reason
|
195
|
+
programState {
|
196
|
+
returnType
|
197
|
+
data
|
198
|
+
}
|
199
|
+
}
|
200
|
+
`;
|
201
|
+
var DryRunSuccessStatusFragmentFragmentDoc = gql`
|
202
|
+
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
203
|
+
programState {
|
204
|
+
returnType
|
205
|
+
data
|
206
|
+
}
|
207
|
+
}
|
208
|
+
`;
|
209
|
+
var DryRunTransactionStatusFragmentFragmentDoc = gql`
|
210
|
+
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
211
|
+
... on DryRunFailureStatus {
|
212
|
+
...dryRunFailureStatusFragment
|
213
|
+
}
|
214
|
+
... on DryRunSuccessStatus {
|
215
|
+
...dryRunSuccessStatusFragment
|
216
|
+
}
|
217
|
+
}
|
218
|
+
${DryRunFailureStatusFragmentFragmentDoc}
|
219
|
+
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
220
|
+
var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
|
221
|
+
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
222
|
+
id
|
223
|
+
status {
|
224
|
+
...dryRunTransactionStatusFragment
|
225
|
+
}
|
226
|
+
receipts {
|
227
|
+
...receiptFragment
|
228
|
+
}
|
229
|
+
}
|
230
|
+
${DryRunTransactionStatusFragmentFragmentDoc}
|
231
|
+
${ReceiptFragmentFragmentDoc}`;
|
183
232
|
var CoinFragmentFragmentDoc = gql`
|
184
233
|
fragment coinFragment on Coin {
|
185
234
|
__typename
|
@@ -187,7 +236,6 @@ var CoinFragmentFragmentDoc = gql`
|
|
187
236
|
owner
|
188
237
|
amount
|
189
238
|
assetId
|
190
|
-
maturity
|
191
239
|
blockCreated
|
192
240
|
txCreatedIdx
|
193
241
|
}
|
@@ -226,26 +274,32 @@ var MessageProofFragmentFragmentDoc = gql`
|
|
226
274
|
messageBlockHeader {
|
227
275
|
id
|
228
276
|
daHeight
|
277
|
+
consensusParametersVersion
|
278
|
+
stateTransitionBytecodeVersion
|
229
279
|
transactionsCount
|
280
|
+
messageReceiptCount
|
230
281
|
transactionsRoot
|
282
|
+
messageOutboxRoot
|
283
|
+
eventInboxRoot
|
231
284
|
height
|
232
285
|
prevRoot
|
233
286
|
time
|
234
287
|
applicationHash
|
235
|
-
messageReceiptRoot
|
236
|
-
messageReceiptCount
|
237
288
|
}
|
238
289
|
commitBlockHeader {
|
239
290
|
id
|
240
291
|
daHeight
|
292
|
+
consensusParametersVersion
|
293
|
+
stateTransitionBytecodeVersion
|
241
294
|
transactionsCount
|
295
|
+
messageReceiptCount
|
242
296
|
transactionsRoot
|
297
|
+
messageOutboxRoot
|
298
|
+
eventInboxRoot
|
243
299
|
height
|
244
300
|
prevRoot
|
245
301
|
time
|
246
302
|
applicationHash
|
247
|
-
messageReceiptRoot
|
248
|
-
messageReceiptCount
|
249
303
|
}
|
250
304
|
sender
|
251
305
|
recipient
|
@@ -264,8 +318,8 @@ var BalanceFragmentFragmentDoc = gql`
|
|
264
318
|
var BlockFragmentFragmentDoc = gql`
|
265
319
|
fragment blockFragment on Block {
|
266
320
|
id
|
321
|
+
height
|
267
322
|
header {
|
268
|
-
height
|
269
323
|
time
|
270
324
|
}
|
271
325
|
transactions {
|
@@ -275,6 +329,7 @@ var BlockFragmentFragmentDoc = gql`
|
|
275
329
|
`;
|
276
330
|
var TxParametersFragmentFragmentDoc = gql`
|
277
331
|
fragment TxParametersFragment on TxParameters {
|
332
|
+
version
|
278
333
|
maxInputs
|
279
334
|
maxOutputs
|
280
335
|
maxWitnesses
|
@@ -284,6 +339,7 @@ var TxParametersFragmentFragmentDoc = gql`
|
|
284
339
|
`;
|
285
340
|
var PredicateParametersFragmentFragmentDoc = gql`
|
286
341
|
fragment PredicateParametersFragment on PredicateParameters {
|
342
|
+
version
|
287
343
|
maxPredicateLength
|
288
344
|
maxPredicateDataLength
|
289
345
|
maxGasPerPredicate
|
@@ -292,18 +348,21 @@ var PredicateParametersFragmentFragmentDoc = gql`
|
|
292
348
|
`;
|
293
349
|
var ScriptParametersFragmentFragmentDoc = gql`
|
294
350
|
fragment ScriptParametersFragment on ScriptParameters {
|
351
|
+
version
|
295
352
|
maxScriptLength
|
296
353
|
maxScriptDataLength
|
297
354
|
}
|
298
355
|
`;
|
299
356
|
var ContractParametersFragmentFragmentDoc = gql`
|
300
357
|
fragment ContractParametersFragment on ContractParameters {
|
358
|
+
version
|
301
359
|
contractMaxSize
|
302
360
|
maxStorageSlots
|
303
361
|
}
|
304
362
|
`;
|
305
363
|
var FeeParametersFragmentFragmentDoc = gql`
|
306
364
|
fragment FeeParametersFragment on FeeParameters {
|
365
|
+
version
|
307
366
|
gasPriceFactor
|
308
367
|
gasPerByte
|
309
368
|
}
|
@@ -323,6 +382,7 @@ var DependentCostFragmentFragmentDoc = gql`
|
|
323
382
|
`;
|
324
383
|
var GasCostsFragmentFragmentDoc = gql`
|
325
384
|
fragment GasCostsFragment on GasCosts {
|
385
|
+
version
|
326
386
|
add
|
327
387
|
addi
|
328
388
|
aloc
|
@@ -335,7 +395,6 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
335
395
|
cb
|
336
396
|
cfei
|
337
397
|
cfsi
|
338
|
-
croo
|
339
398
|
div
|
340
399
|
divi
|
341
400
|
ecr1
|
@@ -418,6 +477,9 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
418
477
|
ccp {
|
419
478
|
...DependentCostFragment
|
420
479
|
}
|
480
|
+
croo {
|
481
|
+
...DependentCostFragment
|
482
|
+
}
|
421
483
|
csiz {
|
422
484
|
...DependentCostFragment
|
423
485
|
}
|
@@ -477,6 +539,7 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
477
539
|
${DependentCostFragmentFragmentDoc}`;
|
478
540
|
var ConsensusParametersFragmentFragmentDoc = gql`
|
479
541
|
fragment consensusParametersFragment on ConsensusParameters {
|
542
|
+
version
|
480
543
|
txParams {
|
481
544
|
...TxParametersFragment
|
482
545
|
}
|
@@ -536,18 +599,9 @@ var NodeInfoFragmentFragmentDoc = gql`
|
|
536
599
|
fragment nodeInfoFragment on NodeInfo {
|
537
600
|
utxoValidation
|
538
601
|
vmBacktrace
|
539
|
-
minGasPrice
|
540
602
|
maxTx
|
541
603
|
maxDepth
|
542
604
|
nodeVersion
|
543
|
-
peers {
|
544
|
-
id
|
545
|
-
addresses
|
546
|
-
clientVersion
|
547
|
-
blockHeight
|
548
|
-
lastHeartbeatMs
|
549
|
-
appScore
|
550
|
-
}
|
551
605
|
}
|
552
606
|
`;
|
553
607
|
var GetVersionDocument = gql`
|
@@ -582,13 +636,9 @@ var GetTransactionWithReceiptsDocument = gql`
|
|
582
636
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
583
637
|
transaction(id: $transactionId) {
|
584
638
|
...transactionFragment
|
585
|
-
receipts {
|
586
|
-
...receiptFragment
|
587
|
-
}
|
588
639
|
}
|
589
640
|
}
|
590
|
-
${TransactionFragmentFragmentDoc}
|
591
|
-
${ReceiptFragmentFragmentDoc}`;
|
641
|
+
${TransactionFragmentFragmentDoc}`;
|
592
642
|
var GetTransactionsDocument = gql`
|
593
643
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
594
644
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -716,6 +766,20 @@ var GetBalanceDocument = gql`
|
|
716
766
|
}
|
717
767
|
}
|
718
768
|
${BalanceFragmentFragmentDoc}`;
|
769
|
+
var GetLatestGasPriceDocument = gql`
|
770
|
+
query getLatestGasPrice {
|
771
|
+
latestGasPrice {
|
772
|
+
gasPrice
|
773
|
+
}
|
774
|
+
}
|
775
|
+
`;
|
776
|
+
var EstimateGasPriceDocument = gql`
|
777
|
+
query estimateGasPrice($blockHorizon: U32!) {
|
778
|
+
estimateGasPrice(blockHorizon: $blockHorizon) {
|
779
|
+
gasPrice
|
780
|
+
}
|
781
|
+
}
|
782
|
+
`;
|
719
783
|
var GetBalancesDocument = gql`
|
720
784
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
721
785
|
balances(
|
@@ -770,12 +834,12 @@ var GetMessageStatusDocument = gql`
|
|
770
834
|
}
|
771
835
|
`;
|
772
836
|
var DryRunDocument = gql`
|
773
|
-
mutation dryRun($
|
774
|
-
dryRun(
|
775
|
-
...
|
837
|
+
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
838
|
+
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
839
|
+
...dryRunTransactionExecutionStatusFragment
|
776
840
|
}
|
777
841
|
}
|
778
|
-
${
|
842
|
+
${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
|
779
843
|
var SubmitDocument = gql`
|
780
844
|
mutation submit($encodedTransaction: HexString!) {
|
781
845
|
submit(tx: $encodedTransaction) {
|
@@ -794,17 +858,17 @@ var ProduceBlocksDocument = gql`
|
|
794
858
|
var SubmitAndAwaitDocument = gql`
|
795
859
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
796
860
|
submitAndAwait(tx: $encodedTransaction) {
|
797
|
-
...
|
861
|
+
...transactionStatusSubscriptionFragment
|
798
862
|
}
|
799
863
|
}
|
800
|
-
${
|
864
|
+
${TransactionStatusSubscriptionFragmentFragmentDoc}`;
|
801
865
|
var StatusChangeDocument = gql`
|
802
866
|
subscription statusChange($transactionId: TransactionId!) {
|
803
867
|
statusChange(id: $transactionId) {
|
804
|
-
...
|
868
|
+
...transactionStatusSubscriptionFragment
|
805
869
|
}
|
806
870
|
}
|
807
|
-
${
|
871
|
+
${TransactionStatusSubscriptionFragmentFragmentDoc}`;
|
808
872
|
function getSdk(requester) {
|
809
873
|
return {
|
810
874
|
getVersion(variables, options) {
|
@@ -858,6 +922,12 @@ function getSdk(requester) {
|
|
858
922
|
getBalance(variables, options) {
|
859
923
|
return requester(GetBalanceDocument, variables, options);
|
860
924
|
},
|
925
|
+
getLatestGasPrice(variables, options) {
|
926
|
+
return requester(GetLatestGasPriceDocument, variables, options);
|
927
|
+
},
|
928
|
+
estimateGasPrice(variables, options) {
|
929
|
+
return requester(EstimateGasPriceDocument, variables, options);
|
930
|
+
},
|
861
931
|
getBalances(variables, options) {
|
862
932
|
return requester(GetBalancesDocument, variables, options);
|
863
933
|
},
|
@@ -1051,10 +1121,9 @@ var inputify = (value) => {
|
|
1051
1121
|
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
1052
1122
|
},
|
1053
1123
|
witnessIndex: value.witnessIndex,
|
1054
|
-
maturity: value.maturity ?? 0,
|
1055
1124
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1056
|
-
predicateLength: predicate.length,
|
1057
|
-
predicateDataLength: predicateData.length,
|
1125
|
+
predicateLength: bn2(predicate.length),
|
1126
|
+
predicateDataLength: bn2(predicateData.length),
|
1058
1127
|
predicate: hexlify3(predicate),
|
1059
1128
|
predicateData: hexlify3(predicateData)
|
1060
1129
|
};
|
@@ -1085,8 +1154,8 @@ var inputify = (value) => {
|
|
1085
1154
|
nonce: hexlify3(value.nonce),
|
1086
1155
|
witnessIndex: value.witnessIndex,
|
1087
1156
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1088
|
-
predicateLength: predicate.length,
|
1089
|
-
predicateDataLength: predicateData.length,
|
1157
|
+
predicateLength: bn2(predicate.length),
|
1158
|
+
predicateDataLength: bn2(predicateData.length),
|
1090
1159
|
predicate: hexlify3(predicate),
|
1091
1160
|
predicateData: hexlify3(predicateData),
|
1092
1161
|
data: hexlify3(data),
|
@@ -1213,8 +1282,8 @@ function assembleReceiptByType(receipt) {
|
|
1213
1282
|
case "CALL" /* Call */: {
|
1214
1283
|
const callReceipt = {
|
1215
1284
|
type: ReceiptType.Call,
|
1216
|
-
from: hexOrZero(receipt.
|
1217
|
-
to: hexOrZero(receipt?.to
|
1285
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1286
|
+
to: hexOrZero(receipt?.to),
|
1218
1287
|
amount: bn4(receipt.amount),
|
1219
1288
|
assetId: hexOrZero(receipt.assetId),
|
1220
1289
|
gas: bn4(receipt.gas),
|
@@ -1228,7 +1297,7 @@ function assembleReceiptByType(receipt) {
|
|
1228
1297
|
case "RETURN" /* Return */: {
|
1229
1298
|
const returnReceipt = {
|
1230
1299
|
type: ReceiptType.Return,
|
1231
|
-
id: hexOrZero(receipt.
|
1300
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1232
1301
|
val: bn4(receipt.val),
|
1233
1302
|
pc: bn4(receipt.pc),
|
1234
1303
|
is: bn4(receipt.is)
|
@@ -1238,7 +1307,7 @@ function assembleReceiptByType(receipt) {
|
|
1238
1307
|
case "RETURN_DATA" /* ReturnData */: {
|
1239
1308
|
const returnDataReceipt = {
|
1240
1309
|
type: ReceiptType.ReturnData,
|
1241
|
-
id: hexOrZero(receipt.
|
1310
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1242
1311
|
ptr: bn4(receipt.ptr),
|
1243
1312
|
len: bn4(receipt.len),
|
1244
1313
|
digest: hexOrZero(receipt.digest),
|
@@ -1250,7 +1319,7 @@ function assembleReceiptByType(receipt) {
|
|
1250
1319
|
case "PANIC" /* Panic */: {
|
1251
1320
|
const panicReceipt = {
|
1252
1321
|
type: ReceiptType.Panic,
|
1253
|
-
id: hexOrZero(receipt.
|
1322
|
+
id: hexOrZero(receipt.id),
|
1254
1323
|
reason: bn4(receipt.reason),
|
1255
1324
|
pc: bn4(receipt.pc),
|
1256
1325
|
is: bn4(receipt.is),
|
@@ -1261,7 +1330,7 @@ function assembleReceiptByType(receipt) {
|
|
1261
1330
|
case "REVERT" /* Revert */: {
|
1262
1331
|
const revertReceipt = {
|
1263
1332
|
type: ReceiptType.Revert,
|
1264
|
-
id: hexOrZero(receipt.
|
1333
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1265
1334
|
val: bn4(receipt.ra),
|
1266
1335
|
pc: bn4(receipt.pc),
|
1267
1336
|
is: bn4(receipt.is)
|
@@ -1271,7 +1340,7 @@ function assembleReceiptByType(receipt) {
|
|
1271
1340
|
case "LOG" /* Log */: {
|
1272
1341
|
const logReceipt = {
|
1273
1342
|
type: ReceiptType.Log,
|
1274
|
-
id: hexOrZero(receipt.
|
1343
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1275
1344
|
val0: bn4(receipt.ra),
|
1276
1345
|
val1: bn4(receipt.rb),
|
1277
1346
|
val2: bn4(receipt.rc),
|
@@ -1284,7 +1353,7 @@ function assembleReceiptByType(receipt) {
|
|
1284
1353
|
case "LOG_DATA" /* LogData */: {
|
1285
1354
|
const logDataReceipt = {
|
1286
1355
|
type: ReceiptType.LogData,
|
1287
|
-
id: hexOrZero(receipt.
|
1356
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1288
1357
|
val0: bn4(receipt.ra),
|
1289
1358
|
val1: bn4(receipt.rb),
|
1290
1359
|
ptr: bn4(receipt.ptr),
|
@@ -1298,8 +1367,8 @@ function assembleReceiptByType(receipt) {
|
|
1298
1367
|
case "TRANSFER" /* Transfer */: {
|
1299
1368
|
const transferReceipt = {
|
1300
1369
|
type: ReceiptType.Transfer,
|
1301
|
-
from: hexOrZero(receipt.
|
1302
|
-
to: hexOrZero(receipt.toAddress || receipt?.to
|
1370
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1371
|
+
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1303
1372
|
amount: bn4(receipt.amount),
|
1304
1373
|
assetId: hexOrZero(receipt.assetId),
|
1305
1374
|
pc: bn4(receipt.pc),
|
@@ -1310,8 +1379,8 @@ function assembleReceiptByType(receipt) {
|
|
1310
1379
|
case "TRANSFER_OUT" /* TransferOut */: {
|
1311
1380
|
const transferOutReceipt = {
|
1312
1381
|
type: ReceiptType.TransferOut,
|
1313
|
-
from: hexOrZero(receipt.
|
1314
|
-
to: hexOrZero(receipt.toAddress || receipt.to
|
1382
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1383
|
+
to: hexOrZero(receipt.toAddress || receipt.to),
|
1315
1384
|
amount: bn4(receipt.amount),
|
1316
1385
|
assetId: hexOrZero(receipt.assetId),
|
1317
1386
|
pc: bn4(receipt.pc),
|
@@ -1354,7 +1423,7 @@ function assembleReceiptByType(receipt) {
|
|
1354
1423
|
return receiptMessageOut;
|
1355
1424
|
}
|
1356
1425
|
case "MINT" /* Mint */: {
|
1357
|
-
const contractId = hexOrZero(receipt.
|
1426
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1358
1427
|
const subId = hexOrZero(receipt.subId);
|
1359
1428
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
1360
1429
|
const mintReceipt = {
|
@@ -1369,7 +1438,7 @@ function assembleReceiptByType(receipt) {
|
|
1369
1438
|
return mintReceipt;
|
1370
1439
|
}
|
1371
1440
|
case "BURN" /* Burn */: {
|
1372
|
-
const contractId = hexOrZero(receipt.
|
1441
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1373
1442
|
const subId = hexOrZero(receipt.subId);
|
1374
1443
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
1375
1444
|
const burnReceipt = {
|
@@ -1395,7 +1464,6 @@ import { ErrorCode as ErrorCode6, FuelError as FuelError6 } from "@fuel-ts/error
|
|
1395
1464
|
import { bn as bn5 } from "@fuel-ts/math";
|
1396
1465
|
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
1397
1466
|
import { arrayify as arrayify3 } from "@fuel-ts/utils";
|
1398
|
-
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1399
1467
|
var getGasUsedFromReceipts = (receipts) => {
|
1400
1468
|
const scriptResult = receipts.filter(
|
1401
1469
|
(receipt) => receipt.type === ReceiptType2.ScriptResult
|
@@ -1416,18 +1484,28 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
1416
1484
|
}
|
1417
1485
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
1418
1486
|
const witnessCache = [];
|
1419
|
-
const
|
1487
|
+
const chargeableInputs = inputs.filter((input) => {
|
1488
|
+
const isCoinOrMessage = "owner" in input || "sender" in input;
|
1489
|
+
if (isCoinOrMessage) {
|
1490
|
+
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1491
|
+
return true;
|
1492
|
+
}
|
1493
|
+
if (!witnessCache.includes(input.witnessIndex)) {
|
1494
|
+
witnessCache.push(input.witnessIndex);
|
1495
|
+
return true;
|
1496
|
+
}
|
1497
|
+
}
|
1498
|
+
return false;
|
1499
|
+
});
|
1500
|
+
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
1501
|
+
const totalGas = chargeableInputs.reduce((total, input) => {
|
1420
1502
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1421
1503
|
return total.add(
|
1422
|
-
|
1504
|
+
vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
|
1423
1505
|
);
|
1424
1506
|
}
|
1425
|
-
|
1426
|
-
|
1427
|
-
return total.add(gasCosts.ecr1);
|
1428
|
-
}
|
1429
|
-
return total;
|
1430
|
-
}, bn5());
|
1507
|
+
return total.add(gasCosts.ecr1);
|
1508
|
+
}, bn5(0));
|
1431
1509
|
return totalGas;
|
1432
1510
|
}
|
1433
1511
|
function getMinGas(params) {
|
@@ -1439,12 +1517,20 @@ function getMinGas(params) {
|
|
1439
1517
|
return minGas;
|
1440
1518
|
}
|
1441
1519
|
function getMaxGas(params) {
|
1442
|
-
const {
|
1520
|
+
const {
|
1521
|
+
gasPerByte,
|
1522
|
+
witnessesLength,
|
1523
|
+
witnessLimit,
|
1524
|
+
minGas,
|
1525
|
+
gasLimit = bn5(0),
|
1526
|
+
maxGasPerTx
|
1527
|
+
} = params;
|
1443
1528
|
let remainingAllowedWitnessGas = bn5(0);
|
1444
1529
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
1445
1530
|
remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
1446
1531
|
}
|
1447
|
-
|
1532
|
+
const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
1533
|
+
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
1448
1534
|
}
|
1449
1535
|
function calculateMetadataGasForTxCreate({
|
1450
1536
|
gasCosts,
|
@@ -1466,6 +1552,10 @@ function calculateMetadataGasForTxScript({
|
|
1466
1552
|
}) {
|
1467
1553
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1468
1554
|
}
|
1555
|
+
var calculateGasFee = (params) => {
|
1556
|
+
const { gas, gasPrice, priceFactor, tip } = params;
|
1557
|
+
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1558
|
+
};
|
1469
1559
|
|
1470
1560
|
// src/providers/utils/json.ts
|
1471
1561
|
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
@@ -1610,7 +1700,7 @@ var witnessify = (value) => {
|
|
1610
1700
|
// src/providers/transaction-request/transaction-request.ts
|
1611
1701
|
var BaseTransactionRequest = class {
|
1612
1702
|
/** Gas price for transaction */
|
1613
|
-
|
1703
|
+
tip;
|
1614
1704
|
/** Block until which tx cannot be included */
|
1615
1705
|
maturity;
|
1616
1706
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -1629,7 +1719,7 @@ var BaseTransactionRequest = class {
|
|
1629
1719
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
1630
1720
|
*/
|
1631
1721
|
constructor({
|
1632
|
-
|
1722
|
+
tip,
|
1633
1723
|
maturity,
|
1634
1724
|
maxFee,
|
1635
1725
|
witnessLimit,
|
@@ -1637,7 +1727,7 @@ var BaseTransactionRequest = class {
|
|
1637
1727
|
outputs,
|
1638
1728
|
witnesses
|
1639
1729
|
} = {}) {
|
1640
|
-
this.
|
1730
|
+
this.tip = bn7(tip);
|
1641
1731
|
this.maturity = maturity ?? 0;
|
1642
1732
|
this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
|
1643
1733
|
this.maxFee = maxFee ? bn7(maxFee) : void 0;
|
@@ -1648,9 +1738,9 @@ var BaseTransactionRequest = class {
|
|
1648
1738
|
static getPolicyMeta(req) {
|
1649
1739
|
let policyTypes = 0;
|
1650
1740
|
const policies = [];
|
1651
|
-
if (req.
|
1652
|
-
policyTypes += PolicyType.
|
1653
|
-
policies.push({ data: req.
|
1741
|
+
if (req.tip) {
|
1742
|
+
policyTypes += PolicyType.Tip;
|
1743
|
+
policies.push({ data: req.tip, type: PolicyType.Tip });
|
1654
1744
|
}
|
1655
1745
|
if (req.witnessLimit) {
|
1656
1746
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -1834,13 +1924,11 @@ var BaseTransactionRequest = class {
|
|
1834
1924
|
* assetId, if one it was not added yet.
|
1835
1925
|
*
|
1836
1926
|
* @param coin - Coin resource.
|
1837
|
-
* @param predicate - Predicate bytes.
|
1838
|
-
* @param predicateData - Predicate data bytes.
|
1839
1927
|
*/
|
1840
|
-
addCoinInput(coin
|
1928
|
+
addCoinInput(coin) {
|
1841
1929
|
const { assetId, owner, amount } = coin;
|
1842
1930
|
let witnessIndex;
|
1843
|
-
if (predicate) {
|
1931
|
+
if (coin.predicate) {
|
1844
1932
|
witnessIndex = 0;
|
1845
1933
|
} else {
|
1846
1934
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -1855,8 +1943,7 @@ var BaseTransactionRequest = class {
|
|
1855
1943
|
amount,
|
1856
1944
|
assetId,
|
1857
1945
|
txPointer: "0x00000000000000000000000000000000",
|
1858
|
-
witnessIndex
|
1859
|
-
predicate: predicate?.bytes
|
1946
|
+
witnessIndex
|
1860
1947
|
};
|
1861
1948
|
this.pushInput(input);
|
1862
1949
|
this.addChangeOutput(owner, assetId);
|
@@ -1866,14 +1953,12 @@ var BaseTransactionRequest = class {
|
|
1866
1953
|
* baseAssetId, if one it was not added yet.
|
1867
1954
|
*
|
1868
1955
|
* @param message - Message resource.
|
1869
|
-
* @param predicate - Predicate bytes.
|
1870
|
-
* @param predicateData - Predicate data bytes.
|
1871
1956
|
*/
|
1872
|
-
addMessageInput(message
|
1957
|
+
addMessageInput(message) {
|
1873
1958
|
const { recipient, sender, amount } = message;
|
1874
1959
|
const assetId = BaseAssetId2;
|
1875
1960
|
let witnessIndex;
|
1876
|
-
if (predicate) {
|
1961
|
+
if (message.predicate) {
|
1877
1962
|
witnessIndex = 0;
|
1878
1963
|
} else {
|
1879
1964
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -1887,8 +1972,7 @@ var BaseTransactionRequest = class {
|
|
1887
1972
|
sender: sender.toB256(),
|
1888
1973
|
recipient: recipient.toB256(),
|
1889
1974
|
amount,
|
1890
|
-
witnessIndex
|
1891
|
-
predicate: predicate?.bytes
|
1975
|
+
witnessIndex
|
1892
1976
|
};
|
1893
1977
|
this.pushInput(input);
|
1894
1978
|
this.addChangeOutput(recipient, assetId);
|
@@ -1919,32 +2003,6 @@ var BaseTransactionRequest = class {
|
|
1919
2003
|
resources.forEach((resource) => this.addResource(resource));
|
1920
2004
|
return this;
|
1921
2005
|
}
|
1922
|
-
/**
|
1923
|
-
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
1924
|
-
* outputs from the related assetIds.
|
1925
|
-
*
|
1926
|
-
* @param resources - The resources to add.
|
1927
|
-
* @returns This transaction.
|
1928
|
-
*/
|
1929
|
-
addPredicateResource(resource, predicate) {
|
1930
|
-
if (isCoin(resource)) {
|
1931
|
-
this.addCoinInput(resource, predicate);
|
1932
|
-
} else {
|
1933
|
-
this.addMessageInput(resource, predicate);
|
1934
|
-
}
|
1935
|
-
return this;
|
1936
|
-
}
|
1937
|
-
/**
|
1938
|
-
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
1939
|
-
* from the related assetIds.
|
1940
|
-
*
|
1941
|
-
* @param resources - The resources to add.
|
1942
|
-
* @returns This transaction.
|
1943
|
-
*/
|
1944
|
-
addPredicateResources(resources, predicate) {
|
1945
|
-
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
1946
|
-
return this;
|
1947
|
-
}
|
1948
2006
|
/**
|
1949
2007
|
* Adds a coin output to the transaction.
|
1950
2008
|
*
|
@@ -2024,7 +2082,7 @@ var BaseTransactionRequest = class {
|
|
2024
2082
|
}
|
2025
2083
|
calculateMaxGas(chainInfo, minGas) {
|
2026
2084
|
const { consensusParameters } = chainInfo;
|
2027
|
-
const { gasPerByte } = consensusParameters;
|
2085
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2028
2086
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2029
2087
|
(acc, wit) => acc + wit.dataLength,
|
2030
2088
|
0
|
@@ -2033,7 +2091,8 @@ var BaseTransactionRequest = class {
|
|
2033
2091
|
gasPerByte,
|
2034
2092
|
minGas,
|
2035
2093
|
witnessesLength,
|
2036
|
-
witnessLimit: this.witnessLimit
|
2094
|
+
witnessLimit: this.witnessLimit,
|
2095
|
+
maxGasPerTx
|
2037
2096
|
});
|
2038
2097
|
}
|
2039
2098
|
/**
|
@@ -2051,17 +2110,20 @@ var BaseTransactionRequest = class {
|
|
2051
2110
|
});
|
2052
2111
|
const updateAssetInput = (assetId, quantity) => {
|
2053
2112
|
const assetInput = findAssetInput(assetId);
|
2113
|
+
let usedQuantity = quantity;
|
2114
|
+
if (assetId === BaseAssetId2) {
|
2115
|
+
usedQuantity = bn7("1000000000000000000");
|
2116
|
+
}
|
2054
2117
|
if (assetInput && "assetId" in assetInput) {
|
2055
2118
|
assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
|
2056
|
-
assetInput.amount =
|
2119
|
+
assetInput.amount = usedQuantity;
|
2057
2120
|
} else {
|
2058
2121
|
this.addResources([
|
2059
2122
|
{
|
2060
2123
|
id: hexlify7(randomBytes(UTXO_ID_LEN2)),
|
2061
|
-
amount:
|
2124
|
+
amount: usedQuantity,
|
2062
2125
|
assetId,
|
2063
2126
|
owner: resourcesOwner || Address.fromRandom(),
|
2064
|
-
maturity: 0,
|
2065
2127
|
blockCreated: bn7(1),
|
2066
2128
|
txCreatedIdx: bn7(1)
|
2067
2129
|
}
|
@@ -2093,7 +2155,7 @@ var BaseTransactionRequest = class {
|
|
2093
2155
|
toJSON() {
|
2094
2156
|
return normalizeJSON(this);
|
2095
2157
|
}
|
2096
|
-
|
2158
|
+
updatePredicateGasUsed(inputs) {
|
2097
2159
|
this.inputs.forEach((i) => {
|
2098
2160
|
let correspondingInput;
|
2099
2161
|
switch (i.type) {
|
@@ -2115,6 +2177,15 @@ var BaseTransactionRequest = class {
|
|
2115
2177
|
}
|
2116
2178
|
});
|
2117
2179
|
}
|
2180
|
+
shiftPredicateData() {
|
2181
|
+
this.inputs.forEach((input) => {
|
2182
|
+
if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
|
2183
|
+
input.predicateData = input.padPredicateData(
|
2184
|
+
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2185
|
+
);
|
2186
|
+
}
|
2187
|
+
});
|
2188
|
+
}
|
2118
2189
|
};
|
2119
2190
|
|
2120
2191
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2261,9 +2332,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2261
2332
|
return {
|
2262
2333
|
type: TransactionType3.Create,
|
2263
2334
|
...baseTransaction,
|
2264
|
-
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2265
2335
|
bytecodeWitnessIndex,
|
2266
|
-
storageSlotsCount: storageSlots.length,
|
2336
|
+
storageSlotsCount: bn9(storageSlots.length),
|
2267
2337
|
salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
|
2268
2338
|
storageSlots
|
2269
2339
|
};
|
@@ -2386,8 +2456,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2386
2456
|
type: TransactionType4.Script,
|
2387
2457
|
scriptGasLimit: this.gasLimit,
|
2388
2458
|
...super.getBaseTransaction(),
|
2389
|
-
scriptLength: script.length,
|
2390
|
-
scriptDataLength: scriptData.length,
|
2459
|
+
scriptLength: bn10(script.length),
|
2460
|
+
scriptDataLength: bn10(scriptData.length),
|
2391
2461
|
receiptsRoot: ZeroBytes327,
|
2392
2462
|
script: hexlify10(script),
|
2393
2463
|
scriptData: hexlify10(scriptData)
|
@@ -2451,7 +2521,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2451
2521
|
}
|
2452
2522
|
calculateMaxGas(chainInfo, minGas) {
|
2453
2523
|
const { consensusParameters } = chainInfo;
|
2454
|
-
const { gasPerByte } = consensusParameters;
|
2524
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2455
2525
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2456
2526
|
(acc, wit) => acc + wit.dataLength,
|
2457
2527
|
0
|
@@ -2461,7 +2531,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2461
2531
|
minGas,
|
2462
2532
|
witnessesLength,
|
2463
2533
|
witnessLimit: this.witnessLimit,
|
2464
|
-
gasLimit: this.gasLimit
|
2534
|
+
gasLimit: this.gasLimit,
|
2535
|
+
maxGasPerTx
|
2465
2536
|
});
|
2466
2537
|
}
|
2467
2538
|
/**
|
@@ -2518,7 +2589,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2518
2589
|
|
2519
2590
|
// src/providers/transaction-request/utils.ts
|
2520
2591
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2521
|
-
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2592
|
+
import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
|
2522
2593
|
var transactionRequestify = (obj) => {
|
2523
2594
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2524
2595
|
return obj;
|
@@ -2536,14 +2607,31 @@ var transactionRequestify = (obj) => {
|
|
2536
2607
|
}
|
2537
2608
|
}
|
2538
2609
|
};
|
2610
|
+
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2611
|
+
(acc, input) => {
|
2612
|
+
if (input.type === InputType5.Coin && input.owner === owner) {
|
2613
|
+
acc.utxos.push(input.id);
|
2614
|
+
}
|
2615
|
+
if (input.type === InputType5.Message && input.recipient === owner) {
|
2616
|
+
acc.messages.push(input.nonce);
|
2617
|
+
}
|
2618
|
+
return acc;
|
2619
|
+
},
|
2620
|
+
{
|
2621
|
+
utxos: [],
|
2622
|
+
messages: []
|
2623
|
+
}
|
2624
|
+
);
|
2539
2625
|
|
2540
2626
|
// src/providers/transaction-response/transaction-response.ts
|
2541
2627
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2542
|
-
import { bn as
|
2628
|
+
import { bn as bn15 } from "@fuel-ts/math";
|
2543
2629
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2544
2630
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2545
2631
|
|
2546
2632
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2633
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
2634
|
+
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2547
2635
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2548
2636
|
|
2549
2637
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
@@ -2552,9 +2640,10 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
|
|
2552
2640
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2553
2641
|
var calculateTransactionFee = (params) => {
|
2554
2642
|
const {
|
2555
|
-
|
2643
|
+
gasPrice,
|
2556
2644
|
rawPayload,
|
2557
|
-
|
2645
|
+
tip,
|
2646
|
+
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2558
2647
|
} = params;
|
2559
2648
|
const gasPerByte = bn11(feeParams.gasPerByte);
|
2560
2649
|
const gasPriceFactor = bn11(feeParams.gasPriceFactor);
|
@@ -2564,8 +2653,7 @@ var calculateTransactionFee = (params) => {
|
|
2564
2653
|
return {
|
2565
2654
|
fee: bn11(0),
|
2566
2655
|
minFee: bn11(0),
|
2567
|
-
maxFee: bn11(0)
|
2568
|
-
feeFromGasUsed: bn11(0)
|
2656
|
+
maxFee: bn11(0)
|
2569
2657
|
};
|
2570
2658
|
}
|
2571
2659
|
const { type, witnesses, inputs, policies } = transaction;
|
@@ -2597,7 +2685,6 @@ var calculateTransactionFee = (params) => {
|
|
2597
2685
|
metadataGas,
|
2598
2686
|
txBytesSize: transactionBytes.length
|
2599
2687
|
});
|
2600
|
-
const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
|
2601
2688
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
|
2602
2689
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2603
2690
|
const maxGas = getMaxGas({
|
@@ -2605,17 +2692,25 @@ var calculateTransactionFee = (params) => {
|
|
2605
2692
|
minGas,
|
2606
2693
|
witnessesLength,
|
2607
2694
|
gasLimit,
|
2608
|
-
witnessLimit
|
2695
|
+
witnessLimit,
|
2696
|
+
maxGasPerTx
|
2697
|
+
});
|
2698
|
+
const minFee = calculateGasFee({
|
2699
|
+
gasPrice,
|
2700
|
+
gas: minGas,
|
2701
|
+
priceFactor: gasPriceFactor,
|
2702
|
+
tip
|
2703
|
+
});
|
2704
|
+
const maxFee = calculateGasFee({
|
2705
|
+
gasPrice,
|
2706
|
+
gas: maxGas,
|
2707
|
+
priceFactor: gasPriceFactor,
|
2708
|
+
tip
|
2609
2709
|
});
|
2610
|
-
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
2611
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
2612
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
2613
|
-
const fee = minFee.add(feeFromGasUsed);
|
2614
2710
|
return {
|
2615
|
-
fee,
|
2616
2711
|
minFee,
|
2617
2712
|
maxFee,
|
2618
|
-
|
2713
|
+
fee: maxFee
|
2619
2714
|
};
|
2620
2715
|
};
|
2621
2716
|
|
@@ -2671,7 +2766,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2671
2766
|
|
2672
2767
|
// src/providers/transaction-summary/input.ts
|
2673
2768
|
import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2674
|
-
import { InputType as
|
2769
|
+
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
2675
2770
|
function getInputsByTypes(inputs, types) {
|
2676
2771
|
return inputs.filter((i) => types.includes(i.type));
|
2677
2772
|
}
|
@@ -2679,16 +2774,16 @@ function getInputsByType(inputs, type) {
|
|
2679
2774
|
return inputs.filter((i) => i.type === type);
|
2680
2775
|
}
|
2681
2776
|
function getInputsCoin(inputs) {
|
2682
|
-
return getInputsByType(inputs,
|
2777
|
+
return getInputsByType(inputs, InputType6.Coin);
|
2683
2778
|
}
|
2684
2779
|
function getInputsMessage(inputs) {
|
2685
|
-
return getInputsByType(inputs,
|
2780
|
+
return getInputsByType(inputs, InputType6.Message);
|
2686
2781
|
}
|
2687
2782
|
function getInputsCoinAndMessage(inputs) {
|
2688
|
-
return getInputsByTypes(inputs, [
|
2783
|
+
return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
|
2689
2784
|
}
|
2690
2785
|
function getInputsContract(inputs) {
|
2691
|
-
return getInputsByType(inputs,
|
2786
|
+
return getInputsByType(inputs, InputType6.Contract);
|
2692
2787
|
}
|
2693
2788
|
function getInputFromAssetId(inputs, assetId) {
|
2694
2789
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2707,7 +2802,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2707
2802
|
if (!contractInput) {
|
2708
2803
|
return void 0;
|
2709
2804
|
}
|
2710
|
-
if (contractInput.type !==
|
2805
|
+
if (contractInput.type !== InputType6.Contract) {
|
2711
2806
|
throw new FuelError9(
|
2712
2807
|
ErrorCode9.INVALID_TRANSACTION_INPUT,
|
2713
2808
|
`Contract input should be of type 'contract'.`
|
@@ -2716,10 +2811,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2716
2811
|
return contractInput;
|
2717
2812
|
}
|
2718
2813
|
function getInputAccountAddress(input) {
|
2719
|
-
if (input.type ===
|
2814
|
+
if (input.type === InputType6.Coin) {
|
2720
2815
|
return input.owner.toString();
|
2721
2816
|
}
|
2722
|
-
if (input.type ===
|
2817
|
+
if (input.type === InputType6.Message) {
|
2723
2818
|
return input.recipient.toString();
|
2724
2819
|
}
|
2725
2820
|
return "";
|
@@ -3182,7 +3277,9 @@ function assembleTransactionSummary(params) {
|
|
3182
3277
|
gqlTransactionStatus,
|
3183
3278
|
abiMap = {},
|
3184
3279
|
maxInputs,
|
3185
|
-
gasCosts
|
3280
|
+
gasCosts,
|
3281
|
+
maxGasPerTx,
|
3282
|
+
gasPrice
|
3186
3283
|
} = params;
|
3187
3284
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3188
3285
|
const rawPayload = hexlify11(transactionBytes);
|
@@ -3196,11 +3293,14 @@ function assembleTransactionSummary(params) {
|
|
3196
3293
|
maxInputs
|
3197
3294
|
});
|
3198
3295
|
const typeName = getTransactionTypeName(transaction.type);
|
3296
|
+
const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3199
3297
|
const { fee } = calculateTransactionFee({
|
3200
|
-
|
3298
|
+
gasPrice,
|
3201
3299
|
rawPayload,
|
3300
|
+
tip,
|
3202
3301
|
consensusParameters: {
|
3203
3302
|
gasCosts,
|
3303
|
+
maxGasPerTx,
|
3204
3304
|
feeParams: {
|
3205
3305
|
gasPerByte,
|
3206
3306
|
gasPriceFactor
|
@@ -3260,7 +3360,7 @@ var TransactionResponse = class {
|
|
3260
3360
|
/** Current provider */
|
3261
3361
|
provider;
|
3262
3362
|
/** Gas used on the transaction */
|
3263
|
-
gasUsed =
|
3363
|
+
gasUsed = bn15(0);
|
3264
3364
|
/** The graphql Transaction with receipts object. */
|
3265
3365
|
gqlTransaction;
|
3266
3366
|
abis;
|
@@ -3338,8 +3438,13 @@ var TransactionResponse = class {
|
|
3338
3438
|
const decodedTransaction = this.decodeTransaction(
|
3339
3439
|
transaction
|
3340
3440
|
);
|
3341
|
-
|
3342
|
-
|
3441
|
+
let txReceipts = [];
|
3442
|
+
if (transaction?.status && "receipts" in transaction.status) {
|
3443
|
+
txReceipts = transaction.status.receipts;
|
3444
|
+
}
|
3445
|
+
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3446
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3447
|
+
const gasPrice = await this.provider.getLatestGasPrice();
|
3343
3448
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3344
3449
|
const transactionSummary = assembleTransactionSummary({
|
3345
3450
|
id: this.id,
|
@@ -3351,7 +3456,9 @@ var TransactionResponse = class {
|
|
3351
3456
|
gasPriceFactor,
|
3352
3457
|
abiMap: contractsAbiMap,
|
3353
3458
|
maxInputs,
|
3354
|
-
gasCosts
|
3459
|
+
gasCosts,
|
3460
|
+
maxGasPerTx,
|
3461
|
+
gasPrice
|
3355
3462
|
});
|
3356
3463
|
return transactionSummary;
|
3357
3464
|
}
|
@@ -3478,29 +3585,29 @@ var processGqlChain = (chain) => {
|
|
3478
3585
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3479
3586
|
return {
|
3480
3587
|
name,
|
3481
|
-
baseChainHeight:
|
3588
|
+
baseChainHeight: bn16(daHeight),
|
3482
3589
|
consensusParameters: {
|
3483
|
-
contractMaxSize:
|
3484
|
-
maxInputs:
|
3485
|
-
maxOutputs:
|
3486
|
-
maxWitnesses:
|
3487
|
-
maxGasPerTx:
|
3488
|
-
maxScriptLength:
|
3489
|
-
maxScriptDataLength:
|
3490
|
-
maxStorageSlots:
|
3491
|
-
maxPredicateLength:
|
3492
|
-
maxPredicateDataLength:
|
3493
|
-
maxGasPerPredicate:
|
3494
|
-
gasPriceFactor:
|
3495
|
-
gasPerByte:
|
3496
|
-
maxMessageDataLength:
|
3497
|
-
chainId:
|
3590
|
+
contractMaxSize: bn16(contractParams.contractMaxSize),
|
3591
|
+
maxInputs: bn16(txParams.maxInputs),
|
3592
|
+
maxOutputs: bn16(txParams.maxOutputs),
|
3593
|
+
maxWitnesses: bn16(txParams.maxWitnesses),
|
3594
|
+
maxGasPerTx: bn16(txParams.maxGasPerTx),
|
3595
|
+
maxScriptLength: bn16(scriptParams.maxScriptLength),
|
3596
|
+
maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
|
3597
|
+
maxStorageSlots: bn16(contractParams.maxStorageSlots),
|
3598
|
+
maxPredicateLength: bn16(predicateParams.maxPredicateLength),
|
3599
|
+
maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
|
3600
|
+
maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
|
3601
|
+
gasPriceFactor: bn16(feeParams.gasPriceFactor),
|
3602
|
+
gasPerByte: bn16(feeParams.gasPerByte),
|
3603
|
+
maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
|
3604
|
+
chainId: bn16(consensusParameters.chainId),
|
3498
3605
|
gasCosts
|
3499
3606
|
},
|
3500
3607
|
gasCosts,
|
3501
3608
|
latestBlock: {
|
3502
3609
|
id: latestBlock.id,
|
3503
|
-
height:
|
3610
|
+
height: bn16(latestBlock.height),
|
3504
3611
|
time: latestBlock.header.time,
|
3505
3612
|
transactions: latestBlock.transactions.map((i) => ({
|
3506
3613
|
id: i.id
|
@@ -3594,10 +3701,8 @@ var _Provider = class {
|
|
3594
3701
|
* Returns some helpful parameters related to gas fees.
|
3595
3702
|
*/
|
3596
3703
|
getGasConfig() {
|
3597
|
-
const { minGasPrice } = this.getNode();
|
3598
3704
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3599
3705
|
return {
|
3600
|
-
minGasPrice,
|
3601
3706
|
maxGasPerTx,
|
3602
3707
|
maxGasPerPredicate,
|
3603
3708
|
gasPriceFactor,
|
@@ -3695,7 +3800,7 @@ var _Provider = class {
|
|
3695
3800
|
*/
|
3696
3801
|
async getBlockNumber() {
|
3697
3802
|
const { chain } = await this.operations.getChain();
|
3698
|
-
return
|
3803
|
+
return bn16(chain.latestBlock.height, 10);
|
3699
3804
|
}
|
3700
3805
|
/**
|
3701
3806
|
* Returns the chain information.
|
@@ -3705,13 +3810,11 @@ var _Provider = class {
|
|
3705
3810
|
async fetchNode() {
|
3706
3811
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3707
3812
|
const processedNodeInfo = {
|
3708
|
-
maxDepth:
|
3709
|
-
maxTx:
|
3710
|
-
minGasPrice: bn15(nodeInfo.minGasPrice),
|
3813
|
+
maxDepth: bn16(nodeInfo.maxDepth),
|
3814
|
+
maxTx: bn16(nodeInfo.maxTx),
|
3711
3815
|
nodeVersion: nodeInfo.nodeVersion,
|
3712
3816
|
utxoValidation: nodeInfo.utxoValidation,
|
3713
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
3714
|
-
peers: nodeInfo.peers
|
3817
|
+
vmBacktrace: nodeInfo.vmBacktrace
|
3715
3818
|
};
|
3716
3819
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
3717
3820
|
return processedNodeInfo;
|
@@ -3797,14 +3900,13 @@ var _Provider = class {
|
|
3797
3900
|
return this.estimateTxDependencies(transactionRequest);
|
3798
3901
|
}
|
3799
3902
|
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
3800
|
-
const { dryRun:
|
3801
|
-
encodedTransaction,
|
3903
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
3904
|
+
encodedTransactions: encodedTransaction,
|
3802
3905
|
utxoValidation: utxoValidation || false
|
3803
3906
|
});
|
3804
|
-
const receipts =
|
3805
|
-
|
3806
|
-
|
3807
|
-
};
|
3907
|
+
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
3908
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
3909
|
+
return { receipts, dryrunStatus: status };
|
3808
3910
|
}
|
3809
3911
|
/**
|
3810
3912
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -3830,7 +3932,7 @@ var _Provider = class {
|
|
3830
3932
|
} = response;
|
3831
3933
|
if (inputs) {
|
3832
3934
|
inputs.forEach((input, index) => {
|
3833
|
-
if ("predicateGasUsed" in input &&
|
3935
|
+
if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
|
3834
3936
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3835
3937
|
}
|
3836
3938
|
});
|
@@ -3843,9 +3945,6 @@ var _Provider = class {
|
|
3843
3945
|
* If there are missing variable outputs,
|
3844
3946
|
* `addVariableOutputs` is called on the transaction.
|
3845
3947
|
*
|
3846
|
-
* @privateRemarks
|
3847
|
-
* TODO: Investigate support for missing contract IDs
|
3848
|
-
* TODO: Add support for missing output messages
|
3849
3948
|
*
|
3850
3949
|
* @param transactionRequest - The transaction request object.
|
3851
3950
|
* @returns A promise.
|
@@ -3858,16 +3957,19 @@ var _Provider = class {
|
|
3858
3957
|
missingContractIds: []
|
3859
3958
|
};
|
3860
3959
|
}
|
3861
|
-
await this.estimatePredicates(transactionRequest);
|
3862
3960
|
let receipts = [];
|
3863
3961
|
const missingContractIds = [];
|
3864
3962
|
let outputVariables = 0;
|
3963
|
+
let dryrunStatus;
|
3865
3964
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3866
|
-
const {
|
3867
|
-
|
3965
|
+
const {
|
3966
|
+
dryRun: [{ receipts: rawReceipts, status }]
|
3967
|
+
} = await this.operations.dryRun({
|
3968
|
+
encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
|
3868
3969
|
utxoValidation: false
|
3869
3970
|
});
|
3870
|
-
receipts =
|
3971
|
+
receipts = rawReceipts.map(processGqlReceipt);
|
3972
|
+
dryrunStatus = status;
|
3871
3973
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
3872
3974
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
3873
3975
|
if (hasMissingOutputs) {
|
@@ -3877,6 +3979,10 @@ var _Provider = class {
|
|
3877
3979
|
transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
|
3878
3980
|
missingContractIds.push(contractId);
|
3879
3981
|
});
|
3982
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
3983
|
+
transactionRequest
|
3984
|
+
});
|
3985
|
+
transactionRequest.maxFee = maxFee;
|
3880
3986
|
} else {
|
3881
3987
|
break;
|
3882
3988
|
}
|
@@ -3884,37 +3990,136 @@ var _Provider = class {
|
|
3884
3990
|
return {
|
3885
3991
|
receipts,
|
3886
3992
|
outputVariables,
|
3887
|
-
missingContractIds
|
3993
|
+
missingContractIds,
|
3994
|
+
dryrunStatus
|
3888
3995
|
};
|
3889
3996
|
}
|
3997
|
+
/**
|
3998
|
+
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
3999
|
+
*
|
4000
|
+
* Transactions are dry run in batches. After each dry run, transactions requiring
|
4001
|
+
* further modifications are identified. The method iteratively updates these transactions
|
4002
|
+
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
4003
|
+
*
|
4004
|
+
* @param transactionRequests - Array of transaction request objects.
|
4005
|
+
* @returns A promise that resolves to an array of results for each transaction.
|
4006
|
+
*/
|
4007
|
+
async estimateMultipleTxDependencies(transactionRequests) {
|
4008
|
+
const results = transactionRequests.map(() => ({
|
4009
|
+
receipts: [],
|
4010
|
+
outputVariables: 0,
|
4011
|
+
missingContractIds: [],
|
4012
|
+
dryrunStatus: void 0
|
4013
|
+
}));
|
4014
|
+
const allRequests = clone3(transactionRequests);
|
4015
|
+
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4016
|
+
allRequests.forEach((req, index) => {
|
4017
|
+
if (req.type === TransactionType8.Script) {
|
4018
|
+
serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
|
4019
|
+
}
|
4020
|
+
});
|
4021
|
+
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
4022
|
+
let attempt = 0;
|
4023
|
+
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
4024
|
+
const encodedTransactions = transactionsToProcess.map(
|
4025
|
+
(index) => serializedTransactionsMap.get(index)
|
4026
|
+
);
|
4027
|
+
const dryRunResults = await this.operations.dryRun({
|
4028
|
+
encodedTransactions,
|
4029
|
+
utxoValidation: false
|
4030
|
+
});
|
4031
|
+
const nextRoundTransactions = [];
|
4032
|
+
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
4033
|
+
const requestIdx = transactionsToProcess[i];
|
4034
|
+
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4035
|
+
const result = results[requestIdx];
|
4036
|
+
result.receipts = rawReceipts.map(processGqlReceipt);
|
4037
|
+
result.dryrunStatus = status;
|
4038
|
+
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4039
|
+
result.receipts
|
4040
|
+
);
|
4041
|
+
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4042
|
+
const request = allRequests[requestIdx];
|
4043
|
+
if (hasMissingOutputs && request?.type === TransactionType8.Script) {
|
4044
|
+
result.outputVariables += missingOutputVariables.length;
|
4045
|
+
request.addVariableOutputs(missingOutputVariables.length);
|
4046
|
+
missingOutputContractIds.forEach(({ contractId }) => {
|
4047
|
+
request.addContractInputAndOutput(Address2.fromString(contractId));
|
4048
|
+
result.missingContractIds.push(contractId);
|
4049
|
+
});
|
4050
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
4051
|
+
transactionRequest: request
|
4052
|
+
});
|
4053
|
+
request.maxFee = maxFee;
|
4054
|
+
serializedTransactionsMap.set(requestIdx, hexlify12(request.toTransactionBytes()));
|
4055
|
+
nextRoundTransactions.push(requestIdx);
|
4056
|
+
}
|
4057
|
+
}
|
4058
|
+
transactionsToProcess = nextRoundTransactions;
|
4059
|
+
attempt += 1;
|
4060
|
+
}
|
4061
|
+
return results;
|
4062
|
+
}
|
4063
|
+
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
4064
|
+
if (estimateTxDependencies) {
|
4065
|
+
return this.estimateMultipleTxDependencies(transactionRequests);
|
4066
|
+
}
|
4067
|
+
const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
|
4068
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4069
|
+
encodedTransactions,
|
4070
|
+
utxoValidation: utxoValidation || false
|
4071
|
+
});
|
4072
|
+
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4073
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
4074
|
+
return { receipts, dryrunStatus: status };
|
4075
|
+
});
|
4076
|
+
return results;
|
4077
|
+
}
|
3890
4078
|
/**
|
3891
4079
|
* Estimates the transaction gas and fee based on the provided transaction request.
|
3892
4080
|
* @param transactionRequest - The transaction request object.
|
3893
4081
|
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
3894
4082
|
*/
|
3895
|
-
estimateTxGasAndFee(params) {
|
4083
|
+
async estimateTxGasAndFee(params) {
|
3896
4084
|
const { transactionRequest } = params;
|
3897
|
-
|
4085
|
+
let { gasPrice } = params;
|
3898
4086
|
const chainInfo = this.getChain();
|
3899
|
-
const
|
3900
|
-
transactionRequest.gasPrice = gasPrice;
|
4087
|
+
const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
|
3901
4088
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
3902
|
-
|
4089
|
+
if (!gasPrice) {
|
4090
|
+
gasPrice = await this.estimateGasPrice(10);
|
4091
|
+
}
|
4092
|
+
const minFee = calculateGasFee({
|
4093
|
+
gasPrice: bn16(gasPrice),
|
4094
|
+
gas: minGas,
|
4095
|
+
priceFactor: gasPriceFactor,
|
4096
|
+
tip: transactionRequest.tip
|
4097
|
+
}).add(1);
|
4098
|
+
let gasLimit = bn16(0);
|
3903
4099
|
if (transactionRequest.type === TransactionType8.Script) {
|
4100
|
+
gasLimit = transactionRequest.gasLimit;
|
3904
4101
|
if (transactionRequest.gasLimit.eq(0)) {
|
3905
4102
|
transactionRequest.gasLimit = minGas;
|
3906
4103
|
transactionRequest.gasLimit = maxGasPerTx.sub(
|
3907
4104
|
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
3908
4105
|
);
|
4106
|
+
gasLimit = transactionRequest.gasLimit;
|
3909
4107
|
}
|
3910
4108
|
}
|
3911
4109
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
3912
|
-
const maxFee =
|
4110
|
+
const maxFee = calculateGasFee({
|
4111
|
+
gasPrice: bn16(gasPrice),
|
4112
|
+
gas: maxGas,
|
4113
|
+
priceFactor: gasPriceFactor,
|
4114
|
+
tip: transactionRequest.tip
|
4115
|
+
}).add(1);
|
3913
4116
|
return {
|
3914
4117
|
minGas,
|
3915
4118
|
minFee,
|
3916
4119
|
maxGas,
|
3917
|
-
maxFee
|
4120
|
+
maxFee,
|
4121
|
+
gasPrice,
|
4122
|
+
gasLimit
|
3918
4123
|
};
|
3919
4124
|
}
|
3920
4125
|
/**
|
@@ -3932,15 +4137,17 @@ var _Provider = class {
|
|
3932
4137
|
if (estimateTxDependencies) {
|
3933
4138
|
return this.estimateTxDependencies(transactionRequest);
|
3934
4139
|
}
|
3935
|
-
const
|
3936
|
-
const { dryRun:
|
3937
|
-
|
4140
|
+
const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
|
4141
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4142
|
+
encodedTransactions,
|
3938
4143
|
utxoValidation: true
|
3939
4144
|
});
|
3940
|
-
const
|
3941
|
-
|
3942
|
-
receipts
|
3943
|
-
|
4145
|
+
const callResult = dryRunStatuses.map((dryRunStatus) => {
|
4146
|
+
const { id, receipts, status } = dryRunStatus;
|
4147
|
+
const processedReceipts = receipts.map(processGqlReceipt);
|
4148
|
+
return { id, receipts: processedReceipts, status };
|
4149
|
+
});
|
4150
|
+
return { receipts: callResult[0].receipts };
|
3944
4151
|
}
|
3945
4152
|
/**
|
3946
4153
|
* Returns a transaction cost to enable user
|
@@ -3957,77 +4164,79 @@ var _Provider = class {
|
|
3957
4164
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
3958
4165
|
* @returns A promise that resolves to the transaction cost object.
|
3959
4166
|
*/
|
3960
|
-
async getTransactionCost(transactionRequestLike,
|
3961
|
-
estimateTxDependencies = true,
|
3962
|
-
estimatePredicates = true,
|
3963
|
-
resourcesOwner,
|
3964
|
-
signatureCallback
|
3965
|
-
} = {}) {
|
4167
|
+
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
3966
4168
|
const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
|
3967
|
-
const { minGasPrice } = this.getGasConfig();
|
3968
|
-
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
3969
4169
|
const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
|
3970
4170
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
3971
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
4171
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
3972
4172
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
4173
|
+
txRequestClone.maxFee = bn16(0);
|
3973
4174
|
if (isScriptTransaction) {
|
3974
|
-
txRequestClone.gasLimit =
|
4175
|
+
txRequestClone.gasLimit = bn16(0);
|
3975
4176
|
}
|
3976
|
-
if (
|
3977
|
-
|
3978
|
-
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
3979
|
-
}
|
3980
|
-
await this.estimatePredicates(txRequestClone);
|
4177
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4178
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
3981
4179
|
}
|
4180
|
+
const signedRequest = clone3(txRequestClone);
|
4181
|
+
let addedSignatures = 0;
|
3982
4182
|
if (signatureCallback && isScriptTransaction) {
|
3983
|
-
|
4183
|
+
const lengthBefore = signedRequest.witnesses.length;
|
4184
|
+
await signatureCallback(signedRequest);
|
4185
|
+
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
3984
4186
|
}
|
3985
|
-
|
3986
|
-
|
4187
|
+
await this.estimatePredicates(signedRequest);
|
4188
|
+
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
4189
|
+
transactionRequest: signedRequest
|
3987
4190
|
});
|
3988
4191
|
let receipts = [];
|
3989
4192
|
let missingContractIds = [];
|
3990
4193
|
let outputVariables = 0;
|
3991
|
-
let gasUsed =
|
3992
|
-
|
3993
|
-
|
4194
|
+
let gasUsed = bn16(0);
|
4195
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4196
|
+
txRequestClone.maxFee = maxFee;
|
4197
|
+
if (isScriptTransaction) {
|
4198
|
+
txRequestClone.gasLimit = gasLimit;
|
4199
|
+
if (signatureCallback) {
|
4200
|
+
await signatureCallback(txRequestClone);
|
4201
|
+
}
|
3994
4202
|
const result = await this.estimateTxDependencies(txRequestClone);
|
3995
4203
|
receipts = result.receipts;
|
3996
4204
|
outputVariables = result.outputVariables;
|
3997
4205
|
missingContractIds = result.missingContractIds;
|
3998
4206
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
3999
4207
|
txRequestClone.gasLimit = gasUsed;
|
4000
|
-
|
4001
|
-
|
4002
|
-
|
4208
|
+
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
4209
|
+
transactionRequest: txRequestClone,
|
4210
|
+
gasPrice
|
4003
4211
|
}));
|
4004
4212
|
}
|
4005
4213
|
return {
|
4006
4214
|
requiredQuantities: allQuantities,
|
4007
4215
|
receipts,
|
4008
4216
|
gasUsed,
|
4009
|
-
|
4010
|
-
gasPrice: setGasPrice,
|
4217
|
+
gasPrice,
|
4011
4218
|
minGas,
|
4012
4219
|
maxGas,
|
4013
4220
|
minFee,
|
4014
4221
|
maxFee,
|
4015
|
-
estimatedInputs: txRequestClone.inputs,
|
4016
4222
|
outputVariables,
|
4017
|
-
missingContractIds
|
4223
|
+
missingContractIds,
|
4224
|
+
addedSignatures,
|
4225
|
+
estimatedPredicates: txRequestClone.inputs
|
4018
4226
|
};
|
4019
4227
|
}
|
4020
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
4228
|
+
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
4021
4229
|
const ownerAddress = Address2.fromAddressOrString(owner);
|
4022
4230
|
const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
|
4023
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
4231
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, {
|
4232
|
+
quantitiesToContract
|
4233
|
+
});
|
4024
4234
|
transactionRequest.addResources(
|
4025
4235
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
4026
4236
|
);
|
4027
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4028
|
-
|
4029
|
-
|
4030
|
-
);
|
4237
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
|
4238
|
+
quantitiesToContract
|
4239
|
+
});
|
4031
4240
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
4032
4241
|
return {
|
4033
4242
|
resources,
|
@@ -4049,11 +4258,10 @@ var _Provider = class {
|
|
4049
4258
|
return coins.map((coin) => ({
|
4050
4259
|
id: coin.utxoId,
|
4051
4260
|
assetId: coin.assetId,
|
4052
|
-
amount:
|
4261
|
+
amount: bn16(coin.amount),
|
4053
4262
|
owner: Address2.fromAddressOrString(coin.owner),
|
4054
|
-
|
4055
|
-
|
4056
|
-
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4263
|
+
blockCreated: bn16(coin.blockCreated),
|
4264
|
+
txCreatedIdx: bn16(coin.txCreatedIdx)
|
4057
4265
|
}));
|
4058
4266
|
}
|
4059
4267
|
/**
|
@@ -4090,9 +4298,9 @@ var _Provider = class {
|
|
4090
4298
|
switch (coin.__typename) {
|
4091
4299
|
case "MessageCoin":
|
4092
4300
|
return {
|
4093
|
-
amount:
|
4301
|
+
amount: bn16(coin.amount),
|
4094
4302
|
assetId: coin.assetId,
|
4095
|
-
daHeight:
|
4303
|
+
daHeight: bn16(coin.daHeight),
|
4096
4304
|
sender: Address2.fromAddressOrString(coin.sender),
|
4097
4305
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4098
4306
|
nonce: coin.nonce
|
@@ -4100,12 +4308,11 @@ var _Provider = class {
|
|
4100
4308
|
case "Coin":
|
4101
4309
|
return {
|
4102
4310
|
id: coin.utxoId,
|
4103
|
-
amount:
|
4311
|
+
amount: bn16(coin.amount),
|
4104
4312
|
assetId: coin.assetId,
|
4105
4313
|
owner: Address2.fromAddressOrString(coin.owner),
|
4106
|
-
|
4107
|
-
|
4108
|
-
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4314
|
+
blockCreated: bn16(coin.blockCreated),
|
4315
|
+
txCreatedIdx: bn16(coin.txCreatedIdx)
|
4109
4316
|
};
|
4110
4317
|
default:
|
4111
4318
|
return null;
|
@@ -4122,13 +4329,13 @@ var _Provider = class {
|
|
4122
4329
|
async getBlock(idOrHeight) {
|
4123
4330
|
let variables;
|
4124
4331
|
if (typeof idOrHeight === "number") {
|
4125
|
-
variables = { height:
|
4332
|
+
variables = { height: bn16(idOrHeight).toString(10) };
|
4126
4333
|
} else if (idOrHeight === "latest") {
|
4127
4334
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4128
4335
|
} else if (idOrHeight.length === 66) {
|
4129
4336
|
variables = { blockId: idOrHeight };
|
4130
4337
|
} else {
|
4131
|
-
variables = { blockId:
|
4338
|
+
variables = { blockId: bn16(idOrHeight).toString(10) };
|
4132
4339
|
}
|
4133
4340
|
const { block } = await this.operations.getBlock(variables);
|
4134
4341
|
if (!block) {
|
@@ -4136,7 +4343,7 @@ var _Provider = class {
|
|
4136
4343
|
}
|
4137
4344
|
return {
|
4138
4345
|
id: block.id,
|
4139
|
-
height:
|
4346
|
+
height: bn16(block.height),
|
4140
4347
|
time: block.header.time,
|
4141
4348
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4142
4349
|
};
|
@@ -4151,7 +4358,7 @@ var _Provider = class {
|
|
4151
4358
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4152
4359
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4153
4360
|
id: block.id,
|
4154
|
-
height:
|
4361
|
+
height: bn16(block.height),
|
4155
4362
|
time: block.header.time,
|
4156
4363
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4157
4364
|
}));
|
@@ -4166,7 +4373,7 @@ var _Provider = class {
|
|
4166
4373
|
async getBlockWithTransactions(idOrHeight) {
|
4167
4374
|
let variables;
|
4168
4375
|
if (typeof idOrHeight === "number") {
|
4169
|
-
variables = { blockHeight:
|
4376
|
+
variables = { blockHeight: bn16(idOrHeight).toString(10) };
|
4170
4377
|
} else if (idOrHeight === "latest") {
|
4171
4378
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4172
4379
|
} else {
|
@@ -4178,7 +4385,7 @@ var _Provider = class {
|
|
4178
4385
|
}
|
4179
4386
|
return {
|
4180
4387
|
id: block.id,
|
4181
|
-
height:
|
4388
|
+
height: bn16(block.height, 10),
|
4182
4389
|
time: block.header.time,
|
4183
4390
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4184
4391
|
transactions: block.transactions.map(
|
@@ -4227,7 +4434,7 @@ var _Provider = class {
|
|
4227
4434
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4228
4435
|
asset: hexlify12(assetId)
|
4229
4436
|
});
|
4230
|
-
return
|
4437
|
+
return bn16(contractBalance.amount, 10);
|
4231
4438
|
}
|
4232
4439
|
/**
|
4233
4440
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4241,7 +4448,7 @@ var _Provider = class {
|
|
4241
4448
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4242
4449
|
assetId: hexlify12(assetId)
|
4243
4450
|
});
|
4244
|
-
return
|
4451
|
+
return bn16(balance.amount, 10);
|
4245
4452
|
}
|
4246
4453
|
/**
|
4247
4454
|
* Returns balances for the given owner.
|
@@ -4259,7 +4466,7 @@ var _Provider = class {
|
|
4259
4466
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4260
4467
|
return balances.map((balance) => ({
|
4261
4468
|
assetId: balance.assetId,
|
4262
|
-
amount:
|
4469
|
+
amount: bn16(balance.amount)
|
4263
4470
|
}));
|
4264
4471
|
}
|
4265
4472
|
/**
|
@@ -4281,15 +4488,15 @@ var _Provider = class {
|
|
4281
4488
|
sender: message.sender,
|
4282
4489
|
recipient: message.recipient,
|
4283
4490
|
nonce: message.nonce,
|
4284
|
-
amount:
|
4491
|
+
amount: bn16(message.amount),
|
4285
4492
|
data: message.data
|
4286
4493
|
}),
|
4287
4494
|
sender: Address2.fromAddressOrString(message.sender),
|
4288
4495
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4289
4496
|
nonce: message.nonce,
|
4290
|
-
amount:
|
4497
|
+
amount: bn16(message.amount),
|
4291
4498
|
data: InputMessageCoder.decodeData(message.data),
|
4292
|
-
daHeight:
|
4499
|
+
daHeight: bn16(message.daHeight)
|
4293
4500
|
}));
|
4294
4501
|
}
|
4295
4502
|
/**
|
@@ -4342,44 +4549,60 @@ var _Provider = class {
|
|
4342
4549
|
} = result.messageProof;
|
4343
4550
|
return {
|
4344
4551
|
messageProof: {
|
4345
|
-
proofIndex:
|
4552
|
+
proofIndex: bn16(messageProof.proofIndex),
|
4346
4553
|
proofSet: messageProof.proofSet
|
4347
4554
|
},
|
4348
4555
|
blockProof: {
|
4349
|
-
proofIndex:
|
4556
|
+
proofIndex: bn16(blockProof.proofIndex),
|
4350
4557
|
proofSet: blockProof.proofSet
|
4351
4558
|
},
|
4352
4559
|
messageBlockHeader: {
|
4353
4560
|
id: messageBlockHeader.id,
|
4354
|
-
daHeight:
|
4355
|
-
transactionsCount:
|
4561
|
+
daHeight: bn16(messageBlockHeader.daHeight),
|
4562
|
+
transactionsCount: bn16(messageBlockHeader.transactionsCount),
|
4356
4563
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4357
|
-
height:
|
4564
|
+
height: bn16(messageBlockHeader.height),
|
4358
4565
|
prevRoot: messageBlockHeader.prevRoot,
|
4359
4566
|
time: messageBlockHeader.time,
|
4360
4567
|
applicationHash: messageBlockHeader.applicationHash,
|
4361
|
-
|
4362
|
-
|
4568
|
+
messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount),
|
4569
|
+
messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
|
4570
|
+
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4571
|
+
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4572
|
+
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4363
4573
|
},
|
4364
4574
|
commitBlockHeader: {
|
4365
4575
|
id: commitBlockHeader.id,
|
4366
|
-
daHeight:
|
4367
|
-
transactionsCount:
|
4576
|
+
daHeight: bn16(commitBlockHeader.daHeight),
|
4577
|
+
transactionsCount: bn16(commitBlockHeader.transactionsCount),
|
4368
4578
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4369
|
-
height:
|
4579
|
+
height: bn16(commitBlockHeader.height),
|
4370
4580
|
prevRoot: commitBlockHeader.prevRoot,
|
4371
4581
|
time: commitBlockHeader.time,
|
4372
4582
|
applicationHash: commitBlockHeader.applicationHash,
|
4373
|
-
|
4374
|
-
|
4583
|
+
messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount),
|
4584
|
+
messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
|
4585
|
+
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4586
|
+
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4587
|
+
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4375
4588
|
},
|
4376
4589
|
sender: Address2.fromAddressOrString(sender),
|
4377
4590
|
recipient: Address2.fromAddressOrString(recipient),
|
4378
4591
|
nonce,
|
4379
|
-
amount:
|
4592
|
+
amount: bn16(amount),
|
4380
4593
|
data
|
4381
4594
|
};
|
4382
4595
|
}
|
4596
|
+
async getLatestGasPrice() {
|
4597
|
+
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4598
|
+
return bn16(latestGasPrice.gasPrice);
|
4599
|
+
}
|
4600
|
+
async estimateGasPrice(blockHorizon) {
|
4601
|
+
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4602
|
+
blockHorizon: String(blockHorizon)
|
4603
|
+
});
|
4604
|
+
return bn16(estimateGasPrice.gasPrice);
|
4605
|
+
}
|
4383
4606
|
/**
|
4384
4607
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
4385
4608
|
*
|
@@ -4399,10 +4622,10 @@ var _Provider = class {
|
|
4399
4622
|
*/
|
4400
4623
|
async produceBlocks(amount, startTime) {
|
4401
4624
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4402
|
-
blocksToProduce:
|
4625
|
+
blocksToProduce: bn16(amount).toString(10),
|
4403
4626
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4404
4627
|
});
|
4405
|
-
return
|
4628
|
+
return bn16(latestBlockHeight);
|
4406
4629
|
}
|
4407
4630
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4408
4631
|
async getTransactionResponse(transactionId) {
|
@@ -4416,7 +4639,7 @@ cacheInputs_fn = function(inputs) {
|
|
4416
4639
|
return;
|
4417
4640
|
}
|
4418
4641
|
inputs.forEach((input) => {
|
4419
|
-
if (input.type ===
|
4642
|
+
if (input.type === InputType7.Coin) {
|
4420
4643
|
this.cache?.set(input.id);
|
4421
4644
|
}
|
4422
4645
|
});
|
@@ -4426,7 +4649,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4426
4649
|
|
4427
4650
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4428
4651
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4429
|
-
import { bn as
|
4652
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
4430
4653
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4431
4654
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4432
4655
|
|
@@ -4672,36 +4895,33 @@ var Account = class extends AbstractAccount {
|
|
4672
4895
|
* @param fee - The estimated transaction fee.
|
4673
4896
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4674
4897
|
*/
|
4675
|
-
async fund(request,
|
4676
|
-
const
|
4677
|
-
|
4898
|
+
async fund(request, params) {
|
4899
|
+
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
4900
|
+
const txRequest = request;
|
4901
|
+
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
4902
|
+
amount: bn18(fee),
|
4678
4903
|
assetId: BaseAssetId3,
|
4679
|
-
coinQuantities
|
4904
|
+
coinQuantities: requiredQuantities
|
4680
4905
|
});
|
4681
4906
|
const quantitiesDict = {};
|
4682
|
-
|
4907
|
+
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
4683
4908
|
quantitiesDict[assetId] = {
|
4684
4909
|
required: amount,
|
4685
|
-
owned:
|
4910
|
+
owned: bn18(0)
|
4686
4911
|
};
|
4687
4912
|
});
|
4688
|
-
|
4689
|
-
const cachedMessages = [];
|
4690
|
-
const owner = this.address.toB256();
|
4691
|
-
request.inputs.forEach((input) => {
|
4913
|
+
txRequest.inputs.forEach((input) => {
|
4692
4914
|
const isResource = "amount" in input;
|
4693
4915
|
if (isResource) {
|
4694
4916
|
const isCoin2 = "owner" in input;
|
4695
4917
|
if (isCoin2) {
|
4696
4918
|
const assetId = String(input.assetId);
|
4697
|
-
if (
|
4698
|
-
const amount =
|
4919
|
+
if (quantitiesDict[assetId]) {
|
4920
|
+
const amount = bn18(input.amount);
|
4699
4921
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4700
|
-
cachedUtxos.push(input.id);
|
4701
4922
|
}
|
4702
|
-
} else if (input.
|
4923
|
+
} else if (input.amount && quantitiesDict[BaseAssetId3]) {
|
4703
4924
|
quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
|
4704
|
-
cachedMessages.push(input.nonce);
|
4705
4925
|
}
|
4706
4926
|
}
|
4707
4927
|
});
|
@@ -4716,12 +4936,21 @@ var Account = class extends AbstractAccount {
|
|
4716
4936
|
});
|
4717
4937
|
const needsToBeFunded = missingQuantities.length;
|
4718
4938
|
if (needsToBeFunded) {
|
4719
|
-
const
|
4720
|
-
|
4721
|
-
|
4722
|
-
|
4723
|
-
|
4724
|
-
|
4939
|
+
const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
|
4940
|
+
const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
|
4941
|
+
txRequest.addResources(resources);
|
4942
|
+
}
|
4943
|
+
txRequest.shiftPredicateData();
|
4944
|
+
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
4945
|
+
const requestToReestimate = clone4(txRequest);
|
4946
|
+
if (addedSignatures) {
|
4947
|
+
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
4948
|
+
}
|
4949
|
+
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
4950
|
+
transactionRequest: requestToReestimate
|
4951
|
+
});
|
4952
|
+
txRequest.maxFee = maxFee;
|
4953
|
+
return txRequest;
|
4725
4954
|
}
|
4726
4955
|
/**
|
4727
4956
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -4729,28 +4958,24 @@ var Account = class extends AbstractAccount {
|
|
4729
4958
|
* @param destination - The address of the destination.
|
4730
4959
|
* @param amount - The amount of coins to transfer.
|
4731
4960
|
* @param assetId - The asset ID of the coins to transfer.
|
4732
|
-
* @param txParams - The transaction parameters (gasLimit,
|
4961
|
+
* @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
|
4733
4962
|
* @returns A promise that resolves to the prepared transaction request.
|
4734
4963
|
*/
|
4735
4964
|
async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
4736
|
-
const
|
4737
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
4738
|
-
const request = new ScriptTransactionRequest(params);
|
4965
|
+
const request = new ScriptTransactionRequest(txParams);
|
4739
4966
|
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
|
4740
|
-
const
|
4967
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
4741
4968
|
estimateTxDependencies: true,
|
4742
4969
|
resourcesOwner: this
|
4743
4970
|
});
|
4744
|
-
|
4745
|
-
|
4746
|
-
|
4747
|
-
|
4748
|
-
gasPrice: request.gasPrice,
|
4749
|
-
gasLimit: request.gasLimit,
|
4750
|
-
minGasPrice
|
4971
|
+
this.validateGasLimitAndMaxFee({
|
4972
|
+
gasUsed: txCost.gasUsed,
|
4973
|
+
maxFee: txCost.maxFee,
|
4974
|
+
txParams
|
4751
4975
|
});
|
4752
|
-
|
4753
|
-
request.
|
4976
|
+
request.gasLimit = txCost.gasUsed;
|
4977
|
+
request.maxFee = txCost.maxFee;
|
4978
|
+
await this.fund(request, txCost);
|
4754
4979
|
return request;
|
4755
4980
|
}
|
4756
4981
|
/**
|
@@ -4763,7 +4988,7 @@ var Account = class extends AbstractAccount {
|
|
4763
4988
|
* @returns A promise that resolves to the transaction response.
|
4764
4989
|
*/
|
4765
4990
|
async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
4766
|
-
if (
|
4991
|
+
if (bn18(amount).lte(0)) {
|
4767
4992
|
throw new FuelError15(
|
4768
4993
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
4769
4994
|
"Transfer amount must be a positive number."
|
@@ -4782,38 +5007,36 @@ var Account = class extends AbstractAccount {
|
|
4782
5007
|
* @returns A promise that resolves to the transaction response.
|
4783
5008
|
*/
|
4784
5009
|
async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
|
4785
|
-
if (
|
5010
|
+
if (bn18(amount).lte(0)) {
|
4786
5011
|
throw new FuelError15(
|
4787
5012
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
4788
5013
|
"Transfer amount must be a positive number."
|
4789
5014
|
);
|
4790
5015
|
}
|
4791
5016
|
const contractAddress = Address3.fromAddressOrString(contractId);
|
4792
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
4793
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
4794
5017
|
const { script, scriptData } = await assembleTransferToContractScript({
|
4795
5018
|
hexlifiedContractId: contractAddress.toB256(),
|
4796
|
-
amountToTransfer:
|
5019
|
+
amountToTransfer: bn18(amount),
|
4797
5020
|
assetId
|
4798
5021
|
});
|
4799
5022
|
const request = new ScriptTransactionRequest({
|
4800
|
-
...
|
5023
|
+
...txParams,
|
4801
5024
|
script,
|
4802
5025
|
scriptData
|
4803
5026
|
});
|
4804
5027
|
request.addContractInputAndOutput(contractAddress);
|
4805
|
-
const
|
4806
|
-
|
4807
|
-
[{ amount:
|
4808
|
-
);
|
4809
|
-
request.gasLimit = bn17(params.gasLimit ?? gasUsed);
|
4810
|
-
this.validateGas({
|
4811
|
-
gasUsed,
|
4812
|
-
gasPrice: request.gasPrice,
|
4813
|
-
gasLimit: request.gasLimit,
|
4814
|
-
minGasPrice
|
5028
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
5029
|
+
resourcesOwner: this,
|
5030
|
+
quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
|
4815
5031
|
});
|
4816
|
-
|
5032
|
+
this.validateGasLimitAndMaxFee({
|
5033
|
+
gasUsed: txCost.gasUsed,
|
5034
|
+
maxFee: txCost.maxFee,
|
5035
|
+
txParams
|
5036
|
+
});
|
5037
|
+
request.gasLimit = txCost.gasUsed;
|
5038
|
+
request.maxFee = txCost.maxFee;
|
5039
|
+
await this.fund(request, txCost);
|
4817
5040
|
return this.sendTransaction(request);
|
4818
5041
|
}
|
4819
5042
|
/**
|
@@ -4825,34 +5048,30 @@ var Account = class extends AbstractAccount {
|
|
4825
5048
|
* @returns A promise that resolves to the transaction response.
|
4826
5049
|
*/
|
4827
5050
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4828
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
4829
5051
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
4830
5052
|
const recipientDataArray = arrayify14(
|
4831
5053
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
4832
5054
|
);
|
4833
5055
|
const amountDataArray = arrayify14(
|
4834
|
-
"0x".concat(
|
5056
|
+
"0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
|
4835
5057
|
);
|
4836
5058
|
const script = new Uint8Array([
|
4837
5059
|
...arrayify14(withdrawScript.bytes),
|
4838
5060
|
...recipientDataArray,
|
4839
5061
|
...amountDataArray
|
4840
5062
|
]);
|
4841
|
-
const params = { script,
|
5063
|
+
const params = { script, ...txParams };
|
4842
5064
|
const request = new ScriptTransactionRequest(params);
|
4843
|
-
const
|
4844
|
-
const
|
4845
|
-
|
4846
|
-
|
4847
|
-
|
4848
|
-
|
4849
|
-
this.validateGas({
|
4850
|
-
gasUsed,
|
4851
|
-
gasPrice: request.gasPrice,
|
4852
|
-
gasLimit: request.gasLimit,
|
4853
|
-
minGasPrice
|
5065
|
+
const quantitiesToContract = [{ amount: bn18(amount), assetId: BaseAssetId3 }];
|
5066
|
+
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5067
|
+
this.validateGasLimitAndMaxFee({
|
5068
|
+
gasUsed: txCost.gasUsed,
|
5069
|
+
maxFee: txCost.maxFee,
|
5070
|
+
txParams
|
4854
5071
|
});
|
4855
|
-
|
5072
|
+
request.maxFee = txCost.maxFee;
|
5073
|
+
request.gasLimit = txCost.gasUsed;
|
5074
|
+
await this.fund(request, txCost);
|
4856
5075
|
return this.sendTransaction(request);
|
4857
5076
|
}
|
4858
5077
|
async signMessage(message) {
|
@@ -4910,22 +5129,21 @@ var Account = class extends AbstractAccount {
|
|
4910
5129
|
}
|
4911
5130
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
4912
5131
|
}
|
4913
|
-
|
5132
|
+
validateGasLimitAndMaxFee({
|
5133
|
+
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
|
4914
5134
|
gasUsed,
|
4915
|
-
|
4916
|
-
gasLimit,
|
4917
|
-
minGasPrice
|
5135
|
+
maxFee
|
4918
5136
|
}) {
|
4919
|
-
if (
|
5137
|
+
if (isDefined(setGasLimit) && gasUsed.gt(setGasLimit)) {
|
4920
5138
|
throw new FuelError15(
|
4921
|
-
ErrorCode15.
|
4922
|
-
`Gas
|
5139
|
+
ErrorCode15.GAS_LIMIT_TOO_LOW,
|
5140
|
+
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
4923
5141
|
);
|
4924
5142
|
}
|
4925
|
-
if (
|
5143
|
+
if (isDefined(setMaxFee) && maxFee.gt(setMaxFee)) {
|
4926
5144
|
throw new FuelError15(
|
4927
|
-
ErrorCode15.
|
4928
|
-
`
|
5145
|
+
ErrorCode15.MAX_FEE_TOO_LOW,
|
5146
|
+
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
4929
5147
|
);
|
4930
5148
|
}
|
4931
5149
|
}
|
@@ -5213,7 +5431,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5213
5431
|
* @param transactionRequestLike - The transaction request to send.
|
5214
5432
|
* @returns A promise that resolves to the TransactionResponse object.
|
5215
5433
|
*/
|
5216
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
5434
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
|
5217
5435
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5218
5436
|
if (estimateTxDependencies) {
|
5219
5437
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -5254,7 +5472,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5254
5472
|
// src/hdwallet/hdwallet.ts
|
5255
5473
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5256
5474
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5257
|
-
import { bn as
|
5475
|
+
import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5258
5476
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5259
5477
|
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5260
5478
|
|
@@ -7720,7 +7938,7 @@ var HDWallet = class {
|
|
7720
7938
|
const IR = bytes.slice(32);
|
7721
7939
|
if (privateKey) {
|
7722
7940
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7723
|
-
const ki =
|
7941
|
+
const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
|
7724
7942
|
return new HDWallet({
|
7725
7943
|
privateKey: ki,
|
7726
7944
|
chainCode: IR,
|
@@ -7991,14 +8209,15 @@ var seedTestWallet = async (wallet, quantities) => {
|
|
7991
8209
|
process.env.GENESIS_SECRET || randomBytes5(32),
|
7992
8210
|
wallet.provider
|
7993
8211
|
);
|
7994
|
-
const
|
7995
|
-
|
7996
|
-
|
7997
|
-
|
7998
|
-
gasPrice: minGasPrice
|
8212
|
+
const request = new ScriptTransactionRequest();
|
8213
|
+
quantities.forEach((quantity) => {
|
8214
|
+
const { amount, assetId } = coinQuantityfy(quantity);
|
8215
|
+
request.addCoinOutput(wallet.address, amount, assetId);
|
7999
8216
|
});
|
8000
|
-
|
8001
|
-
|
8217
|
+
const txCost = await genesisWallet.provider.getTransactionCost(request);
|
8218
|
+
request.gasLimit = txCost.gasUsed;
|
8219
|
+
request.maxFee = txCost.maxFee;
|
8220
|
+
await genesisWallet.fund(request, txCost);
|
8002
8221
|
await genesisWallet.sendTransaction(request, { awaitExecution: true });
|
8003
8222
|
};
|
8004
8223
|
|
@@ -8012,9 +8231,10 @@ var generateTestWallet = async (provider, quantities) => {
|
|
8012
8231
|
};
|
8013
8232
|
|
8014
8233
|
// src/test-utils/launchNode.ts
|
8234
|
+
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
8015
8235
|
import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
|
8016
|
-
import {
|
8017
|
-
import {
|
8236
|
+
import { randomBytes as randomBytes6 } from "@fuel-ts/crypto";
|
8237
|
+
import { defaultChainConfigs, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
|
8018
8238
|
import { findBinPath } from "@fuel-ts/utils/cli-utils";
|
8019
8239
|
import { spawn } from "child_process";
|
8020
8240
|
import { randomUUID } from "crypto";
|
@@ -8058,7 +8278,6 @@ var launchNode = async ({
|
|
8058
8278
|
ip,
|
8059
8279
|
port,
|
8060
8280
|
args = [],
|
8061
|
-
fuelCorePath = void 0,
|
8062
8281
|
useSystemFuelCore = false,
|
8063
8282
|
loggingEnabled = true,
|
8064
8283
|
debugEnabled = false,
|
@@ -8067,19 +8286,19 @@ var launchNode = async ({
|
|
8067
8286
|
// eslint-disable-next-line no-async-promise-executor
|
8068
8287
|
new Promise(async (resolve, reject) => {
|
8069
8288
|
const remainingArgs = extractRemainingArgs(args, [
|
8070
|
-
"--
|
8289
|
+
"--snapshot",
|
8071
8290
|
"--consensus-key",
|
8072
8291
|
"--db-type",
|
8073
8292
|
"--poa-instant"
|
8074
8293
|
]);
|
8075
|
-
const chainConfigPath = getFlagValueFromArgs(args, "--
|
8294
|
+
const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
|
8076
8295
|
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || defaultConsensusKey;
|
8077
8296
|
const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
|
8078
8297
|
const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
|
8079
8298
|
const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
|
8080
8299
|
const poaInstant = poaInstantFlagValue === "true" || poaInstantFlagValue === void 0;
|
8081
8300
|
const graphQLStartSubstring = "Binding GraphQL provider to";
|
8082
|
-
const binPath =
|
8301
|
+
const binPath = findBinPath("fuels-core", __dirname);
|
8083
8302
|
const command = useSystemFuelCore ? "fuel-core" : binPath;
|
8084
8303
|
const ipToUse = ip || "0.0.0.0";
|
8085
8304
|
const portToUse = port || (await getPortPromise({
|
@@ -8091,36 +8310,54 @@ var launchNode = async ({
|
|
8091
8310
|
let chainConfigPathToUse;
|
8092
8311
|
const prefix = basePath || os.tmpdir();
|
8093
8312
|
const suffix = basePath ? "" : randomUUID();
|
8094
|
-
const tempDirPath = path.join(prefix, ".fuels", suffix);
|
8313
|
+
const tempDirPath = path.join(prefix, ".fuels", suffix, "chainConfigs");
|
8095
8314
|
if (chainConfigPath) {
|
8096
8315
|
chainConfigPathToUse = chainConfigPath;
|
8097
8316
|
} else {
|
8098
8317
|
if (!existsSync(tempDirPath)) {
|
8099
8318
|
mkdirSync(tempDirPath, { recursive: true });
|
8100
8319
|
}
|
8101
|
-
|
8102
|
-
|
8320
|
+
let { stateConfigJson } = defaultChainConfigs;
|
8321
|
+
const { chainConfigJson, metadataJson } = defaultChainConfigs;
|
8322
|
+
stateConfigJson = {
|
8323
|
+
...stateConfigJson,
|
8324
|
+
coins: [
|
8325
|
+
...stateConfigJson.coins.map((coin) => ({
|
8326
|
+
...coin,
|
8327
|
+
amount: "18446744073709551615"
|
8328
|
+
}))
|
8329
|
+
],
|
8330
|
+
messages: stateConfigJson.messages.map((message) => ({
|
8331
|
+
...message,
|
8332
|
+
amount: "18446744073709551615"
|
8333
|
+
}))
|
8334
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8335
|
+
};
|
8103
8336
|
if (!process.env.GENESIS_SECRET) {
|
8104
8337
|
const pk = Signer.generatePrivateKey();
|
8105
8338
|
const signer = new Signer(pk);
|
8106
8339
|
process.env.GENESIS_SECRET = hexlify18(pk);
|
8107
|
-
|
8108
|
-
|
8109
|
-
|
8110
|
-
|
8111
|
-
|
8112
|
-
|
8113
|
-
|
8114
|
-
|
8115
|
-
|
8116
|
-
|
8117
|
-
}
|
8118
|
-
]
|
8119
|
-
}
|
8120
|
-
};
|
8340
|
+
stateConfigJson.coins.push({
|
8341
|
+
tx_id: hexlify18(randomBytes6(UTXO_ID_LEN3)),
|
8342
|
+
owner: signer.address.toHexString(),
|
8343
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8344
|
+
amount: "18446744073709551615",
|
8345
|
+
asset_id: BaseAssetId4,
|
8346
|
+
output_index: 0,
|
8347
|
+
tx_pointer_block_height: 0,
|
8348
|
+
tx_pointer_tx_idx: 0
|
8349
|
+
});
|
8121
8350
|
}
|
8122
|
-
|
8123
|
-
|
8351
|
+
let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
|
8352
|
+
const regexMakeNumber = /("amount":)"(\d+)"/gm;
|
8353
|
+
fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
|
8354
|
+
const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
|
8355
|
+
const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
|
8356
|
+
const metadataWritePath = path.join(tempDirPath, "metadata.json");
|
8357
|
+
writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
|
8358
|
+
writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
|
8359
|
+
writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
|
8360
|
+
chainConfigPathToUse = tempDirPath;
|
8124
8361
|
}
|
8125
8362
|
const child = spawn(
|
8126
8363
|
command,
|
@@ -8129,10 +8366,10 @@ var launchNode = async ({
|
|
8129
8366
|
["--ip", ipToUse],
|
8130
8367
|
["--port", portToUse],
|
8131
8368
|
useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
|
8132
|
-
["--min-gas-price", "
|
8369
|
+
["--min-gas-price", "1"],
|
8133
8370
|
poaInstant ? ["--poa-instant", "true"] : [],
|
8134
8371
|
["--consensus-key", consensusKey],
|
8135
|
-
["--
|
8372
|
+
["--snapshot", chainConfigPathToUse],
|
8136
8373
|
"--vm-backtrace",
|
8137
8374
|
"--utxo-validation",
|
8138
8375
|
"--debug",
|
@@ -8191,7 +8428,7 @@ var launchNodeAndGetWallets = async ({
|
|
8191
8428
|
walletCount = 10
|
8192
8429
|
} = {}) => {
|
8193
8430
|
const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
|
8194
|
-
const provider = await Provider.create(`http://${ip}:${port}/graphql`);
|
8431
|
+
const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
|
8195
8432
|
const wallets = await generateWallets(walletCount, provider);
|
8196
8433
|
const cleanup = () => {
|
8197
8434
|
closeNode();
|