@fuel-ts/account 0.0.0-rc-2021-20240423152230 → 0.0.0-rc-2037-20240423161807
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 +4 -5
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +604 -829
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +641 -857
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +459 -680
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +18 -11
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +327 -821
- 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 +1 -2
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +1 -6
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +27 -37
- 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/helpers.d.ts +10 -0
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -0
- package/dist/providers/transaction-request/index.d.ts +1 -0
- package/dist/providers/transaction-request/index.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +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 +11 -6
- 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/index.d.ts +1 -0
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/resources.d.ts +4 -0
- package/dist/test-utils/resources.d.ts.map +1 -0
- package/dist/test-utils/seedTestWallet.d.ts +1 -1
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils/transactionRequest.d.ts +5 -0
- package/dist/test-utils/transactionRequest.d.ts.map +1 -0
- package/dist/test-utils.global.js +1082 -1547
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +618 -839
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +450 -674
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +16 -16
package/dist/test-utils.mjs
CHANGED
@@ -27,9 +27,8 @@ import { Address as Address3 } from "@fuel-ts/address";
|
|
27
27
|
import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
|
28
28
|
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
29
29
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
30
|
-
import { bn as
|
30
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
31
31
|
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
32
|
-
import { clone as clone4 } from "ramda";
|
33
32
|
|
34
33
|
// src/providers/coin-quantity.ts
|
35
34
|
import { BaseAssetId } from "@fuel-ts/address/configs";
|
@@ -38,24 +37,24 @@ import { hexlify } from "@fuel-ts/utils";
|
|
38
37
|
var coinQuantityfy = (coinQuantityLike) => {
|
39
38
|
let assetId;
|
40
39
|
let amount;
|
41
|
-
let
|
40
|
+
let max2;
|
42
41
|
if (Array.isArray(coinQuantityLike)) {
|
43
42
|
amount = coinQuantityLike[0];
|
44
43
|
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
45
|
-
|
44
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
46
45
|
} else {
|
47
46
|
amount = coinQuantityLike.amount;
|
48
47
|
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
49
|
-
|
48
|
+
max2 = coinQuantityLike.max ?? void 0;
|
50
49
|
}
|
51
50
|
const bnAmount = bn(amount);
|
52
51
|
return {
|
53
52
|
assetId: hexlify(assetId),
|
54
53
|
amount: bnAmount.lt(1) ? bn(1) : bnAmount,
|
55
|
-
max:
|
54
|
+
max: max2 ? bn(max2) : void 0
|
56
55
|
};
|
57
56
|
};
|
58
|
-
var
|
57
|
+
var addAmountToAsset = (params) => {
|
59
58
|
const { amount, assetId } = params;
|
60
59
|
const coinQuantities = [...params.coinQuantities];
|
61
60
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -70,7 +69,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
70
69
|
// src/providers/provider.ts
|
71
70
|
import { Address as Address2 } from "@fuel-ts/address";
|
72
71
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
73
|
-
import { BN, bn as
|
72
|
+
import { BN, bn as bn15, max } from "@fuel-ts/math";
|
74
73
|
import {
|
75
74
|
InputType as InputType7,
|
76
75
|
TransactionType as TransactionType8,
|
@@ -86,40 +85,16 @@ import { clone as clone3 } from "ramda";
|
|
86
85
|
|
87
86
|
// src/providers/__generated__/operations.ts
|
88
87
|
import gql from "graphql-tag";
|
89
|
-
var TransactionStatusSubscriptionFragmentFragmentDoc = gql`
|
90
|
-
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
91
|
-
type: __typename
|
92
|
-
... on SubmittedStatus {
|
93
|
-
time
|
94
|
-
}
|
95
|
-
... on SuccessStatus {
|
96
|
-
block {
|
97
|
-
id
|
98
|
-
}
|
99
|
-
time
|
100
|
-
programState {
|
101
|
-
returnType
|
102
|
-
data
|
103
|
-
}
|
104
|
-
}
|
105
|
-
... on FailureStatus {
|
106
|
-
block {
|
107
|
-
id
|
108
|
-
}
|
109
|
-
time
|
110
|
-
reason
|
111
|
-
}
|
112
|
-
... on SqueezedOutStatus {
|
113
|
-
reason
|
114
|
-
}
|
115
|
-
}
|
116
|
-
`;
|
117
88
|
var ReceiptFragmentFragmentDoc = gql`
|
118
89
|
fragment receiptFragment on Receipt {
|
119
|
-
|
90
|
+
contract {
|
91
|
+
id
|
92
|
+
}
|
120
93
|
pc
|
121
94
|
is
|
122
|
-
to
|
95
|
+
to {
|
96
|
+
id
|
97
|
+
}
|
123
98
|
toAddress
|
124
99
|
amount
|
125
100
|
assetId
|
@@ -157,16 +132,10 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
157
132
|
id
|
158
133
|
}
|
159
134
|
time
|
160
|
-
receipts {
|
161
|
-
...receiptFragment
|
162
|
-
}
|
163
135
|
programState {
|
164
136
|
returnType
|
165
137
|
data
|
166
138
|
}
|
167
|
-
receipts {
|
168
|
-
...receiptFragment
|
169
|
-
}
|
170
139
|
}
|
171
140
|
... on FailureStatus {
|
172
141
|
block {
|
@@ -174,24 +143,26 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
174
143
|
}
|
175
144
|
time
|
176
145
|
reason
|
177
|
-
receipts {
|
178
|
-
...receiptFragment
|
179
|
-
}
|
180
146
|
}
|
181
147
|
... on SqueezedOutStatus {
|
182
148
|
reason
|
183
149
|
}
|
184
150
|
}
|
185
|
-
|
151
|
+
`;
|
186
152
|
var TransactionFragmentFragmentDoc = gql`
|
187
153
|
fragment transactionFragment on Transaction {
|
188
154
|
id
|
189
155
|
rawPayload
|
156
|
+
gasPrice
|
157
|
+
receipts {
|
158
|
+
...receiptFragment
|
159
|
+
}
|
190
160
|
status {
|
191
161
|
...transactionStatusFragment
|
192
162
|
}
|
193
163
|
}
|
194
|
-
${
|
164
|
+
${ReceiptFragmentFragmentDoc}
|
165
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
195
166
|
var InputEstimatePredicatesFragmentFragmentDoc = gql`
|
196
167
|
fragment inputEstimatePredicatesFragment on Input {
|
197
168
|
... on InputCoin {
|
@@ -209,46 +180,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
|
|
209
180
|
}
|
210
181
|
}
|
211
182
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
212
|
-
var DryRunFailureStatusFragmentFragmentDoc = gql`
|
213
|
-
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
214
|
-
reason
|
215
|
-
programState {
|
216
|
-
returnType
|
217
|
-
data
|
218
|
-
}
|
219
|
-
}
|
220
|
-
`;
|
221
|
-
var DryRunSuccessStatusFragmentFragmentDoc = gql`
|
222
|
-
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
223
|
-
programState {
|
224
|
-
returnType
|
225
|
-
data
|
226
|
-
}
|
227
|
-
}
|
228
|
-
`;
|
229
|
-
var DryRunTransactionStatusFragmentFragmentDoc = gql`
|
230
|
-
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
231
|
-
... on DryRunFailureStatus {
|
232
|
-
...dryRunFailureStatusFragment
|
233
|
-
}
|
234
|
-
... on DryRunSuccessStatus {
|
235
|
-
...dryRunSuccessStatusFragment
|
236
|
-
}
|
237
|
-
}
|
238
|
-
${DryRunFailureStatusFragmentFragmentDoc}
|
239
|
-
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
240
|
-
var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
|
241
|
-
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
242
|
-
id
|
243
|
-
status {
|
244
|
-
...dryRunTransactionStatusFragment
|
245
|
-
}
|
246
|
-
receipts {
|
247
|
-
...receiptFragment
|
248
|
-
}
|
249
|
-
}
|
250
|
-
${DryRunTransactionStatusFragmentFragmentDoc}
|
251
|
-
${ReceiptFragmentFragmentDoc}`;
|
252
183
|
var CoinFragmentFragmentDoc = gql`
|
253
184
|
fragment coinFragment on Coin {
|
254
185
|
__typename
|
@@ -256,6 +187,7 @@ var CoinFragmentFragmentDoc = gql`
|
|
256
187
|
owner
|
257
188
|
amount
|
258
189
|
assetId
|
190
|
+
maturity
|
259
191
|
blockCreated
|
260
192
|
txCreatedIdx
|
261
193
|
}
|
@@ -294,32 +226,26 @@ var MessageProofFragmentFragmentDoc = gql`
|
|
294
226
|
messageBlockHeader {
|
295
227
|
id
|
296
228
|
daHeight
|
297
|
-
consensusParametersVersion
|
298
|
-
stateTransitionBytecodeVersion
|
299
229
|
transactionsCount
|
300
|
-
messageReceiptCount
|
301
230
|
transactionsRoot
|
302
|
-
messageOutboxRoot
|
303
|
-
eventInboxRoot
|
304
231
|
height
|
305
232
|
prevRoot
|
306
233
|
time
|
307
234
|
applicationHash
|
235
|
+
messageReceiptRoot
|
236
|
+
messageReceiptCount
|
308
237
|
}
|
309
238
|
commitBlockHeader {
|
310
239
|
id
|
311
240
|
daHeight
|
312
|
-
consensusParametersVersion
|
313
|
-
stateTransitionBytecodeVersion
|
314
241
|
transactionsCount
|
315
|
-
messageReceiptCount
|
316
242
|
transactionsRoot
|
317
|
-
messageOutboxRoot
|
318
|
-
eventInboxRoot
|
319
243
|
height
|
320
244
|
prevRoot
|
321
245
|
time
|
322
246
|
applicationHash
|
247
|
+
messageReceiptRoot
|
248
|
+
messageReceiptCount
|
323
249
|
}
|
324
250
|
sender
|
325
251
|
recipient
|
@@ -338,8 +264,8 @@ var BalanceFragmentFragmentDoc = gql`
|
|
338
264
|
var BlockFragmentFragmentDoc = gql`
|
339
265
|
fragment blockFragment on Block {
|
340
266
|
id
|
341
|
-
height
|
342
267
|
header {
|
268
|
+
height
|
343
269
|
time
|
344
270
|
}
|
345
271
|
transactions {
|
@@ -397,11 +323,6 @@ var DependentCostFragmentFragmentDoc = gql`
|
|
397
323
|
`;
|
398
324
|
var GasCostsFragmentFragmentDoc = gql`
|
399
325
|
fragment GasCostsFragment on GasCosts {
|
400
|
-
version {
|
401
|
-
... on Version {
|
402
|
-
value
|
403
|
-
}
|
404
|
-
}
|
405
326
|
add
|
406
327
|
addi
|
407
328
|
aloc
|
@@ -414,6 +335,7 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
414
335
|
cb
|
415
336
|
cfei
|
416
337
|
cfsi
|
338
|
+
croo
|
417
339
|
div
|
418
340
|
divi
|
419
341
|
ecr1
|
@@ -496,9 +418,6 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
496
418
|
ccp {
|
497
419
|
...DependentCostFragment
|
498
420
|
}
|
499
|
-
croo {
|
500
|
-
...DependentCostFragment
|
501
|
-
}
|
502
421
|
csiz {
|
503
422
|
...DependentCostFragment
|
504
423
|
}
|
@@ -558,11 +477,6 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
558
477
|
${DependentCostFragmentFragmentDoc}`;
|
559
478
|
var ConsensusParametersFragmentFragmentDoc = gql`
|
560
479
|
fragment consensusParametersFragment on ConsensusParameters {
|
561
|
-
version {
|
562
|
-
... on Version {
|
563
|
-
value
|
564
|
-
}
|
565
|
-
}
|
566
480
|
txParams {
|
567
481
|
...TxParametersFragment
|
568
482
|
}
|
@@ -622,9 +536,18 @@ var NodeInfoFragmentFragmentDoc = gql`
|
|
622
536
|
fragment nodeInfoFragment on NodeInfo {
|
623
537
|
utxoValidation
|
624
538
|
vmBacktrace
|
539
|
+
minGasPrice
|
625
540
|
maxTx
|
626
541
|
maxDepth
|
627
542
|
nodeVersion
|
543
|
+
peers {
|
544
|
+
id
|
545
|
+
addresses
|
546
|
+
clientVersion
|
547
|
+
blockHeight
|
548
|
+
lastHeartbeatMs
|
549
|
+
appScore
|
550
|
+
}
|
628
551
|
}
|
629
552
|
`;
|
630
553
|
var GetVersionDocument = gql`
|
@@ -659,9 +582,13 @@ var GetTransactionWithReceiptsDocument = gql`
|
|
659
582
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
660
583
|
transaction(id: $transactionId) {
|
661
584
|
...transactionFragment
|
585
|
+
receipts {
|
586
|
+
...receiptFragment
|
587
|
+
}
|
662
588
|
}
|
663
589
|
}
|
664
|
-
${TransactionFragmentFragmentDoc}
|
590
|
+
${TransactionFragmentFragmentDoc}
|
591
|
+
${ReceiptFragmentFragmentDoc}`;
|
665
592
|
var GetTransactionsDocument = gql`
|
666
593
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
667
594
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -789,20 +716,6 @@ var GetBalanceDocument = gql`
|
|
789
716
|
}
|
790
717
|
}
|
791
718
|
${BalanceFragmentFragmentDoc}`;
|
792
|
-
var GetLatestGasPriceDocument = gql`
|
793
|
-
query getLatestGasPrice {
|
794
|
-
latestGasPrice {
|
795
|
-
gasPrice
|
796
|
-
}
|
797
|
-
}
|
798
|
-
`;
|
799
|
-
var EstimateGasPriceDocument = gql`
|
800
|
-
query estimateGasPrice($blockHorizon: U32!) {
|
801
|
-
estimateGasPrice(blockHorizon: $blockHorizon) {
|
802
|
-
gasPrice
|
803
|
-
}
|
804
|
-
}
|
805
|
-
`;
|
806
719
|
var GetBalancesDocument = gql`
|
807
720
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
808
721
|
balances(
|
@@ -857,12 +770,12 @@ var GetMessageStatusDocument = gql`
|
|
857
770
|
}
|
858
771
|
`;
|
859
772
|
var DryRunDocument = gql`
|
860
|
-
mutation dryRun($
|
861
|
-
dryRun(
|
862
|
-
...
|
773
|
+
mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
|
774
|
+
dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
|
775
|
+
...receiptFragment
|
863
776
|
}
|
864
777
|
}
|
865
|
-
${
|
778
|
+
${ReceiptFragmentFragmentDoc}`;
|
866
779
|
var SubmitDocument = gql`
|
867
780
|
mutation submit($encodedTransaction: HexString!) {
|
868
781
|
submit(tx: $encodedTransaction) {
|
@@ -881,17 +794,17 @@ var ProduceBlocksDocument = gql`
|
|
881
794
|
var SubmitAndAwaitDocument = gql`
|
882
795
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
883
796
|
submitAndAwait(tx: $encodedTransaction) {
|
884
|
-
...
|
797
|
+
...transactionStatusFragment
|
885
798
|
}
|
886
799
|
}
|
887
|
-
${
|
800
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
888
801
|
var StatusChangeDocument = gql`
|
889
802
|
subscription statusChange($transactionId: TransactionId!) {
|
890
803
|
statusChange(id: $transactionId) {
|
891
|
-
...
|
804
|
+
...transactionStatusFragment
|
892
805
|
}
|
893
806
|
}
|
894
|
-
${
|
807
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
895
808
|
function getSdk(requester) {
|
896
809
|
return {
|
897
810
|
getVersion(variables, options) {
|
@@ -945,12 +858,6 @@ function getSdk(requester) {
|
|
945
858
|
getBalance(variables, options) {
|
946
859
|
return requester(GetBalanceDocument, variables, options);
|
947
860
|
},
|
948
|
-
getLatestGasPrice(variables, options) {
|
949
|
-
return requester(GetLatestGasPriceDocument, variables, options);
|
950
|
-
},
|
951
|
-
estimateGasPrice(variables, options) {
|
952
|
-
return requester(EstimateGasPriceDocument, variables, options);
|
953
|
-
},
|
954
861
|
getBalances(variables, options) {
|
955
862
|
return requester(GetBalancesDocument, variables, options);
|
956
863
|
},
|
@@ -1144,9 +1051,10 @@ var inputify = (value) => {
|
|
1144
1051
|
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
1145
1052
|
},
|
1146
1053
|
witnessIndex: value.witnessIndex,
|
1054
|
+
maturity: value.maturity ?? 0,
|
1147
1055
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1148
|
-
predicateLength:
|
1149
|
-
predicateDataLength:
|
1056
|
+
predicateLength: predicate.length,
|
1057
|
+
predicateDataLength: predicateData.length,
|
1150
1058
|
predicate: hexlify3(predicate),
|
1151
1059
|
predicateData: hexlify3(predicateData)
|
1152
1060
|
};
|
@@ -1177,8 +1085,8 @@ var inputify = (value) => {
|
|
1177
1085
|
nonce: hexlify3(value.nonce),
|
1178
1086
|
witnessIndex: value.witnessIndex,
|
1179
1087
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1180
|
-
predicateLength:
|
1181
|
-
predicateDataLength:
|
1088
|
+
predicateLength: predicate.length,
|
1089
|
+
predicateDataLength: predicateData.length,
|
1182
1090
|
predicate: hexlify3(predicate),
|
1183
1091
|
predicateData: hexlify3(predicateData),
|
1184
1092
|
data: hexlify3(data),
|
@@ -1260,7 +1168,7 @@ import { bn as bn7 } from "@fuel-ts/math";
|
|
1260
1168
|
import {
|
1261
1169
|
PolicyType,
|
1262
1170
|
TransactionCoder,
|
1263
|
-
InputType as
|
1171
|
+
InputType as InputType3,
|
1264
1172
|
OutputType as OutputType2,
|
1265
1173
|
TransactionType
|
1266
1174
|
} from "@fuel-ts/transactions";
|
@@ -1305,8 +1213,8 @@ function assembleReceiptByType(receipt) {
|
|
1305
1213
|
case "CALL" /* Call */: {
|
1306
1214
|
const callReceipt = {
|
1307
1215
|
type: ReceiptType.Call,
|
1308
|
-
from: hexOrZero(receipt.id
|
1309
|
-
to: hexOrZero(receipt?.to),
|
1216
|
+
from: hexOrZero(receipt.contract?.id),
|
1217
|
+
to: hexOrZero(receipt?.to?.id),
|
1310
1218
|
amount: bn4(receipt.amount),
|
1311
1219
|
assetId: hexOrZero(receipt.assetId),
|
1312
1220
|
gas: bn4(receipt.gas),
|
@@ -1320,7 +1228,7 @@ function assembleReceiptByType(receipt) {
|
|
1320
1228
|
case "RETURN" /* Return */: {
|
1321
1229
|
const returnReceipt = {
|
1322
1230
|
type: ReceiptType.Return,
|
1323
|
-
id: hexOrZero(receipt.id
|
1231
|
+
id: hexOrZero(receipt.contract?.id),
|
1324
1232
|
val: bn4(receipt.val),
|
1325
1233
|
pc: bn4(receipt.pc),
|
1326
1234
|
is: bn4(receipt.is)
|
@@ -1330,7 +1238,7 @@ function assembleReceiptByType(receipt) {
|
|
1330
1238
|
case "RETURN_DATA" /* ReturnData */: {
|
1331
1239
|
const returnDataReceipt = {
|
1332
1240
|
type: ReceiptType.ReturnData,
|
1333
|
-
id: hexOrZero(receipt.id
|
1241
|
+
id: hexOrZero(receipt.contract?.id),
|
1334
1242
|
ptr: bn4(receipt.ptr),
|
1335
1243
|
len: bn4(receipt.len),
|
1336
1244
|
digest: hexOrZero(receipt.digest),
|
@@ -1342,7 +1250,7 @@ function assembleReceiptByType(receipt) {
|
|
1342
1250
|
case "PANIC" /* Panic */: {
|
1343
1251
|
const panicReceipt = {
|
1344
1252
|
type: ReceiptType.Panic,
|
1345
|
-
id: hexOrZero(receipt.id),
|
1253
|
+
id: hexOrZero(receipt.contract?.id),
|
1346
1254
|
reason: bn4(receipt.reason),
|
1347
1255
|
pc: bn4(receipt.pc),
|
1348
1256
|
is: bn4(receipt.is),
|
@@ -1353,7 +1261,7 @@ function assembleReceiptByType(receipt) {
|
|
1353
1261
|
case "REVERT" /* Revert */: {
|
1354
1262
|
const revertReceipt = {
|
1355
1263
|
type: ReceiptType.Revert,
|
1356
|
-
id: hexOrZero(receipt.id
|
1264
|
+
id: hexOrZero(receipt.contract?.id),
|
1357
1265
|
val: bn4(receipt.ra),
|
1358
1266
|
pc: bn4(receipt.pc),
|
1359
1267
|
is: bn4(receipt.is)
|
@@ -1363,7 +1271,7 @@ function assembleReceiptByType(receipt) {
|
|
1363
1271
|
case "LOG" /* Log */: {
|
1364
1272
|
const logReceipt = {
|
1365
1273
|
type: ReceiptType.Log,
|
1366
|
-
id: hexOrZero(receipt.id
|
1274
|
+
id: hexOrZero(receipt.contract?.id),
|
1367
1275
|
val0: bn4(receipt.ra),
|
1368
1276
|
val1: bn4(receipt.rb),
|
1369
1277
|
val2: bn4(receipt.rc),
|
@@ -1376,7 +1284,7 @@ function assembleReceiptByType(receipt) {
|
|
1376
1284
|
case "LOG_DATA" /* LogData */: {
|
1377
1285
|
const logDataReceipt = {
|
1378
1286
|
type: ReceiptType.LogData,
|
1379
|
-
id: hexOrZero(receipt.id
|
1287
|
+
id: hexOrZero(receipt.contract?.id),
|
1380
1288
|
val0: bn4(receipt.ra),
|
1381
1289
|
val1: bn4(receipt.rb),
|
1382
1290
|
ptr: bn4(receipt.ptr),
|
@@ -1390,8 +1298,8 @@ function assembleReceiptByType(receipt) {
|
|
1390
1298
|
case "TRANSFER" /* Transfer */: {
|
1391
1299
|
const transferReceipt = {
|
1392
1300
|
type: ReceiptType.Transfer,
|
1393
|
-
from: hexOrZero(receipt.id
|
1394
|
-
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1301
|
+
from: hexOrZero(receipt.contract?.id),
|
1302
|
+
to: hexOrZero(receipt.toAddress || receipt?.to?.id),
|
1395
1303
|
amount: bn4(receipt.amount),
|
1396
1304
|
assetId: hexOrZero(receipt.assetId),
|
1397
1305
|
pc: bn4(receipt.pc),
|
@@ -1402,8 +1310,8 @@ function assembleReceiptByType(receipt) {
|
|
1402
1310
|
case "TRANSFER_OUT" /* TransferOut */: {
|
1403
1311
|
const transferOutReceipt = {
|
1404
1312
|
type: ReceiptType.TransferOut,
|
1405
|
-
from: hexOrZero(receipt.id
|
1406
|
-
to: hexOrZero(receipt.toAddress || receipt.to),
|
1313
|
+
from: hexOrZero(receipt.contract?.id),
|
1314
|
+
to: hexOrZero(receipt.toAddress || receipt.to?.id),
|
1407
1315
|
amount: bn4(receipt.amount),
|
1408
1316
|
assetId: hexOrZero(receipt.assetId),
|
1409
1317
|
pc: bn4(receipt.pc),
|
@@ -1446,7 +1354,7 @@ function assembleReceiptByType(receipt) {
|
|
1446
1354
|
return receiptMessageOut;
|
1447
1355
|
}
|
1448
1356
|
case "MINT" /* Mint */: {
|
1449
|
-
const contractId = hexOrZero(receipt.id
|
1357
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
1450
1358
|
const subId = hexOrZero(receipt.subId);
|
1451
1359
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
1452
1360
|
const mintReceipt = {
|
@@ -1461,7 +1369,7 @@ function assembleReceiptByType(receipt) {
|
|
1461
1369
|
return mintReceipt;
|
1462
1370
|
}
|
1463
1371
|
case "BURN" /* Burn */: {
|
1464
|
-
const contractId = hexOrZero(receipt.id
|
1372
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
1465
1373
|
const subId = hexOrZero(receipt.subId);
|
1466
1374
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
1467
1375
|
const burnReceipt = {
|
@@ -1487,6 +1395,7 @@ import { ErrorCode as ErrorCode6, FuelError as FuelError6 } from "@fuel-ts/error
|
|
1487
1395
|
import { bn as bn5 } from "@fuel-ts/math";
|
1488
1396
|
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
1489
1397
|
import { arrayify as arrayify3 } from "@fuel-ts/utils";
|
1398
|
+
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1490
1399
|
var getGasUsedFromReceipts = (receipts) => {
|
1491
1400
|
const scriptResult = receipts.filter(
|
1492
1401
|
(receipt) => receipt.type === ReceiptType2.ScriptResult
|
@@ -1507,28 +1416,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
1507
1416
|
}
|
1508
1417
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
1509
1418
|
const witnessCache = [];
|
1510
|
-
const
|
1511
|
-
const isCoinOrMessage = "owner" in input || "sender" in input;
|
1512
|
-
if (isCoinOrMessage) {
|
1513
|
-
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1514
|
-
return true;
|
1515
|
-
}
|
1516
|
-
if (!witnessCache.includes(input.witnessIndex)) {
|
1517
|
-
witnessCache.push(input.witnessIndex);
|
1518
|
-
return true;
|
1519
|
-
}
|
1520
|
-
}
|
1521
|
-
return false;
|
1522
|
-
});
|
1523
|
-
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
1524
|
-
const totalGas = chargeableInputs.reduce((total, input) => {
|
1419
|
+
const totalGas = inputs.reduce((total, input) => {
|
1525
1420
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1526
1421
|
return total.add(
|
1527
|
-
|
1422
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
|
1528
1423
|
);
|
1529
1424
|
}
|
1530
|
-
|
1531
|
-
|
1425
|
+
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
1426
|
+
witnessCache.push(input.witnessIndex);
|
1427
|
+
return total.add(gasCosts.ecr1);
|
1428
|
+
}
|
1429
|
+
return total;
|
1430
|
+
}, bn5());
|
1532
1431
|
return totalGas;
|
1533
1432
|
}
|
1534
1433
|
function getMinGas(params) {
|
@@ -1540,20 +1439,12 @@ function getMinGas(params) {
|
|
1540
1439
|
return minGas;
|
1541
1440
|
}
|
1542
1441
|
function getMaxGas(params) {
|
1543
|
-
const {
|
1544
|
-
gasPerByte,
|
1545
|
-
witnessesLength,
|
1546
|
-
witnessLimit,
|
1547
|
-
minGas,
|
1548
|
-
gasLimit = bn5(0),
|
1549
|
-
maxGasPerTx
|
1550
|
-
} = params;
|
1442
|
+
const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
|
1551
1443
|
let remainingAllowedWitnessGas = bn5(0);
|
1552
1444
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
1553
1445
|
remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
1554
1446
|
}
|
1555
|
-
|
1556
|
-
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
1447
|
+
return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
1557
1448
|
}
|
1558
1449
|
function calculateMetadataGasForTxCreate({
|
1559
1450
|
gasCosts,
|
@@ -1575,10 +1466,6 @@ function calculateMetadataGasForTxScript({
|
|
1575
1466
|
}) {
|
1576
1467
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1577
1468
|
}
|
1578
|
-
var calculateGasFee = (params) => {
|
1579
|
-
const { gas, gasPrice, priceFactor, tip } = params;
|
1580
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1581
|
-
};
|
1582
1469
|
|
1583
1470
|
// src/providers/utils/json.ts
|
1584
1471
|
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
@@ -1710,6 +1597,12 @@ var NoWitnessAtIndexError = class extends Error {
|
|
1710
1597
|
name = "NoWitnessAtIndexError";
|
1711
1598
|
};
|
1712
1599
|
|
1600
|
+
// src/providers/transaction-request/helpers.ts
|
1601
|
+
import { InputType as InputType2 } from "@fuel-ts/transactions";
|
1602
|
+
var isRequestInputCoin = (input) => input.type === InputType2.Coin;
|
1603
|
+
var isRequestInputMessage = (input) => input.type === InputType2.Message;
|
1604
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
1605
|
+
|
1713
1606
|
// src/providers/transaction-request/witness.ts
|
1714
1607
|
import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
|
1715
1608
|
var witnessify = (value) => {
|
@@ -1723,7 +1616,7 @@ var witnessify = (value) => {
|
|
1723
1616
|
// src/providers/transaction-request/transaction-request.ts
|
1724
1617
|
var BaseTransactionRequest = class {
|
1725
1618
|
/** Gas price for transaction */
|
1726
|
-
|
1619
|
+
gasPrice;
|
1727
1620
|
/** Block until which tx cannot be included */
|
1728
1621
|
maturity;
|
1729
1622
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -1742,7 +1635,7 @@ var BaseTransactionRequest = class {
|
|
1742
1635
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
1743
1636
|
*/
|
1744
1637
|
constructor({
|
1745
|
-
|
1638
|
+
gasPrice,
|
1746
1639
|
maturity,
|
1747
1640
|
maxFee,
|
1748
1641
|
witnessLimit,
|
@@ -1750,7 +1643,7 @@ var BaseTransactionRequest = class {
|
|
1750
1643
|
outputs,
|
1751
1644
|
witnesses
|
1752
1645
|
} = {}) {
|
1753
|
-
this.
|
1646
|
+
this.gasPrice = bn7(gasPrice);
|
1754
1647
|
this.maturity = maturity ?? 0;
|
1755
1648
|
this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
|
1756
1649
|
this.maxFee = maxFee ? bn7(maxFee) : void 0;
|
@@ -1761,9 +1654,9 @@ var BaseTransactionRequest = class {
|
|
1761
1654
|
static getPolicyMeta(req) {
|
1762
1655
|
let policyTypes = 0;
|
1763
1656
|
const policies = [];
|
1764
|
-
if (req.
|
1765
|
-
policyTypes += PolicyType.
|
1766
|
-
policies.push({ data: req.
|
1657
|
+
if (req.gasPrice) {
|
1658
|
+
policyTypes += PolicyType.GasPrice;
|
1659
|
+
policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
|
1767
1660
|
}
|
1768
1661
|
if (req.witnessLimit) {
|
1769
1662
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -1900,7 +1793,7 @@ var BaseTransactionRequest = class {
|
|
1900
1793
|
*/
|
1901
1794
|
getCoinInputs() {
|
1902
1795
|
return this.inputs.filter(
|
1903
|
-
(input) => input.type ===
|
1796
|
+
(input) => input.type === InputType3.Coin
|
1904
1797
|
);
|
1905
1798
|
}
|
1906
1799
|
/**
|
@@ -1932,9 +1825,9 @@ var BaseTransactionRequest = class {
|
|
1932
1825
|
const ownerAddress = addressify(owner);
|
1933
1826
|
const found = this.inputs.find((input) => {
|
1934
1827
|
switch (input.type) {
|
1935
|
-
case
|
1828
|
+
case InputType3.Coin:
|
1936
1829
|
return hexlify7(input.owner) === ownerAddress.toB256();
|
1937
|
-
case
|
1830
|
+
case InputType3.Message:
|
1938
1831
|
return hexlify7(input.recipient) === ownerAddress.toB256();
|
1939
1832
|
default:
|
1940
1833
|
return false;
|
@@ -1947,11 +1840,13 @@ var BaseTransactionRequest = class {
|
|
1947
1840
|
* assetId, if one it was not added yet.
|
1948
1841
|
*
|
1949
1842
|
* @param coin - Coin resource.
|
1843
|
+
* @param predicate - Predicate bytes.
|
1844
|
+
* @param predicateData - Predicate data bytes.
|
1950
1845
|
*/
|
1951
1846
|
addCoinInput(coin) {
|
1952
|
-
const { assetId, owner, amount } = coin;
|
1847
|
+
const { assetId, owner, amount, id, predicate } = coin;
|
1953
1848
|
let witnessIndex;
|
1954
|
-
if (
|
1849
|
+
if (predicate) {
|
1955
1850
|
witnessIndex = 0;
|
1956
1851
|
} else {
|
1957
1852
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -1960,13 +1855,14 @@ var BaseTransactionRequest = class {
|
|
1960
1855
|
}
|
1961
1856
|
}
|
1962
1857
|
const input = {
|
1963
|
-
|
1964
|
-
type:
|
1858
|
+
id,
|
1859
|
+
type: InputType3.Coin,
|
1965
1860
|
owner: owner.toB256(),
|
1966
1861
|
amount,
|
1967
1862
|
assetId,
|
1968
1863
|
txPointer: "0x00000000000000000000000000000000",
|
1969
|
-
witnessIndex
|
1864
|
+
witnessIndex,
|
1865
|
+
predicate
|
1970
1866
|
};
|
1971
1867
|
this.pushInput(input);
|
1972
1868
|
this.addChangeOutput(owner, assetId);
|
@@ -1976,12 +1872,14 @@ var BaseTransactionRequest = class {
|
|
1976
1872
|
* baseAssetId, if one it was not added yet.
|
1977
1873
|
*
|
1978
1874
|
* @param message - Message resource.
|
1875
|
+
* @param predicate - Predicate bytes.
|
1876
|
+
* @param predicateData - Predicate data bytes.
|
1979
1877
|
*/
|
1980
1878
|
addMessageInput(message) {
|
1981
|
-
const { recipient, sender, amount } = message;
|
1879
|
+
const { recipient, sender, amount, predicate, nonce } = message;
|
1982
1880
|
const assetId = BaseAssetId2;
|
1983
1881
|
let witnessIndex;
|
1984
|
-
if (
|
1882
|
+
if (predicate) {
|
1985
1883
|
witnessIndex = 0;
|
1986
1884
|
} else {
|
1987
1885
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -1990,12 +1888,13 @@ var BaseTransactionRequest = class {
|
|
1990
1888
|
}
|
1991
1889
|
}
|
1992
1890
|
const input = {
|
1993
|
-
|
1994
|
-
type:
|
1891
|
+
nonce,
|
1892
|
+
type: InputType3.Message,
|
1995
1893
|
sender: sender.toB256(),
|
1996
1894
|
recipient: recipient.toB256(),
|
1997
1895
|
amount,
|
1998
|
-
witnessIndex
|
1896
|
+
witnessIndex,
|
1897
|
+
predicate
|
1999
1898
|
};
|
2000
1899
|
this.pushInput(input);
|
2001
1900
|
this.addChangeOutput(recipient, assetId);
|
@@ -2105,7 +2004,7 @@ var BaseTransactionRequest = class {
|
|
2105
2004
|
}
|
2106
2005
|
calculateMaxGas(chainInfo, minGas) {
|
2107
2006
|
const { consensusParameters } = chainInfo;
|
2108
|
-
const { gasPerByte
|
2007
|
+
const { gasPerByte } = consensusParameters;
|
2109
2008
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2110
2009
|
(acc, wit) => acc + wit.dataLength,
|
2111
2010
|
0
|
@@ -2114,8 +2013,7 @@ var BaseTransactionRequest = class {
|
|
2114
2013
|
gasPerByte,
|
2115
2014
|
minGas,
|
2116
2015
|
witnessesLength,
|
2117
|
-
witnessLimit: this.witnessLimit
|
2118
|
-
maxGasPerTx
|
2016
|
+
witnessLimit: this.witnessLimit
|
2119
2017
|
});
|
2120
2018
|
}
|
2121
2019
|
/**
|
@@ -2133,20 +2031,17 @@ var BaseTransactionRequest = class {
|
|
2133
2031
|
});
|
2134
2032
|
const updateAssetInput = (assetId, quantity) => {
|
2135
2033
|
const assetInput = findAssetInput(assetId);
|
2136
|
-
let usedQuantity = quantity;
|
2137
|
-
if (assetId === BaseAssetId2) {
|
2138
|
-
usedQuantity = bn7("1000000000000000000");
|
2139
|
-
}
|
2140
2034
|
if (assetInput && "assetId" in assetInput) {
|
2141
2035
|
assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
|
2142
|
-
assetInput.amount =
|
2036
|
+
assetInput.amount = quantity;
|
2143
2037
|
} else {
|
2144
2038
|
this.addResources([
|
2145
2039
|
{
|
2146
2040
|
id: hexlify7(randomBytes(UTXO_ID_LEN2)),
|
2147
|
-
amount:
|
2041
|
+
amount: quantity,
|
2148
2042
|
assetId,
|
2149
2043
|
owner: resourcesOwner || Address.fromRandom(),
|
2044
|
+
maturity: 0,
|
2150
2045
|
blockCreated: bn7(1),
|
2151
2046
|
txCreatedIdx: bn7(1)
|
2152
2047
|
}
|
@@ -2178,16 +2073,20 @@ var BaseTransactionRequest = class {
|
|
2178
2073
|
toJSON() {
|
2179
2074
|
return normalizeJSON(this);
|
2180
2075
|
}
|
2181
|
-
|
2076
|
+
removeWitness(index) {
|
2077
|
+
this.witnesses.splice(index, 1);
|
2078
|
+
this.adjustWitnessIndexes(index);
|
2079
|
+
}
|
2080
|
+
updatePredicateInputs(inputs) {
|
2182
2081
|
this.inputs.forEach((i) => {
|
2183
2082
|
let correspondingInput;
|
2184
2083
|
switch (i.type) {
|
2185
|
-
case
|
2186
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2084
|
+
case InputType3.Coin:
|
2085
|
+
correspondingInput = inputs.find((x) => x.type === InputType3.Coin && x.owner === i.owner);
|
2187
2086
|
break;
|
2188
|
-
case
|
2087
|
+
case InputType3.Message:
|
2189
2088
|
correspondingInput = inputs.find(
|
2190
|
-
(x) => x.type ===
|
2089
|
+
(x) => x.type === InputType3.Message && x.sender === i.sender
|
2191
2090
|
);
|
2192
2091
|
break;
|
2193
2092
|
default:
|
@@ -2200,12 +2099,10 @@ var BaseTransactionRequest = class {
|
|
2200
2099
|
}
|
2201
2100
|
});
|
2202
2101
|
}
|
2203
|
-
|
2204
|
-
this.inputs.forEach((input) => {
|
2205
|
-
if (
|
2206
|
-
input.
|
2207
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2208
|
-
);
|
2102
|
+
adjustWitnessIndexes(removedIndex) {
|
2103
|
+
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
2104
|
+
if (input.witnessIndex > removedIndex) {
|
2105
|
+
input.witnessIndex -= 1;
|
2209
2106
|
}
|
2210
2107
|
});
|
2211
2108
|
}
|
@@ -2221,7 +2118,7 @@ import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
|
2221
2118
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2222
2119
|
import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
|
2223
2120
|
import { bn as bn8 } from "@fuel-ts/math";
|
2224
|
-
import { TransactionType as TransactionType2, InputType as
|
2121
|
+
import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
|
2225
2122
|
import { concat as concat2 } from "@fuel-ts/utils";
|
2226
2123
|
import { clone as clone2 } from "ramda";
|
2227
2124
|
function hashTransaction(transactionRequest, chainId) {
|
@@ -2232,7 +2129,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2232
2129
|
transaction.inputs = transaction.inputs.map((input) => {
|
2233
2130
|
const inputClone = clone2(input);
|
2234
2131
|
switch (inputClone.type) {
|
2235
|
-
case
|
2132
|
+
case InputType4.Coin: {
|
2236
2133
|
inputClone.txPointer = {
|
2237
2134
|
blockHeight: 0,
|
2238
2135
|
txIndex: 0
|
@@ -2240,11 +2137,11 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2240
2137
|
inputClone.predicateGasUsed = bn8(0);
|
2241
2138
|
return inputClone;
|
2242
2139
|
}
|
2243
|
-
case
|
2140
|
+
case InputType4.Message: {
|
2244
2141
|
inputClone.predicateGasUsed = bn8(0);
|
2245
2142
|
return inputClone;
|
2246
2143
|
}
|
2247
|
-
case
|
2144
|
+
case InputType4.Contract: {
|
2248
2145
|
inputClone.txPointer = {
|
2249
2146
|
blockHeight: 0,
|
2250
2147
|
txIndex: 0
|
@@ -2355,8 +2252,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2355
2252
|
return {
|
2356
2253
|
type: TransactionType3.Create,
|
2357
2254
|
...baseTransaction,
|
2255
|
+
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2358
2256
|
bytecodeWitnessIndex,
|
2359
|
-
storageSlotsCount:
|
2257
|
+
storageSlotsCount: storageSlots.length,
|
2360
2258
|
salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
|
2361
2259
|
storageSlots
|
2362
2260
|
};
|
@@ -2409,7 +2307,7 @@ import { Interface } from "@fuel-ts/abi-coder";
|
|
2409
2307
|
import { addressify as addressify2 } from "@fuel-ts/address";
|
2410
2308
|
import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
2411
2309
|
import { bn as bn10 } from "@fuel-ts/math";
|
2412
|
-
import { InputType as
|
2310
|
+
import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
2413
2311
|
import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
|
2414
2312
|
|
2415
2313
|
// src/providers/transaction-request/scripts.ts
|
@@ -2479,8 +2377,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2479
2377
|
type: TransactionType4.Script,
|
2480
2378
|
scriptGasLimit: this.gasLimit,
|
2481
2379
|
...super.getBaseTransaction(),
|
2482
|
-
scriptLength:
|
2483
|
-
scriptDataLength:
|
2380
|
+
scriptLength: script.length,
|
2381
|
+
scriptDataLength: scriptData.length,
|
2484
2382
|
receiptsRoot: ZeroBytes327,
|
2485
2383
|
script: hexlify10(script),
|
2486
2384
|
scriptData: hexlify10(scriptData)
|
@@ -2493,7 +2391,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2493
2391
|
*/
|
2494
2392
|
getContractInputs() {
|
2495
2393
|
return this.inputs.filter(
|
2496
|
-
(input) => input.type ===
|
2394
|
+
(input) => input.type === InputType5.Contract
|
2497
2395
|
);
|
2498
2396
|
}
|
2499
2397
|
/**
|
@@ -2544,7 +2442,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2544
2442
|
}
|
2545
2443
|
calculateMaxGas(chainInfo, minGas) {
|
2546
2444
|
const { consensusParameters } = chainInfo;
|
2547
|
-
const { gasPerByte
|
2445
|
+
const { gasPerByte } = consensusParameters;
|
2548
2446
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2549
2447
|
(acc, wit) => acc + wit.dataLength,
|
2550
2448
|
0
|
@@ -2554,8 +2452,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2554
2452
|
minGas,
|
2555
2453
|
witnessesLength,
|
2556
2454
|
witnessLimit: this.witnessLimit,
|
2557
|
-
gasLimit: this.gasLimit
|
2558
|
-
maxGasPerTx
|
2455
|
+
gasLimit: this.gasLimit
|
2559
2456
|
});
|
2560
2457
|
}
|
2561
2458
|
/**
|
@@ -2570,7 +2467,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2570
2467
|
return this;
|
2571
2468
|
}
|
2572
2469
|
const inputIndex = super.pushInput({
|
2573
|
-
type:
|
2470
|
+
type: InputType5.Contract,
|
2574
2471
|
contractId: contractAddress.toB256(),
|
2575
2472
|
txPointer: "0x00000000000000000000000000000000"
|
2576
2473
|
});
|
@@ -2612,7 +2509,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2612
2509
|
|
2613
2510
|
// src/providers/transaction-request/utils.ts
|
2614
2511
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2615
|
-
import { TransactionType as TransactionType5
|
2512
|
+
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2616
2513
|
var transactionRequestify = (obj) => {
|
2617
2514
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2618
2515
|
return obj;
|
@@ -2630,31 +2527,14 @@ var transactionRequestify = (obj) => {
|
|
2630
2527
|
}
|
2631
2528
|
}
|
2632
2529
|
};
|
2633
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2634
|
-
(acc, input) => {
|
2635
|
-
if (input.type === InputType5.Coin && input.owner === owner) {
|
2636
|
-
acc.utxos.push(input.id);
|
2637
|
-
}
|
2638
|
-
if (input.type === InputType5.Message && input.recipient === owner) {
|
2639
|
-
acc.messages.push(input.nonce);
|
2640
|
-
}
|
2641
|
-
return acc;
|
2642
|
-
},
|
2643
|
-
{
|
2644
|
-
utxos: [],
|
2645
|
-
messages: []
|
2646
|
-
}
|
2647
|
-
);
|
2648
2530
|
|
2649
2531
|
// src/providers/transaction-response/transaction-response.ts
|
2650
2532
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2651
|
-
import { bn as
|
2533
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
2652
2534
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2653
2535
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2654
2536
|
|
2655
2537
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2656
|
-
import { bn as bn14 } from "@fuel-ts/math";
|
2657
|
-
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2658
2538
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2659
2539
|
|
2660
2540
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
@@ -2663,10 +2543,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
|
|
2663
2543
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2664
2544
|
var calculateTransactionFee = (params) => {
|
2665
2545
|
const {
|
2666
|
-
|
2546
|
+
gasUsed,
|
2667
2547
|
rawPayload,
|
2668
|
-
|
2669
|
-
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2548
|
+
consensusParameters: { gasCosts, feeParams }
|
2670
2549
|
} = params;
|
2671
2550
|
const gasPerByte = bn11(feeParams.gasPerByte);
|
2672
2551
|
const gasPriceFactor = bn11(feeParams.gasPriceFactor);
|
@@ -2676,7 +2555,8 @@ var calculateTransactionFee = (params) => {
|
|
2676
2555
|
return {
|
2677
2556
|
fee: bn11(0),
|
2678
2557
|
minFee: bn11(0),
|
2679
|
-
maxFee: bn11(0)
|
2558
|
+
maxFee: bn11(0),
|
2559
|
+
feeFromGasUsed: bn11(0)
|
2680
2560
|
};
|
2681
2561
|
}
|
2682
2562
|
const { type, witnesses, inputs, policies } = transaction;
|
@@ -2708,6 +2588,7 @@ var calculateTransactionFee = (params) => {
|
|
2708
2588
|
metadataGas,
|
2709
2589
|
txBytesSize: transactionBytes.length
|
2710
2590
|
});
|
2591
|
+
const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
|
2711
2592
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
|
2712
2593
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2713
2594
|
const maxGas = getMaxGas({
|
@@ -2715,25 +2596,17 @@ var calculateTransactionFee = (params) => {
|
|
2715
2596
|
minGas,
|
2716
2597
|
witnessesLength,
|
2717
2598
|
gasLimit,
|
2718
|
-
witnessLimit
|
2719
|
-
maxGasPerTx
|
2720
|
-
});
|
2721
|
-
const minFee = calculateGasFee({
|
2722
|
-
gasPrice,
|
2723
|
-
gas: minGas,
|
2724
|
-
priceFactor: gasPriceFactor,
|
2725
|
-
tip
|
2726
|
-
});
|
2727
|
-
const maxFee = calculateGasFee({
|
2728
|
-
gasPrice,
|
2729
|
-
gas: maxGas,
|
2730
|
-
priceFactor: gasPriceFactor,
|
2731
|
-
tip
|
2599
|
+
witnessLimit
|
2732
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);
|
2733
2605
|
return {
|
2606
|
+
fee,
|
2734
2607
|
minFee,
|
2735
2608
|
maxFee,
|
2736
|
-
|
2609
|
+
feeFromGasUsed
|
2737
2610
|
};
|
2738
2611
|
};
|
2739
2612
|
|
@@ -3300,9 +3173,7 @@ function assembleTransactionSummary(params) {
|
|
3300
3173
|
gqlTransactionStatus,
|
3301
3174
|
abiMap = {},
|
3302
3175
|
maxInputs,
|
3303
|
-
gasCosts
|
3304
|
-
maxGasPerTx,
|
3305
|
-
gasPrice
|
3176
|
+
gasCosts
|
3306
3177
|
} = params;
|
3307
3178
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3308
3179
|
const rawPayload = hexlify11(transactionBytes);
|
@@ -3316,14 +3187,11 @@ function assembleTransactionSummary(params) {
|
|
3316
3187
|
maxInputs
|
3317
3188
|
});
|
3318
3189
|
const typeName = getTransactionTypeName(transaction.type);
|
3319
|
-
const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3320
3190
|
const { fee } = calculateTransactionFee({
|
3321
|
-
|
3191
|
+
gasUsed,
|
3322
3192
|
rawPayload,
|
3323
|
-
tip,
|
3324
3193
|
consensusParameters: {
|
3325
3194
|
gasCosts,
|
3326
|
-
maxGasPerTx,
|
3327
3195
|
feeParams: {
|
3328
3196
|
gasPerByte,
|
3329
3197
|
gasPriceFactor
|
@@ -3383,7 +3251,7 @@ var TransactionResponse = class {
|
|
3383
3251
|
/** Current provider */
|
3384
3252
|
provider;
|
3385
3253
|
/** Gas used on the transaction */
|
3386
|
-
gasUsed =
|
3254
|
+
gasUsed = bn14(0);
|
3387
3255
|
/** The graphql Transaction with receipts object. */
|
3388
3256
|
gqlTransaction;
|
3389
3257
|
abis;
|
@@ -3461,13 +3329,8 @@ var TransactionResponse = class {
|
|
3461
3329
|
const decodedTransaction = this.decodeTransaction(
|
3462
3330
|
transaction
|
3463
3331
|
);
|
3464
|
-
|
3465
|
-
|
3466
|
-
txReceipts = transaction.status.receipts;
|
3467
|
-
}
|
3468
|
-
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3469
|
-
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3470
|
-
const gasPrice = await this.provider.getLatestGasPrice();
|
3332
|
+
const receipts = transaction.receipts?.map(processGqlReceipt) || [];
|
3333
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
|
3471
3334
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3472
3335
|
const transactionSummary = assembleTransactionSummary({
|
3473
3336
|
id: this.id,
|
@@ -3479,9 +3342,7 @@ var TransactionResponse = class {
|
|
3479
3342
|
gasPriceFactor,
|
3480
3343
|
abiMap: contractsAbiMap,
|
3481
3344
|
maxInputs,
|
3482
|
-
gasCosts
|
3483
|
-
maxGasPerTx,
|
3484
|
-
gasPrice
|
3345
|
+
gasCosts
|
3485
3346
|
});
|
3486
3347
|
return transactionSummary;
|
3487
3348
|
}
|
@@ -3608,29 +3469,29 @@ var processGqlChain = (chain) => {
|
|
3608
3469
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3609
3470
|
return {
|
3610
3471
|
name,
|
3611
|
-
baseChainHeight:
|
3472
|
+
baseChainHeight: bn15(daHeight),
|
3612
3473
|
consensusParameters: {
|
3613
|
-
contractMaxSize:
|
3614
|
-
maxInputs:
|
3615
|
-
maxOutputs:
|
3616
|
-
maxWitnesses:
|
3617
|
-
maxGasPerTx:
|
3618
|
-
maxScriptLength:
|
3619
|
-
maxScriptDataLength:
|
3620
|
-
maxStorageSlots:
|
3621
|
-
maxPredicateLength:
|
3622
|
-
maxPredicateDataLength:
|
3623
|
-
maxGasPerPredicate:
|
3624
|
-
gasPriceFactor:
|
3625
|
-
gasPerByte:
|
3626
|
-
maxMessageDataLength:
|
3627
|
-
chainId:
|
3474
|
+
contractMaxSize: bn15(contractParams.contractMaxSize),
|
3475
|
+
maxInputs: bn15(txParams.maxInputs),
|
3476
|
+
maxOutputs: bn15(txParams.maxOutputs),
|
3477
|
+
maxWitnesses: bn15(txParams.maxWitnesses),
|
3478
|
+
maxGasPerTx: bn15(txParams.maxGasPerTx),
|
3479
|
+
maxScriptLength: bn15(scriptParams.maxScriptLength),
|
3480
|
+
maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
|
3481
|
+
maxStorageSlots: bn15(contractParams.maxStorageSlots),
|
3482
|
+
maxPredicateLength: bn15(predicateParams.maxPredicateLength),
|
3483
|
+
maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
|
3484
|
+
maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
|
3485
|
+
gasPriceFactor: bn15(feeParams.gasPriceFactor),
|
3486
|
+
gasPerByte: bn15(feeParams.gasPerByte),
|
3487
|
+
maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
|
3488
|
+
chainId: bn15(consensusParameters.chainId),
|
3628
3489
|
gasCosts
|
3629
3490
|
},
|
3630
3491
|
gasCosts,
|
3631
3492
|
latestBlock: {
|
3632
3493
|
id: latestBlock.id,
|
3633
|
-
height:
|
3494
|
+
height: bn15(latestBlock.header.height),
|
3634
3495
|
time: latestBlock.header.time,
|
3635
3496
|
transactions: latestBlock.transactions.map((i) => ({
|
3636
3497
|
id: i.id
|
@@ -3724,8 +3585,10 @@ var _Provider = class {
|
|
3724
3585
|
* Returns some helpful parameters related to gas fees.
|
3725
3586
|
*/
|
3726
3587
|
getGasConfig() {
|
3588
|
+
const { minGasPrice } = this.getNode();
|
3727
3589
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3728
3590
|
return {
|
3591
|
+
minGasPrice,
|
3729
3592
|
maxGasPerTx,
|
3730
3593
|
maxGasPerPredicate,
|
3731
3594
|
gasPriceFactor,
|
@@ -3823,7 +3686,7 @@ var _Provider = class {
|
|
3823
3686
|
*/
|
3824
3687
|
async getBlockNumber() {
|
3825
3688
|
const { chain } = await this.operations.getChain();
|
3826
|
-
return
|
3689
|
+
return bn15(chain.latestBlock.header.height, 10);
|
3827
3690
|
}
|
3828
3691
|
/**
|
3829
3692
|
* Returns the chain information.
|
@@ -3833,11 +3696,13 @@ var _Provider = class {
|
|
3833
3696
|
async fetchNode() {
|
3834
3697
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3835
3698
|
const processedNodeInfo = {
|
3836
|
-
maxDepth:
|
3837
|
-
maxTx:
|
3699
|
+
maxDepth: bn15(nodeInfo.maxDepth),
|
3700
|
+
maxTx: bn15(nodeInfo.maxTx),
|
3701
|
+
minGasPrice: bn15(nodeInfo.minGasPrice),
|
3838
3702
|
nodeVersion: nodeInfo.nodeVersion,
|
3839
3703
|
utxoValidation: nodeInfo.utxoValidation,
|
3840
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
3704
|
+
vmBacktrace: nodeInfo.vmBacktrace,
|
3705
|
+
peers: nodeInfo.peers
|
3841
3706
|
};
|
3842
3707
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
3843
3708
|
return processedNodeInfo;
|
@@ -3923,13 +3788,14 @@ var _Provider = class {
|
|
3923
3788
|
return this.estimateTxDependencies(transactionRequest);
|
3924
3789
|
}
|
3925
3790
|
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
3926
|
-
const { dryRun:
|
3927
|
-
|
3791
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3792
|
+
encodedTransaction,
|
3928
3793
|
utxoValidation: utxoValidation || false
|
3929
3794
|
});
|
3930
|
-
const
|
3931
|
-
|
3932
|
-
|
3795
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
3796
|
+
return {
|
3797
|
+
receipts
|
3798
|
+
};
|
3933
3799
|
}
|
3934
3800
|
/**
|
3935
3801
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -3955,7 +3821,7 @@ var _Provider = class {
|
|
3955
3821
|
} = response;
|
3956
3822
|
if (inputs) {
|
3957
3823
|
inputs.forEach((input, index) => {
|
3958
|
-
if ("predicateGasUsed" in input &&
|
3824
|
+
if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
|
3959
3825
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3960
3826
|
}
|
3961
3827
|
});
|
@@ -3968,6 +3834,9 @@ var _Provider = class {
|
|
3968
3834
|
* If there are missing variable outputs,
|
3969
3835
|
* `addVariableOutputs` is called on the transaction.
|
3970
3836
|
*
|
3837
|
+
* @privateRemarks
|
3838
|
+
* TODO: Investigate support for missing contract IDs
|
3839
|
+
* TODO: Add support for missing output messages
|
3971
3840
|
*
|
3972
3841
|
* @param transactionRequest - The transaction request object.
|
3973
3842
|
* @returns A promise.
|
@@ -3980,19 +3849,16 @@ var _Provider = class {
|
|
3980
3849
|
missingContractIds: []
|
3981
3850
|
};
|
3982
3851
|
}
|
3852
|
+
await this.estimatePredicates(transactionRequest);
|
3983
3853
|
let receipts = [];
|
3984
3854
|
const missingContractIds = [];
|
3985
3855
|
let outputVariables = 0;
|
3986
|
-
let dryrunStatus;
|
3987
3856
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3988
|
-
const {
|
3989
|
-
|
3990
|
-
} = await this.operations.dryRun({
|
3991
|
-
encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
|
3857
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3858
|
+
encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
|
3992
3859
|
utxoValidation: false
|
3993
3860
|
});
|
3994
|
-
receipts =
|
3995
|
-
dryrunStatus = status;
|
3861
|
+
receipts = gqlReceipts.map(processGqlReceipt);
|
3996
3862
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
3997
3863
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
3998
3864
|
if (hasMissingOutputs) {
|
@@ -4002,10 +3868,6 @@ var _Provider = class {
|
|
4002
3868
|
transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
|
4003
3869
|
missingContractIds.push(contractId);
|
4004
3870
|
});
|
4005
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
4006
|
-
transactionRequest
|
4007
|
-
});
|
4008
|
-
transactionRequest.maxFee = maxFee;
|
4009
3871
|
} else {
|
4010
3872
|
break;
|
4011
3873
|
}
|
@@ -4013,139 +3875,37 @@ var _Provider = class {
|
|
4013
3875
|
return {
|
4014
3876
|
receipts,
|
4015
3877
|
outputVariables,
|
4016
|
-
missingContractIds
|
4017
|
-
dryrunStatus
|
3878
|
+
missingContractIds
|
4018
3879
|
};
|
4019
3880
|
}
|
4020
|
-
/**
|
4021
|
-
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
4022
|
-
*
|
4023
|
-
* Transactions are dry run in batches. After each dry run, transactions requiring
|
4024
|
-
* further modifications are identified. The method iteratively updates these transactions
|
4025
|
-
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
4026
|
-
*
|
4027
|
-
* @param transactionRequests - Array of transaction request objects.
|
4028
|
-
* @returns A promise that resolves to an array of results for each transaction.
|
4029
|
-
*/
|
4030
|
-
async estimateMultipleTxDependencies(transactionRequests) {
|
4031
|
-
const results = transactionRequests.map(() => ({
|
4032
|
-
receipts: [],
|
4033
|
-
outputVariables: 0,
|
4034
|
-
missingContractIds: [],
|
4035
|
-
dryrunStatus: void 0
|
4036
|
-
}));
|
4037
|
-
const allRequests = clone3(transactionRequests);
|
4038
|
-
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4039
|
-
allRequests.forEach((req, index) => {
|
4040
|
-
if (req.type === TransactionType8.Script) {
|
4041
|
-
serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
|
4042
|
-
}
|
4043
|
-
});
|
4044
|
-
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
4045
|
-
let attempt = 0;
|
4046
|
-
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
4047
|
-
const encodedTransactions = transactionsToProcess.map(
|
4048
|
-
(index) => serializedTransactionsMap.get(index)
|
4049
|
-
);
|
4050
|
-
const dryRunResults = await this.operations.dryRun({
|
4051
|
-
encodedTransactions,
|
4052
|
-
utxoValidation: false
|
4053
|
-
});
|
4054
|
-
const nextRoundTransactions = [];
|
4055
|
-
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
4056
|
-
const currentResultIndex = transactionsToProcess[i];
|
4057
|
-
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4058
|
-
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
4059
|
-
results[currentResultIndex].dryrunStatus = status;
|
4060
|
-
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4061
|
-
results[currentResultIndex].receipts
|
4062
|
-
);
|
4063
|
-
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4064
|
-
const requestToProcess = allRequests[currentResultIndex];
|
4065
|
-
if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
|
4066
|
-
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
4067
|
-
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
4068
|
-
missingOutputContractIds.forEach(({ contractId }) => {
|
4069
|
-
requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
|
4070
|
-
results[currentResultIndex].missingContractIds.push(contractId);
|
4071
|
-
});
|
4072
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
4073
|
-
transactionRequest: requestToProcess
|
4074
|
-
});
|
4075
|
-
requestToProcess.maxFee = maxFee;
|
4076
|
-
serializedTransactionsMap.set(
|
4077
|
-
currentResultIndex,
|
4078
|
-
hexlify12(requestToProcess.toTransactionBytes())
|
4079
|
-
);
|
4080
|
-
nextRoundTransactions.push(currentResultIndex);
|
4081
|
-
allRequests[currentResultIndex] = requestToProcess;
|
4082
|
-
}
|
4083
|
-
}
|
4084
|
-
transactionsToProcess = nextRoundTransactions;
|
4085
|
-
attempt += 1;
|
4086
|
-
}
|
4087
|
-
return results;
|
4088
|
-
}
|
4089
|
-
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
4090
|
-
if (estimateTxDependencies) {
|
4091
|
-
return this.estimateMultipleTxDependencies(transactionRequests);
|
4092
|
-
}
|
4093
|
-
const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
|
4094
|
-
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4095
|
-
encodedTransactions,
|
4096
|
-
utxoValidation: utxoValidation || false
|
4097
|
-
});
|
4098
|
-
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4099
|
-
const receipts = rawReceipts.map(processGqlReceipt);
|
4100
|
-
return { receipts, dryrunStatus: status };
|
4101
|
-
});
|
4102
|
-
return results;
|
4103
|
-
}
|
4104
3881
|
/**
|
4105
3882
|
* Estimates the transaction gas and fee based on the provided transaction request.
|
4106
3883
|
* @param transactionRequest - The transaction request object.
|
4107
3884
|
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
4108
3885
|
*/
|
4109
|
-
|
3886
|
+
estimateTxGasAndFee(params) {
|
4110
3887
|
const { transactionRequest } = params;
|
4111
|
-
|
3888
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
4112
3889
|
const chainInfo = this.getChain();
|
4113
|
-
const
|
3890
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
3891
|
+
transactionRequest.gasPrice = gasPrice;
|
4114
3892
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
4115
|
-
|
4116
|
-
gasPrice = await this.estimateGasPrice(10);
|
4117
|
-
}
|
4118
|
-
const minFee = calculateGasFee({
|
4119
|
-
gasPrice: bn16(gasPrice),
|
4120
|
-
gas: minGas,
|
4121
|
-
priceFactor: gasPriceFactor,
|
4122
|
-
tip: transactionRequest.tip
|
4123
|
-
}).add(1);
|
4124
|
-
let gasLimit = bn16(0);
|
3893
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4125
3894
|
if (transactionRequest.type === TransactionType8.Script) {
|
4126
|
-
gasLimit = transactionRequest.gasLimit;
|
4127
3895
|
if (transactionRequest.gasLimit.eq(0)) {
|
4128
3896
|
transactionRequest.gasLimit = minGas;
|
4129
3897
|
transactionRequest.gasLimit = maxGasPerTx.sub(
|
4130
3898
|
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
4131
3899
|
);
|
4132
|
-
gasLimit = transactionRequest.gasLimit;
|
4133
3900
|
}
|
4134
3901
|
}
|
4135
3902
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4136
|
-
const maxFee =
|
4137
|
-
gasPrice: bn16(gasPrice),
|
4138
|
-
gas: maxGas,
|
4139
|
-
priceFactor: gasPriceFactor,
|
4140
|
-
tip: transactionRequest.tip
|
4141
|
-
}).add(1);
|
3903
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4142
3904
|
return {
|
4143
3905
|
minGas,
|
4144
3906
|
minFee,
|
4145
3907
|
maxGas,
|
4146
|
-
maxFee
|
4147
|
-
gasPrice,
|
4148
|
-
gasLimit
|
3908
|
+
maxFee
|
4149
3909
|
};
|
4150
3910
|
}
|
4151
3911
|
/**
|
@@ -4163,17 +3923,15 @@ var _Provider = class {
|
|
4163
3923
|
if (estimateTxDependencies) {
|
4164
3924
|
return this.estimateTxDependencies(transactionRequest);
|
4165
3925
|
}
|
4166
|
-
const
|
4167
|
-
const { dryRun:
|
4168
|
-
|
3926
|
+
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
3927
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3928
|
+
encodedTransaction,
|
4169
3929
|
utxoValidation: true
|
4170
3930
|
});
|
4171
|
-
const
|
4172
|
-
|
4173
|
-
|
4174
|
-
|
4175
|
-
});
|
4176
|
-
return { receipts: callResult[0].receipts };
|
3931
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
3932
|
+
return {
|
3933
|
+
receipts
|
3934
|
+
};
|
4177
3935
|
}
|
4178
3936
|
/**
|
4179
3937
|
* Returns a transaction cost to enable user
|
@@ -4190,79 +3948,77 @@ var _Provider = class {
|
|
4190
3948
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
4191
3949
|
* @returns A promise that resolves to the transaction cost object.
|
4192
3950
|
*/
|
4193
|
-
async getTransactionCost(transactionRequestLike,
|
3951
|
+
async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
|
3952
|
+
estimateTxDependencies = true,
|
3953
|
+
estimatePredicates = true,
|
3954
|
+
resourcesOwner,
|
3955
|
+
signatureCallback
|
3956
|
+
} = {}) {
|
4194
3957
|
const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
|
3958
|
+
const { minGasPrice } = this.getGasConfig();
|
3959
|
+
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
4195
3960
|
const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
|
4196
3961
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4197
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
3962
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
4198
3963
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
4199
|
-
txRequestClone.maxFee = bn16(0);
|
4200
3964
|
if (isScriptTransaction) {
|
4201
|
-
txRequestClone.gasLimit =
|
3965
|
+
txRequestClone.gasLimit = bn15(0);
|
4202
3966
|
}
|
4203
|
-
if (
|
4204
|
-
resourcesOwner
|
3967
|
+
if (estimatePredicates) {
|
3968
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
3969
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
3970
|
+
}
|
3971
|
+
await this.estimatePredicates(txRequestClone);
|
4205
3972
|
}
|
4206
|
-
const signedRequest = clone3(txRequestClone);
|
4207
|
-
let addedSignatures = 0;
|
4208
3973
|
if (signatureCallback && isScriptTransaction) {
|
4209
|
-
|
4210
|
-
await signatureCallback(signedRequest);
|
4211
|
-
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
3974
|
+
await signatureCallback(txRequestClone);
|
4212
3975
|
}
|
4213
|
-
|
4214
|
-
|
4215
|
-
transactionRequest: signedRequest
|
3976
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
3977
|
+
transactionRequest: txRequestClone
|
4216
3978
|
});
|
4217
3979
|
let receipts = [];
|
4218
3980
|
let missingContractIds = [];
|
4219
3981
|
let outputVariables = 0;
|
4220
|
-
let gasUsed =
|
4221
|
-
|
4222
|
-
|
4223
|
-
if (isScriptTransaction) {
|
4224
|
-
txRequestClone.gasLimit = gasLimit;
|
4225
|
-
if (signatureCallback) {
|
4226
|
-
await signatureCallback(txRequestClone);
|
4227
|
-
}
|
3982
|
+
let gasUsed = bn15(0);
|
3983
|
+
if (isScriptTransaction && estimateTxDependencies) {
|
3984
|
+
txRequestClone.gasPrice = bn15(0);
|
4228
3985
|
const result = await this.estimateTxDependencies(txRequestClone);
|
4229
3986
|
receipts = result.receipts;
|
4230
3987
|
outputVariables = result.outputVariables;
|
4231
3988
|
missingContractIds = result.missingContractIds;
|
4232
3989
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4233
3990
|
txRequestClone.gasLimit = gasUsed;
|
4234
|
-
|
4235
|
-
|
4236
|
-
|
3991
|
+
txRequestClone.gasPrice = setGasPrice;
|
3992
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
3993
|
+
transactionRequest: txRequestClone
|
4237
3994
|
}));
|
4238
3995
|
}
|
4239
3996
|
return {
|
4240
3997
|
requiredQuantities: allQuantities,
|
4241
3998
|
receipts,
|
4242
3999
|
gasUsed,
|
4243
|
-
|
4000
|
+
minGasPrice,
|
4001
|
+
gasPrice: setGasPrice,
|
4244
4002
|
minGas,
|
4245
4003
|
maxGas,
|
4246
4004
|
minFee,
|
4247
4005
|
maxFee,
|
4006
|
+
estimatedInputs: txRequestClone.inputs,
|
4248
4007
|
outputVariables,
|
4249
|
-
missingContractIds
|
4250
|
-
addedSignatures,
|
4251
|
-
estimatedPredicates: txRequestClone.inputs
|
4008
|
+
missingContractIds
|
4252
4009
|
};
|
4253
4010
|
}
|
4254
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
4011
|
+
async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
|
4255
4012
|
const ownerAddress = Address2.fromAddressOrString(owner);
|
4256
4013
|
const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
|
4257
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
4258
|
-
quantitiesToContract
|
4259
|
-
});
|
4014
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
|
4260
4015
|
transactionRequest.addResources(
|
4261
4016
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
4262
4017
|
);
|
4263
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4264
|
-
|
4265
|
-
|
4018
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4019
|
+
transactionRequest,
|
4020
|
+
forwardingQuantities
|
4021
|
+
);
|
4266
4022
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
4267
4023
|
return {
|
4268
4024
|
resources,
|
@@ -4284,10 +4040,11 @@ var _Provider = class {
|
|
4284
4040
|
return coins.map((coin) => ({
|
4285
4041
|
id: coin.utxoId,
|
4286
4042
|
assetId: coin.assetId,
|
4287
|
-
amount:
|
4043
|
+
amount: bn15(coin.amount),
|
4288
4044
|
owner: Address2.fromAddressOrString(coin.owner),
|
4289
|
-
|
4290
|
-
|
4045
|
+
maturity: bn15(coin.maturity).toNumber(),
|
4046
|
+
blockCreated: bn15(coin.blockCreated),
|
4047
|
+
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4291
4048
|
}));
|
4292
4049
|
}
|
4293
4050
|
/**
|
@@ -4324,9 +4081,9 @@ var _Provider = class {
|
|
4324
4081
|
switch (coin.__typename) {
|
4325
4082
|
case "MessageCoin":
|
4326
4083
|
return {
|
4327
|
-
amount:
|
4084
|
+
amount: bn15(coin.amount),
|
4328
4085
|
assetId: coin.assetId,
|
4329
|
-
daHeight:
|
4086
|
+
daHeight: bn15(coin.daHeight),
|
4330
4087
|
sender: Address2.fromAddressOrString(coin.sender),
|
4331
4088
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4332
4089
|
nonce: coin.nonce
|
@@ -4334,11 +4091,12 @@ var _Provider = class {
|
|
4334
4091
|
case "Coin":
|
4335
4092
|
return {
|
4336
4093
|
id: coin.utxoId,
|
4337
|
-
amount:
|
4094
|
+
amount: bn15(coin.amount),
|
4338
4095
|
assetId: coin.assetId,
|
4339
4096
|
owner: Address2.fromAddressOrString(coin.owner),
|
4340
|
-
|
4341
|
-
|
4097
|
+
maturity: bn15(coin.maturity).toNumber(),
|
4098
|
+
blockCreated: bn15(coin.blockCreated),
|
4099
|
+
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4342
4100
|
};
|
4343
4101
|
default:
|
4344
4102
|
return null;
|
@@ -4355,13 +4113,13 @@ var _Provider = class {
|
|
4355
4113
|
async getBlock(idOrHeight) {
|
4356
4114
|
let variables;
|
4357
4115
|
if (typeof idOrHeight === "number") {
|
4358
|
-
variables = { height:
|
4116
|
+
variables = { height: bn15(idOrHeight).toString(10) };
|
4359
4117
|
} else if (idOrHeight === "latest") {
|
4360
4118
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4361
4119
|
} else if (idOrHeight.length === 66) {
|
4362
4120
|
variables = { blockId: idOrHeight };
|
4363
4121
|
} else {
|
4364
|
-
variables = { blockId:
|
4122
|
+
variables = { blockId: bn15(idOrHeight).toString(10) };
|
4365
4123
|
}
|
4366
4124
|
const { block } = await this.operations.getBlock(variables);
|
4367
4125
|
if (!block) {
|
@@ -4369,7 +4127,7 @@ var _Provider = class {
|
|
4369
4127
|
}
|
4370
4128
|
return {
|
4371
4129
|
id: block.id,
|
4372
|
-
height:
|
4130
|
+
height: bn15(block.header.height),
|
4373
4131
|
time: block.header.time,
|
4374
4132
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4375
4133
|
};
|
@@ -4384,7 +4142,7 @@ var _Provider = class {
|
|
4384
4142
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4385
4143
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4386
4144
|
id: block.id,
|
4387
|
-
height:
|
4145
|
+
height: bn15(block.header.height),
|
4388
4146
|
time: block.header.time,
|
4389
4147
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4390
4148
|
}));
|
@@ -4399,7 +4157,7 @@ var _Provider = class {
|
|
4399
4157
|
async getBlockWithTransactions(idOrHeight) {
|
4400
4158
|
let variables;
|
4401
4159
|
if (typeof idOrHeight === "number") {
|
4402
|
-
variables = { blockHeight:
|
4160
|
+
variables = { blockHeight: bn15(idOrHeight).toString(10) };
|
4403
4161
|
} else if (idOrHeight === "latest") {
|
4404
4162
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4405
4163
|
} else {
|
@@ -4411,7 +4169,7 @@ var _Provider = class {
|
|
4411
4169
|
}
|
4412
4170
|
return {
|
4413
4171
|
id: block.id,
|
4414
|
-
height:
|
4172
|
+
height: bn15(block.header.height, 10),
|
4415
4173
|
time: block.header.time,
|
4416
4174
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4417
4175
|
transactions: block.transactions.map(
|
@@ -4460,7 +4218,7 @@ var _Provider = class {
|
|
4460
4218
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4461
4219
|
asset: hexlify12(assetId)
|
4462
4220
|
});
|
4463
|
-
return
|
4221
|
+
return bn15(contractBalance.amount, 10);
|
4464
4222
|
}
|
4465
4223
|
/**
|
4466
4224
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4474,7 +4232,7 @@ var _Provider = class {
|
|
4474
4232
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4475
4233
|
assetId: hexlify12(assetId)
|
4476
4234
|
});
|
4477
|
-
return
|
4235
|
+
return bn15(balance.amount, 10);
|
4478
4236
|
}
|
4479
4237
|
/**
|
4480
4238
|
* Returns balances for the given owner.
|
@@ -4492,7 +4250,7 @@ var _Provider = class {
|
|
4492
4250
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4493
4251
|
return balances.map((balance) => ({
|
4494
4252
|
assetId: balance.assetId,
|
4495
|
-
amount:
|
4253
|
+
amount: bn15(balance.amount)
|
4496
4254
|
}));
|
4497
4255
|
}
|
4498
4256
|
/**
|
@@ -4514,15 +4272,15 @@ var _Provider = class {
|
|
4514
4272
|
sender: message.sender,
|
4515
4273
|
recipient: message.recipient,
|
4516
4274
|
nonce: message.nonce,
|
4517
|
-
amount:
|
4275
|
+
amount: bn15(message.amount),
|
4518
4276
|
data: message.data
|
4519
4277
|
}),
|
4520
4278
|
sender: Address2.fromAddressOrString(message.sender),
|
4521
4279
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4522
4280
|
nonce: message.nonce,
|
4523
|
-
amount:
|
4281
|
+
amount: bn15(message.amount),
|
4524
4282
|
data: InputMessageCoder.decodeData(message.data),
|
4525
|
-
daHeight:
|
4283
|
+
daHeight: bn15(message.daHeight)
|
4526
4284
|
}));
|
4527
4285
|
}
|
4528
4286
|
/**
|
@@ -4575,60 +4333,44 @@ var _Provider = class {
|
|
4575
4333
|
} = result.messageProof;
|
4576
4334
|
return {
|
4577
4335
|
messageProof: {
|
4578
|
-
proofIndex:
|
4336
|
+
proofIndex: bn15(messageProof.proofIndex),
|
4579
4337
|
proofSet: messageProof.proofSet
|
4580
4338
|
},
|
4581
4339
|
blockProof: {
|
4582
|
-
proofIndex:
|
4340
|
+
proofIndex: bn15(blockProof.proofIndex),
|
4583
4341
|
proofSet: blockProof.proofSet
|
4584
4342
|
},
|
4585
4343
|
messageBlockHeader: {
|
4586
4344
|
id: messageBlockHeader.id,
|
4587
|
-
daHeight:
|
4588
|
-
transactionsCount:
|
4345
|
+
daHeight: bn15(messageBlockHeader.daHeight),
|
4346
|
+
transactionsCount: bn15(messageBlockHeader.transactionsCount),
|
4589
4347
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4590
|
-
height:
|
4348
|
+
height: bn15(messageBlockHeader.height),
|
4591
4349
|
prevRoot: messageBlockHeader.prevRoot,
|
4592
4350
|
time: messageBlockHeader.time,
|
4593
4351
|
applicationHash: messageBlockHeader.applicationHash,
|
4594
|
-
|
4595
|
-
|
4596
|
-
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4597
|
-
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4598
|
-
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4352
|
+
messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
|
4353
|
+
messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
|
4599
4354
|
},
|
4600
4355
|
commitBlockHeader: {
|
4601
4356
|
id: commitBlockHeader.id,
|
4602
|
-
daHeight:
|
4603
|
-
transactionsCount:
|
4357
|
+
daHeight: bn15(commitBlockHeader.daHeight),
|
4358
|
+
transactionsCount: bn15(commitBlockHeader.transactionsCount),
|
4604
4359
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4605
|
-
height:
|
4360
|
+
height: bn15(commitBlockHeader.height),
|
4606
4361
|
prevRoot: commitBlockHeader.prevRoot,
|
4607
4362
|
time: commitBlockHeader.time,
|
4608
4363
|
applicationHash: commitBlockHeader.applicationHash,
|
4609
|
-
|
4610
|
-
|
4611
|
-
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4612
|
-
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4613
|
-
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4364
|
+
messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
|
4365
|
+
messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
|
4614
4366
|
},
|
4615
4367
|
sender: Address2.fromAddressOrString(sender),
|
4616
4368
|
recipient: Address2.fromAddressOrString(recipient),
|
4617
4369
|
nonce,
|
4618
|
-
amount:
|
4370
|
+
amount: bn15(amount),
|
4619
4371
|
data
|
4620
4372
|
};
|
4621
4373
|
}
|
4622
|
-
async getLatestGasPrice() {
|
4623
|
-
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4624
|
-
return bn16(latestGasPrice.gasPrice);
|
4625
|
-
}
|
4626
|
-
async estimateGasPrice(blockHorizon) {
|
4627
|
-
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4628
|
-
blockHorizon: String(blockHorizon)
|
4629
|
-
});
|
4630
|
-
return bn16(estimateGasPrice.gasPrice);
|
4631
|
-
}
|
4632
4374
|
/**
|
4633
4375
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
4634
4376
|
*
|
@@ -4648,10 +4390,10 @@ var _Provider = class {
|
|
4648
4390
|
*/
|
4649
4391
|
async produceBlocks(amount, startTime) {
|
4650
4392
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4651
|
-
blocksToProduce:
|
4393
|
+
blocksToProduce: bn15(amount).toString(10),
|
4652
4394
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4653
4395
|
});
|
4654
|
-
return
|
4396
|
+
return bn15(latestBlockHeight);
|
4655
4397
|
}
|
4656
4398
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4657
4399
|
async getTransactionResponse(transactionId) {
|
@@ -4675,7 +4417,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4675
4417
|
|
4676
4418
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4677
4419
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4678
|
-
import { bn as
|
4420
|
+
import { bn as bn16 } from "@fuel-ts/math";
|
4679
4421
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4680
4422
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4681
4423
|
|
@@ -4921,33 +4663,36 @@ var Account = class extends AbstractAccount {
|
|
4921
4663
|
* @param fee - The estimated transaction fee.
|
4922
4664
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4923
4665
|
*/
|
4924
|
-
async fund(request,
|
4925
|
-
const
|
4926
|
-
|
4927
|
-
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
4928
|
-
amount: bn18(fee),
|
4666
|
+
async fund(request, coinQuantities, fee) {
|
4667
|
+
const updatedQuantities = addAmountToAsset({
|
4668
|
+
amount: bn17(fee),
|
4929
4669
|
assetId: BaseAssetId3,
|
4930
|
-
coinQuantities
|
4670
|
+
coinQuantities
|
4931
4671
|
});
|
4932
4672
|
const quantitiesDict = {};
|
4933
|
-
|
4673
|
+
updatedQuantities.forEach(({ amount, assetId }) => {
|
4934
4674
|
quantitiesDict[assetId] = {
|
4935
4675
|
required: amount,
|
4936
|
-
owned:
|
4676
|
+
owned: bn17(0)
|
4937
4677
|
};
|
4938
4678
|
});
|
4939
|
-
|
4679
|
+
const cachedUtxos = [];
|
4680
|
+
const cachedMessages = [];
|
4681
|
+
const owner = this.address.toB256();
|
4682
|
+
request.inputs.forEach((input) => {
|
4940
4683
|
const isResource = "amount" in input;
|
4941
4684
|
if (isResource) {
|
4942
4685
|
const isCoin2 = "owner" in input;
|
4943
4686
|
if (isCoin2) {
|
4944
4687
|
const assetId = String(input.assetId);
|
4945
|
-
if (quantitiesDict[assetId]) {
|
4946
|
-
const amount =
|
4688
|
+
if (input.owner === owner && quantitiesDict[assetId]) {
|
4689
|
+
const amount = bn17(input.amount);
|
4947
4690
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4691
|
+
cachedUtxos.push(input.id);
|
4948
4692
|
}
|
4949
|
-
} else if (input.amount && quantitiesDict[BaseAssetId3]) {
|
4693
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
|
4950
4694
|
quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
|
4695
|
+
cachedMessages.push(input.nonce);
|
4951
4696
|
}
|
4952
4697
|
}
|
4953
4698
|
});
|
@@ -4962,23 +4707,12 @@ var Account = class extends AbstractAccount {
|
|
4962
4707
|
});
|
4963
4708
|
const needsToBeFunded = missingQuantities.length;
|
4964
4709
|
if (needsToBeFunded) {
|
4965
|
-
const
|
4966
|
-
|
4967
|
-
|
4968
|
-
|
4969
|
-
|
4970
|
-
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
4971
|
-
const requestToBeReEstimate = clone4(txRequest);
|
4972
|
-
if (addedSignatures) {
|
4973
|
-
Array.from({ length: addedSignatures }).forEach(
|
4974
|
-
() => requestToBeReEstimate.addEmptyWitness()
|
4975
|
-
);
|
4710
|
+
const resources = await this.getResourcesToSpend(missingQuantities, {
|
4711
|
+
messages: cachedMessages,
|
4712
|
+
utxos: cachedUtxos
|
4713
|
+
});
|
4714
|
+
request.addResources(resources);
|
4976
4715
|
}
|
4977
|
-
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
4978
|
-
transactionRequest: requestToBeReEstimate
|
4979
|
-
});
|
4980
|
-
txRequest.maxFee = maxFee;
|
4981
|
-
return txRequest;
|
4982
4716
|
}
|
4983
4717
|
/**
|
4984
4718
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -4986,25 +4720,28 @@ var Account = class extends AbstractAccount {
|
|
4986
4720
|
* @param destination - The address of the destination.
|
4987
4721
|
* @param amount - The amount of coins to transfer.
|
4988
4722
|
* @param assetId - The asset ID of the coins to transfer.
|
4989
|
-
* @param txParams - The transaction parameters (gasLimit,
|
4723
|
+
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4990
4724
|
* @returns A promise that resolves to the prepared transaction request.
|
4991
4725
|
*/
|
4992
4726
|
async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
4993
|
-
const
|
4727
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
4728
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
4729
|
+
const request = new ScriptTransactionRequest(params);
|
4994
4730
|
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
|
4995
|
-
const
|
4731
|
+
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
4996
4732
|
estimateTxDependencies: true,
|
4997
4733
|
resourcesOwner: this
|
4998
4734
|
});
|
4999
|
-
|
5000
|
-
|
5001
|
-
|
5002
|
-
|
5003
|
-
|
5004
|
-
|
5005
|
-
|
5006
|
-
|
5007
|
-
await this.fund(request,
|
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
|
4742
|
+
});
|
4743
|
+
await this.fund(request, requiredQuantities, maxFee);
|
4744
|
+
request.updatePredicateInputs(estimatedInputs);
|
5008
4745
|
return request;
|
5009
4746
|
}
|
5010
4747
|
/**
|
@@ -5017,7 +4754,7 @@ var Account = class extends AbstractAccount {
|
|
5017
4754
|
* @returns A promise that resolves to the transaction response.
|
5018
4755
|
*/
|
5019
4756
|
async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
5020
|
-
if (
|
4757
|
+
if (bn17(amount).lte(0)) {
|
5021
4758
|
throw new FuelError15(
|
5022
4759
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5023
4760
|
"Transfer amount must be a positive number."
|
@@ -5036,37 +4773,38 @@ var Account = class extends AbstractAccount {
|
|
5036
4773
|
* @returns A promise that resolves to the transaction response.
|
5037
4774
|
*/
|
5038
4775
|
async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
|
5039
|
-
if (
|
4776
|
+
if (bn17(amount).lte(0)) {
|
5040
4777
|
throw new FuelError15(
|
5041
4778
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5042
4779
|
"Transfer amount must be a positive number."
|
5043
4780
|
);
|
5044
4781
|
}
|
5045
4782
|
const contractAddress = Address3.fromAddressOrString(contractId);
|
4783
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
4784
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
5046
4785
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5047
4786
|
hexlifiedContractId: contractAddress.toB256(),
|
5048
|
-
amountToTransfer:
|
4787
|
+
amountToTransfer: bn17(amount),
|
5049
4788
|
assetId
|
5050
4789
|
});
|
5051
4790
|
const request = new ScriptTransactionRequest({
|
5052
|
-
...
|
4791
|
+
...params,
|
5053
4792
|
script,
|
5054
4793
|
scriptData
|
5055
4794
|
});
|
5056
4795
|
request.addContractInputAndOutput(contractAddress);
|
5057
|
-
const
|
5058
|
-
|
5059
|
-
|
4796
|
+
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
4797
|
+
request,
|
4798
|
+
[{ amount: bn17(amount), assetId: String(assetId) }]
|
4799
|
+
);
|
4800
|
+
request.gasLimit = bn17(params.gasLimit ?? gasUsed);
|
4801
|
+
this.validateGas({
|
4802
|
+
gasUsed,
|
4803
|
+
gasPrice: request.gasPrice,
|
4804
|
+
gasLimit: request.gasLimit,
|
4805
|
+
minGasPrice
|
5060
4806
|
});
|
5061
|
-
|
5062
|
-
this.validateGas({
|
5063
|
-
gasUsed: txCost.gasUsed,
|
5064
|
-
gasLimit: request.gasLimit
|
5065
|
-
});
|
5066
|
-
}
|
5067
|
-
request.gasLimit = txCost.gasUsed;
|
5068
|
-
request.maxFee = txCost.maxFee;
|
5069
|
-
await this.fund(request, txCost);
|
4807
|
+
await this.fund(request, requiredQuantities, maxFee);
|
5070
4808
|
return this.sendTransaction(request);
|
5071
4809
|
}
|
5072
4810
|
/**
|
@@ -5078,31 +4816,34 @@ var Account = class extends AbstractAccount {
|
|
5078
4816
|
* @returns A promise that resolves to the transaction response.
|
5079
4817
|
*/
|
5080
4818
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4819
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
5081
4820
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
5082
4821
|
const recipientDataArray = arrayify14(
|
5083
4822
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5084
4823
|
);
|
5085
4824
|
const amountDataArray = arrayify14(
|
5086
|
-
"0x".concat(
|
4825
|
+
"0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
|
5087
4826
|
);
|
5088
4827
|
const script = new Uint8Array([
|
5089
4828
|
...arrayify14(withdrawScript.bytes),
|
5090
4829
|
...recipientDataArray,
|
5091
4830
|
...amountDataArray
|
5092
4831
|
]);
|
5093
|
-
const params = { script, ...txParams };
|
4832
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
5094
4833
|
const request = new ScriptTransactionRequest(params);
|
5095
|
-
const
|
5096
|
-
const
|
5097
|
-
|
5098
|
-
|
5099
|
-
|
5100
|
-
|
5101
|
-
|
5102
|
-
|
5103
|
-
|
5104
|
-
|
5105
|
-
|
4834
|
+
const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
|
4835
|
+
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
4836
|
+
request,
|
4837
|
+
forwardingQuantities
|
4838
|
+
);
|
4839
|
+
request.gasLimit = bn17(params.gasLimit ?? gasUsed);
|
4840
|
+
this.validateGas({
|
4841
|
+
gasUsed,
|
4842
|
+
gasPrice: request.gasPrice,
|
4843
|
+
gasLimit: request.gasLimit,
|
4844
|
+
minGasPrice
|
4845
|
+
});
|
4846
|
+
await this.fund(request, requiredQuantities, maxFee);
|
5106
4847
|
return this.sendTransaction(request);
|
5107
4848
|
}
|
5108
4849
|
async signMessage(message) {
|
@@ -5160,7 +4901,18 @@ var Account = class extends AbstractAccount {
|
|
5160
4901
|
}
|
5161
4902
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5162
4903
|
}
|
5163
|
-
validateGas({
|
4904
|
+
validateGas({
|
4905
|
+
gasUsed,
|
4906
|
+
gasPrice,
|
4907
|
+
gasLimit,
|
4908
|
+
minGasPrice
|
4909
|
+
}) {
|
4910
|
+
if (minGasPrice.gt(gasPrice)) {
|
4911
|
+
throw new FuelError15(
|
4912
|
+
ErrorCode15.GAS_PRICE_TOO_LOW,
|
4913
|
+
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
4914
|
+
);
|
4915
|
+
}
|
5164
4916
|
if (gasUsed.gt(gasLimit)) {
|
5165
4917
|
throw new FuelError15(
|
5166
4918
|
ErrorCode15.GAS_LIMIT_TOO_LOW,
|
@@ -5452,7 +5204,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5452
5204
|
* @param transactionRequestLike - The transaction request to send.
|
5453
5205
|
* @returns A promise that resolves to the TransactionResponse object.
|
5454
5206
|
*/
|
5455
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
5207
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
5456
5208
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5457
5209
|
if (estimateTxDependencies) {
|
5458
5210
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -5493,7 +5245,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5493
5245
|
// src/hdwallet/hdwallet.ts
|
5494
5246
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5495
5247
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5496
|
-
import { bn as
|
5248
|
+
import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5497
5249
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5498
5250
|
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5499
5251
|
|
@@ -7959,7 +7711,7 @@ var HDWallet = class {
|
|
7959
7711
|
const IR = bytes.slice(32);
|
7960
7712
|
if (privateKey) {
|
7961
7713
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7962
|
-
const ki =
|
7714
|
+
const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
|
7963
7715
|
return new HDWallet({
|
7964
7716
|
privateKey: ki,
|
7965
7717
|
chainCode: IR,
|
@@ -8225,20 +7977,26 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
8225
7977
|
|
8226
7978
|
// src/test-utils/seedTestWallet.ts
|
8227
7979
|
import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
|
8228
|
-
var seedTestWallet = async (wallet, quantities) => {
|
7980
|
+
var seedTestWallet = async (wallet, quantities, utxosAmount = 1) => {
|
7981
|
+
const toFundAccounts = Array.isArray(wallet) ? wallet : [wallet];
|
8229
7982
|
const genesisWallet = new WalletUnlocked(
|
8230
7983
|
process.env.GENESIS_SECRET || randomBytes5(32),
|
8231
|
-
|
7984
|
+
toFundAccounts[0].provider
|
8232
7985
|
);
|
8233
|
-
const
|
8234
|
-
|
8235
|
-
|
8236
|
-
|
7986
|
+
const resources = await genesisWallet.getResourcesToSpend(quantities);
|
7987
|
+
const { minGasPrice } = genesisWallet.provider.getGasConfig();
|
7988
|
+
const request = new ScriptTransactionRequest({
|
7989
|
+
gasLimit: 1e4,
|
7990
|
+
gasPrice: minGasPrice
|
8237
7991
|
});
|
8238
|
-
|
8239
|
-
|
8240
|
-
|
8241
|
-
|
7992
|
+
request.addResources(resources);
|
7993
|
+
quantities.map(coinQuantityfy).forEach(
|
7994
|
+
({ amount, assetId }) => toFundAccounts.forEach(({ address }) => {
|
7995
|
+
for (let i = 0; i < utxosAmount; i++) {
|
7996
|
+
request.addCoinOutput(address, amount.div(utxosAmount), assetId);
|
7997
|
+
}
|
7998
|
+
})
|
7999
|
+
);
|
8242
8000
|
await genesisWallet.sendTransaction(request, { awaitExecution: true });
|
8243
8001
|
};
|
8244
8002
|
|
@@ -8252,10 +8010,9 @@ var generateTestWallet = async (provider, quantities) => {
|
|
8252
8010
|
};
|
8253
8011
|
|
8254
8012
|
// src/test-utils/launchNode.ts
|
8255
|
-
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
8256
8013
|
import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
|
8257
|
-
import {
|
8258
|
-
import {
|
8014
|
+
import { toHex as toHex2 } from "@fuel-ts/math";
|
8015
|
+
import { defaultChainConfig, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
|
8259
8016
|
import { findBinPath } from "@fuel-ts/utils/cli-utils";
|
8260
8017
|
import { spawn } from "child_process";
|
8261
8018
|
import { randomUUID } from "crypto";
|
@@ -8307,12 +8064,12 @@ var launchNode = async ({
|
|
8307
8064
|
// eslint-disable-next-line no-async-promise-executor
|
8308
8065
|
new Promise(async (resolve, reject) => {
|
8309
8066
|
const remainingArgs = extractRemainingArgs(args, [
|
8310
|
-
"--
|
8067
|
+
"--chain",
|
8311
8068
|
"--consensus-key",
|
8312
8069
|
"--db-type",
|
8313
8070
|
"--poa-instant"
|
8314
8071
|
]);
|
8315
|
-
const chainConfigPath = getFlagValueFromArgs(args, "--
|
8072
|
+
const chainConfigPath = getFlagValueFromArgs(args, "--chain");
|
8316
8073
|
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || defaultConsensusKey;
|
8317
8074
|
const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
|
8318
8075
|
const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
|
@@ -8331,54 +8088,36 @@ var launchNode = async ({
|
|
8331
8088
|
let chainConfigPathToUse;
|
8332
8089
|
const prefix = basePath || os.tmpdir();
|
8333
8090
|
const suffix = basePath ? "" : randomUUID();
|
8334
|
-
const tempDirPath = path.join(prefix, ".fuels", suffix
|
8091
|
+
const tempDirPath = path.join(prefix, ".fuels", suffix);
|
8335
8092
|
if (chainConfigPath) {
|
8336
8093
|
chainConfigPathToUse = chainConfigPath;
|
8337
8094
|
} else {
|
8338
8095
|
if (!existsSync(tempDirPath)) {
|
8339
8096
|
mkdirSync(tempDirPath, { recursive: true });
|
8340
8097
|
}
|
8341
|
-
|
8342
|
-
|
8343
|
-
stateConfigJson = {
|
8344
|
-
...stateConfigJson,
|
8345
|
-
coins: [
|
8346
|
-
...stateConfigJson.coins.map((coin) => ({
|
8347
|
-
...coin,
|
8348
|
-
amount: "18446744073709551615"
|
8349
|
-
}))
|
8350
|
-
],
|
8351
|
-
messages: stateConfigJson.messages.map((message) => ({
|
8352
|
-
...message,
|
8353
|
-
amount: "18446744073709551615"
|
8354
|
-
}))
|
8355
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8356
|
-
};
|
8098
|
+
const tempChainConfigFilePath = path.join(tempDirPath, "chainConfig.json");
|
8099
|
+
let chainConfig = defaultChainConfig;
|
8357
8100
|
if (!process.env.GENESIS_SECRET) {
|
8358
8101
|
const pk = Signer.generatePrivateKey();
|
8359
8102
|
const signer = new Signer(pk);
|
8360
8103
|
process.env.GENESIS_SECRET = hexlify18(pk);
|
8361
|
-
|
8362
|
-
|
8363
|
-
|
8364
|
-
|
8365
|
-
|
8366
|
-
|
8367
|
-
|
8368
|
-
|
8369
|
-
|
8370
|
-
|
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: BaseAssetId4
|
8114
|
+
}
|
8115
|
+
]
|
8116
|
+
}
|
8117
|
+
};
|
8371
8118
|
}
|
8372
|
-
|
8373
|
-
|
8374
|
-
fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
|
8375
|
-
const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
|
8376
|
-
const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
|
8377
|
-
const metadataWritePath = path.join(tempDirPath, "metadata.json");
|
8378
|
-
writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
|
8379
|
-
writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
|
8380
|
-
writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
|
8381
|
-
chainConfigPathToUse = tempDirPath;
|
8119
|
+
writeFileSync(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
|
8120
|
+
chainConfigPathToUse = tempChainConfigFilePath;
|
8382
8121
|
}
|
8383
8122
|
const child = spawn(
|
8384
8123
|
command,
|
@@ -8387,10 +8126,10 @@ var launchNode = async ({
|
|
8387
8126
|
["--ip", ipToUse],
|
8388
8127
|
["--port", portToUse],
|
8389
8128
|
useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
|
8390
|
-
["--min-gas-price", "
|
8129
|
+
["--min-gas-price", "0"],
|
8391
8130
|
poaInstant ? ["--poa-instant", "true"] : [],
|
8392
8131
|
["--consensus-key", consensusKey],
|
8393
|
-
["--
|
8132
|
+
["--chain", chainConfigPathToUse],
|
8394
8133
|
"--vm-backtrace",
|
8395
8134
|
"--utxo-validation",
|
8396
8135
|
"--debug",
|
@@ -8449,14 +8188,51 @@ var launchNodeAndGetWallets = async ({
|
|
8449
8188
|
walletCount = 10
|
8450
8189
|
} = {}) => {
|
8451
8190
|
const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
|
8452
|
-
const provider = await Provider.create(`http://${ip}:${port}/
|
8191
|
+
const provider = await Provider.create(`http://${ip}:${port}/graphql`);
|
8453
8192
|
const wallets = await generateWallets(walletCount, provider);
|
8454
8193
|
const cleanup = () => {
|
8455
8194
|
closeNode();
|
8456
8195
|
};
|
8457
8196
|
return { wallets, stop: cleanup, provider };
|
8458
8197
|
};
|
8198
|
+
|
8199
|
+
// src/test-utils/transactionRequest.ts
|
8200
|
+
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
8201
|
+
import { getRandomB256 } from "@fuel-ts/address";
|
8202
|
+
import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
|
8203
|
+
import { randomBytes as randomBytes6 } from "@fuel-ts/crypto";
|
8204
|
+
import { bn as bn19 } from "@fuel-ts/math";
|
8205
|
+
import { InputType as InputType8 } from "@fuel-ts/transactions";
|
8206
|
+
import { hexlify as hexlify19 } from "@fuel-ts/utils";
|
8207
|
+
var generateFakeRequestInputCoin = (partial = {}) => ({
|
8208
|
+
id: hexlify19(randomBytes6(UTXO_ID_LEN3)),
|
8209
|
+
type: InputType8.Coin,
|
8210
|
+
owner: getRandomB256(),
|
8211
|
+
amount: bn19(100),
|
8212
|
+
assetId: ZeroBytes329,
|
8213
|
+
txPointer: "0x00000000000000000000000000000000",
|
8214
|
+
witnessIndex: 0,
|
8215
|
+
...partial
|
8216
|
+
});
|
8217
|
+
var generateFakeRequestInputMessage = (partial = {}) => ({
|
8218
|
+
nonce: getRandomB256(),
|
8219
|
+
type: InputType8.Message,
|
8220
|
+
sender: getRandomB256(),
|
8221
|
+
recipient: getRandomB256(),
|
8222
|
+
amount: bn19(100),
|
8223
|
+
witnessIndex: 0,
|
8224
|
+
...partial
|
8225
|
+
});
|
8226
|
+
var generateFakeRequestInputContract = (partial = {}) => ({
|
8227
|
+
contractId: getRandomB256(),
|
8228
|
+
type: InputType8.Contract,
|
8229
|
+
txPointer: "0x00000000000000000000000000000000",
|
8230
|
+
...partial
|
8231
|
+
});
|
8459
8232
|
export {
|
8233
|
+
generateFakeRequestInputCoin,
|
8234
|
+
generateFakeRequestInputContract,
|
8235
|
+
generateFakeRequestInputMessage,
|
8460
8236
|
generateTestWallet,
|
8461
8237
|
killNode,
|
8462
8238
|
launchNode,
|