@fuel-ts/account 0.0.0-rc-2130-20240422142413 → 0.0.0-rc-2021-20240422173414
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 +5 -4
- 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/hdwallet/hdwallet.d.ts.map +1 -1
- package/dist/index.global.js +3380 -1998
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +786 -518
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +663 -396
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts.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 +906 -324
- 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 +46 -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 -25
- 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.map +1 -1
- package/dist/test-utils.global.js +4111 -2491
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +765 -515
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +655 -405
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +17 -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
|
30
|
+
import { bn as bn18 } from "@fuel-ts/math";
|
31
31
|
import { arrayify as arrayify14 } 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
|
@@ -79,6 +80,7 @@ import {
|
|
79
80
|
import { arrayify as arrayify11, hexlify as hexlify12, DateTime as DateTime2 } from "@fuel-ts/utils";
|
80
81
|
import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
|
81
82
|
import { equalBytes } from "@noble/curves/abstract/utils";
|
83
|
+
import { Network } from "ethers";
|
82
84
|
import { GraphQLClient } from "graphql-request";
|
83
85
|
import { clone as clone3 } from "ramda";
|
84
86
|
|
@@ -86,14 +88,10 @@ import { clone as clone3 } from "ramda";
|
|
86
88
|
import gql from "graphql-tag";
|
87
89
|
var ReceiptFragmentFragmentDoc = gql`
|
88
90
|
fragment receiptFragment on Receipt {
|
89
|
-
|
90
|
-
id
|
91
|
-
}
|
91
|
+
id
|
92
92
|
pc
|
93
93
|
is
|
94
|
-
to
|
95
|
-
id
|
96
|
-
}
|
94
|
+
to
|
97
95
|
toAddress
|
98
96
|
amount
|
99
97
|
assetId
|
@@ -131,10 +129,16 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
131
129
|
id
|
132
130
|
}
|
133
131
|
time
|
132
|
+
receipts {
|
133
|
+
...receiptFragment
|
134
|
+
}
|
134
135
|
programState {
|
135
136
|
returnType
|
136
137
|
data
|
137
138
|
}
|
139
|
+
receipts {
|
140
|
+
...receiptFragment
|
141
|
+
}
|
138
142
|
}
|
139
143
|
... on FailureStatus {
|
140
144
|
block {
|
@@ -142,26 +146,24 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
142
146
|
}
|
143
147
|
time
|
144
148
|
reason
|
149
|
+
receipts {
|
150
|
+
...receiptFragment
|
151
|
+
}
|
145
152
|
}
|
146
153
|
... on SqueezedOutStatus {
|
147
154
|
reason
|
148
155
|
}
|
149
156
|
}
|
150
|
-
`;
|
157
|
+
${ReceiptFragmentFragmentDoc}`;
|
151
158
|
var TransactionFragmentFragmentDoc = gql`
|
152
159
|
fragment transactionFragment on Transaction {
|
153
160
|
id
|
154
161
|
rawPayload
|
155
|
-
gasPrice
|
156
|
-
receipts {
|
157
|
-
...receiptFragment
|
158
|
-
}
|
159
162
|
status {
|
160
163
|
...transactionStatusFragment
|
161
164
|
}
|
162
165
|
}
|
163
|
-
${
|
164
|
-
${TransactionStatusFragmentFragmentDoc}`;
|
166
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
165
167
|
var InputEstimatePredicatesFragmentFragmentDoc = gql`
|
166
168
|
fragment inputEstimatePredicatesFragment on Input {
|
167
169
|
... on InputCoin {
|
@@ -179,6 +181,46 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
|
|
179
181
|
}
|
180
182
|
}
|
181
183
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
184
|
+
var DryRunFailureStatusFragmentFragmentDoc = gql`
|
185
|
+
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
186
|
+
reason
|
187
|
+
programState {
|
188
|
+
returnType
|
189
|
+
data
|
190
|
+
}
|
191
|
+
}
|
192
|
+
`;
|
193
|
+
var DryRunSuccessStatusFragmentFragmentDoc = gql`
|
194
|
+
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
195
|
+
programState {
|
196
|
+
returnType
|
197
|
+
data
|
198
|
+
}
|
199
|
+
}
|
200
|
+
`;
|
201
|
+
var DryRunTransactionStatusFragmentFragmentDoc = gql`
|
202
|
+
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
203
|
+
... on DryRunFailureStatus {
|
204
|
+
...dryRunFailureStatusFragment
|
205
|
+
}
|
206
|
+
... on DryRunSuccessStatus {
|
207
|
+
...dryRunSuccessStatusFragment
|
208
|
+
}
|
209
|
+
}
|
210
|
+
${DryRunFailureStatusFragmentFragmentDoc}
|
211
|
+
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
212
|
+
var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
|
213
|
+
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
214
|
+
id
|
215
|
+
status {
|
216
|
+
...dryRunTransactionStatusFragment
|
217
|
+
}
|
218
|
+
receipts {
|
219
|
+
...receiptFragment
|
220
|
+
}
|
221
|
+
}
|
222
|
+
${DryRunTransactionStatusFragmentFragmentDoc}
|
223
|
+
${ReceiptFragmentFragmentDoc}`;
|
182
224
|
var CoinFragmentFragmentDoc = gql`
|
183
225
|
fragment coinFragment on Coin {
|
184
226
|
__typename
|
@@ -186,7 +228,6 @@ var CoinFragmentFragmentDoc = gql`
|
|
186
228
|
owner
|
187
229
|
amount
|
188
230
|
assetId
|
189
|
-
maturity
|
190
231
|
blockCreated
|
191
232
|
txCreatedIdx
|
192
233
|
}
|
@@ -225,26 +266,32 @@ var MessageProofFragmentFragmentDoc = gql`
|
|
225
266
|
messageBlockHeader {
|
226
267
|
id
|
227
268
|
daHeight
|
269
|
+
consensusParametersVersion
|
270
|
+
stateTransitionBytecodeVersion
|
228
271
|
transactionsCount
|
272
|
+
messageReceiptCount
|
229
273
|
transactionsRoot
|
274
|
+
messageOutboxRoot
|
275
|
+
eventInboxRoot
|
230
276
|
height
|
231
277
|
prevRoot
|
232
278
|
time
|
233
279
|
applicationHash
|
234
|
-
messageReceiptRoot
|
235
|
-
messageReceiptCount
|
236
280
|
}
|
237
281
|
commitBlockHeader {
|
238
282
|
id
|
239
283
|
daHeight
|
284
|
+
consensusParametersVersion
|
285
|
+
stateTransitionBytecodeVersion
|
240
286
|
transactionsCount
|
287
|
+
messageReceiptCount
|
241
288
|
transactionsRoot
|
289
|
+
messageOutboxRoot
|
290
|
+
eventInboxRoot
|
242
291
|
height
|
243
292
|
prevRoot
|
244
293
|
time
|
245
294
|
applicationHash
|
246
|
-
messageReceiptRoot
|
247
|
-
messageReceiptCount
|
248
295
|
}
|
249
296
|
sender
|
250
297
|
recipient
|
@@ -263,8 +310,8 @@ var BalanceFragmentFragmentDoc = gql`
|
|
263
310
|
var BlockFragmentFragmentDoc = gql`
|
264
311
|
fragment blockFragment on Block {
|
265
312
|
id
|
313
|
+
height
|
266
314
|
header {
|
267
|
-
height
|
268
315
|
time
|
269
316
|
}
|
270
317
|
transactions {
|
@@ -322,6 +369,11 @@ var DependentCostFragmentFragmentDoc = gql`
|
|
322
369
|
`;
|
323
370
|
var GasCostsFragmentFragmentDoc = gql`
|
324
371
|
fragment GasCostsFragment on GasCosts {
|
372
|
+
version {
|
373
|
+
... on Version {
|
374
|
+
value
|
375
|
+
}
|
376
|
+
}
|
325
377
|
add
|
326
378
|
addi
|
327
379
|
aloc
|
@@ -334,7 +386,6 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
334
386
|
cb
|
335
387
|
cfei
|
336
388
|
cfsi
|
337
|
-
croo
|
338
389
|
div
|
339
390
|
divi
|
340
391
|
ecr1
|
@@ -417,6 +468,9 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
417
468
|
ccp {
|
418
469
|
...DependentCostFragment
|
419
470
|
}
|
471
|
+
croo {
|
472
|
+
...DependentCostFragment
|
473
|
+
}
|
420
474
|
csiz {
|
421
475
|
...DependentCostFragment
|
422
476
|
}
|
@@ -476,6 +530,11 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
476
530
|
${DependentCostFragmentFragmentDoc}`;
|
477
531
|
var ConsensusParametersFragmentFragmentDoc = gql`
|
478
532
|
fragment consensusParametersFragment on ConsensusParameters {
|
533
|
+
version {
|
534
|
+
... on Version {
|
535
|
+
value
|
536
|
+
}
|
537
|
+
}
|
479
538
|
txParams {
|
480
539
|
...TxParametersFragment
|
481
540
|
}
|
@@ -535,18 +594,9 @@ var NodeInfoFragmentFragmentDoc = gql`
|
|
535
594
|
fragment nodeInfoFragment on NodeInfo {
|
536
595
|
utxoValidation
|
537
596
|
vmBacktrace
|
538
|
-
minGasPrice
|
539
597
|
maxTx
|
540
598
|
maxDepth
|
541
599
|
nodeVersion
|
542
|
-
peers {
|
543
|
-
id
|
544
|
-
addresses
|
545
|
-
clientVersion
|
546
|
-
blockHeight
|
547
|
-
lastHeartbeatMs
|
548
|
-
appScore
|
549
|
-
}
|
550
600
|
}
|
551
601
|
`;
|
552
602
|
var GetVersionDocument = gql`
|
@@ -581,13 +631,9 @@ var GetTransactionWithReceiptsDocument = gql`
|
|
581
631
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
582
632
|
transaction(id: $transactionId) {
|
583
633
|
...transactionFragment
|
584
|
-
receipts {
|
585
|
-
...receiptFragment
|
586
|
-
}
|
587
634
|
}
|
588
635
|
}
|
589
|
-
${TransactionFragmentFragmentDoc}
|
590
|
-
${ReceiptFragmentFragmentDoc}`;
|
636
|
+
${TransactionFragmentFragmentDoc}`;
|
591
637
|
var GetTransactionsDocument = gql`
|
592
638
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
593
639
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -715,6 +761,20 @@ var GetBalanceDocument = gql`
|
|
715
761
|
}
|
716
762
|
}
|
717
763
|
${BalanceFragmentFragmentDoc}`;
|
764
|
+
var GetLatestGasPriceDocument = gql`
|
765
|
+
query getLatestGasPrice {
|
766
|
+
latestGasPrice {
|
767
|
+
gasPrice
|
768
|
+
}
|
769
|
+
}
|
770
|
+
`;
|
771
|
+
var EstimateGasPriceDocument = gql`
|
772
|
+
query estimateGasPrice($blockHorizon: U32!) {
|
773
|
+
estimateGasPrice(blockHorizon: $blockHorizon) {
|
774
|
+
gasPrice
|
775
|
+
}
|
776
|
+
}
|
777
|
+
`;
|
718
778
|
var GetBalancesDocument = gql`
|
719
779
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
720
780
|
balances(
|
@@ -769,12 +829,12 @@ var GetMessageStatusDocument = gql`
|
|
769
829
|
}
|
770
830
|
`;
|
771
831
|
var DryRunDocument = gql`
|
772
|
-
mutation dryRun($
|
773
|
-
dryRun(
|
774
|
-
...
|
832
|
+
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
833
|
+
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
834
|
+
...dryRunTransactionExecutionStatusFragment
|
775
835
|
}
|
776
836
|
}
|
777
|
-
${
|
837
|
+
${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
|
778
838
|
var SubmitDocument = gql`
|
779
839
|
mutation submit($encodedTransaction: HexString!) {
|
780
840
|
submit(tx: $encodedTransaction) {
|
@@ -857,6 +917,12 @@ function getSdk(requester) {
|
|
857
917
|
getBalance(variables, options) {
|
858
918
|
return requester(GetBalanceDocument, variables, options);
|
859
919
|
},
|
920
|
+
getLatestGasPrice(variables, options) {
|
921
|
+
return requester(GetLatestGasPriceDocument, variables, options);
|
922
|
+
},
|
923
|
+
estimateGasPrice(variables, options) {
|
924
|
+
return requester(EstimateGasPriceDocument, variables, options);
|
925
|
+
},
|
860
926
|
getBalances(variables, options) {
|
861
927
|
return requester(GetBalancesDocument, variables, options);
|
862
928
|
},
|
@@ -1050,10 +1116,9 @@ var inputify = (value) => {
|
|
1050
1116
|
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
1051
1117
|
},
|
1052
1118
|
witnessIndex: value.witnessIndex,
|
1053
|
-
maturity: value.maturity ?? 0,
|
1054
1119
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1055
|
-
predicateLength: predicate.length,
|
1056
|
-
predicateDataLength: predicateData.length,
|
1120
|
+
predicateLength: bn2(predicate.length),
|
1121
|
+
predicateDataLength: bn2(predicateData.length),
|
1057
1122
|
predicate: hexlify3(predicate),
|
1058
1123
|
predicateData: hexlify3(predicateData)
|
1059
1124
|
};
|
@@ -1084,8 +1149,8 @@ var inputify = (value) => {
|
|
1084
1149
|
nonce: hexlify3(value.nonce),
|
1085
1150
|
witnessIndex: value.witnessIndex,
|
1086
1151
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1087
|
-
predicateLength: predicate.length,
|
1088
|
-
predicateDataLength: predicateData.length,
|
1152
|
+
predicateLength: bn2(predicate.length),
|
1153
|
+
predicateDataLength: bn2(predicateData.length),
|
1089
1154
|
predicate: hexlify3(predicate),
|
1090
1155
|
predicateData: hexlify3(predicateData),
|
1091
1156
|
data: hexlify3(data),
|
@@ -1212,8 +1277,8 @@ function assembleReceiptByType(receipt) {
|
|
1212
1277
|
case "CALL" /* Call */: {
|
1213
1278
|
const callReceipt = {
|
1214
1279
|
type: ReceiptType.Call,
|
1215
|
-
from: hexOrZero(receipt.
|
1216
|
-
to: hexOrZero(receipt?.to
|
1280
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1281
|
+
to: hexOrZero(receipt?.to),
|
1217
1282
|
amount: bn4(receipt.amount),
|
1218
1283
|
assetId: hexOrZero(receipt.assetId),
|
1219
1284
|
gas: bn4(receipt.gas),
|
@@ -1227,7 +1292,7 @@ function assembleReceiptByType(receipt) {
|
|
1227
1292
|
case "RETURN" /* Return */: {
|
1228
1293
|
const returnReceipt = {
|
1229
1294
|
type: ReceiptType.Return,
|
1230
|
-
id: hexOrZero(receipt.
|
1295
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1231
1296
|
val: bn4(receipt.val),
|
1232
1297
|
pc: bn4(receipt.pc),
|
1233
1298
|
is: bn4(receipt.is)
|
@@ -1237,7 +1302,7 @@ function assembleReceiptByType(receipt) {
|
|
1237
1302
|
case "RETURN_DATA" /* ReturnData */: {
|
1238
1303
|
const returnDataReceipt = {
|
1239
1304
|
type: ReceiptType.ReturnData,
|
1240
|
-
id: hexOrZero(receipt.
|
1305
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1241
1306
|
ptr: bn4(receipt.ptr),
|
1242
1307
|
len: bn4(receipt.len),
|
1243
1308
|
digest: hexOrZero(receipt.digest),
|
@@ -1249,7 +1314,7 @@ function assembleReceiptByType(receipt) {
|
|
1249
1314
|
case "PANIC" /* Panic */: {
|
1250
1315
|
const panicReceipt = {
|
1251
1316
|
type: ReceiptType.Panic,
|
1252
|
-
id: hexOrZero(receipt.
|
1317
|
+
id: hexOrZero(receipt.id),
|
1253
1318
|
reason: bn4(receipt.reason),
|
1254
1319
|
pc: bn4(receipt.pc),
|
1255
1320
|
is: bn4(receipt.is),
|
@@ -1260,7 +1325,7 @@ function assembleReceiptByType(receipt) {
|
|
1260
1325
|
case "REVERT" /* Revert */: {
|
1261
1326
|
const revertReceipt = {
|
1262
1327
|
type: ReceiptType.Revert,
|
1263
|
-
id: hexOrZero(receipt.
|
1328
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1264
1329
|
val: bn4(receipt.ra),
|
1265
1330
|
pc: bn4(receipt.pc),
|
1266
1331
|
is: bn4(receipt.is)
|
@@ -1270,7 +1335,7 @@ function assembleReceiptByType(receipt) {
|
|
1270
1335
|
case "LOG" /* Log */: {
|
1271
1336
|
const logReceipt = {
|
1272
1337
|
type: ReceiptType.Log,
|
1273
|
-
id: hexOrZero(receipt.
|
1338
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1274
1339
|
val0: bn4(receipt.ra),
|
1275
1340
|
val1: bn4(receipt.rb),
|
1276
1341
|
val2: bn4(receipt.rc),
|
@@ -1283,7 +1348,7 @@ function assembleReceiptByType(receipt) {
|
|
1283
1348
|
case "LOG_DATA" /* LogData */: {
|
1284
1349
|
const logDataReceipt = {
|
1285
1350
|
type: ReceiptType.LogData,
|
1286
|
-
id: hexOrZero(receipt.
|
1351
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1287
1352
|
val0: bn4(receipt.ra),
|
1288
1353
|
val1: bn4(receipt.rb),
|
1289
1354
|
ptr: bn4(receipt.ptr),
|
@@ -1297,8 +1362,8 @@ function assembleReceiptByType(receipt) {
|
|
1297
1362
|
case "TRANSFER" /* Transfer */: {
|
1298
1363
|
const transferReceipt = {
|
1299
1364
|
type: ReceiptType.Transfer,
|
1300
|
-
from: hexOrZero(receipt.
|
1301
|
-
to: hexOrZero(receipt.toAddress || receipt?.to
|
1365
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1366
|
+
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1302
1367
|
amount: bn4(receipt.amount),
|
1303
1368
|
assetId: hexOrZero(receipt.assetId),
|
1304
1369
|
pc: bn4(receipt.pc),
|
@@ -1309,8 +1374,8 @@ function assembleReceiptByType(receipt) {
|
|
1309
1374
|
case "TRANSFER_OUT" /* TransferOut */: {
|
1310
1375
|
const transferOutReceipt = {
|
1311
1376
|
type: ReceiptType.TransferOut,
|
1312
|
-
from: hexOrZero(receipt.
|
1313
|
-
to: hexOrZero(receipt.toAddress || receipt.to
|
1377
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1378
|
+
to: hexOrZero(receipt.toAddress || receipt.to),
|
1314
1379
|
amount: bn4(receipt.amount),
|
1315
1380
|
assetId: hexOrZero(receipt.assetId),
|
1316
1381
|
pc: bn4(receipt.pc),
|
@@ -1353,7 +1418,7 @@ function assembleReceiptByType(receipt) {
|
|
1353
1418
|
return receiptMessageOut;
|
1354
1419
|
}
|
1355
1420
|
case "MINT" /* Mint */: {
|
1356
|
-
const contractId = hexOrZero(receipt.
|
1421
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1357
1422
|
const subId = hexOrZero(receipt.subId);
|
1358
1423
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
1359
1424
|
const mintReceipt = {
|
@@ -1368,7 +1433,7 @@ function assembleReceiptByType(receipt) {
|
|
1368
1433
|
return mintReceipt;
|
1369
1434
|
}
|
1370
1435
|
case "BURN" /* Burn */: {
|
1371
|
-
const contractId = hexOrZero(receipt.
|
1436
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1372
1437
|
const subId = hexOrZero(receipt.subId);
|
1373
1438
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
1374
1439
|
const burnReceipt = {
|
@@ -1394,7 +1459,6 @@ import { ErrorCode as ErrorCode6, FuelError as FuelError6 } from "@fuel-ts/error
|
|
1394
1459
|
import { bn as bn5 } from "@fuel-ts/math";
|
1395
1460
|
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
1396
1461
|
import { arrayify as arrayify3 } from "@fuel-ts/utils";
|
1397
|
-
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1398
1462
|
var getGasUsedFromReceipts = (receipts) => {
|
1399
1463
|
const scriptResult = receipts.filter(
|
1400
1464
|
(receipt) => receipt.type === ReceiptType2.ScriptResult
|
@@ -1415,18 +1479,28 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
1415
1479
|
}
|
1416
1480
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
1417
1481
|
const witnessCache = [];
|
1418
|
-
const
|
1482
|
+
const chargeableInputs = inputs.filter((input) => {
|
1483
|
+
const isCoinOrMessage = "owner" in input || "sender" in input;
|
1484
|
+
if (isCoinOrMessage) {
|
1485
|
+
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1486
|
+
return true;
|
1487
|
+
}
|
1488
|
+
if (!witnessCache.includes(input.witnessIndex)) {
|
1489
|
+
witnessCache.push(input.witnessIndex);
|
1490
|
+
return true;
|
1491
|
+
}
|
1492
|
+
}
|
1493
|
+
return false;
|
1494
|
+
});
|
1495
|
+
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
1496
|
+
const totalGas = chargeableInputs.reduce((total, input) => {
|
1419
1497
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1420
1498
|
return total.add(
|
1421
|
-
|
1499
|
+
vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
|
1422
1500
|
);
|
1423
1501
|
}
|
1424
|
-
|
1425
|
-
|
1426
|
-
return total.add(gasCosts.ecr1);
|
1427
|
-
}
|
1428
|
-
return total;
|
1429
|
-
}, bn5());
|
1502
|
+
return total.add(gasCosts.ecr1);
|
1503
|
+
}, bn5(0));
|
1430
1504
|
return totalGas;
|
1431
1505
|
}
|
1432
1506
|
function getMinGas(params) {
|
@@ -1438,12 +1512,20 @@ function getMinGas(params) {
|
|
1438
1512
|
return minGas;
|
1439
1513
|
}
|
1440
1514
|
function getMaxGas(params) {
|
1441
|
-
const {
|
1515
|
+
const {
|
1516
|
+
gasPerByte,
|
1517
|
+
witnessesLength,
|
1518
|
+
witnessLimit,
|
1519
|
+
minGas,
|
1520
|
+
gasLimit = bn5(0),
|
1521
|
+
maxGasPerTx
|
1522
|
+
} = params;
|
1442
1523
|
let remainingAllowedWitnessGas = bn5(0);
|
1443
1524
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
1444
1525
|
remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
1445
1526
|
}
|
1446
|
-
|
1527
|
+
const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
1528
|
+
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
1447
1529
|
}
|
1448
1530
|
function calculateMetadataGasForTxCreate({
|
1449
1531
|
gasCosts,
|
@@ -1465,6 +1547,10 @@ function calculateMetadataGasForTxScript({
|
|
1465
1547
|
}) {
|
1466
1548
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1467
1549
|
}
|
1550
|
+
var calculateGasFee = (params) => {
|
1551
|
+
const { gas, gasPrice, priceFactor, tip } = params;
|
1552
|
+
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1553
|
+
};
|
1468
1554
|
|
1469
1555
|
// src/providers/utils/json.ts
|
1470
1556
|
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
@@ -1609,7 +1695,7 @@ var witnessify = (value) => {
|
|
1609
1695
|
// src/providers/transaction-request/transaction-request.ts
|
1610
1696
|
var BaseTransactionRequest = class {
|
1611
1697
|
/** Gas price for transaction */
|
1612
|
-
|
1698
|
+
tip;
|
1613
1699
|
/** Block until which tx cannot be included */
|
1614
1700
|
maturity;
|
1615
1701
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -1628,7 +1714,7 @@ var BaseTransactionRequest = class {
|
|
1628
1714
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
1629
1715
|
*/
|
1630
1716
|
constructor({
|
1631
|
-
|
1717
|
+
tip,
|
1632
1718
|
maturity,
|
1633
1719
|
maxFee,
|
1634
1720
|
witnessLimit,
|
@@ -1636,7 +1722,7 @@ var BaseTransactionRequest = class {
|
|
1636
1722
|
outputs,
|
1637
1723
|
witnesses
|
1638
1724
|
} = {}) {
|
1639
|
-
this.
|
1725
|
+
this.tip = bn7(tip);
|
1640
1726
|
this.maturity = maturity ?? 0;
|
1641
1727
|
this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
|
1642
1728
|
this.maxFee = maxFee ? bn7(maxFee) : void 0;
|
@@ -1647,9 +1733,9 @@ var BaseTransactionRequest = class {
|
|
1647
1733
|
static getPolicyMeta(req) {
|
1648
1734
|
let policyTypes = 0;
|
1649
1735
|
const policies = [];
|
1650
|
-
if (req.
|
1651
|
-
policyTypes += PolicyType.
|
1652
|
-
policies.push({ data: req.
|
1736
|
+
if (req.tip) {
|
1737
|
+
policyTypes += PolicyType.Tip;
|
1738
|
+
policies.push({ data: req.tip, type: PolicyType.Tip });
|
1653
1739
|
}
|
1654
1740
|
if (req.witnessLimit) {
|
1655
1741
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -1836,10 +1922,10 @@ var BaseTransactionRequest = class {
|
|
1836
1922
|
* @param predicate - Predicate bytes.
|
1837
1923
|
* @param predicateData - Predicate data bytes.
|
1838
1924
|
*/
|
1839
|
-
addCoinInput(coin
|
1925
|
+
addCoinInput(coin) {
|
1840
1926
|
const { assetId, owner, amount } = coin;
|
1841
1927
|
let witnessIndex;
|
1842
|
-
if (predicate) {
|
1928
|
+
if (coin.predicate) {
|
1843
1929
|
witnessIndex = 0;
|
1844
1930
|
} else {
|
1845
1931
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -1854,8 +1940,7 @@ var BaseTransactionRequest = class {
|
|
1854
1940
|
amount,
|
1855
1941
|
assetId,
|
1856
1942
|
txPointer: "0x00000000000000000000000000000000",
|
1857
|
-
witnessIndex
|
1858
|
-
predicate: predicate?.bytes
|
1943
|
+
witnessIndex
|
1859
1944
|
};
|
1860
1945
|
this.pushInput(input);
|
1861
1946
|
this.addChangeOutput(owner, assetId);
|
@@ -1868,11 +1953,11 @@ var BaseTransactionRequest = class {
|
|
1868
1953
|
* @param predicate - Predicate bytes.
|
1869
1954
|
* @param predicateData - Predicate data bytes.
|
1870
1955
|
*/
|
1871
|
-
addMessageInput(message
|
1956
|
+
addMessageInput(message) {
|
1872
1957
|
const { recipient, sender, amount } = message;
|
1873
1958
|
const assetId = BaseAssetId2;
|
1874
1959
|
let witnessIndex;
|
1875
|
-
if (predicate) {
|
1960
|
+
if (message.predicate) {
|
1876
1961
|
witnessIndex = 0;
|
1877
1962
|
} else {
|
1878
1963
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -1886,8 +1971,7 @@ var BaseTransactionRequest = class {
|
|
1886
1971
|
sender: sender.toB256(),
|
1887
1972
|
recipient: recipient.toB256(),
|
1888
1973
|
amount,
|
1889
|
-
witnessIndex
|
1890
|
-
predicate: predicate?.bytes
|
1974
|
+
witnessIndex
|
1891
1975
|
};
|
1892
1976
|
this.pushInput(input);
|
1893
1977
|
this.addChangeOutput(recipient, assetId);
|
@@ -1918,32 +2002,6 @@ var BaseTransactionRequest = class {
|
|
1918
2002
|
resources.forEach((resource) => this.addResource(resource));
|
1919
2003
|
return this;
|
1920
2004
|
}
|
1921
|
-
/**
|
1922
|
-
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
1923
|
-
* outputs from the related assetIds.
|
1924
|
-
*
|
1925
|
-
* @param resources - The resources to add.
|
1926
|
-
* @returns This transaction.
|
1927
|
-
*/
|
1928
|
-
addPredicateResource(resource, predicate) {
|
1929
|
-
if (isCoin(resource)) {
|
1930
|
-
this.addCoinInput(resource, predicate);
|
1931
|
-
} else {
|
1932
|
-
this.addMessageInput(resource, predicate);
|
1933
|
-
}
|
1934
|
-
return this;
|
1935
|
-
}
|
1936
|
-
/**
|
1937
|
-
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
1938
|
-
* from the related assetIds.
|
1939
|
-
*
|
1940
|
-
* @param resources - The resources to add.
|
1941
|
-
* @returns This transaction.
|
1942
|
-
*/
|
1943
|
-
addPredicateResources(resources, predicate) {
|
1944
|
-
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
1945
|
-
return this;
|
1946
|
-
}
|
1947
2005
|
/**
|
1948
2006
|
* Adds a coin output to the transaction.
|
1949
2007
|
*
|
@@ -2023,7 +2081,7 @@ var BaseTransactionRequest = class {
|
|
2023
2081
|
}
|
2024
2082
|
calculateMaxGas(chainInfo, minGas) {
|
2025
2083
|
const { consensusParameters } = chainInfo;
|
2026
|
-
const { gasPerByte } = consensusParameters;
|
2084
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2027
2085
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2028
2086
|
(acc, wit) => acc + wit.dataLength,
|
2029
2087
|
0
|
@@ -2032,7 +2090,8 @@ var BaseTransactionRequest = class {
|
|
2032
2090
|
gasPerByte,
|
2033
2091
|
minGas,
|
2034
2092
|
witnessesLength,
|
2035
|
-
witnessLimit: this.witnessLimit
|
2093
|
+
witnessLimit: this.witnessLimit,
|
2094
|
+
maxGasPerTx
|
2036
2095
|
});
|
2037
2096
|
}
|
2038
2097
|
/**
|
@@ -2050,17 +2109,20 @@ var BaseTransactionRequest = class {
|
|
2050
2109
|
});
|
2051
2110
|
const updateAssetInput = (assetId, quantity) => {
|
2052
2111
|
const assetInput = findAssetInput(assetId);
|
2112
|
+
let usedQuantity = quantity;
|
2113
|
+
if (assetId === BaseAssetId2) {
|
2114
|
+
usedQuantity = bn7("1000000000000000000");
|
2115
|
+
}
|
2053
2116
|
if (assetInput && "assetId" in assetInput) {
|
2054
2117
|
assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
|
2055
|
-
assetInput.amount =
|
2118
|
+
assetInput.amount = usedQuantity;
|
2056
2119
|
} else {
|
2057
2120
|
this.addResources([
|
2058
2121
|
{
|
2059
2122
|
id: hexlify7(randomBytes(UTXO_ID_LEN2)),
|
2060
|
-
amount:
|
2123
|
+
amount: usedQuantity,
|
2061
2124
|
assetId,
|
2062
2125
|
owner: resourcesOwner || Address.fromRandom(),
|
2063
|
-
maturity: 0,
|
2064
2126
|
blockCreated: bn7(1),
|
2065
2127
|
txCreatedIdx: bn7(1)
|
2066
2128
|
}
|
@@ -2092,7 +2154,7 @@ var BaseTransactionRequest = class {
|
|
2092
2154
|
toJSON() {
|
2093
2155
|
return normalizeJSON(this);
|
2094
2156
|
}
|
2095
|
-
|
2157
|
+
updatePredicateGasUsed(inputs) {
|
2096
2158
|
this.inputs.forEach((i) => {
|
2097
2159
|
let correspondingInput;
|
2098
2160
|
switch (i.type) {
|
@@ -2114,6 +2176,15 @@ var BaseTransactionRequest = class {
|
|
2114
2176
|
}
|
2115
2177
|
});
|
2116
2178
|
}
|
2179
|
+
shiftPredicateData() {
|
2180
|
+
this.inputs.forEach((input) => {
|
2181
|
+
if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
|
2182
|
+
input.predicateData = input.paddPredicateData(
|
2183
|
+
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2184
|
+
);
|
2185
|
+
}
|
2186
|
+
});
|
2187
|
+
}
|
2117
2188
|
};
|
2118
2189
|
|
2119
2190
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2260,9 +2331,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2260
2331
|
return {
|
2261
2332
|
type: TransactionType3.Create,
|
2262
2333
|
...baseTransaction,
|
2263
|
-
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2264
2334
|
bytecodeWitnessIndex,
|
2265
|
-
storageSlotsCount: storageSlots.length,
|
2335
|
+
storageSlotsCount: bn9(storageSlots.length),
|
2266
2336
|
salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
|
2267
2337
|
storageSlots
|
2268
2338
|
};
|
@@ -2385,8 +2455,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2385
2455
|
type: TransactionType4.Script,
|
2386
2456
|
scriptGasLimit: this.gasLimit,
|
2387
2457
|
...super.getBaseTransaction(),
|
2388
|
-
scriptLength: script.length,
|
2389
|
-
scriptDataLength: scriptData.length,
|
2458
|
+
scriptLength: bn10(script.length),
|
2459
|
+
scriptDataLength: bn10(scriptData.length),
|
2390
2460
|
receiptsRoot: ZeroBytes327,
|
2391
2461
|
script: hexlify10(script),
|
2392
2462
|
scriptData: hexlify10(scriptData)
|
@@ -2450,7 +2520,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2450
2520
|
}
|
2451
2521
|
calculateMaxGas(chainInfo, minGas) {
|
2452
2522
|
const { consensusParameters } = chainInfo;
|
2453
|
-
const { gasPerByte } = consensusParameters;
|
2523
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2454
2524
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2455
2525
|
(acc, wit) => acc + wit.dataLength,
|
2456
2526
|
0
|
@@ -2460,7 +2530,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2460
2530
|
minGas,
|
2461
2531
|
witnessesLength,
|
2462
2532
|
witnessLimit: this.witnessLimit,
|
2463
|
-
gasLimit: this.gasLimit
|
2533
|
+
gasLimit: this.gasLimit,
|
2534
|
+
maxGasPerTx
|
2464
2535
|
});
|
2465
2536
|
}
|
2466
2537
|
/**
|
@@ -2517,7 +2588,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2517
2588
|
|
2518
2589
|
// src/providers/transaction-request/utils.ts
|
2519
2590
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2520
|
-
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2591
|
+
import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
|
2521
2592
|
var transactionRequestify = (obj) => {
|
2522
2593
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2523
2594
|
return obj;
|
@@ -2535,14 +2606,31 @@ var transactionRequestify = (obj) => {
|
|
2535
2606
|
}
|
2536
2607
|
}
|
2537
2608
|
};
|
2609
|
+
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2610
|
+
(acc, input) => {
|
2611
|
+
if (input.type === InputType5.Coin && input.owner === owner) {
|
2612
|
+
acc.utxos.push(input.id);
|
2613
|
+
}
|
2614
|
+
if (input.type === InputType5.Message && input.recipient === owner) {
|
2615
|
+
acc.messages.push(input.nonce);
|
2616
|
+
}
|
2617
|
+
return acc;
|
2618
|
+
},
|
2619
|
+
{
|
2620
|
+
utxos: [],
|
2621
|
+
messages: []
|
2622
|
+
}
|
2623
|
+
);
|
2538
2624
|
|
2539
2625
|
// src/providers/transaction-response/transaction-response.ts
|
2540
2626
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2541
|
-
import { bn as
|
2627
|
+
import { bn as bn15 } from "@fuel-ts/math";
|
2542
2628
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2543
2629
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2544
2630
|
|
2545
2631
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2632
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
2633
|
+
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2546
2634
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2547
2635
|
|
2548
2636
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
@@ -2551,9 +2639,10 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
|
|
2551
2639
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2552
2640
|
var calculateTransactionFee = (params) => {
|
2553
2641
|
const {
|
2554
|
-
|
2642
|
+
gasPrice,
|
2555
2643
|
rawPayload,
|
2556
|
-
|
2644
|
+
tip,
|
2645
|
+
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2557
2646
|
} = params;
|
2558
2647
|
const gasPerByte = bn11(feeParams.gasPerByte);
|
2559
2648
|
const gasPriceFactor = bn11(feeParams.gasPriceFactor);
|
@@ -2563,8 +2652,7 @@ var calculateTransactionFee = (params) => {
|
|
2563
2652
|
return {
|
2564
2653
|
fee: bn11(0),
|
2565
2654
|
minFee: bn11(0),
|
2566
|
-
maxFee: bn11(0)
|
2567
|
-
feeFromGasUsed: bn11(0)
|
2655
|
+
maxFee: bn11(0)
|
2568
2656
|
};
|
2569
2657
|
}
|
2570
2658
|
const { type, witnesses, inputs, policies } = transaction;
|
@@ -2596,7 +2684,6 @@ var calculateTransactionFee = (params) => {
|
|
2596
2684
|
metadataGas,
|
2597
2685
|
txBytesSize: transactionBytes.length
|
2598
2686
|
});
|
2599
|
-
const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
|
2600
2687
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
|
2601
2688
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2602
2689
|
const maxGas = getMaxGas({
|
@@ -2604,17 +2691,25 @@ var calculateTransactionFee = (params) => {
|
|
2604
2691
|
minGas,
|
2605
2692
|
witnessesLength,
|
2606
2693
|
gasLimit,
|
2607
|
-
witnessLimit
|
2694
|
+
witnessLimit,
|
2695
|
+
maxGasPerTx
|
2696
|
+
});
|
2697
|
+
const minFee = calculateGasFee({
|
2698
|
+
gasPrice,
|
2699
|
+
gas: minGas,
|
2700
|
+
priceFactor: gasPriceFactor,
|
2701
|
+
tip
|
2702
|
+
});
|
2703
|
+
const maxFee = calculateGasFee({
|
2704
|
+
gasPrice,
|
2705
|
+
gas: maxGas,
|
2706
|
+
priceFactor: gasPriceFactor,
|
2707
|
+
tip
|
2608
2708
|
});
|
2609
|
-
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
2610
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
2611
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
2612
|
-
const fee = minFee.add(feeFromGasUsed);
|
2613
2709
|
return {
|
2614
|
-
fee,
|
2615
2710
|
minFee,
|
2616
2711
|
maxFee,
|
2617
|
-
|
2712
|
+
fee: maxFee
|
2618
2713
|
};
|
2619
2714
|
};
|
2620
2715
|
|
@@ -2670,7 +2765,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2670
2765
|
|
2671
2766
|
// src/providers/transaction-summary/input.ts
|
2672
2767
|
import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2673
|
-
import { InputType as
|
2768
|
+
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
2674
2769
|
function getInputsByTypes(inputs, types) {
|
2675
2770
|
return inputs.filter((i) => types.includes(i.type));
|
2676
2771
|
}
|
@@ -2678,16 +2773,16 @@ function getInputsByType(inputs, type) {
|
|
2678
2773
|
return inputs.filter((i) => i.type === type);
|
2679
2774
|
}
|
2680
2775
|
function getInputsCoin(inputs) {
|
2681
|
-
return getInputsByType(inputs,
|
2776
|
+
return getInputsByType(inputs, InputType6.Coin);
|
2682
2777
|
}
|
2683
2778
|
function getInputsMessage(inputs) {
|
2684
|
-
return getInputsByType(inputs,
|
2779
|
+
return getInputsByType(inputs, InputType6.Message);
|
2685
2780
|
}
|
2686
2781
|
function getInputsCoinAndMessage(inputs) {
|
2687
|
-
return getInputsByTypes(inputs, [
|
2782
|
+
return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
|
2688
2783
|
}
|
2689
2784
|
function getInputsContract(inputs) {
|
2690
|
-
return getInputsByType(inputs,
|
2785
|
+
return getInputsByType(inputs, InputType6.Contract);
|
2691
2786
|
}
|
2692
2787
|
function getInputFromAssetId(inputs, assetId) {
|
2693
2788
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2706,7 +2801,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2706
2801
|
if (!contractInput) {
|
2707
2802
|
return void 0;
|
2708
2803
|
}
|
2709
|
-
if (contractInput.type !==
|
2804
|
+
if (contractInput.type !== InputType6.Contract) {
|
2710
2805
|
throw new FuelError9(
|
2711
2806
|
ErrorCode9.INVALID_TRANSACTION_INPUT,
|
2712
2807
|
`Contract input should be of type 'contract'.`
|
@@ -2715,10 +2810,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2715
2810
|
return contractInput;
|
2716
2811
|
}
|
2717
2812
|
function getInputAccountAddress(input) {
|
2718
|
-
if (input.type ===
|
2813
|
+
if (input.type === InputType6.Coin) {
|
2719
2814
|
return input.owner.toString();
|
2720
2815
|
}
|
2721
|
-
if (input.type ===
|
2816
|
+
if (input.type === InputType6.Message) {
|
2722
2817
|
return input.recipient.toString();
|
2723
2818
|
}
|
2724
2819
|
return "";
|
@@ -3181,7 +3276,9 @@ function assembleTransactionSummary(params) {
|
|
3181
3276
|
gqlTransactionStatus,
|
3182
3277
|
abiMap = {},
|
3183
3278
|
maxInputs,
|
3184
|
-
gasCosts
|
3279
|
+
gasCosts,
|
3280
|
+
maxGasPerTx,
|
3281
|
+
gasPrice
|
3185
3282
|
} = params;
|
3186
3283
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3187
3284
|
const rawPayload = hexlify11(transactionBytes);
|
@@ -3195,11 +3292,14 @@ function assembleTransactionSummary(params) {
|
|
3195
3292
|
maxInputs
|
3196
3293
|
});
|
3197
3294
|
const typeName = getTransactionTypeName(transaction.type);
|
3295
|
+
const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3198
3296
|
const { fee } = calculateTransactionFee({
|
3199
|
-
|
3297
|
+
gasPrice,
|
3200
3298
|
rawPayload,
|
3299
|
+
tip,
|
3201
3300
|
consensusParameters: {
|
3202
3301
|
gasCosts,
|
3302
|
+
maxGasPerTx,
|
3203
3303
|
feeParams: {
|
3204
3304
|
gasPerByte,
|
3205
3305
|
gasPriceFactor
|
@@ -3259,7 +3359,7 @@ var TransactionResponse = class {
|
|
3259
3359
|
/** Current provider */
|
3260
3360
|
provider;
|
3261
3361
|
/** Gas used on the transaction */
|
3262
|
-
gasUsed =
|
3362
|
+
gasUsed = bn15(0);
|
3263
3363
|
/** The graphql Transaction with receipts object. */
|
3264
3364
|
gqlTransaction;
|
3265
3365
|
abis;
|
@@ -3337,8 +3437,13 @@ var TransactionResponse = class {
|
|
3337
3437
|
const decodedTransaction = this.decodeTransaction(
|
3338
3438
|
transaction
|
3339
3439
|
);
|
3340
|
-
|
3341
|
-
|
3440
|
+
let txReceipts = [];
|
3441
|
+
if (transaction?.status && "receipts" in transaction.status) {
|
3442
|
+
txReceipts = transaction.status.receipts;
|
3443
|
+
}
|
3444
|
+
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3445
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3446
|
+
const gasPrice = await this.provider.getLatestGasPrice();
|
3342
3447
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3343
3448
|
const transactionSummary = assembleTransactionSummary({
|
3344
3449
|
id: this.id,
|
@@ -3350,7 +3455,9 @@ var TransactionResponse = class {
|
|
3350
3455
|
gasPriceFactor,
|
3351
3456
|
abiMap: contractsAbiMap,
|
3352
3457
|
maxInputs,
|
3353
|
-
gasCosts
|
3458
|
+
gasCosts,
|
3459
|
+
maxGasPerTx,
|
3460
|
+
gasPrice
|
3354
3461
|
});
|
3355
3462
|
return transactionSummary;
|
3356
3463
|
}
|
@@ -3477,29 +3584,29 @@ var processGqlChain = (chain) => {
|
|
3477
3584
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3478
3585
|
return {
|
3479
3586
|
name,
|
3480
|
-
baseChainHeight:
|
3587
|
+
baseChainHeight: bn16(daHeight),
|
3481
3588
|
consensusParameters: {
|
3482
|
-
contractMaxSize:
|
3483
|
-
maxInputs:
|
3484
|
-
maxOutputs:
|
3485
|
-
maxWitnesses:
|
3486
|
-
maxGasPerTx:
|
3487
|
-
maxScriptLength:
|
3488
|
-
maxScriptDataLength:
|
3489
|
-
maxStorageSlots:
|
3490
|
-
maxPredicateLength:
|
3491
|
-
maxPredicateDataLength:
|
3492
|
-
maxGasPerPredicate:
|
3493
|
-
gasPriceFactor:
|
3494
|
-
gasPerByte:
|
3495
|
-
maxMessageDataLength:
|
3496
|
-
chainId:
|
3589
|
+
contractMaxSize: bn16(contractParams.contractMaxSize),
|
3590
|
+
maxInputs: bn16(txParams.maxInputs),
|
3591
|
+
maxOutputs: bn16(txParams.maxOutputs),
|
3592
|
+
maxWitnesses: bn16(txParams.maxWitnesses),
|
3593
|
+
maxGasPerTx: bn16(txParams.maxGasPerTx),
|
3594
|
+
maxScriptLength: bn16(scriptParams.maxScriptLength),
|
3595
|
+
maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
|
3596
|
+
maxStorageSlots: bn16(contractParams.maxStorageSlots),
|
3597
|
+
maxPredicateLength: bn16(predicateParams.maxPredicateLength),
|
3598
|
+
maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
|
3599
|
+
maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
|
3600
|
+
gasPriceFactor: bn16(feeParams.gasPriceFactor),
|
3601
|
+
gasPerByte: bn16(feeParams.gasPerByte),
|
3602
|
+
maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
|
3603
|
+
chainId: bn16(consensusParameters.chainId),
|
3497
3604
|
gasCosts
|
3498
3605
|
},
|
3499
3606
|
gasCosts,
|
3500
3607
|
latestBlock: {
|
3501
3608
|
id: latestBlock.id,
|
3502
|
-
height:
|
3609
|
+
height: bn16(latestBlock.height),
|
3503
3610
|
time: latestBlock.header.time,
|
3504
3611
|
transactions: latestBlock.transactions.map((i) => ({
|
3505
3612
|
id: i.id
|
@@ -3593,10 +3700,8 @@ var _Provider = class {
|
|
3593
3700
|
* Returns some helpful parameters related to gas fees.
|
3594
3701
|
*/
|
3595
3702
|
getGasConfig() {
|
3596
|
-
const { minGasPrice } = this.getNode();
|
3597
3703
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3598
3704
|
return {
|
3599
|
-
minGasPrice,
|
3600
3705
|
maxGasPerTx,
|
3601
3706
|
maxGasPerPredicate,
|
3602
3707
|
gasPriceFactor,
|
@@ -3672,6 +3777,21 @@ var _Provider = class {
|
|
3672
3777
|
} = await this.operations.getVersion();
|
3673
3778
|
return nodeVersion;
|
3674
3779
|
}
|
3780
|
+
/**
|
3781
|
+
* @hidden
|
3782
|
+
*
|
3783
|
+
* Returns the network configuration of the connected Fuel node.
|
3784
|
+
*
|
3785
|
+
* @returns A promise that resolves to the network configuration object
|
3786
|
+
*/
|
3787
|
+
async getNetwork() {
|
3788
|
+
const {
|
3789
|
+
name,
|
3790
|
+
consensusParameters: { chainId }
|
3791
|
+
} = await this.getChain();
|
3792
|
+
const network = new Network(name, chainId.toNumber());
|
3793
|
+
return Promise.resolve(network);
|
3794
|
+
}
|
3675
3795
|
/**
|
3676
3796
|
* Returns the block number.
|
3677
3797
|
*
|
@@ -3679,7 +3799,7 @@ var _Provider = class {
|
|
3679
3799
|
*/
|
3680
3800
|
async getBlockNumber() {
|
3681
3801
|
const { chain } = await this.operations.getChain();
|
3682
|
-
return
|
3802
|
+
return bn16(chain.latestBlock.height, 10);
|
3683
3803
|
}
|
3684
3804
|
/**
|
3685
3805
|
* Returns the chain information.
|
@@ -3689,13 +3809,11 @@ var _Provider = class {
|
|
3689
3809
|
async fetchNode() {
|
3690
3810
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3691
3811
|
const processedNodeInfo = {
|
3692
|
-
maxDepth:
|
3693
|
-
maxTx:
|
3694
|
-
minGasPrice: bn15(nodeInfo.minGasPrice),
|
3812
|
+
maxDepth: bn16(nodeInfo.maxDepth),
|
3813
|
+
maxTx: bn16(nodeInfo.maxTx),
|
3695
3814
|
nodeVersion: nodeInfo.nodeVersion,
|
3696
3815
|
utxoValidation: nodeInfo.utxoValidation,
|
3697
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
3698
|
-
peers: nodeInfo.peers
|
3816
|
+
vmBacktrace: nodeInfo.vmBacktrace
|
3699
3817
|
};
|
3700
3818
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
3701
3819
|
return processedNodeInfo;
|
@@ -3781,14 +3899,13 @@ var _Provider = class {
|
|
3781
3899
|
return this.estimateTxDependencies(transactionRequest);
|
3782
3900
|
}
|
3783
3901
|
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
3784
|
-
const { dryRun:
|
3785
|
-
encodedTransaction,
|
3902
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
3903
|
+
encodedTransactions: encodedTransaction,
|
3786
3904
|
utxoValidation: utxoValidation || false
|
3787
3905
|
});
|
3788
|
-
const receipts =
|
3789
|
-
|
3790
|
-
|
3791
|
-
};
|
3906
|
+
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
3907
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
3908
|
+
return { receipts, dryrunStatus: status };
|
3792
3909
|
}
|
3793
3910
|
/**
|
3794
3911
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -3814,7 +3931,7 @@ var _Provider = class {
|
|
3814
3931
|
} = response;
|
3815
3932
|
if (inputs) {
|
3816
3933
|
inputs.forEach((input, index) => {
|
3817
|
-
if ("predicateGasUsed" in input &&
|
3934
|
+
if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
|
3818
3935
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3819
3936
|
}
|
3820
3937
|
});
|
@@ -3827,9 +3944,6 @@ var _Provider = class {
|
|
3827
3944
|
* If there are missing variable outputs,
|
3828
3945
|
* `addVariableOutputs` is called on the transaction.
|
3829
3946
|
*
|
3830
|
-
* @privateRemarks
|
3831
|
-
* TODO: Investigate support for missing contract IDs
|
3832
|
-
* TODO: Add support for missing output messages
|
3833
3947
|
*
|
3834
3948
|
* @param transactionRequest - The transaction request object.
|
3835
3949
|
* @returns A promise.
|
@@ -3842,16 +3956,19 @@ var _Provider = class {
|
|
3842
3956
|
missingContractIds: []
|
3843
3957
|
};
|
3844
3958
|
}
|
3845
|
-
await this.estimatePredicates(transactionRequest);
|
3846
3959
|
let receipts = [];
|
3847
3960
|
const missingContractIds = [];
|
3848
3961
|
let outputVariables = 0;
|
3962
|
+
let dryrunStatus;
|
3849
3963
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3850
|
-
const {
|
3851
|
-
|
3964
|
+
const {
|
3965
|
+
dryRun: [{ receipts: rawReceipts, status }]
|
3966
|
+
} = await this.operations.dryRun({
|
3967
|
+
encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
|
3852
3968
|
utxoValidation: false
|
3853
3969
|
});
|
3854
|
-
receipts =
|
3970
|
+
receipts = rawReceipts.map(processGqlReceipt);
|
3971
|
+
dryrunStatus = status;
|
3855
3972
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
3856
3973
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
3857
3974
|
if (hasMissingOutputs) {
|
@@ -3861,6 +3978,10 @@ var _Provider = class {
|
|
3861
3978
|
transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
|
3862
3979
|
missingContractIds.push(contractId);
|
3863
3980
|
});
|
3981
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
3982
|
+
transactionRequest
|
3983
|
+
});
|
3984
|
+
transactionRequest.maxFee = maxFee;
|
3864
3985
|
} else {
|
3865
3986
|
break;
|
3866
3987
|
}
|
@@ -3868,37 +3989,139 @@ var _Provider = class {
|
|
3868
3989
|
return {
|
3869
3990
|
receipts,
|
3870
3991
|
outputVariables,
|
3871
|
-
missingContractIds
|
3992
|
+
missingContractIds,
|
3993
|
+
dryrunStatus
|
3872
3994
|
};
|
3873
3995
|
}
|
3996
|
+
/**
|
3997
|
+
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
3998
|
+
*
|
3999
|
+
* Transactions are dry run in batches. After each dry run, transactions requiring
|
4000
|
+
* further modifications are identified. The method iteratively updates these transactions
|
4001
|
+
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
4002
|
+
*
|
4003
|
+
* @param transactionRequests - Array of transaction request objects.
|
4004
|
+
* @returns A promise that resolves to an array of results for each transaction.
|
4005
|
+
*/
|
4006
|
+
async estimateMultipleTxDependencies(transactionRequests) {
|
4007
|
+
const results = transactionRequests.map(() => ({
|
4008
|
+
receipts: [],
|
4009
|
+
outputVariables: 0,
|
4010
|
+
missingContractIds: [],
|
4011
|
+
dryrunStatus: void 0
|
4012
|
+
}));
|
4013
|
+
const allRequests = clone3(transactionRequests);
|
4014
|
+
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4015
|
+
allRequests.forEach((req, index) => {
|
4016
|
+
if (req.type === TransactionType8.Script) {
|
4017
|
+
serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
|
4018
|
+
}
|
4019
|
+
});
|
4020
|
+
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
4021
|
+
let attempt = 0;
|
4022
|
+
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
4023
|
+
const encodedTransactions = transactionsToProcess.map(
|
4024
|
+
(index) => serializedTransactionsMap.get(index)
|
4025
|
+
);
|
4026
|
+
const dryRunResults = await this.operations.dryRun({
|
4027
|
+
encodedTransactions,
|
4028
|
+
utxoValidation: false
|
4029
|
+
});
|
4030
|
+
const nextRoundTransactions = [];
|
4031
|
+
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
4032
|
+
const currentResultIndex = transactionsToProcess[i];
|
4033
|
+
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4034
|
+
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
4035
|
+
results[currentResultIndex].dryrunStatus = status;
|
4036
|
+
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4037
|
+
results[currentResultIndex].receipts
|
4038
|
+
);
|
4039
|
+
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4040
|
+
const requestToProcess = allRequests[currentResultIndex];
|
4041
|
+
if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
|
4042
|
+
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
4043
|
+
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
4044
|
+
missingOutputContractIds.forEach(({ contractId }) => {
|
4045
|
+
requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
|
4046
|
+
results[currentResultIndex].missingContractIds.push(contractId);
|
4047
|
+
});
|
4048
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
4049
|
+
transactionRequest: requestToProcess
|
4050
|
+
});
|
4051
|
+
requestToProcess.maxFee = maxFee;
|
4052
|
+
serializedTransactionsMap.set(
|
4053
|
+
currentResultIndex,
|
4054
|
+
hexlify12(requestToProcess.toTransactionBytes())
|
4055
|
+
);
|
4056
|
+
nextRoundTransactions.push(currentResultIndex);
|
4057
|
+
allRequests[currentResultIndex] = requestToProcess;
|
4058
|
+
}
|
4059
|
+
}
|
4060
|
+
transactionsToProcess = nextRoundTransactions;
|
4061
|
+
attempt += 1;
|
4062
|
+
}
|
4063
|
+
return results;
|
4064
|
+
}
|
4065
|
+
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
4066
|
+
if (estimateTxDependencies) {
|
4067
|
+
return this.estimateMultipleTxDependencies(transactionRequests);
|
4068
|
+
}
|
4069
|
+
const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
|
4070
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4071
|
+
encodedTransactions,
|
4072
|
+
utxoValidation: utxoValidation || false
|
4073
|
+
});
|
4074
|
+
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4075
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
4076
|
+
return { receipts, dryrunStatus: status };
|
4077
|
+
});
|
4078
|
+
return results;
|
4079
|
+
}
|
3874
4080
|
/**
|
3875
4081
|
* Estimates the transaction gas and fee based on the provided transaction request.
|
3876
4082
|
* @param transactionRequest - The transaction request object.
|
3877
4083
|
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
3878
4084
|
*/
|
3879
|
-
estimateTxGasAndFee(params) {
|
4085
|
+
async estimateTxGasAndFee(params) {
|
3880
4086
|
const { transactionRequest } = params;
|
3881
|
-
|
4087
|
+
let { gasPrice } = params;
|
3882
4088
|
const chainInfo = this.getChain();
|
3883
|
-
const
|
3884
|
-
transactionRequest.gasPrice = gasPrice;
|
4089
|
+
const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
|
3885
4090
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
3886
|
-
|
4091
|
+
if (!gasPrice) {
|
4092
|
+
gasPrice = await this.estimateGasPrice(10);
|
4093
|
+
}
|
4094
|
+
const minFee = calculateGasFee({
|
4095
|
+
gasPrice: bn16(gasPrice),
|
4096
|
+
gas: minGas,
|
4097
|
+
priceFactor: gasPriceFactor,
|
4098
|
+
tip: transactionRequest.tip
|
4099
|
+
}).add(1);
|
4100
|
+
let gasLimit = bn16(0);
|
3887
4101
|
if (transactionRequest.type === TransactionType8.Script) {
|
4102
|
+
gasLimit = transactionRequest.gasLimit;
|
3888
4103
|
if (transactionRequest.gasLimit.eq(0)) {
|
3889
4104
|
transactionRequest.gasLimit = minGas;
|
3890
4105
|
transactionRequest.gasLimit = maxGasPerTx.sub(
|
3891
4106
|
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
3892
4107
|
);
|
4108
|
+
gasLimit = transactionRequest.gasLimit;
|
3893
4109
|
}
|
3894
4110
|
}
|
3895
4111
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
3896
|
-
const maxFee =
|
4112
|
+
const maxFee = calculateGasFee({
|
4113
|
+
gasPrice: bn16(gasPrice),
|
4114
|
+
gas: maxGas,
|
4115
|
+
priceFactor: gasPriceFactor,
|
4116
|
+
tip: transactionRequest.tip
|
4117
|
+
}).add(1);
|
3897
4118
|
return {
|
3898
4119
|
minGas,
|
3899
4120
|
minFee,
|
3900
4121
|
maxGas,
|
3901
|
-
maxFee
|
4122
|
+
maxFee,
|
4123
|
+
gasPrice,
|
4124
|
+
gasLimit
|
3902
4125
|
};
|
3903
4126
|
}
|
3904
4127
|
/**
|
@@ -3916,15 +4139,17 @@ var _Provider = class {
|
|
3916
4139
|
if (estimateTxDependencies) {
|
3917
4140
|
return this.estimateTxDependencies(transactionRequest);
|
3918
4141
|
}
|
3919
|
-
const
|
3920
|
-
const { dryRun:
|
3921
|
-
|
4142
|
+
const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
|
4143
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4144
|
+
encodedTransactions,
|
3922
4145
|
utxoValidation: true
|
3923
4146
|
});
|
3924
|
-
const
|
3925
|
-
|
3926
|
-
receipts
|
3927
|
-
|
4147
|
+
const callResult = dryRunStatuses.map((dryRunStatus) => {
|
4148
|
+
const { id, receipts, status } = dryRunStatus;
|
4149
|
+
const processedReceipts = receipts.map(processGqlReceipt);
|
4150
|
+
return { id, receipts: processedReceipts, status };
|
4151
|
+
});
|
4152
|
+
return { receipts: callResult[0].receipts };
|
3928
4153
|
}
|
3929
4154
|
/**
|
3930
4155
|
* Returns a transaction cost to enable user
|
@@ -3941,77 +4166,79 @@ var _Provider = class {
|
|
3941
4166
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
3942
4167
|
* @returns A promise that resolves to the transaction cost object.
|
3943
4168
|
*/
|
3944
|
-
async getTransactionCost(transactionRequestLike,
|
3945
|
-
estimateTxDependencies = true,
|
3946
|
-
estimatePredicates = true,
|
3947
|
-
resourcesOwner,
|
3948
|
-
signatureCallback
|
3949
|
-
} = {}) {
|
4169
|
+
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
3950
4170
|
const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
|
3951
|
-
const { minGasPrice } = this.getGasConfig();
|
3952
|
-
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
3953
4171
|
const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
|
3954
4172
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
3955
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
4173
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
3956
4174
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
4175
|
+
txRequestClone.maxFee = bn16(0);
|
3957
4176
|
if (isScriptTransaction) {
|
3958
|
-
txRequestClone.gasLimit =
|
4177
|
+
txRequestClone.gasLimit = bn16(0);
|
3959
4178
|
}
|
3960
|
-
if (
|
3961
|
-
|
3962
|
-
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
3963
|
-
}
|
3964
|
-
await this.estimatePredicates(txRequestClone);
|
4179
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4180
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
3965
4181
|
}
|
4182
|
+
const signedRequest = clone3(txRequestClone);
|
4183
|
+
let addedSignatures = 0;
|
3966
4184
|
if (signatureCallback && isScriptTransaction) {
|
3967
|
-
|
4185
|
+
const lengthBefore = signedRequest.witnesses.length;
|
4186
|
+
await signatureCallback(signedRequest);
|
4187
|
+
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
3968
4188
|
}
|
3969
|
-
|
3970
|
-
|
4189
|
+
await this.estimatePredicates(signedRequest);
|
4190
|
+
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
4191
|
+
transactionRequest: signedRequest
|
3971
4192
|
});
|
3972
4193
|
let receipts = [];
|
3973
4194
|
let missingContractIds = [];
|
3974
4195
|
let outputVariables = 0;
|
3975
|
-
let gasUsed =
|
3976
|
-
|
3977
|
-
|
4196
|
+
let gasUsed = bn16(0);
|
4197
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4198
|
+
txRequestClone.maxFee = maxFee;
|
4199
|
+
if (isScriptTransaction) {
|
4200
|
+
txRequestClone.gasLimit = gasLimit;
|
4201
|
+
if (signatureCallback) {
|
4202
|
+
await signatureCallback(txRequestClone);
|
4203
|
+
}
|
3978
4204
|
const result = await this.estimateTxDependencies(txRequestClone);
|
3979
4205
|
receipts = result.receipts;
|
3980
4206
|
outputVariables = result.outputVariables;
|
3981
4207
|
missingContractIds = result.missingContractIds;
|
3982
4208
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
3983
4209
|
txRequestClone.gasLimit = gasUsed;
|
3984
|
-
|
3985
|
-
|
3986
|
-
|
4210
|
+
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
4211
|
+
transactionRequest: txRequestClone,
|
4212
|
+
gasPrice
|
3987
4213
|
}));
|
3988
4214
|
}
|
3989
4215
|
return {
|
3990
4216
|
requiredQuantities: allQuantities,
|
3991
4217
|
receipts,
|
3992
4218
|
gasUsed,
|
3993
|
-
|
3994
|
-
gasPrice: setGasPrice,
|
4219
|
+
gasPrice,
|
3995
4220
|
minGas,
|
3996
4221
|
maxGas,
|
3997
4222
|
minFee,
|
3998
4223
|
maxFee,
|
3999
|
-
estimatedInputs: txRequestClone.inputs,
|
4000
4224
|
outputVariables,
|
4001
|
-
missingContractIds
|
4225
|
+
missingContractIds,
|
4226
|
+
addedSignatures,
|
4227
|
+
estimatedPredicates: txRequestClone.inputs
|
4002
4228
|
};
|
4003
4229
|
}
|
4004
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
4230
|
+
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
4005
4231
|
const ownerAddress = Address2.fromAddressOrString(owner);
|
4006
4232
|
const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
|
4007
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
4233
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, {
|
4234
|
+
quantitiesToContract
|
4235
|
+
});
|
4008
4236
|
transactionRequest.addResources(
|
4009
4237
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
4010
4238
|
);
|
4011
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4012
|
-
|
4013
|
-
|
4014
|
-
);
|
4239
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
|
4240
|
+
quantitiesToContract
|
4241
|
+
});
|
4015
4242
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
4016
4243
|
return {
|
4017
4244
|
resources,
|
@@ -4033,11 +4260,10 @@ var _Provider = class {
|
|
4033
4260
|
return coins.map((coin) => ({
|
4034
4261
|
id: coin.utxoId,
|
4035
4262
|
assetId: coin.assetId,
|
4036
|
-
amount:
|
4263
|
+
amount: bn16(coin.amount),
|
4037
4264
|
owner: Address2.fromAddressOrString(coin.owner),
|
4038
|
-
|
4039
|
-
|
4040
|
-
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4265
|
+
blockCreated: bn16(coin.blockCreated),
|
4266
|
+
txCreatedIdx: bn16(coin.txCreatedIdx)
|
4041
4267
|
}));
|
4042
4268
|
}
|
4043
4269
|
/**
|
@@ -4074,9 +4300,9 @@ var _Provider = class {
|
|
4074
4300
|
switch (coin.__typename) {
|
4075
4301
|
case "MessageCoin":
|
4076
4302
|
return {
|
4077
|
-
amount:
|
4303
|
+
amount: bn16(coin.amount),
|
4078
4304
|
assetId: coin.assetId,
|
4079
|
-
daHeight:
|
4305
|
+
daHeight: bn16(coin.daHeight),
|
4080
4306
|
sender: Address2.fromAddressOrString(coin.sender),
|
4081
4307
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4082
4308
|
nonce: coin.nonce
|
@@ -4084,12 +4310,11 @@ var _Provider = class {
|
|
4084
4310
|
case "Coin":
|
4085
4311
|
return {
|
4086
4312
|
id: coin.utxoId,
|
4087
|
-
amount:
|
4313
|
+
amount: bn16(coin.amount),
|
4088
4314
|
assetId: coin.assetId,
|
4089
4315
|
owner: Address2.fromAddressOrString(coin.owner),
|
4090
|
-
|
4091
|
-
|
4092
|
-
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4316
|
+
blockCreated: bn16(coin.blockCreated),
|
4317
|
+
txCreatedIdx: bn16(coin.txCreatedIdx)
|
4093
4318
|
};
|
4094
4319
|
default:
|
4095
4320
|
return null;
|
@@ -4106,13 +4331,13 @@ var _Provider = class {
|
|
4106
4331
|
async getBlock(idOrHeight) {
|
4107
4332
|
let variables;
|
4108
4333
|
if (typeof idOrHeight === "number") {
|
4109
|
-
variables = { height:
|
4334
|
+
variables = { height: bn16(idOrHeight).toString(10) };
|
4110
4335
|
} else if (idOrHeight === "latest") {
|
4111
4336
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4112
4337
|
} else if (idOrHeight.length === 66) {
|
4113
4338
|
variables = { blockId: idOrHeight };
|
4114
4339
|
} else {
|
4115
|
-
variables = { blockId:
|
4340
|
+
variables = { blockId: bn16(idOrHeight).toString(10) };
|
4116
4341
|
}
|
4117
4342
|
const { block } = await this.operations.getBlock(variables);
|
4118
4343
|
if (!block) {
|
@@ -4120,7 +4345,7 @@ var _Provider = class {
|
|
4120
4345
|
}
|
4121
4346
|
return {
|
4122
4347
|
id: block.id,
|
4123
|
-
height:
|
4348
|
+
height: bn16(block.height),
|
4124
4349
|
time: block.header.time,
|
4125
4350
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4126
4351
|
};
|
@@ -4135,7 +4360,7 @@ var _Provider = class {
|
|
4135
4360
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4136
4361
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4137
4362
|
id: block.id,
|
4138
|
-
height:
|
4363
|
+
height: bn16(block.height),
|
4139
4364
|
time: block.header.time,
|
4140
4365
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4141
4366
|
}));
|
@@ -4150,7 +4375,7 @@ var _Provider = class {
|
|
4150
4375
|
async getBlockWithTransactions(idOrHeight) {
|
4151
4376
|
let variables;
|
4152
4377
|
if (typeof idOrHeight === "number") {
|
4153
|
-
variables = { blockHeight:
|
4378
|
+
variables = { blockHeight: bn16(idOrHeight).toString(10) };
|
4154
4379
|
} else if (idOrHeight === "latest") {
|
4155
4380
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4156
4381
|
} else {
|
@@ -4162,7 +4387,7 @@ var _Provider = class {
|
|
4162
4387
|
}
|
4163
4388
|
return {
|
4164
4389
|
id: block.id,
|
4165
|
-
height:
|
4390
|
+
height: bn16(block.height, 10),
|
4166
4391
|
time: block.header.time,
|
4167
4392
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4168
4393
|
transactions: block.transactions.map(
|
@@ -4211,7 +4436,7 @@ var _Provider = class {
|
|
4211
4436
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4212
4437
|
asset: hexlify12(assetId)
|
4213
4438
|
});
|
4214
|
-
return
|
4439
|
+
return bn16(contractBalance.amount, 10);
|
4215
4440
|
}
|
4216
4441
|
/**
|
4217
4442
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4225,7 +4450,7 @@ var _Provider = class {
|
|
4225
4450
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4226
4451
|
assetId: hexlify12(assetId)
|
4227
4452
|
});
|
4228
|
-
return
|
4453
|
+
return bn16(balance.amount, 10);
|
4229
4454
|
}
|
4230
4455
|
/**
|
4231
4456
|
* Returns balances for the given owner.
|
@@ -4243,7 +4468,7 @@ var _Provider = class {
|
|
4243
4468
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4244
4469
|
return balances.map((balance) => ({
|
4245
4470
|
assetId: balance.assetId,
|
4246
|
-
amount:
|
4471
|
+
amount: bn16(balance.amount)
|
4247
4472
|
}));
|
4248
4473
|
}
|
4249
4474
|
/**
|
@@ -4265,15 +4490,15 @@ var _Provider = class {
|
|
4265
4490
|
sender: message.sender,
|
4266
4491
|
recipient: message.recipient,
|
4267
4492
|
nonce: message.nonce,
|
4268
|
-
amount:
|
4493
|
+
amount: bn16(message.amount),
|
4269
4494
|
data: message.data
|
4270
4495
|
}),
|
4271
4496
|
sender: Address2.fromAddressOrString(message.sender),
|
4272
4497
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4273
4498
|
nonce: message.nonce,
|
4274
|
-
amount:
|
4499
|
+
amount: bn16(message.amount),
|
4275
4500
|
data: InputMessageCoder.decodeData(message.data),
|
4276
|
-
daHeight:
|
4501
|
+
daHeight: bn16(message.daHeight)
|
4277
4502
|
}));
|
4278
4503
|
}
|
4279
4504
|
/**
|
@@ -4326,44 +4551,60 @@ var _Provider = class {
|
|
4326
4551
|
} = result.messageProof;
|
4327
4552
|
return {
|
4328
4553
|
messageProof: {
|
4329
|
-
proofIndex:
|
4554
|
+
proofIndex: bn16(messageProof.proofIndex),
|
4330
4555
|
proofSet: messageProof.proofSet
|
4331
4556
|
},
|
4332
4557
|
blockProof: {
|
4333
|
-
proofIndex:
|
4558
|
+
proofIndex: bn16(blockProof.proofIndex),
|
4334
4559
|
proofSet: blockProof.proofSet
|
4335
4560
|
},
|
4336
4561
|
messageBlockHeader: {
|
4337
4562
|
id: messageBlockHeader.id,
|
4338
|
-
daHeight:
|
4339
|
-
transactionsCount:
|
4563
|
+
daHeight: bn16(messageBlockHeader.daHeight),
|
4564
|
+
transactionsCount: bn16(messageBlockHeader.transactionsCount),
|
4340
4565
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4341
|
-
height:
|
4566
|
+
height: bn16(messageBlockHeader.height),
|
4342
4567
|
prevRoot: messageBlockHeader.prevRoot,
|
4343
4568
|
time: messageBlockHeader.time,
|
4344
4569
|
applicationHash: messageBlockHeader.applicationHash,
|
4345
|
-
|
4346
|
-
|
4570
|
+
messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount),
|
4571
|
+
messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
|
4572
|
+
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4573
|
+
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4574
|
+
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4347
4575
|
},
|
4348
4576
|
commitBlockHeader: {
|
4349
4577
|
id: commitBlockHeader.id,
|
4350
|
-
daHeight:
|
4351
|
-
transactionsCount:
|
4578
|
+
daHeight: bn16(commitBlockHeader.daHeight),
|
4579
|
+
transactionsCount: bn16(commitBlockHeader.transactionsCount),
|
4352
4580
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4353
|
-
height:
|
4581
|
+
height: bn16(commitBlockHeader.height),
|
4354
4582
|
prevRoot: commitBlockHeader.prevRoot,
|
4355
4583
|
time: commitBlockHeader.time,
|
4356
4584
|
applicationHash: commitBlockHeader.applicationHash,
|
4357
|
-
|
4358
|
-
|
4585
|
+
messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount),
|
4586
|
+
messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
|
4587
|
+
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4588
|
+
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4589
|
+
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4359
4590
|
},
|
4360
4591
|
sender: Address2.fromAddressOrString(sender),
|
4361
4592
|
recipient: Address2.fromAddressOrString(recipient),
|
4362
4593
|
nonce,
|
4363
|
-
amount:
|
4594
|
+
amount: bn16(amount),
|
4364
4595
|
data
|
4365
4596
|
};
|
4366
4597
|
}
|
4598
|
+
async getLatestGasPrice() {
|
4599
|
+
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4600
|
+
return bn16(latestGasPrice.gasPrice);
|
4601
|
+
}
|
4602
|
+
async estimateGasPrice(blockHorizon) {
|
4603
|
+
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4604
|
+
blockHorizon: String(blockHorizon)
|
4605
|
+
});
|
4606
|
+
return bn16(estimateGasPrice.gasPrice);
|
4607
|
+
}
|
4367
4608
|
/**
|
4368
4609
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
4369
4610
|
*
|
@@ -4383,10 +4624,10 @@ var _Provider = class {
|
|
4383
4624
|
*/
|
4384
4625
|
async produceBlocks(amount, startTime) {
|
4385
4626
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4386
|
-
blocksToProduce:
|
4627
|
+
blocksToProduce: bn16(amount).toString(10),
|
4387
4628
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4388
4629
|
});
|
4389
|
-
return
|
4630
|
+
return bn16(latestBlockHeight);
|
4390
4631
|
}
|
4391
4632
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4392
4633
|
async getTransactionResponse(transactionId) {
|
@@ -4400,7 +4641,7 @@ cacheInputs_fn = function(inputs) {
|
|
4400
4641
|
return;
|
4401
4642
|
}
|
4402
4643
|
inputs.forEach((input) => {
|
4403
|
-
if (input.type ===
|
4644
|
+
if (input.type === InputType7.Coin) {
|
4404
4645
|
this.cache?.set(input.id);
|
4405
4646
|
}
|
4406
4647
|
});
|
@@ -4410,7 +4651,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4410
4651
|
|
4411
4652
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4412
4653
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4413
|
-
import { bn as
|
4654
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
4414
4655
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4415
4656
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4416
4657
|
|
@@ -4656,36 +4897,33 @@ var Account = class extends AbstractAccount {
|
|
4656
4897
|
* @param fee - The estimated transaction fee.
|
4657
4898
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4658
4899
|
*/
|
4659
|
-
async fund(request,
|
4660
|
-
const
|
4661
|
-
|
4900
|
+
async fund(request, params) {
|
4901
|
+
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
4902
|
+
const txRequest = request;
|
4903
|
+
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
4904
|
+
amount: bn18(fee),
|
4662
4905
|
assetId: BaseAssetId3,
|
4663
|
-
coinQuantities
|
4906
|
+
coinQuantities: requiredQuantities
|
4664
4907
|
});
|
4665
4908
|
const quantitiesDict = {};
|
4666
|
-
|
4909
|
+
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
4667
4910
|
quantitiesDict[assetId] = {
|
4668
4911
|
required: amount,
|
4669
|
-
owned:
|
4912
|
+
owned: bn18(0)
|
4670
4913
|
};
|
4671
4914
|
});
|
4672
|
-
|
4673
|
-
const cachedMessages = [];
|
4674
|
-
const owner = this.address.toB256();
|
4675
|
-
request.inputs.forEach((input) => {
|
4915
|
+
txRequest.inputs.forEach((input) => {
|
4676
4916
|
const isResource = "amount" in input;
|
4677
4917
|
if (isResource) {
|
4678
4918
|
const isCoin2 = "owner" in input;
|
4679
4919
|
if (isCoin2) {
|
4680
4920
|
const assetId = String(input.assetId);
|
4681
|
-
if (
|
4682
|
-
const amount =
|
4921
|
+
if (quantitiesDict[assetId]) {
|
4922
|
+
const amount = bn18(input.amount);
|
4683
4923
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4684
|
-
cachedUtxos.push(input.id);
|
4685
4924
|
}
|
4686
|
-
} else if (input.
|
4925
|
+
} else if (input.amount && quantitiesDict[BaseAssetId3]) {
|
4687
4926
|
quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
|
4688
|
-
cachedMessages.push(input.nonce);
|
4689
4927
|
}
|
4690
4928
|
}
|
4691
4929
|
});
|
@@ -4700,12 +4938,23 @@ var Account = class extends AbstractAccount {
|
|
4700
4938
|
});
|
4701
4939
|
const needsToBeFunded = missingQuantities.length;
|
4702
4940
|
if (needsToBeFunded) {
|
4703
|
-
const
|
4704
|
-
|
4705
|
-
|
4706
|
-
|
4707
|
-
|
4941
|
+
const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
|
4942
|
+
const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
|
4943
|
+
txRequest.addResources(resources);
|
4944
|
+
}
|
4945
|
+
txRequest.shiftPredicateData();
|
4946
|
+
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
4947
|
+
const requestToBeReEstimate = clone4(txRequest);
|
4948
|
+
if (addedSignatures) {
|
4949
|
+
Array.from({ length: addedSignatures }).forEach(
|
4950
|
+
() => requestToBeReEstimate.addEmptyWitness()
|
4951
|
+
);
|
4708
4952
|
}
|
4953
|
+
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
4954
|
+
transactionRequest: requestToBeReEstimate
|
4955
|
+
});
|
4956
|
+
txRequest.maxFee = maxFee;
|
4957
|
+
return txRequest;
|
4709
4958
|
}
|
4710
4959
|
/**
|
4711
4960
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -4713,28 +4962,25 @@ var Account = class extends AbstractAccount {
|
|
4713
4962
|
* @param destination - The address of the destination.
|
4714
4963
|
* @param amount - The amount of coins to transfer.
|
4715
4964
|
* @param assetId - The asset ID of the coins to transfer.
|
4716
|
-
* @param txParams - The transaction parameters (gasLimit,
|
4965
|
+
* @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
|
4717
4966
|
* @returns A promise that resolves to the prepared transaction request.
|
4718
4967
|
*/
|
4719
4968
|
async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
4720
|
-
const
|
4721
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
4722
|
-
const request = new ScriptTransactionRequest(params);
|
4969
|
+
const request = new ScriptTransactionRequest(txParams);
|
4723
4970
|
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
|
4724
|
-
const
|
4971
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
4725
4972
|
estimateTxDependencies: true,
|
4726
4973
|
resourcesOwner: this
|
4727
4974
|
});
|
4728
|
-
|
4729
|
-
|
4730
|
-
|
4731
|
-
|
4732
|
-
|
4733
|
-
|
4734
|
-
|
4735
|
-
|
4736
|
-
await this.fund(request,
|
4737
|
-
request.updatePredicateInputs(estimatedInputs);
|
4975
|
+
if ("gasLimit" in txParams) {
|
4976
|
+
this.validateGas({
|
4977
|
+
gasUsed: txCost.gasUsed,
|
4978
|
+
gasLimit: request.gasLimit
|
4979
|
+
});
|
4980
|
+
}
|
4981
|
+
request.gasLimit = txCost.gasUsed;
|
4982
|
+
request.maxFee = txCost.maxFee;
|
4983
|
+
await this.fund(request, txCost);
|
4738
4984
|
return request;
|
4739
4985
|
}
|
4740
4986
|
/**
|
@@ -4747,7 +4993,7 @@ var Account = class extends AbstractAccount {
|
|
4747
4993
|
* @returns A promise that resolves to the transaction response.
|
4748
4994
|
*/
|
4749
4995
|
async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
4750
|
-
if (
|
4996
|
+
if (bn18(amount).lte(0)) {
|
4751
4997
|
throw new FuelError15(
|
4752
4998
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
4753
4999
|
"Transfer amount must be a positive number."
|
@@ -4766,38 +5012,37 @@ var Account = class extends AbstractAccount {
|
|
4766
5012
|
* @returns A promise that resolves to the transaction response.
|
4767
5013
|
*/
|
4768
5014
|
async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
|
4769
|
-
if (
|
5015
|
+
if (bn18(amount).lte(0)) {
|
4770
5016
|
throw new FuelError15(
|
4771
5017
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
4772
5018
|
"Transfer amount must be a positive number."
|
4773
5019
|
);
|
4774
5020
|
}
|
4775
5021
|
const contractAddress = Address3.fromAddressOrString(contractId);
|
4776
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
4777
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
4778
5022
|
const { script, scriptData } = await assembleTransferToContractScript({
|
4779
5023
|
hexlifiedContractId: contractAddress.toB256(),
|
4780
|
-
amountToTransfer:
|
5024
|
+
amountToTransfer: bn18(amount),
|
4781
5025
|
assetId
|
4782
5026
|
});
|
4783
5027
|
const request = new ScriptTransactionRequest({
|
4784
|
-
...
|
5028
|
+
...txParams,
|
4785
5029
|
script,
|
4786
5030
|
scriptData
|
4787
5031
|
});
|
4788
5032
|
request.addContractInputAndOutput(contractAddress);
|
4789
|
-
const
|
4790
|
-
|
4791
|
-
[{ amount:
|
4792
|
-
);
|
4793
|
-
request.gasLimit = bn17(params.gasLimit ?? gasUsed);
|
4794
|
-
this.validateGas({
|
4795
|
-
gasUsed,
|
4796
|
-
gasPrice: request.gasPrice,
|
4797
|
-
gasLimit: request.gasLimit,
|
4798
|
-
minGasPrice
|
5033
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
5034
|
+
resourcesOwner: this,
|
5035
|
+
quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
|
4799
5036
|
});
|
4800
|
-
|
5037
|
+
if (txParams.gasLimit) {
|
5038
|
+
this.validateGas({
|
5039
|
+
gasUsed: txCost.gasUsed,
|
5040
|
+
gasLimit: request.gasLimit
|
5041
|
+
});
|
5042
|
+
}
|
5043
|
+
request.gasLimit = txCost.gasUsed;
|
5044
|
+
request.maxFee = txCost.maxFee;
|
5045
|
+
await this.fund(request, txCost);
|
4801
5046
|
return this.sendTransaction(request);
|
4802
5047
|
}
|
4803
5048
|
/**
|
@@ -4809,34 +5054,31 @@ var Account = class extends AbstractAccount {
|
|
4809
5054
|
* @returns A promise that resolves to the transaction response.
|
4810
5055
|
*/
|
4811
5056
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4812
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
4813
5057
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
4814
5058
|
const recipientDataArray = arrayify14(
|
4815
5059
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
4816
5060
|
);
|
4817
5061
|
const amountDataArray = arrayify14(
|
4818
|
-
"0x".concat(
|
5062
|
+
"0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
|
4819
5063
|
);
|
4820
5064
|
const script = new Uint8Array([
|
4821
5065
|
...arrayify14(withdrawScript.bytes),
|
4822
5066
|
...recipientDataArray,
|
4823
5067
|
...amountDataArray
|
4824
5068
|
]);
|
4825
|
-
const params = { script,
|
5069
|
+
const params = { script, ...txParams };
|
4826
5070
|
const request = new ScriptTransactionRequest(params);
|
4827
|
-
const
|
4828
|
-
const
|
4829
|
-
|
4830
|
-
|
4831
|
-
|
4832
|
-
|
4833
|
-
|
4834
|
-
|
4835
|
-
|
4836
|
-
|
4837
|
-
|
4838
|
-
});
|
4839
|
-
await this.fund(request, requiredQuantities, maxFee);
|
5071
|
+
const quantitiesToContract = [{ amount: bn18(amount), assetId: BaseAssetId3 }];
|
5072
|
+
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5073
|
+
if (txParams.gasLimit) {
|
5074
|
+
this.validateGas({
|
5075
|
+
gasUsed: txCost.gasUsed,
|
5076
|
+
gasLimit: request.gasLimit
|
5077
|
+
});
|
5078
|
+
}
|
5079
|
+
request.maxFee = txCost.maxFee;
|
5080
|
+
request.gasLimit = txCost.gasUsed;
|
5081
|
+
await this.fund(request, txCost);
|
4840
5082
|
return this.sendTransaction(request);
|
4841
5083
|
}
|
4842
5084
|
async signMessage(message) {
|
@@ -4894,18 +5136,7 @@ var Account = class extends AbstractAccount {
|
|
4894
5136
|
}
|
4895
5137
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
4896
5138
|
}
|
4897
|
-
validateGas({
|
4898
|
-
gasUsed,
|
4899
|
-
gasPrice,
|
4900
|
-
gasLimit,
|
4901
|
-
minGasPrice
|
4902
|
-
}) {
|
4903
|
-
if (minGasPrice.gt(gasPrice)) {
|
4904
|
-
throw new FuelError15(
|
4905
|
-
ErrorCode15.GAS_PRICE_TOO_LOW,
|
4906
|
-
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
4907
|
-
);
|
4908
|
-
}
|
5139
|
+
validateGas({ gasUsed, gasLimit }) {
|
4909
5140
|
if (gasUsed.gt(gasLimit)) {
|
4910
5141
|
throw new FuelError15(
|
4911
5142
|
ErrorCode15.GAS_LIMIT_TOO_LOW,
|
@@ -5197,7 +5428,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5197
5428
|
* @param transactionRequestLike - The transaction request to send.
|
5198
5429
|
* @returns A promise that resolves to the TransactionResponse object.
|
5199
5430
|
*/
|
5200
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
5431
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
|
5201
5432
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5202
5433
|
if (estimateTxDependencies) {
|
5203
5434
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -5236,17 +5467,18 @@ var BaseWalletUnlocked = class extends Account {
|
|
5236
5467
|
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
5237
5468
|
|
5238
5469
|
// src/hdwallet/hdwallet.ts
|
5239
|
-
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
5240
5470
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5241
5471
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5242
|
-
import { bn as
|
5243
|
-
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5
|
5472
|
+
import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5473
|
+
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5474
|
+
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5244
5475
|
|
5245
5476
|
// src/mnemonic/mnemonic.ts
|
5246
|
-
import { randomBytes as randomBytes4
|
5477
|
+
import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
|
5247
5478
|
import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
|
5248
5479
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
5249
|
-
import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4
|
5480
|
+
import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
|
5481
|
+
import { dataSlice, pbkdf2, computeHmac, encodeBase58 } from "ethers";
|
5250
5482
|
|
5251
5483
|
// src/wordlists/words/english.ts
|
5252
5484
|
var english = [
|
@@ -7703,7 +7935,7 @@ var HDWallet = class {
|
|
7703
7935
|
const IR = bytes.slice(32);
|
7704
7936
|
if (privateKey) {
|
7705
7937
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7706
|
-
const ki =
|
7938
|
+
const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
|
7707
7939
|
return new HDWallet({
|
7708
7940
|
privateKey: ki,
|
7709
7941
|
chainCode: IR,
|
@@ -7769,8 +8001,7 @@ var HDWallet = class {
|
|
7769
8001
|
});
|
7770
8002
|
}
|
7771
8003
|
static fromExtendedKey(extendedKey) {
|
7772
|
-
|
7773
|
-
decoded = `${decoded.substring(0, 2)}0${decoded.substring(2)}`;
|
8004
|
+
const decoded = toBeHex(decodeBase58(extendedKey));
|
7774
8005
|
const bytes = arrayify18(decoded);
|
7775
8006
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
7776
8007
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
@@ -7975,14 +8206,15 @@ var seedTestWallet = async (wallet, quantities) => {
|
|
7975
8206
|
process.env.GENESIS_SECRET || randomBytes5(32),
|
7976
8207
|
wallet.provider
|
7977
8208
|
);
|
7978
|
-
const
|
7979
|
-
|
7980
|
-
|
7981
|
-
|
7982
|
-
gasPrice: minGasPrice
|
8209
|
+
const request = new ScriptTransactionRequest();
|
8210
|
+
quantities.forEach((quantity) => {
|
8211
|
+
const { amount, assetId } = coinQuantityfy(quantity);
|
8212
|
+
request.addCoinOutput(wallet.address, amount, assetId);
|
7983
8213
|
});
|
7984
|
-
|
7985
|
-
|
8214
|
+
const txCost = await genesisWallet.provider.getTransactionCost(request);
|
8215
|
+
request.gasLimit = txCost.gasUsed;
|
8216
|
+
request.maxFee = txCost.maxFee;
|
8217
|
+
await genesisWallet.fund(request, txCost);
|
7986
8218
|
await genesisWallet.sendTransaction(request, { awaitExecution: true });
|
7987
8219
|
};
|
7988
8220
|
|
@@ -7997,11 +8229,11 @@ var generateTestWallet = async (provider, quantities) => {
|
|
7997
8229
|
|
7998
8230
|
// src/test-utils/launchNode.ts
|
7999
8231
|
import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
|
8000
|
-
import {
|
8001
|
-
import { defaultChainConfig, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
|
8232
|
+
import { defaultChainConfigs, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
|
8002
8233
|
import { findBinPath } from "@fuel-ts/utils/cli-utils";
|
8003
8234
|
import { spawn } from "child_process";
|
8004
8235
|
import { randomUUID } from "crypto";
|
8236
|
+
import { randomBytes as randomBytes6 } from "ethers";
|
8005
8237
|
import { existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
|
8006
8238
|
import os from "os";
|
8007
8239
|
import path from "path";
|
@@ -8050,12 +8282,12 @@ var launchNode = async ({
|
|
8050
8282
|
// eslint-disable-next-line no-async-promise-executor
|
8051
8283
|
new Promise(async (resolve, reject) => {
|
8052
8284
|
const remainingArgs = extractRemainingArgs(args, [
|
8053
|
-
"--
|
8285
|
+
"--snapshot",
|
8054
8286
|
"--consensus-key",
|
8055
8287
|
"--db-type",
|
8056
8288
|
"--poa-instant"
|
8057
8289
|
]);
|
8058
|
-
const chainConfigPath = getFlagValueFromArgs(args, "--
|
8290
|
+
const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
|
8059
8291
|
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || defaultConsensusKey;
|
8060
8292
|
const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
|
8061
8293
|
const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
|
@@ -8074,36 +8306,54 @@ var launchNode = async ({
|
|
8074
8306
|
let chainConfigPathToUse;
|
8075
8307
|
const prefix = basePath || os.tmpdir();
|
8076
8308
|
const suffix = basePath ? "" : randomUUID();
|
8077
|
-
const tempDirPath = path.join(prefix, ".fuels", suffix);
|
8309
|
+
const tempDirPath = path.join(prefix, ".fuels", suffix, "chainConfigs");
|
8078
8310
|
if (chainConfigPath) {
|
8079
8311
|
chainConfigPathToUse = chainConfigPath;
|
8080
8312
|
} else {
|
8081
8313
|
if (!existsSync(tempDirPath)) {
|
8082
8314
|
mkdirSync(tempDirPath, { recursive: true });
|
8083
8315
|
}
|
8084
|
-
|
8085
|
-
|
8316
|
+
let { stateConfigJson } = defaultChainConfigs;
|
8317
|
+
const { chainConfigJson, metadataJson } = defaultChainConfigs;
|
8318
|
+
stateConfigJson = {
|
8319
|
+
...stateConfigJson,
|
8320
|
+
coins: [
|
8321
|
+
...stateConfigJson.coins.map((coin) => ({
|
8322
|
+
...coin,
|
8323
|
+
amount: "18446744073709551615"
|
8324
|
+
}))
|
8325
|
+
],
|
8326
|
+
messages: stateConfigJson.messages.map((message) => ({
|
8327
|
+
...message,
|
8328
|
+
amount: "18446744073709551615"
|
8329
|
+
}))
|
8330
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8331
|
+
};
|
8086
8332
|
if (!process.env.GENESIS_SECRET) {
|
8087
8333
|
const pk = Signer.generatePrivateKey();
|
8088
8334
|
const signer = new Signer(pk);
|
8089
8335
|
process.env.GENESIS_SECRET = hexlify18(pk);
|
8090
|
-
|
8091
|
-
|
8092
|
-
|
8093
|
-
|
8094
|
-
|
8095
|
-
|
8096
|
-
|
8097
|
-
|
8098
|
-
|
8099
|
-
|
8100
|
-
}
|
8101
|
-
]
|
8102
|
-
}
|
8103
|
-
};
|
8336
|
+
stateConfigJson.coins.push({
|
8337
|
+
tx_id: hexlify18(randomBytes6(34)),
|
8338
|
+
owner: signer.address.toHexString(),
|
8339
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8340
|
+
amount: "18446744073709551615",
|
8341
|
+
asset_id: BaseAssetId4,
|
8342
|
+
output_index: 0,
|
8343
|
+
tx_pointer_block_height: 0,
|
8344
|
+
tx_pointer_tx_idx: 0
|
8345
|
+
});
|
8104
8346
|
}
|
8105
|
-
|
8106
|
-
|
8347
|
+
let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
|
8348
|
+
const regexMakeNumber = /("amount":)"(\d+)"/gm;
|
8349
|
+
fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
|
8350
|
+
const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
|
8351
|
+
const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
|
8352
|
+
const metadataWritePath = path.join(tempDirPath, "metadata.json");
|
8353
|
+
writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
|
8354
|
+
writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
|
8355
|
+
writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
|
8356
|
+
chainConfigPathToUse = tempDirPath;
|
8107
8357
|
}
|
8108
8358
|
const child = spawn(
|
8109
8359
|
command,
|
@@ -8112,10 +8362,10 @@ var launchNode = async ({
|
|
8112
8362
|
["--ip", ipToUse],
|
8113
8363
|
["--port", portToUse],
|
8114
8364
|
useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
|
8115
|
-
["--min-gas-price", "
|
8365
|
+
["--min-gas-price", "1"],
|
8116
8366
|
poaInstant ? ["--poa-instant", "true"] : [],
|
8117
8367
|
["--consensus-key", consensusKey],
|
8118
|
-
["--
|
8368
|
+
["--snapshot", chainConfigPathToUse],
|
8119
8369
|
"--vm-backtrace",
|
8120
8370
|
"--utxo-validation",
|
8121
8371
|
"--debug",
|
@@ -8174,7 +8424,7 @@ var launchNodeAndGetWallets = async ({
|
|
8174
8424
|
walletCount = 10
|
8175
8425
|
} = {}) => {
|
8176
8426
|
const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
|
8177
|
-
const provider = await Provider.create(`http://${ip}:${port}/graphql`);
|
8427
|
+
const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
|
8178
8428
|
const wallets = await generateWallets(walletCount, provider);
|
8179
8429
|
const cleanup = () => {
|
8180
8430
|
closeNode();
|