@fuel-ts/account 0.0.0-rc-2021-20240418170033 → 0.0.0-rc-2037-20240418195040
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 +596 -797
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +633 -825
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +451 -648
- 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 +329 -911
- 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 +7 -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 +1085 -1547
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +608 -804
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +442 -641
- 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,
|
@@ -88,10 +87,14 @@ import { clone as clone3 } from "ramda";
|
|
88
87
|
import gql from "graphql-tag";
|
89
88
|
var ReceiptFragmentFragmentDoc = gql`
|
90
89
|
fragment receiptFragment on Receipt {
|
91
|
-
|
90
|
+
contract {
|
91
|
+
id
|
92
|
+
}
|
92
93
|
pc
|
93
94
|
is
|
94
|
-
to
|
95
|
+
to {
|
96
|
+
id
|
97
|
+
}
|
95
98
|
toAddress
|
96
99
|
amount
|
97
100
|
assetId
|
@@ -129,16 +132,10 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
129
132
|
id
|
130
133
|
}
|
131
134
|
time
|
132
|
-
receipts {
|
133
|
-
...receiptFragment
|
134
|
-
}
|
135
135
|
programState {
|
136
136
|
returnType
|
137
137
|
data
|
138
138
|
}
|
139
|
-
receipts {
|
140
|
-
...receiptFragment
|
141
|
-
}
|
142
139
|
}
|
143
140
|
... on FailureStatus {
|
144
141
|
block {
|
@@ -146,24 +143,26 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
146
143
|
}
|
147
144
|
time
|
148
145
|
reason
|
149
|
-
receipts {
|
150
|
-
...receiptFragment
|
151
|
-
}
|
152
146
|
}
|
153
147
|
... on SqueezedOutStatus {
|
154
148
|
reason
|
155
149
|
}
|
156
150
|
}
|
157
|
-
|
151
|
+
`;
|
158
152
|
var TransactionFragmentFragmentDoc = gql`
|
159
153
|
fragment transactionFragment on Transaction {
|
160
154
|
id
|
161
155
|
rawPayload
|
156
|
+
gasPrice
|
157
|
+
receipts {
|
158
|
+
...receiptFragment
|
159
|
+
}
|
162
160
|
status {
|
163
161
|
...transactionStatusFragment
|
164
162
|
}
|
165
163
|
}
|
166
|
-
${
|
164
|
+
${ReceiptFragmentFragmentDoc}
|
165
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
167
166
|
var InputEstimatePredicatesFragmentFragmentDoc = gql`
|
168
167
|
fragment inputEstimatePredicatesFragment on Input {
|
169
168
|
... on InputCoin {
|
@@ -181,46 +180,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
|
|
181
180
|
}
|
182
181
|
}
|
183
182
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
184
|
-
var DryRunFailureStatusFragmentFragmentDoc = gql`
|
185
|
-
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
186
|
-
reason
|
187
|
-
programState {
|
188
|
-
returnType
|
189
|
-
data
|
190
|
-
}
|
191
|
-
}
|
192
|
-
`;
|
193
|
-
var DryRunSuccessStatusFragmentFragmentDoc = gql`
|
194
|
-
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
195
|
-
programState {
|
196
|
-
returnType
|
197
|
-
data
|
198
|
-
}
|
199
|
-
}
|
200
|
-
`;
|
201
|
-
var DryRunTransactionStatusFragmentFragmentDoc = gql`
|
202
|
-
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
203
|
-
... on DryRunFailureStatus {
|
204
|
-
...dryRunFailureStatusFragment
|
205
|
-
}
|
206
|
-
... on DryRunSuccessStatus {
|
207
|
-
...dryRunSuccessStatusFragment
|
208
|
-
}
|
209
|
-
}
|
210
|
-
${DryRunFailureStatusFragmentFragmentDoc}
|
211
|
-
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
212
|
-
var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
|
213
|
-
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
214
|
-
id
|
215
|
-
status {
|
216
|
-
...dryRunTransactionStatusFragment
|
217
|
-
}
|
218
|
-
receipts {
|
219
|
-
...receiptFragment
|
220
|
-
}
|
221
|
-
}
|
222
|
-
${DryRunTransactionStatusFragmentFragmentDoc}
|
223
|
-
${ReceiptFragmentFragmentDoc}`;
|
224
183
|
var CoinFragmentFragmentDoc = gql`
|
225
184
|
fragment coinFragment on Coin {
|
226
185
|
__typename
|
@@ -228,6 +187,7 @@ var CoinFragmentFragmentDoc = gql`
|
|
228
187
|
owner
|
229
188
|
amount
|
230
189
|
assetId
|
190
|
+
maturity
|
231
191
|
blockCreated
|
232
192
|
txCreatedIdx
|
233
193
|
}
|
@@ -266,32 +226,26 @@ var MessageProofFragmentFragmentDoc = gql`
|
|
266
226
|
messageBlockHeader {
|
267
227
|
id
|
268
228
|
daHeight
|
269
|
-
consensusParametersVersion
|
270
|
-
stateTransitionBytecodeVersion
|
271
229
|
transactionsCount
|
272
|
-
messageReceiptCount
|
273
230
|
transactionsRoot
|
274
|
-
messageOutboxRoot
|
275
|
-
eventInboxRoot
|
276
231
|
height
|
277
232
|
prevRoot
|
278
233
|
time
|
279
234
|
applicationHash
|
235
|
+
messageReceiptRoot
|
236
|
+
messageReceiptCount
|
280
237
|
}
|
281
238
|
commitBlockHeader {
|
282
239
|
id
|
283
240
|
daHeight
|
284
|
-
consensusParametersVersion
|
285
|
-
stateTransitionBytecodeVersion
|
286
241
|
transactionsCount
|
287
|
-
messageReceiptCount
|
288
242
|
transactionsRoot
|
289
|
-
messageOutboxRoot
|
290
|
-
eventInboxRoot
|
291
243
|
height
|
292
244
|
prevRoot
|
293
245
|
time
|
294
246
|
applicationHash
|
247
|
+
messageReceiptRoot
|
248
|
+
messageReceiptCount
|
295
249
|
}
|
296
250
|
sender
|
297
251
|
recipient
|
@@ -310,8 +264,8 @@ var BalanceFragmentFragmentDoc = gql`
|
|
310
264
|
var BlockFragmentFragmentDoc = gql`
|
311
265
|
fragment blockFragment on Block {
|
312
266
|
id
|
313
|
-
height
|
314
267
|
header {
|
268
|
+
height
|
315
269
|
time
|
316
270
|
}
|
317
271
|
transactions {
|
@@ -369,11 +323,6 @@ var DependentCostFragmentFragmentDoc = gql`
|
|
369
323
|
`;
|
370
324
|
var GasCostsFragmentFragmentDoc = gql`
|
371
325
|
fragment GasCostsFragment on GasCosts {
|
372
|
-
version {
|
373
|
-
... on Version {
|
374
|
-
value
|
375
|
-
}
|
376
|
-
}
|
377
326
|
add
|
378
327
|
addi
|
379
328
|
aloc
|
@@ -386,6 +335,7 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
386
335
|
cb
|
387
336
|
cfei
|
388
337
|
cfsi
|
338
|
+
croo
|
389
339
|
div
|
390
340
|
divi
|
391
341
|
ecr1
|
@@ -468,9 +418,6 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
468
418
|
ccp {
|
469
419
|
...DependentCostFragment
|
470
420
|
}
|
471
|
-
croo {
|
472
|
-
...DependentCostFragment
|
473
|
-
}
|
474
421
|
csiz {
|
475
422
|
...DependentCostFragment
|
476
423
|
}
|
@@ -530,11 +477,6 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
530
477
|
${DependentCostFragmentFragmentDoc}`;
|
531
478
|
var ConsensusParametersFragmentFragmentDoc = gql`
|
532
479
|
fragment consensusParametersFragment on ConsensusParameters {
|
533
|
-
version {
|
534
|
-
... on Version {
|
535
|
-
value
|
536
|
-
}
|
537
|
-
}
|
538
480
|
txParams {
|
539
481
|
...TxParametersFragment
|
540
482
|
}
|
@@ -594,9 +536,18 @@ var NodeInfoFragmentFragmentDoc = gql`
|
|
594
536
|
fragment nodeInfoFragment on NodeInfo {
|
595
537
|
utxoValidation
|
596
538
|
vmBacktrace
|
539
|
+
minGasPrice
|
597
540
|
maxTx
|
598
541
|
maxDepth
|
599
542
|
nodeVersion
|
543
|
+
peers {
|
544
|
+
id
|
545
|
+
addresses
|
546
|
+
clientVersion
|
547
|
+
blockHeight
|
548
|
+
lastHeartbeatMs
|
549
|
+
appScore
|
550
|
+
}
|
600
551
|
}
|
601
552
|
`;
|
602
553
|
var GetVersionDocument = gql`
|
@@ -631,9 +582,13 @@ var GetTransactionWithReceiptsDocument = gql`
|
|
631
582
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
632
583
|
transaction(id: $transactionId) {
|
633
584
|
...transactionFragment
|
585
|
+
receipts {
|
586
|
+
...receiptFragment
|
587
|
+
}
|
634
588
|
}
|
635
589
|
}
|
636
|
-
${TransactionFragmentFragmentDoc}
|
590
|
+
${TransactionFragmentFragmentDoc}
|
591
|
+
${ReceiptFragmentFragmentDoc}`;
|
637
592
|
var GetTransactionsDocument = gql`
|
638
593
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
639
594
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -761,20 +716,6 @@ var GetBalanceDocument = gql`
|
|
761
716
|
}
|
762
717
|
}
|
763
718
|
${BalanceFragmentFragmentDoc}`;
|
764
|
-
var GetLatestGasPriceDocument = gql`
|
765
|
-
query getLatestGasPrice {
|
766
|
-
latestGasPrice {
|
767
|
-
gasPrice
|
768
|
-
}
|
769
|
-
}
|
770
|
-
`;
|
771
|
-
var EstimateGasPriceDocument = gql`
|
772
|
-
query estimateGasPrice($blockHorizon: U32!) {
|
773
|
-
estimateGasPrice(blockHorizon: $blockHorizon) {
|
774
|
-
gasPrice
|
775
|
-
}
|
776
|
-
}
|
777
|
-
`;
|
778
719
|
var GetBalancesDocument = gql`
|
779
720
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
780
721
|
balances(
|
@@ -829,12 +770,12 @@ var GetMessageStatusDocument = gql`
|
|
829
770
|
}
|
830
771
|
`;
|
831
772
|
var DryRunDocument = gql`
|
832
|
-
mutation dryRun($
|
833
|
-
dryRun(
|
834
|
-
...
|
773
|
+
mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
|
774
|
+
dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
|
775
|
+
...receiptFragment
|
835
776
|
}
|
836
777
|
}
|
837
|
-
${
|
778
|
+
${ReceiptFragmentFragmentDoc}`;
|
838
779
|
var SubmitDocument = gql`
|
839
780
|
mutation submit($encodedTransaction: HexString!) {
|
840
781
|
submit(tx: $encodedTransaction) {
|
@@ -917,12 +858,6 @@ function getSdk(requester) {
|
|
917
858
|
getBalance(variables, options) {
|
918
859
|
return requester(GetBalanceDocument, variables, options);
|
919
860
|
},
|
920
|
-
getLatestGasPrice(variables, options) {
|
921
|
-
return requester(GetLatestGasPriceDocument, variables, options);
|
922
|
-
},
|
923
|
-
estimateGasPrice(variables, options) {
|
924
|
-
return requester(EstimateGasPriceDocument, variables, options);
|
925
|
-
},
|
926
861
|
getBalances(variables, options) {
|
927
862
|
return requester(GetBalancesDocument, variables, options);
|
928
863
|
},
|
@@ -1116,9 +1051,10 @@ var inputify = (value) => {
|
|
1116
1051
|
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
1117
1052
|
},
|
1118
1053
|
witnessIndex: value.witnessIndex,
|
1054
|
+
maturity: value.maturity ?? 0,
|
1119
1055
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1120
|
-
predicateLength:
|
1121
|
-
predicateDataLength:
|
1056
|
+
predicateLength: predicate.length,
|
1057
|
+
predicateDataLength: predicateData.length,
|
1122
1058
|
predicate: hexlify3(predicate),
|
1123
1059
|
predicateData: hexlify3(predicateData)
|
1124
1060
|
};
|
@@ -1149,8 +1085,8 @@ var inputify = (value) => {
|
|
1149
1085
|
nonce: hexlify3(value.nonce),
|
1150
1086
|
witnessIndex: value.witnessIndex,
|
1151
1087
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1152
|
-
predicateLength:
|
1153
|
-
predicateDataLength:
|
1088
|
+
predicateLength: predicate.length,
|
1089
|
+
predicateDataLength: predicateData.length,
|
1154
1090
|
predicate: hexlify3(predicate),
|
1155
1091
|
predicateData: hexlify3(predicateData),
|
1156
1092
|
data: hexlify3(data),
|
@@ -1232,7 +1168,7 @@ import { bn as bn7 } from "@fuel-ts/math";
|
|
1232
1168
|
import {
|
1233
1169
|
PolicyType,
|
1234
1170
|
TransactionCoder,
|
1235
|
-
InputType as
|
1171
|
+
InputType as InputType3,
|
1236
1172
|
OutputType as OutputType2,
|
1237
1173
|
TransactionType
|
1238
1174
|
} from "@fuel-ts/transactions";
|
@@ -1277,8 +1213,8 @@ function assembleReceiptByType(receipt) {
|
|
1277
1213
|
case "CALL" /* Call */: {
|
1278
1214
|
const callReceipt = {
|
1279
1215
|
type: ReceiptType.Call,
|
1280
|
-
from: hexOrZero(receipt.id
|
1281
|
-
to: hexOrZero(receipt?.to),
|
1216
|
+
from: hexOrZero(receipt.contract?.id),
|
1217
|
+
to: hexOrZero(receipt?.to?.id),
|
1282
1218
|
amount: bn4(receipt.amount),
|
1283
1219
|
assetId: hexOrZero(receipt.assetId),
|
1284
1220
|
gas: bn4(receipt.gas),
|
@@ -1292,7 +1228,7 @@ function assembleReceiptByType(receipt) {
|
|
1292
1228
|
case "RETURN" /* Return */: {
|
1293
1229
|
const returnReceipt = {
|
1294
1230
|
type: ReceiptType.Return,
|
1295
|
-
id: hexOrZero(receipt.id
|
1231
|
+
id: hexOrZero(receipt.contract?.id),
|
1296
1232
|
val: bn4(receipt.val),
|
1297
1233
|
pc: bn4(receipt.pc),
|
1298
1234
|
is: bn4(receipt.is)
|
@@ -1302,7 +1238,7 @@ function assembleReceiptByType(receipt) {
|
|
1302
1238
|
case "RETURN_DATA" /* ReturnData */: {
|
1303
1239
|
const returnDataReceipt = {
|
1304
1240
|
type: ReceiptType.ReturnData,
|
1305
|
-
id: hexOrZero(receipt.id
|
1241
|
+
id: hexOrZero(receipt.contract?.id),
|
1306
1242
|
ptr: bn4(receipt.ptr),
|
1307
1243
|
len: bn4(receipt.len),
|
1308
1244
|
digest: hexOrZero(receipt.digest),
|
@@ -1314,7 +1250,7 @@ function assembleReceiptByType(receipt) {
|
|
1314
1250
|
case "PANIC" /* Panic */: {
|
1315
1251
|
const panicReceipt = {
|
1316
1252
|
type: ReceiptType.Panic,
|
1317
|
-
id: hexOrZero(receipt.id),
|
1253
|
+
id: hexOrZero(receipt.contract?.id),
|
1318
1254
|
reason: bn4(receipt.reason),
|
1319
1255
|
pc: bn4(receipt.pc),
|
1320
1256
|
is: bn4(receipt.is),
|
@@ -1325,7 +1261,7 @@ function assembleReceiptByType(receipt) {
|
|
1325
1261
|
case "REVERT" /* Revert */: {
|
1326
1262
|
const revertReceipt = {
|
1327
1263
|
type: ReceiptType.Revert,
|
1328
|
-
id: hexOrZero(receipt.id
|
1264
|
+
id: hexOrZero(receipt.contract?.id),
|
1329
1265
|
val: bn4(receipt.ra),
|
1330
1266
|
pc: bn4(receipt.pc),
|
1331
1267
|
is: bn4(receipt.is)
|
@@ -1335,7 +1271,7 @@ function assembleReceiptByType(receipt) {
|
|
1335
1271
|
case "LOG" /* Log */: {
|
1336
1272
|
const logReceipt = {
|
1337
1273
|
type: ReceiptType.Log,
|
1338
|
-
id: hexOrZero(receipt.id
|
1274
|
+
id: hexOrZero(receipt.contract?.id),
|
1339
1275
|
val0: bn4(receipt.ra),
|
1340
1276
|
val1: bn4(receipt.rb),
|
1341
1277
|
val2: bn4(receipt.rc),
|
@@ -1348,7 +1284,7 @@ function assembleReceiptByType(receipt) {
|
|
1348
1284
|
case "LOG_DATA" /* LogData */: {
|
1349
1285
|
const logDataReceipt = {
|
1350
1286
|
type: ReceiptType.LogData,
|
1351
|
-
id: hexOrZero(receipt.id
|
1287
|
+
id: hexOrZero(receipt.contract?.id),
|
1352
1288
|
val0: bn4(receipt.ra),
|
1353
1289
|
val1: bn4(receipt.rb),
|
1354
1290
|
ptr: bn4(receipt.ptr),
|
@@ -1362,8 +1298,8 @@ function assembleReceiptByType(receipt) {
|
|
1362
1298
|
case "TRANSFER" /* Transfer */: {
|
1363
1299
|
const transferReceipt = {
|
1364
1300
|
type: ReceiptType.Transfer,
|
1365
|
-
from: hexOrZero(receipt.id
|
1366
|
-
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1301
|
+
from: hexOrZero(receipt.contract?.id),
|
1302
|
+
to: hexOrZero(receipt.toAddress || receipt?.to?.id),
|
1367
1303
|
amount: bn4(receipt.amount),
|
1368
1304
|
assetId: hexOrZero(receipt.assetId),
|
1369
1305
|
pc: bn4(receipt.pc),
|
@@ -1374,8 +1310,8 @@ function assembleReceiptByType(receipt) {
|
|
1374
1310
|
case "TRANSFER_OUT" /* TransferOut */: {
|
1375
1311
|
const transferOutReceipt = {
|
1376
1312
|
type: ReceiptType.TransferOut,
|
1377
|
-
from: hexOrZero(receipt.id
|
1378
|
-
to: hexOrZero(receipt.toAddress || receipt.to),
|
1313
|
+
from: hexOrZero(receipt.contract?.id),
|
1314
|
+
to: hexOrZero(receipt.toAddress || receipt.to?.id),
|
1379
1315
|
amount: bn4(receipt.amount),
|
1380
1316
|
assetId: hexOrZero(receipt.assetId),
|
1381
1317
|
pc: bn4(receipt.pc),
|
@@ -1418,7 +1354,7 @@ function assembleReceiptByType(receipt) {
|
|
1418
1354
|
return receiptMessageOut;
|
1419
1355
|
}
|
1420
1356
|
case "MINT" /* Mint */: {
|
1421
|
-
const contractId = hexOrZero(receipt.id
|
1357
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
1422
1358
|
const subId = hexOrZero(receipt.subId);
|
1423
1359
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
1424
1360
|
const mintReceipt = {
|
@@ -1433,7 +1369,7 @@ function assembleReceiptByType(receipt) {
|
|
1433
1369
|
return mintReceipt;
|
1434
1370
|
}
|
1435
1371
|
case "BURN" /* Burn */: {
|
1436
|
-
const contractId = hexOrZero(receipt.id
|
1372
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
1437
1373
|
const subId = hexOrZero(receipt.subId);
|
1438
1374
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
1439
1375
|
const burnReceipt = {
|
@@ -1459,6 +1395,7 @@ import { ErrorCode as ErrorCode6, FuelError as FuelError6 } from "@fuel-ts/error
|
|
1459
1395
|
import { bn as bn5 } from "@fuel-ts/math";
|
1460
1396
|
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
1461
1397
|
import { arrayify as arrayify3 } from "@fuel-ts/utils";
|
1398
|
+
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1462
1399
|
var getGasUsedFromReceipts = (receipts) => {
|
1463
1400
|
const scriptResult = receipts.filter(
|
1464
1401
|
(receipt) => receipt.type === ReceiptType2.ScriptResult
|
@@ -1479,28 +1416,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
1479
1416
|
}
|
1480
1417
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
1481
1418
|
const witnessCache = [];
|
1482
|
-
const
|
1483
|
-
const isCoinOrMessage = "owner" in input || "sender" in input;
|
1484
|
-
if (isCoinOrMessage) {
|
1485
|
-
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1486
|
-
return true;
|
1487
|
-
}
|
1488
|
-
if (!witnessCache.includes(input.witnessIndex)) {
|
1489
|
-
witnessCache.push(input.witnessIndex);
|
1490
|
-
return true;
|
1491
|
-
}
|
1492
|
-
}
|
1493
|
-
return false;
|
1494
|
-
});
|
1495
|
-
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
1496
|
-
const totalGas = chargeableInputs.reduce((total, input) => {
|
1419
|
+
const totalGas = inputs.reduce((total, input) => {
|
1497
1420
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1498
1421
|
return total.add(
|
1499
|
-
|
1422
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
|
1500
1423
|
);
|
1501
1424
|
}
|
1502
|
-
|
1503
|
-
|
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());
|
1504
1431
|
return totalGas;
|
1505
1432
|
}
|
1506
1433
|
function getMinGas(params) {
|
@@ -1512,20 +1439,12 @@ function getMinGas(params) {
|
|
1512
1439
|
return minGas;
|
1513
1440
|
}
|
1514
1441
|
function getMaxGas(params) {
|
1515
|
-
const {
|
1516
|
-
gasPerByte,
|
1517
|
-
witnessesLength,
|
1518
|
-
witnessLimit,
|
1519
|
-
minGas,
|
1520
|
-
gasLimit = bn5(0),
|
1521
|
-
maxGasPerTx
|
1522
|
-
} = params;
|
1442
|
+
const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
|
1523
1443
|
let remainingAllowedWitnessGas = bn5(0);
|
1524
1444
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
1525
1445
|
remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
1526
1446
|
}
|
1527
|
-
|
1528
|
-
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
1447
|
+
return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
1529
1448
|
}
|
1530
1449
|
function calculateMetadataGasForTxCreate({
|
1531
1450
|
gasCosts,
|
@@ -1547,10 +1466,6 @@ function calculateMetadataGasForTxScript({
|
|
1547
1466
|
}) {
|
1548
1467
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1549
1468
|
}
|
1550
|
-
var calculateGasFee = (params) => {
|
1551
|
-
const { gas, gasPrice, priceFactor, tip } = params;
|
1552
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1553
|
-
};
|
1554
1469
|
|
1555
1470
|
// src/providers/utils/json.ts
|
1556
1471
|
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
@@ -1682,6 +1597,12 @@ var NoWitnessAtIndexError = class extends Error {
|
|
1682
1597
|
name = "NoWitnessAtIndexError";
|
1683
1598
|
};
|
1684
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
|
+
|
1685
1606
|
// src/providers/transaction-request/witness.ts
|
1686
1607
|
import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
|
1687
1608
|
var witnessify = (value) => {
|
@@ -1695,7 +1616,7 @@ var witnessify = (value) => {
|
|
1695
1616
|
// src/providers/transaction-request/transaction-request.ts
|
1696
1617
|
var BaseTransactionRequest = class {
|
1697
1618
|
/** Gas price for transaction */
|
1698
|
-
|
1619
|
+
gasPrice;
|
1699
1620
|
/** Block until which tx cannot be included */
|
1700
1621
|
maturity;
|
1701
1622
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -1714,7 +1635,7 @@ var BaseTransactionRequest = class {
|
|
1714
1635
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
1715
1636
|
*/
|
1716
1637
|
constructor({
|
1717
|
-
|
1638
|
+
gasPrice,
|
1718
1639
|
maturity,
|
1719
1640
|
maxFee,
|
1720
1641
|
witnessLimit,
|
@@ -1722,7 +1643,7 @@ var BaseTransactionRequest = class {
|
|
1722
1643
|
outputs,
|
1723
1644
|
witnesses
|
1724
1645
|
} = {}) {
|
1725
|
-
this.
|
1646
|
+
this.gasPrice = bn7(gasPrice);
|
1726
1647
|
this.maturity = maturity ?? 0;
|
1727
1648
|
this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
|
1728
1649
|
this.maxFee = maxFee ? bn7(maxFee) : void 0;
|
@@ -1733,9 +1654,9 @@ var BaseTransactionRequest = class {
|
|
1733
1654
|
static getPolicyMeta(req) {
|
1734
1655
|
let policyTypes = 0;
|
1735
1656
|
const policies = [];
|
1736
|
-
if (req.
|
1737
|
-
policyTypes += PolicyType.
|
1738
|
-
policies.push({ data: req.
|
1657
|
+
if (req.gasPrice) {
|
1658
|
+
policyTypes += PolicyType.GasPrice;
|
1659
|
+
policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
|
1739
1660
|
}
|
1740
1661
|
if (req.witnessLimit) {
|
1741
1662
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -1872,7 +1793,7 @@ var BaseTransactionRequest = class {
|
|
1872
1793
|
*/
|
1873
1794
|
getCoinInputs() {
|
1874
1795
|
return this.inputs.filter(
|
1875
|
-
(input) => input.type ===
|
1796
|
+
(input) => input.type === InputType3.Coin
|
1876
1797
|
);
|
1877
1798
|
}
|
1878
1799
|
/**
|
@@ -1904,9 +1825,9 @@ var BaseTransactionRequest = class {
|
|
1904
1825
|
const ownerAddress = addressify(owner);
|
1905
1826
|
const found = this.inputs.find((input) => {
|
1906
1827
|
switch (input.type) {
|
1907
|
-
case
|
1828
|
+
case InputType3.Coin:
|
1908
1829
|
return hexlify7(input.owner) === ownerAddress.toB256();
|
1909
|
-
case
|
1830
|
+
case InputType3.Message:
|
1910
1831
|
return hexlify7(input.recipient) === ownerAddress.toB256();
|
1911
1832
|
default:
|
1912
1833
|
return false;
|
@@ -1923,9 +1844,9 @@ var BaseTransactionRequest = class {
|
|
1923
1844
|
* @param predicateData - Predicate data bytes.
|
1924
1845
|
*/
|
1925
1846
|
addCoinInput(coin) {
|
1926
|
-
const { assetId, owner, amount } = coin;
|
1847
|
+
const { assetId, owner, amount, id, predicate } = coin;
|
1927
1848
|
let witnessIndex;
|
1928
|
-
if (
|
1849
|
+
if (predicate) {
|
1929
1850
|
witnessIndex = 0;
|
1930
1851
|
} else {
|
1931
1852
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -1934,13 +1855,14 @@ var BaseTransactionRequest = class {
|
|
1934
1855
|
}
|
1935
1856
|
}
|
1936
1857
|
const input = {
|
1937
|
-
|
1938
|
-
type:
|
1858
|
+
id,
|
1859
|
+
type: InputType3.Coin,
|
1939
1860
|
owner: owner.toB256(),
|
1940
1861
|
amount,
|
1941
1862
|
assetId,
|
1942
1863
|
txPointer: "0x00000000000000000000000000000000",
|
1943
|
-
witnessIndex
|
1864
|
+
witnessIndex,
|
1865
|
+
predicate
|
1944
1866
|
};
|
1945
1867
|
this.pushInput(input);
|
1946
1868
|
this.addChangeOutput(owner, assetId);
|
@@ -1954,10 +1876,10 @@ var BaseTransactionRequest = class {
|
|
1954
1876
|
* @param predicateData - Predicate data bytes.
|
1955
1877
|
*/
|
1956
1878
|
addMessageInput(message) {
|
1957
|
-
const { recipient, sender, amount } = message;
|
1879
|
+
const { recipient, sender, amount, predicate, nonce } = message;
|
1958
1880
|
const assetId = BaseAssetId2;
|
1959
1881
|
let witnessIndex;
|
1960
|
-
if (
|
1882
|
+
if (predicate) {
|
1961
1883
|
witnessIndex = 0;
|
1962
1884
|
} else {
|
1963
1885
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -1966,12 +1888,13 @@ var BaseTransactionRequest = class {
|
|
1966
1888
|
}
|
1967
1889
|
}
|
1968
1890
|
const input = {
|
1969
|
-
|
1970
|
-
type:
|
1891
|
+
nonce,
|
1892
|
+
type: InputType3.Message,
|
1971
1893
|
sender: sender.toB256(),
|
1972
1894
|
recipient: recipient.toB256(),
|
1973
1895
|
amount,
|
1974
|
-
witnessIndex
|
1896
|
+
witnessIndex,
|
1897
|
+
predicate
|
1975
1898
|
};
|
1976
1899
|
this.pushInput(input);
|
1977
1900
|
this.addChangeOutput(recipient, assetId);
|
@@ -2081,7 +2004,7 @@ var BaseTransactionRequest = class {
|
|
2081
2004
|
}
|
2082
2005
|
calculateMaxGas(chainInfo, minGas) {
|
2083
2006
|
const { consensusParameters } = chainInfo;
|
2084
|
-
const { gasPerByte
|
2007
|
+
const { gasPerByte } = consensusParameters;
|
2085
2008
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2086
2009
|
(acc, wit) => acc + wit.dataLength,
|
2087
2010
|
0
|
@@ -2090,8 +2013,7 @@ var BaseTransactionRequest = class {
|
|
2090
2013
|
gasPerByte,
|
2091
2014
|
minGas,
|
2092
2015
|
witnessesLength,
|
2093
|
-
witnessLimit: this.witnessLimit
|
2094
|
-
maxGasPerTx
|
2016
|
+
witnessLimit: this.witnessLimit
|
2095
2017
|
});
|
2096
2018
|
}
|
2097
2019
|
/**
|
@@ -2109,20 +2031,17 @@ var BaseTransactionRequest = class {
|
|
2109
2031
|
});
|
2110
2032
|
const updateAssetInput = (assetId, quantity) => {
|
2111
2033
|
const assetInput = findAssetInput(assetId);
|
2112
|
-
let usedQuantity = quantity;
|
2113
|
-
if (assetId === BaseAssetId2) {
|
2114
|
-
usedQuantity = bn7("1000000000000000000");
|
2115
|
-
}
|
2116
2034
|
if (assetInput && "assetId" in assetInput) {
|
2117
2035
|
assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
|
2118
|
-
assetInput.amount =
|
2036
|
+
assetInput.amount = quantity;
|
2119
2037
|
} else {
|
2120
2038
|
this.addResources([
|
2121
2039
|
{
|
2122
2040
|
id: hexlify7(randomBytes(UTXO_ID_LEN2)),
|
2123
|
-
amount:
|
2041
|
+
amount: quantity,
|
2124
2042
|
assetId,
|
2125
2043
|
owner: resourcesOwner || Address.fromRandom(),
|
2044
|
+
maturity: 0,
|
2126
2045
|
blockCreated: bn7(1),
|
2127
2046
|
txCreatedIdx: bn7(1)
|
2128
2047
|
}
|
@@ -2154,16 +2073,20 @@ var BaseTransactionRequest = class {
|
|
2154
2073
|
toJSON() {
|
2155
2074
|
return normalizeJSON(this);
|
2156
2075
|
}
|
2157
|
-
|
2076
|
+
removeWitness(index) {
|
2077
|
+
this.witnesses.splice(index, 1);
|
2078
|
+
this.adjustWitnessIndexes(index);
|
2079
|
+
}
|
2080
|
+
updatePredicateInputs(inputs) {
|
2158
2081
|
this.inputs.forEach((i) => {
|
2159
2082
|
let correspondingInput;
|
2160
2083
|
switch (i.type) {
|
2161
|
-
case
|
2162
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2084
|
+
case InputType3.Coin:
|
2085
|
+
correspondingInput = inputs.find((x) => x.type === InputType3.Coin && x.owner === i.owner);
|
2163
2086
|
break;
|
2164
|
-
case
|
2087
|
+
case InputType3.Message:
|
2165
2088
|
correspondingInput = inputs.find(
|
2166
|
-
(x) => x.type ===
|
2089
|
+
(x) => x.type === InputType3.Message && x.sender === i.sender
|
2167
2090
|
);
|
2168
2091
|
break;
|
2169
2092
|
default:
|
@@ -2176,12 +2099,10 @@ var BaseTransactionRequest = class {
|
|
2176
2099
|
}
|
2177
2100
|
});
|
2178
2101
|
}
|
2179
|
-
|
2180
|
-
this.inputs.forEach((input) => {
|
2181
|
-
if (
|
2182
|
-
input.
|
2183
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2184
|
-
);
|
2102
|
+
adjustWitnessIndexes(removedIndex) {
|
2103
|
+
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
2104
|
+
if (input.witnessIndex > removedIndex) {
|
2105
|
+
input.witnessIndex -= 1;
|
2185
2106
|
}
|
2186
2107
|
});
|
2187
2108
|
}
|
@@ -2197,7 +2118,7 @@ import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
|
2197
2118
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2198
2119
|
import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
|
2199
2120
|
import { bn as bn8 } from "@fuel-ts/math";
|
2200
|
-
import { TransactionType as TransactionType2, InputType as
|
2121
|
+
import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
|
2201
2122
|
import { concat as concat2 } from "@fuel-ts/utils";
|
2202
2123
|
import { clone as clone2 } from "ramda";
|
2203
2124
|
function hashTransaction(transactionRequest, chainId) {
|
@@ -2208,7 +2129,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2208
2129
|
transaction.inputs = transaction.inputs.map((input) => {
|
2209
2130
|
const inputClone = clone2(input);
|
2210
2131
|
switch (inputClone.type) {
|
2211
|
-
case
|
2132
|
+
case InputType4.Coin: {
|
2212
2133
|
inputClone.txPointer = {
|
2213
2134
|
blockHeight: 0,
|
2214
2135
|
txIndex: 0
|
@@ -2216,11 +2137,11 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2216
2137
|
inputClone.predicateGasUsed = bn8(0);
|
2217
2138
|
return inputClone;
|
2218
2139
|
}
|
2219
|
-
case
|
2140
|
+
case InputType4.Message: {
|
2220
2141
|
inputClone.predicateGasUsed = bn8(0);
|
2221
2142
|
return inputClone;
|
2222
2143
|
}
|
2223
|
-
case
|
2144
|
+
case InputType4.Contract: {
|
2224
2145
|
inputClone.txPointer = {
|
2225
2146
|
blockHeight: 0,
|
2226
2147
|
txIndex: 0
|
@@ -2331,8 +2252,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2331
2252
|
return {
|
2332
2253
|
type: TransactionType3.Create,
|
2333
2254
|
...baseTransaction,
|
2255
|
+
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2334
2256
|
bytecodeWitnessIndex,
|
2335
|
-
storageSlotsCount:
|
2257
|
+
storageSlotsCount: storageSlots.length,
|
2336
2258
|
salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
|
2337
2259
|
storageSlots
|
2338
2260
|
};
|
@@ -2385,7 +2307,7 @@ import { Interface } from "@fuel-ts/abi-coder";
|
|
2385
2307
|
import { addressify as addressify2 } from "@fuel-ts/address";
|
2386
2308
|
import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
2387
2309
|
import { bn as bn10 } from "@fuel-ts/math";
|
2388
|
-
import { InputType as
|
2310
|
+
import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
2389
2311
|
import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
|
2390
2312
|
|
2391
2313
|
// src/providers/transaction-request/scripts.ts
|
@@ -2455,8 +2377,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2455
2377
|
type: TransactionType4.Script,
|
2456
2378
|
scriptGasLimit: this.gasLimit,
|
2457
2379
|
...super.getBaseTransaction(),
|
2458
|
-
scriptLength:
|
2459
|
-
scriptDataLength:
|
2380
|
+
scriptLength: script.length,
|
2381
|
+
scriptDataLength: scriptData.length,
|
2460
2382
|
receiptsRoot: ZeroBytes327,
|
2461
2383
|
script: hexlify10(script),
|
2462
2384
|
scriptData: hexlify10(scriptData)
|
@@ -2469,7 +2391,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2469
2391
|
*/
|
2470
2392
|
getContractInputs() {
|
2471
2393
|
return this.inputs.filter(
|
2472
|
-
(input) => input.type ===
|
2394
|
+
(input) => input.type === InputType5.Contract
|
2473
2395
|
);
|
2474
2396
|
}
|
2475
2397
|
/**
|
@@ -2520,7 +2442,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2520
2442
|
}
|
2521
2443
|
calculateMaxGas(chainInfo, minGas) {
|
2522
2444
|
const { consensusParameters } = chainInfo;
|
2523
|
-
const { gasPerByte
|
2445
|
+
const { gasPerByte } = consensusParameters;
|
2524
2446
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2525
2447
|
(acc, wit) => acc + wit.dataLength,
|
2526
2448
|
0
|
@@ -2530,8 +2452,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2530
2452
|
minGas,
|
2531
2453
|
witnessesLength,
|
2532
2454
|
witnessLimit: this.witnessLimit,
|
2533
|
-
gasLimit: this.gasLimit
|
2534
|
-
maxGasPerTx
|
2455
|
+
gasLimit: this.gasLimit
|
2535
2456
|
});
|
2536
2457
|
}
|
2537
2458
|
/**
|
@@ -2546,7 +2467,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2546
2467
|
return this;
|
2547
2468
|
}
|
2548
2469
|
const inputIndex = super.pushInput({
|
2549
|
-
type:
|
2470
|
+
type: InputType5.Contract,
|
2550
2471
|
contractId: contractAddress.toB256(),
|
2551
2472
|
txPointer: "0x00000000000000000000000000000000"
|
2552
2473
|
});
|
@@ -2588,7 +2509,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2588
2509
|
|
2589
2510
|
// src/providers/transaction-request/utils.ts
|
2590
2511
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2591
|
-
import { TransactionType as TransactionType5
|
2512
|
+
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2592
2513
|
var transactionRequestify = (obj) => {
|
2593
2514
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2594
2515
|
return obj;
|
@@ -2606,31 +2527,14 @@ var transactionRequestify = (obj) => {
|
|
2606
2527
|
}
|
2607
2528
|
}
|
2608
2529
|
};
|
2609
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2610
|
-
(acc, input) => {
|
2611
|
-
if (input.type === InputType5.Coin && input.owner === owner) {
|
2612
|
-
acc.utxos.push(input.id);
|
2613
|
-
}
|
2614
|
-
if (input.type === InputType5.Message && input.recipient === owner) {
|
2615
|
-
acc.messages.push(input.nonce);
|
2616
|
-
}
|
2617
|
-
return acc;
|
2618
|
-
},
|
2619
|
-
{
|
2620
|
-
utxos: [],
|
2621
|
-
messages: []
|
2622
|
-
}
|
2623
|
-
);
|
2624
2530
|
|
2625
2531
|
// src/providers/transaction-response/transaction-response.ts
|
2626
2532
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2627
|
-
import { bn as
|
2533
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
2628
2534
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2629
2535
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2630
2536
|
|
2631
2537
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2632
|
-
import { bn as bn14 } from "@fuel-ts/math";
|
2633
|
-
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2634
2538
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2635
2539
|
|
2636
2540
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
@@ -2639,10 +2543,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
|
|
2639
2543
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2640
2544
|
var calculateTransactionFee = (params) => {
|
2641
2545
|
const {
|
2642
|
-
|
2546
|
+
gasUsed,
|
2643
2547
|
rawPayload,
|
2644
|
-
|
2645
|
-
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2548
|
+
consensusParameters: { gasCosts, feeParams }
|
2646
2549
|
} = params;
|
2647
2550
|
const gasPerByte = bn11(feeParams.gasPerByte);
|
2648
2551
|
const gasPriceFactor = bn11(feeParams.gasPriceFactor);
|
@@ -2652,7 +2555,8 @@ var calculateTransactionFee = (params) => {
|
|
2652
2555
|
return {
|
2653
2556
|
fee: bn11(0),
|
2654
2557
|
minFee: bn11(0),
|
2655
|
-
maxFee: bn11(0)
|
2558
|
+
maxFee: bn11(0),
|
2559
|
+
feeFromGasUsed: bn11(0)
|
2656
2560
|
};
|
2657
2561
|
}
|
2658
2562
|
const { type, witnesses, inputs, policies } = transaction;
|
@@ -2684,6 +2588,7 @@ var calculateTransactionFee = (params) => {
|
|
2684
2588
|
metadataGas,
|
2685
2589
|
txBytesSize: transactionBytes.length
|
2686
2590
|
});
|
2591
|
+
const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
|
2687
2592
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
|
2688
2593
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2689
2594
|
const maxGas = getMaxGas({
|
@@ -2691,25 +2596,17 @@ var calculateTransactionFee = (params) => {
|
|
2691
2596
|
minGas,
|
2692
2597
|
witnessesLength,
|
2693
2598
|
gasLimit,
|
2694
|
-
witnessLimit
|
2695
|
-
maxGasPerTx
|
2696
|
-
});
|
2697
|
-
const minFee = calculateGasFee({
|
2698
|
-
gasPrice,
|
2699
|
-
gas: minGas,
|
2700
|
-
priceFactor: gasPriceFactor,
|
2701
|
-
tip
|
2702
|
-
});
|
2703
|
-
const maxFee = calculateGasFee({
|
2704
|
-
gasPrice,
|
2705
|
-
gas: maxGas,
|
2706
|
-
priceFactor: gasPriceFactor,
|
2707
|
-
tip
|
2599
|
+
witnessLimit
|
2708
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);
|
2709
2605
|
return {
|
2606
|
+
fee,
|
2710
2607
|
minFee,
|
2711
2608
|
maxFee,
|
2712
|
-
|
2609
|
+
feeFromGasUsed
|
2713
2610
|
};
|
2714
2611
|
};
|
2715
2612
|
|
@@ -3276,9 +3173,7 @@ function assembleTransactionSummary(params) {
|
|
3276
3173
|
gqlTransactionStatus,
|
3277
3174
|
abiMap = {},
|
3278
3175
|
maxInputs,
|
3279
|
-
gasCosts
|
3280
|
-
maxGasPerTx,
|
3281
|
-
gasPrice
|
3176
|
+
gasCosts
|
3282
3177
|
} = params;
|
3283
3178
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3284
3179
|
const rawPayload = hexlify11(transactionBytes);
|
@@ -3292,14 +3187,11 @@ function assembleTransactionSummary(params) {
|
|
3292
3187
|
maxInputs
|
3293
3188
|
});
|
3294
3189
|
const typeName = getTransactionTypeName(transaction.type);
|
3295
|
-
const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3296
3190
|
const { fee } = calculateTransactionFee({
|
3297
|
-
|
3191
|
+
gasUsed,
|
3298
3192
|
rawPayload,
|
3299
|
-
tip,
|
3300
3193
|
consensusParameters: {
|
3301
3194
|
gasCosts,
|
3302
|
-
maxGasPerTx,
|
3303
3195
|
feeParams: {
|
3304
3196
|
gasPerByte,
|
3305
3197
|
gasPriceFactor
|
@@ -3359,7 +3251,7 @@ var TransactionResponse = class {
|
|
3359
3251
|
/** Current provider */
|
3360
3252
|
provider;
|
3361
3253
|
/** Gas used on the transaction */
|
3362
|
-
gasUsed =
|
3254
|
+
gasUsed = bn14(0);
|
3363
3255
|
/** The graphql Transaction with receipts object. */
|
3364
3256
|
gqlTransaction;
|
3365
3257
|
abis;
|
@@ -3437,13 +3329,8 @@ var TransactionResponse = class {
|
|
3437
3329
|
const decodedTransaction = this.decodeTransaction(
|
3438
3330
|
transaction
|
3439
3331
|
);
|
3440
|
-
|
3441
|
-
|
3442
|
-
txReceipts = transaction.status.receipts;
|
3443
|
-
}
|
3444
|
-
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3445
|
-
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3446
|
-
const gasPrice = await this.provider.getLatestGasPrice();
|
3332
|
+
const receipts = transaction.receipts?.map(processGqlReceipt) || [];
|
3333
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
|
3447
3334
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3448
3335
|
const transactionSummary = assembleTransactionSummary({
|
3449
3336
|
id: this.id,
|
@@ -3455,9 +3342,7 @@ var TransactionResponse = class {
|
|
3455
3342
|
gasPriceFactor,
|
3456
3343
|
abiMap: contractsAbiMap,
|
3457
3344
|
maxInputs,
|
3458
|
-
gasCosts
|
3459
|
-
maxGasPerTx,
|
3460
|
-
gasPrice
|
3345
|
+
gasCosts
|
3461
3346
|
});
|
3462
3347
|
return transactionSummary;
|
3463
3348
|
}
|
@@ -3584,29 +3469,29 @@ var processGqlChain = (chain) => {
|
|
3584
3469
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3585
3470
|
return {
|
3586
3471
|
name,
|
3587
|
-
baseChainHeight:
|
3472
|
+
baseChainHeight: bn15(daHeight),
|
3588
3473
|
consensusParameters: {
|
3589
|
-
contractMaxSize:
|
3590
|
-
maxInputs:
|
3591
|
-
maxOutputs:
|
3592
|
-
maxWitnesses:
|
3593
|
-
maxGasPerTx:
|
3594
|
-
maxScriptLength:
|
3595
|
-
maxScriptDataLength:
|
3596
|
-
maxStorageSlots:
|
3597
|
-
maxPredicateLength:
|
3598
|
-
maxPredicateDataLength:
|
3599
|
-
maxGasPerPredicate:
|
3600
|
-
gasPriceFactor:
|
3601
|
-
gasPerByte:
|
3602
|
-
maxMessageDataLength:
|
3603
|
-
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),
|
3604
3489
|
gasCosts
|
3605
3490
|
},
|
3606
3491
|
gasCosts,
|
3607
3492
|
latestBlock: {
|
3608
3493
|
id: latestBlock.id,
|
3609
|
-
height:
|
3494
|
+
height: bn15(latestBlock.header.height),
|
3610
3495
|
time: latestBlock.header.time,
|
3611
3496
|
transactions: latestBlock.transactions.map((i) => ({
|
3612
3497
|
id: i.id
|
@@ -3700,8 +3585,10 @@ var _Provider = class {
|
|
3700
3585
|
* Returns some helpful parameters related to gas fees.
|
3701
3586
|
*/
|
3702
3587
|
getGasConfig() {
|
3588
|
+
const { minGasPrice } = this.getNode();
|
3703
3589
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3704
3590
|
return {
|
3591
|
+
minGasPrice,
|
3705
3592
|
maxGasPerTx,
|
3706
3593
|
maxGasPerPredicate,
|
3707
3594
|
gasPriceFactor,
|
@@ -3799,7 +3686,7 @@ var _Provider = class {
|
|
3799
3686
|
*/
|
3800
3687
|
async getBlockNumber() {
|
3801
3688
|
const { chain } = await this.operations.getChain();
|
3802
|
-
return
|
3689
|
+
return bn15(chain.latestBlock.header.height, 10);
|
3803
3690
|
}
|
3804
3691
|
/**
|
3805
3692
|
* Returns the chain information.
|
@@ -3809,11 +3696,13 @@ var _Provider = class {
|
|
3809
3696
|
async fetchNode() {
|
3810
3697
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3811
3698
|
const processedNodeInfo = {
|
3812
|
-
maxDepth:
|
3813
|
-
maxTx:
|
3699
|
+
maxDepth: bn15(nodeInfo.maxDepth),
|
3700
|
+
maxTx: bn15(nodeInfo.maxTx),
|
3701
|
+
minGasPrice: bn15(nodeInfo.minGasPrice),
|
3814
3702
|
nodeVersion: nodeInfo.nodeVersion,
|
3815
3703
|
utxoValidation: nodeInfo.utxoValidation,
|
3816
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
3704
|
+
vmBacktrace: nodeInfo.vmBacktrace,
|
3705
|
+
peers: nodeInfo.peers
|
3817
3706
|
};
|
3818
3707
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
3819
3708
|
return processedNodeInfo;
|
@@ -3899,13 +3788,14 @@ var _Provider = class {
|
|
3899
3788
|
return this.estimateTxDependencies(transactionRequest);
|
3900
3789
|
}
|
3901
3790
|
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
3902
|
-
const { dryRun:
|
3903
|
-
|
3791
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3792
|
+
encodedTransaction,
|
3904
3793
|
utxoValidation: utxoValidation || false
|
3905
3794
|
});
|
3906
|
-
const
|
3907
|
-
|
3908
|
-
|
3795
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
3796
|
+
return {
|
3797
|
+
receipts
|
3798
|
+
};
|
3909
3799
|
}
|
3910
3800
|
/**
|
3911
3801
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -3931,7 +3821,7 @@ var _Provider = class {
|
|
3931
3821
|
} = response;
|
3932
3822
|
if (inputs) {
|
3933
3823
|
inputs.forEach((input, index) => {
|
3934
|
-
if ("predicateGasUsed" in input &&
|
3824
|
+
if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
|
3935
3825
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3936
3826
|
}
|
3937
3827
|
});
|
@@ -3944,6 +3834,9 @@ var _Provider = class {
|
|
3944
3834
|
* If there are missing variable outputs,
|
3945
3835
|
* `addVariableOutputs` is called on the transaction.
|
3946
3836
|
*
|
3837
|
+
* @privateRemarks
|
3838
|
+
* TODO: Investigate support for missing contract IDs
|
3839
|
+
* TODO: Add support for missing output messages
|
3947
3840
|
*
|
3948
3841
|
* @param transactionRequest - The transaction request object.
|
3949
3842
|
* @returns A promise.
|
@@ -3956,19 +3849,16 @@ var _Provider = class {
|
|
3956
3849
|
missingContractIds: []
|
3957
3850
|
};
|
3958
3851
|
}
|
3852
|
+
await this.estimatePredicates(transactionRequest);
|
3959
3853
|
let receipts = [];
|
3960
3854
|
const missingContractIds = [];
|
3961
3855
|
let outputVariables = 0;
|
3962
|
-
let dryrunStatus;
|
3963
3856
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3964
|
-
const {
|
3965
|
-
|
3966
|
-
} = await this.operations.dryRun({
|
3967
|
-
encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
|
3857
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3858
|
+
encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
|
3968
3859
|
utxoValidation: false
|
3969
3860
|
});
|
3970
|
-
receipts =
|
3971
|
-
dryrunStatus = status;
|
3861
|
+
receipts = gqlReceipts.map(processGqlReceipt);
|
3972
3862
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
3973
3863
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
3974
3864
|
if (hasMissingOutputs) {
|
@@ -3978,10 +3868,6 @@ var _Provider = class {
|
|
3978
3868
|
transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
|
3979
3869
|
missingContractIds.push(contractId);
|
3980
3870
|
});
|
3981
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
3982
|
-
transactionRequest
|
3983
|
-
});
|
3984
|
-
transactionRequest.maxFee = maxFee;
|
3985
3871
|
} else {
|
3986
3872
|
break;
|
3987
3873
|
}
|
@@ -3989,139 +3875,37 @@ var _Provider = class {
|
|
3989
3875
|
return {
|
3990
3876
|
receipts,
|
3991
3877
|
outputVariables,
|
3992
|
-
missingContractIds
|
3993
|
-
dryrunStatus
|
3878
|
+
missingContractIds
|
3994
3879
|
};
|
3995
3880
|
}
|
3996
|
-
/**
|
3997
|
-
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
3998
|
-
*
|
3999
|
-
* Transactions are dry run in batches. After each dry run, transactions requiring
|
4000
|
-
* further modifications are identified. The method iteratively updates these transactions
|
4001
|
-
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
4002
|
-
*
|
4003
|
-
* @param transactionRequests - Array of transaction request objects.
|
4004
|
-
* @returns A promise that resolves to an array of results for each transaction.
|
4005
|
-
*/
|
4006
|
-
async estimateMultipleTxDependencies(transactionRequests) {
|
4007
|
-
const results = transactionRequests.map(() => ({
|
4008
|
-
receipts: [],
|
4009
|
-
outputVariables: 0,
|
4010
|
-
missingContractIds: [],
|
4011
|
-
dryrunStatus: void 0
|
4012
|
-
}));
|
4013
|
-
const allRequests = clone3(transactionRequests);
|
4014
|
-
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4015
|
-
allRequests.forEach((req, index) => {
|
4016
|
-
if (req.type === TransactionType8.Script) {
|
4017
|
-
serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
|
4018
|
-
}
|
4019
|
-
});
|
4020
|
-
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
4021
|
-
let attempt = 0;
|
4022
|
-
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
4023
|
-
const encodedTransactions = transactionsToProcess.map(
|
4024
|
-
(index) => serializedTransactionsMap.get(index)
|
4025
|
-
);
|
4026
|
-
const dryRunResults = await this.operations.dryRun({
|
4027
|
-
encodedTransactions,
|
4028
|
-
utxoValidation: false
|
4029
|
-
});
|
4030
|
-
const nextRoundTransactions = [];
|
4031
|
-
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
4032
|
-
const currentResultIndex = transactionsToProcess[i];
|
4033
|
-
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4034
|
-
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
4035
|
-
results[currentResultIndex].dryrunStatus = status;
|
4036
|
-
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4037
|
-
results[currentResultIndex].receipts
|
4038
|
-
);
|
4039
|
-
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4040
|
-
const requestToProcess = allRequests[currentResultIndex];
|
4041
|
-
if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
|
4042
|
-
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
4043
|
-
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
4044
|
-
missingOutputContractIds.forEach(({ contractId }) => {
|
4045
|
-
requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
|
4046
|
-
results[currentResultIndex].missingContractIds.push(contractId);
|
4047
|
-
});
|
4048
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
4049
|
-
transactionRequest: requestToProcess
|
4050
|
-
});
|
4051
|
-
requestToProcess.maxFee = maxFee;
|
4052
|
-
serializedTransactionsMap.set(
|
4053
|
-
currentResultIndex,
|
4054
|
-
hexlify12(requestToProcess.toTransactionBytes())
|
4055
|
-
);
|
4056
|
-
nextRoundTransactions.push(currentResultIndex);
|
4057
|
-
allRequests[currentResultIndex] = requestToProcess;
|
4058
|
-
}
|
4059
|
-
}
|
4060
|
-
transactionsToProcess = nextRoundTransactions;
|
4061
|
-
attempt += 1;
|
4062
|
-
}
|
4063
|
-
return results;
|
4064
|
-
}
|
4065
|
-
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
4066
|
-
if (estimateTxDependencies) {
|
4067
|
-
return this.estimateMultipleTxDependencies(transactionRequests);
|
4068
|
-
}
|
4069
|
-
const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
|
4070
|
-
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4071
|
-
encodedTransactions,
|
4072
|
-
utxoValidation: utxoValidation || false
|
4073
|
-
});
|
4074
|
-
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4075
|
-
const receipts = rawReceipts.map(processGqlReceipt);
|
4076
|
-
return { receipts, dryrunStatus: status };
|
4077
|
-
});
|
4078
|
-
return results;
|
4079
|
-
}
|
4080
3881
|
/**
|
4081
3882
|
* Estimates the transaction gas and fee based on the provided transaction request.
|
4082
3883
|
* @param transactionRequest - The transaction request object.
|
4083
3884
|
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
4084
3885
|
*/
|
4085
|
-
|
3886
|
+
estimateTxGasAndFee(params) {
|
4086
3887
|
const { transactionRequest } = params;
|
4087
|
-
|
3888
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
4088
3889
|
const chainInfo = this.getChain();
|
4089
|
-
const
|
3890
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
3891
|
+
transactionRequest.gasPrice = gasPrice;
|
4090
3892
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
4091
|
-
|
4092
|
-
gasPrice = await this.estimateGasPrice(10);
|
4093
|
-
}
|
4094
|
-
const minFee = calculateGasFee({
|
4095
|
-
gasPrice: bn16(gasPrice),
|
4096
|
-
gas: minGas,
|
4097
|
-
priceFactor: gasPriceFactor,
|
4098
|
-
tip: transactionRequest.tip
|
4099
|
-
}).add(1);
|
4100
|
-
let gasLimit = bn16(0);
|
3893
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4101
3894
|
if (transactionRequest.type === TransactionType8.Script) {
|
4102
|
-
gasLimit = transactionRequest.gasLimit;
|
4103
3895
|
if (transactionRequest.gasLimit.eq(0)) {
|
4104
3896
|
transactionRequest.gasLimit = minGas;
|
4105
3897
|
transactionRequest.gasLimit = maxGasPerTx.sub(
|
4106
3898
|
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
4107
3899
|
);
|
4108
|
-
gasLimit = transactionRequest.gasLimit;
|
4109
3900
|
}
|
4110
3901
|
}
|
4111
3902
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4112
|
-
const maxFee =
|
4113
|
-
gasPrice: bn16(gasPrice),
|
4114
|
-
gas: maxGas,
|
4115
|
-
priceFactor: gasPriceFactor,
|
4116
|
-
tip: transactionRequest.tip
|
4117
|
-
}).add(1);
|
3903
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4118
3904
|
return {
|
4119
3905
|
minGas,
|
4120
3906
|
minFee,
|
4121
3907
|
maxGas,
|
4122
|
-
maxFee
|
4123
|
-
gasPrice,
|
4124
|
-
gasLimit
|
3908
|
+
maxFee
|
4125
3909
|
};
|
4126
3910
|
}
|
4127
3911
|
/**
|
@@ -4139,17 +3923,15 @@ var _Provider = class {
|
|
4139
3923
|
if (estimateTxDependencies) {
|
4140
3924
|
return this.estimateTxDependencies(transactionRequest);
|
4141
3925
|
}
|
4142
|
-
const
|
4143
|
-
const { dryRun:
|
4144
|
-
|
3926
|
+
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
3927
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3928
|
+
encodedTransaction,
|
4145
3929
|
utxoValidation: true
|
4146
3930
|
});
|
4147
|
-
const
|
4148
|
-
|
4149
|
-
|
4150
|
-
|
4151
|
-
});
|
4152
|
-
return { receipts: callResult[0].receipts };
|
3931
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
3932
|
+
return {
|
3933
|
+
receipts
|
3934
|
+
};
|
4153
3935
|
}
|
4154
3936
|
/**
|
4155
3937
|
* Returns a transaction cost to enable user
|
@@ -4166,79 +3948,77 @@ var _Provider = class {
|
|
4166
3948
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
4167
3949
|
* @returns A promise that resolves to the transaction cost object.
|
4168
3950
|
*/
|
4169
|
-
async getTransactionCost(transactionRequestLike,
|
3951
|
+
async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
|
3952
|
+
estimateTxDependencies = true,
|
3953
|
+
estimatePredicates = true,
|
3954
|
+
resourcesOwner,
|
3955
|
+
signatureCallback
|
3956
|
+
} = {}) {
|
4170
3957
|
const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
|
3958
|
+
const { minGasPrice } = this.getGasConfig();
|
3959
|
+
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
4171
3960
|
const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
|
4172
3961
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4173
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
3962
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
4174
3963
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
4175
|
-
txRequestClone.maxFee = bn16(0);
|
4176
3964
|
if (isScriptTransaction) {
|
4177
|
-
txRequestClone.gasLimit =
|
3965
|
+
txRequestClone.gasLimit = bn15(0);
|
4178
3966
|
}
|
4179
|
-
if (
|
4180
|
-
resourcesOwner
|
3967
|
+
if (estimatePredicates) {
|
3968
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
3969
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
3970
|
+
}
|
3971
|
+
await this.estimatePredicates(txRequestClone);
|
4181
3972
|
}
|
4182
|
-
const signedRequest = clone3(txRequestClone);
|
4183
|
-
let addedSignatures = 0;
|
4184
3973
|
if (signatureCallback && isScriptTransaction) {
|
4185
|
-
|
4186
|
-
await signatureCallback(signedRequest);
|
4187
|
-
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
3974
|
+
await signatureCallback(txRequestClone);
|
4188
3975
|
}
|
4189
|
-
|
4190
|
-
|
4191
|
-
transactionRequest: signedRequest
|
3976
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
3977
|
+
transactionRequest: txRequestClone
|
4192
3978
|
});
|
4193
3979
|
let receipts = [];
|
4194
3980
|
let missingContractIds = [];
|
4195
3981
|
let outputVariables = 0;
|
4196
|
-
let gasUsed =
|
4197
|
-
|
4198
|
-
|
4199
|
-
if (isScriptTransaction) {
|
4200
|
-
txRequestClone.gasLimit = gasLimit;
|
4201
|
-
if (signatureCallback) {
|
4202
|
-
await signatureCallback(txRequestClone);
|
4203
|
-
}
|
3982
|
+
let gasUsed = bn15(0);
|
3983
|
+
if (isScriptTransaction && estimateTxDependencies) {
|
3984
|
+
txRequestClone.gasPrice = bn15(0);
|
4204
3985
|
const result = await this.estimateTxDependencies(txRequestClone);
|
4205
3986
|
receipts = result.receipts;
|
4206
3987
|
outputVariables = result.outputVariables;
|
4207
3988
|
missingContractIds = result.missingContractIds;
|
4208
3989
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4209
3990
|
txRequestClone.gasLimit = gasUsed;
|
4210
|
-
|
4211
|
-
|
4212
|
-
|
3991
|
+
txRequestClone.gasPrice = setGasPrice;
|
3992
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
3993
|
+
transactionRequest: txRequestClone
|
4213
3994
|
}));
|
4214
3995
|
}
|
4215
3996
|
return {
|
4216
3997
|
requiredQuantities: allQuantities,
|
4217
3998
|
receipts,
|
4218
3999
|
gasUsed,
|
4219
|
-
|
4000
|
+
minGasPrice,
|
4001
|
+
gasPrice: setGasPrice,
|
4220
4002
|
minGas,
|
4221
4003
|
maxGas,
|
4222
4004
|
minFee,
|
4223
4005
|
maxFee,
|
4006
|
+
estimatedInputs: txRequestClone.inputs,
|
4224
4007
|
outputVariables,
|
4225
|
-
missingContractIds
|
4226
|
-
addedSignatures,
|
4227
|
-
estimatedPredicates: txRequestClone.inputs
|
4008
|
+
missingContractIds
|
4228
4009
|
};
|
4229
4010
|
}
|
4230
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
4011
|
+
async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
|
4231
4012
|
const ownerAddress = Address2.fromAddressOrString(owner);
|
4232
4013
|
const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
|
4233
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
4234
|
-
quantitiesToContract
|
4235
|
-
});
|
4014
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
|
4236
4015
|
transactionRequest.addResources(
|
4237
4016
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
4238
4017
|
);
|
4239
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4240
|
-
|
4241
|
-
|
4018
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4019
|
+
transactionRequest,
|
4020
|
+
forwardingQuantities
|
4021
|
+
);
|
4242
4022
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
4243
4023
|
return {
|
4244
4024
|
resources,
|
@@ -4260,10 +4040,11 @@ var _Provider = class {
|
|
4260
4040
|
return coins.map((coin) => ({
|
4261
4041
|
id: coin.utxoId,
|
4262
4042
|
assetId: coin.assetId,
|
4263
|
-
amount:
|
4043
|
+
amount: bn15(coin.amount),
|
4264
4044
|
owner: Address2.fromAddressOrString(coin.owner),
|
4265
|
-
|
4266
|
-
|
4045
|
+
maturity: bn15(coin.maturity).toNumber(),
|
4046
|
+
blockCreated: bn15(coin.blockCreated),
|
4047
|
+
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4267
4048
|
}));
|
4268
4049
|
}
|
4269
4050
|
/**
|
@@ -4300,9 +4081,9 @@ var _Provider = class {
|
|
4300
4081
|
switch (coin.__typename) {
|
4301
4082
|
case "MessageCoin":
|
4302
4083
|
return {
|
4303
|
-
amount:
|
4084
|
+
amount: bn15(coin.amount),
|
4304
4085
|
assetId: coin.assetId,
|
4305
|
-
daHeight:
|
4086
|
+
daHeight: bn15(coin.daHeight),
|
4306
4087
|
sender: Address2.fromAddressOrString(coin.sender),
|
4307
4088
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4308
4089
|
nonce: coin.nonce
|
@@ -4310,11 +4091,12 @@ var _Provider = class {
|
|
4310
4091
|
case "Coin":
|
4311
4092
|
return {
|
4312
4093
|
id: coin.utxoId,
|
4313
|
-
amount:
|
4094
|
+
amount: bn15(coin.amount),
|
4314
4095
|
assetId: coin.assetId,
|
4315
4096
|
owner: Address2.fromAddressOrString(coin.owner),
|
4316
|
-
|
4317
|
-
|
4097
|
+
maturity: bn15(coin.maturity).toNumber(),
|
4098
|
+
blockCreated: bn15(coin.blockCreated),
|
4099
|
+
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4318
4100
|
};
|
4319
4101
|
default:
|
4320
4102
|
return null;
|
@@ -4331,13 +4113,13 @@ var _Provider = class {
|
|
4331
4113
|
async getBlock(idOrHeight) {
|
4332
4114
|
let variables;
|
4333
4115
|
if (typeof idOrHeight === "number") {
|
4334
|
-
variables = { height:
|
4116
|
+
variables = { height: bn15(idOrHeight).toString(10) };
|
4335
4117
|
} else if (idOrHeight === "latest") {
|
4336
4118
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4337
4119
|
} else if (idOrHeight.length === 66) {
|
4338
4120
|
variables = { blockId: idOrHeight };
|
4339
4121
|
} else {
|
4340
|
-
variables = { blockId:
|
4122
|
+
variables = { blockId: bn15(idOrHeight).toString(10) };
|
4341
4123
|
}
|
4342
4124
|
const { block } = await this.operations.getBlock(variables);
|
4343
4125
|
if (!block) {
|
@@ -4345,7 +4127,7 @@ var _Provider = class {
|
|
4345
4127
|
}
|
4346
4128
|
return {
|
4347
4129
|
id: block.id,
|
4348
|
-
height:
|
4130
|
+
height: bn15(block.header.height),
|
4349
4131
|
time: block.header.time,
|
4350
4132
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4351
4133
|
};
|
@@ -4360,7 +4142,7 @@ var _Provider = class {
|
|
4360
4142
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4361
4143
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4362
4144
|
id: block.id,
|
4363
|
-
height:
|
4145
|
+
height: bn15(block.header.height),
|
4364
4146
|
time: block.header.time,
|
4365
4147
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4366
4148
|
}));
|
@@ -4375,7 +4157,7 @@ var _Provider = class {
|
|
4375
4157
|
async getBlockWithTransactions(idOrHeight) {
|
4376
4158
|
let variables;
|
4377
4159
|
if (typeof idOrHeight === "number") {
|
4378
|
-
variables = { blockHeight:
|
4160
|
+
variables = { blockHeight: bn15(idOrHeight).toString(10) };
|
4379
4161
|
} else if (idOrHeight === "latest") {
|
4380
4162
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4381
4163
|
} else {
|
@@ -4387,7 +4169,7 @@ var _Provider = class {
|
|
4387
4169
|
}
|
4388
4170
|
return {
|
4389
4171
|
id: block.id,
|
4390
|
-
height:
|
4172
|
+
height: bn15(block.header.height, 10),
|
4391
4173
|
time: block.header.time,
|
4392
4174
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4393
4175
|
transactions: block.transactions.map(
|
@@ -4436,7 +4218,7 @@ var _Provider = class {
|
|
4436
4218
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4437
4219
|
asset: hexlify12(assetId)
|
4438
4220
|
});
|
4439
|
-
return
|
4221
|
+
return bn15(contractBalance.amount, 10);
|
4440
4222
|
}
|
4441
4223
|
/**
|
4442
4224
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4450,7 +4232,7 @@ var _Provider = class {
|
|
4450
4232
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4451
4233
|
assetId: hexlify12(assetId)
|
4452
4234
|
});
|
4453
|
-
return
|
4235
|
+
return bn15(balance.amount, 10);
|
4454
4236
|
}
|
4455
4237
|
/**
|
4456
4238
|
* Returns balances for the given owner.
|
@@ -4468,7 +4250,7 @@ var _Provider = class {
|
|
4468
4250
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4469
4251
|
return balances.map((balance) => ({
|
4470
4252
|
assetId: balance.assetId,
|
4471
|
-
amount:
|
4253
|
+
amount: bn15(balance.amount)
|
4472
4254
|
}));
|
4473
4255
|
}
|
4474
4256
|
/**
|
@@ -4490,15 +4272,15 @@ var _Provider = class {
|
|
4490
4272
|
sender: message.sender,
|
4491
4273
|
recipient: message.recipient,
|
4492
4274
|
nonce: message.nonce,
|
4493
|
-
amount:
|
4275
|
+
amount: bn15(message.amount),
|
4494
4276
|
data: message.data
|
4495
4277
|
}),
|
4496
4278
|
sender: Address2.fromAddressOrString(message.sender),
|
4497
4279
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4498
4280
|
nonce: message.nonce,
|
4499
|
-
amount:
|
4281
|
+
amount: bn15(message.amount),
|
4500
4282
|
data: InputMessageCoder.decodeData(message.data),
|
4501
|
-
daHeight:
|
4283
|
+
daHeight: bn15(message.daHeight)
|
4502
4284
|
}));
|
4503
4285
|
}
|
4504
4286
|
/**
|
@@ -4551,60 +4333,44 @@ var _Provider = class {
|
|
4551
4333
|
} = result.messageProof;
|
4552
4334
|
return {
|
4553
4335
|
messageProof: {
|
4554
|
-
proofIndex:
|
4336
|
+
proofIndex: bn15(messageProof.proofIndex),
|
4555
4337
|
proofSet: messageProof.proofSet
|
4556
4338
|
},
|
4557
4339
|
blockProof: {
|
4558
|
-
proofIndex:
|
4340
|
+
proofIndex: bn15(blockProof.proofIndex),
|
4559
4341
|
proofSet: blockProof.proofSet
|
4560
4342
|
},
|
4561
4343
|
messageBlockHeader: {
|
4562
4344
|
id: messageBlockHeader.id,
|
4563
|
-
daHeight:
|
4564
|
-
transactionsCount:
|
4345
|
+
daHeight: bn15(messageBlockHeader.daHeight),
|
4346
|
+
transactionsCount: bn15(messageBlockHeader.transactionsCount),
|
4565
4347
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4566
|
-
height:
|
4348
|
+
height: bn15(messageBlockHeader.height),
|
4567
4349
|
prevRoot: messageBlockHeader.prevRoot,
|
4568
4350
|
time: messageBlockHeader.time,
|
4569
4351
|
applicationHash: messageBlockHeader.applicationHash,
|
4570
|
-
|
4571
|
-
|
4572
|
-
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4573
|
-
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4574
|
-
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4352
|
+
messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
|
4353
|
+
messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
|
4575
4354
|
},
|
4576
4355
|
commitBlockHeader: {
|
4577
4356
|
id: commitBlockHeader.id,
|
4578
|
-
daHeight:
|
4579
|
-
transactionsCount:
|
4357
|
+
daHeight: bn15(commitBlockHeader.daHeight),
|
4358
|
+
transactionsCount: bn15(commitBlockHeader.transactionsCount),
|
4580
4359
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4581
|
-
height:
|
4360
|
+
height: bn15(commitBlockHeader.height),
|
4582
4361
|
prevRoot: commitBlockHeader.prevRoot,
|
4583
4362
|
time: commitBlockHeader.time,
|
4584
4363
|
applicationHash: commitBlockHeader.applicationHash,
|
4585
|
-
|
4586
|
-
|
4587
|
-
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4588
|
-
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4589
|
-
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4364
|
+
messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
|
4365
|
+
messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
|
4590
4366
|
},
|
4591
4367
|
sender: Address2.fromAddressOrString(sender),
|
4592
4368
|
recipient: Address2.fromAddressOrString(recipient),
|
4593
4369
|
nonce,
|
4594
|
-
amount:
|
4370
|
+
amount: bn15(amount),
|
4595
4371
|
data
|
4596
4372
|
};
|
4597
4373
|
}
|
4598
|
-
async getLatestGasPrice() {
|
4599
|
-
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4600
|
-
return bn16(latestGasPrice.gasPrice);
|
4601
|
-
}
|
4602
|
-
async estimateGasPrice(blockHorizon) {
|
4603
|
-
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4604
|
-
blockHorizon: String(blockHorizon)
|
4605
|
-
});
|
4606
|
-
return bn16(estimateGasPrice.gasPrice);
|
4607
|
-
}
|
4608
4374
|
/**
|
4609
4375
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
4610
4376
|
*
|
@@ -4624,10 +4390,10 @@ var _Provider = class {
|
|
4624
4390
|
*/
|
4625
4391
|
async produceBlocks(amount, startTime) {
|
4626
4392
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4627
|
-
blocksToProduce:
|
4393
|
+
blocksToProduce: bn15(amount).toString(10),
|
4628
4394
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4629
4395
|
});
|
4630
|
-
return
|
4396
|
+
return bn15(latestBlockHeight);
|
4631
4397
|
}
|
4632
4398
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4633
4399
|
async getTransactionResponse(transactionId) {
|
@@ -4651,7 +4417,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4651
4417
|
|
4652
4418
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4653
4419
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4654
|
-
import { bn as
|
4420
|
+
import { bn as bn16 } from "@fuel-ts/math";
|
4655
4421
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4656
4422
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4657
4423
|
|
@@ -4897,33 +4663,36 @@ var Account = class extends AbstractAccount {
|
|
4897
4663
|
* @param fee - The estimated transaction fee.
|
4898
4664
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4899
4665
|
*/
|
4900
|
-
async fund(request,
|
4901
|
-
const
|
4902
|
-
|
4903
|
-
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
4904
|
-
amount: bn18(fee),
|
4666
|
+
async fund(request, coinQuantities, fee) {
|
4667
|
+
const updatedQuantities = addAmountToAsset({
|
4668
|
+
amount: bn17(fee),
|
4905
4669
|
assetId: BaseAssetId3,
|
4906
|
-
coinQuantities
|
4670
|
+
coinQuantities
|
4907
4671
|
});
|
4908
4672
|
const quantitiesDict = {};
|
4909
|
-
|
4673
|
+
updatedQuantities.forEach(({ amount, assetId }) => {
|
4910
4674
|
quantitiesDict[assetId] = {
|
4911
4675
|
required: amount,
|
4912
|
-
owned:
|
4676
|
+
owned: bn17(0)
|
4913
4677
|
};
|
4914
4678
|
});
|
4915
|
-
|
4679
|
+
const cachedUtxos = [];
|
4680
|
+
const cachedMessages = [];
|
4681
|
+
const owner = this.address.toB256();
|
4682
|
+
request.inputs.forEach((input) => {
|
4916
4683
|
const isResource = "amount" in input;
|
4917
4684
|
if (isResource) {
|
4918
4685
|
const isCoin2 = "owner" in input;
|
4919
4686
|
if (isCoin2) {
|
4920
4687
|
const assetId = String(input.assetId);
|
4921
|
-
if (quantitiesDict[assetId]) {
|
4922
|
-
const amount =
|
4688
|
+
if (input.owner === owner && quantitiesDict[assetId]) {
|
4689
|
+
const amount = bn17(input.amount);
|
4923
4690
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4691
|
+
cachedUtxos.push(input.id);
|
4924
4692
|
}
|
4925
|
-
} else if (input.amount && quantitiesDict[BaseAssetId3]) {
|
4693
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
|
4926
4694
|
quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
|
4695
|
+
cachedMessages.push(input.nonce);
|
4927
4696
|
}
|
4928
4697
|
}
|
4929
4698
|
});
|
@@ -4938,23 +4707,12 @@ var Account = class extends AbstractAccount {
|
|
4938
4707
|
});
|
4939
4708
|
const needsToBeFunded = missingQuantities.length;
|
4940
4709
|
if (needsToBeFunded) {
|
4941
|
-
const
|
4942
|
-
|
4943
|
-
|
4944
|
-
|
4945
|
-
|
4946
|
-
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
4947
|
-
const requestToBeReEstimate = clone4(txRequest);
|
4948
|
-
if (addedSignatures) {
|
4949
|
-
Array.from({ length: addedSignatures }).forEach(
|
4950
|
-
() => requestToBeReEstimate.addEmptyWitness()
|
4951
|
-
);
|
4710
|
+
const resources = await this.getResourcesToSpend(missingQuantities, {
|
4711
|
+
messages: cachedMessages,
|
4712
|
+
utxos: cachedUtxos
|
4713
|
+
});
|
4714
|
+
request.addResources(resources);
|
4952
4715
|
}
|
4953
|
-
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
4954
|
-
transactionRequest: requestToBeReEstimate
|
4955
|
-
});
|
4956
|
-
txRequest.maxFee = maxFee;
|
4957
|
-
return txRequest;
|
4958
4716
|
}
|
4959
4717
|
/**
|
4960
4718
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -4962,25 +4720,28 @@ var Account = class extends AbstractAccount {
|
|
4962
4720
|
* @param destination - The address of the destination.
|
4963
4721
|
* @param amount - The amount of coins to transfer.
|
4964
4722
|
* @param assetId - The asset ID of the coins to transfer.
|
4965
|
-
* @param txParams - The transaction parameters (gasLimit,
|
4723
|
+
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4966
4724
|
* @returns A promise that resolves to the prepared transaction request.
|
4967
4725
|
*/
|
4968
4726
|
async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
4969
|
-
const
|
4727
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
4728
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
4729
|
+
const request = new ScriptTransactionRequest(params);
|
4970
4730
|
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
|
4971
|
-
const
|
4731
|
+
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
4972
4732
|
estimateTxDependencies: true,
|
4973
4733
|
resourcesOwner: this
|
4974
4734
|
});
|
4975
|
-
|
4976
|
-
|
4977
|
-
|
4978
|
-
|
4979
|
-
|
4980
|
-
|
4981
|
-
|
4982
|
-
|
4983
|
-
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);
|
4984
4745
|
return request;
|
4985
4746
|
}
|
4986
4747
|
/**
|
@@ -4993,7 +4754,7 @@ var Account = class extends AbstractAccount {
|
|
4993
4754
|
* @returns A promise that resolves to the transaction response.
|
4994
4755
|
*/
|
4995
4756
|
async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
4996
|
-
if (
|
4757
|
+
if (bn17(amount).lte(0)) {
|
4997
4758
|
throw new FuelError15(
|
4998
4759
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
4999
4760
|
"Transfer amount must be a positive number."
|
@@ -5012,37 +4773,38 @@ var Account = class extends AbstractAccount {
|
|
5012
4773
|
* @returns A promise that resolves to the transaction response.
|
5013
4774
|
*/
|
5014
4775
|
async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
|
5015
|
-
if (
|
4776
|
+
if (bn17(amount).lte(0)) {
|
5016
4777
|
throw new FuelError15(
|
5017
4778
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5018
4779
|
"Transfer amount must be a positive number."
|
5019
4780
|
);
|
5020
4781
|
}
|
5021
4782
|
const contractAddress = Address3.fromAddressOrString(contractId);
|
4783
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
4784
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
5022
4785
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5023
4786
|
hexlifiedContractId: contractAddress.toB256(),
|
5024
|
-
amountToTransfer:
|
4787
|
+
amountToTransfer: bn17(amount),
|
5025
4788
|
assetId
|
5026
4789
|
});
|
5027
4790
|
const request = new ScriptTransactionRequest({
|
5028
|
-
...
|
4791
|
+
...params,
|
5029
4792
|
script,
|
5030
4793
|
scriptData
|
5031
4794
|
});
|
5032
4795
|
request.addContractInputAndOutput(contractAddress);
|
5033
|
-
const
|
5034
|
-
|
5035
|
-
|
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
|
5036
4806
|
});
|
5037
|
-
|
5038
|
-
this.validateGas({
|
5039
|
-
gasUsed: txCost.gasUsed,
|
5040
|
-
gasLimit: request.gasLimit
|
5041
|
-
});
|
5042
|
-
}
|
5043
|
-
request.gasLimit = txCost.gasUsed;
|
5044
|
-
request.maxFee = txCost.maxFee;
|
5045
|
-
await this.fund(request, txCost);
|
4807
|
+
await this.fund(request, requiredQuantities, maxFee);
|
5046
4808
|
return this.sendTransaction(request);
|
5047
4809
|
}
|
5048
4810
|
/**
|
@@ -5054,31 +4816,34 @@ var Account = class extends AbstractAccount {
|
|
5054
4816
|
* @returns A promise that resolves to the transaction response.
|
5055
4817
|
*/
|
5056
4818
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4819
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
5057
4820
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
5058
4821
|
const recipientDataArray = arrayify14(
|
5059
4822
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5060
4823
|
);
|
5061
4824
|
const amountDataArray = arrayify14(
|
5062
|
-
"0x".concat(
|
4825
|
+
"0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
|
5063
4826
|
);
|
5064
4827
|
const script = new Uint8Array([
|
5065
4828
|
...arrayify14(withdrawScript.bytes),
|
5066
4829
|
...recipientDataArray,
|
5067
4830
|
...amountDataArray
|
5068
4831
|
]);
|
5069
|
-
const params = { script, ...txParams };
|
4832
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
5070
4833
|
const request = new ScriptTransactionRequest(params);
|
5071
|
-
const
|
5072
|
-
const
|
5073
|
-
|
5074
|
-
|
5075
|
-
|
5076
|
-
|
5077
|
-
|
5078
|
-
|
5079
|
-
|
5080
|
-
|
5081
|
-
|
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);
|
5082
4847
|
return this.sendTransaction(request);
|
5083
4848
|
}
|
5084
4849
|
async signMessage(message) {
|
@@ -5136,7 +4901,18 @@ var Account = class extends AbstractAccount {
|
|
5136
4901
|
}
|
5137
4902
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5138
4903
|
}
|
5139
|
-
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
|
+
}
|
5140
4916
|
if (gasUsed.gt(gasLimit)) {
|
5141
4917
|
throw new FuelError15(
|
5142
4918
|
ErrorCode15.GAS_LIMIT_TOO_LOW,
|
@@ -5428,7 +5204,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5428
5204
|
* @param transactionRequestLike - The transaction request to send.
|
5429
5205
|
* @returns A promise that resolves to the TransactionResponse object.
|
5430
5206
|
*/
|
5431
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
5207
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
5432
5208
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5433
5209
|
if (estimateTxDependencies) {
|
5434
5210
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -5469,7 +5245,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5469
5245
|
// src/hdwallet/hdwallet.ts
|
5470
5246
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5471
5247
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5472
|
-
import { bn as
|
5248
|
+
import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5473
5249
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5474
5250
|
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5475
5251
|
|
@@ -7935,7 +7711,7 @@ var HDWallet = class {
|
|
7935
7711
|
const IR = bytes.slice(32);
|
7936
7712
|
if (privateKey) {
|
7937
7713
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7938
|
-
const ki =
|
7714
|
+
const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
|
7939
7715
|
return new HDWallet({
|
7940
7716
|
privateKey: ki,
|
7941
7717
|
chainCode: IR,
|
@@ -8201,20 +7977,26 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
8201
7977
|
|
8202
7978
|
// src/test-utils/seedTestWallet.ts
|
8203
7979
|
import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
|
8204
|
-
var seedTestWallet = async (wallet, quantities) => {
|
7980
|
+
var seedTestWallet = async (wallet, quantities, utxosAmount = 1) => {
|
7981
|
+
const toFundAccounts = Array.isArray(wallet) ? wallet : [wallet];
|
8205
7982
|
const genesisWallet = new WalletUnlocked(
|
8206
7983
|
process.env.GENESIS_SECRET || randomBytes5(32),
|
8207
|
-
|
7984
|
+
toFundAccounts[0].provider
|
8208
7985
|
);
|
8209
|
-
const
|
8210
|
-
|
8211
|
-
|
8212
|
-
|
7986
|
+
const resources = await genesisWallet.getResourcesToSpend(quantities);
|
7987
|
+
const { minGasPrice } = genesisWallet.provider.getGasConfig();
|
7988
|
+
const request = new ScriptTransactionRequest({
|
7989
|
+
gasLimit: 1e4,
|
7990
|
+
gasPrice: minGasPrice
|
8213
7991
|
});
|
8214
|
-
|
8215
|
-
|
8216
|
-
|
8217
|
-
|
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
|
+
);
|
8218
8000
|
await genesisWallet.sendTransaction(request, { awaitExecution: true });
|
8219
8001
|
};
|
8220
8002
|
|
@@ -8229,11 +8011,11 @@ var generateTestWallet = async (provider, quantities) => {
|
|
8229
8011
|
|
8230
8012
|
// src/test-utils/launchNode.ts
|
8231
8013
|
import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
|
8232
|
-
import {
|
8014
|
+
import { toHex as toHex2 } from "@fuel-ts/math";
|
8015
|
+
import { defaultChainConfig, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
|
8233
8016
|
import { findBinPath } from "@fuel-ts/utils/cli-utils";
|
8234
8017
|
import { spawn } from "child_process";
|
8235
8018
|
import { randomUUID } from "crypto";
|
8236
|
-
import { randomBytes as randomBytes6 } from "ethers";
|
8237
8019
|
import { existsSync, mkdirSync, rmSync, writeFileSync } from "fs";
|
8238
8020
|
import os from "os";
|
8239
8021
|
import path from "path";
|
@@ -8282,12 +8064,12 @@ var launchNode = async ({
|
|
8282
8064
|
// eslint-disable-next-line no-async-promise-executor
|
8283
8065
|
new Promise(async (resolve, reject) => {
|
8284
8066
|
const remainingArgs = extractRemainingArgs(args, [
|
8285
|
-
"--
|
8067
|
+
"--chain",
|
8286
8068
|
"--consensus-key",
|
8287
8069
|
"--db-type",
|
8288
8070
|
"--poa-instant"
|
8289
8071
|
]);
|
8290
|
-
const chainConfigPath = getFlagValueFromArgs(args, "--
|
8072
|
+
const chainConfigPath = getFlagValueFromArgs(args, "--chain");
|
8291
8073
|
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || defaultConsensusKey;
|
8292
8074
|
const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
|
8293
8075
|
const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
|
@@ -8306,54 +8088,36 @@ var launchNode = async ({
|
|
8306
8088
|
let chainConfigPathToUse;
|
8307
8089
|
const prefix = basePath || os.tmpdir();
|
8308
8090
|
const suffix = basePath ? "" : randomUUID();
|
8309
|
-
const tempDirPath = path.join(prefix, ".fuels", suffix
|
8091
|
+
const tempDirPath = path.join(prefix, ".fuels", suffix);
|
8310
8092
|
if (chainConfigPath) {
|
8311
8093
|
chainConfigPathToUse = chainConfigPath;
|
8312
8094
|
} else {
|
8313
8095
|
if (!existsSync(tempDirPath)) {
|
8314
8096
|
mkdirSync(tempDirPath, { recursive: true });
|
8315
8097
|
}
|
8316
|
-
|
8317
|
-
|
8318
|
-
stateConfigJson = {
|
8319
|
-
...stateConfigJson,
|
8320
|
-
coins: [
|
8321
|
-
...stateConfigJson.coins.map((coin) => ({
|
8322
|
-
...coin,
|
8323
|
-
amount: "18446744073709551615"
|
8324
|
-
}))
|
8325
|
-
],
|
8326
|
-
messages: stateConfigJson.messages.map((message) => ({
|
8327
|
-
...message,
|
8328
|
-
amount: "18446744073709551615"
|
8329
|
-
}))
|
8330
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8331
|
-
};
|
8098
|
+
const tempChainConfigFilePath = path.join(tempDirPath, "chainConfig.json");
|
8099
|
+
let chainConfig = defaultChainConfig;
|
8332
8100
|
if (!process.env.GENESIS_SECRET) {
|
8333
8101
|
const pk = Signer.generatePrivateKey();
|
8334
8102
|
const signer = new Signer(pk);
|
8335
8103
|
process.env.GENESIS_SECRET = hexlify18(pk);
|
8336
|
-
|
8337
|
-
|
8338
|
-
|
8339
|
-
|
8340
|
-
|
8341
|
-
|
8342
|
-
|
8343
|
-
|
8344
|
-
|
8345
|
-
|
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
|
+
};
|
8346
8118
|
}
|
8347
|
-
|
8348
|
-
|
8349
|
-
fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
|
8350
|
-
const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
|
8351
|
-
const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
|
8352
|
-
const metadataWritePath = path.join(tempDirPath, "metadata.json");
|
8353
|
-
writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
|
8354
|
-
writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
|
8355
|
-
writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
|
8356
|
-
chainConfigPathToUse = tempDirPath;
|
8119
|
+
writeFileSync(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
|
8120
|
+
chainConfigPathToUse = tempChainConfigFilePath;
|
8357
8121
|
}
|
8358
8122
|
const child = spawn(
|
8359
8123
|
command,
|
@@ -8362,10 +8126,10 @@ var launchNode = async ({
|
|
8362
8126
|
["--ip", ipToUse],
|
8363
8127
|
["--port", portToUse],
|
8364
8128
|
useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
|
8365
|
-
["--min-gas-price", "
|
8129
|
+
["--min-gas-price", "0"],
|
8366
8130
|
poaInstant ? ["--poa-instant", "true"] : [],
|
8367
8131
|
["--consensus-key", consensusKey],
|
8368
|
-
["--
|
8132
|
+
["--chain", chainConfigPathToUse],
|
8369
8133
|
"--vm-backtrace",
|
8370
8134
|
"--utxo-validation",
|
8371
8135
|
"--debug",
|
@@ -8424,14 +8188,51 @@ var launchNodeAndGetWallets = async ({
|
|
8424
8188
|
walletCount = 10
|
8425
8189
|
} = {}) => {
|
8426
8190
|
const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
|
8427
|
-
const provider = await Provider.create(`http://${ip}:${port}/
|
8191
|
+
const provider = await Provider.create(`http://${ip}:${port}/graphql`);
|
8428
8192
|
const wallets = await generateWallets(walletCount, provider);
|
8429
8193
|
const cleanup = () => {
|
8430
8194
|
closeNode();
|
8431
8195
|
};
|
8432
8196
|
return { wallets, stop: cleanup, provider };
|
8433
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
|
+
});
|
8434
8232
|
export {
|
8233
|
+
generateFakeRequestInputCoin,
|
8234
|
+
generateFakeRequestInputContract,
|
8235
|
+
generateFakeRequestInputMessage,
|
8435
8236
|
generateTestWallet,
|
8436
8237
|
killNode,
|
8437
8238
|
launchNode,
|