@fuel-ts/account 0.0.0-rc-2021-20240425184301 → 0.0.0-rc-2152-20240425194419
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/README.md +1 -1
- package/dist/account.d.ts +6 -7
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +696 -1818
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +545 -796
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +421 -671
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +24 -12
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +359 -810
- 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 +2 -4
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +1 -7
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +27 -46
- 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 +28 -8
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +0 -3
- 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 +0 -2
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
- 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 +2 -8
- 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 +1189 -2540
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +532 -778
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +419 -665
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +16 -16
package/dist/test-utils.mjs
CHANGED
@@ -26,9 +26,8 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
|
|
26
26
|
import { Address as Address3 } from "@fuel-ts/address";
|
27
27
|
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
28
28
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
29
|
-
import { bn as
|
30
|
-
import { arrayify as arrayify14
|
31
|
-
import { clone as clone4 } from "ramda";
|
29
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
30
|
+
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
32
31
|
|
33
32
|
// src/providers/coin-quantity.ts
|
34
33
|
import { bn } from "@fuel-ts/math";
|
@@ -36,24 +35,24 @@ import { hexlify } from "@fuel-ts/utils";
|
|
36
35
|
var coinQuantityfy = (coinQuantityLike) => {
|
37
36
|
let assetId;
|
38
37
|
let amount;
|
39
|
-
let
|
38
|
+
let max2;
|
40
39
|
if (Array.isArray(coinQuantityLike)) {
|
41
40
|
amount = coinQuantityLike[0];
|
42
41
|
assetId = coinQuantityLike[1];
|
43
|
-
|
42
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
44
43
|
} else {
|
45
44
|
amount = coinQuantityLike.amount;
|
46
45
|
assetId = coinQuantityLike.assetId;
|
47
|
-
|
46
|
+
max2 = coinQuantityLike.max ?? void 0;
|
48
47
|
}
|
49
48
|
const bnAmount = bn(amount);
|
50
49
|
return {
|
51
50
|
assetId: hexlify(assetId),
|
52
51
|
amount: bnAmount.lt(1) ? bn(1) : bnAmount,
|
53
|
-
max:
|
52
|
+
max: max2 ? bn(max2) : void 0
|
54
53
|
};
|
55
54
|
};
|
56
|
-
var
|
55
|
+
var addAmountToAsset = (params) => {
|
57
56
|
const { amount, assetId } = params;
|
58
57
|
const coinQuantities = [...params.coinQuantities];
|
59
58
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -68,9 +67,9 @@ var addAmountToCoinQuantities = (params) => {
|
|
68
67
|
// src/providers/provider.ts
|
69
68
|
import { Address as Address2 } from "@fuel-ts/address";
|
70
69
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
71
|
-
import { BN, bn as
|
70
|
+
import { BN, bn as bn15, max } from "@fuel-ts/math";
|
72
71
|
import {
|
73
|
-
InputType as
|
72
|
+
InputType as InputType6,
|
74
73
|
TransactionType as TransactionType8,
|
75
74
|
InputMessageCoder,
|
76
75
|
TransactionCoder as TransactionCoder5
|
@@ -78,26 +77,21 @@ import {
|
|
78
77
|
import { arrayify as arrayify11, hexlify as hexlify12, DateTime as DateTime2 } from "@fuel-ts/utils";
|
79
78
|
import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
|
80
79
|
import { equalBytes } from "@noble/curves/abstract/utils";
|
81
|
-
import { Network } from "ethers";
|
82
80
|
import { GraphQLClient } from "graphql-request";
|
83
81
|
import { clone as clone3 } from "ramda";
|
84
82
|
|
85
83
|
// src/providers/__generated__/operations.ts
|
86
84
|
import gql from "graphql-tag";
|
87
|
-
var TransactionStatusSubscriptionFragmentFragmentDoc = gql`
|
88
|
-
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
89
|
-
type: __typename
|
90
|
-
... on SqueezedOutStatus {
|
91
|
-
reason
|
92
|
-
}
|
93
|
-
}
|
94
|
-
`;
|
95
85
|
var ReceiptFragmentFragmentDoc = gql`
|
96
86
|
fragment receiptFragment on Receipt {
|
97
|
-
|
87
|
+
contract {
|
88
|
+
id
|
89
|
+
}
|
98
90
|
pc
|
99
91
|
is
|
100
|
-
to
|
92
|
+
to {
|
93
|
+
id
|
94
|
+
}
|
101
95
|
toAddress
|
102
96
|
amount
|
103
97
|
assetId
|
@@ -135,16 +129,10 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
135
129
|
id
|
136
130
|
}
|
137
131
|
time
|
138
|
-
receipts {
|
139
|
-
...receiptFragment
|
140
|
-
}
|
141
132
|
programState {
|
142
133
|
returnType
|
143
134
|
data
|
144
135
|
}
|
145
|
-
receipts {
|
146
|
-
...receiptFragment
|
147
|
-
}
|
148
136
|
}
|
149
137
|
... on FailureStatus {
|
150
138
|
block {
|
@@ -152,24 +140,26 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
152
140
|
}
|
153
141
|
time
|
154
142
|
reason
|
155
|
-
receipts {
|
156
|
-
...receiptFragment
|
157
|
-
}
|
158
143
|
}
|
159
144
|
... on SqueezedOutStatus {
|
160
145
|
reason
|
161
146
|
}
|
162
147
|
}
|
163
|
-
|
148
|
+
`;
|
164
149
|
var TransactionFragmentFragmentDoc = gql`
|
165
150
|
fragment transactionFragment on Transaction {
|
166
151
|
id
|
167
152
|
rawPayload
|
153
|
+
gasPrice
|
154
|
+
receipts {
|
155
|
+
...receiptFragment
|
156
|
+
}
|
168
157
|
status {
|
169
158
|
...transactionStatusFragment
|
170
159
|
}
|
171
160
|
}
|
172
|
-
${
|
161
|
+
${ReceiptFragmentFragmentDoc}
|
162
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
173
163
|
var InputEstimatePredicatesFragmentFragmentDoc = gql`
|
174
164
|
fragment inputEstimatePredicatesFragment on Input {
|
175
165
|
... on InputCoin {
|
@@ -187,46 +177,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
|
|
187
177
|
}
|
188
178
|
}
|
189
179
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
190
|
-
var DryRunFailureStatusFragmentFragmentDoc = gql`
|
191
|
-
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
192
|
-
reason
|
193
|
-
programState {
|
194
|
-
returnType
|
195
|
-
data
|
196
|
-
}
|
197
|
-
}
|
198
|
-
`;
|
199
|
-
var DryRunSuccessStatusFragmentFragmentDoc = gql`
|
200
|
-
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
201
|
-
programState {
|
202
|
-
returnType
|
203
|
-
data
|
204
|
-
}
|
205
|
-
}
|
206
|
-
`;
|
207
|
-
var DryRunTransactionStatusFragmentFragmentDoc = gql`
|
208
|
-
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
209
|
-
... on DryRunFailureStatus {
|
210
|
-
...dryRunFailureStatusFragment
|
211
|
-
}
|
212
|
-
... on DryRunSuccessStatus {
|
213
|
-
...dryRunSuccessStatusFragment
|
214
|
-
}
|
215
|
-
}
|
216
|
-
${DryRunFailureStatusFragmentFragmentDoc}
|
217
|
-
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
218
|
-
var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
|
219
|
-
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
220
|
-
id
|
221
|
-
status {
|
222
|
-
...dryRunTransactionStatusFragment
|
223
|
-
}
|
224
|
-
receipts {
|
225
|
-
...receiptFragment
|
226
|
-
}
|
227
|
-
}
|
228
|
-
${DryRunTransactionStatusFragmentFragmentDoc}
|
229
|
-
${ReceiptFragmentFragmentDoc}`;
|
230
180
|
var CoinFragmentFragmentDoc = gql`
|
231
181
|
fragment coinFragment on Coin {
|
232
182
|
__typename
|
@@ -234,6 +184,7 @@ var CoinFragmentFragmentDoc = gql`
|
|
234
184
|
owner
|
235
185
|
amount
|
236
186
|
assetId
|
187
|
+
maturity
|
237
188
|
blockCreated
|
238
189
|
txCreatedIdx
|
239
190
|
}
|
@@ -272,32 +223,26 @@ var MessageProofFragmentFragmentDoc = gql`
|
|
272
223
|
messageBlockHeader {
|
273
224
|
id
|
274
225
|
daHeight
|
275
|
-
consensusParametersVersion
|
276
|
-
stateTransitionBytecodeVersion
|
277
226
|
transactionsCount
|
278
|
-
messageReceiptCount
|
279
227
|
transactionsRoot
|
280
|
-
messageOutboxRoot
|
281
|
-
eventInboxRoot
|
282
228
|
height
|
283
229
|
prevRoot
|
284
230
|
time
|
285
231
|
applicationHash
|
232
|
+
messageReceiptRoot
|
233
|
+
messageReceiptCount
|
286
234
|
}
|
287
235
|
commitBlockHeader {
|
288
236
|
id
|
289
237
|
daHeight
|
290
|
-
consensusParametersVersion
|
291
|
-
stateTransitionBytecodeVersion
|
292
238
|
transactionsCount
|
293
|
-
messageReceiptCount
|
294
239
|
transactionsRoot
|
295
|
-
messageOutboxRoot
|
296
|
-
eventInboxRoot
|
297
240
|
height
|
298
241
|
prevRoot
|
299
242
|
time
|
300
243
|
applicationHash
|
244
|
+
messageReceiptRoot
|
245
|
+
messageReceiptCount
|
301
246
|
}
|
302
247
|
sender
|
303
248
|
recipient
|
@@ -316,8 +261,8 @@ var BalanceFragmentFragmentDoc = gql`
|
|
316
261
|
var BlockFragmentFragmentDoc = gql`
|
317
262
|
fragment blockFragment on Block {
|
318
263
|
id
|
319
|
-
height
|
320
264
|
header {
|
265
|
+
height
|
321
266
|
time
|
322
267
|
}
|
323
268
|
transactions {
|
@@ -327,7 +272,6 @@ var BlockFragmentFragmentDoc = gql`
|
|
327
272
|
`;
|
328
273
|
var TxParametersFragmentFragmentDoc = gql`
|
329
274
|
fragment TxParametersFragment on TxParameters {
|
330
|
-
version
|
331
275
|
maxInputs
|
332
276
|
maxOutputs
|
333
277
|
maxWitnesses
|
@@ -337,7 +281,6 @@ var TxParametersFragmentFragmentDoc = gql`
|
|
337
281
|
`;
|
338
282
|
var PredicateParametersFragmentFragmentDoc = gql`
|
339
283
|
fragment PredicateParametersFragment on PredicateParameters {
|
340
|
-
version
|
341
284
|
maxPredicateLength
|
342
285
|
maxPredicateDataLength
|
343
286
|
maxGasPerPredicate
|
@@ -346,21 +289,18 @@ var PredicateParametersFragmentFragmentDoc = gql`
|
|
346
289
|
`;
|
347
290
|
var ScriptParametersFragmentFragmentDoc = gql`
|
348
291
|
fragment ScriptParametersFragment on ScriptParameters {
|
349
|
-
version
|
350
292
|
maxScriptLength
|
351
293
|
maxScriptDataLength
|
352
294
|
}
|
353
295
|
`;
|
354
296
|
var ContractParametersFragmentFragmentDoc = gql`
|
355
297
|
fragment ContractParametersFragment on ContractParameters {
|
356
|
-
version
|
357
298
|
contractMaxSize
|
358
299
|
maxStorageSlots
|
359
300
|
}
|
360
301
|
`;
|
361
302
|
var FeeParametersFragmentFragmentDoc = gql`
|
362
303
|
fragment FeeParametersFragment on FeeParameters {
|
363
|
-
version
|
364
304
|
gasPriceFactor
|
365
305
|
gasPerByte
|
366
306
|
}
|
@@ -380,7 +320,6 @@ var DependentCostFragmentFragmentDoc = gql`
|
|
380
320
|
`;
|
381
321
|
var GasCostsFragmentFragmentDoc = gql`
|
382
322
|
fragment GasCostsFragment on GasCosts {
|
383
|
-
version
|
384
323
|
add
|
385
324
|
addi
|
386
325
|
aloc
|
@@ -393,6 +332,7 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
393
332
|
cb
|
394
333
|
cfei
|
395
334
|
cfsi
|
335
|
+
croo
|
396
336
|
div
|
397
337
|
divi
|
398
338
|
ecr1
|
@@ -475,9 +415,6 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
475
415
|
ccp {
|
476
416
|
...DependentCostFragment
|
477
417
|
}
|
478
|
-
croo {
|
479
|
-
...DependentCostFragment
|
480
|
-
}
|
481
418
|
csiz {
|
482
419
|
...DependentCostFragment
|
483
420
|
}
|
@@ -537,7 +474,6 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
537
474
|
${DependentCostFragmentFragmentDoc}`;
|
538
475
|
var ConsensusParametersFragmentFragmentDoc = gql`
|
539
476
|
fragment consensusParametersFragment on ConsensusParameters {
|
540
|
-
version
|
541
477
|
txParams {
|
542
478
|
...TxParametersFragment
|
543
479
|
}
|
@@ -597,9 +533,18 @@ var NodeInfoFragmentFragmentDoc = gql`
|
|
597
533
|
fragment nodeInfoFragment on NodeInfo {
|
598
534
|
utxoValidation
|
599
535
|
vmBacktrace
|
536
|
+
minGasPrice
|
600
537
|
maxTx
|
601
538
|
maxDepth
|
602
539
|
nodeVersion
|
540
|
+
peers {
|
541
|
+
id
|
542
|
+
addresses
|
543
|
+
clientVersion
|
544
|
+
blockHeight
|
545
|
+
lastHeartbeatMs
|
546
|
+
appScore
|
547
|
+
}
|
603
548
|
}
|
604
549
|
`;
|
605
550
|
var GetVersionDocument = gql`
|
@@ -634,9 +579,13 @@ var GetTransactionWithReceiptsDocument = gql`
|
|
634
579
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
635
580
|
transaction(id: $transactionId) {
|
636
581
|
...transactionFragment
|
582
|
+
receipts {
|
583
|
+
...receiptFragment
|
584
|
+
}
|
637
585
|
}
|
638
586
|
}
|
639
|
-
${TransactionFragmentFragmentDoc}
|
587
|
+
${TransactionFragmentFragmentDoc}
|
588
|
+
${ReceiptFragmentFragmentDoc}`;
|
640
589
|
var GetTransactionsDocument = gql`
|
641
590
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
642
591
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -764,20 +713,6 @@ var GetBalanceDocument = gql`
|
|
764
713
|
}
|
765
714
|
}
|
766
715
|
${BalanceFragmentFragmentDoc}`;
|
767
|
-
var GetLatestGasPriceDocument = gql`
|
768
|
-
query getLatestGasPrice {
|
769
|
-
latestGasPrice {
|
770
|
-
gasPrice
|
771
|
-
}
|
772
|
-
}
|
773
|
-
`;
|
774
|
-
var EstimateGasPriceDocument = gql`
|
775
|
-
query estimateGasPrice($blockHorizon: U32!) {
|
776
|
-
estimateGasPrice(blockHorizon: $blockHorizon) {
|
777
|
-
gasPrice
|
778
|
-
}
|
779
|
-
}
|
780
|
-
`;
|
781
716
|
var GetBalancesDocument = gql`
|
782
717
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
783
718
|
balances(
|
@@ -832,12 +767,12 @@ var GetMessageStatusDocument = gql`
|
|
832
767
|
}
|
833
768
|
`;
|
834
769
|
var DryRunDocument = gql`
|
835
|
-
mutation dryRun($
|
836
|
-
dryRun(
|
837
|
-
...
|
770
|
+
mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
|
771
|
+
dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
|
772
|
+
...receiptFragment
|
838
773
|
}
|
839
774
|
}
|
840
|
-
${
|
775
|
+
${ReceiptFragmentFragmentDoc}`;
|
841
776
|
var SubmitDocument = gql`
|
842
777
|
mutation submit($encodedTransaction: HexString!) {
|
843
778
|
submit(tx: $encodedTransaction) {
|
@@ -856,17 +791,17 @@ var ProduceBlocksDocument = gql`
|
|
856
791
|
var SubmitAndAwaitDocument = gql`
|
857
792
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
858
793
|
submitAndAwait(tx: $encodedTransaction) {
|
859
|
-
...
|
794
|
+
...transactionStatusFragment
|
860
795
|
}
|
861
796
|
}
|
862
|
-
${
|
797
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
863
798
|
var StatusChangeDocument = gql`
|
864
799
|
subscription statusChange($transactionId: TransactionId!) {
|
865
800
|
statusChange(id: $transactionId) {
|
866
|
-
...
|
801
|
+
...transactionStatusFragment
|
867
802
|
}
|
868
803
|
}
|
869
|
-
${
|
804
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
870
805
|
function getSdk(requester) {
|
871
806
|
return {
|
872
807
|
getVersion(variables, options) {
|
@@ -920,12 +855,6 @@ function getSdk(requester) {
|
|
920
855
|
getBalance(variables, options) {
|
921
856
|
return requester(GetBalanceDocument, variables, options);
|
922
857
|
},
|
923
|
-
getLatestGasPrice(variables, options) {
|
924
|
-
return requester(GetLatestGasPriceDocument, variables, options);
|
925
|
-
},
|
926
|
-
estimateGasPrice(variables, options) {
|
927
|
-
return requester(EstimateGasPriceDocument, variables, options);
|
928
|
-
},
|
929
858
|
getBalances(variables, options) {
|
930
859
|
return requester(GetBalancesDocument, variables, options);
|
931
860
|
},
|
@@ -1119,9 +1048,10 @@ var inputify = (value) => {
|
|
1119
1048
|
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
1120
1049
|
},
|
1121
1050
|
witnessIndex: value.witnessIndex,
|
1051
|
+
maturity: value.maturity ?? 0,
|
1122
1052
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1123
|
-
predicateLength:
|
1124
|
-
predicateDataLength:
|
1053
|
+
predicateLength: predicate.length,
|
1054
|
+
predicateDataLength: predicateData.length,
|
1125
1055
|
predicate: hexlify3(predicate),
|
1126
1056
|
predicateData: hexlify3(predicateData)
|
1127
1057
|
};
|
@@ -1152,8 +1082,8 @@ var inputify = (value) => {
|
|
1152
1082
|
nonce: hexlify3(value.nonce),
|
1153
1083
|
witnessIndex: value.witnessIndex,
|
1154
1084
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1155
|
-
predicateLength:
|
1156
|
-
predicateDataLength:
|
1085
|
+
predicateLength: predicate.length,
|
1086
|
+
predicateDataLength: predicateData.length,
|
1157
1087
|
predicate: hexlify3(predicate),
|
1158
1088
|
predicateData: hexlify3(predicateData),
|
1159
1089
|
data: hexlify3(data),
|
@@ -1280,8 +1210,8 @@ function assembleReceiptByType(receipt) {
|
|
1280
1210
|
case "CALL" /* Call */: {
|
1281
1211
|
const callReceipt = {
|
1282
1212
|
type: ReceiptType.Call,
|
1283
|
-
from: hexOrZero(receipt.id
|
1284
|
-
to: hexOrZero(receipt?.to),
|
1213
|
+
from: hexOrZero(receipt.contract?.id),
|
1214
|
+
to: hexOrZero(receipt?.to?.id),
|
1285
1215
|
amount: bn4(receipt.amount),
|
1286
1216
|
assetId: hexOrZero(receipt.assetId),
|
1287
1217
|
gas: bn4(receipt.gas),
|
@@ -1295,7 +1225,7 @@ function assembleReceiptByType(receipt) {
|
|
1295
1225
|
case "RETURN" /* Return */: {
|
1296
1226
|
const returnReceipt = {
|
1297
1227
|
type: ReceiptType.Return,
|
1298
|
-
id: hexOrZero(receipt.id
|
1228
|
+
id: hexOrZero(receipt.contract?.id),
|
1299
1229
|
val: bn4(receipt.val),
|
1300
1230
|
pc: bn4(receipt.pc),
|
1301
1231
|
is: bn4(receipt.is)
|
@@ -1305,7 +1235,7 @@ function assembleReceiptByType(receipt) {
|
|
1305
1235
|
case "RETURN_DATA" /* ReturnData */: {
|
1306
1236
|
const returnDataReceipt = {
|
1307
1237
|
type: ReceiptType.ReturnData,
|
1308
|
-
id: hexOrZero(receipt.id
|
1238
|
+
id: hexOrZero(receipt.contract?.id),
|
1309
1239
|
ptr: bn4(receipt.ptr),
|
1310
1240
|
len: bn4(receipt.len),
|
1311
1241
|
digest: hexOrZero(receipt.digest),
|
@@ -1317,7 +1247,7 @@ function assembleReceiptByType(receipt) {
|
|
1317
1247
|
case "PANIC" /* Panic */: {
|
1318
1248
|
const panicReceipt = {
|
1319
1249
|
type: ReceiptType.Panic,
|
1320
|
-
id: hexOrZero(receipt.id),
|
1250
|
+
id: hexOrZero(receipt.contract?.id),
|
1321
1251
|
reason: bn4(receipt.reason),
|
1322
1252
|
pc: bn4(receipt.pc),
|
1323
1253
|
is: bn4(receipt.is),
|
@@ -1328,7 +1258,7 @@ function assembleReceiptByType(receipt) {
|
|
1328
1258
|
case "REVERT" /* Revert */: {
|
1329
1259
|
const revertReceipt = {
|
1330
1260
|
type: ReceiptType.Revert,
|
1331
|
-
id: hexOrZero(receipt.id
|
1261
|
+
id: hexOrZero(receipt.contract?.id),
|
1332
1262
|
val: bn4(receipt.ra),
|
1333
1263
|
pc: bn4(receipt.pc),
|
1334
1264
|
is: bn4(receipt.is)
|
@@ -1338,7 +1268,7 @@ function assembleReceiptByType(receipt) {
|
|
1338
1268
|
case "LOG" /* Log */: {
|
1339
1269
|
const logReceipt = {
|
1340
1270
|
type: ReceiptType.Log,
|
1341
|
-
id: hexOrZero(receipt.id
|
1271
|
+
id: hexOrZero(receipt.contract?.id),
|
1342
1272
|
val0: bn4(receipt.ra),
|
1343
1273
|
val1: bn4(receipt.rb),
|
1344
1274
|
val2: bn4(receipt.rc),
|
@@ -1351,7 +1281,7 @@ function assembleReceiptByType(receipt) {
|
|
1351
1281
|
case "LOG_DATA" /* LogData */: {
|
1352
1282
|
const logDataReceipt = {
|
1353
1283
|
type: ReceiptType.LogData,
|
1354
|
-
id: hexOrZero(receipt.id
|
1284
|
+
id: hexOrZero(receipt.contract?.id),
|
1355
1285
|
val0: bn4(receipt.ra),
|
1356
1286
|
val1: bn4(receipt.rb),
|
1357
1287
|
ptr: bn4(receipt.ptr),
|
@@ -1365,8 +1295,8 @@ function assembleReceiptByType(receipt) {
|
|
1365
1295
|
case "TRANSFER" /* Transfer */: {
|
1366
1296
|
const transferReceipt = {
|
1367
1297
|
type: ReceiptType.Transfer,
|
1368
|
-
from: hexOrZero(receipt.id
|
1369
|
-
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1298
|
+
from: hexOrZero(receipt.contract?.id),
|
1299
|
+
to: hexOrZero(receipt.toAddress || receipt?.to?.id),
|
1370
1300
|
amount: bn4(receipt.amount),
|
1371
1301
|
assetId: hexOrZero(receipt.assetId),
|
1372
1302
|
pc: bn4(receipt.pc),
|
@@ -1377,8 +1307,8 @@ function assembleReceiptByType(receipt) {
|
|
1377
1307
|
case "TRANSFER_OUT" /* TransferOut */: {
|
1378
1308
|
const transferOutReceipt = {
|
1379
1309
|
type: ReceiptType.TransferOut,
|
1380
|
-
from: hexOrZero(receipt.id
|
1381
|
-
to: hexOrZero(receipt.toAddress || receipt.to),
|
1310
|
+
from: hexOrZero(receipt.contract?.id),
|
1311
|
+
to: hexOrZero(receipt.toAddress || receipt.to?.id),
|
1382
1312
|
amount: bn4(receipt.amount),
|
1383
1313
|
assetId: hexOrZero(receipt.assetId),
|
1384
1314
|
pc: bn4(receipt.pc),
|
@@ -1421,7 +1351,7 @@ function assembleReceiptByType(receipt) {
|
|
1421
1351
|
return receiptMessageOut;
|
1422
1352
|
}
|
1423
1353
|
case "MINT" /* Mint */: {
|
1424
|
-
const contractId = hexOrZero(receipt.id
|
1354
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
1425
1355
|
const subId = hexOrZero(receipt.subId);
|
1426
1356
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
1427
1357
|
const mintReceipt = {
|
@@ -1436,7 +1366,7 @@ function assembleReceiptByType(receipt) {
|
|
1436
1366
|
return mintReceipt;
|
1437
1367
|
}
|
1438
1368
|
case "BURN" /* Burn */: {
|
1439
|
-
const contractId = hexOrZero(receipt.id
|
1369
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
1440
1370
|
const subId = hexOrZero(receipt.subId);
|
1441
1371
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
1442
1372
|
const burnReceipt = {
|
@@ -1462,6 +1392,7 @@ import { ErrorCode as ErrorCode6, FuelError as FuelError6 } from "@fuel-ts/error
|
|
1462
1392
|
import { bn as bn5 } from "@fuel-ts/math";
|
1463
1393
|
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
1464
1394
|
import { arrayify as arrayify3 } from "@fuel-ts/utils";
|
1395
|
+
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1465
1396
|
var getGasUsedFromReceipts = (receipts) => {
|
1466
1397
|
const scriptResult = receipts.filter(
|
1467
1398
|
(receipt) => receipt.type === ReceiptType2.ScriptResult
|
@@ -1482,28 +1413,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
1482
1413
|
}
|
1483
1414
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
1484
1415
|
const witnessCache = [];
|
1485
|
-
const
|
1486
|
-
const isCoinOrMessage = "owner" in input || "sender" in input;
|
1487
|
-
if (isCoinOrMessage) {
|
1488
|
-
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1489
|
-
return true;
|
1490
|
-
}
|
1491
|
-
if (!witnessCache.includes(input.witnessIndex)) {
|
1492
|
-
witnessCache.push(input.witnessIndex);
|
1493
|
-
return true;
|
1494
|
-
}
|
1495
|
-
}
|
1496
|
-
return false;
|
1497
|
-
});
|
1498
|
-
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
1499
|
-
const totalGas = chargeableInputs.reduce((total, input) => {
|
1416
|
+
const totalGas = inputs.reduce((total, input) => {
|
1500
1417
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1501
1418
|
return total.add(
|
1502
|
-
|
1419
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
|
1503
1420
|
);
|
1504
1421
|
}
|
1505
|
-
|
1506
|
-
|
1422
|
+
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
1423
|
+
witnessCache.push(input.witnessIndex);
|
1424
|
+
return total.add(gasCosts.ecr1);
|
1425
|
+
}
|
1426
|
+
return total;
|
1427
|
+
}, bn5());
|
1507
1428
|
return totalGas;
|
1508
1429
|
}
|
1509
1430
|
function getMinGas(params) {
|
@@ -1515,20 +1436,12 @@ function getMinGas(params) {
|
|
1515
1436
|
return minGas;
|
1516
1437
|
}
|
1517
1438
|
function getMaxGas(params) {
|
1518
|
-
const {
|
1519
|
-
gasPerByte,
|
1520
|
-
witnessesLength,
|
1521
|
-
witnessLimit,
|
1522
|
-
minGas,
|
1523
|
-
gasLimit = bn5(0),
|
1524
|
-
maxGasPerTx
|
1525
|
-
} = params;
|
1439
|
+
const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
|
1526
1440
|
let remainingAllowedWitnessGas = bn5(0);
|
1527
1441
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
1528
1442
|
remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
1529
1443
|
}
|
1530
|
-
|
1531
|
-
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
1444
|
+
return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
1532
1445
|
}
|
1533
1446
|
function calculateMetadataGasForTxCreate({
|
1534
1447
|
gasCosts,
|
@@ -1550,10 +1463,6 @@ function calculateMetadataGasForTxScript({
|
|
1550
1463
|
}) {
|
1551
1464
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1552
1465
|
}
|
1553
|
-
var calculateGasFee = (params) => {
|
1554
|
-
const { gas, gasPrice, priceFactor, tip } = params;
|
1555
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1556
|
-
};
|
1557
1466
|
|
1558
1467
|
// src/providers/utils/json.ts
|
1559
1468
|
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
@@ -1698,7 +1607,7 @@ var witnessify = (value) => {
|
|
1698
1607
|
// src/providers/transaction-request/transaction-request.ts
|
1699
1608
|
var BaseTransactionRequest = class {
|
1700
1609
|
/** Gas price for transaction */
|
1701
|
-
|
1610
|
+
gasPrice;
|
1702
1611
|
/** Block until which tx cannot be included */
|
1703
1612
|
maturity;
|
1704
1613
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -1717,7 +1626,7 @@ var BaseTransactionRequest = class {
|
|
1717
1626
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
1718
1627
|
*/
|
1719
1628
|
constructor({
|
1720
|
-
|
1629
|
+
gasPrice,
|
1721
1630
|
maturity,
|
1722
1631
|
maxFee,
|
1723
1632
|
witnessLimit,
|
@@ -1725,7 +1634,7 @@ var BaseTransactionRequest = class {
|
|
1725
1634
|
outputs,
|
1726
1635
|
witnesses
|
1727
1636
|
} = {}) {
|
1728
|
-
this.
|
1637
|
+
this.gasPrice = bn7(gasPrice);
|
1729
1638
|
this.maturity = maturity ?? 0;
|
1730
1639
|
this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
|
1731
1640
|
this.maxFee = maxFee ? bn7(maxFee) : void 0;
|
@@ -1736,9 +1645,9 @@ var BaseTransactionRequest = class {
|
|
1736
1645
|
static getPolicyMeta(req) {
|
1737
1646
|
let policyTypes = 0;
|
1738
1647
|
const policies = [];
|
1739
|
-
if (req.
|
1740
|
-
policyTypes += PolicyType.
|
1741
|
-
policies.push({ data: req.
|
1648
|
+
if (req.gasPrice) {
|
1649
|
+
policyTypes += PolicyType.GasPrice;
|
1650
|
+
policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
|
1742
1651
|
}
|
1743
1652
|
if (req.witnessLimit) {
|
1744
1653
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -1922,11 +1831,13 @@ var BaseTransactionRequest = class {
|
|
1922
1831
|
* assetId, if one it was not added yet.
|
1923
1832
|
*
|
1924
1833
|
* @param coin - Coin resource.
|
1834
|
+
* @param predicate - Predicate bytes.
|
1835
|
+
* @param predicateData - Predicate data bytes.
|
1925
1836
|
*/
|
1926
|
-
addCoinInput(coin) {
|
1837
|
+
addCoinInput(coin, predicate) {
|
1927
1838
|
const { assetId, owner, amount } = coin;
|
1928
1839
|
let witnessIndex;
|
1929
|
-
if (
|
1840
|
+
if (predicate) {
|
1930
1841
|
witnessIndex = 0;
|
1931
1842
|
} else {
|
1932
1843
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -1941,7 +1852,8 @@ var BaseTransactionRequest = class {
|
|
1941
1852
|
amount,
|
1942
1853
|
assetId,
|
1943
1854
|
txPointer: "0x00000000000000000000000000000000",
|
1944
|
-
witnessIndex
|
1855
|
+
witnessIndex,
|
1856
|
+
predicate: predicate?.bytes
|
1945
1857
|
};
|
1946
1858
|
this.pushInput(input);
|
1947
1859
|
this.addChangeOutput(owner, assetId);
|
@@ -1951,11 +1863,12 @@ var BaseTransactionRequest = class {
|
|
1951
1863
|
* asset against the message
|
1952
1864
|
*
|
1953
1865
|
* @param message - Message resource.
|
1866
|
+
* @param predicate - Predicate bytes.
|
1954
1867
|
*/
|
1955
|
-
addMessageInput(message) {
|
1868
|
+
addMessageInput(message, predicate) {
|
1956
1869
|
const { recipient, sender, amount, assetId } = message;
|
1957
1870
|
let witnessIndex;
|
1958
|
-
if (
|
1871
|
+
if (predicate) {
|
1959
1872
|
witnessIndex = 0;
|
1960
1873
|
} else {
|
1961
1874
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -1969,7 +1882,8 @@ var BaseTransactionRequest = class {
|
|
1969
1882
|
sender: sender.toB256(),
|
1970
1883
|
recipient: recipient.toB256(),
|
1971
1884
|
amount,
|
1972
|
-
witnessIndex
|
1885
|
+
witnessIndex,
|
1886
|
+
predicate: predicate?.bytes
|
1973
1887
|
};
|
1974
1888
|
this.pushInput(input);
|
1975
1889
|
this.addChangeOutput(recipient, assetId);
|
@@ -2000,6 +1914,32 @@ var BaseTransactionRequest = class {
|
|
2000
1914
|
resources.forEach((resource) => this.addResource(resource));
|
2001
1915
|
return this;
|
2002
1916
|
}
|
1917
|
+
/**
|
1918
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
1919
|
+
* outputs from the related assetIds.
|
1920
|
+
*
|
1921
|
+
* @param resources - The resources to add.
|
1922
|
+
* @returns This transaction.
|
1923
|
+
*/
|
1924
|
+
addPredicateResource(resource, predicate) {
|
1925
|
+
if (isCoin(resource)) {
|
1926
|
+
this.addCoinInput(resource, predicate);
|
1927
|
+
} else {
|
1928
|
+
this.addMessageInput(resource, predicate);
|
1929
|
+
}
|
1930
|
+
return this;
|
1931
|
+
}
|
1932
|
+
/**
|
1933
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
1934
|
+
* from the related assetIds.
|
1935
|
+
*
|
1936
|
+
* @param resources - The resources to add.
|
1937
|
+
* @returns This transaction.
|
1938
|
+
*/
|
1939
|
+
addPredicateResources(resources, predicate) {
|
1940
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
1941
|
+
return this;
|
1942
|
+
}
|
2003
1943
|
/**
|
2004
1944
|
* Adds a coin output to the transaction.
|
2005
1945
|
*
|
@@ -2079,7 +2019,7 @@ var BaseTransactionRequest = class {
|
|
2079
2019
|
}
|
2080
2020
|
calculateMaxGas(chainInfo, minGas) {
|
2081
2021
|
const { consensusParameters } = chainInfo;
|
2082
|
-
const { gasPerByte
|
2022
|
+
const { gasPerByte } = consensusParameters;
|
2083
2023
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2084
2024
|
(acc, wit) => acc + wit.dataLength,
|
2085
2025
|
0
|
@@ -2088,8 +2028,7 @@ var BaseTransactionRequest = class {
|
|
2088
2028
|
gasPerByte,
|
2089
2029
|
minGas,
|
2090
2030
|
witnessesLength,
|
2091
|
-
witnessLimit: this.witnessLimit
|
2092
|
-
maxGasPerTx
|
2031
|
+
witnessLimit: this.witnessLimit
|
2093
2032
|
});
|
2094
2033
|
}
|
2095
2034
|
/**
|
@@ -2108,20 +2047,17 @@ var BaseTransactionRequest = class {
|
|
2108
2047
|
});
|
2109
2048
|
const updateAssetInput = (assetId, quantity) => {
|
2110
2049
|
const assetInput = findAssetInput(assetId);
|
2111
|
-
let usedQuantity = quantity;
|
2112
|
-
if (assetId === baseAssetId) {
|
2113
|
-
usedQuantity = bn7("1000000000000000000");
|
2114
|
-
}
|
2115
2050
|
if (assetInput && "assetId" in assetInput) {
|
2116
2051
|
assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
|
2117
|
-
assetInput.amount =
|
2052
|
+
assetInput.amount = quantity;
|
2118
2053
|
} else {
|
2119
2054
|
this.addResources([
|
2120
2055
|
{
|
2121
2056
|
id: hexlify7(randomBytes(UTXO_ID_LEN2)),
|
2122
|
-
amount:
|
2057
|
+
amount: quantity,
|
2123
2058
|
assetId,
|
2124
2059
|
owner: resourcesOwner || Address.fromRandom(),
|
2060
|
+
maturity: 0,
|
2125
2061
|
blockCreated: bn7(1),
|
2126
2062
|
txCreatedIdx: bn7(1)
|
2127
2063
|
}
|
@@ -2153,7 +2089,7 @@ var BaseTransactionRequest = class {
|
|
2153
2089
|
toJSON() {
|
2154
2090
|
return normalizeJSON(this);
|
2155
2091
|
}
|
2156
|
-
|
2092
|
+
updatePredicateInputs(inputs) {
|
2157
2093
|
this.inputs.forEach((i) => {
|
2158
2094
|
let correspondingInput;
|
2159
2095
|
switch (i.type) {
|
@@ -2175,15 +2111,6 @@ var BaseTransactionRequest = class {
|
|
2175
2111
|
}
|
2176
2112
|
});
|
2177
2113
|
}
|
2178
|
-
shiftPredicateData() {
|
2179
|
-
this.inputs.forEach((input) => {
|
2180
|
-
if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
|
2181
|
-
input.predicateData = input.padPredicateData(
|
2182
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2183
|
-
);
|
2184
|
-
}
|
2185
|
-
});
|
2186
|
-
}
|
2187
2114
|
};
|
2188
2115
|
|
2189
2116
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2325,8 +2252,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2325
2252
|
return {
|
2326
2253
|
type: TransactionType3.Create,
|
2327
2254
|
...baseTransaction,
|
2255
|
+
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2328
2256
|
bytecodeWitnessIndex,
|
2329
|
-
storageSlotsCount:
|
2257
|
+
storageSlotsCount: storageSlots.length,
|
2330
2258
|
salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
|
2331
2259
|
storageSlots
|
2332
2260
|
};
|
@@ -2449,8 +2377,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2449
2377
|
type: TransactionType4.Script,
|
2450
2378
|
scriptGasLimit: this.gasLimit,
|
2451
2379
|
...super.getBaseTransaction(),
|
2452
|
-
scriptLength:
|
2453
|
-
scriptDataLength:
|
2380
|
+
scriptLength: script.length,
|
2381
|
+
scriptDataLength: scriptData.length,
|
2454
2382
|
receiptsRoot: ZeroBytes327,
|
2455
2383
|
script: hexlify10(script),
|
2456
2384
|
scriptData: hexlify10(scriptData)
|
@@ -2514,7 +2442,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2514
2442
|
}
|
2515
2443
|
calculateMaxGas(chainInfo, minGas) {
|
2516
2444
|
const { consensusParameters } = chainInfo;
|
2517
|
-
const { gasPerByte
|
2445
|
+
const { gasPerByte } = consensusParameters;
|
2518
2446
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2519
2447
|
(acc, wit) => acc + wit.dataLength,
|
2520
2448
|
0
|
@@ -2524,8 +2452,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2524
2452
|
minGas,
|
2525
2453
|
witnessesLength,
|
2526
2454
|
witnessLimit: this.witnessLimit,
|
2527
|
-
gasLimit: this.gasLimit
|
2528
|
-
maxGasPerTx
|
2455
|
+
gasLimit: this.gasLimit
|
2529
2456
|
});
|
2530
2457
|
}
|
2531
2458
|
/**
|
@@ -2582,7 +2509,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2582
2509
|
|
2583
2510
|
// src/providers/transaction-request/utils.ts
|
2584
2511
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2585
|
-
import { TransactionType as TransactionType5
|
2512
|
+
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2586
2513
|
var transactionRequestify = (obj) => {
|
2587
2514
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2588
2515
|
return obj;
|
@@ -2600,31 +2527,14 @@ var transactionRequestify = (obj) => {
|
|
2600
2527
|
}
|
2601
2528
|
}
|
2602
2529
|
};
|
2603
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2604
|
-
(acc, input) => {
|
2605
|
-
if (input.type === InputType5.Coin && input.owner === owner) {
|
2606
|
-
acc.utxos.push(input.id);
|
2607
|
-
}
|
2608
|
-
if (input.type === InputType5.Message && input.recipient === owner) {
|
2609
|
-
acc.messages.push(input.nonce);
|
2610
|
-
}
|
2611
|
-
return acc;
|
2612
|
-
},
|
2613
|
-
{
|
2614
|
-
utxos: [],
|
2615
|
-
messages: []
|
2616
|
-
}
|
2617
|
-
);
|
2618
2530
|
|
2619
2531
|
// src/providers/transaction-response/transaction-response.ts
|
2620
2532
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2621
|
-
import { bn as
|
2533
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
2622
2534
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2623
2535
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2624
2536
|
|
2625
2537
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2626
|
-
import { bn as bn14 } from "@fuel-ts/math";
|
2627
|
-
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2628
2538
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2629
2539
|
|
2630
2540
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
@@ -2633,10 +2543,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
|
|
2633
2543
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2634
2544
|
var calculateTransactionFee = (params) => {
|
2635
2545
|
const {
|
2636
|
-
|
2546
|
+
gasUsed,
|
2637
2547
|
rawPayload,
|
2638
|
-
|
2639
|
-
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2548
|
+
consensusParameters: { gasCosts, feeParams }
|
2640
2549
|
} = params;
|
2641
2550
|
const gasPerByte = bn11(feeParams.gasPerByte);
|
2642
2551
|
const gasPriceFactor = bn11(feeParams.gasPriceFactor);
|
@@ -2646,7 +2555,8 @@ var calculateTransactionFee = (params) => {
|
|
2646
2555
|
return {
|
2647
2556
|
fee: bn11(0),
|
2648
2557
|
minFee: bn11(0),
|
2649
|
-
maxFee: bn11(0)
|
2558
|
+
maxFee: bn11(0),
|
2559
|
+
feeFromGasUsed: bn11(0)
|
2650
2560
|
};
|
2651
2561
|
}
|
2652
2562
|
const { type, witnesses, inputs, policies } = transaction;
|
@@ -2678,6 +2588,7 @@ var calculateTransactionFee = (params) => {
|
|
2678
2588
|
metadataGas,
|
2679
2589
|
txBytesSize: transactionBytes.length
|
2680
2590
|
});
|
2591
|
+
const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
|
2681
2592
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
|
2682
2593
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2683
2594
|
const maxGas = getMaxGas({
|
@@ -2685,25 +2596,17 @@ var calculateTransactionFee = (params) => {
|
|
2685
2596
|
minGas,
|
2686
2597
|
witnessesLength,
|
2687
2598
|
gasLimit,
|
2688
|
-
witnessLimit
|
2689
|
-
maxGasPerTx
|
2690
|
-
});
|
2691
|
-
const minFee = calculateGasFee({
|
2692
|
-
gasPrice,
|
2693
|
-
gas: minGas,
|
2694
|
-
priceFactor: gasPriceFactor,
|
2695
|
-
tip
|
2696
|
-
});
|
2697
|
-
const maxFee = calculateGasFee({
|
2698
|
-
gasPrice,
|
2699
|
-
gas: maxGas,
|
2700
|
-
priceFactor: gasPriceFactor,
|
2701
|
-
tip
|
2599
|
+
witnessLimit
|
2702
2600
|
});
|
2601
|
+
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
2602
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
2603
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
2604
|
+
const fee = minFee.add(feeFromGasUsed);
|
2703
2605
|
return {
|
2606
|
+
fee,
|
2704
2607
|
minFee,
|
2705
2608
|
maxFee,
|
2706
|
-
|
2609
|
+
feeFromGasUsed
|
2707
2610
|
};
|
2708
2611
|
};
|
2709
2612
|
|
@@ -2759,7 +2662,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2759
2662
|
|
2760
2663
|
// src/providers/transaction-summary/input.ts
|
2761
2664
|
import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2762
|
-
import { InputType as
|
2665
|
+
import { InputType as InputType5 } from "@fuel-ts/transactions";
|
2763
2666
|
function getInputsByTypes(inputs, types) {
|
2764
2667
|
return inputs.filter((i) => types.includes(i.type));
|
2765
2668
|
}
|
@@ -2767,16 +2670,16 @@ function getInputsByType(inputs, type) {
|
|
2767
2670
|
return inputs.filter((i) => i.type === type);
|
2768
2671
|
}
|
2769
2672
|
function getInputsCoin(inputs) {
|
2770
|
-
return getInputsByType(inputs,
|
2673
|
+
return getInputsByType(inputs, InputType5.Coin);
|
2771
2674
|
}
|
2772
2675
|
function getInputsMessage(inputs) {
|
2773
|
-
return getInputsByType(inputs,
|
2676
|
+
return getInputsByType(inputs, InputType5.Message);
|
2774
2677
|
}
|
2775
2678
|
function getInputsCoinAndMessage(inputs) {
|
2776
|
-
return getInputsByTypes(inputs, [
|
2679
|
+
return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
|
2777
2680
|
}
|
2778
2681
|
function getInputsContract(inputs) {
|
2779
|
-
return getInputsByType(inputs,
|
2682
|
+
return getInputsByType(inputs, InputType5.Contract);
|
2780
2683
|
}
|
2781
2684
|
function getInputFromAssetId(inputs, assetId) {
|
2782
2685
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2795,7 +2698,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2795
2698
|
if (!contractInput) {
|
2796
2699
|
return void 0;
|
2797
2700
|
}
|
2798
|
-
if (contractInput.type !==
|
2701
|
+
if (contractInput.type !== InputType5.Contract) {
|
2799
2702
|
throw new FuelError9(
|
2800
2703
|
ErrorCode9.INVALID_TRANSACTION_INPUT,
|
2801
2704
|
`Contract input should be of type 'contract'.`
|
@@ -2804,10 +2707,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2804
2707
|
return contractInput;
|
2805
2708
|
}
|
2806
2709
|
function getInputAccountAddress(input) {
|
2807
|
-
if (input.type ===
|
2710
|
+
if (input.type === InputType5.Coin) {
|
2808
2711
|
return input.owner.toString();
|
2809
2712
|
}
|
2810
|
-
if (input.type ===
|
2713
|
+
if (input.type === InputType5.Message) {
|
2811
2714
|
return input.recipient.toString();
|
2812
2715
|
}
|
2813
2716
|
return "";
|
@@ -3270,9 +3173,7 @@ function assembleTransactionSummary(params) {
|
|
3270
3173
|
gqlTransactionStatus,
|
3271
3174
|
abiMap = {},
|
3272
3175
|
maxInputs,
|
3273
|
-
gasCosts
|
3274
|
-
maxGasPerTx,
|
3275
|
-
gasPrice
|
3176
|
+
gasCosts
|
3276
3177
|
} = params;
|
3277
3178
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3278
3179
|
const rawPayload = hexlify11(transactionBytes);
|
@@ -3286,14 +3187,11 @@ function assembleTransactionSummary(params) {
|
|
3286
3187
|
maxInputs
|
3287
3188
|
});
|
3288
3189
|
const typeName = getTransactionTypeName(transaction.type);
|
3289
|
-
const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3290
3190
|
const { fee } = calculateTransactionFee({
|
3291
|
-
|
3191
|
+
gasUsed,
|
3292
3192
|
rawPayload,
|
3293
|
-
tip,
|
3294
3193
|
consensusParameters: {
|
3295
3194
|
gasCosts,
|
3296
|
-
maxGasPerTx,
|
3297
3195
|
feeParams: {
|
3298
3196
|
gasPerByte,
|
3299
3197
|
gasPriceFactor
|
@@ -3353,7 +3251,7 @@ var TransactionResponse = class {
|
|
3353
3251
|
/** Current provider */
|
3354
3252
|
provider;
|
3355
3253
|
/** Gas used on the transaction */
|
3356
|
-
gasUsed =
|
3254
|
+
gasUsed = bn14(0);
|
3357
3255
|
/** The graphql Transaction with receipts object. */
|
3358
3256
|
gqlTransaction;
|
3359
3257
|
abis;
|
@@ -3431,13 +3329,8 @@ var TransactionResponse = class {
|
|
3431
3329
|
const decodedTransaction = this.decodeTransaction(
|
3432
3330
|
transaction
|
3433
3331
|
);
|
3434
|
-
|
3435
|
-
|
3436
|
-
txReceipts = transaction.status.receipts;
|
3437
|
-
}
|
3438
|
-
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3439
|
-
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3440
|
-
const gasPrice = await this.provider.getLatestGasPrice();
|
3332
|
+
const receipts = transaction.receipts?.map(processGqlReceipt) || [];
|
3333
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
|
3441
3334
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3442
3335
|
const transactionSummary = assembleTransactionSummary({
|
3443
3336
|
id: this.id,
|
@@ -3449,9 +3342,7 @@ var TransactionResponse = class {
|
|
3449
3342
|
gasPriceFactor,
|
3450
3343
|
abiMap: contractsAbiMap,
|
3451
3344
|
maxInputs,
|
3452
|
-
gasCosts
|
3453
|
-
maxGasPerTx,
|
3454
|
-
gasPrice
|
3345
|
+
gasCosts
|
3455
3346
|
});
|
3456
3347
|
return transactionSummary;
|
3457
3348
|
}
|
@@ -3577,30 +3468,30 @@ var processGqlChain = (chain) => {
|
|
3577
3468
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3578
3469
|
return {
|
3579
3470
|
name,
|
3580
|
-
baseChainHeight:
|
3471
|
+
baseChainHeight: bn15(daHeight),
|
3581
3472
|
consensusParameters: {
|
3582
|
-
contractMaxSize:
|
3583
|
-
maxInputs:
|
3584
|
-
maxOutputs:
|
3585
|
-
maxWitnesses:
|
3586
|
-
maxGasPerTx:
|
3587
|
-
maxScriptLength:
|
3588
|
-
maxScriptDataLength:
|
3589
|
-
maxStorageSlots:
|
3590
|
-
maxPredicateLength:
|
3591
|
-
maxPredicateDataLength:
|
3592
|
-
maxGasPerPredicate:
|
3593
|
-
gasPriceFactor:
|
3594
|
-
gasPerByte:
|
3595
|
-
maxMessageDataLength:
|
3596
|
-
chainId:
|
3473
|
+
contractMaxSize: bn15(contractParams.contractMaxSize),
|
3474
|
+
maxInputs: bn15(txParams.maxInputs),
|
3475
|
+
maxOutputs: bn15(txParams.maxOutputs),
|
3476
|
+
maxWitnesses: bn15(txParams.maxWitnesses),
|
3477
|
+
maxGasPerTx: bn15(txParams.maxGasPerTx),
|
3478
|
+
maxScriptLength: bn15(scriptParams.maxScriptLength),
|
3479
|
+
maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
|
3480
|
+
maxStorageSlots: bn15(contractParams.maxStorageSlots),
|
3481
|
+
maxPredicateLength: bn15(predicateParams.maxPredicateLength),
|
3482
|
+
maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
|
3483
|
+
maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
|
3484
|
+
gasPriceFactor: bn15(feeParams.gasPriceFactor),
|
3485
|
+
gasPerByte: bn15(feeParams.gasPerByte),
|
3486
|
+
maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
|
3487
|
+
chainId: bn15(consensusParameters.chainId),
|
3597
3488
|
baseAssetId: consensusParameters.baseAssetId,
|
3598
3489
|
gasCosts
|
3599
3490
|
},
|
3600
3491
|
gasCosts,
|
3601
3492
|
latestBlock: {
|
3602
3493
|
id: latestBlock.id,
|
3603
|
-
height:
|
3494
|
+
height: bn15(latestBlock.header.height),
|
3604
3495
|
time: latestBlock.header.time,
|
3605
3496
|
transactions: latestBlock.transactions.map((i) => ({
|
3606
3497
|
id: i.id
|
@@ -3694,8 +3585,10 @@ var _Provider = class {
|
|
3694
3585
|
* Returns some helpful parameters related to gas fees.
|
3695
3586
|
*/
|
3696
3587
|
getGasConfig() {
|
3588
|
+
const { minGasPrice } = this.getNode();
|
3697
3589
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3698
3590
|
return {
|
3591
|
+
minGasPrice,
|
3699
3592
|
maxGasPerTx,
|
3700
3593
|
maxGasPerPredicate,
|
3701
3594
|
gasPriceFactor,
|
@@ -3771,21 +3664,6 @@ var _Provider = class {
|
|
3771
3664
|
} = await this.operations.getVersion();
|
3772
3665
|
return nodeVersion;
|
3773
3666
|
}
|
3774
|
-
/**
|
3775
|
-
* @hidden
|
3776
|
-
*
|
3777
|
-
* Returns the network configuration of the connected Fuel node.
|
3778
|
-
*
|
3779
|
-
* @returns A promise that resolves to the network configuration object
|
3780
|
-
*/
|
3781
|
-
async getNetwork() {
|
3782
|
-
const {
|
3783
|
-
name,
|
3784
|
-
consensusParameters: { chainId }
|
3785
|
-
} = await this.getChain();
|
3786
|
-
const network = new Network(name, chainId.toNumber());
|
3787
|
-
return Promise.resolve(network);
|
3788
|
-
}
|
3789
3667
|
/**
|
3790
3668
|
* Returns the block number.
|
3791
3669
|
*
|
@@ -3793,7 +3671,7 @@ var _Provider = class {
|
|
3793
3671
|
*/
|
3794
3672
|
async getBlockNumber() {
|
3795
3673
|
const { chain } = await this.operations.getChain();
|
3796
|
-
return
|
3674
|
+
return bn15(chain.latestBlock.header.height, 10);
|
3797
3675
|
}
|
3798
3676
|
/**
|
3799
3677
|
* Returns the chain information.
|
@@ -3803,11 +3681,13 @@ var _Provider = class {
|
|
3803
3681
|
async fetchNode() {
|
3804
3682
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3805
3683
|
const processedNodeInfo = {
|
3806
|
-
maxDepth:
|
3807
|
-
maxTx:
|
3684
|
+
maxDepth: bn15(nodeInfo.maxDepth),
|
3685
|
+
maxTx: bn15(nodeInfo.maxTx),
|
3686
|
+
minGasPrice: bn15(nodeInfo.minGasPrice),
|
3808
3687
|
nodeVersion: nodeInfo.nodeVersion,
|
3809
3688
|
utxoValidation: nodeInfo.utxoValidation,
|
3810
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
3689
|
+
vmBacktrace: nodeInfo.vmBacktrace,
|
3690
|
+
peers: nodeInfo.peers
|
3811
3691
|
};
|
3812
3692
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
3813
3693
|
return processedNodeInfo;
|
@@ -3904,13 +3784,14 @@ var _Provider = class {
|
|
3904
3784
|
return this.estimateTxDependencies(transactionRequest);
|
3905
3785
|
}
|
3906
3786
|
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
3907
|
-
const { dryRun:
|
3908
|
-
|
3787
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3788
|
+
encodedTransaction,
|
3909
3789
|
utxoValidation: utxoValidation || false
|
3910
3790
|
});
|
3911
|
-
const
|
3912
|
-
|
3913
|
-
|
3791
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
3792
|
+
return {
|
3793
|
+
receipts
|
3794
|
+
};
|
3914
3795
|
}
|
3915
3796
|
/**
|
3916
3797
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -3936,7 +3817,7 @@ var _Provider = class {
|
|
3936
3817
|
} = response;
|
3937
3818
|
if (inputs) {
|
3938
3819
|
inputs.forEach((input, index) => {
|
3939
|
-
if ("predicateGasUsed" in input &&
|
3820
|
+
if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
|
3940
3821
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3941
3822
|
}
|
3942
3823
|
});
|
@@ -3949,6 +3830,9 @@ var _Provider = class {
|
|
3949
3830
|
* If there are missing variable outputs,
|
3950
3831
|
* `addVariableOutputs` is called on the transaction.
|
3951
3832
|
*
|
3833
|
+
* @privateRemarks
|
3834
|
+
* TODO: Investigate support for missing contract IDs
|
3835
|
+
* TODO: Add support for missing output messages
|
3952
3836
|
*
|
3953
3837
|
* @param transactionRequest - The transaction request object.
|
3954
3838
|
* @returns A promise.
|
@@ -3961,19 +3845,16 @@ var _Provider = class {
|
|
3961
3845
|
missingContractIds: []
|
3962
3846
|
};
|
3963
3847
|
}
|
3848
|
+
await this.estimatePredicates(transactionRequest);
|
3964
3849
|
let receipts = [];
|
3965
3850
|
const missingContractIds = [];
|
3966
3851
|
let outputVariables = 0;
|
3967
|
-
let dryrunStatus;
|
3968
3852
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3969
|
-
const {
|
3970
|
-
|
3971
|
-
} = await this.operations.dryRun({
|
3972
|
-
encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
|
3853
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3854
|
+
encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
|
3973
3855
|
utxoValidation: false
|
3974
3856
|
});
|
3975
|
-
receipts =
|
3976
|
-
dryrunStatus = status;
|
3857
|
+
receipts = gqlReceipts.map(processGqlReceipt);
|
3977
3858
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
3978
3859
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
3979
3860
|
if (hasMissingOutputs) {
|
@@ -3983,10 +3864,6 @@ var _Provider = class {
|
|
3983
3864
|
transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
|
3984
3865
|
missingContractIds.push(contractId);
|
3985
3866
|
});
|
3986
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
3987
|
-
transactionRequest
|
3988
|
-
});
|
3989
|
-
transactionRequest.maxFee = maxFee;
|
3990
3867
|
} else {
|
3991
3868
|
break;
|
3992
3869
|
}
|
@@ -3994,136 +3871,37 @@ var _Provider = class {
|
|
3994
3871
|
return {
|
3995
3872
|
receipts,
|
3996
3873
|
outputVariables,
|
3997
|
-
missingContractIds
|
3998
|
-
dryrunStatus
|
3874
|
+
missingContractIds
|
3999
3875
|
};
|
4000
3876
|
}
|
4001
|
-
/**
|
4002
|
-
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
4003
|
-
*
|
4004
|
-
* Transactions are dry run in batches. After each dry run, transactions requiring
|
4005
|
-
* further modifications are identified. The method iteratively updates these transactions
|
4006
|
-
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
4007
|
-
*
|
4008
|
-
* @param transactionRequests - Array of transaction request objects.
|
4009
|
-
* @returns A promise that resolves to an array of results for each transaction.
|
4010
|
-
*/
|
4011
|
-
async estimateMultipleTxDependencies(transactionRequests) {
|
4012
|
-
const results = transactionRequests.map(() => ({
|
4013
|
-
receipts: [],
|
4014
|
-
outputVariables: 0,
|
4015
|
-
missingContractIds: [],
|
4016
|
-
dryrunStatus: void 0
|
4017
|
-
}));
|
4018
|
-
const allRequests = clone3(transactionRequests);
|
4019
|
-
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4020
|
-
allRequests.forEach((req, index) => {
|
4021
|
-
if (req.type === TransactionType8.Script) {
|
4022
|
-
serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
|
4023
|
-
}
|
4024
|
-
});
|
4025
|
-
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
4026
|
-
let attempt = 0;
|
4027
|
-
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
4028
|
-
const encodedTransactions = transactionsToProcess.map(
|
4029
|
-
(index) => serializedTransactionsMap.get(index)
|
4030
|
-
);
|
4031
|
-
const dryRunResults = await this.operations.dryRun({
|
4032
|
-
encodedTransactions,
|
4033
|
-
utxoValidation: false
|
4034
|
-
});
|
4035
|
-
const nextRoundTransactions = [];
|
4036
|
-
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
4037
|
-
const requestIdx = transactionsToProcess[i];
|
4038
|
-
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4039
|
-
const result = results[requestIdx];
|
4040
|
-
result.receipts = rawReceipts.map(processGqlReceipt);
|
4041
|
-
result.dryrunStatus = status;
|
4042
|
-
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4043
|
-
result.receipts
|
4044
|
-
);
|
4045
|
-
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4046
|
-
const request = allRequests[requestIdx];
|
4047
|
-
if (hasMissingOutputs && request?.type === TransactionType8.Script) {
|
4048
|
-
result.outputVariables += missingOutputVariables.length;
|
4049
|
-
request.addVariableOutputs(missingOutputVariables.length);
|
4050
|
-
missingOutputContractIds.forEach(({ contractId }) => {
|
4051
|
-
request.addContractInputAndOutput(Address2.fromString(contractId));
|
4052
|
-
result.missingContractIds.push(contractId);
|
4053
|
-
});
|
4054
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
4055
|
-
transactionRequest: request
|
4056
|
-
});
|
4057
|
-
request.maxFee = maxFee;
|
4058
|
-
serializedTransactionsMap.set(requestIdx, hexlify12(request.toTransactionBytes()));
|
4059
|
-
nextRoundTransactions.push(requestIdx);
|
4060
|
-
}
|
4061
|
-
}
|
4062
|
-
transactionsToProcess = nextRoundTransactions;
|
4063
|
-
attempt += 1;
|
4064
|
-
}
|
4065
|
-
return results;
|
4066
|
-
}
|
4067
|
-
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
4068
|
-
if (estimateTxDependencies) {
|
4069
|
-
return this.estimateMultipleTxDependencies(transactionRequests);
|
4070
|
-
}
|
4071
|
-
const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
|
4072
|
-
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4073
|
-
encodedTransactions,
|
4074
|
-
utxoValidation: utxoValidation || false
|
4075
|
-
});
|
4076
|
-
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4077
|
-
const receipts = rawReceipts.map(processGqlReceipt);
|
4078
|
-
return { receipts, dryrunStatus: status };
|
4079
|
-
});
|
4080
|
-
return results;
|
4081
|
-
}
|
4082
3877
|
/**
|
4083
3878
|
* Estimates the transaction gas and fee based on the provided transaction request.
|
4084
3879
|
* @param transactionRequest - The transaction request object.
|
4085
3880
|
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
4086
3881
|
*/
|
4087
|
-
|
3882
|
+
estimateTxGasAndFee(params) {
|
4088
3883
|
const { transactionRequest } = params;
|
4089
|
-
|
3884
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
4090
3885
|
const chainInfo = this.getChain();
|
4091
|
-
const
|
3886
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
3887
|
+
transactionRequest.gasPrice = gasPrice;
|
4092
3888
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
4093
|
-
|
4094
|
-
gasPrice = await this.estimateGasPrice(10);
|
4095
|
-
}
|
4096
|
-
const minFee = calculateGasFee({
|
4097
|
-
gasPrice: bn16(gasPrice),
|
4098
|
-
gas: minGas,
|
4099
|
-
priceFactor: gasPriceFactor,
|
4100
|
-
tip: transactionRequest.tip
|
4101
|
-
}).add(1);
|
4102
|
-
let gasLimit = bn16(0);
|
3889
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4103
3890
|
if (transactionRequest.type === TransactionType8.Script) {
|
4104
|
-
gasLimit = transactionRequest.gasLimit;
|
4105
3891
|
if (transactionRequest.gasLimit.eq(0)) {
|
4106
3892
|
transactionRequest.gasLimit = minGas;
|
4107
3893
|
transactionRequest.gasLimit = maxGasPerTx.sub(
|
4108
3894
|
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
4109
3895
|
);
|
4110
|
-
gasLimit = transactionRequest.gasLimit;
|
4111
3896
|
}
|
4112
3897
|
}
|
4113
3898
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4114
|
-
const maxFee =
|
4115
|
-
gasPrice: bn16(gasPrice),
|
4116
|
-
gas: maxGas,
|
4117
|
-
priceFactor: gasPriceFactor,
|
4118
|
-
tip: transactionRequest.tip
|
4119
|
-
}).add(1);
|
3899
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4120
3900
|
return {
|
4121
3901
|
minGas,
|
4122
3902
|
minFee,
|
4123
3903
|
maxGas,
|
4124
|
-
maxFee
|
4125
|
-
gasPrice,
|
4126
|
-
gasLimit
|
3904
|
+
maxFee
|
4127
3905
|
};
|
4128
3906
|
}
|
4129
3907
|
/**
|
@@ -4141,17 +3919,15 @@ var _Provider = class {
|
|
4141
3919
|
if (estimateTxDependencies) {
|
4142
3920
|
return this.estimateTxDependencies(transactionRequest);
|
4143
3921
|
}
|
4144
|
-
const
|
4145
|
-
const { dryRun:
|
4146
|
-
|
3922
|
+
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
3923
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3924
|
+
encodedTransaction,
|
4147
3925
|
utxoValidation: true
|
4148
3926
|
});
|
4149
|
-
const
|
4150
|
-
|
4151
|
-
|
4152
|
-
|
4153
|
-
});
|
4154
|
-
return { receipts: callResult[0].receipts };
|
3927
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
3928
|
+
return {
|
3929
|
+
receipts
|
3930
|
+
};
|
4155
3931
|
}
|
4156
3932
|
/**
|
4157
3933
|
* Returns a transaction cost to enable user
|
@@ -4168,80 +3944,78 @@ var _Provider = class {
|
|
4168
3944
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
4169
3945
|
* @returns A promise that resolves to the transaction cost object.
|
4170
3946
|
*/
|
4171
|
-
async getTransactionCost(transactionRequestLike,
|
3947
|
+
async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
|
3948
|
+
estimateTxDependencies = true,
|
3949
|
+
estimatePredicates = true,
|
3950
|
+
resourcesOwner,
|
3951
|
+
signatureCallback
|
3952
|
+
} = {}) {
|
4172
3953
|
const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
|
3954
|
+
const { minGasPrice } = this.getGasConfig();
|
3955
|
+
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
4173
3956
|
const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
|
4174
3957
|
const baseAssetId = this.getBaseAssetId();
|
4175
3958
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4176
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
3959
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
4177
3960
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4178
|
-
txRequestClone.maxFee = bn16(0);
|
4179
3961
|
if (isScriptTransaction) {
|
4180
|
-
txRequestClone.gasLimit =
|
3962
|
+
txRequestClone.gasLimit = bn15(0);
|
4181
3963
|
}
|
4182
|
-
if (
|
4183
|
-
resourcesOwner
|
3964
|
+
if (estimatePredicates) {
|
3965
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
3966
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
3967
|
+
}
|
3968
|
+
await this.estimatePredicates(txRequestClone);
|
4184
3969
|
}
|
4185
|
-
const signedRequest = clone3(txRequestClone);
|
4186
|
-
let addedSignatures = 0;
|
4187
3970
|
if (signatureCallback && isScriptTransaction) {
|
4188
|
-
|
4189
|
-
await signatureCallback(signedRequest);
|
4190
|
-
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
3971
|
+
await signatureCallback(txRequestClone);
|
4191
3972
|
}
|
4192
|
-
|
4193
|
-
|
4194
|
-
transactionRequest: signedRequest
|
3973
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
3974
|
+
transactionRequest: txRequestClone
|
4195
3975
|
});
|
4196
3976
|
let receipts = [];
|
4197
3977
|
let missingContractIds = [];
|
4198
3978
|
let outputVariables = 0;
|
4199
|
-
let gasUsed =
|
4200
|
-
|
4201
|
-
|
4202
|
-
if (isScriptTransaction) {
|
4203
|
-
txRequestClone.gasLimit = gasLimit;
|
4204
|
-
if (signatureCallback) {
|
4205
|
-
await signatureCallback(txRequestClone);
|
4206
|
-
}
|
3979
|
+
let gasUsed = bn15(0);
|
3980
|
+
if (isScriptTransaction && estimateTxDependencies) {
|
3981
|
+
txRequestClone.gasPrice = bn15(0);
|
4207
3982
|
const result = await this.estimateTxDependencies(txRequestClone);
|
4208
3983
|
receipts = result.receipts;
|
4209
3984
|
outputVariables = result.outputVariables;
|
4210
3985
|
missingContractIds = result.missingContractIds;
|
4211
3986
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4212
3987
|
txRequestClone.gasLimit = gasUsed;
|
4213
|
-
|
4214
|
-
|
4215
|
-
|
3988
|
+
txRequestClone.gasPrice = setGasPrice;
|
3989
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
3990
|
+
transactionRequest: txRequestClone
|
4216
3991
|
}));
|
4217
3992
|
}
|
4218
3993
|
return {
|
4219
3994
|
requiredQuantities: allQuantities,
|
4220
3995
|
receipts,
|
4221
3996
|
gasUsed,
|
4222
|
-
|
3997
|
+
minGasPrice,
|
3998
|
+
gasPrice: setGasPrice,
|
4223
3999
|
minGas,
|
4224
4000
|
maxGas,
|
4225
4001
|
minFee,
|
4226
4002
|
maxFee,
|
4003
|
+
estimatedInputs: txRequestClone.inputs,
|
4227
4004
|
outputVariables,
|
4228
|
-
missingContractIds
|
4229
|
-
addedSignatures,
|
4230
|
-
estimatedPredicates: txRequestClone.inputs
|
4005
|
+
missingContractIds
|
4231
4006
|
};
|
4232
4007
|
}
|
4233
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
4008
|
+
async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
|
4234
4009
|
const ownerAddress = Address2.fromAddressOrString(owner);
|
4235
4010
|
const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
|
4236
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
4237
|
-
quantitiesToContract
|
4238
|
-
});
|
4011
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
|
4239
4012
|
transactionRequest.addResources(
|
4240
4013
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
4241
4014
|
);
|
4242
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4243
|
-
|
4244
|
-
|
4015
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4016
|
+
transactionRequest,
|
4017
|
+
forwardingQuantities
|
4018
|
+
);
|
4245
4019
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
4246
4020
|
return {
|
4247
4021
|
resources,
|
@@ -4263,10 +4037,11 @@ var _Provider = class {
|
|
4263
4037
|
return coins.map((coin) => ({
|
4264
4038
|
id: coin.utxoId,
|
4265
4039
|
assetId: coin.assetId,
|
4266
|
-
amount:
|
4040
|
+
amount: bn15(coin.amount),
|
4267
4041
|
owner: Address2.fromAddressOrString(coin.owner),
|
4268
|
-
|
4269
|
-
|
4042
|
+
maturity: bn15(coin.maturity).toNumber(),
|
4043
|
+
blockCreated: bn15(coin.blockCreated),
|
4044
|
+
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4270
4045
|
}));
|
4271
4046
|
}
|
4272
4047
|
/**
|
@@ -4303,9 +4078,9 @@ var _Provider = class {
|
|
4303
4078
|
switch (coin.__typename) {
|
4304
4079
|
case "MessageCoin":
|
4305
4080
|
return {
|
4306
|
-
amount:
|
4081
|
+
amount: bn15(coin.amount),
|
4307
4082
|
assetId: coin.assetId,
|
4308
|
-
daHeight:
|
4083
|
+
daHeight: bn15(coin.daHeight),
|
4309
4084
|
sender: Address2.fromAddressOrString(coin.sender),
|
4310
4085
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4311
4086
|
nonce: coin.nonce
|
@@ -4313,11 +4088,12 @@ var _Provider = class {
|
|
4313
4088
|
case "Coin":
|
4314
4089
|
return {
|
4315
4090
|
id: coin.utxoId,
|
4316
|
-
amount:
|
4091
|
+
amount: bn15(coin.amount),
|
4317
4092
|
assetId: coin.assetId,
|
4318
4093
|
owner: Address2.fromAddressOrString(coin.owner),
|
4319
|
-
|
4320
|
-
|
4094
|
+
maturity: bn15(coin.maturity).toNumber(),
|
4095
|
+
blockCreated: bn15(coin.blockCreated),
|
4096
|
+
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4321
4097
|
};
|
4322
4098
|
default:
|
4323
4099
|
return null;
|
@@ -4334,13 +4110,13 @@ var _Provider = class {
|
|
4334
4110
|
async getBlock(idOrHeight) {
|
4335
4111
|
let variables;
|
4336
4112
|
if (typeof idOrHeight === "number") {
|
4337
|
-
variables = { height:
|
4113
|
+
variables = { height: bn15(idOrHeight).toString(10) };
|
4338
4114
|
} else if (idOrHeight === "latest") {
|
4339
4115
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4340
4116
|
} else if (idOrHeight.length === 66) {
|
4341
4117
|
variables = { blockId: idOrHeight };
|
4342
4118
|
} else {
|
4343
|
-
variables = { blockId:
|
4119
|
+
variables = { blockId: bn15(idOrHeight).toString(10) };
|
4344
4120
|
}
|
4345
4121
|
const { block } = await this.operations.getBlock(variables);
|
4346
4122
|
if (!block) {
|
@@ -4348,7 +4124,7 @@ var _Provider = class {
|
|
4348
4124
|
}
|
4349
4125
|
return {
|
4350
4126
|
id: block.id,
|
4351
|
-
height:
|
4127
|
+
height: bn15(block.header.height),
|
4352
4128
|
time: block.header.time,
|
4353
4129
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4354
4130
|
};
|
@@ -4363,7 +4139,7 @@ var _Provider = class {
|
|
4363
4139
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4364
4140
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4365
4141
|
id: block.id,
|
4366
|
-
height:
|
4142
|
+
height: bn15(block.header.height),
|
4367
4143
|
time: block.header.time,
|
4368
4144
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4369
4145
|
}));
|
@@ -4378,7 +4154,7 @@ var _Provider = class {
|
|
4378
4154
|
async getBlockWithTransactions(idOrHeight) {
|
4379
4155
|
let variables;
|
4380
4156
|
if (typeof idOrHeight === "number") {
|
4381
|
-
variables = { blockHeight:
|
4157
|
+
variables = { blockHeight: bn15(idOrHeight).toString(10) };
|
4382
4158
|
} else if (idOrHeight === "latest") {
|
4383
4159
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4384
4160
|
} else {
|
@@ -4390,7 +4166,7 @@ var _Provider = class {
|
|
4390
4166
|
}
|
4391
4167
|
return {
|
4392
4168
|
id: block.id,
|
4393
|
-
height:
|
4169
|
+
height: bn15(block.header.height, 10),
|
4394
4170
|
time: block.header.time,
|
4395
4171
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4396
4172
|
transactions: block.transactions.map(
|
@@ -4439,7 +4215,7 @@ var _Provider = class {
|
|
4439
4215
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4440
4216
|
asset: hexlify12(assetId)
|
4441
4217
|
});
|
4442
|
-
return
|
4218
|
+
return bn15(contractBalance.amount, 10);
|
4443
4219
|
}
|
4444
4220
|
/**
|
4445
4221
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4453,7 +4229,7 @@ var _Provider = class {
|
|
4453
4229
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4454
4230
|
assetId: hexlify12(assetId)
|
4455
4231
|
});
|
4456
|
-
return
|
4232
|
+
return bn15(balance.amount, 10);
|
4457
4233
|
}
|
4458
4234
|
/**
|
4459
4235
|
* Returns balances for the given owner.
|
@@ -4471,7 +4247,7 @@ var _Provider = class {
|
|
4471
4247
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4472
4248
|
return balances.map((balance) => ({
|
4473
4249
|
assetId: balance.assetId,
|
4474
|
-
amount:
|
4250
|
+
amount: bn15(balance.amount)
|
4475
4251
|
}));
|
4476
4252
|
}
|
4477
4253
|
/**
|
@@ -4493,15 +4269,15 @@ var _Provider = class {
|
|
4493
4269
|
sender: message.sender,
|
4494
4270
|
recipient: message.recipient,
|
4495
4271
|
nonce: message.nonce,
|
4496
|
-
amount:
|
4272
|
+
amount: bn15(message.amount),
|
4497
4273
|
data: message.data
|
4498
4274
|
}),
|
4499
4275
|
sender: Address2.fromAddressOrString(message.sender),
|
4500
4276
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4501
4277
|
nonce: message.nonce,
|
4502
|
-
amount:
|
4278
|
+
amount: bn15(message.amount),
|
4503
4279
|
data: InputMessageCoder.decodeData(message.data),
|
4504
|
-
daHeight:
|
4280
|
+
daHeight: bn15(message.daHeight)
|
4505
4281
|
}));
|
4506
4282
|
}
|
4507
4283
|
/**
|
@@ -4554,60 +4330,44 @@ var _Provider = class {
|
|
4554
4330
|
} = result.messageProof;
|
4555
4331
|
return {
|
4556
4332
|
messageProof: {
|
4557
|
-
proofIndex:
|
4333
|
+
proofIndex: bn15(messageProof.proofIndex),
|
4558
4334
|
proofSet: messageProof.proofSet
|
4559
4335
|
},
|
4560
4336
|
blockProof: {
|
4561
|
-
proofIndex:
|
4337
|
+
proofIndex: bn15(blockProof.proofIndex),
|
4562
4338
|
proofSet: blockProof.proofSet
|
4563
4339
|
},
|
4564
4340
|
messageBlockHeader: {
|
4565
4341
|
id: messageBlockHeader.id,
|
4566
|
-
daHeight:
|
4567
|
-
transactionsCount:
|
4342
|
+
daHeight: bn15(messageBlockHeader.daHeight),
|
4343
|
+
transactionsCount: bn15(messageBlockHeader.transactionsCount),
|
4568
4344
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4569
|
-
height:
|
4345
|
+
height: bn15(messageBlockHeader.height),
|
4570
4346
|
prevRoot: messageBlockHeader.prevRoot,
|
4571
4347
|
time: messageBlockHeader.time,
|
4572
4348
|
applicationHash: messageBlockHeader.applicationHash,
|
4573
|
-
|
4574
|
-
|
4575
|
-
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4576
|
-
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4577
|
-
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4349
|
+
messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
|
4350
|
+
messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
|
4578
4351
|
},
|
4579
4352
|
commitBlockHeader: {
|
4580
4353
|
id: commitBlockHeader.id,
|
4581
|
-
daHeight:
|
4582
|
-
transactionsCount:
|
4354
|
+
daHeight: bn15(commitBlockHeader.daHeight),
|
4355
|
+
transactionsCount: bn15(commitBlockHeader.transactionsCount),
|
4583
4356
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4584
|
-
height:
|
4357
|
+
height: bn15(commitBlockHeader.height),
|
4585
4358
|
prevRoot: commitBlockHeader.prevRoot,
|
4586
4359
|
time: commitBlockHeader.time,
|
4587
4360
|
applicationHash: commitBlockHeader.applicationHash,
|
4588
|
-
|
4589
|
-
|
4590
|
-
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4591
|
-
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4592
|
-
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4361
|
+
messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
|
4362
|
+
messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
|
4593
4363
|
},
|
4594
4364
|
sender: Address2.fromAddressOrString(sender),
|
4595
4365
|
recipient: Address2.fromAddressOrString(recipient),
|
4596
4366
|
nonce,
|
4597
|
-
amount:
|
4367
|
+
amount: bn15(amount),
|
4598
4368
|
data
|
4599
4369
|
};
|
4600
4370
|
}
|
4601
|
-
async getLatestGasPrice() {
|
4602
|
-
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4603
|
-
return bn16(latestGasPrice.gasPrice);
|
4604
|
-
}
|
4605
|
-
async estimateGasPrice(blockHorizon) {
|
4606
|
-
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4607
|
-
blockHorizon: String(blockHorizon)
|
4608
|
-
});
|
4609
|
-
return bn16(estimateGasPrice.gasPrice);
|
4610
|
-
}
|
4611
4371
|
/**
|
4612
4372
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
4613
4373
|
*
|
@@ -4627,10 +4387,10 @@ var _Provider = class {
|
|
4627
4387
|
*/
|
4628
4388
|
async produceBlocks(amount, startTime) {
|
4629
4389
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4630
|
-
blocksToProduce:
|
4390
|
+
blocksToProduce: bn15(amount).toString(10),
|
4631
4391
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4632
4392
|
});
|
4633
|
-
return
|
4393
|
+
return bn15(latestBlockHeight);
|
4634
4394
|
}
|
4635
4395
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4636
4396
|
async getTransactionResponse(transactionId) {
|
@@ -4644,7 +4404,7 @@ cacheInputs_fn = function(inputs) {
|
|
4644
4404
|
return;
|
4645
4405
|
}
|
4646
4406
|
inputs.forEach((input) => {
|
4647
|
-
if (input.type ===
|
4407
|
+
if (input.type === InputType6.Coin) {
|
4648
4408
|
this.cache?.set(input.id);
|
4649
4409
|
}
|
4650
4410
|
});
|
@@ -4654,7 +4414,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4654
4414
|
|
4655
4415
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4656
4416
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4657
|
-
import { bn as
|
4417
|
+
import { bn as bn16 } from "@fuel-ts/math";
|
4658
4418
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4659
4419
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4660
4420
|
|
@@ -4901,31 +4661,38 @@ var Account = class extends AbstractAccount {
|
|
4901
4661
|
* @param fee - The estimated transaction fee.
|
4902
4662
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4903
4663
|
*/
|
4904
|
-
async fund(request,
|
4905
|
-
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
4664
|
+
async fund(request, coinQuantities, fee) {
|
4906
4665
|
const baseAssetId = this.provider.getBaseAssetId();
|
4907
|
-
const
|
4908
|
-
|
4909
|
-
amount: bn18(fee),
|
4666
|
+
const updatedQuantities = addAmountToAsset({
|
4667
|
+
amount: bn17(fee),
|
4910
4668
|
assetId: baseAssetId,
|
4911
|
-
coinQuantities
|
4669
|
+
coinQuantities
|
4912
4670
|
});
|
4913
4671
|
const quantitiesDict = {};
|
4914
|
-
|
4672
|
+
updatedQuantities.forEach(({ amount, assetId }) => {
|
4915
4673
|
quantitiesDict[assetId] = {
|
4916
4674
|
required: amount,
|
4917
|
-
owned:
|
4675
|
+
owned: bn17(0)
|
4918
4676
|
};
|
4919
4677
|
});
|
4920
|
-
|
4678
|
+
const cachedUtxos = [];
|
4679
|
+
const cachedMessages = [];
|
4680
|
+
const owner = this.address.toB256();
|
4681
|
+
request.inputs.forEach((input) => {
|
4921
4682
|
const isResource = "amount" in input;
|
4922
|
-
if (
|
4923
|
-
|
4924
|
-
|
4925
|
-
|
4926
|
-
|
4927
|
-
|
4928
|
-
|
4683
|
+
if (isResource) {
|
4684
|
+
const isCoin2 = "owner" in input;
|
4685
|
+
if (isCoin2) {
|
4686
|
+
const assetId = String(input.assetId);
|
4687
|
+
if (input.owner === owner && quantitiesDict[assetId]) {
|
4688
|
+
const amount = bn17(input.amount);
|
4689
|
+
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4690
|
+
cachedUtxos.push(input.id);
|
4691
|
+
}
|
4692
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
4693
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
4694
|
+
cachedMessages.push(input.nonce);
|
4695
|
+
}
|
4929
4696
|
}
|
4930
4697
|
});
|
4931
4698
|
const missingQuantities = [];
|
@@ -4939,21 +4706,12 @@ var Account = class extends AbstractAccount {
|
|
4939
4706
|
});
|
4940
4707
|
const needsToBeFunded = missingQuantities.length;
|
4941
4708
|
if (needsToBeFunded) {
|
4942
|
-
const
|
4943
|
-
|
4944
|
-
|
4945
|
-
|
4946
|
-
|
4947
|
-
|
4948
|
-
const requestToReestimate = clone4(txRequest);
|
4949
|
-
if (addedSignatures) {
|
4950
|
-
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
4951
|
-
}
|
4952
|
-
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
4953
|
-
transactionRequest: requestToReestimate
|
4954
|
-
});
|
4955
|
-
txRequest.maxFee = maxFee;
|
4956
|
-
return txRequest;
|
4709
|
+
const resources = await this.getResourcesToSpend(missingQuantities, {
|
4710
|
+
messages: cachedMessages,
|
4711
|
+
utxos: cachedUtxos
|
4712
|
+
});
|
4713
|
+
request.addResources(resources);
|
4714
|
+
}
|
4957
4715
|
}
|
4958
4716
|
/**
|
4959
4717
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -4961,25 +4719,29 @@ var Account = class extends AbstractAccount {
|
|
4961
4719
|
* @param destination - The address of the destination.
|
4962
4720
|
* @param amount - The amount of coins to transfer.
|
4963
4721
|
* @param assetId - The asset ID of the coins to transfer.
|
4964
|
-
* @param txParams - The transaction parameters (gasLimit,
|
4722
|
+
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4965
4723
|
* @returns A promise that resolves to the prepared transaction request.
|
4966
4724
|
*/
|
4967
4725
|
async createTransfer(destination, amount, assetId, txParams = {}) {
|
4968
|
-
const
|
4726
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
4969
4727
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
4728
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
4729
|
+
const request = new ScriptTransactionRequest(params);
|
4970
4730
|
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
|
4971
|
-
const
|
4731
|
+
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
4972
4732
|
estimateTxDependencies: true,
|
4973
4733
|
resourcesOwner: this
|
4974
4734
|
});
|
4975
|
-
|
4976
|
-
|
4977
|
-
|
4978
|
-
|
4735
|
+
request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
|
4736
|
+
request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
|
4737
|
+
this.validateGas({
|
4738
|
+
gasUsed,
|
4739
|
+
gasPrice: request.gasPrice,
|
4740
|
+
gasLimit: request.gasLimit,
|
4741
|
+
minGasPrice
|
4979
4742
|
});
|
4980
|
-
request
|
4981
|
-
request.
|
4982
|
-
await this.fund(request, txCost);
|
4743
|
+
await this.fund(request, requiredQuantities, maxFee);
|
4744
|
+
request.updatePredicateInputs(estimatedInputs);
|
4983
4745
|
return request;
|
4984
4746
|
}
|
4985
4747
|
/**
|
@@ -4988,11 +4750,11 @@ var Account = class extends AbstractAccount {
|
|
4988
4750
|
* @param destination - The address of the destination.
|
4989
4751
|
* @param amount - The amount of coins to transfer.
|
4990
4752
|
* @param assetId - The asset ID of the coins to transfer.
|
4991
|
-
* @param txParams - The transaction parameters (gasLimit, maturity).
|
4753
|
+
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4992
4754
|
* @returns A promise that resolves to the transaction response.
|
4993
4755
|
*/
|
4994
4756
|
async transfer(destination, amount, assetId, txParams = {}) {
|
4995
|
-
if (
|
4757
|
+
if (bn17(amount).lte(0)) {
|
4996
4758
|
throw new FuelError15(
|
4997
4759
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
4998
4760
|
"Transfer amount must be a positive number."
|
@@ -5012,37 +4774,39 @@ var Account = class extends AbstractAccount {
|
|
5012
4774
|
* @returns A promise that resolves to the transaction response.
|
5013
4775
|
*/
|
5014
4776
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5015
|
-
if (
|
4777
|
+
if (bn17(amount).lte(0)) {
|
5016
4778
|
throw new FuelError15(
|
5017
4779
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5018
4780
|
"Transfer amount must be a positive number."
|
5019
4781
|
);
|
5020
4782
|
}
|
5021
4783
|
const contractAddress = Address3.fromAddressOrString(contractId);
|
4784
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
5022
4785
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
4786
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
5023
4787
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5024
4788
|
hexlifiedContractId: contractAddress.toB256(),
|
5025
|
-
amountToTransfer:
|
4789
|
+
amountToTransfer: bn17(amount),
|
5026
4790
|
assetId: assetIdToTransfer
|
5027
4791
|
});
|
5028
4792
|
const request = new ScriptTransactionRequest({
|
5029
|
-
...
|
4793
|
+
...params,
|
5030
4794
|
script,
|
5031
4795
|
scriptData
|
5032
4796
|
});
|
5033
4797
|
request.addContractInputAndOutput(contractAddress);
|
5034
|
-
const
|
5035
|
-
|
5036
|
-
|
5037
|
-
|
5038
|
-
|
5039
|
-
|
5040
|
-
|
5041
|
-
|
4798
|
+
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
4799
|
+
request,
|
4800
|
+
[{ amount: bn17(amount), assetId: String(assetIdToTransfer) }]
|
4801
|
+
);
|
4802
|
+
request.gasLimit = bn17(params.gasLimit ?? gasUsed);
|
4803
|
+
this.validateGas({
|
4804
|
+
gasUsed,
|
4805
|
+
gasPrice: request.gasPrice,
|
4806
|
+
gasLimit: request.gasLimit,
|
4807
|
+
minGasPrice
|
5042
4808
|
});
|
5043
|
-
request
|
5044
|
-
request.maxFee = txCost.maxFee;
|
5045
|
-
await this.fund(request, txCost);
|
4809
|
+
await this.fund(request, requiredQuantities, maxFee);
|
5046
4810
|
return this.sendTransaction(request);
|
5047
4811
|
}
|
5048
4812
|
/**
|
@@ -5054,31 +4818,39 @@ var Account = class extends AbstractAccount {
|
|
5054
4818
|
* @returns A promise that resolves to the transaction response.
|
5055
4819
|
*/
|
5056
4820
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4821
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
4822
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
5057
4823
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
5058
4824
|
const recipientDataArray = arrayify14(
|
5059
4825
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5060
4826
|
);
|
5061
4827
|
const amountDataArray = arrayify14(
|
5062
|
-
"0x".concat(
|
4828
|
+
"0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
|
5063
4829
|
);
|
5064
4830
|
const script = new Uint8Array([
|
5065
4831
|
...arrayify14(withdrawScript.bytes),
|
5066
4832
|
...recipientDataArray,
|
5067
4833
|
...amountDataArray
|
5068
4834
|
]);
|
5069
|
-
const params = {
|
5070
|
-
|
4835
|
+
const params = {
|
4836
|
+
script,
|
4837
|
+
gasPrice: minGasPrice,
|
4838
|
+
...txParams
|
4839
|
+
};
|
5071
4840
|
const request = new ScriptTransactionRequest(params);
|
5072
|
-
const
|
5073
|
-
const
|
5074
|
-
|
5075
|
-
|
5076
|
-
|
5077
|
-
|
4841
|
+
const forwardingQuantities = [{ amount: bn17(amount), assetId: baseAssetId }];
|
4842
|
+
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
4843
|
+
request,
|
4844
|
+
forwardingQuantities
|
4845
|
+
);
|
4846
|
+
request.gasLimit = bn17(params.gasLimit ?? gasUsed);
|
4847
|
+
this.validateGas({
|
4848
|
+
gasUsed,
|
4849
|
+
gasPrice: request.gasPrice,
|
4850
|
+
gasLimit: request.gasLimit,
|
4851
|
+
minGasPrice
|
5078
4852
|
});
|
5079
|
-
request
|
5080
|
-
request.gasLimit = txCost.gasUsed;
|
5081
|
-
await this.fund(request, txCost);
|
4853
|
+
await this.fund(request, requiredQuantities, maxFee);
|
5082
4854
|
return this.sendTransaction(request);
|
5083
4855
|
}
|
5084
4856
|
async signMessage(message) {
|
@@ -5136,21 +4908,22 @@ var Account = class extends AbstractAccount {
|
|
5136
4908
|
}
|
5137
4909
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5138
4910
|
}
|
5139
|
-
|
5140
|
-
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
|
4911
|
+
validateGas({
|
5141
4912
|
gasUsed,
|
5142
|
-
|
4913
|
+
gasPrice,
|
4914
|
+
gasLimit,
|
4915
|
+
minGasPrice
|
5143
4916
|
}) {
|
5144
|
-
if (
|
4917
|
+
if (minGasPrice.gt(gasPrice)) {
|
5145
4918
|
throw new FuelError15(
|
5146
|
-
ErrorCode15.
|
5147
|
-
`Gas
|
4919
|
+
ErrorCode15.GAS_PRICE_TOO_LOW,
|
4920
|
+
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
5148
4921
|
);
|
5149
4922
|
}
|
5150
|
-
if (
|
4923
|
+
if (gasUsed.gt(gasLimit)) {
|
5151
4924
|
throw new FuelError15(
|
5152
|
-
ErrorCode15.
|
5153
|
-
`
|
4925
|
+
ErrorCode15.GAS_LIMIT_TOO_LOW,
|
4926
|
+
`Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
|
5154
4927
|
);
|
5155
4928
|
}
|
5156
4929
|
}
|
@@ -5438,7 +5211,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5438
5211
|
* @param transactionRequestLike - The transaction request to send.
|
5439
5212
|
* @returns A promise that resolves to the TransactionResponse object.
|
5440
5213
|
*/
|
5441
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
5214
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
5442
5215
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5443
5216
|
if (estimateTxDependencies) {
|
5444
5217
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -5479,7 +5252,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5479
5252
|
// src/hdwallet/hdwallet.ts
|
5480
5253
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5481
5254
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5482
|
-
import { bn as
|
5255
|
+
import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5483
5256
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5484
5257
|
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5485
5258
|
|
@@ -7945,7 +7718,7 @@ var HDWallet = class {
|
|
7945
7718
|
const IR = bytes.slice(32);
|
7946
7719
|
if (privateKey) {
|
7947
7720
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7948
|
-
const ki =
|
7721
|
+
const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
|
7949
7722
|
return new HDWallet({
|
7950
7723
|
privateKey: ki,
|
7951
7724
|
chainCode: IR,
|
@@ -8216,15 +7989,14 @@ var seedTestWallet = async (wallet, quantities) => {
|
|
8216
7989
|
process.env.GENESIS_SECRET || randomBytes5(32),
|
8217
7990
|
wallet.provider
|
8218
7991
|
);
|
8219
|
-
const
|
8220
|
-
|
8221
|
-
|
8222
|
-
|
7992
|
+
const resources = await genesisWallet.getResourcesToSpend(quantities);
|
7993
|
+
const { minGasPrice } = genesisWallet.provider.getGasConfig();
|
7994
|
+
const request = new ScriptTransactionRequest({
|
7995
|
+
gasLimit: 1e4,
|
7996
|
+
gasPrice: minGasPrice
|
8223
7997
|
});
|
8224
|
-
|
8225
|
-
request.
|
8226
|
-
request.maxFee = txCost.maxFee;
|
8227
|
-
await genesisWallet.fund(request, txCost);
|
7998
|
+
request.addResources(resources);
|
7999
|
+
quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
|
8228
8000
|
await genesisWallet.sendTransaction(request, { awaitExecution: true });
|
8229
8001
|
};
|
8230
8002
|
|
@@ -8238,9 +8010,9 @@ var generateTestWallet = async (provider, quantities) => {
|
|
8238
8010
|
};
|
8239
8011
|
|
8240
8012
|
// src/test-utils/launchNode.ts
|
8241
|
-
import {
|
8242
|
-
import {
|
8243
|
-
import {
|
8013
|
+
import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
|
8014
|
+
import { toHex as toHex2 } from "@fuel-ts/math";
|
8015
|
+
import { defaultChainConfig, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
|
8244
8016
|
import { findBinPath } from "@fuel-ts/utils/cli-utils";
|
8245
8017
|
import { spawn } from "child_process";
|
8246
8018
|
import { randomUUID } from "crypto";
|
@@ -8292,12 +8064,12 @@ var launchNode = async ({
|
|
8292
8064
|
// eslint-disable-next-line no-async-promise-executor
|
8293
8065
|
new Promise(async (resolve, reject) => {
|
8294
8066
|
const remainingArgs = extractRemainingArgs(args, [
|
8295
|
-
"--
|
8067
|
+
"--chain",
|
8296
8068
|
"--consensus-key",
|
8297
8069
|
"--db-type",
|
8298
8070
|
"--poa-instant"
|
8299
8071
|
]);
|
8300
|
-
const chainConfigPath = getFlagValueFromArgs(args, "--
|
8072
|
+
const chainConfigPath = getFlagValueFromArgs(args, "--chain");
|
8301
8073
|
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || defaultConsensusKey;
|
8302
8074
|
const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
|
8303
8075
|
const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
|
@@ -8316,54 +8088,36 @@ var launchNode = async ({
|
|
8316
8088
|
let chainConfigPathToUse;
|
8317
8089
|
const prefix = basePath || os.tmpdir();
|
8318
8090
|
const suffix = basePath ? "" : randomUUID();
|
8319
|
-
const tempDirPath = path.join(prefix, ".fuels", suffix
|
8091
|
+
const tempDirPath = path.join(prefix, ".fuels", suffix);
|
8320
8092
|
if (chainConfigPath) {
|
8321
8093
|
chainConfigPathToUse = chainConfigPath;
|
8322
8094
|
} else {
|
8323
8095
|
if (!existsSync(tempDirPath)) {
|
8324
8096
|
mkdirSync(tempDirPath, { recursive: true });
|
8325
8097
|
}
|
8326
|
-
|
8327
|
-
|
8328
|
-
stateConfigJson = {
|
8329
|
-
...stateConfigJson,
|
8330
|
-
coins: [
|
8331
|
-
...stateConfigJson.coins.map((coin) => ({
|
8332
|
-
...coin,
|
8333
|
-
amount: "18446744073709551615"
|
8334
|
-
}))
|
8335
|
-
],
|
8336
|
-
messages: stateConfigJson.messages.map((message) => ({
|
8337
|
-
...message,
|
8338
|
-
amount: "18446744073709551615"
|
8339
|
-
}))
|
8340
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8341
|
-
};
|
8098
|
+
const tempChainConfigFilePath = path.join(tempDirPath, "chainConfig.json");
|
8099
|
+
let chainConfig = defaultChainConfig;
|
8342
8100
|
if (!process.env.GENESIS_SECRET) {
|
8343
8101
|
const pk = Signer.generatePrivateKey();
|
8344
8102
|
const signer = new Signer(pk);
|
8345
8103
|
process.env.GENESIS_SECRET = hexlify18(pk);
|
8346
|
-
|
8347
|
-
|
8348
|
-
|
8349
|
-
|
8350
|
-
|
8351
|
-
|
8352
|
-
|
8353
|
-
|
8354
|
-
|
8355
|
-
|
8104
|
+
chainConfig = {
|
8105
|
+
...defaultChainConfig,
|
8106
|
+
initial_state: {
|
8107
|
+
...defaultChainConfig.initial_state,
|
8108
|
+
coins: [
|
8109
|
+
...defaultChainConfig.initial_state.coins,
|
8110
|
+
{
|
8111
|
+
owner: signer.address.toHexString(),
|
8112
|
+
amount: toHex2(1e9),
|
8113
|
+
asset_id: defaultChainConfig?.consensus_parameters?.base_asset_id ?? ZeroBytes329
|
8114
|
+
}
|
8115
|
+
]
|
8116
|
+
}
|
8117
|
+
};
|
8356
8118
|
}
|
8357
|
-
|
8358
|
-
|
8359
|
-
fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
|
8360
|
-
const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
|
8361
|
-
const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
|
8362
|
-
const metadataWritePath = path.join(tempDirPath, "metadata.json");
|
8363
|
-
writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
|
8364
|
-
writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
|
8365
|
-
writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
|
8366
|
-
chainConfigPathToUse = tempDirPath;
|
8119
|
+
writeFileSync(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
|
8120
|
+
chainConfigPathToUse = tempChainConfigFilePath;
|
8367
8121
|
}
|
8368
8122
|
const child = spawn(
|
8369
8123
|
command,
|
@@ -8372,10 +8126,10 @@ var launchNode = async ({
|
|
8372
8126
|
["--ip", ipToUse],
|
8373
8127
|
["--port", portToUse],
|
8374
8128
|
useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
|
8375
|
-
["--min-gas-price", "
|
8129
|
+
["--min-gas-price", "0"],
|
8376
8130
|
poaInstant ? ["--poa-instant", "true"] : [],
|
8377
8131
|
["--consensus-key", consensusKey],
|
8378
|
-
["--
|
8132
|
+
["--chain", chainConfigPathToUse],
|
8379
8133
|
"--vm-backtrace",
|
8380
8134
|
"--utxo-validation",
|
8381
8135
|
"--debug",
|
@@ -8435,7 +8189,7 @@ var launchNodeAndGetWallets = async ({
|
|
8435
8189
|
walletCount = 10
|
8436
8190
|
} = {}) => {
|
8437
8191
|
const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
|
8438
|
-
const provider = await Provider.create(`http://${ip}:${port}/
|
8192
|
+
const provider = await Provider.create(`http://${ip}:${port}/graphql`);
|
8439
8193
|
const wallets = await generateWallets(walletCount, provider);
|
8440
8194
|
const cleanup = () => {
|
8441
8195
|
closeNode();
|