@fuel-ts/account 0.0.0-rc-2040-20240415161844 → 0.0.0-rc-2021-20240415193305
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/README.md +1 -1
- package/dist/account.d.ts +5 -4
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +833 -560
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +834 -555
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +684 -406
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +10 -2
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +906 -324
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +4 -2
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/message.d.ts +7 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +48 -27
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +2 -2
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +8 -25
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +3 -0
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +8 -2
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +1579 -1068
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +809 -548
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +678 -417
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +17 -17
package/dist/test-utils.js
CHANGED
@@ -58,15 +58,16 @@ module.exports = __toCommonJS(test_utils_exports);
|
|
58
58
|
|
59
59
|
// src/wallet/base-wallet-unlocked.ts
|
60
60
|
var import_hasher3 = require("@fuel-ts/hasher");
|
61
|
-
var
|
61
|
+
var import_utils30 = require("@fuel-ts/utils");
|
62
62
|
|
63
63
|
// src/account.ts
|
64
64
|
var import_address4 = require("@fuel-ts/address");
|
65
65
|
var import_configs12 = require("@fuel-ts/address/configs");
|
66
66
|
var import_errors16 = require("@fuel-ts/errors");
|
67
67
|
var import_interfaces = require("@fuel-ts/interfaces");
|
68
|
-
var
|
69
|
-
var
|
68
|
+
var import_math19 = require("@fuel-ts/math");
|
69
|
+
var import_utils27 = require("@fuel-ts/utils");
|
70
|
+
var import_ramda4 = require("ramda");
|
70
71
|
|
71
72
|
// src/providers/coin-quantity.ts
|
72
73
|
var import_configs = require("@fuel-ts/address/configs");
|
@@ -92,7 +93,7 @@ var coinQuantityfy = (coinQuantityLike) => {
|
|
92
93
|
max: max2 ? (0, import_math.bn)(max2) : void 0
|
93
94
|
};
|
94
95
|
};
|
95
|
-
var
|
96
|
+
var addAmountToCoinQuantities = (params) => {
|
96
97
|
const { amount, assetId } = params;
|
97
98
|
const coinQuantities = [...params.coinQuantities];
|
98
99
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -107,11 +108,11 @@ var addAmountToAsset = (params) => {
|
|
107
108
|
// src/providers/provider.ts
|
108
109
|
var import_address3 = require("@fuel-ts/address");
|
109
110
|
var import_errors14 = require("@fuel-ts/errors");
|
110
|
-
var
|
111
|
-
var
|
112
|
-
var
|
111
|
+
var import_math16 = require("@fuel-ts/math");
|
112
|
+
var import_transactions19 = require("@fuel-ts/transactions");
|
113
|
+
var import_utils22 = require("@fuel-ts/utils");
|
113
114
|
var import_versions = require("@fuel-ts/versions");
|
114
|
-
var
|
115
|
+
var import_utils23 = require("@noble/curves/abstract/utils");
|
115
116
|
var import_ethers = require("ethers");
|
116
117
|
var import_graphql_request = require("graphql-request");
|
117
118
|
var import_ramda3 = require("ramda");
|
@@ -120,14 +121,10 @@ var import_ramda3 = require("ramda");
|
|
120
121
|
var import_graphql_tag = __toESM(require("graphql-tag"));
|
121
122
|
var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
|
122
123
|
fragment receiptFragment on Receipt {
|
123
|
-
|
124
|
-
id
|
125
|
-
}
|
124
|
+
id
|
126
125
|
pc
|
127
126
|
is
|
128
|
-
to
|
129
|
-
id
|
130
|
-
}
|
127
|
+
to
|
131
128
|
toAddress
|
132
129
|
amount
|
133
130
|
assetId
|
@@ -165,10 +162,16 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
165
162
|
id
|
166
163
|
}
|
167
164
|
time
|
165
|
+
receipts {
|
166
|
+
...receiptFragment
|
167
|
+
}
|
168
168
|
programState {
|
169
169
|
returnType
|
170
170
|
data
|
171
171
|
}
|
172
|
+
receipts {
|
173
|
+
...receiptFragment
|
174
|
+
}
|
172
175
|
}
|
173
176
|
... on FailureStatus {
|
174
177
|
block {
|
@@ -176,26 +179,24 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
176
179
|
}
|
177
180
|
time
|
178
181
|
reason
|
182
|
+
receipts {
|
183
|
+
...receiptFragment
|
184
|
+
}
|
179
185
|
}
|
180
186
|
... on SqueezedOutStatus {
|
181
187
|
reason
|
182
188
|
}
|
183
189
|
}
|
184
|
-
`;
|
190
|
+
${ReceiptFragmentFragmentDoc}`;
|
185
191
|
var TransactionFragmentFragmentDoc = import_graphql_tag.default`
|
186
192
|
fragment transactionFragment on Transaction {
|
187
193
|
id
|
188
194
|
rawPayload
|
189
|
-
gasPrice
|
190
|
-
receipts {
|
191
|
-
...receiptFragment
|
192
|
-
}
|
193
195
|
status {
|
194
196
|
...transactionStatusFragment
|
195
197
|
}
|
196
198
|
}
|
197
|
-
${
|
198
|
-
${TransactionStatusFragmentFragmentDoc}`;
|
199
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
199
200
|
var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
|
200
201
|
fragment inputEstimatePredicatesFragment on Input {
|
201
202
|
... on InputCoin {
|
@@ -213,6 +214,46 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
|
|
213
214
|
}
|
214
215
|
}
|
215
216
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
217
|
+
var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
|
218
|
+
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
219
|
+
reason
|
220
|
+
programState {
|
221
|
+
returnType
|
222
|
+
data
|
223
|
+
}
|
224
|
+
}
|
225
|
+
`;
|
226
|
+
var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
|
227
|
+
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
228
|
+
programState {
|
229
|
+
returnType
|
230
|
+
data
|
231
|
+
}
|
232
|
+
}
|
233
|
+
`;
|
234
|
+
var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
235
|
+
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
236
|
+
... on DryRunFailureStatus {
|
237
|
+
...dryRunFailureStatusFragment
|
238
|
+
}
|
239
|
+
... on DryRunSuccessStatus {
|
240
|
+
...dryRunSuccessStatusFragment
|
241
|
+
}
|
242
|
+
}
|
243
|
+
${DryRunFailureStatusFragmentFragmentDoc}
|
244
|
+
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
245
|
+
var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
246
|
+
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
247
|
+
id
|
248
|
+
status {
|
249
|
+
...dryRunTransactionStatusFragment
|
250
|
+
}
|
251
|
+
receipts {
|
252
|
+
...receiptFragment
|
253
|
+
}
|
254
|
+
}
|
255
|
+
${DryRunTransactionStatusFragmentFragmentDoc}
|
256
|
+
${ReceiptFragmentFragmentDoc}`;
|
216
257
|
var CoinFragmentFragmentDoc = import_graphql_tag.default`
|
217
258
|
fragment coinFragment on Coin {
|
218
259
|
__typename
|
@@ -220,7 +261,6 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
|
|
220
261
|
owner
|
221
262
|
amount
|
222
263
|
assetId
|
223
|
-
maturity
|
224
264
|
blockCreated
|
225
265
|
txCreatedIdx
|
226
266
|
}
|
@@ -259,26 +299,32 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
|
|
259
299
|
messageBlockHeader {
|
260
300
|
id
|
261
301
|
daHeight
|
302
|
+
consensusParametersVersion
|
303
|
+
stateTransitionBytecodeVersion
|
262
304
|
transactionsCount
|
305
|
+
messageReceiptCount
|
263
306
|
transactionsRoot
|
307
|
+
messageOutboxRoot
|
308
|
+
eventInboxRoot
|
264
309
|
height
|
265
310
|
prevRoot
|
266
311
|
time
|
267
312
|
applicationHash
|
268
|
-
messageReceiptRoot
|
269
|
-
messageReceiptCount
|
270
313
|
}
|
271
314
|
commitBlockHeader {
|
272
315
|
id
|
273
316
|
daHeight
|
317
|
+
consensusParametersVersion
|
318
|
+
stateTransitionBytecodeVersion
|
274
319
|
transactionsCount
|
320
|
+
messageReceiptCount
|
275
321
|
transactionsRoot
|
322
|
+
messageOutboxRoot
|
323
|
+
eventInboxRoot
|
276
324
|
height
|
277
325
|
prevRoot
|
278
326
|
time
|
279
327
|
applicationHash
|
280
|
-
messageReceiptRoot
|
281
|
-
messageReceiptCount
|
282
328
|
}
|
283
329
|
sender
|
284
330
|
recipient
|
@@ -297,8 +343,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
|
|
297
343
|
var BlockFragmentFragmentDoc = import_graphql_tag.default`
|
298
344
|
fragment blockFragment on Block {
|
299
345
|
id
|
346
|
+
height
|
300
347
|
header {
|
301
|
-
height
|
302
348
|
time
|
303
349
|
}
|
304
350
|
transactions {
|
@@ -356,6 +402,11 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
|
|
356
402
|
`;
|
357
403
|
var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
358
404
|
fragment GasCostsFragment on GasCosts {
|
405
|
+
version {
|
406
|
+
... on Version {
|
407
|
+
value
|
408
|
+
}
|
409
|
+
}
|
359
410
|
add
|
360
411
|
addi
|
361
412
|
aloc
|
@@ -368,7 +419,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
|
368
419
|
cb
|
369
420
|
cfei
|
370
421
|
cfsi
|
371
|
-
croo
|
372
422
|
div
|
373
423
|
divi
|
374
424
|
ecr1
|
@@ -451,6 +501,9 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
|
451
501
|
ccp {
|
452
502
|
...DependentCostFragment
|
453
503
|
}
|
504
|
+
croo {
|
505
|
+
...DependentCostFragment
|
506
|
+
}
|
454
507
|
csiz {
|
455
508
|
...DependentCostFragment
|
456
509
|
}
|
@@ -510,6 +563,11 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
|
510
563
|
${DependentCostFragmentFragmentDoc}`;
|
511
564
|
var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
|
512
565
|
fragment consensusParametersFragment on ConsensusParameters {
|
566
|
+
version {
|
567
|
+
... on Version {
|
568
|
+
value
|
569
|
+
}
|
570
|
+
}
|
513
571
|
txParams {
|
514
572
|
...TxParametersFragment
|
515
573
|
}
|
@@ -569,18 +627,9 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
|
|
569
627
|
fragment nodeInfoFragment on NodeInfo {
|
570
628
|
utxoValidation
|
571
629
|
vmBacktrace
|
572
|
-
minGasPrice
|
573
630
|
maxTx
|
574
631
|
maxDepth
|
575
632
|
nodeVersion
|
576
|
-
peers {
|
577
|
-
id
|
578
|
-
addresses
|
579
|
-
clientVersion
|
580
|
-
blockHeight
|
581
|
-
lastHeartbeatMs
|
582
|
-
appScore
|
583
|
-
}
|
584
633
|
}
|
585
634
|
`;
|
586
635
|
var GetVersionDocument = import_graphql_tag.default`
|
@@ -615,13 +664,9 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
|
|
615
664
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
616
665
|
transaction(id: $transactionId) {
|
617
666
|
...transactionFragment
|
618
|
-
receipts {
|
619
|
-
...receiptFragment
|
620
|
-
}
|
621
667
|
}
|
622
668
|
}
|
623
|
-
${TransactionFragmentFragmentDoc}
|
624
|
-
${ReceiptFragmentFragmentDoc}`;
|
669
|
+
${TransactionFragmentFragmentDoc}`;
|
625
670
|
var GetTransactionsDocument = import_graphql_tag.default`
|
626
671
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
627
672
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -749,6 +794,20 @@ var GetBalanceDocument = import_graphql_tag.default`
|
|
749
794
|
}
|
750
795
|
}
|
751
796
|
${BalanceFragmentFragmentDoc}`;
|
797
|
+
var GetLatestGasPriceDocument = import_graphql_tag.default`
|
798
|
+
query getLatestGasPrice {
|
799
|
+
latestGasPrice {
|
800
|
+
gasPrice
|
801
|
+
}
|
802
|
+
}
|
803
|
+
`;
|
804
|
+
var EstimateGasPriceDocument = import_graphql_tag.default`
|
805
|
+
query estimateGasPrice($blockHorizon: U32!) {
|
806
|
+
estimateGasPrice(blockHorizon: $blockHorizon) {
|
807
|
+
gasPrice
|
808
|
+
}
|
809
|
+
}
|
810
|
+
`;
|
752
811
|
var GetBalancesDocument = import_graphql_tag.default`
|
753
812
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
754
813
|
balances(
|
@@ -803,12 +862,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
|
|
803
862
|
}
|
804
863
|
`;
|
805
864
|
var DryRunDocument = import_graphql_tag.default`
|
806
|
-
mutation dryRun($
|
807
|
-
dryRun(
|
808
|
-
...
|
865
|
+
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
866
|
+
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
867
|
+
...dryRunTransactionExecutionStatusFragment
|
809
868
|
}
|
810
869
|
}
|
811
|
-
${
|
870
|
+
${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
|
812
871
|
var SubmitDocument = import_graphql_tag.default`
|
813
872
|
mutation submit($encodedTransaction: HexString!) {
|
814
873
|
submit(tx: $encodedTransaction) {
|
@@ -891,6 +950,12 @@ function getSdk(requester) {
|
|
891
950
|
getBalance(variables, options) {
|
892
951
|
return requester(GetBalanceDocument, variables, options);
|
893
952
|
},
|
953
|
+
getLatestGasPrice(variables, options) {
|
954
|
+
return requester(GetLatestGasPriceDocument, variables, options);
|
955
|
+
},
|
956
|
+
estimateGasPrice(variables, options) {
|
957
|
+
return requester(EstimateGasPriceDocument, variables, options);
|
958
|
+
},
|
894
959
|
getBalances(variables, options) {
|
895
960
|
return requester(GetBalancesDocument, variables, options);
|
896
961
|
},
|
@@ -960,11 +1025,14 @@ var _FuelGraphqlSubscriber = class {
|
|
960
1025
|
let data;
|
961
1026
|
let errors;
|
962
1027
|
try {
|
963
|
-
|
1028
|
+
const sanitizedText = text.replace(/\s/g, "");
|
1029
|
+
({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
|
964
1030
|
} catch (e) {
|
965
1031
|
throw new import_errors.FuelError(
|
966
1032
|
import_errors.ErrorCode.STREAM_PARSING_ERROR,
|
967
|
-
`Error while parsing stream data response: ${text}
|
1033
|
+
`Error while parsing stream data response: ${text}
|
1034
|
+
|
1035
|
+
Thrown error: ${e}`
|
968
1036
|
);
|
969
1037
|
}
|
970
1038
|
if (Array.isArray(errors)) {
|
@@ -1051,6 +1119,7 @@ var MemoryCache = class {
|
|
1051
1119
|
};
|
1052
1120
|
|
1053
1121
|
// src/providers/transaction-request/input.ts
|
1122
|
+
var import_abi_coder = require("@fuel-ts/abi-coder");
|
1054
1123
|
var import_configs2 = require("@fuel-ts/address/configs");
|
1055
1124
|
var import_errors3 = require("@fuel-ts/errors");
|
1056
1125
|
var import_math2 = require("@fuel-ts/math");
|
@@ -1064,8 +1133,8 @@ var inputify = (value) => {
|
|
1064
1133
|
const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
|
1065
1134
|
return {
|
1066
1135
|
type: import_transactions.InputType.Coin,
|
1067
|
-
txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0,
|
1068
|
-
outputIndex: (0, import_utils3.arrayify)(value.id)
|
1136
|
+
txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, import_abi_coder.BYTES_32)),
|
1137
|
+
outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(import_abi_coder.BYTES_32, import_abi_coder.UTXO_ID_LEN)),
|
1069
1138
|
owner: (0, import_utils3.hexlify)(value.owner),
|
1070
1139
|
amount: (0, import_math2.bn)(value.amount),
|
1071
1140
|
assetId: (0, import_utils3.hexlify)(value.assetId),
|
@@ -1074,10 +1143,9 @@ var inputify = (value) => {
|
|
1074
1143
|
txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
|
1075
1144
|
},
|
1076
1145
|
witnessIndex: value.witnessIndex,
|
1077
|
-
maturity: value.maturity ?? 0,
|
1078
1146
|
predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
|
1079
|
-
predicateLength: predicate.length,
|
1080
|
-
predicateDataLength: predicateData.length,
|
1147
|
+
predicateLength: (0, import_math2.bn)(predicate.length),
|
1148
|
+
predicateDataLength: (0, import_math2.bn)(predicateData.length),
|
1081
1149
|
predicate: (0, import_utils3.hexlify)(predicate),
|
1082
1150
|
predicateData: (0, import_utils3.hexlify)(predicateData)
|
1083
1151
|
};
|
@@ -1108,8 +1176,8 @@ var inputify = (value) => {
|
|
1108
1176
|
nonce: (0, import_utils3.hexlify)(value.nonce),
|
1109
1177
|
witnessIndex: value.witnessIndex,
|
1110
1178
|
predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
|
1111
|
-
predicateLength: predicate.length,
|
1112
|
-
predicateDataLength: predicateData.length,
|
1179
|
+
predicateLength: (0, import_math2.bn)(predicate.length),
|
1180
|
+
predicateDataLength: (0, import_math2.bn)(predicateData.length),
|
1113
1181
|
predicate: (0, import_utils3.hexlify)(predicate),
|
1114
1182
|
predicateData: (0, import_utils3.hexlify)(predicateData),
|
1115
1183
|
data: (0, import_utils3.hexlify)(data),
|
@@ -1183,8 +1251,10 @@ var outputify = (value) => {
|
|
1183
1251
|
};
|
1184
1252
|
|
1185
1253
|
// src/providers/transaction-request/transaction-request.ts
|
1254
|
+
var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
1186
1255
|
var import_address = require("@fuel-ts/address");
|
1187
1256
|
var import_configs7 = require("@fuel-ts/address/configs");
|
1257
|
+
var import_crypto = require("@fuel-ts/crypto");
|
1188
1258
|
var import_math7 = require("@fuel-ts/math");
|
1189
1259
|
var import_transactions6 = require("@fuel-ts/transactions");
|
1190
1260
|
var import_utils9 = require("@fuel-ts/utils");
|
@@ -1223,8 +1293,8 @@ function assembleReceiptByType(receipt) {
|
|
1223
1293
|
case "CALL" /* Call */: {
|
1224
1294
|
const callReceipt = {
|
1225
1295
|
type: import_transactions3.ReceiptType.Call,
|
1226
|
-
from: hexOrZero(receipt.
|
1227
|
-
to: hexOrZero(receipt?.to
|
1296
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1297
|
+
to: hexOrZero(receipt?.to),
|
1228
1298
|
amount: (0, import_math4.bn)(receipt.amount),
|
1229
1299
|
assetId: hexOrZero(receipt.assetId),
|
1230
1300
|
gas: (0, import_math4.bn)(receipt.gas),
|
@@ -1238,7 +1308,7 @@ function assembleReceiptByType(receipt) {
|
|
1238
1308
|
case "RETURN" /* Return */: {
|
1239
1309
|
const returnReceipt = {
|
1240
1310
|
type: import_transactions3.ReceiptType.Return,
|
1241
|
-
id: hexOrZero(receipt.
|
1311
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1242
1312
|
val: (0, import_math4.bn)(receipt.val),
|
1243
1313
|
pc: (0, import_math4.bn)(receipt.pc),
|
1244
1314
|
is: (0, import_math4.bn)(receipt.is)
|
@@ -1248,7 +1318,7 @@ function assembleReceiptByType(receipt) {
|
|
1248
1318
|
case "RETURN_DATA" /* ReturnData */: {
|
1249
1319
|
const returnDataReceipt = {
|
1250
1320
|
type: import_transactions3.ReceiptType.ReturnData,
|
1251
|
-
id: hexOrZero(receipt.
|
1321
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1252
1322
|
ptr: (0, import_math4.bn)(receipt.ptr),
|
1253
1323
|
len: (0, import_math4.bn)(receipt.len),
|
1254
1324
|
digest: hexOrZero(receipt.digest),
|
@@ -1260,7 +1330,7 @@ function assembleReceiptByType(receipt) {
|
|
1260
1330
|
case "PANIC" /* Panic */: {
|
1261
1331
|
const panicReceipt = {
|
1262
1332
|
type: import_transactions3.ReceiptType.Panic,
|
1263
|
-
id: hexOrZero(receipt.
|
1333
|
+
id: hexOrZero(receipt.id),
|
1264
1334
|
reason: (0, import_math4.bn)(receipt.reason),
|
1265
1335
|
pc: (0, import_math4.bn)(receipt.pc),
|
1266
1336
|
is: (0, import_math4.bn)(receipt.is),
|
@@ -1271,7 +1341,7 @@ function assembleReceiptByType(receipt) {
|
|
1271
1341
|
case "REVERT" /* Revert */: {
|
1272
1342
|
const revertReceipt = {
|
1273
1343
|
type: import_transactions3.ReceiptType.Revert,
|
1274
|
-
id: hexOrZero(receipt.
|
1344
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1275
1345
|
val: (0, import_math4.bn)(receipt.ra),
|
1276
1346
|
pc: (0, import_math4.bn)(receipt.pc),
|
1277
1347
|
is: (0, import_math4.bn)(receipt.is)
|
@@ -1281,7 +1351,7 @@ function assembleReceiptByType(receipt) {
|
|
1281
1351
|
case "LOG" /* Log */: {
|
1282
1352
|
const logReceipt = {
|
1283
1353
|
type: import_transactions3.ReceiptType.Log,
|
1284
|
-
id: hexOrZero(receipt.
|
1354
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1285
1355
|
val0: (0, import_math4.bn)(receipt.ra),
|
1286
1356
|
val1: (0, import_math4.bn)(receipt.rb),
|
1287
1357
|
val2: (0, import_math4.bn)(receipt.rc),
|
@@ -1294,7 +1364,7 @@ function assembleReceiptByType(receipt) {
|
|
1294
1364
|
case "LOG_DATA" /* LogData */: {
|
1295
1365
|
const logDataReceipt = {
|
1296
1366
|
type: import_transactions3.ReceiptType.LogData,
|
1297
|
-
id: hexOrZero(receipt.
|
1367
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1298
1368
|
val0: (0, import_math4.bn)(receipt.ra),
|
1299
1369
|
val1: (0, import_math4.bn)(receipt.rb),
|
1300
1370
|
ptr: (0, import_math4.bn)(receipt.ptr),
|
@@ -1308,8 +1378,8 @@ function assembleReceiptByType(receipt) {
|
|
1308
1378
|
case "TRANSFER" /* Transfer */: {
|
1309
1379
|
const transferReceipt = {
|
1310
1380
|
type: import_transactions3.ReceiptType.Transfer,
|
1311
|
-
from: hexOrZero(receipt.
|
1312
|
-
to: hexOrZero(receipt.toAddress || receipt?.to
|
1381
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1382
|
+
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1313
1383
|
amount: (0, import_math4.bn)(receipt.amount),
|
1314
1384
|
assetId: hexOrZero(receipt.assetId),
|
1315
1385
|
pc: (0, import_math4.bn)(receipt.pc),
|
@@ -1320,8 +1390,8 @@ function assembleReceiptByType(receipt) {
|
|
1320
1390
|
case "TRANSFER_OUT" /* TransferOut */: {
|
1321
1391
|
const transferOutReceipt = {
|
1322
1392
|
type: import_transactions3.ReceiptType.TransferOut,
|
1323
|
-
from: hexOrZero(receipt.
|
1324
|
-
to: hexOrZero(receipt.toAddress || receipt.to
|
1393
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1394
|
+
to: hexOrZero(receipt.toAddress || receipt.to),
|
1325
1395
|
amount: (0, import_math4.bn)(receipt.amount),
|
1326
1396
|
assetId: hexOrZero(receipt.assetId),
|
1327
1397
|
pc: (0, import_math4.bn)(receipt.pc),
|
@@ -1364,7 +1434,7 @@ function assembleReceiptByType(receipt) {
|
|
1364
1434
|
return receiptMessageOut;
|
1365
1435
|
}
|
1366
1436
|
case "MINT" /* Mint */: {
|
1367
|
-
const contractId = hexOrZero(receipt.
|
1437
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1368
1438
|
const subId = hexOrZero(receipt.subId);
|
1369
1439
|
const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
|
1370
1440
|
const mintReceipt = {
|
@@ -1379,7 +1449,7 @@ function assembleReceiptByType(receipt) {
|
|
1379
1449
|
return mintReceipt;
|
1380
1450
|
}
|
1381
1451
|
case "BURN" /* Burn */: {
|
1382
|
-
const contractId = hexOrZero(receipt.
|
1452
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1383
1453
|
const subId = hexOrZero(receipt.subId);
|
1384
1454
|
const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
|
1385
1455
|
const burnReceipt = {
|
@@ -1405,7 +1475,6 @@ var import_errors6 = require("@fuel-ts/errors");
|
|
1405
1475
|
var import_math5 = require("@fuel-ts/math");
|
1406
1476
|
var import_transactions4 = require("@fuel-ts/transactions");
|
1407
1477
|
var import_utils6 = require("@fuel-ts/utils");
|
1408
|
-
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1409
1478
|
var getGasUsedFromReceipts = (receipts) => {
|
1410
1479
|
const scriptResult = receipts.filter(
|
1411
1480
|
(receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
|
@@ -1426,18 +1495,28 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
1426
1495
|
}
|
1427
1496
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
1428
1497
|
const witnessCache = [];
|
1429
|
-
const
|
1498
|
+
const chargeableInputs = inputs.filter((input) => {
|
1499
|
+
const isCoinOrMessage = "owner" in input || "sender" in input;
|
1500
|
+
if (isCoinOrMessage) {
|
1501
|
+
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1502
|
+
return true;
|
1503
|
+
}
|
1504
|
+
if (!witnessCache.includes(input.witnessIndex)) {
|
1505
|
+
witnessCache.push(input.witnessIndex);
|
1506
|
+
return true;
|
1507
|
+
}
|
1508
|
+
}
|
1509
|
+
return false;
|
1510
|
+
});
|
1511
|
+
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
1512
|
+
const totalGas = chargeableInputs.reduce((total, input) => {
|
1430
1513
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1431
1514
|
return total.add(
|
1432
|
-
|
1515
|
+
vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
|
1433
1516
|
);
|
1434
1517
|
}
|
1435
|
-
|
1436
|
-
|
1437
|
-
return total.add(gasCosts.ecr1);
|
1438
|
-
}
|
1439
|
-
return total;
|
1440
|
-
}, (0, import_math5.bn)());
|
1518
|
+
return total.add(gasCosts.ecr1);
|
1519
|
+
}, (0, import_math5.bn)(0));
|
1441
1520
|
return totalGas;
|
1442
1521
|
}
|
1443
1522
|
function getMinGas(params) {
|
@@ -1449,12 +1528,20 @@ function getMinGas(params) {
|
|
1449
1528
|
return minGas;
|
1450
1529
|
}
|
1451
1530
|
function getMaxGas(params) {
|
1452
|
-
const {
|
1531
|
+
const {
|
1532
|
+
gasPerByte,
|
1533
|
+
witnessesLength,
|
1534
|
+
witnessLimit,
|
1535
|
+
minGas,
|
1536
|
+
gasLimit = (0, import_math5.bn)(0),
|
1537
|
+
maxGasPerTx
|
1538
|
+
} = params;
|
1453
1539
|
let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
|
1454
1540
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
1455
1541
|
remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
1456
1542
|
}
|
1457
|
-
|
1543
|
+
const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
1544
|
+
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
1458
1545
|
}
|
1459
1546
|
function calculateMetadataGasForTxCreate({
|
1460
1547
|
gasCosts,
|
@@ -1476,6 +1563,10 @@ function calculateMetadataGasForTxScript({
|
|
1476
1563
|
}) {
|
1477
1564
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1478
1565
|
}
|
1566
|
+
var calculateGasFee = (params) => {
|
1567
|
+
const { gas, gasPrice, priceFactor, tip } = params;
|
1568
|
+
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1569
|
+
};
|
1479
1570
|
|
1480
1571
|
// src/providers/utils/json.ts
|
1481
1572
|
var import_utils7 = require("@fuel-ts/utils");
|
@@ -1612,7 +1703,7 @@ var witnessify = (value) => {
|
|
1612
1703
|
// src/providers/transaction-request/transaction-request.ts
|
1613
1704
|
var BaseTransactionRequest = class {
|
1614
1705
|
/** Gas price for transaction */
|
1615
|
-
|
1706
|
+
tip;
|
1616
1707
|
/** Block until which tx cannot be included */
|
1617
1708
|
maturity;
|
1618
1709
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -1631,7 +1722,7 @@ var BaseTransactionRequest = class {
|
|
1631
1722
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
1632
1723
|
*/
|
1633
1724
|
constructor({
|
1634
|
-
|
1725
|
+
tip,
|
1635
1726
|
maturity,
|
1636
1727
|
maxFee,
|
1637
1728
|
witnessLimit,
|
@@ -1639,7 +1730,7 @@ var BaseTransactionRequest = class {
|
|
1639
1730
|
outputs,
|
1640
1731
|
witnesses
|
1641
1732
|
} = {}) {
|
1642
|
-
this.
|
1733
|
+
this.tip = (0, import_math7.bn)(tip);
|
1643
1734
|
this.maturity = maturity ?? 0;
|
1644
1735
|
this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
|
1645
1736
|
this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
|
@@ -1650,9 +1741,9 @@ var BaseTransactionRequest = class {
|
|
1650
1741
|
static getPolicyMeta(req) {
|
1651
1742
|
let policyTypes = 0;
|
1652
1743
|
const policies = [];
|
1653
|
-
if (req.
|
1654
|
-
policyTypes += import_transactions6.PolicyType.
|
1655
|
-
policies.push({ data: req.
|
1744
|
+
if (req.tip) {
|
1745
|
+
policyTypes += import_transactions6.PolicyType.Tip;
|
1746
|
+
policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
|
1656
1747
|
}
|
1657
1748
|
if (req.witnessLimit) {
|
1658
1749
|
policyTypes += import_transactions6.PolicyType.WitnessLimit;
|
@@ -1839,10 +1930,10 @@ var BaseTransactionRequest = class {
|
|
1839
1930
|
* @param predicate - Predicate bytes.
|
1840
1931
|
* @param predicateData - Predicate data bytes.
|
1841
1932
|
*/
|
1842
|
-
addCoinInput(coin
|
1933
|
+
addCoinInput(coin) {
|
1843
1934
|
const { assetId, owner, amount } = coin;
|
1844
1935
|
let witnessIndex;
|
1845
|
-
if (predicate) {
|
1936
|
+
if (coin.predicate) {
|
1846
1937
|
witnessIndex = 0;
|
1847
1938
|
} else {
|
1848
1939
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -1857,8 +1948,7 @@ var BaseTransactionRequest = class {
|
|
1857
1948
|
amount,
|
1858
1949
|
assetId,
|
1859
1950
|
txPointer: "0x00000000000000000000000000000000",
|
1860
|
-
witnessIndex
|
1861
|
-
predicate: predicate?.bytes
|
1951
|
+
witnessIndex
|
1862
1952
|
};
|
1863
1953
|
this.pushInput(input);
|
1864
1954
|
this.addChangeOutput(owner, assetId);
|
@@ -1871,11 +1961,11 @@ var BaseTransactionRequest = class {
|
|
1871
1961
|
* @param predicate - Predicate bytes.
|
1872
1962
|
* @param predicateData - Predicate data bytes.
|
1873
1963
|
*/
|
1874
|
-
addMessageInput(message
|
1964
|
+
addMessageInput(message) {
|
1875
1965
|
const { recipient, sender, amount } = message;
|
1876
1966
|
const assetId = import_configs7.BaseAssetId;
|
1877
1967
|
let witnessIndex;
|
1878
|
-
if (predicate) {
|
1968
|
+
if (message.predicate) {
|
1879
1969
|
witnessIndex = 0;
|
1880
1970
|
} else {
|
1881
1971
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -1889,8 +1979,7 @@ var BaseTransactionRequest = class {
|
|
1889
1979
|
sender: sender.toB256(),
|
1890
1980
|
recipient: recipient.toB256(),
|
1891
1981
|
amount,
|
1892
|
-
witnessIndex
|
1893
|
-
predicate: predicate?.bytes
|
1982
|
+
witnessIndex
|
1894
1983
|
};
|
1895
1984
|
this.pushInput(input);
|
1896
1985
|
this.addChangeOutput(recipient, assetId);
|
@@ -1921,32 +2010,6 @@ var BaseTransactionRequest = class {
|
|
1921
2010
|
resources.forEach((resource) => this.addResource(resource));
|
1922
2011
|
return this;
|
1923
2012
|
}
|
1924
|
-
/**
|
1925
|
-
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
1926
|
-
* outputs from the related assetIds.
|
1927
|
-
*
|
1928
|
-
* @param resources - The resources to add.
|
1929
|
-
* @returns This transaction.
|
1930
|
-
*/
|
1931
|
-
addPredicateResource(resource, predicate) {
|
1932
|
-
if (isCoin(resource)) {
|
1933
|
-
this.addCoinInput(resource, predicate);
|
1934
|
-
} else {
|
1935
|
-
this.addMessageInput(resource, predicate);
|
1936
|
-
}
|
1937
|
-
return this;
|
1938
|
-
}
|
1939
|
-
/**
|
1940
|
-
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
1941
|
-
* from the related assetIds.
|
1942
|
-
*
|
1943
|
-
* @param resources - The resources to add.
|
1944
|
-
* @returns This transaction.
|
1945
|
-
*/
|
1946
|
-
addPredicateResources(resources, predicate) {
|
1947
|
-
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
1948
|
-
return this;
|
1949
|
-
}
|
1950
2013
|
/**
|
1951
2014
|
* Adds a coin output to the transaction.
|
1952
2015
|
*
|
@@ -2026,7 +2089,7 @@ var BaseTransactionRequest = class {
|
|
2026
2089
|
}
|
2027
2090
|
calculateMaxGas(chainInfo, minGas) {
|
2028
2091
|
const { consensusParameters } = chainInfo;
|
2029
|
-
const { gasPerByte } = consensusParameters;
|
2092
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2030
2093
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2031
2094
|
(acc, wit) => acc + wit.dataLength,
|
2032
2095
|
0
|
@@ -2035,7 +2098,8 @@ var BaseTransactionRequest = class {
|
|
2035
2098
|
gasPerByte,
|
2036
2099
|
minGas,
|
2037
2100
|
witnessesLength,
|
2038
|
-
witnessLimit: this.witnessLimit
|
2101
|
+
witnessLimit: this.witnessLimit,
|
2102
|
+
maxGasPerTx
|
2039
2103
|
});
|
2040
2104
|
}
|
2041
2105
|
/**
|
@@ -2045,12 +2109,6 @@ var BaseTransactionRequest = class {
|
|
2045
2109
|
* @param quantities - CoinQuantity Array.
|
2046
2110
|
*/
|
2047
2111
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
2048
|
-
let idCounter = 0;
|
2049
|
-
const generateId = () => {
|
2050
|
-
const counterString = String(idCounter++);
|
2051
|
-
const id = import_configs7.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
2052
|
-
return id;
|
2053
|
-
};
|
2054
2112
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
2055
2113
|
if ("assetId" in input) {
|
2056
2114
|
return input.assetId === assetId;
|
@@ -2059,17 +2117,20 @@ var BaseTransactionRequest = class {
|
|
2059
2117
|
});
|
2060
2118
|
const updateAssetInput = (assetId, quantity) => {
|
2061
2119
|
const assetInput = findAssetInput(assetId);
|
2120
|
+
let usedQuantity = quantity;
|
2121
|
+
if (assetId === import_configs7.BaseAssetId) {
|
2122
|
+
usedQuantity = (0, import_math7.bn)("1000000000000000000");
|
2123
|
+
}
|
2062
2124
|
if (assetInput && "assetId" in assetInput) {
|
2063
|
-
assetInput.id =
|
2064
|
-
assetInput.amount =
|
2125
|
+
assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
|
2126
|
+
assetInput.amount = usedQuantity;
|
2065
2127
|
} else {
|
2066
2128
|
this.addResources([
|
2067
2129
|
{
|
2068
|
-
id:
|
2069
|
-
amount:
|
2130
|
+
id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
|
2131
|
+
amount: usedQuantity,
|
2070
2132
|
assetId,
|
2071
2133
|
owner: resourcesOwner || import_address.Address.fromRandom(),
|
2072
|
-
maturity: 0,
|
2073
2134
|
blockCreated: (0, import_math7.bn)(1),
|
2074
2135
|
txCreatedIdx: (0, import_math7.bn)(1)
|
2075
2136
|
}
|
@@ -2101,7 +2162,7 @@ var BaseTransactionRequest = class {
|
|
2101
2162
|
toJSON() {
|
2102
2163
|
return normalizeJSON(this);
|
2103
2164
|
}
|
2104
|
-
|
2165
|
+
updatePredicateGasUsed(inputs) {
|
2105
2166
|
this.inputs.forEach((i) => {
|
2106
2167
|
let correspondingInput;
|
2107
2168
|
switch (i.type) {
|
@@ -2123,6 +2184,15 @@ var BaseTransactionRequest = class {
|
|
2123
2184
|
}
|
2124
2185
|
});
|
2125
2186
|
}
|
2187
|
+
shiftPredicateData() {
|
2188
|
+
this.inputs.forEach((input) => {
|
2189
|
+
if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
|
2190
|
+
input.predicateData = input.paddPredicateData(
|
2191
|
+
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2192
|
+
);
|
2193
|
+
}
|
2194
|
+
});
|
2195
|
+
}
|
2126
2196
|
};
|
2127
2197
|
|
2128
2198
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2269,9 +2339,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2269
2339
|
return {
|
2270
2340
|
type: import_transactions8.TransactionType.Create,
|
2271
2341
|
...baseTransaction,
|
2272
|
-
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2273
2342
|
bytecodeWitnessIndex,
|
2274
|
-
storageSlotsCount: storageSlots.length,
|
2343
|
+
storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
|
2275
2344
|
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
|
2276
2345
|
storageSlots
|
2277
2346
|
};
|
@@ -2320,7 +2389,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2320
2389
|
};
|
2321
2390
|
|
2322
2391
|
// src/providers/transaction-request/script-transaction-request.ts
|
2323
|
-
var
|
2392
|
+
var import_abi_coder3 = require("@fuel-ts/abi-coder");
|
2324
2393
|
var import_address2 = require("@fuel-ts/address");
|
2325
2394
|
var import_configs10 = require("@fuel-ts/address/configs");
|
2326
2395
|
var import_math10 = require("@fuel-ts/math");
|
@@ -2394,8 +2463,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2394
2463
|
type: import_transactions9.TransactionType.Script,
|
2395
2464
|
scriptGasLimit: this.gasLimit,
|
2396
2465
|
...super.getBaseTransaction(),
|
2397
|
-
scriptLength: script.length,
|
2398
|
-
scriptDataLength: scriptData.length,
|
2466
|
+
scriptLength: (0, import_math10.bn)(script.length),
|
2467
|
+
scriptDataLength: (0, import_math10.bn)(scriptData.length),
|
2399
2468
|
receiptsRoot: import_configs10.ZeroBytes32,
|
2400
2469
|
script: (0, import_utils15.hexlify)(script),
|
2401
2470
|
scriptData: (0, import_utils15.hexlify)(scriptData)
|
@@ -2459,7 +2528,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2459
2528
|
}
|
2460
2529
|
calculateMaxGas(chainInfo, minGas) {
|
2461
2530
|
const { consensusParameters } = chainInfo;
|
2462
|
-
const { gasPerByte } = consensusParameters;
|
2531
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2463
2532
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2464
2533
|
(acc, wit) => acc + wit.dataLength,
|
2465
2534
|
0
|
@@ -2469,7 +2538,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2469
2538
|
minGas,
|
2470
2539
|
witnessesLength,
|
2471
2540
|
witnessLimit: this.witnessLimit,
|
2472
|
-
gasLimit: this.gasLimit
|
2541
|
+
gasLimit: this.gasLimit,
|
2542
|
+
maxGasPerTx
|
2473
2543
|
});
|
2474
2544
|
}
|
2475
2545
|
/**
|
@@ -2512,7 +2582,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2512
2582
|
* @returns The current instance of the `ScriptTransactionRequest`.
|
2513
2583
|
*/
|
2514
2584
|
setData(abi, args) {
|
2515
|
-
const abiInterface = new
|
2585
|
+
const abiInterface = new import_abi_coder3.Interface(abi);
|
2516
2586
|
this.scriptData = abiInterface.functions.main.encodeArguments(args);
|
2517
2587
|
return this;
|
2518
2588
|
}
|
@@ -2544,15 +2614,32 @@ var transactionRequestify = (obj) => {
|
|
2544
2614
|
}
|
2545
2615
|
}
|
2546
2616
|
};
|
2617
|
+
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2618
|
+
(acc, input) => {
|
2619
|
+
if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
|
2620
|
+
acc.utxos.push(input.id);
|
2621
|
+
}
|
2622
|
+
if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
|
2623
|
+
acc.messages.push(input.nonce);
|
2624
|
+
}
|
2625
|
+
return acc;
|
2626
|
+
},
|
2627
|
+
{
|
2628
|
+
utxos: [],
|
2629
|
+
messages: []
|
2630
|
+
}
|
2631
|
+
);
|
2547
2632
|
|
2548
2633
|
// src/providers/transaction-response/transaction-response.ts
|
2549
2634
|
var import_errors13 = require("@fuel-ts/errors");
|
2550
|
-
var
|
2551
|
-
var
|
2552
|
-
var
|
2635
|
+
var import_math15 = require("@fuel-ts/math");
|
2636
|
+
var import_transactions18 = require("@fuel-ts/transactions");
|
2637
|
+
var import_utils20 = require("@fuel-ts/utils");
|
2553
2638
|
|
2554
2639
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2555
|
-
var
|
2640
|
+
var import_math14 = require("@fuel-ts/math");
|
2641
|
+
var import_transactions16 = require("@fuel-ts/transactions");
|
2642
|
+
var import_utils18 = require("@fuel-ts/utils");
|
2556
2643
|
|
2557
2644
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2558
2645
|
var import_math11 = require("@fuel-ts/math");
|
@@ -2560,9 +2647,10 @@ var import_transactions11 = require("@fuel-ts/transactions");
|
|
2560
2647
|
var import_utils16 = require("@fuel-ts/utils");
|
2561
2648
|
var calculateTransactionFee = (params) => {
|
2562
2649
|
const {
|
2563
|
-
|
2650
|
+
gasPrice,
|
2564
2651
|
rawPayload,
|
2565
|
-
|
2652
|
+
tip,
|
2653
|
+
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2566
2654
|
} = params;
|
2567
2655
|
const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
|
2568
2656
|
const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
|
@@ -2572,8 +2660,7 @@ var calculateTransactionFee = (params) => {
|
|
2572
2660
|
return {
|
2573
2661
|
fee: (0, import_math11.bn)(0),
|
2574
2662
|
minFee: (0, import_math11.bn)(0),
|
2575
|
-
maxFee: (0, import_math11.bn)(0)
|
2576
|
-
feeFromGasUsed: (0, import_math11.bn)(0)
|
2663
|
+
maxFee: (0, import_math11.bn)(0)
|
2577
2664
|
};
|
2578
2665
|
}
|
2579
2666
|
const { type, witnesses, inputs, policies } = transaction;
|
@@ -2605,7 +2692,6 @@ var calculateTransactionFee = (params) => {
|
|
2605
2692
|
metadataGas,
|
2606
2693
|
txBytesSize: transactionBytes.length
|
2607
2694
|
});
|
2608
|
-
const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
|
2609
2695
|
const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
|
2610
2696
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2611
2697
|
const maxGas = getMaxGas({
|
@@ -2613,17 +2699,25 @@ var calculateTransactionFee = (params) => {
|
|
2613
2699
|
minGas,
|
2614
2700
|
witnessesLength,
|
2615
2701
|
gasLimit,
|
2616
|
-
witnessLimit
|
2702
|
+
witnessLimit,
|
2703
|
+
maxGasPerTx
|
2704
|
+
});
|
2705
|
+
const minFee = calculateGasFee({
|
2706
|
+
gasPrice,
|
2707
|
+
gas: minGas,
|
2708
|
+
priceFactor: gasPriceFactor,
|
2709
|
+
tip
|
2710
|
+
});
|
2711
|
+
const maxFee = calculateGasFee({
|
2712
|
+
gasPrice,
|
2713
|
+
gas: maxGas,
|
2714
|
+
priceFactor: gasPriceFactor,
|
2715
|
+
tip
|
2617
2716
|
});
|
2618
|
-
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
2619
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
2620
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
2621
|
-
const fee = minFee.add(feeFromGasUsed);
|
2622
2717
|
return {
|
2623
|
-
fee,
|
2624
2718
|
minFee,
|
2625
2719
|
maxFee,
|
2626
|
-
|
2720
|
+
fee: maxFee
|
2627
2721
|
};
|
2628
2722
|
};
|
2629
2723
|
|
@@ -2634,17 +2728,17 @@ var import_math13 = require("@fuel-ts/math");
|
|
2634
2728
|
var import_transactions14 = require("@fuel-ts/transactions");
|
2635
2729
|
|
2636
2730
|
// src/providers/transaction-summary/call.ts
|
2637
|
-
var
|
2731
|
+
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
2638
2732
|
var import_math12 = require("@fuel-ts/math");
|
2639
2733
|
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2640
|
-
const abiInterface = new
|
2734
|
+
const abiInterface = new import_abi_coder4.Interface(abi);
|
2641
2735
|
const callFunctionSelector = receipt.param1.toHex(8);
|
2642
2736
|
const functionFragment = abiInterface.getFunction(callFunctionSelector);
|
2643
2737
|
const inputs = functionFragment.jsonFn.inputs;
|
2644
2738
|
let encodedArgs;
|
2645
2739
|
if (functionFragment.isInputDataPointer) {
|
2646
2740
|
if (rawPayload) {
|
2647
|
-
const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0,
|
2741
|
+
const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2648
2742
|
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2649
2743
|
}
|
2650
2744
|
} else {
|
@@ -3190,10 +3284,12 @@ function assembleTransactionSummary(params) {
|
|
3190
3284
|
gqlTransactionStatus,
|
3191
3285
|
abiMap = {},
|
3192
3286
|
maxInputs,
|
3193
|
-
gasCosts
|
3287
|
+
gasCosts,
|
3288
|
+
maxGasPerTx,
|
3289
|
+
gasPrice
|
3194
3290
|
} = params;
|
3195
3291
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3196
|
-
const rawPayload = (0,
|
3292
|
+
const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
|
3197
3293
|
const operations = getOperations({
|
3198
3294
|
transactionType: transaction.type,
|
3199
3295
|
inputs: transaction.inputs || [],
|
@@ -3204,11 +3300,14 @@ function assembleTransactionSummary(params) {
|
|
3204
3300
|
maxInputs
|
3205
3301
|
});
|
3206
3302
|
const typeName = getTransactionTypeName(transaction.type);
|
3303
|
+
const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
|
3207
3304
|
const { fee } = calculateTransactionFee({
|
3208
|
-
|
3305
|
+
gasPrice,
|
3209
3306
|
rawPayload,
|
3307
|
+
tip,
|
3210
3308
|
consensusParameters: {
|
3211
3309
|
gasCosts,
|
3310
|
+
maxGasPerTx,
|
3212
3311
|
feeParams: {
|
3213
3312
|
gasPerByte,
|
3214
3313
|
gasPriceFactor
|
@@ -3220,7 +3319,7 @@ function assembleTransactionSummary(params) {
|
|
3220
3319
|
const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
|
3221
3320
|
let date;
|
3222
3321
|
if (time) {
|
3223
|
-
date =
|
3322
|
+
date = import_utils18.DateTime.fromTai64(time);
|
3224
3323
|
}
|
3225
3324
|
const transactionSummary = {
|
3226
3325
|
id,
|
@@ -3247,13 +3346,13 @@ function assembleTransactionSummary(params) {
|
|
3247
3346
|
}
|
3248
3347
|
|
3249
3348
|
// src/providers/transaction-response/getDecodedLogs.ts
|
3250
|
-
var
|
3251
|
-
var
|
3349
|
+
var import_abi_coder5 = require("@fuel-ts/abi-coder");
|
3350
|
+
var import_transactions17 = require("@fuel-ts/transactions");
|
3252
3351
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
3253
3352
|
return receipts.reduce((logs, receipt) => {
|
3254
|
-
if (receipt.type ===
|
3255
|
-
const interfaceToUse = new
|
3256
|
-
const data = receipt.type ===
|
3353
|
+
if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
|
3354
|
+
const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
|
3355
|
+
const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
|
3257
3356
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
|
3258
3357
|
logs.push(decodedLog);
|
3259
3358
|
}
|
@@ -3268,7 +3367,7 @@ var TransactionResponse = class {
|
|
3268
3367
|
/** Current provider */
|
3269
3368
|
provider;
|
3270
3369
|
/** Gas used on the transaction */
|
3271
|
-
gasUsed = (0,
|
3370
|
+
gasUsed = (0, import_math15.bn)(0);
|
3272
3371
|
/** The graphql Transaction with receipts object. */
|
3273
3372
|
gqlTransaction;
|
3274
3373
|
abis;
|
@@ -3326,8 +3425,8 @@ var TransactionResponse = class {
|
|
3326
3425
|
* @returns The decoded transaction.
|
3327
3426
|
*/
|
3328
3427
|
decodeTransaction(transactionWithReceipts) {
|
3329
|
-
return new
|
3330
|
-
(0,
|
3428
|
+
return new import_transactions18.TransactionCoder().decode(
|
3429
|
+
(0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
|
3331
3430
|
0
|
3332
3431
|
)?.[0];
|
3333
3432
|
}
|
@@ -3346,20 +3445,27 @@ var TransactionResponse = class {
|
|
3346
3445
|
const decodedTransaction = this.decodeTransaction(
|
3347
3446
|
transaction
|
3348
3447
|
);
|
3349
|
-
|
3350
|
-
|
3448
|
+
let txReceipts = [];
|
3449
|
+
if (transaction?.status && "receipts" in transaction.status) {
|
3450
|
+
txReceipts = transaction.status.receipts;
|
3451
|
+
}
|
3452
|
+
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3453
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3454
|
+
const gasPrice = await this.provider.getLatestGasPrice();
|
3351
3455
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3352
3456
|
const transactionSummary = assembleTransactionSummary({
|
3353
3457
|
id: this.id,
|
3354
3458
|
receipts,
|
3355
3459
|
transaction: decodedTransaction,
|
3356
|
-
transactionBytes: (0,
|
3460
|
+
transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
|
3357
3461
|
gqlTransactionStatus: transaction.status,
|
3358
3462
|
gasPerByte,
|
3359
3463
|
gasPriceFactor,
|
3360
3464
|
abiMap: contractsAbiMap,
|
3361
3465
|
maxInputs,
|
3362
|
-
gasCosts
|
3466
|
+
gasCosts,
|
3467
|
+
maxGasPerTx,
|
3468
|
+
gasPrice
|
3363
3469
|
});
|
3364
3470
|
return transactionSummary;
|
3365
3471
|
}
|
@@ -3486,29 +3592,29 @@ var processGqlChain = (chain) => {
|
|
3486
3592
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3487
3593
|
return {
|
3488
3594
|
name,
|
3489
|
-
baseChainHeight: (0,
|
3595
|
+
baseChainHeight: (0, import_math16.bn)(daHeight),
|
3490
3596
|
consensusParameters: {
|
3491
|
-
contractMaxSize: (0,
|
3492
|
-
maxInputs: (0,
|
3493
|
-
maxOutputs: (0,
|
3494
|
-
maxWitnesses: (0,
|
3495
|
-
maxGasPerTx: (0,
|
3496
|
-
maxScriptLength: (0,
|
3497
|
-
maxScriptDataLength: (0,
|
3498
|
-
maxStorageSlots: (0,
|
3499
|
-
maxPredicateLength: (0,
|
3500
|
-
maxPredicateDataLength: (0,
|
3501
|
-
maxGasPerPredicate: (0,
|
3502
|
-
gasPriceFactor: (0,
|
3503
|
-
gasPerByte: (0,
|
3504
|
-
maxMessageDataLength: (0,
|
3505
|
-
chainId: (0,
|
3597
|
+
contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
|
3598
|
+
maxInputs: (0, import_math16.bn)(txParams.maxInputs),
|
3599
|
+
maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
|
3600
|
+
maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
|
3601
|
+
maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
|
3602
|
+
maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
|
3603
|
+
maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
|
3604
|
+
maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
|
3605
|
+
maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
|
3606
|
+
maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
|
3607
|
+
maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
|
3608
|
+
gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
|
3609
|
+
gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
|
3610
|
+
maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
|
3611
|
+
chainId: (0, import_math16.bn)(consensusParameters.chainId),
|
3506
3612
|
gasCosts
|
3507
3613
|
},
|
3508
3614
|
gasCosts,
|
3509
3615
|
latestBlock: {
|
3510
3616
|
id: latestBlock.id,
|
3511
|
-
height: (0,
|
3617
|
+
height: (0, import_math16.bn)(latestBlock.height),
|
3512
3618
|
time: latestBlock.header.time,
|
3513
3619
|
transactions: latestBlock.transactions.map((i) => ({
|
3514
3620
|
id: i.id
|
@@ -3602,10 +3708,8 @@ var _Provider = class {
|
|
3602
3708
|
* Returns some helpful parameters related to gas fees.
|
3603
3709
|
*/
|
3604
3710
|
getGasConfig() {
|
3605
|
-
const { minGasPrice } = this.getNode();
|
3606
3711
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3607
3712
|
return {
|
3608
|
-
minGasPrice,
|
3609
3713
|
maxGasPerTx,
|
3610
3714
|
maxGasPerPredicate,
|
3611
3715
|
gasPriceFactor,
|
@@ -3703,7 +3807,7 @@ var _Provider = class {
|
|
3703
3807
|
*/
|
3704
3808
|
async getBlockNumber() {
|
3705
3809
|
const { chain } = await this.operations.getChain();
|
3706
|
-
return (0,
|
3810
|
+
return (0, import_math16.bn)(chain.latestBlock.height, 10);
|
3707
3811
|
}
|
3708
3812
|
/**
|
3709
3813
|
* Returns the chain information.
|
@@ -3713,13 +3817,11 @@ var _Provider = class {
|
|
3713
3817
|
async fetchNode() {
|
3714
3818
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3715
3819
|
const processedNodeInfo = {
|
3716
|
-
maxDepth: (0,
|
3717
|
-
maxTx: (0,
|
3718
|
-
minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
|
3820
|
+
maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
|
3821
|
+
maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
|
3719
3822
|
nodeVersion: nodeInfo.nodeVersion,
|
3720
3823
|
utxoValidation: nodeInfo.utxoValidation,
|
3721
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
3722
|
-
peers: nodeInfo.peers
|
3824
|
+
vmBacktrace: nodeInfo.vmBacktrace
|
3723
3825
|
};
|
3724
3826
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
3725
3827
|
return processedNodeInfo;
|
@@ -3761,9 +3863,9 @@ var _Provider = class {
|
|
3761
3863
|
if (estimateTxDependencies) {
|
3762
3864
|
await this.estimateTxDependencies(transactionRequest);
|
3763
3865
|
}
|
3764
|
-
const encodedTransaction = (0,
|
3866
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3765
3867
|
let abis;
|
3766
|
-
if (transactionRequest.type ===
|
3868
|
+
if (transactionRequest.type === import_transactions19.TransactionType.Script) {
|
3767
3869
|
abis = transactionRequest.abis;
|
3768
3870
|
}
|
3769
3871
|
if (awaitExecution) {
|
@@ -3804,15 +3906,14 @@ var _Provider = class {
|
|
3804
3906
|
if (estimateTxDependencies) {
|
3805
3907
|
return this.estimateTxDependencies(transactionRequest);
|
3806
3908
|
}
|
3807
|
-
const encodedTransaction = (0,
|
3808
|
-
const { dryRun:
|
3809
|
-
encodedTransaction,
|
3909
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3910
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
3911
|
+
encodedTransactions: encodedTransaction,
|
3810
3912
|
utxoValidation: utxoValidation || false
|
3811
3913
|
});
|
3812
|
-
const receipts =
|
3813
|
-
|
3814
|
-
|
3815
|
-
};
|
3914
|
+
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
3915
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
3916
|
+
return { receipts, dryrunStatus: status };
|
3816
3917
|
}
|
3817
3918
|
/**
|
3818
3919
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -3823,13 +3924,13 @@ var _Provider = class {
|
|
3823
3924
|
async estimatePredicates(transactionRequest) {
|
3824
3925
|
const shouldEstimatePredicates = Boolean(
|
3825
3926
|
transactionRequest.inputs.find(
|
3826
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
3927
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math16.BN(input.predicateGasUsed).isZero()
|
3827
3928
|
)
|
3828
3929
|
);
|
3829
3930
|
if (!shouldEstimatePredicates) {
|
3830
3931
|
return transactionRequest;
|
3831
3932
|
}
|
3832
|
-
const encodedTransaction = (0,
|
3933
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3833
3934
|
const response = await this.operations.estimatePredicates({
|
3834
3935
|
encodedTransaction
|
3835
3936
|
});
|
@@ -3838,7 +3939,7 @@ var _Provider = class {
|
|
3838
3939
|
} = response;
|
3839
3940
|
if (inputs) {
|
3840
3941
|
inputs.forEach((input, index) => {
|
3841
|
-
if ("predicateGasUsed" in input && (0,
|
3942
|
+
if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
|
3842
3943
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3843
3944
|
}
|
3844
3945
|
});
|
@@ -3851,31 +3952,31 @@ var _Provider = class {
|
|
3851
3952
|
* If there are missing variable outputs,
|
3852
3953
|
* `addVariableOutputs` is called on the transaction.
|
3853
3954
|
*
|
3854
|
-
* @privateRemarks
|
3855
|
-
* TODO: Investigate support for missing contract IDs
|
3856
|
-
* TODO: Add support for missing output messages
|
3857
3955
|
*
|
3858
3956
|
* @param transactionRequest - The transaction request object.
|
3859
3957
|
* @returns A promise.
|
3860
3958
|
*/
|
3861
3959
|
async estimateTxDependencies(transactionRequest) {
|
3862
|
-
if (transactionRequest.type ===
|
3960
|
+
if (transactionRequest.type === import_transactions19.TransactionType.Create) {
|
3863
3961
|
return {
|
3864
3962
|
receipts: [],
|
3865
3963
|
outputVariables: 0,
|
3866
3964
|
missingContractIds: []
|
3867
3965
|
};
|
3868
3966
|
}
|
3869
|
-
await this.estimatePredicates(transactionRequest);
|
3870
3967
|
let receipts = [];
|
3871
3968
|
const missingContractIds = [];
|
3872
3969
|
let outputVariables = 0;
|
3970
|
+
let dryrunStatus;
|
3873
3971
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3874
|
-
const {
|
3875
|
-
|
3972
|
+
const {
|
3973
|
+
dryRun: [{ receipts: rawReceipts, status }]
|
3974
|
+
} = await this.operations.dryRun({
|
3975
|
+
encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
|
3876
3976
|
utxoValidation: false
|
3877
3977
|
});
|
3878
|
-
receipts =
|
3978
|
+
receipts = rawReceipts.map(processGqlReceipt);
|
3979
|
+
dryrunStatus = status;
|
3879
3980
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
3880
3981
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
3881
3982
|
if (hasMissingOutputs) {
|
@@ -3885,6 +3986,10 @@ var _Provider = class {
|
|
3885
3986
|
transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
|
3886
3987
|
missingContractIds.push(contractId);
|
3887
3988
|
});
|
3989
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
3990
|
+
transactionRequest
|
3991
|
+
});
|
3992
|
+
transactionRequest.maxFee = maxFee;
|
3888
3993
|
} else {
|
3889
3994
|
break;
|
3890
3995
|
}
|
@@ -3892,7 +3997,139 @@ var _Provider = class {
|
|
3892
3997
|
return {
|
3893
3998
|
receipts,
|
3894
3999
|
outputVariables,
|
3895
|
-
missingContractIds
|
4000
|
+
missingContractIds,
|
4001
|
+
dryrunStatus
|
4002
|
+
};
|
4003
|
+
}
|
4004
|
+
/**
|
4005
|
+
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
4006
|
+
*
|
4007
|
+
* Transactions are dry run in batches. After each dry run, transactions requiring
|
4008
|
+
* further modifications are identified. The method iteratively updates these transactions
|
4009
|
+
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
4010
|
+
*
|
4011
|
+
* @param transactionRequests - Array of transaction request objects.
|
4012
|
+
* @returns A promise that resolves to an array of results for each transaction.
|
4013
|
+
*/
|
4014
|
+
async estimateMultipleTxDependencies(transactionRequests) {
|
4015
|
+
const results = transactionRequests.map(() => ({
|
4016
|
+
receipts: [],
|
4017
|
+
outputVariables: 0,
|
4018
|
+
missingContractIds: [],
|
4019
|
+
dryrunStatus: void 0
|
4020
|
+
}));
|
4021
|
+
const allRequests = (0, import_ramda3.clone)(transactionRequests);
|
4022
|
+
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4023
|
+
allRequests.forEach((req, index) => {
|
4024
|
+
if (req.type === import_transactions19.TransactionType.Script) {
|
4025
|
+
serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
|
4026
|
+
}
|
4027
|
+
});
|
4028
|
+
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
4029
|
+
let attempt = 0;
|
4030
|
+
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
4031
|
+
const encodedTransactions = transactionsToProcess.map(
|
4032
|
+
(index) => serializedTransactionsMap.get(index)
|
4033
|
+
);
|
4034
|
+
const dryRunResults = await this.operations.dryRun({
|
4035
|
+
encodedTransactions,
|
4036
|
+
utxoValidation: false
|
4037
|
+
});
|
4038
|
+
const nextRoundTransactions = [];
|
4039
|
+
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
4040
|
+
const currentResultIndex = transactionsToProcess[i];
|
4041
|
+
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4042
|
+
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
4043
|
+
results[currentResultIndex].dryrunStatus = status;
|
4044
|
+
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4045
|
+
results[currentResultIndex].receipts
|
4046
|
+
);
|
4047
|
+
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4048
|
+
const requestToProcess = allRequests[currentResultIndex];
|
4049
|
+
if (hasMissingOutputs && requestToProcess?.type === import_transactions19.TransactionType.Script) {
|
4050
|
+
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
4051
|
+
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
4052
|
+
missingOutputContractIds.forEach(({ contractId }) => {
|
4053
|
+
requestToProcess.addContractInputAndOutput(import_address3.Address.fromString(contractId));
|
4054
|
+
results[currentResultIndex].missingContractIds.push(contractId);
|
4055
|
+
});
|
4056
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
4057
|
+
transactionRequest: requestToProcess
|
4058
|
+
});
|
4059
|
+
requestToProcess.maxFee = maxFee;
|
4060
|
+
serializedTransactionsMap.set(
|
4061
|
+
currentResultIndex,
|
4062
|
+
(0, import_utils22.hexlify)(requestToProcess.toTransactionBytes())
|
4063
|
+
);
|
4064
|
+
nextRoundTransactions.push(currentResultIndex);
|
4065
|
+
allRequests[currentResultIndex] = requestToProcess;
|
4066
|
+
}
|
4067
|
+
}
|
4068
|
+
transactionsToProcess = nextRoundTransactions;
|
4069
|
+
attempt += 1;
|
4070
|
+
}
|
4071
|
+
return results;
|
4072
|
+
}
|
4073
|
+
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
4074
|
+
if (estimateTxDependencies) {
|
4075
|
+
return this.estimateMultipleTxDependencies(transactionRequests);
|
4076
|
+
}
|
4077
|
+
const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
|
4078
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4079
|
+
encodedTransactions,
|
4080
|
+
utxoValidation: utxoValidation || false
|
4081
|
+
});
|
4082
|
+
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4083
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
4084
|
+
return { receipts, dryrunStatus: status };
|
4085
|
+
});
|
4086
|
+
return results;
|
4087
|
+
}
|
4088
|
+
/**
|
4089
|
+
* Estimates the transaction gas and fee based on the provided transaction request.
|
4090
|
+
* @param transactionRequest - The transaction request object.
|
4091
|
+
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
4092
|
+
*/
|
4093
|
+
async estimateTxGasAndFee(params) {
|
4094
|
+
const { transactionRequest } = params;
|
4095
|
+
let { gasPrice } = params;
|
4096
|
+
const chainInfo = this.getChain();
|
4097
|
+
const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
|
4098
|
+
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
4099
|
+
if (!gasPrice) {
|
4100
|
+
gasPrice = await this.estimateGasPrice(10);
|
4101
|
+
}
|
4102
|
+
const minFee = calculateGasFee({
|
4103
|
+
gasPrice: (0, import_math16.bn)(gasPrice),
|
4104
|
+
gas: minGas,
|
4105
|
+
priceFactor: gasPriceFactor,
|
4106
|
+
tip: transactionRequest.tip
|
4107
|
+
}).add(1);
|
4108
|
+
let gasLimit = (0, import_math16.bn)(0);
|
4109
|
+
if (transactionRequest.type === import_transactions19.TransactionType.Script) {
|
4110
|
+
gasLimit = transactionRequest.gasLimit;
|
4111
|
+
if (transactionRequest.gasLimit.eq(0)) {
|
4112
|
+
transactionRequest.gasLimit = minGas;
|
4113
|
+
transactionRequest.gasLimit = maxGasPerTx.sub(
|
4114
|
+
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
4115
|
+
);
|
4116
|
+
gasLimit = transactionRequest.gasLimit;
|
4117
|
+
}
|
4118
|
+
}
|
4119
|
+
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4120
|
+
const maxFee = calculateGasFee({
|
4121
|
+
gasPrice: (0, import_math16.bn)(gasPrice),
|
4122
|
+
gas: maxGas,
|
4123
|
+
priceFactor: gasPriceFactor,
|
4124
|
+
tip: transactionRequest.tip
|
4125
|
+
}).add(1);
|
4126
|
+
return {
|
4127
|
+
minGas,
|
4128
|
+
minFee,
|
4129
|
+
maxGas,
|
4130
|
+
maxFee,
|
4131
|
+
gasPrice,
|
4132
|
+
gasLimit
|
3896
4133
|
};
|
3897
4134
|
}
|
3898
4135
|
/**
|
@@ -3910,15 +4147,17 @@ var _Provider = class {
|
|
3910
4147
|
if (estimateTxDependencies) {
|
3911
4148
|
return this.estimateTxDependencies(transactionRequest);
|
3912
4149
|
}
|
3913
|
-
const
|
3914
|
-
const { dryRun:
|
3915
|
-
|
4150
|
+
const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
|
4151
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4152
|
+
encodedTransactions,
|
3916
4153
|
utxoValidation: true
|
3917
4154
|
});
|
3918
|
-
const
|
3919
|
-
|
3920
|
-
receipts
|
3921
|
-
|
4155
|
+
const callResult = dryRunStatuses.map((dryRunStatus) => {
|
4156
|
+
const { id, receipts, status } = dryRunStatus;
|
4157
|
+
const processedReceipts = receipts.map(processGqlReceipt);
|
4158
|
+
return { id, receipts: processedReceipts, status };
|
4159
|
+
});
|
4160
|
+
return { receipts: callResult[0].receipts };
|
3922
4161
|
}
|
3923
4162
|
/**
|
3924
4163
|
* Returns a transaction cost to enable user
|
@@ -3935,80 +4174,79 @@ var _Provider = class {
|
|
3935
4174
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
3936
4175
|
* @returns A promise that resolves to the transaction cost object.
|
3937
4176
|
*/
|
3938
|
-
async getTransactionCost(transactionRequestLike,
|
3939
|
-
estimateTxDependencies = true,
|
3940
|
-
estimatePredicates = true,
|
3941
|
-
resourcesOwner,
|
3942
|
-
signatureCallback
|
3943
|
-
} = {}) {
|
4177
|
+
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
3944
4178
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
3945
|
-
const
|
3946
|
-
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
3947
|
-
const gasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
|
3948
|
-
const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
|
4179
|
+
const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
|
3949
4180
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
3950
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
4181
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
3951
4182
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
3952
|
-
|
3953
|
-
|
3954
|
-
|
3955
|
-
|
3956
|
-
|
3957
|
-
|
3958
|
-
}
|
3959
|
-
await this.estimatePredicates(txRequestClone);
|
4183
|
+
txRequestClone.maxFee = (0, import_math16.bn)(0);
|
4184
|
+
if (isScriptTransaction) {
|
4185
|
+
txRequestClone.gasLimit = (0, import_math16.bn)(0);
|
4186
|
+
}
|
4187
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4188
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
3960
4189
|
}
|
4190
|
+
const signedRequest = (0, import_ramda3.clone)(txRequestClone);
|
4191
|
+
let addedSignatures = 0;
|
3961
4192
|
if (signatureCallback && isScriptTransaction) {
|
3962
|
-
|
4193
|
+
const lengthBefore = signedRequest.witnesses.length;
|
4194
|
+
await signatureCallback(signedRequest);
|
4195
|
+
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
3963
4196
|
}
|
3964
|
-
|
3965
|
-
|
4197
|
+
await this.estimatePredicates(signedRequest);
|
4198
|
+
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
4199
|
+
transactionRequest: signedRequest
|
4200
|
+
});
|
3966
4201
|
let receipts = [];
|
3967
4202
|
let missingContractIds = [];
|
3968
4203
|
let outputVariables = 0;
|
3969
|
-
|
3970
|
-
|
3971
|
-
|
4204
|
+
let gasUsed = (0, import_math16.bn)(0);
|
4205
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4206
|
+
txRequestClone.maxFee = maxFee;
|
4207
|
+
if (isScriptTransaction) {
|
4208
|
+
txRequestClone.gasLimit = gasLimit;
|
4209
|
+
if (signatureCallback) {
|
4210
|
+
await signatureCallback(txRequestClone);
|
4211
|
+
}
|
3972
4212
|
const result = await this.estimateTxDependencies(txRequestClone);
|
3973
4213
|
receipts = result.receipts;
|
3974
4214
|
outputVariables = result.outputVariables;
|
3975
4215
|
missingContractIds = result.missingContractIds;
|
4216
|
+
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4217
|
+
txRequestClone.gasLimit = gasUsed;
|
4218
|
+
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
4219
|
+
transactionRequest: txRequestClone,
|
4220
|
+
gasPrice
|
4221
|
+
}));
|
3976
4222
|
}
|
3977
|
-
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
3978
|
-
const usedFee = calculatePriceWithFactor(
|
3979
|
-
gasUsed,
|
3980
|
-
gasPrice,
|
3981
|
-
gasPriceFactor
|
3982
|
-
).normalizeZeroToOne();
|
3983
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
3984
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
3985
4223
|
return {
|
3986
4224
|
requiredQuantities: allQuantities,
|
3987
4225
|
receipts,
|
3988
4226
|
gasUsed,
|
3989
|
-
minGasPrice,
|
3990
4227
|
gasPrice,
|
3991
4228
|
minGas,
|
3992
4229
|
maxGas,
|
3993
|
-
usedFee,
|
3994
4230
|
minFee,
|
3995
4231
|
maxFee,
|
3996
|
-
estimatedInputs: txRequestClone.inputs,
|
3997
4232
|
outputVariables,
|
3998
|
-
missingContractIds
|
4233
|
+
missingContractIds,
|
4234
|
+
addedSignatures,
|
4235
|
+
estimatedPredicates: txRequestClone.inputs
|
3999
4236
|
};
|
4000
4237
|
}
|
4001
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
4238
|
+
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
4002
4239
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4003
4240
|
const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
|
4004
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
4241
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, {
|
4242
|
+
quantitiesToContract
|
4243
|
+
});
|
4005
4244
|
transactionRequest.addResources(
|
4006
4245
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
4007
4246
|
);
|
4008
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4009
|
-
|
4010
|
-
|
4011
|
-
);
|
4247
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
|
4248
|
+
quantitiesToContract
|
4249
|
+
});
|
4012
4250
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
4013
4251
|
return {
|
4014
4252
|
resources,
|
@@ -4024,17 +4262,16 @@ var _Provider = class {
|
|
4024
4262
|
const result = await this.operations.getCoins({
|
4025
4263
|
first: 10,
|
4026
4264
|
...paginationArgs,
|
4027
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
4265
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
|
4028
4266
|
});
|
4029
4267
|
const coins = result.coins.edges.map((edge) => edge.node);
|
4030
4268
|
return coins.map((coin) => ({
|
4031
4269
|
id: coin.utxoId,
|
4032
4270
|
assetId: coin.assetId,
|
4033
|
-
amount: (0,
|
4271
|
+
amount: (0, import_math16.bn)(coin.amount),
|
4034
4272
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4035
|
-
|
4036
|
-
|
4037
|
-
txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
|
4273
|
+
blockCreated: (0, import_math16.bn)(coin.blockCreated),
|
4274
|
+
txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
|
4038
4275
|
}));
|
4039
4276
|
}
|
4040
4277
|
/**
|
@@ -4048,19 +4285,19 @@ var _Provider = class {
|
|
4048
4285
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4049
4286
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4050
4287
|
const excludeInput = {
|
4051
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
4052
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
4288
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
|
4289
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
|
4053
4290
|
};
|
4054
4291
|
if (this.cache) {
|
4055
4292
|
const uniqueUtxos = new Set(
|
4056
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
4293
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
|
4057
4294
|
);
|
4058
4295
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
4059
4296
|
}
|
4060
4297
|
const coinsQuery = {
|
4061
4298
|
owner: ownerAddress.toB256(),
|
4062
4299
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4063
|
-
assetId: (0,
|
4300
|
+
assetId: (0, import_utils22.hexlify)(assetId),
|
4064
4301
|
amount: amount.toString(10),
|
4065
4302
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4066
4303
|
})),
|
@@ -4071,9 +4308,9 @@ var _Provider = class {
|
|
4071
4308
|
switch (coin.__typename) {
|
4072
4309
|
case "MessageCoin":
|
4073
4310
|
return {
|
4074
|
-
amount: (0,
|
4311
|
+
amount: (0, import_math16.bn)(coin.amount),
|
4075
4312
|
assetId: coin.assetId,
|
4076
|
-
daHeight: (0,
|
4313
|
+
daHeight: (0, import_math16.bn)(coin.daHeight),
|
4077
4314
|
sender: import_address3.Address.fromAddressOrString(coin.sender),
|
4078
4315
|
recipient: import_address3.Address.fromAddressOrString(coin.recipient),
|
4079
4316
|
nonce: coin.nonce
|
@@ -4081,12 +4318,11 @@ var _Provider = class {
|
|
4081
4318
|
case "Coin":
|
4082
4319
|
return {
|
4083
4320
|
id: coin.utxoId,
|
4084
|
-
amount: (0,
|
4321
|
+
amount: (0, import_math16.bn)(coin.amount),
|
4085
4322
|
assetId: coin.assetId,
|
4086
4323
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4087
|
-
|
4088
|
-
|
4089
|
-
txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
|
4324
|
+
blockCreated: (0, import_math16.bn)(coin.blockCreated),
|
4325
|
+
txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
|
4090
4326
|
};
|
4091
4327
|
default:
|
4092
4328
|
return null;
|
@@ -4103,13 +4339,13 @@ var _Provider = class {
|
|
4103
4339
|
async getBlock(idOrHeight) {
|
4104
4340
|
let variables;
|
4105
4341
|
if (typeof idOrHeight === "number") {
|
4106
|
-
variables = { height: (0,
|
4342
|
+
variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
|
4107
4343
|
} else if (idOrHeight === "latest") {
|
4108
4344
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4109
4345
|
} else if (idOrHeight.length === 66) {
|
4110
4346
|
variables = { blockId: idOrHeight };
|
4111
4347
|
} else {
|
4112
|
-
variables = { blockId: (0,
|
4348
|
+
variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
|
4113
4349
|
}
|
4114
4350
|
const { block } = await this.operations.getBlock(variables);
|
4115
4351
|
if (!block) {
|
@@ -4117,7 +4353,7 @@ var _Provider = class {
|
|
4117
4353
|
}
|
4118
4354
|
return {
|
4119
4355
|
id: block.id,
|
4120
|
-
height: (0,
|
4356
|
+
height: (0, import_math16.bn)(block.height),
|
4121
4357
|
time: block.header.time,
|
4122
4358
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4123
4359
|
};
|
@@ -4132,7 +4368,7 @@ var _Provider = class {
|
|
4132
4368
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4133
4369
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4134
4370
|
id: block.id,
|
4135
|
-
height: (0,
|
4371
|
+
height: (0, import_math16.bn)(block.height),
|
4136
4372
|
time: block.header.time,
|
4137
4373
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4138
4374
|
}));
|
@@ -4147,7 +4383,7 @@ var _Provider = class {
|
|
4147
4383
|
async getBlockWithTransactions(idOrHeight) {
|
4148
4384
|
let variables;
|
4149
4385
|
if (typeof idOrHeight === "number") {
|
4150
|
-
variables = { blockHeight: (0,
|
4386
|
+
variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
|
4151
4387
|
} else if (idOrHeight === "latest") {
|
4152
4388
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4153
4389
|
} else {
|
@@ -4159,11 +4395,11 @@ var _Provider = class {
|
|
4159
4395
|
}
|
4160
4396
|
return {
|
4161
4397
|
id: block.id,
|
4162
|
-
height: (0,
|
4398
|
+
height: (0, import_math16.bn)(block.height, 10),
|
4163
4399
|
time: block.header.time,
|
4164
4400
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4165
4401
|
transactions: block.transactions.map(
|
4166
|
-
(tx) => new
|
4402
|
+
(tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
|
4167
4403
|
)
|
4168
4404
|
};
|
4169
4405
|
}
|
@@ -4178,8 +4414,8 @@ var _Provider = class {
|
|
4178
4414
|
if (!transaction) {
|
4179
4415
|
return null;
|
4180
4416
|
}
|
4181
|
-
return new
|
4182
|
-
(0,
|
4417
|
+
return new import_transactions19.TransactionCoder().decode(
|
4418
|
+
(0, import_utils22.arrayify)(transaction.rawPayload),
|
4183
4419
|
0
|
4184
4420
|
)?.[0];
|
4185
4421
|
}
|
@@ -4206,9 +4442,9 @@ var _Provider = class {
|
|
4206
4442
|
async getContractBalance(contractId, assetId) {
|
4207
4443
|
const { contractBalance } = await this.operations.getContractBalance({
|
4208
4444
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4209
|
-
asset: (0,
|
4445
|
+
asset: (0, import_utils22.hexlify)(assetId)
|
4210
4446
|
});
|
4211
|
-
return (0,
|
4447
|
+
return (0, import_math16.bn)(contractBalance.amount, 10);
|
4212
4448
|
}
|
4213
4449
|
/**
|
4214
4450
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4220,9 +4456,9 @@ var _Provider = class {
|
|
4220
4456
|
async getBalance(owner, assetId) {
|
4221
4457
|
const { balance } = await this.operations.getBalance({
|
4222
4458
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4223
|
-
assetId: (0,
|
4459
|
+
assetId: (0, import_utils22.hexlify)(assetId)
|
4224
4460
|
});
|
4225
|
-
return (0,
|
4461
|
+
return (0, import_math16.bn)(balance.amount, 10);
|
4226
4462
|
}
|
4227
4463
|
/**
|
4228
4464
|
* Returns balances for the given owner.
|
@@ -4240,7 +4476,7 @@ var _Provider = class {
|
|
4240
4476
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4241
4477
|
return balances.map((balance) => ({
|
4242
4478
|
assetId: balance.assetId,
|
4243
|
-
amount: (0,
|
4479
|
+
amount: (0, import_math16.bn)(balance.amount)
|
4244
4480
|
}));
|
4245
4481
|
}
|
4246
4482
|
/**
|
@@ -4258,19 +4494,19 @@ var _Provider = class {
|
|
4258
4494
|
});
|
4259
4495
|
const messages = result.messages.edges.map((edge) => edge.node);
|
4260
4496
|
return messages.map((message) => ({
|
4261
|
-
messageId:
|
4497
|
+
messageId: import_transactions19.InputMessageCoder.getMessageId({
|
4262
4498
|
sender: message.sender,
|
4263
4499
|
recipient: message.recipient,
|
4264
4500
|
nonce: message.nonce,
|
4265
|
-
amount: (0,
|
4501
|
+
amount: (0, import_math16.bn)(message.amount),
|
4266
4502
|
data: message.data
|
4267
4503
|
}),
|
4268
4504
|
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4269
4505
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4270
4506
|
nonce: message.nonce,
|
4271
|
-
amount: (0,
|
4272
|
-
data:
|
4273
|
-
daHeight: (0,
|
4507
|
+
amount: (0, import_math16.bn)(message.amount),
|
4508
|
+
data: import_transactions19.InputMessageCoder.decodeData(message.data),
|
4509
|
+
daHeight: (0, import_math16.bn)(message.daHeight)
|
4274
4510
|
}));
|
4275
4511
|
}
|
4276
4512
|
/**
|
@@ -4323,44 +4559,60 @@ var _Provider = class {
|
|
4323
4559
|
} = result.messageProof;
|
4324
4560
|
return {
|
4325
4561
|
messageProof: {
|
4326
|
-
proofIndex: (0,
|
4562
|
+
proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
|
4327
4563
|
proofSet: messageProof.proofSet
|
4328
4564
|
},
|
4329
4565
|
blockProof: {
|
4330
|
-
proofIndex: (0,
|
4566
|
+
proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
|
4331
4567
|
proofSet: blockProof.proofSet
|
4332
4568
|
},
|
4333
4569
|
messageBlockHeader: {
|
4334
4570
|
id: messageBlockHeader.id,
|
4335
|
-
daHeight: (0,
|
4336
|
-
transactionsCount: (0,
|
4571
|
+
daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
|
4572
|
+
transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
|
4337
4573
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4338
|
-
height: (0,
|
4574
|
+
height: (0, import_math16.bn)(messageBlockHeader.height),
|
4339
4575
|
prevRoot: messageBlockHeader.prevRoot,
|
4340
4576
|
time: messageBlockHeader.time,
|
4341
4577
|
applicationHash: messageBlockHeader.applicationHash,
|
4342
|
-
|
4343
|
-
|
4578
|
+
messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
|
4579
|
+
messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
|
4580
|
+
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4581
|
+
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4582
|
+
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4344
4583
|
},
|
4345
4584
|
commitBlockHeader: {
|
4346
4585
|
id: commitBlockHeader.id,
|
4347
|
-
daHeight: (0,
|
4348
|
-
transactionsCount: (0,
|
4586
|
+
daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
|
4587
|
+
transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
|
4349
4588
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4350
|
-
height: (0,
|
4589
|
+
height: (0, import_math16.bn)(commitBlockHeader.height),
|
4351
4590
|
prevRoot: commitBlockHeader.prevRoot,
|
4352
4591
|
time: commitBlockHeader.time,
|
4353
4592
|
applicationHash: commitBlockHeader.applicationHash,
|
4354
|
-
|
4355
|
-
|
4593
|
+
messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
|
4594
|
+
messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
|
4595
|
+
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4596
|
+
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4597
|
+
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4356
4598
|
},
|
4357
4599
|
sender: import_address3.Address.fromAddressOrString(sender),
|
4358
4600
|
recipient: import_address3.Address.fromAddressOrString(recipient),
|
4359
4601
|
nonce,
|
4360
|
-
amount: (0,
|
4602
|
+
amount: (0, import_math16.bn)(amount),
|
4361
4603
|
data
|
4362
4604
|
};
|
4363
4605
|
}
|
4606
|
+
async getLatestGasPrice() {
|
4607
|
+
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4608
|
+
return (0, import_math16.bn)(latestGasPrice.gasPrice);
|
4609
|
+
}
|
4610
|
+
async estimateGasPrice(blockHorizon) {
|
4611
|
+
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4612
|
+
blockHorizon: String(blockHorizon)
|
4613
|
+
});
|
4614
|
+
return (0, import_math16.bn)(estimateGasPrice.gasPrice);
|
4615
|
+
}
|
4364
4616
|
/**
|
4365
4617
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
4366
4618
|
*
|
@@ -4380,10 +4632,10 @@ var _Provider = class {
|
|
4380
4632
|
*/
|
4381
4633
|
async produceBlocks(amount, startTime) {
|
4382
4634
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4383
|
-
blocksToProduce: (0,
|
4384
|
-
startTimestamp: startTime ?
|
4635
|
+
blocksToProduce: (0, import_math16.bn)(amount).toString(10),
|
4636
|
+
startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4385
4637
|
});
|
4386
|
-
return (0,
|
4638
|
+
return (0, import_math16.bn)(latestBlockHeight);
|
4387
4639
|
}
|
4388
4640
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4389
4641
|
async getTransactionResponse(transactionId) {
|
@@ -4397,7 +4649,7 @@ cacheInputs_fn = function(inputs) {
|
|
4397
4649
|
return;
|
4398
4650
|
}
|
4399
4651
|
inputs.forEach((input) => {
|
4400
|
-
if (input.type ===
|
4652
|
+
if (input.type === import_transactions19.InputType.Coin) {
|
4401
4653
|
this.cache?.set(input.id);
|
4402
4654
|
}
|
4403
4655
|
});
|
@@ -4407,9 +4659,9 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4407
4659
|
|
4408
4660
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4409
4661
|
var import_errors15 = require("@fuel-ts/errors");
|
4410
|
-
var
|
4411
|
-
var
|
4412
|
-
var
|
4662
|
+
var import_math17 = require("@fuel-ts/math");
|
4663
|
+
var import_transactions20 = require("@fuel-ts/transactions");
|
4664
|
+
var import_utils25 = require("@fuel-ts/utils");
|
4413
4665
|
|
4414
4666
|
// src/providers/chains.ts
|
4415
4667
|
var CHAIN_IDS = {
|
@@ -4457,18 +4709,18 @@ var assets = [
|
|
4457
4709
|
];
|
4458
4710
|
|
4459
4711
|
// src/utils/formatTransferToContractScriptData.ts
|
4460
|
-
var
|
4461
|
-
var
|
4462
|
-
var
|
4712
|
+
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
4713
|
+
var import_math18 = require("@fuel-ts/math");
|
4714
|
+
var import_utils26 = require("@fuel-ts/utils");
|
4463
4715
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4464
4716
|
var formatTransferToContractScriptData = (params) => {
|
4465
4717
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4466
|
-
const numberCoder = new
|
4467
|
-
const encoded = numberCoder.encode(new
|
4718
|
+
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
4719
|
+
const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
|
4468
4720
|
const scriptData = Uint8Array.from([
|
4469
|
-
...(0,
|
4721
|
+
...(0, import_utils26.arrayify)(hexlifiedContractId),
|
4470
4722
|
...encoded,
|
4471
|
-
...(0,
|
4723
|
+
...(0, import_utils26.arrayify)(assetId)
|
4472
4724
|
]);
|
4473
4725
|
return scriptData;
|
4474
4726
|
};
|
@@ -4653,36 +4905,33 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4653
4905
|
* @param fee - The estimated transaction fee.
|
4654
4906
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4655
4907
|
*/
|
4656
|
-
async fund(request,
|
4657
|
-
const
|
4658
|
-
|
4908
|
+
async fund(request, params) {
|
4909
|
+
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
4910
|
+
const txRequest = request;
|
4911
|
+
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
4912
|
+
amount: (0, import_math19.bn)(fee),
|
4659
4913
|
assetId: import_configs12.BaseAssetId,
|
4660
|
-
coinQuantities
|
4914
|
+
coinQuantities: requiredQuantities
|
4661
4915
|
});
|
4662
4916
|
const quantitiesDict = {};
|
4663
|
-
|
4917
|
+
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
4664
4918
|
quantitiesDict[assetId] = {
|
4665
4919
|
required: amount,
|
4666
|
-
owned: (0,
|
4920
|
+
owned: (0, import_math19.bn)(0)
|
4667
4921
|
};
|
4668
4922
|
});
|
4669
|
-
|
4670
|
-
const cachedMessages = [];
|
4671
|
-
const owner = this.address.toB256();
|
4672
|
-
request.inputs.forEach((input) => {
|
4923
|
+
txRequest.inputs.forEach((input) => {
|
4673
4924
|
const isResource = "amount" in input;
|
4674
4925
|
if (isResource) {
|
4675
4926
|
const isCoin2 = "owner" in input;
|
4676
4927
|
if (isCoin2) {
|
4677
4928
|
const assetId = String(input.assetId);
|
4678
|
-
if (
|
4679
|
-
const amount = (0,
|
4929
|
+
if (quantitiesDict[assetId]) {
|
4930
|
+
const amount = (0, import_math19.bn)(input.amount);
|
4680
4931
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4681
|
-
cachedUtxos.push(input.id);
|
4682
4932
|
}
|
4683
|
-
} else if (input.
|
4933
|
+
} else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
|
4684
4934
|
quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
|
4685
|
-
cachedMessages.push(input.nonce);
|
4686
4935
|
}
|
4687
4936
|
}
|
4688
4937
|
});
|
@@ -4697,12 +4946,23 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4697
4946
|
});
|
4698
4947
|
const needsToBeFunded = missingQuantities.length;
|
4699
4948
|
if (needsToBeFunded) {
|
4700
|
-
const
|
4701
|
-
|
4702
|
-
|
4703
|
-
|
4704
|
-
|
4949
|
+
const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
|
4950
|
+
const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
|
4951
|
+
txRequest.addResources(resources);
|
4952
|
+
}
|
4953
|
+
txRequest.shiftPredicateData();
|
4954
|
+
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
4955
|
+
const requestToBeReEstimate = (0, import_ramda4.clone)(txRequest);
|
4956
|
+
if (addedSignatures) {
|
4957
|
+
Array.from({ length: addedSignatures }).forEach(
|
4958
|
+
() => requestToBeReEstimate.addEmptyWitness()
|
4959
|
+
);
|
4705
4960
|
}
|
4961
|
+
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
4962
|
+
transactionRequest: requestToBeReEstimate
|
4963
|
+
});
|
4964
|
+
txRequest.maxFee = maxFee;
|
4965
|
+
return txRequest;
|
4706
4966
|
}
|
4707
4967
|
/**
|
4708
4968
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -4710,28 +4970,25 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4710
4970
|
* @param destination - The address of the destination.
|
4711
4971
|
* @param amount - The amount of coins to transfer.
|
4712
4972
|
* @param assetId - The asset ID of the coins to transfer.
|
4713
|
-
* @param txParams - The transaction parameters (gasLimit,
|
4973
|
+
* @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
|
4714
4974
|
* @returns A promise that resolves to the prepared transaction request.
|
4715
4975
|
*/
|
4716
4976
|
async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
4717
|
-
const
|
4718
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
4719
|
-
const request = new ScriptTransactionRequest(params);
|
4977
|
+
const request = new ScriptTransactionRequest(txParams);
|
4720
4978
|
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
|
4721
|
-
const
|
4979
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
4722
4980
|
estimateTxDependencies: true,
|
4723
4981
|
resourcesOwner: this
|
4724
4982
|
});
|
4725
|
-
|
4726
|
-
|
4727
|
-
|
4728
|
-
|
4729
|
-
|
4730
|
-
|
4731
|
-
|
4732
|
-
|
4733
|
-
await this.fund(request,
|
4734
|
-
request.updatePredicateInputs(estimatedInputs);
|
4983
|
+
if ("gasLimit" in txParams) {
|
4984
|
+
this.validateGas({
|
4985
|
+
gasUsed: txCost.gasUsed,
|
4986
|
+
gasLimit: request.gasLimit
|
4987
|
+
});
|
4988
|
+
}
|
4989
|
+
request.gasLimit = txCost.gasUsed;
|
4990
|
+
request.maxFee = txCost.maxFee;
|
4991
|
+
await this.fund(request, txCost);
|
4735
4992
|
return request;
|
4736
4993
|
}
|
4737
4994
|
/**
|
@@ -4744,7 +5001,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4744
5001
|
* @returns A promise that resolves to the transaction response.
|
4745
5002
|
*/
|
4746
5003
|
async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
4747
|
-
if ((0,
|
5004
|
+
if ((0, import_math19.bn)(amount).lte(0)) {
|
4748
5005
|
throw new import_errors16.FuelError(
|
4749
5006
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
4750
5007
|
"Transfer amount must be a positive number."
|
@@ -4763,38 +5020,37 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4763
5020
|
* @returns A promise that resolves to the transaction response.
|
4764
5021
|
*/
|
4765
5022
|
async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
4766
|
-
if ((0,
|
5023
|
+
if ((0, import_math19.bn)(amount).lte(0)) {
|
4767
5024
|
throw new import_errors16.FuelError(
|
4768
5025
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
4769
5026
|
"Transfer amount must be a positive number."
|
4770
5027
|
);
|
4771
5028
|
}
|
4772
5029
|
const contractAddress = import_address4.Address.fromAddressOrString(contractId);
|
4773
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
4774
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
4775
5030
|
const { script, scriptData } = await assembleTransferToContractScript({
|
4776
5031
|
hexlifiedContractId: contractAddress.toB256(),
|
4777
|
-
amountToTransfer: (0,
|
5032
|
+
amountToTransfer: (0, import_math19.bn)(amount),
|
4778
5033
|
assetId
|
4779
5034
|
});
|
4780
5035
|
const request = new ScriptTransactionRequest({
|
4781
|
-
...
|
5036
|
+
...txParams,
|
4782
5037
|
script,
|
4783
5038
|
scriptData
|
4784
5039
|
});
|
4785
5040
|
request.addContractInputAndOutput(contractAddress);
|
4786
|
-
const
|
4787
|
-
|
4788
|
-
[{ amount: (0,
|
4789
|
-
);
|
4790
|
-
request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
|
4791
|
-
this.validateGas({
|
4792
|
-
gasUsed,
|
4793
|
-
gasPrice: request.gasPrice,
|
4794
|
-
gasLimit: request.gasLimit,
|
4795
|
-
minGasPrice
|
5041
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
5042
|
+
resourcesOwner: this,
|
5043
|
+
quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
|
4796
5044
|
});
|
4797
|
-
|
5045
|
+
if (txParams.gasLimit) {
|
5046
|
+
this.validateGas({
|
5047
|
+
gasUsed: txCost.gasUsed,
|
5048
|
+
gasLimit: request.gasLimit
|
5049
|
+
});
|
5050
|
+
}
|
5051
|
+
request.gasLimit = txCost.gasUsed;
|
5052
|
+
request.maxFee = txCost.maxFee;
|
5053
|
+
await this.fund(request, txCost);
|
4798
5054
|
return this.sendTransaction(request);
|
4799
5055
|
}
|
4800
5056
|
/**
|
@@ -4806,34 +5062,31 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4806
5062
|
* @returns A promise that resolves to the transaction response.
|
4807
5063
|
*/
|
4808
5064
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4809
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
4810
5065
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
4811
|
-
const recipientDataArray = (0,
|
5066
|
+
const recipientDataArray = (0, import_utils27.arrayify)(
|
4812
5067
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
4813
5068
|
);
|
4814
|
-
const amountDataArray = (0,
|
4815
|
-
"0x".concat((0,
|
5069
|
+
const amountDataArray = (0, import_utils27.arrayify)(
|
5070
|
+
"0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
4816
5071
|
);
|
4817
5072
|
const script = new Uint8Array([
|
4818
|
-
...(0,
|
5073
|
+
...(0, import_utils27.arrayify)(withdrawScript.bytes),
|
4819
5074
|
...recipientDataArray,
|
4820
5075
|
...amountDataArray
|
4821
5076
|
]);
|
4822
|
-
const params = { script,
|
5077
|
+
const params = { script, ...txParams };
|
4823
5078
|
const request = new ScriptTransactionRequest(params);
|
4824
|
-
const
|
4825
|
-
const
|
4826
|
-
|
4827
|
-
|
4828
|
-
|
4829
|
-
|
4830
|
-
|
4831
|
-
|
4832
|
-
|
4833
|
-
|
4834
|
-
|
4835
|
-
});
|
4836
|
-
await this.fund(request, requiredQuantities, maxFee);
|
5079
|
+
const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: import_configs12.BaseAssetId }];
|
5080
|
+
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5081
|
+
if (txParams.gasLimit) {
|
5082
|
+
this.validateGas({
|
5083
|
+
gasUsed: txCost.gasUsed,
|
5084
|
+
gasLimit: request.gasLimit
|
5085
|
+
});
|
5086
|
+
}
|
5087
|
+
request.maxFee = txCost.maxFee;
|
5088
|
+
request.gasLimit = txCost.gasUsed;
|
5089
|
+
await this.fund(request, txCost);
|
4837
5090
|
return this.sendTransaction(request);
|
4838
5091
|
}
|
4839
5092
|
async signMessage(message) {
|
@@ -4891,18 +5144,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4891
5144
|
}
|
4892
5145
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
4893
5146
|
}
|
4894
|
-
validateGas({
|
4895
|
-
gasUsed,
|
4896
|
-
gasPrice,
|
4897
|
-
gasLimit,
|
4898
|
-
minGasPrice
|
4899
|
-
}) {
|
4900
|
-
if (minGasPrice.gt(gasPrice)) {
|
4901
|
-
throw new import_errors16.FuelError(
|
4902
|
-
import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
|
4903
|
-
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
4904
|
-
);
|
4905
|
-
}
|
5147
|
+
validateGas({ gasUsed, gasLimit }) {
|
4906
5148
|
if (gasUsed.gt(gasLimit)) {
|
4907
5149
|
throw new import_errors16.FuelError(
|
4908
5150
|
import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
|
@@ -4914,10 +5156,10 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4914
5156
|
|
4915
5157
|
// src/signer/signer.ts
|
4916
5158
|
var import_address5 = require("@fuel-ts/address");
|
4917
|
-
var
|
5159
|
+
var import_crypto2 = require("@fuel-ts/crypto");
|
4918
5160
|
var import_hasher2 = require("@fuel-ts/hasher");
|
4919
|
-
var
|
4920
|
-
var
|
5161
|
+
var import_math20 = require("@fuel-ts/math");
|
5162
|
+
var import_utils28 = require("@fuel-ts/utils");
|
4921
5163
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
4922
5164
|
var Signer = class {
|
4923
5165
|
address;
|
@@ -4936,10 +5178,10 @@ var Signer = class {
|
|
4936
5178
|
privateKey = `0x${privateKey}`;
|
4937
5179
|
}
|
4938
5180
|
}
|
4939
|
-
const privateKeyBytes = (0,
|
4940
|
-
this.privateKey = (0,
|
4941
|
-
this.publicKey = (0,
|
4942
|
-
this.compressedPublicKey = (0,
|
5181
|
+
const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
|
5182
|
+
this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
|
5183
|
+
this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5184
|
+
this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
4943
5185
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
4944
5186
|
}
|
4945
5187
|
/**
|
@@ -4953,11 +5195,11 @@ var Signer = class {
|
|
4953
5195
|
* @returns hashed signature
|
4954
5196
|
*/
|
4955
5197
|
sign(data) {
|
4956
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
4957
|
-
const r = (0,
|
4958
|
-
const s = (0,
|
5198
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
|
5199
|
+
const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5200
|
+
const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
4959
5201
|
s[0] |= (signature.recovery || 0) << 7;
|
4960
|
-
return (0,
|
5202
|
+
return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
|
4961
5203
|
}
|
4962
5204
|
/**
|
4963
5205
|
* Add point on the current elliptic curve
|
@@ -4966,8 +5208,8 @@ var Signer = class {
|
|
4966
5208
|
* @returns compressed point on the curve
|
4967
5209
|
*/
|
4968
5210
|
addPoint(point) {
|
4969
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
4970
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5211
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
|
5212
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
|
4971
5213
|
const result = p0.add(p1);
|
4972
5214
|
return `0x${result.toHex(true)}`;
|
4973
5215
|
}
|
@@ -4979,16 +5221,16 @@ var Signer = class {
|
|
4979
5221
|
* @returns public key from signature from the
|
4980
5222
|
*/
|
4981
5223
|
static recoverPublicKey(data, signature) {
|
4982
|
-
const signedMessageBytes = (0,
|
5224
|
+
const signedMessageBytes = (0, import_utils28.arrayify)(signature);
|
4983
5225
|
const r = signedMessageBytes.slice(0, 32);
|
4984
5226
|
const s = signedMessageBytes.slice(32, 64);
|
4985
5227
|
const recoveryParam = (s[0] & 128) >> 7;
|
4986
5228
|
s[0] &= 127;
|
4987
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5229
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
|
4988
5230
|
recoveryParam
|
4989
5231
|
);
|
4990
|
-
const publicKey = sig.recoverPublicKey((0,
|
4991
|
-
return (0,
|
5232
|
+
const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
|
5233
|
+
return (0, import_utils28.hexlify)(publicKey);
|
4992
5234
|
}
|
4993
5235
|
/**
|
4994
5236
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5007,7 +5249,7 @@ var Signer = class {
|
|
5007
5249
|
* @returns random 32-byte hashed
|
5008
5250
|
*/
|
5009
5251
|
static generatePrivateKey(entropy) {
|
5010
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5252
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
|
5011
5253
|
}
|
5012
5254
|
/**
|
5013
5255
|
* Extended publicKey from a compact publicKey
|
@@ -5016,16 +5258,16 @@ var Signer = class {
|
|
5016
5258
|
* @returns extended publicKey
|
5017
5259
|
*/
|
5018
5260
|
static extendPublicKey(publicKey) {
|
5019
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5020
|
-
return (0,
|
5261
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
|
5262
|
+
return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
|
5021
5263
|
}
|
5022
5264
|
};
|
5023
5265
|
|
5024
5266
|
// src/wallet/keystore-wallet.ts
|
5025
5267
|
var import_address6 = require("@fuel-ts/address");
|
5026
|
-
var
|
5268
|
+
var import_crypto3 = require("@fuel-ts/crypto");
|
5027
5269
|
var import_errors17 = require("@fuel-ts/errors");
|
5028
|
-
var
|
5270
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5029
5271
|
var import_uuid = require("uuid");
|
5030
5272
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5031
5273
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5039,22 +5281,22 @@ var removeHexPrefix = (hexString) => {
|
|
5039
5281
|
return hexString;
|
5040
5282
|
};
|
5041
5283
|
async function encryptKeystoreWallet(privateKey, address, password) {
|
5042
|
-
const privateKeyBuffer = (0,
|
5284
|
+
const privateKeyBuffer = (0, import_crypto3.bufferFromString)(removeHexPrefix(privateKey), "hex");
|
5043
5285
|
const ownerAddress = import_address6.Address.fromAddressOrString(address);
|
5044
|
-
const salt = (0,
|
5045
|
-
const key = (0,
|
5046
|
-
password: (0,
|
5286
|
+
const salt = (0, import_crypto3.randomBytes)(DEFAULT_KEY_SIZE);
|
5287
|
+
const key = (0, import_crypto3.scrypt)({
|
5288
|
+
password: (0, import_crypto3.bufferFromString)(password),
|
5047
5289
|
salt,
|
5048
5290
|
dklen: DEFAULT_KEY_SIZE,
|
5049
5291
|
n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
|
5050
5292
|
r: DEFAULT_KDF_PARAMS_R,
|
5051
5293
|
p: DEFAULT_KDF_PARAMS_P
|
5052
5294
|
});
|
5053
|
-
const iv = (0,
|
5054
|
-
const ciphertext = await (0,
|
5295
|
+
const iv = (0, import_crypto3.randomBytes)(DEFAULT_IV_SIZE);
|
5296
|
+
const ciphertext = await (0, import_crypto3.encryptJsonWalletData)(privateKeyBuffer, key, iv);
|
5055
5297
|
const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
|
5056
|
-
const macHashUint8Array = (0,
|
5057
|
-
const mac = (0,
|
5298
|
+
const macHashUint8Array = (0, import_crypto3.keccak256)(data);
|
5299
|
+
const mac = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
|
5058
5300
|
const keystore = {
|
5059
5301
|
id: (0, import_uuid.v4)(),
|
5060
5302
|
version: 3,
|
@@ -5062,15 +5304,15 @@ async function encryptKeystoreWallet(privateKey, address, password) {
|
|
5062
5304
|
crypto: {
|
5063
5305
|
cipher: "aes-128-ctr",
|
5064
5306
|
mac,
|
5065
|
-
cipherparams: { iv: (0,
|
5066
|
-
ciphertext: (0,
|
5307
|
+
cipherparams: { iv: (0, import_crypto3.stringFromBuffer)(iv, "hex") },
|
5308
|
+
ciphertext: (0, import_crypto3.stringFromBuffer)(ciphertext, "hex"),
|
5067
5309
|
kdf: "scrypt",
|
5068
5310
|
kdfparams: {
|
5069
5311
|
dklen: DEFAULT_KEY_SIZE,
|
5070
5312
|
n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
|
5071
5313
|
p: DEFAULT_KDF_PARAMS_P,
|
5072
5314
|
r: DEFAULT_KDF_PARAMS_R,
|
5073
|
-
salt: (0,
|
5315
|
+
salt: (0, import_crypto3.stringFromBuffer)(salt, "hex")
|
5074
5316
|
}
|
5075
5317
|
}
|
5076
5318
|
};
|
@@ -5086,11 +5328,11 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5086
5328
|
kdfparams: { dklen, n, r, p, salt }
|
5087
5329
|
}
|
5088
5330
|
} = keystoreWallet;
|
5089
|
-
const ciphertextBuffer = (0,
|
5090
|
-
const ivBuffer = (0,
|
5091
|
-
const saltBuffer = (0,
|
5092
|
-
const passwordBuffer = (0,
|
5093
|
-
const key = (0,
|
5331
|
+
const ciphertextBuffer = (0, import_crypto3.bufferFromString)(ciphertext, "hex");
|
5332
|
+
const ivBuffer = (0, import_crypto3.bufferFromString)(iv, "hex");
|
5333
|
+
const saltBuffer = (0, import_crypto3.bufferFromString)(salt, "hex");
|
5334
|
+
const passwordBuffer = (0, import_crypto3.bufferFromString)(password);
|
5335
|
+
const key = (0, import_crypto3.scrypt)({
|
5094
5336
|
password: passwordBuffer,
|
5095
5337
|
salt: saltBuffer,
|
5096
5338
|
n,
|
@@ -5099,16 +5341,16 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5099
5341
|
dklen
|
5100
5342
|
});
|
5101
5343
|
const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertextBuffer]);
|
5102
|
-
const macHashUint8Array = (0,
|
5103
|
-
const macHash = (0,
|
5344
|
+
const macHashUint8Array = (0, import_crypto3.keccak256)(data);
|
5345
|
+
const macHash = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
|
5104
5346
|
if (mac !== macHash) {
|
5105
5347
|
throw new import_errors17.FuelError(
|
5106
5348
|
import_errors17.ErrorCode.INVALID_PASSWORD,
|
5107
5349
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
5108
5350
|
);
|
5109
5351
|
}
|
5110
|
-
const buffer = await (0,
|
5111
|
-
const privateKey = (0,
|
5352
|
+
const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
5353
|
+
const privateKey = (0, import_utils29.hexlify)(buffer);
|
5112
5354
|
return privateKey;
|
5113
5355
|
}
|
5114
5356
|
|
@@ -5153,7 +5395,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5153
5395
|
*/
|
5154
5396
|
async signMessage(message) {
|
5155
5397
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
5156
|
-
return (0,
|
5398
|
+
return (0, import_utils30.hexlify)(signedMessage);
|
5157
5399
|
}
|
5158
5400
|
/**
|
5159
5401
|
* Signs a transaction with the wallet's private key.
|
@@ -5166,7 +5408,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5166
5408
|
const chainId = this.provider.getChainId();
|
5167
5409
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5168
5410
|
const signature = await this.signer().sign(hashedTransaction);
|
5169
|
-
return (0,
|
5411
|
+
return (0, import_utils30.hexlify)(signature);
|
5170
5412
|
}
|
5171
5413
|
/**
|
5172
5414
|
* Populates a transaction with the witnesses signature.
|
@@ -5186,7 +5428,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5186
5428
|
* @param transactionRequestLike - The transaction request to send.
|
5187
5429
|
* @returns A promise that resolves to the TransactionResponse object.
|
5188
5430
|
*/
|
5189
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
5431
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
|
5190
5432
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5191
5433
|
if (estimateTxDependencies) {
|
5192
5434
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -5227,15 +5469,15 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5227
5469
|
// src/hdwallet/hdwallet.ts
|
5228
5470
|
var import_errors20 = require("@fuel-ts/errors");
|
5229
5471
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5230
|
-
var
|
5231
|
-
var
|
5472
|
+
var import_math21 = require("@fuel-ts/math");
|
5473
|
+
var import_utils34 = require("@fuel-ts/utils");
|
5232
5474
|
var import_ethers3 = require("ethers");
|
5233
5475
|
|
5234
5476
|
// src/mnemonic/mnemonic.ts
|
5235
|
-
var
|
5477
|
+
var import_crypto4 = require("@fuel-ts/crypto");
|
5236
5478
|
var import_errors19 = require("@fuel-ts/errors");
|
5237
5479
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5238
|
-
var
|
5480
|
+
var import_utils32 = require("@fuel-ts/utils");
|
5239
5481
|
var import_ethers2 = require("ethers");
|
5240
5482
|
|
5241
5483
|
// src/wordlists/words/english.ts
|
@@ -7293,7 +7535,7 @@ var english = [
|
|
7293
7535
|
// src/mnemonic/utils.ts
|
7294
7536
|
var import_errors18 = require("@fuel-ts/errors");
|
7295
7537
|
var import_hasher4 = require("@fuel-ts/hasher");
|
7296
|
-
var
|
7538
|
+
var import_utils31 = require("@fuel-ts/utils");
|
7297
7539
|
function toUtf8Bytes(stri) {
|
7298
7540
|
const str = stri.normalize("NFKD");
|
7299
7541
|
const result = [];
|
@@ -7360,14 +7602,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
7360
7602
|
}
|
7361
7603
|
}
|
7362
7604
|
const checksumBits = entropy.length / 4;
|
7363
|
-
const checksum = (0,
|
7605
|
+
const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
7364
7606
|
indices[indices.length - 1] <<= checksumBits;
|
7365
7607
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7366
7608
|
return indices;
|
7367
7609
|
}
|
7368
7610
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7369
7611
|
const size = Math.ceil(11 * words.length / 8);
|
7370
|
-
const entropy = (0,
|
7612
|
+
const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
|
7371
7613
|
let offset = 0;
|
7372
7614
|
for (let i = 0; i < words.length; i += 1) {
|
7373
7615
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -7387,7 +7629,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7387
7629
|
const entropyBits = 32 * words.length / 3;
|
7388
7630
|
const checksumBits = words.length / 3;
|
7389
7631
|
const checksumMask = getUpperMask(checksumBits);
|
7390
|
-
const checksum = (0,
|
7632
|
+
const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7391
7633
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7392
7634
|
throw new import_errors18.FuelError(
|
7393
7635
|
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
@@ -7462,7 +7704,7 @@ var Mnemonic = class {
|
|
7462
7704
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7463
7705
|
const words = getWords(phrase);
|
7464
7706
|
assertMnemonic(words);
|
7465
|
-
return (0,
|
7707
|
+
return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
7466
7708
|
}
|
7467
7709
|
/**
|
7468
7710
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7470,7 +7712,7 @@ var Mnemonic = class {
|
|
7470
7712
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7471
7713
|
*/
|
7472
7714
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7473
|
-
const entropyBytes = (0,
|
7715
|
+
const entropyBytes = (0, import_utils32.arrayify)(entropy);
|
7474
7716
|
assertWordList(wordlist);
|
7475
7717
|
assertEntropy(entropyBytes);
|
7476
7718
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7539,14 +7781,14 @@ var Mnemonic = class {
|
|
7539
7781
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7540
7782
|
*/
|
7541
7783
|
static masterKeysFromSeed(seed) {
|
7542
|
-
const seedArray = (0,
|
7784
|
+
const seedArray = (0, import_utils32.arrayify)(seed);
|
7543
7785
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7544
7786
|
throw new import_errors19.FuelError(
|
7545
7787
|
import_errors19.ErrorCode.INVALID_SEED,
|
7546
7788
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7547
7789
|
);
|
7548
7790
|
}
|
7549
|
-
return (0,
|
7791
|
+
return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
|
7550
7792
|
}
|
7551
7793
|
/**
|
7552
7794
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7557,22 +7799,22 @@ var Mnemonic = class {
|
|
7557
7799
|
*/
|
7558
7800
|
static seedToExtendedKey(seed, testnet = false) {
|
7559
7801
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7560
|
-
const prefix = (0,
|
7802
|
+
const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
7561
7803
|
const depth = "0x00";
|
7562
7804
|
const fingerprint = "0x00000000";
|
7563
7805
|
const index = "0x00000000";
|
7564
7806
|
const chainCode = masterKey.slice(32);
|
7565
7807
|
const privateKey = masterKey.slice(0, 32);
|
7566
|
-
const extendedKey = (0,
|
7808
|
+
const extendedKey = (0, import_utils32.concat)([
|
7567
7809
|
prefix,
|
7568
7810
|
depth,
|
7569
7811
|
fingerprint,
|
7570
7812
|
index,
|
7571
7813
|
chainCode,
|
7572
|
-
(0,
|
7814
|
+
(0, import_utils32.concat)(["0x00", privateKey])
|
7573
7815
|
]);
|
7574
7816
|
const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
7575
|
-
return (0, import_ethers2.encodeBase58)((0,
|
7817
|
+
return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
|
7576
7818
|
}
|
7577
7819
|
/**
|
7578
7820
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -7587,7 +7829,7 @@ var Mnemonic = class {
|
|
7587
7829
|
* @returns A randomly generated mnemonic
|
7588
7830
|
*/
|
7589
7831
|
static generate(size = 32, extraEntropy = "") {
|
7590
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
7832
|
+
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
|
7591
7833
|
return Mnemonic.entropyToMnemonic(entropy);
|
7592
7834
|
}
|
7593
7835
|
};
|
@@ -7595,12 +7837,12 @@ var mnemonic_default = Mnemonic;
|
|
7595
7837
|
|
7596
7838
|
// src/hdwallet/hdwallet.ts
|
7597
7839
|
var HARDENED_INDEX = 2147483648;
|
7598
|
-
var MainnetPRV2 = (0,
|
7599
|
-
var MainnetPUB = (0,
|
7600
|
-
var TestnetPRV2 = (0,
|
7601
|
-
var TestnetPUB = (0,
|
7840
|
+
var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
|
7841
|
+
var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
|
7842
|
+
var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
|
7843
|
+
var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
|
7602
7844
|
function base58check(data) {
|
7603
|
-
return (0, import_ethers3.encodeBase58)((0,
|
7845
|
+
return (0, import_ethers3.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
7604
7846
|
}
|
7605
7847
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
7606
7848
|
if (isPublic) {
|
@@ -7609,11 +7851,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
7609
7851
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
7610
7852
|
}
|
7611
7853
|
function isPublicExtendedKey(extendedKey) {
|
7612
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
7854
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
|
7613
7855
|
}
|
7614
7856
|
function isValidExtendedKey(extendedKey) {
|
7615
7857
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
7616
|
-
(0,
|
7858
|
+
(0, import_utils34.hexlify)(extendedKey.slice(0, 4))
|
7617
7859
|
);
|
7618
7860
|
}
|
7619
7861
|
function parsePath(path2, depth = 0) {
|
@@ -7631,8 +7873,8 @@ function parsePath(path2, depth = 0) {
|
|
7631
7873
|
var HDWallet = class {
|
7632
7874
|
depth = 0;
|
7633
7875
|
index = 0;
|
7634
|
-
fingerprint = (0,
|
7635
|
-
parentFingerprint = (0,
|
7876
|
+
fingerprint = (0, import_utils34.hexlify)("0x00000000");
|
7877
|
+
parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
|
7636
7878
|
privateKey;
|
7637
7879
|
publicKey;
|
7638
7880
|
chainCode;
|
@@ -7644,8 +7886,8 @@ var HDWallet = class {
|
|
7644
7886
|
constructor(config) {
|
7645
7887
|
if (config.privateKey) {
|
7646
7888
|
const signer = new Signer(config.privateKey);
|
7647
|
-
this.publicKey = (0,
|
7648
|
-
this.privateKey = (0,
|
7889
|
+
this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
|
7890
|
+
this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
|
7649
7891
|
} else {
|
7650
7892
|
if (!config.publicKey) {
|
7651
7893
|
throw new import_errors20.FuelError(
|
@@ -7653,7 +7895,7 @@ var HDWallet = class {
|
|
7653
7895
|
"Both public and private Key cannot be missing. At least one should be provided."
|
7654
7896
|
);
|
7655
7897
|
}
|
7656
|
-
this.publicKey = (0,
|
7898
|
+
this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
|
7657
7899
|
}
|
7658
7900
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
7659
7901
|
this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
@@ -7672,9 +7914,9 @@ var HDWallet = class {
|
|
7672
7914
|
* @returns A new instance of HDWallet on the derived index
|
7673
7915
|
*/
|
7674
7916
|
deriveIndex(index) {
|
7675
|
-
const privateKey = this.privateKey && (0,
|
7676
|
-
const publicKey = (0,
|
7677
|
-
const chainCode = (0,
|
7917
|
+
const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
|
7918
|
+
const publicKey = (0, import_utils34.arrayify)(this.publicKey);
|
7919
|
+
const chainCode = (0, import_utils34.arrayify)(this.chainCode);
|
7678
7920
|
const data = new Uint8Array(37);
|
7679
7921
|
if (index & HARDENED_INDEX) {
|
7680
7922
|
if (!privateKey) {
|
@@ -7685,15 +7927,15 @@ var HDWallet = class {
|
|
7685
7927
|
}
|
7686
7928
|
data.set(privateKey, 1);
|
7687
7929
|
} else {
|
7688
|
-
data.set((0,
|
7930
|
+
data.set((0, import_utils34.arrayify)(this.publicKey));
|
7689
7931
|
}
|
7690
|
-
data.set((0,
|
7691
|
-
const bytes = (0,
|
7932
|
+
data.set((0, import_math21.toBytes)(index, 4), 33);
|
7933
|
+
const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
|
7692
7934
|
const IL = bytes.slice(0, 32);
|
7693
7935
|
const IR = bytes.slice(32);
|
7694
7936
|
if (privateKey) {
|
7695
7937
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7696
|
-
const ki = (0,
|
7938
|
+
const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
7697
7939
|
return new HDWallet({
|
7698
7940
|
privateKey: ki,
|
7699
7941
|
chainCode: IR,
|
@@ -7702,7 +7944,7 @@ var HDWallet = class {
|
|
7702
7944
|
parentFingerprint: this.fingerprint
|
7703
7945
|
});
|
7704
7946
|
}
|
7705
|
-
const signer = new Signer((0,
|
7947
|
+
const signer = new Signer((0, import_utils34.hexlify)(IL));
|
7706
7948
|
const Ki = signer.addPoint(publicKey);
|
7707
7949
|
return new HDWallet({
|
7708
7950
|
publicKey: Ki,
|
@@ -7737,12 +7979,12 @@ var HDWallet = class {
|
|
7737
7979
|
);
|
7738
7980
|
}
|
7739
7981
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
7740
|
-
const depth = (0,
|
7982
|
+
const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
|
7741
7983
|
const parentFingerprint = this.parentFingerprint;
|
7742
|
-
const index = (0,
|
7984
|
+
const index = (0, import_math21.toHex)(this.index, 4);
|
7743
7985
|
const chainCode = this.chainCode;
|
7744
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
7745
|
-
const extendedKey = (0,
|
7986
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
|
7987
|
+
const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
7746
7988
|
return base58check(extendedKey);
|
7747
7989
|
}
|
7748
7990
|
/**
|
@@ -7754,13 +7996,13 @@ var HDWallet = class {
|
|
7754
7996
|
static fromSeed(seed) {
|
7755
7997
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
7756
7998
|
return new HDWallet({
|
7757
|
-
chainCode: (0,
|
7758
|
-
privateKey: (0,
|
7999
|
+
chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
|
8000
|
+
privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
|
7759
8001
|
});
|
7760
8002
|
}
|
7761
8003
|
static fromExtendedKey(extendedKey) {
|
7762
8004
|
const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
|
7763
|
-
const bytes = (0,
|
8005
|
+
const bytes = (0, import_utils34.arrayify)(decoded);
|
7764
8006
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
7765
8007
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
7766
8008
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -7769,9 +8011,9 @@ var HDWallet = class {
|
|
7769
8011
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
7770
8012
|
}
|
7771
8013
|
const depth = bytes[4];
|
7772
|
-
const parentFingerprint = (0,
|
7773
|
-
const index = parseInt((0,
|
7774
|
-
const chainCode = (0,
|
8014
|
+
const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
|
8015
|
+
const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8016
|
+
const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
|
7775
8017
|
const key = bytes.slice(45, 78);
|
7776
8018
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
7777
8019
|
throw new import_errors20.FuelError(
|
@@ -7958,20 +8200,21 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
|
|
7958
8200
|
__publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
7959
8201
|
|
7960
8202
|
// src/test-utils/seedTestWallet.ts
|
7961
|
-
var
|
8203
|
+
var import_crypto5 = require("@fuel-ts/crypto");
|
7962
8204
|
var seedTestWallet = async (wallet, quantities) => {
|
7963
8205
|
const genesisWallet = new WalletUnlocked(
|
7964
|
-
process.env.GENESIS_SECRET || (0,
|
8206
|
+
process.env.GENESIS_SECRET || (0, import_crypto5.randomBytes)(32),
|
7965
8207
|
wallet.provider
|
7966
8208
|
);
|
7967
|
-
const
|
7968
|
-
|
7969
|
-
|
7970
|
-
|
7971
|
-
gasPrice: minGasPrice
|
8209
|
+
const request = new ScriptTransactionRequest();
|
8210
|
+
quantities.forEach((quantity) => {
|
8211
|
+
const { amount, assetId } = coinQuantityfy(quantity);
|
8212
|
+
request.addCoinOutput(wallet.address, amount, assetId);
|
7972
8213
|
});
|
7973
|
-
|
7974
|
-
|
8214
|
+
const txCost = await genesisWallet.provider.getTransactionCost(request);
|
8215
|
+
request.gasLimit = txCost.gasUsed;
|
8216
|
+
request.maxFee = txCost.maxFee;
|
8217
|
+
await genesisWallet.fund(request, txCost);
|
7975
8218
|
await genesisWallet.sendTransaction(request, { awaitExecution: true });
|
7976
8219
|
};
|
7977
8220
|
|
@@ -7986,11 +8229,11 @@ var generateTestWallet = async (provider, quantities) => {
|
|
7986
8229
|
|
7987
8230
|
// src/test-utils/launchNode.ts
|
7988
8231
|
var import_configs13 = require("@fuel-ts/address/configs");
|
7989
|
-
var
|
7990
|
-
var import_utils36 = require("@fuel-ts/utils");
|
8232
|
+
var import_utils35 = require("@fuel-ts/utils");
|
7991
8233
|
var import_cli_utils = require("@fuel-ts/utils/cli-utils");
|
7992
8234
|
var import_child_process = require("child_process");
|
7993
|
-
var
|
8235
|
+
var import_crypto6 = require("crypto");
|
8236
|
+
var import_ethers4 = require("ethers");
|
7994
8237
|
var import_fs = require("fs");
|
7995
8238
|
var import_os = __toESM(require("os"));
|
7996
8239
|
var import_path = __toESM(require("path"));
|
@@ -8039,13 +8282,13 @@ var launchNode = async ({
|
|
8039
8282
|
// eslint-disable-next-line no-async-promise-executor
|
8040
8283
|
new Promise(async (resolve, reject) => {
|
8041
8284
|
const remainingArgs = extractRemainingArgs(args, [
|
8042
|
-
"--
|
8285
|
+
"--snapshot",
|
8043
8286
|
"--consensus-key",
|
8044
8287
|
"--db-type",
|
8045
8288
|
"--poa-instant"
|
8046
8289
|
]);
|
8047
|
-
const chainConfigPath = getFlagValueFromArgs(args, "--
|
8048
|
-
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") ||
|
8290
|
+
const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
|
8291
|
+
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils35.defaultConsensusKey;
|
8049
8292
|
const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
|
8050
8293
|
const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
|
8051
8294
|
const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
|
@@ -8062,37 +8305,55 @@ var launchNode = async ({
|
|
8062
8305
|
})).toString();
|
8063
8306
|
let chainConfigPathToUse;
|
8064
8307
|
const prefix = basePath || import_os.default.tmpdir();
|
8065
|
-
const suffix = basePath ? "" : (0,
|
8066
|
-
const tempDirPath = import_path.default.join(prefix, ".fuels", suffix);
|
8308
|
+
const suffix = basePath ? "" : (0, import_crypto6.randomUUID)();
|
8309
|
+
const tempDirPath = import_path.default.join(prefix, ".fuels", suffix, "chainConfigs");
|
8067
8310
|
if (chainConfigPath) {
|
8068
8311
|
chainConfigPathToUse = chainConfigPath;
|
8069
8312
|
} else {
|
8070
8313
|
if (!(0, import_fs.existsSync)(tempDirPath)) {
|
8071
8314
|
(0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
|
8072
8315
|
}
|
8073
|
-
|
8074
|
-
|
8316
|
+
let { stateConfigJson } = import_utils35.defaultChainConfigs;
|
8317
|
+
const { chainConfigJson, metadataJson } = import_utils35.defaultChainConfigs;
|
8318
|
+
stateConfigJson = {
|
8319
|
+
...stateConfigJson,
|
8320
|
+
coins: [
|
8321
|
+
...stateConfigJson.coins.map((coin) => ({
|
8322
|
+
...coin,
|
8323
|
+
amount: "18446744073709551615"
|
8324
|
+
}))
|
8325
|
+
],
|
8326
|
+
messages: stateConfigJson.messages.map((message) => ({
|
8327
|
+
...message,
|
8328
|
+
amount: "18446744073709551615"
|
8329
|
+
}))
|
8330
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8331
|
+
};
|
8075
8332
|
if (!process.env.GENESIS_SECRET) {
|
8076
8333
|
const pk = Signer.generatePrivateKey();
|
8077
8334
|
const signer = new Signer(pk);
|
8078
|
-
process.env.GENESIS_SECRET = (0,
|
8079
|
-
|
8080
|
-
|
8081
|
-
|
8082
|
-
|
8083
|
-
|
8084
|
-
|
8085
|
-
|
8086
|
-
|
8087
|
-
|
8088
|
-
|
8089
|
-
}
|
8090
|
-
]
|
8091
|
-
}
|
8092
|
-
};
|
8335
|
+
process.env.GENESIS_SECRET = (0, import_utils35.hexlify)(pk);
|
8336
|
+
stateConfigJson.coins.push({
|
8337
|
+
tx_id: (0, import_utils35.hexlify)((0, import_ethers4.randomBytes)(34)),
|
8338
|
+
owner: signer.address.toHexString(),
|
8339
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8340
|
+
amount: "18446744073709551615",
|
8341
|
+
asset_id: import_configs13.BaseAssetId,
|
8342
|
+
output_index: 0,
|
8343
|
+
tx_pointer_block_height: 0,
|
8344
|
+
tx_pointer_tx_idx: 0
|
8345
|
+
});
|
8093
8346
|
}
|
8094
|
-
|
8095
|
-
|
8347
|
+
let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
|
8348
|
+
const regexMakeNumber = /("amount":)"(\d+)"/gm;
|
8349
|
+
fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
|
8350
|
+
const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
|
8351
|
+
const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
|
8352
|
+
const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
|
8353
|
+
(0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
|
8354
|
+
(0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
|
8355
|
+
(0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
|
8356
|
+
chainConfigPathToUse = tempDirPath;
|
8096
8357
|
}
|
8097
8358
|
const child = (0, import_child_process.spawn)(
|
8098
8359
|
command,
|
@@ -8101,10 +8362,10 @@ var launchNode = async ({
|
|
8101
8362
|
["--ip", ipToUse],
|
8102
8363
|
["--port", portToUse],
|
8103
8364
|
useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
|
8104
|
-
["--min-gas-price", "
|
8365
|
+
["--min-gas-price", "1"],
|
8105
8366
|
poaInstant ? ["--poa-instant", "true"] : [],
|
8106
8367
|
["--consensus-key", consensusKey],
|
8107
|
-
["--
|
8368
|
+
["--snapshot", chainConfigPathToUse],
|
8108
8369
|
"--vm-backtrace",
|
8109
8370
|
"--utxo-validation",
|
8110
8371
|
"--debug",
|
@@ -8163,7 +8424,7 @@ var launchNodeAndGetWallets = async ({
|
|
8163
8424
|
walletCount = 10
|
8164
8425
|
} = {}) => {
|
8165
8426
|
const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
|
8166
|
-
const provider = await Provider.create(`http://${ip}:${port}/graphql`);
|
8427
|
+
const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
|
8167
8428
|
const wallets = await generateWallets(walletCount, provider);
|
8168
8429
|
const cleanup = () => {
|
8169
8430
|
closeNode();
|