@fuel-ts/account 0.0.0-rc-2021-20240411154255 → 0.0.0-rc-2045-20240411190910
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/README.md +1 -1
- package/dist/account.d.ts +4 -5
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +574 -841
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +574 -823
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +409 -657
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +2 -10
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +329 -911
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +2 -4
- 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 +1 -7
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +30 -37
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/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 +25 -8
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +0 -3
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +2 -8
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +1073 -1557
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +567 -798
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +418 -649
- 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,16 +58,15 @@ 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_utils31 = 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
|
70
|
-
var import_ramda4 = require("ramda");
|
68
|
+
var import_math18 = require("@fuel-ts/math");
|
69
|
+
var import_utils28 = require("@fuel-ts/utils");
|
71
70
|
|
72
71
|
// src/providers/coin-quantity.ts
|
73
72
|
var import_configs = require("@fuel-ts/address/configs");
|
@@ -76,24 +75,24 @@ var import_utils = require("@fuel-ts/utils");
|
|
76
75
|
var coinQuantityfy = (coinQuantityLike) => {
|
77
76
|
let assetId;
|
78
77
|
let amount;
|
79
|
-
let
|
78
|
+
let max2;
|
80
79
|
if (Array.isArray(coinQuantityLike)) {
|
81
80
|
amount = coinQuantityLike[0];
|
82
81
|
assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
|
83
|
-
|
82
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
84
83
|
} else {
|
85
84
|
amount = coinQuantityLike.amount;
|
86
85
|
assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
|
87
|
-
|
86
|
+
max2 = coinQuantityLike.max ?? void 0;
|
88
87
|
}
|
89
88
|
const bnAmount = (0, import_math.bn)(amount);
|
90
89
|
return {
|
91
90
|
assetId: (0, import_utils.hexlify)(assetId),
|
92
91
|
amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
|
93
|
-
max:
|
92
|
+
max: max2 ? (0, import_math.bn)(max2) : void 0
|
94
93
|
};
|
95
94
|
};
|
96
|
-
var
|
95
|
+
var addAmountToAsset = (params) => {
|
97
96
|
const { amount, assetId } = params;
|
98
97
|
const coinQuantities = [...params.coinQuantities];
|
99
98
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -108,12 +107,12 @@ var addAmountToCoinQuantities = (params) => {
|
|
108
107
|
// src/providers/provider.ts
|
109
108
|
var import_address3 = require("@fuel-ts/address");
|
110
109
|
var import_errors14 = require("@fuel-ts/errors");
|
111
|
-
var
|
112
|
-
var
|
113
|
-
var
|
110
|
+
var import_math15 = require("@fuel-ts/math");
|
111
|
+
var import_transactions18 = require("@fuel-ts/transactions");
|
112
|
+
var import_utils23 = require("@fuel-ts/utils");
|
114
113
|
var import_versions = require("@fuel-ts/versions");
|
115
|
-
var
|
116
|
-
var
|
114
|
+
var import_utils24 = require("@noble/curves/abstract/utils");
|
115
|
+
var import_ethers = require("ethers");
|
117
116
|
var import_graphql_request = require("graphql-request");
|
118
117
|
var import_ramda3 = require("ramda");
|
119
118
|
|
@@ -121,10 +120,14 @@ var import_ramda3 = require("ramda");
|
|
121
120
|
var import_graphql_tag = __toESM(require("graphql-tag"));
|
122
121
|
var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
|
123
122
|
fragment receiptFragment on Receipt {
|
124
|
-
|
123
|
+
contract {
|
124
|
+
id
|
125
|
+
}
|
125
126
|
pc
|
126
127
|
is
|
127
|
-
to
|
128
|
+
to {
|
129
|
+
id
|
130
|
+
}
|
128
131
|
toAddress
|
129
132
|
amount
|
130
133
|
assetId
|
@@ -162,16 +165,10 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
162
165
|
id
|
163
166
|
}
|
164
167
|
time
|
165
|
-
receipts {
|
166
|
-
...receiptFragment
|
167
|
-
}
|
168
168
|
programState {
|
169
169
|
returnType
|
170
170
|
data
|
171
171
|
}
|
172
|
-
receipts {
|
173
|
-
...receiptFragment
|
174
|
-
}
|
175
172
|
}
|
176
173
|
... on FailureStatus {
|
177
174
|
block {
|
@@ -179,24 +176,26 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
179
176
|
}
|
180
177
|
time
|
181
178
|
reason
|
182
|
-
receipts {
|
183
|
-
...receiptFragment
|
184
|
-
}
|
185
179
|
}
|
186
180
|
... on SqueezedOutStatus {
|
187
181
|
reason
|
188
182
|
}
|
189
183
|
}
|
190
|
-
|
184
|
+
`;
|
191
185
|
var TransactionFragmentFragmentDoc = import_graphql_tag.default`
|
192
186
|
fragment transactionFragment on Transaction {
|
193
187
|
id
|
194
188
|
rawPayload
|
189
|
+
gasPrice
|
190
|
+
receipts {
|
191
|
+
...receiptFragment
|
192
|
+
}
|
195
193
|
status {
|
196
194
|
...transactionStatusFragment
|
197
195
|
}
|
198
196
|
}
|
199
|
-
${
|
197
|
+
${ReceiptFragmentFragmentDoc}
|
198
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
200
199
|
var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
|
201
200
|
fragment inputEstimatePredicatesFragment on Input {
|
202
201
|
... on InputCoin {
|
@@ -214,46 +213,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
|
|
214
213
|
}
|
215
214
|
}
|
216
215
|
${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}`;
|
257
216
|
var CoinFragmentFragmentDoc = import_graphql_tag.default`
|
258
217
|
fragment coinFragment on Coin {
|
259
218
|
__typename
|
@@ -261,6 +220,7 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
|
|
261
220
|
owner
|
262
221
|
amount
|
263
222
|
assetId
|
223
|
+
maturity
|
264
224
|
blockCreated
|
265
225
|
txCreatedIdx
|
266
226
|
}
|
@@ -299,32 +259,26 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
|
|
299
259
|
messageBlockHeader {
|
300
260
|
id
|
301
261
|
daHeight
|
302
|
-
consensusParametersVersion
|
303
|
-
stateTransitionBytecodeVersion
|
304
262
|
transactionsCount
|
305
|
-
messageReceiptCount
|
306
263
|
transactionsRoot
|
307
|
-
messageOutboxRoot
|
308
|
-
eventInboxRoot
|
309
264
|
height
|
310
265
|
prevRoot
|
311
266
|
time
|
312
267
|
applicationHash
|
268
|
+
messageReceiptRoot
|
269
|
+
messageReceiptCount
|
313
270
|
}
|
314
271
|
commitBlockHeader {
|
315
272
|
id
|
316
273
|
daHeight
|
317
|
-
consensusParametersVersion
|
318
|
-
stateTransitionBytecodeVersion
|
319
274
|
transactionsCount
|
320
|
-
messageReceiptCount
|
321
275
|
transactionsRoot
|
322
|
-
messageOutboxRoot
|
323
|
-
eventInboxRoot
|
324
276
|
height
|
325
277
|
prevRoot
|
326
278
|
time
|
327
279
|
applicationHash
|
280
|
+
messageReceiptRoot
|
281
|
+
messageReceiptCount
|
328
282
|
}
|
329
283
|
sender
|
330
284
|
recipient
|
@@ -343,8 +297,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
|
|
343
297
|
var BlockFragmentFragmentDoc = import_graphql_tag.default`
|
344
298
|
fragment blockFragment on Block {
|
345
299
|
id
|
346
|
-
height
|
347
300
|
header {
|
301
|
+
height
|
348
302
|
time
|
349
303
|
}
|
350
304
|
transactions {
|
@@ -402,11 +356,6 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
|
|
402
356
|
`;
|
403
357
|
var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
404
358
|
fragment GasCostsFragment on GasCosts {
|
405
|
-
version {
|
406
|
-
... on Version {
|
407
|
-
value
|
408
|
-
}
|
409
|
-
}
|
410
359
|
add
|
411
360
|
addi
|
412
361
|
aloc
|
@@ -419,6 +368,7 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
|
419
368
|
cb
|
420
369
|
cfei
|
421
370
|
cfsi
|
371
|
+
croo
|
422
372
|
div
|
423
373
|
divi
|
424
374
|
ecr1
|
@@ -501,9 +451,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
|
501
451
|
ccp {
|
502
452
|
...DependentCostFragment
|
503
453
|
}
|
504
|
-
croo {
|
505
|
-
...DependentCostFragment
|
506
|
-
}
|
507
454
|
csiz {
|
508
455
|
...DependentCostFragment
|
509
456
|
}
|
@@ -563,11 +510,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
|
563
510
|
${DependentCostFragmentFragmentDoc}`;
|
564
511
|
var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
|
565
512
|
fragment consensusParametersFragment on ConsensusParameters {
|
566
|
-
version {
|
567
|
-
... on Version {
|
568
|
-
value
|
569
|
-
}
|
570
|
-
}
|
571
513
|
txParams {
|
572
514
|
...TxParametersFragment
|
573
515
|
}
|
@@ -627,9 +569,18 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
|
|
627
569
|
fragment nodeInfoFragment on NodeInfo {
|
628
570
|
utxoValidation
|
629
571
|
vmBacktrace
|
572
|
+
minGasPrice
|
630
573
|
maxTx
|
631
574
|
maxDepth
|
632
575
|
nodeVersion
|
576
|
+
peers {
|
577
|
+
id
|
578
|
+
addresses
|
579
|
+
clientVersion
|
580
|
+
blockHeight
|
581
|
+
lastHeartbeatMs
|
582
|
+
appScore
|
583
|
+
}
|
633
584
|
}
|
634
585
|
`;
|
635
586
|
var GetVersionDocument = import_graphql_tag.default`
|
@@ -664,9 +615,13 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
|
|
664
615
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
665
616
|
transaction(id: $transactionId) {
|
666
617
|
...transactionFragment
|
618
|
+
receipts {
|
619
|
+
...receiptFragment
|
620
|
+
}
|
667
621
|
}
|
668
622
|
}
|
669
|
-
${TransactionFragmentFragmentDoc}
|
623
|
+
${TransactionFragmentFragmentDoc}
|
624
|
+
${ReceiptFragmentFragmentDoc}`;
|
670
625
|
var GetTransactionsDocument = import_graphql_tag.default`
|
671
626
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
672
627
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -794,20 +749,6 @@ var GetBalanceDocument = import_graphql_tag.default`
|
|
794
749
|
}
|
795
750
|
}
|
796
751
|
${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
|
-
`;
|
811
752
|
var GetBalancesDocument = import_graphql_tag.default`
|
812
753
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
813
754
|
balances(
|
@@ -862,12 +803,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
|
|
862
803
|
}
|
863
804
|
`;
|
864
805
|
var DryRunDocument = import_graphql_tag.default`
|
865
|
-
mutation dryRun($
|
866
|
-
dryRun(
|
867
|
-
...
|
806
|
+
mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
|
807
|
+
dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
|
808
|
+
...receiptFragment
|
868
809
|
}
|
869
810
|
}
|
870
|
-
${
|
811
|
+
${ReceiptFragmentFragmentDoc}`;
|
871
812
|
var SubmitDocument = import_graphql_tag.default`
|
872
813
|
mutation submit($encodedTransaction: HexString!) {
|
873
814
|
submit(tx: $encodedTransaction) {
|
@@ -950,12 +891,6 @@ function getSdk(requester) {
|
|
950
891
|
getBalance(variables, options) {
|
951
892
|
return requester(GetBalanceDocument, variables, options);
|
952
893
|
},
|
953
|
-
getLatestGasPrice(variables, options) {
|
954
|
-
return requester(GetLatestGasPriceDocument, variables, options);
|
955
|
-
},
|
956
|
-
estimateGasPrice(variables, options) {
|
957
|
-
return requester(EstimateGasPriceDocument, variables, options);
|
958
|
-
},
|
959
894
|
getBalances(variables, options) {
|
960
895
|
return requester(GetBalancesDocument, variables, options);
|
961
896
|
},
|
@@ -1025,14 +960,11 @@ var _FuelGraphqlSubscriber = class {
|
|
1025
960
|
let data;
|
1026
961
|
let errors;
|
1027
962
|
try {
|
1028
|
-
|
1029
|
-
({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
|
963
|
+
({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
|
1030
964
|
} catch (e) {
|
1031
965
|
throw new import_errors.FuelError(
|
1032
966
|
import_errors.ErrorCode.STREAM_PARSING_ERROR,
|
1033
|
-
`Error while parsing stream data response: ${text}
|
1034
|
-
|
1035
|
-
Thrown error: ${e}`
|
967
|
+
`Error while parsing stream data response: ${text}`
|
1036
968
|
);
|
1037
969
|
}
|
1038
970
|
if (Array.isArray(errors)) {
|
@@ -1119,6 +1051,7 @@ var MemoryCache = class {
|
|
1119
1051
|
};
|
1120
1052
|
|
1121
1053
|
// src/providers/transaction-request/input.ts
|
1054
|
+
var import_abi_coder = require("@fuel-ts/abi-coder");
|
1122
1055
|
var import_configs2 = require("@fuel-ts/address/configs");
|
1123
1056
|
var import_errors3 = require("@fuel-ts/errors");
|
1124
1057
|
var import_math2 = require("@fuel-ts/math");
|
@@ -1132,8 +1065,8 @@ var inputify = (value) => {
|
|
1132
1065
|
const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
|
1133
1066
|
return {
|
1134
1067
|
type: import_transactions.InputType.Coin,
|
1135
|
-
txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0,
|
1136
|
-
outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(
|
1068
|
+
txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, import_abi_coder.BYTES_32)),
|
1069
|
+
outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(import_abi_coder.BYTES_32, import_abi_coder.UTXO_ID_LEN)),
|
1137
1070
|
owner: (0, import_utils3.hexlify)(value.owner),
|
1138
1071
|
amount: (0, import_math2.bn)(value.amount),
|
1139
1072
|
assetId: (0, import_utils3.hexlify)(value.assetId),
|
@@ -1142,9 +1075,10 @@ var inputify = (value) => {
|
|
1142
1075
|
txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
|
1143
1076
|
},
|
1144
1077
|
witnessIndex: value.witnessIndex,
|
1078
|
+
maturity: value.maturity ?? 0,
|
1145
1079
|
predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
|
1146
|
-
predicateLength:
|
1147
|
-
predicateDataLength:
|
1080
|
+
predicateLength: predicate.length,
|
1081
|
+
predicateDataLength: predicateData.length,
|
1148
1082
|
predicate: (0, import_utils3.hexlify)(predicate),
|
1149
1083
|
predicateData: (0, import_utils3.hexlify)(predicateData)
|
1150
1084
|
};
|
@@ -1175,8 +1109,8 @@ var inputify = (value) => {
|
|
1175
1109
|
nonce: (0, import_utils3.hexlify)(value.nonce),
|
1176
1110
|
witnessIndex: value.witnessIndex,
|
1177
1111
|
predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
|
1178
|
-
predicateLength:
|
1179
|
-
predicateDataLength:
|
1112
|
+
predicateLength: predicate.length,
|
1113
|
+
predicateDataLength: predicateData.length,
|
1180
1114
|
predicate: (0, import_utils3.hexlify)(predicate),
|
1181
1115
|
predicateData: (0, import_utils3.hexlify)(predicateData),
|
1182
1116
|
data: (0, import_utils3.hexlify)(data),
|
@@ -1250,12 +1184,13 @@ var outputify = (value) => {
|
|
1250
1184
|
};
|
1251
1185
|
|
1252
1186
|
// src/providers/transaction-request/transaction-request.ts
|
1187
|
+
var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
1253
1188
|
var import_address = require("@fuel-ts/address");
|
1254
1189
|
var import_configs7 = require("@fuel-ts/address/configs");
|
1190
|
+
var import_crypto = require("@fuel-ts/crypto");
|
1255
1191
|
var import_math7 = require("@fuel-ts/math");
|
1256
1192
|
var import_transactions6 = require("@fuel-ts/transactions");
|
1257
1193
|
var import_utils9 = require("@fuel-ts/utils");
|
1258
|
-
var import_ethers = require("ethers");
|
1259
1194
|
|
1260
1195
|
// src/providers/resource.ts
|
1261
1196
|
var isCoin = (resource) => "id" in resource;
|
@@ -1291,8 +1226,8 @@ function assembleReceiptByType(receipt) {
|
|
1291
1226
|
case "CALL" /* Call */: {
|
1292
1227
|
const callReceipt = {
|
1293
1228
|
type: import_transactions3.ReceiptType.Call,
|
1294
|
-
from: hexOrZero(receipt.id
|
1295
|
-
to: hexOrZero(receipt?.to),
|
1229
|
+
from: hexOrZero(receipt.contract?.id),
|
1230
|
+
to: hexOrZero(receipt?.to?.id),
|
1296
1231
|
amount: (0, import_math4.bn)(receipt.amount),
|
1297
1232
|
assetId: hexOrZero(receipt.assetId),
|
1298
1233
|
gas: (0, import_math4.bn)(receipt.gas),
|
@@ -1306,7 +1241,7 @@ function assembleReceiptByType(receipt) {
|
|
1306
1241
|
case "RETURN" /* Return */: {
|
1307
1242
|
const returnReceipt = {
|
1308
1243
|
type: import_transactions3.ReceiptType.Return,
|
1309
|
-
id: hexOrZero(receipt.id
|
1244
|
+
id: hexOrZero(receipt.contract?.id),
|
1310
1245
|
val: (0, import_math4.bn)(receipt.val),
|
1311
1246
|
pc: (0, import_math4.bn)(receipt.pc),
|
1312
1247
|
is: (0, import_math4.bn)(receipt.is)
|
@@ -1316,7 +1251,7 @@ function assembleReceiptByType(receipt) {
|
|
1316
1251
|
case "RETURN_DATA" /* ReturnData */: {
|
1317
1252
|
const returnDataReceipt = {
|
1318
1253
|
type: import_transactions3.ReceiptType.ReturnData,
|
1319
|
-
id: hexOrZero(receipt.id
|
1254
|
+
id: hexOrZero(receipt.contract?.id),
|
1320
1255
|
ptr: (0, import_math4.bn)(receipt.ptr),
|
1321
1256
|
len: (0, import_math4.bn)(receipt.len),
|
1322
1257
|
digest: hexOrZero(receipt.digest),
|
@@ -1328,7 +1263,7 @@ function assembleReceiptByType(receipt) {
|
|
1328
1263
|
case "PANIC" /* Panic */: {
|
1329
1264
|
const panicReceipt = {
|
1330
1265
|
type: import_transactions3.ReceiptType.Panic,
|
1331
|
-
id: hexOrZero(receipt.id),
|
1266
|
+
id: hexOrZero(receipt.contract?.id),
|
1332
1267
|
reason: (0, import_math4.bn)(receipt.reason),
|
1333
1268
|
pc: (0, import_math4.bn)(receipt.pc),
|
1334
1269
|
is: (0, import_math4.bn)(receipt.is),
|
@@ -1339,7 +1274,7 @@ function assembleReceiptByType(receipt) {
|
|
1339
1274
|
case "REVERT" /* Revert */: {
|
1340
1275
|
const revertReceipt = {
|
1341
1276
|
type: import_transactions3.ReceiptType.Revert,
|
1342
|
-
id: hexOrZero(receipt.id
|
1277
|
+
id: hexOrZero(receipt.contract?.id),
|
1343
1278
|
val: (0, import_math4.bn)(receipt.ra),
|
1344
1279
|
pc: (0, import_math4.bn)(receipt.pc),
|
1345
1280
|
is: (0, import_math4.bn)(receipt.is)
|
@@ -1349,7 +1284,7 @@ function assembleReceiptByType(receipt) {
|
|
1349
1284
|
case "LOG" /* Log */: {
|
1350
1285
|
const logReceipt = {
|
1351
1286
|
type: import_transactions3.ReceiptType.Log,
|
1352
|
-
id: hexOrZero(receipt.id
|
1287
|
+
id: hexOrZero(receipt.contract?.id),
|
1353
1288
|
val0: (0, import_math4.bn)(receipt.ra),
|
1354
1289
|
val1: (0, import_math4.bn)(receipt.rb),
|
1355
1290
|
val2: (0, import_math4.bn)(receipt.rc),
|
@@ -1362,7 +1297,7 @@ function assembleReceiptByType(receipt) {
|
|
1362
1297
|
case "LOG_DATA" /* LogData */: {
|
1363
1298
|
const logDataReceipt = {
|
1364
1299
|
type: import_transactions3.ReceiptType.LogData,
|
1365
|
-
id: hexOrZero(receipt.id
|
1300
|
+
id: hexOrZero(receipt.contract?.id),
|
1366
1301
|
val0: (0, import_math4.bn)(receipt.ra),
|
1367
1302
|
val1: (0, import_math4.bn)(receipt.rb),
|
1368
1303
|
ptr: (0, import_math4.bn)(receipt.ptr),
|
@@ -1376,8 +1311,8 @@ function assembleReceiptByType(receipt) {
|
|
1376
1311
|
case "TRANSFER" /* Transfer */: {
|
1377
1312
|
const transferReceipt = {
|
1378
1313
|
type: import_transactions3.ReceiptType.Transfer,
|
1379
|
-
from: hexOrZero(receipt.id
|
1380
|
-
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1314
|
+
from: hexOrZero(receipt.contract?.id),
|
1315
|
+
to: hexOrZero(receipt.toAddress || receipt?.to?.id),
|
1381
1316
|
amount: (0, import_math4.bn)(receipt.amount),
|
1382
1317
|
assetId: hexOrZero(receipt.assetId),
|
1383
1318
|
pc: (0, import_math4.bn)(receipt.pc),
|
@@ -1388,8 +1323,8 @@ function assembleReceiptByType(receipt) {
|
|
1388
1323
|
case "TRANSFER_OUT" /* TransferOut */: {
|
1389
1324
|
const transferOutReceipt = {
|
1390
1325
|
type: import_transactions3.ReceiptType.TransferOut,
|
1391
|
-
from: hexOrZero(receipt.id
|
1392
|
-
to: hexOrZero(receipt.toAddress || receipt.to),
|
1326
|
+
from: hexOrZero(receipt.contract?.id),
|
1327
|
+
to: hexOrZero(receipt.toAddress || receipt.to?.id),
|
1393
1328
|
amount: (0, import_math4.bn)(receipt.amount),
|
1394
1329
|
assetId: hexOrZero(receipt.assetId),
|
1395
1330
|
pc: (0, import_math4.bn)(receipt.pc),
|
@@ -1432,7 +1367,7 @@ function assembleReceiptByType(receipt) {
|
|
1432
1367
|
return receiptMessageOut;
|
1433
1368
|
}
|
1434
1369
|
case "MINT" /* Mint */: {
|
1435
|
-
const contractId = hexOrZero(receipt.id
|
1370
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
1436
1371
|
const subId = hexOrZero(receipt.subId);
|
1437
1372
|
const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
|
1438
1373
|
const mintReceipt = {
|
@@ -1447,7 +1382,7 @@ function assembleReceiptByType(receipt) {
|
|
1447
1382
|
return mintReceipt;
|
1448
1383
|
}
|
1449
1384
|
case "BURN" /* Burn */: {
|
1450
|
-
const contractId = hexOrZero(receipt.id
|
1385
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
1451
1386
|
const subId = hexOrZero(receipt.subId);
|
1452
1387
|
const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
|
1453
1388
|
const burnReceipt = {
|
@@ -1473,6 +1408,7 @@ var import_errors6 = require("@fuel-ts/errors");
|
|
1473
1408
|
var import_math5 = require("@fuel-ts/math");
|
1474
1409
|
var import_transactions4 = require("@fuel-ts/transactions");
|
1475
1410
|
var import_utils6 = require("@fuel-ts/utils");
|
1411
|
+
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1476
1412
|
var getGasUsedFromReceipts = (receipts) => {
|
1477
1413
|
const scriptResult = receipts.filter(
|
1478
1414
|
(receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
|
@@ -1493,28 +1429,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
1493
1429
|
}
|
1494
1430
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
1495
1431
|
const witnessCache = [];
|
1496
|
-
const
|
1497
|
-
const isCoinOrMessage = "owner" in input || "sender" in input;
|
1498
|
-
if (isCoinOrMessage) {
|
1499
|
-
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1500
|
-
return true;
|
1501
|
-
}
|
1502
|
-
if (!witnessCache.includes(input.witnessIndex)) {
|
1503
|
-
witnessCache.push(input.witnessIndex);
|
1504
|
-
return true;
|
1505
|
-
}
|
1506
|
-
}
|
1507
|
-
return false;
|
1508
|
-
});
|
1509
|
-
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
1510
|
-
const totalGas = chargeableInputs.reduce((total, input) => {
|
1432
|
+
const totalGas = inputs.reduce((total, input) => {
|
1511
1433
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1512
1434
|
return total.add(
|
1513
|
-
|
1435
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
|
1514
1436
|
);
|
1515
1437
|
}
|
1516
|
-
|
1517
|
-
|
1438
|
+
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
1439
|
+
witnessCache.push(input.witnessIndex);
|
1440
|
+
return total.add(gasCosts.ecr1);
|
1441
|
+
}
|
1442
|
+
return total;
|
1443
|
+
}, (0, import_math5.bn)());
|
1518
1444
|
return totalGas;
|
1519
1445
|
}
|
1520
1446
|
function getMinGas(params) {
|
@@ -1526,20 +1452,12 @@ function getMinGas(params) {
|
|
1526
1452
|
return minGas;
|
1527
1453
|
}
|
1528
1454
|
function getMaxGas(params) {
|
1529
|
-
const {
|
1530
|
-
gasPerByte,
|
1531
|
-
witnessesLength,
|
1532
|
-
witnessLimit,
|
1533
|
-
minGas,
|
1534
|
-
gasLimit = (0, import_math5.bn)(0),
|
1535
|
-
maxGasPerTx
|
1536
|
-
} = params;
|
1455
|
+
const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = (0, import_math5.bn)(0) } = params;
|
1537
1456
|
let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
|
1538
1457
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
1539
1458
|
remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
1540
1459
|
}
|
1541
|
-
|
1542
|
-
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
1460
|
+
return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
1543
1461
|
}
|
1544
1462
|
function calculateMetadataGasForTxCreate({
|
1545
1463
|
gasCosts,
|
@@ -1561,10 +1479,6 @@ function calculateMetadataGasForTxScript({
|
|
1561
1479
|
}) {
|
1562
1480
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1563
1481
|
}
|
1564
|
-
var calculateGasFee = (params) => {
|
1565
|
-
const { gas, gasPrice, priceFactor, tip } = params;
|
1566
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1567
|
-
};
|
1568
1482
|
|
1569
1483
|
// src/providers/utils/json.ts
|
1570
1484
|
var import_utils7 = require("@fuel-ts/utils");
|
@@ -1701,7 +1615,7 @@ var witnessify = (value) => {
|
|
1701
1615
|
// src/providers/transaction-request/transaction-request.ts
|
1702
1616
|
var BaseTransactionRequest = class {
|
1703
1617
|
/** Gas price for transaction */
|
1704
|
-
|
1618
|
+
gasPrice;
|
1705
1619
|
/** Block until which tx cannot be included */
|
1706
1620
|
maturity;
|
1707
1621
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -1720,7 +1634,7 @@ var BaseTransactionRequest = class {
|
|
1720
1634
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
1721
1635
|
*/
|
1722
1636
|
constructor({
|
1723
|
-
|
1637
|
+
gasPrice,
|
1724
1638
|
maturity,
|
1725
1639
|
maxFee,
|
1726
1640
|
witnessLimit,
|
@@ -1728,7 +1642,7 @@ var BaseTransactionRequest = class {
|
|
1728
1642
|
outputs,
|
1729
1643
|
witnesses
|
1730
1644
|
} = {}) {
|
1731
|
-
this.
|
1645
|
+
this.gasPrice = (0, import_math7.bn)(gasPrice);
|
1732
1646
|
this.maturity = maturity ?? 0;
|
1733
1647
|
this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
|
1734
1648
|
this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
|
@@ -1739,9 +1653,9 @@ var BaseTransactionRequest = class {
|
|
1739
1653
|
static getPolicyMeta(req) {
|
1740
1654
|
let policyTypes = 0;
|
1741
1655
|
const policies = [];
|
1742
|
-
if (req.
|
1743
|
-
policyTypes += import_transactions6.PolicyType.
|
1744
|
-
policies.push({ data: req.
|
1656
|
+
if (req.gasPrice) {
|
1657
|
+
policyTypes += import_transactions6.PolicyType.GasPrice;
|
1658
|
+
policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
|
1745
1659
|
}
|
1746
1660
|
if (req.witnessLimit) {
|
1747
1661
|
policyTypes += import_transactions6.PolicyType.WitnessLimit;
|
@@ -1928,10 +1842,10 @@ var BaseTransactionRequest = class {
|
|
1928
1842
|
* @param predicate - Predicate bytes.
|
1929
1843
|
* @param predicateData - Predicate data bytes.
|
1930
1844
|
*/
|
1931
|
-
addCoinInput(coin) {
|
1845
|
+
addCoinInput(coin, predicate) {
|
1932
1846
|
const { assetId, owner, amount } = coin;
|
1933
1847
|
let witnessIndex;
|
1934
|
-
if (
|
1848
|
+
if (predicate) {
|
1935
1849
|
witnessIndex = 0;
|
1936
1850
|
} else {
|
1937
1851
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -1946,7 +1860,8 @@ var BaseTransactionRequest = class {
|
|
1946
1860
|
amount,
|
1947
1861
|
assetId,
|
1948
1862
|
txPointer: "0x00000000000000000000000000000000",
|
1949
|
-
witnessIndex
|
1863
|
+
witnessIndex,
|
1864
|
+
predicate: predicate?.bytes
|
1950
1865
|
};
|
1951
1866
|
this.pushInput(input);
|
1952
1867
|
this.addChangeOutput(owner, assetId);
|
@@ -1959,11 +1874,11 @@ var BaseTransactionRequest = class {
|
|
1959
1874
|
* @param predicate - Predicate bytes.
|
1960
1875
|
* @param predicateData - Predicate data bytes.
|
1961
1876
|
*/
|
1962
|
-
addMessageInput(message) {
|
1877
|
+
addMessageInput(message, predicate) {
|
1963
1878
|
const { recipient, sender, amount } = message;
|
1964
1879
|
const assetId = import_configs7.BaseAssetId;
|
1965
1880
|
let witnessIndex;
|
1966
|
-
if (
|
1881
|
+
if (predicate) {
|
1967
1882
|
witnessIndex = 0;
|
1968
1883
|
} else {
|
1969
1884
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -1977,7 +1892,8 @@ var BaseTransactionRequest = class {
|
|
1977
1892
|
sender: sender.toB256(),
|
1978
1893
|
recipient: recipient.toB256(),
|
1979
1894
|
amount,
|
1980
|
-
witnessIndex
|
1895
|
+
witnessIndex,
|
1896
|
+
predicate: predicate?.bytes
|
1981
1897
|
};
|
1982
1898
|
this.pushInput(input);
|
1983
1899
|
this.addChangeOutput(recipient, assetId);
|
@@ -2008,6 +1924,32 @@ var BaseTransactionRequest = class {
|
|
2008
1924
|
resources.forEach((resource) => this.addResource(resource));
|
2009
1925
|
return this;
|
2010
1926
|
}
|
1927
|
+
/**
|
1928
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
1929
|
+
* outputs from the related assetIds.
|
1930
|
+
*
|
1931
|
+
* @param resources - The resources to add.
|
1932
|
+
* @returns This transaction.
|
1933
|
+
*/
|
1934
|
+
addPredicateResource(resource, predicate) {
|
1935
|
+
if (isCoin(resource)) {
|
1936
|
+
this.addCoinInput(resource, predicate);
|
1937
|
+
} else {
|
1938
|
+
this.addMessageInput(resource, predicate);
|
1939
|
+
}
|
1940
|
+
return this;
|
1941
|
+
}
|
1942
|
+
/**
|
1943
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
1944
|
+
* from the related assetIds.
|
1945
|
+
*
|
1946
|
+
* @param resources - The resources to add.
|
1947
|
+
* @returns This transaction.
|
1948
|
+
*/
|
1949
|
+
addPredicateResources(resources, predicate) {
|
1950
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
1951
|
+
return this;
|
1952
|
+
}
|
2011
1953
|
/**
|
2012
1954
|
* Adds a coin output to the transaction.
|
2013
1955
|
*
|
@@ -2087,7 +2029,7 @@ var BaseTransactionRequest = class {
|
|
2087
2029
|
}
|
2088
2030
|
calculateMaxGas(chainInfo, minGas) {
|
2089
2031
|
const { consensusParameters } = chainInfo;
|
2090
|
-
const { gasPerByte
|
2032
|
+
const { gasPerByte } = consensusParameters;
|
2091
2033
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2092
2034
|
(acc, wit) => acc + wit.dataLength,
|
2093
2035
|
0
|
@@ -2096,8 +2038,7 @@ var BaseTransactionRequest = class {
|
|
2096
2038
|
gasPerByte,
|
2097
2039
|
minGas,
|
2098
2040
|
witnessesLength,
|
2099
|
-
witnessLimit: this.witnessLimit
|
2100
|
-
maxGasPerTx
|
2041
|
+
witnessLimit: this.witnessLimit
|
2101
2042
|
});
|
2102
2043
|
}
|
2103
2044
|
/**
|
@@ -2115,20 +2056,17 @@ var BaseTransactionRequest = class {
|
|
2115
2056
|
});
|
2116
2057
|
const updateAssetInput = (assetId, quantity) => {
|
2117
2058
|
const assetInput = findAssetInput(assetId);
|
2118
|
-
let usedQuantity = quantity;
|
2119
|
-
if (assetId === import_configs7.BaseAssetId) {
|
2120
|
-
usedQuantity = (0, import_math7.bn)("1000000000000000000");
|
2121
|
-
}
|
2122
2059
|
if (assetInput && "assetId" in assetInput) {
|
2123
|
-
assetInput.id = (0, import_utils9.hexlify)((0,
|
2124
|
-
assetInput.amount =
|
2060
|
+
assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
|
2061
|
+
assetInput.amount = quantity;
|
2125
2062
|
} else {
|
2126
2063
|
this.addResources([
|
2127
2064
|
{
|
2128
|
-
id: (0, import_utils9.hexlify)((0,
|
2129
|
-
amount:
|
2065
|
+
id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
|
2066
|
+
amount: quantity,
|
2130
2067
|
assetId,
|
2131
2068
|
owner: resourcesOwner || import_address.Address.fromRandom(),
|
2069
|
+
maturity: 0,
|
2132
2070
|
blockCreated: (0, import_math7.bn)(1),
|
2133
2071
|
txCreatedIdx: (0, import_math7.bn)(1)
|
2134
2072
|
}
|
@@ -2160,7 +2098,7 @@ var BaseTransactionRequest = class {
|
|
2160
2098
|
toJSON() {
|
2161
2099
|
return normalizeJSON(this);
|
2162
2100
|
}
|
2163
|
-
|
2101
|
+
updatePredicateInputs(inputs) {
|
2164
2102
|
this.inputs.forEach((i) => {
|
2165
2103
|
let correspondingInput;
|
2166
2104
|
switch (i.type) {
|
@@ -2182,15 +2120,6 @@ var BaseTransactionRequest = class {
|
|
2182
2120
|
}
|
2183
2121
|
});
|
2184
2122
|
}
|
2185
|
-
shiftPredicateData() {
|
2186
|
-
this.inputs.forEach((input) => {
|
2187
|
-
if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
|
2188
|
-
input.predicateData = input.paddPredicateData(
|
2189
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2190
|
-
);
|
2191
|
-
}
|
2192
|
-
});
|
2193
|
-
}
|
2194
2123
|
};
|
2195
2124
|
|
2196
2125
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2337,8 +2266,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2337
2266
|
return {
|
2338
2267
|
type: import_transactions8.TransactionType.Create,
|
2339
2268
|
...baseTransaction,
|
2269
|
+
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2340
2270
|
bytecodeWitnessIndex,
|
2341
|
-
storageSlotsCount:
|
2271
|
+
storageSlotsCount: storageSlots.length,
|
2342
2272
|
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
|
2343
2273
|
storageSlots
|
2344
2274
|
};
|
@@ -2387,7 +2317,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2387
2317
|
};
|
2388
2318
|
|
2389
2319
|
// src/providers/transaction-request/script-transaction-request.ts
|
2390
|
-
var
|
2320
|
+
var import_abi_coder3 = require("@fuel-ts/abi-coder");
|
2391
2321
|
var import_address2 = require("@fuel-ts/address");
|
2392
2322
|
var import_configs10 = require("@fuel-ts/address/configs");
|
2393
2323
|
var import_math10 = require("@fuel-ts/math");
|
@@ -2461,8 +2391,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2461
2391
|
type: import_transactions9.TransactionType.Script,
|
2462
2392
|
scriptGasLimit: this.gasLimit,
|
2463
2393
|
...super.getBaseTransaction(),
|
2464
|
-
scriptLength:
|
2465
|
-
scriptDataLength:
|
2394
|
+
scriptLength: script.length,
|
2395
|
+
scriptDataLength: scriptData.length,
|
2466
2396
|
receiptsRoot: import_configs10.ZeroBytes32,
|
2467
2397
|
script: (0, import_utils15.hexlify)(script),
|
2468
2398
|
scriptData: (0, import_utils15.hexlify)(scriptData)
|
@@ -2526,7 +2456,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2526
2456
|
}
|
2527
2457
|
calculateMaxGas(chainInfo, minGas) {
|
2528
2458
|
const { consensusParameters } = chainInfo;
|
2529
|
-
const { gasPerByte
|
2459
|
+
const { gasPerByte } = consensusParameters;
|
2530
2460
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2531
2461
|
(acc, wit) => acc + wit.dataLength,
|
2532
2462
|
0
|
@@ -2536,8 +2466,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2536
2466
|
minGas,
|
2537
2467
|
witnessesLength,
|
2538
2468
|
witnessLimit: this.witnessLimit,
|
2539
|
-
gasLimit: this.gasLimit
|
2540
|
-
maxGasPerTx
|
2469
|
+
gasLimit: this.gasLimit
|
2541
2470
|
});
|
2542
2471
|
}
|
2543
2472
|
/**
|
@@ -2580,7 +2509,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2580
2509
|
* @returns The current instance of the `ScriptTransactionRequest`.
|
2581
2510
|
*/
|
2582
2511
|
setData(abi, args) {
|
2583
|
-
const abiInterface = new
|
2512
|
+
const abiInterface = new import_abi_coder3.Interface(abi);
|
2584
2513
|
this.scriptData = abiInterface.functions.main.encodeArguments(args);
|
2585
2514
|
return this;
|
2586
2515
|
}
|
@@ -2612,32 +2541,15 @@ var transactionRequestify = (obj) => {
|
|
2612
2541
|
}
|
2613
2542
|
}
|
2614
2543
|
};
|
2615
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2616
|
-
(acc, input) => {
|
2617
|
-
if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
|
2618
|
-
acc.utxos.push(input.id);
|
2619
|
-
}
|
2620
|
-
if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
|
2621
|
-
acc.messages.push(input.nonce);
|
2622
|
-
}
|
2623
|
-
return acc;
|
2624
|
-
},
|
2625
|
-
{
|
2626
|
-
utxos: [],
|
2627
|
-
messages: []
|
2628
|
-
}
|
2629
|
-
);
|
2630
2544
|
|
2631
2545
|
// src/providers/transaction-response/transaction-response.ts
|
2632
2546
|
var import_errors13 = require("@fuel-ts/errors");
|
2633
|
-
var
|
2634
|
-
var
|
2635
|
-
var
|
2547
|
+
var import_math14 = require("@fuel-ts/math");
|
2548
|
+
var import_transactions17 = require("@fuel-ts/transactions");
|
2549
|
+
var import_utils21 = require("@fuel-ts/utils");
|
2636
2550
|
|
2637
2551
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2638
|
-
var
|
2639
|
-
var import_transactions16 = require("@fuel-ts/transactions");
|
2640
|
-
var import_utils18 = require("@fuel-ts/utils");
|
2552
|
+
var import_utils19 = require("@fuel-ts/utils");
|
2641
2553
|
|
2642
2554
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2643
2555
|
var import_math11 = require("@fuel-ts/math");
|
@@ -2645,10 +2557,9 @@ var import_transactions11 = require("@fuel-ts/transactions");
|
|
2645
2557
|
var import_utils16 = require("@fuel-ts/utils");
|
2646
2558
|
var calculateTransactionFee = (params) => {
|
2647
2559
|
const {
|
2648
|
-
|
2560
|
+
gasUsed,
|
2649
2561
|
rawPayload,
|
2650
|
-
|
2651
|
-
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2562
|
+
consensusParameters: { gasCosts, feeParams }
|
2652
2563
|
} = params;
|
2653
2564
|
const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
|
2654
2565
|
const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
|
@@ -2658,7 +2569,8 @@ var calculateTransactionFee = (params) => {
|
|
2658
2569
|
return {
|
2659
2570
|
fee: (0, import_math11.bn)(0),
|
2660
2571
|
minFee: (0, import_math11.bn)(0),
|
2661
|
-
maxFee: (0, import_math11.bn)(0)
|
2572
|
+
maxFee: (0, import_math11.bn)(0),
|
2573
|
+
feeFromGasUsed: (0, import_math11.bn)(0)
|
2662
2574
|
};
|
2663
2575
|
}
|
2664
2576
|
const { type, witnesses, inputs, policies } = transaction;
|
@@ -2690,6 +2602,7 @@ var calculateTransactionFee = (params) => {
|
|
2690
2602
|
metadataGas,
|
2691
2603
|
txBytesSize: transactionBytes.length
|
2692
2604
|
});
|
2605
|
+
const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
|
2693
2606
|
const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
|
2694
2607
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2695
2608
|
const maxGas = getMaxGas({
|
@@ -2697,25 +2610,17 @@ var calculateTransactionFee = (params) => {
|
|
2697
2610
|
minGas,
|
2698
2611
|
witnessesLength,
|
2699
2612
|
gasLimit,
|
2700
|
-
witnessLimit
|
2701
|
-
maxGasPerTx
|
2702
|
-
});
|
2703
|
-
const minFee = calculateGasFee({
|
2704
|
-
gasPrice,
|
2705
|
-
gas: minGas,
|
2706
|
-
priceFactor: gasPriceFactor,
|
2707
|
-
tip
|
2708
|
-
});
|
2709
|
-
const maxFee = calculateGasFee({
|
2710
|
-
gasPrice,
|
2711
|
-
gas: maxGas,
|
2712
|
-
priceFactor: gasPriceFactor,
|
2713
|
-
tip
|
2613
|
+
witnessLimit
|
2714
2614
|
});
|
2615
|
+
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
2616
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
2617
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
2618
|
+
const fee = minFee.add(feeFromGasUsed);
|
2715
2619
|
return {
|
2620
|
+
fee,
|
2716
2621
|
minFee,
|
2717
2622
|
maxFee,
|
2718
|
-
|
2623
|
+
feeFromGasUsed
|
2719
2624
|
};
|
2720
2625
|
};
|
2721
2626
|
|
@@ -2726,17 +2631,17 @@ var import_math13 = require("@fuel-ts/math");
|
|
2726
2631
|
var import_transactions14 = require("@fuel-ts/transactions");
|
2727
2632
|
|
2728
2633
|
// src/providers/transaction-summary/call.ts
|
2729
|
-
var
|
2634
|
+
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
2730
2635
|
var import_math12 = require("@fuel-ts/math");
|
2731
2636
|
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2732
|
-
const abiInterface = new
|
2637
|
+
const abiInterface = new import_abi_coder4.Interface(abi);
|
2733
2638
|
const callFunctionSelector = receipt.param1.toHex(8);
|
2734
2639
|
const functionFragment = abiInterface.getFunction(callFunctionSelector);
|
2735
2640
|
const inputs = functionFragment.jsonFn.inputs;
|
2736
2641
|
let encodedArgs;
|
2737
2642
|
if (functionFragment.isInputDataPointer) {
|
2738
2643
|
if (rawPayload) {
|
2739
|
-
const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0,
|
2644
|
+
const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2740
2645
|
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2741
2646
|
}
|
2742
2647
|
} else {
|
@@ -3282,12 +3187,10 @@ function assembleTransactionSummary(params) {
|
|
3282
3187
|
gqlTransactionStatus,
|
3283
3188
|
abiMap = {},
|
3284
3189
|
maxInputs,
|
3285
|
-
gasCosts
|
3286
|
-
maxGasPerTx,
|
3287
|
-
gasPrice
|
3190
|
+
gasCosts
|
3288
3191
|
} = params;
|
3289
3192
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3290
|
-
const rawPayload = (0,
|
3193
|
+
const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
|
3291
3194
|
const operations = getOperations({
|
3292
3195
|
transactionType: transaction.type,
|
3293
3196
|
inputs: transaction.inputs || [],
|
@@ -3298,14 +3201,11 @@ function assembleTransactionSummary(params) {
|
|
3298
3201
|
maxInputs
|
3299
3202
|
});
|
3300
3203
|
const typeName = getTransactionTypeName(transaction.type);
|
3301
|
-
const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
|
3302
3204
|
const { fee } = calculateTransactionFee({
|
3303
|
-
|
3205
|
+
gasUsed,
|
3304
3206
|
rawPayload,
|
3305
|
-
tip,
|
3306
3207
|
consensusParameters: {
|
3307
3208
|
gasCosts,
|
3308
|
-
maxGasPerTx,
|
3309
3209
|
feeParams: {
|
3310
3210
|
gasPerByte,
|
3311
3211
|
gasPriceFactor
|
@@ -3317,7 +3217,7 @@ function assembleTransactionSummary(params) {
|
|
3317
3217
|
const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
|
3318
3218
|
let date;
|
3319
3219
|
if (time) {
|
3320
|
-
date =
|
3220
|
+
date = import_utils19.DateTime.fromTai64(time);
|
3321
3221
|
}
|
3322
3222
|
const transactionSummary = {
|
3323
3223
|
id,
|
@@ -3344,13 +3244,13 @@ function assembleTransactionSummary(params) {
|
|
3344
3244
|
}
|
3345
3245
|
|
3346
3246
|
// src/providers/transaction-response/getDecodedLogs.ts
|
3347
|
-
var
|
3348
|
-
var
|
3247
|
+
var import_abi_coder5 = require("@fuel-ts/abi-coder");
|
3248
|
+
var import_transactions16 = require("@fuel-ts/transactions");
|
3349
3249
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
3350
3250
|
return receipts.reduce((logs, receipt) => {
|
3351
|
-
if (receipt.type ===
|
3352
|
-
const interfaceToUse = new
|
3353
|
-
const data = receipt.type ===
|
3251
|
+
if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
|
3252
|
+
const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
|
3253
|
+
const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
|
3354
3254
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
|
3355
3255
|
logs.push(decodedLog);
|
3356
3256
|
}
|
@@ -3365,7 +3265,7 @@ var TransactionResponse = class {
|
|
3365
3265
|
/** Current provider */
|
3366
3266
|
provider;
|
3367
3267
|
/** Gas used on the transaction */
|
3368
|
-
gasUsed = (0,
|
3268
|
+
gasUsed = (0, import_math14.bn)(0);
|
3369
3269
|
/** The graphql Transaction with receipts object. */
|
3370
3270
|
gqlTransaction;
|
3371
3271
|
abis;
|
@@ -3423,8 +3323,8 @@ var TransactionResponse = class {
|
|
3423
3323
|
* @returns The decoded transaction.
|
3424
3324
|
*/
|
3425
3325
|
decodeTransaction(transactionWithReceipts) {
|
3426
|
-
return new
|
3427
|
-
(0,
|
3326
|
+
return new import_transactions17.TransactionCoder().decode(
|
3327
|
+
(0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
|
3428
3328
|
0
|
3429
3329
|
)?.[0];
|
3430
3330
|
}
|
@@ -3443,27 +3343,20 @@ var TransactionResponse = class {
|
|
3443
3343
|
const decodedTransaction = this.decodeTransaction(
|
3444
3344
|
transaction
|
3445
3345
|
);
|
3446
|
-
|
3447
|
-
|
3448
|
-
txReceipts = transaction.status.receipts;
|
3449
|
-
}
|
3450
|
-
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3451
|
-
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3452
|
-
const gasPrice = await this.provider.getLatestGasPrice();
|
3346
|
+
const receipts = transaction.receipts?.map(processGqlReceipt) || [];
|
3347
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
|
3453
3348
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3454
3349
|
const transactionSummary = assembleTransactionSummary({
|
3455
3350
|
id: this.id,
|
3456
3351
|
receipts,
|
3457
3352
|
transaction: decodedTransaction,
|
3458
|
-
transactionBytes: (0,
|
3353
|
+
transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
|
3459
3354
|
gqlTransactionStatus: transaction.status,
|
3460
3355
|
gasPerByte,
|
3461
3356
|
gasPriceFactor,
|
3462
3357
|
abiMap: contractsAbiMap,
|
3463
3358
|
maxInputs,
|
3464
|
-
gasCosts
|
3465
|
-
maxGasPerTx,
|
3466
|
-
gasPrice
|
3359
|
+
gasCosts
|
3467
3360
|
});
|
3468
3361
|
return transactionSummary;
|
3469
3362
|
}
|
@@ -3590,29 +3483,29 @@ var processGqlChain = (chain) => {
|
|
3590
3483
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3591
3484
|
return {
|
3592
3485
|
name,
|
3593
|
-
baseChainHeight: (0,
|
3486
|
+
baseChainHeight: (0, import_math15.bn)(daHeight),
|
3594
3487
|
consensusParameters: {
|
3595
|
-
contractMaxSize: (0,
|
3596
|
-
maxInputs: (0,
|
3597
|
-
maxOutputs: (0,
|
3598
|
-
maxWitnesses: (0,
|
3599
|
-
maxGasPerTx: (0,
|
3600
|
-
maxScriptLength: (0,
|
3601
|
-
maxScriptDataLength: (0,
|
3602
|
-
maxStorageSlots: (0,
|
3603
|
-
maxPredicateLength: (0,
|
3604
|
-
maxPredicateDataLength: (0,
|
3605
|
-
maxGasPerPredicate: (0,
|
3606
|
-
gasPriceFactor: (0,
|
3607
|
-
gasPerByte: (0,
|
3608
|
-
maxMessageDataLength: (0,
|
3609
|
-
chainId: (0,
|
3488
|
+
contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
|
3489
|
+
maxInputs: (0, import_math15.bn)(txParams.maxInputs),
|
3490
|
+
maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
|
3491
|
+
maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
|
3492
|
+
maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
|
3493
|
+
maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
|
3494
|
+
maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
|
3495
|
+
maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
|
3496
|
+
maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
|
3497
|
+
maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
|
3498
|
+
maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
|
3499
|
+
gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
|
3500
|
+
gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
|
3501
|
+
maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
|
3502
|
+
chainId: (0, import_math15.bn)(consensusParameters.chainId),
|
3610
3503
|
gasCosts
|
3611
3504
|
},
|
3612
3505
|
gasCosts,
|
3613
3506
|
latestBlock: {
|
3614
3507
|
id: latestBlock.id,
|
3615
|
-
height: (0,
|
3508
|
+
height: (0, import_math15.bn)(latestBlock.header.height),
|
3616
3509
|
time: latestBlock.header.time,
|
3617
3510
|
transactions: latestBlock.transactions.map((i) => ({
|
3618
3511
|
id: i.id
|
@@ -3706,8 +3599,10 @@ var _Provider = class {
|
|
3706
3599
|
* Returns some helpful parameters related to gas fees.
|
3707
3600
|
*/
|
3708
3601
|
getGasConfig() {
|
3602
|
+
const { minGasPrice } = this.getNode();
|
3709
3603
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3710
3604
|
return {
|
3605
|
+
minGasPrice,
|
3711
3606
|
maxGasPerTx,
|
3712
3607
|
maxGasPerPredicate,
|
3713
3608
|
gasPriceFactor,
|
@@ -3795,7 +3690,7 @@ var _Provider = class {
|
|
3795
3690
|
name,
|
3796
3691
|
consensusParameters: { chainId }
|
3797
3692
|
} = await this.getChain();
|
3798
|
-
const network = new
|
3693
|
+
const network = new import_ethers.Network(name, chainId.toNumber());
|
3799
3694
|
return Promise.resolve(network);
|
3800
3695
|
}
|
3801
3696
|
/**
|
@@ -3805,7 +3700,7 @@ var _Provider = class {
|
|
3805
3700
|
*/
|
3806
3701
|
async getBlockNumber() {
|
3807
3702
|
const { chain } = await this.operations.getChain();
|
3808
|
-
return (0,
|
3703
|
+
return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
|
3809
3704
|
}
|
3810
3705
|
/**
|
3811
3706
|
* Returns the chain information.
|
@@ -3815,11 +3710,13 @@ var _Provider = class {
|
|
3815
3710
|
async fetchNode() {
|
3816
3711
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3817
3712
|
const processedNodeInfo = {
|
3818
|
-
maxDepth: (0,
|
3819
|
-
maxTx: (0,
|
3713
|
+
maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
|
3714
|
+
maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
|
3715
|
+
minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
|
3820
3716
|
nodeVersion: nodeInfo.nodeVersion,
|
3821
3717
|
utxoValidation: nodeInfo.utxoValidation,
|
3822
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
3718
|
+
vmBacktrace: nodeInfo.vmBacktrace,
|
3719
|
+
peers: nodeInfo.peers
|
3823
3720
|
};
|
3824
3721
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
3825
3722
|
return processedNodeInfo;
|
@@ -3861,9 +3758,9 @@ var _Provider = class {
|
|
3861
3758
|
if (estimateTxDependencies) {
|
3862
3759
|
await this.estimateTxDependencies(transactionRequest);
|
3863
3760
|
}
|
3864
|
-
const encodedTransaction = (0,
|
3761
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
3865
3762
|
let abis;
|
3866
|
-
if (transactionRequest.type ===
|
3763
|
+
if (transactionRequest.type === import_transactions18.TransactionType.Script) {
|
3867
3764
|
abis = transactionRequest.abis;
|
3868
3765
|
}
|
3869
3766
|
if (awaitExecution) {
|
@@ -3904,14 +3801,15 @@ var _Provider = class {
|
|
3904
3801
|
if (estimateTxDependencies) {
|
3905
3802
|
return this.estimateTxDependencies(transactionRequest);
|
3906
3803
|
}
|
3907
|
-
const encodedTransaction = (0,
|
3908
|
-
const { dryRun:
|
3909
|
-
|
3804
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
3805
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3806
|
+
encodedTransaction,
|
3910
3807
|
utxoValidation: utxoValidation || false
|
3911
3808
|
});
|
3912
|
-
const
|
3913
|
-
|
3914
|
-
|
3809
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
3810
|
+
return {
|
3811
|
+
receipts
|
3812
|
+
};
|
3915
3813
|
}
|
3916
3814
|
/**
|
3917
3815
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -3922,13 +3820,13 @@ var _Provider = class {
|
|
3922
3820
|
async estimatePredicates(transactionRequest) {
|
3923
3821
|
const shouldEstimatePredicates = Boolean(
|
3924
3822
|
transactionRequest.inputs.find(
|
3925
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
3823
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils24.equalBytes)((0, import_utils23.arrayify)(input.predicate), (0, import_utils23.arrayify)("0x")) && new import_math15.BN(input.predicateGasUsed).isZero()
|
3926
3824
|
)
|
3927
3825
|
);
|
3928
3826
|
if (!shouldEstimatePredicates) {
|
3929
3827
|
return transactionRequest;
|
3930
3828
|
}
|
3931
|
-
const encodedTransaction = (0,
|
3829
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
3932
3830
|
const response = await this.operations.estimatePredicates({
|
3933
3831
|
encodedTransaction
|
3934
3832
|
});
|
@@ -3937,7 +3835,7 @@ var _Provider = class {
|
|
3937
3835
|
} = response;
|
3938
3836
|
if (inputs) {
|
3939
3837
|
inputs.forEach((input, index) => {
|
3940
|
-
if ("predicateGasUsed" in input && (0,
|
3838
|
+
if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
|
3941
3839
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3942
3840
|
}
|
3943
3841
|
});
|
@@ -3950,31 +3848,31 @@ var _Provider = class {
|
|
3950
3848
|
* If there are missing variable outputs,
|
3951
3849
|
* `addVariableOutputs` is called on the transaction.
|
3952
3850
|
*
|
3851
|
+
* @privateRemarks
|
3852
|
+
* TODO: Investigate support for missing contract IDs
|
3853
|
+
* TODO: Add support for missing output messages
|
3953
3854
|
*
|
3954
3855
|
* @param transactionRequest - The transaction request object.
|
3955
3856
|
* @returns A promise.
|
3956
3857
|
*/
|
3957
3858
|
async estimateTxDependencies(transactionRequest) {
|
3958
|
-
if (transactionRequest.type ===
|
3859
|
+
if (transactionRequest.type === import_transactions18.TransactionType.Create) {
|
3959
3860
|
return {
|
3960
3861
|
receipts: [],
|
3961
3862
|
outputVariables: 0,
|
3962
3863
|
missingContractIds: []
|
3963
3864
|
};
|
3964
3865
|
}
|
3866
|
+
await this.estimatePredicates(transactionRequest);
|
3965
3867
|
let receipts = [];
|
3966
3868
|
const missingContractIds = [];
|
3967
3869
|
let outputVariables = 0;
|
3968
|
-
let dryrunStatus;
|
3969
3870
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3970
|
-
const {
|
3971
|
-
|
3972
|
-
} = await this.operations.dryRun({
|
3973
|
-
encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
|
3871
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3872
|
+
encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
|
3974
3873
|
utxoValidation: false
|
3975
3874
|
});
|
3976
|
-
receipts =
|
3977
|
-
dryrunStatus = status;
|
3875
|
+
receipts = gqlReceipts.map(processGqlReceipt);
|
3978
3876
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
3979
3877
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
3980
3878
|
if (hasMissingOutputs) {
|
@@ -3984,11 +3882,6 @@ var _Provider = class {
|
|
3984
3882
|
transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
|
3985
3883
|
missingContractIds.push(contractId);
|
3986
3884
|
});
|
3987
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
3988
|
-
transactionRequest,
|
3989
|
-
optimizeGas: false
|
3990
|
-
});
|
3991
|
-
transactionRequest.maxFee = maxFee;
|
3992
3885
|
} else {
|
3993
3886
|
break;
|
3994
3887
|
}
|
@@ -3996,133 +3889,37 @@ var _Provider = class {
|
|
3996
3889
|
return {
|
3997
3890
|
receipts,
|
3998
3891
|
outputVariables,
|
3999
|
-
missingContractIds
|
4000
|
-
dryrunStatus
|
3892
|
+
missingContractIds
|
4001
3893
|
};
|
4002
3894
|
}
|
4003
3895
|
/**
|
4004
|
-
*
|
4005
|
-
*
|
4006
|
-
*
|
4007
|
-
* further modifications are identified. The method iteratively updates these transactions
|
4008
|
-
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
4009
|
-
*
|
4010
|
-
* @param transactionRequests - Array of transaction request objects.
|
4011
|
-
* @returns A promise that resolves to an array of results for each transaction.
|
3896
|
+
* Estimates the transaction gas and fee based on the provided transaction request.
|
3897
|
+
* @param transactionRequest - The transaction request object.
|
3898
|
+
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
4012
3899
|
*/
|
4013
|
-
|
4014
|
-
const
|
4015
|
-
|
4016
|
-
outputVariables: 0,
|
4017
|
-
missingContractIds: [],
|
4018
|
-
dryrunStatus: void 0
|
4019
|
-
}));
|
4020
|
-
const allRequests = (0, import_ramda3.clone)(transactionRequests);
|
4021
|
-
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4022
|
-
allRequests.forEach((req, index) => {
|
4023
|
-
if (req.type === import_transactions19.TransactionType.Script) {
|
4024
|
-
serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
|
4025
|
-
}
|
4026
|
-
});
|
4027
|
-
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
4028
|
-
let attempt = 0;
|
4029
|
-
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
4030
|
-
const encodedTransactions = transactionsToProcess.map(
|
4031
|
-
(index) => serializedTransactionsMap.get(index)
|
4032
|
-
);
|
4033
|
-
const dryRunResults = await this.operations.dryRun({
|
4034
|
-
encodedTransactions,
|
4035
|
-
utxoValidation: false
|
4036
|
-
});
|
4037
|
-
const nextRoundTransactions = [];
|
4038
|
-
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
4039
|
-
const currentResultIndex = transactionsToProcess[i];
|
4040
|
-
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4041
|
-
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
4042
|
-
results[currentResultIndex].dryrunStatus = status;
|
4043
|
-
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4044
|
-
results[currentResultIndex].receipts
|
4045
|
-
);
|
4046
|
-
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4047
|
-
const requestToProcess = allRequests[currentResultIndex];
|
4048
|
-
if (hasMissingOutputs && requestToProcess?.type === import_transactions19.TransactionType.Script) {
|
4049
|
-
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
4050
|
-
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
4051
|
-
missingOutputContractIds.forEach(({ contractId }) => {
|
4052
|
-
requestToProcess.addContractInputAndOutput(import_address3.Address.fromString(contractId));
|
4053
|
-
results[currentResultIndex].missingContractIds.push(contractId);
|
4054
|
-
});
|
4055
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
4056
|
-
transactionRequest: requestToProcess,
|
4057
|
-
optimizeGas: false
|
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
|
-
async estimateTxGasAndFee(params) {
|
4089
|
-
const { transactionRequest, optimizeGas = true } = params;
|
4090
|
-
let { gasPrice } = params;
|
3900
|
+
estimateTxGasAndFee(params) {
|
3901
|
+
const { transactionRequest } = params;
|
3902
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
4091
3903
|
const chainInfo = this.getChain();
|
4092
|
-
const
|
3904
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
3905
|
+
transactionRequest.gasPrice = gasPrice;
|
4093
3906
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
4094
|
-
|
4095
|
-
|
4096
|
-
|
4097
|
-
const minFee = calculateGasFee({
|
4098
|
-
gasPrice: (0, import_math16.bn)(gasPrice),
|
4099
|
-
gas: minGas,
|
4100
|
-
priceFactor: gasPriceFactor,
|
4101
|
-
tip: transactionRequest.tip
|
4102
|
-
}).add(1);
|
4103
|
-
let gasLimit = (0, import_math16.bn)(0);
|
4104
|
-
if (transactionRequest.type === import_transactions19.TransactionType.Script) {
|
4105
|
-
gasLimit = transactionRequest.gasLimit;
|
4106
|
-
if (!optimizeGas) {
|
3907
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
3908
|
+
if (transactionRequest.type === import_transactions18.TransactionType.Script) {
|
3909
|
+
if (transactionRequest.gasLimit.eq(0)) {
|
4107
3910
|
transactionRequest.gasLimit = minGas;
|
4108
|
-
gasLimit =
|
4109
|
-
|
3911
|
+
transactionRequest.gasLimit = maxGasPerTx.sub(
|
3912
|
+
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
3913
|
+
);
|
4110
3914
|
}
|
4111
3915
|
}
|
4112
3916
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4113
|
-
const maxFee =
|
4114
|
-
gasPrice: (0, import_math16.bn)(gasPrice),
|
4115
|
-
gas: maxGas,
|
4116
|
-
priceFactor: gasPriceFactor,
|
4117
|
-
tip: transactionRequest.tip
|
4118
|
-
}).add(1);
|
3917
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4119
3918
|
return {
|
4120
3919
|
minGas,
|
4121
3920
|
minFee,
|
4122
3921
|
maxGas,
|
4123
|
-
maxFee
|
4124
|
-
gasPrice,
|
4125
|
-
gasLimit
|
3922
|
+
maxFee
|
4126
3923
|
};
|
4127
3924
|
}
|
4128
3925
|
/**
|
@@ -4140,17 +3937,15 @@ var _Provider = class {
|
|
4140
3937
|
if (estimateTxDependencies) {
|
4141
3938
|
return this.estimateTxDependencies(transactionRequest);
|
4142
3939
|
}
|
4143
|
-
const
|
4144
|
-
const { dryRun:
|
4145
|
-
|
3940
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
3941
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3942
|
+
encodedTransaction,
|
4146
3943
|
utxoValidation: true
|
4147
3944
|
});
|
4148
|
-
const
|
4149
|
-
|
4150
|
-
|
4151
|
-
|
4152
|
-
});
|
4153
|
-
return { receipts: callResult[0].receipts };
|
3945
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
3946
|
+
return {
|
3947
|
+
receipts
|
3948
|
+
};
|
4154
3949
|
}
|
4155
3950
|
/**
|
4156
3951
|
* Returns a transaction cost to enable user
|
@@ -4167,80 +3962,77 @@ var _Provider = class {
|
|
4167
3962
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
4168
3963
|
* @returns A promise that resolves to the transaction cost object.
|
4169
3964
|
*/
|
4170
|
-
async getTransactionCost(transactionRequestLike,
|
3965
|
+
async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
|
3966
|
+
estimateTxDependencies = true,
|
3967
|
+
estimatePredicates = true,
|
3968
|
+
resourcesOwner,
|
3969
|
+
signatureCallback
|
3970
|
+
} = {}) {
|
4171
3971
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
4172
|
-
const
|
3972
|
+
const { minGasPrice } = this.getGasConfig();
|
3973
|
+
const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
|
3974
|
+
const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
|
4173
3975
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4174
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
3976
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
4175
3977
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
4176
|
-
txRequestClone.maxFee = (0, import_math16.bn)(0);
|
4177
3978
|
if (isScriptTransaction) {
|
4178
|
-
txRequestClone.gasLimit = (0,
|
3979
|
+
txRequestClone.gasLimit = (0, import_math15.bn)(0);
|
4179
3980
|
}
|
4180
|
-
if (
|
4181
|
-
resourcesOwner
|
3981
|
+
if (estimatePredicates) {
|
3982
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
3983
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
3984
|
+
}
|
3985
|
+
await this.estimatePredicates(txRequestClone);
|
4182
3986
|
}
|
4183
|
-
const signedRequest = (0, import_ramda3.clone)(txRequestClone);
|
4184
|
-
let addedSignatures = 0;
|
4185
3987
|
if (signatureCallback && isScriptTransaction) {
|
4186
|
-
|
4187
|
-
|
4188
|
-
|
4189
|
-
|
4190
|
-
await this.estimatePredicates(signedRequest);
|
4191
|
-
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
4192
|
-
transactionRequest: signedRequest,
|
4193
|
-
optimizeGas: false
|
3988
|
+
await signatureCallback(txRequestClone);
|
3989
|
+
}
|
3990
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
3991
|
+
transactionRequest: txRequestClone
|
4194
3992
|
});
|
4195
|
-
txRequestClone.maxFee = maxFee;
|
4196
3993
|
let receipts = [];
|
4197
3994
|
let missingContractIds = [];
|
4198
3995
|
let outputVariables = 0;
|
4199
|
-
let gasUsed = (0,
|
4200
|
-
|
4201
|
-
|
4202
|
-
if (signatureCallback) {
|
4203
|
-
await signatureCallback(txRequestClone);
|
4204
|
-
}
|
4205
|
-
txRequestClone.gasLimit = gasLimit;
|
3996
|
+
let gasUsed = (0, import_math15.bn)(0);
|
3997
|
+
if (isScriptTransaction && estimateTxDependencies) {
|
3998
|
+
txRequestClone.gasPrice = (0, import_math15.bn)(0);
|
4206
3999
|
const result = await this.estimateTxDependencies(txRequestClone);
|
4207
4000
|
receipts = result.receipts;
|
4208
4001
|
outputVariables = result.outputVariables;
|
4209
4002
|
missingContractIds = result.missingContractIds;
|
4210
|
-
gasUsed = getGasUsedFromReceipts(receipts);
|
4003
|
+
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4211
4004
|
txRequestClone.gasLimit = gasUsed;
|
4212
|
-
|
4213
|
-
|
4214
|
-
|
4005
|
+
txRequestClone.gasPrice = setGasPrice;
|
4006
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
4007
|
+
transactionRequest: txRequestClone
|
4215
4008
|
}));
|
4216
4009
|
}
|
4217
4010
|
return {
|
4218
4011
|
requiredQuantities: allQuantities,
|
4219
4012
|
receipts,
|
4220
4013
|
gasUsed,
|
4221
|
-
|
4014
|
+
minGasPrice,
|
4015
|
+
gasPrice: setGasPrice,
|
4222
4016
|
minGas,
|
4223
4017
|
maxGas,
|
4224
4018
|
minFee,
|
4225
4019
|
maxFee,
|
4020
|
+
estimatedInputs: txRequestClone.inputs,
|
4226
4021
|
outputVariables,
|
4227
|
-
missingContractIds
|
4228
|
-
addedSignatures,
|
4229
|
-
estimatedPredicates: txRequestClone.inputs
|
4022
|
+
missingContractIds
|
4230
4023
|
};
|
4231
4024
|
}
|
4232
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
4025
|
+
async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
|
4233
4026
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4234
4027
|
const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
|
4235
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
4236
|
-
quantitiesToContract
|
4237
|
-
});
|
4028
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
|
4238
4029
|
transactionRequest.addResources(
|
4239
4030
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
4240
4031
|
);
|
4241
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4242
|
-
|
4243
|
-
|
4032
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4033
|
+
transactionRequest,
|
4034
|
+
forwardingQuantities
|
4035
|
+
);
|
4244
4036
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
4245
4037
|
return {
|
4246
4038
|
resources,
|
@@ -4256,16 +4048,17 @@ var _Provider = class {
|
|
4256
4048
|
const result = await this.operations.getCoins({
|
4257
4049
|
first: 10,
|
4258
4050
|
...paginationArgs,
|
4259
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
4051
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
|
4260
4052
|
});
|
4261
4053
|
const coins = result.coins.edges.map((edge) => edge.node);
|
4262
4054
|
return coins.map((coin) => ({
|
4263
4055
|
id: coin.utxoId,
|
4264
4056
|
assetId: coin.assetId,
|
4265
|
-
amount: (0,
|
4057
|
+
amount: (0, import_math15.bn)(coin.amount),
|
4266
4058
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4267
|
-
|
4268
|
-
|
4059
|
+
maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
|
4060
|
+
blockCreated: (0, import_math15.bn)(coin.blockCreated),
|
4061
|
+
txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
|
4269
4062
|
}));
|
4270
4063
|
}
|
4271
4064
|
/**
|
@@ -4279,19 +4072,19 @@ var _Provider = class {
|
|
4279
4072
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4280
4073
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4281
4074
|
const excludeInput = {
|
4282
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
4283
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
4075
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
|
4076
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
|
4284
4077
|
};
|
4285
4078
|
if (this.cache) {
|
4286
4079
|
const uniqueUtxos = new Set(
|
4287
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
4080
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
|
4288
4081
|
);
|
4289
4082
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
4290
4083
|
}
|
4291
4084
|
const coinsQuery = {
|
4292
4085
|
owner: ownerAddress.toB256(),
|
4293
4086
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4294
|
-
assetId: (0,
|
4087
|
+
assetId: (0, import_utils23.hexlify)(assetId),
|
4295
4088
|
amount: amount.toString(10),
|
4296
4089
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4297
4090
|
})),
|
@@ -4302,9 +4095,9 @@ var _Provider = class {
|
|
4302
4095
|
switch (coin.__typename) {
|
4303
4096
|
case "MessageCoin":
|
4304
4097
|
return {
|
4305
|
-
amount: (0,
|
4098
|
+
amount: (0, import_math15.bn)(coin.amount),
|
4306
4099
|
assetId: coin.assetId,
|
4307
|
-
daHeight: (0,
|
4100
|
+
daHeight: (0, import_math15.bn)(coin.daHeight),
|
4308
4101
|
sender: import_address3.Address.fromAddressOrString(coin.sender),
|
4309
4102
|
recipient: import_address3.Address.fromAddressOrString(coin.recipient),
|
4310
4103
|
nonce: coin.nonce
|
@@ -4312,11 +4105,12 @@ var _Provider = class {
|
|
4312
4105
|
case "Coin":
|
4313
4106
|
return {
|
4314
4107
|
id: coin.utxoId,
|
4315
|
-
amount: (0,
|
4108
|
+
amount: (0, import_math15.bn)(coin.amount),
|
4316
4109
|
assetId: coin.assetId,
|
4317
4110
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4318
|
-
|
4319
|
-
|
4111
|
+
maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
|
4112
|
+
blockCreated: (0, import_math15.bn)(coin.blockCreated),
|
4113
|
+
txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
|
4320
4114
|
};
|
4321
4115
|
default:
|
4322
4116
|
return null;
|
@@ -4333,13 +4127,13 @@ var _Provider = class {
|
|
4333
4127
|
async getBlock(idOrHeight) {
|
4334
4128
|
let variables;
|
4335
4129
|
if (typeof idOrHeight === "number") {
|
4336
|
-
variables = { height: (0,
|
4130
|
+
variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
|
4337
4131
|
} else if (idOrHeight === "latest") {
|
4338
4132
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4339
4133
|
} else if (idOrHeight.length === 66) {
|
4340
4134
|
variables = { blockId: idOrHeight };
|
4341
4135
|
} else {
|
4342
|
-
variables = { blockId: (0,
|
4136
|
+
variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
|
4343
4137
|
}
|
4344
4138
|
const { block } = await this.operations.getBlock(variables);
|
4345
4139
|
if (!block) {
|
@@ -4347,7 +4141,7 @@ var _Provider = class {
|
|
4347
4141
|
}
|
4348
4142
|
return {
|
4349
4143
|
id: block.id,
|
4350
|
-
height: (0,
|
4144
|
+
height: (0, import_math15.bn)(block.header.height),
|
4351
4145
|
time: block.header.time,
|
4352
4146
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4353
4147
|
};
|
@@ -4362,7 +4156,7 @@ var _Provider = class {
|
|
4362
4156
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4363
4157
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4364
4158
|
id: block.id,
|
4365
|
-
height: (0,
|
4159
|
+
height: (0, import_math15.bn)(block.header.height),
|
4366
4160
|
time: block.header.time,
|
4367
4161
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4368
4162
|
}));
|
@@ -4377,7 +4171,7 @@ var _Provider = class {
|
|
4377
4171
|
async getBlockWithTransactions(idOrHeight) {
|
4378
4172
|
let variables;
|
4379
4173
|
if (typeof idOrHeight === "number") {
|
4380
|
-
variables = { blockHeight: (0,
|
4174
|
+
variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
|
4381
4175
|
} else if (idOrHeight === "latest") {
|
4382
4176
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4383
4177
|
} else {
|
@@ -4389,11 +4183,11 @@ var _Provider = class {
|
|
4389
4183
|
}
|
4390
4184
|
return {
|
4391
4185
|
id: block.id,
|
4392
|
-
height: (0,
|
4186
|
+
height: (0, import_math15.bn)(block.header.height, 10),
|
4393
4187
|
time: block.header.time,
|
4394
4188
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4395
4189
|
transactions: block.transactions.map(
|
4396
|
-
(tx) => new
|
4190
|
+
(tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
|
4397
4191
|
)
|
4398
4192
|
};
|
4399
4193
|
}
|
@@ -4408,8 +4202,8 @@ var _Provider = class {
|
|
4408
4202
|
if (!transaction) {
|
4409
4203
|
return null;
|
4410
4204
|
}
|
4411
|
-
return new
|
4412
|
-
(0,
|
4205
|
+
return new import_transactions18.TransactionCoder().decode(
|
4206
|
+
(0, import_utils23.arrayify)(transaction.rawPayload),
|
4413
4207
|
0
|
4414
4208
|
)?.[0];
|
4415
4209
|
}
|
@@ -4436,9 +4230,9 @@ var _Provider = class {
|
|
4436
4230
|
async getContractBalance(contractId, assetId) {
|
4437
4231
|
const { contractBalance } = await this.operations.getContractBalance({
|
4438
4232
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4439
|
-
asset: (0,
|
4233
|
+
asset: (0, import_utils23.hexlify)(assetId)
|
4440
4234
|
});
|
4441
|
-
return (0,
|
4235
|
+
return (0, import_math15.bn)(contractBalance.amount, 10);
|
4442
4236
|
}
|
4443
4237
|
/**
|
4444
4238
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4450,9 +4244,9 @@ var _Provider = class {
|
|
4450
4244
|
async getBalance(owner, assetId) {
|
4451
4245
|
const { balance } = await this.operations.getBalance({
|
4452
4246
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4453
|
-
assetId: (0,
|
4247
|
+
assetId: (0, import_utils23.hexlify)(assetId)
|
4454
4248
|
});
|
4455
|
-
return (0,
|
4249
|
+
return (0, import_math15.bn)(balance.amount, 10);
|
4456
4250
|
}
|
4457
4251
|
/**
|
4458
4252
|
* Returns balances for the given owner.
|
@@ -4470,7 +4264,7 @@ var _Provider = class {
|
|
4470
4264
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4471
4265
|
return balances.map((balance) => ({
|
4472
4266
|
assetId: balance.assetId,
|
4473
|
-
amount: (0,
|
4267
|
+
amount: (0, import_math15.bn)(balance.amount)
|
4474
4268
|
}));
|
4475
4269
|
}
|
4476
4270
|
/**
|
@@ -4488,19 +4282,19 @@ var _Provider = class {
|
|
4488
4282
|
});
|
4489
4283
|
const messages = result.messages.edges.map((edge) => edge.node);
|
4490
4284
|
return messages.map((message) => ({
|
4491
|
-
messageId:
|
4285
|
+
messageId: import_transactions18.InputMessageCoder.getMessageId({
|
4492
4286
|
sender: message.sender,
|
4493
4287
|
recipient: message.recipient,
|
4494
4288
|
nonce: message.nonce,
|
4495
|
-
amount: (0,
|
4289
|
+
amount: (0, import_math15.bn)(message.amount),
|
4496
4290
|
data: message.data
|
4497
4291
|
}),
|
4498
4292
|
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4499
4293
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4500
4294
|
nonce: message.nonce,
|
4501
|
-
amount: (0,
|
4502
|
-
data:
|
4503
|
-
daHeight: (0,
|
4295
|
+
amount: (0, import_math15.bn)(message.amount),
|
4296
|
+
data: import_transactions18.InputMessageCoder.decodeData(message.data),
|
4297
|
+
daHeight: (0, import_math15.bn)(message.daHeight)
|
4504
4298
|
}));
|
4505
4299
|
}
|
4506
4300
|
/**
|
@@ -4553,60 +4347,44 @@ var _Provider = class {
|
|
4553
4347
|
} = result.messageProof;
|
4554
4348
|
return {
|
4555
4349
|
messageProof: {
|
4556
|
-
proofIndex: (0,
|
4350
|
+
proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
|
4557
4351
|
proofSet: messageProof.proofSet
|
4558
4352
|
},
|
4559
4353
|
blockProof: {
|
4560
|
-
proofIndex: (0,
|
4354
|
+
proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
|
4561
4355
|
proofSet: blockProof.proofSet
|
4562
4356
|
},
|
4563
4357
|
messageBlockHeader: {
|
4564
4358
|
id: messageBlockHeader.id,
|
4565
|
-
daHeight: (0,
|
4566
|
-
transactionsCount: (0,
|
4359
|
+
daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
|
4360
|
+
transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
|
4567
4361
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4568
|
-
height: (0,
|
4362
|
+
height: (0, import_math15.bn)(messageBlockHeader.height),
|
4569
4363
|
prevRoot: messageBlockHeader.prevRoot,
|
4570
4364
|
time: messageBlockHeader.time,
|
4571
4365
|
applicationHash: messageBlockHeader.applicationHash,
|
4572
|
-
|
4573
|
-
|
4574
|
-
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4575
|
-
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4576
|
-
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4366
|
+
messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
|
4367
|
+
messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
|
4577
4368
|
},
|
4578
4369
|
commitBlockHeader: {
|
4579
4370
|
id: commitBlockHeader.id,
|
4580
|
-
daHeight: (0,
|
4581
|
-
transactionsCount: (0,
|
4371
|
+
daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
|
4372
|
+
transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
|
4582
4373
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4583
|
-
height: (0,
|
4374
|
+
height: (0, import_math15.bn)(commitBlockHeader.height),
|
4584
4375
|
prevRoot: commitBlockHeader.prevRoot,
|
4585
4376
|
time: commitBlockHeader.time,
|
4586
4377
|
applicationHash: commitBlockHeader.applicationHash,
|
4587
|
-
|
4588
|
-
|
4589
|
-
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4590
|
-
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4591
|
-
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4378
|
+
messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
|
4379
|
+
messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
|
4592
4380
|
},
|
4593
4381
|
sender: import_address3.Address.fromAddressOrString(sender),
|
4594
4382
|
recipient: import_address3.Address.fromAddressOrString(recipient),
|
4595
4383
|
nonce,
|
4596
|
-
amount: (0,
|
4384
|
+
amount: (0, import_math15.bn)(amount),
|
4597
4385
|
data
|
4598
4386
|
};
|
4599
4387
|
}
|
4600
|
-
async getLatestGasPrice() {
|
4601
|
-
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4602
|
-
return (0, import_math16.bn)(latestGasPrice.gasPrice);
|
4603
|
-
}
|
4604
|
-
async estimateGasPrice(blockHorizon) {
|
4605
|
-
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4606
|
-
blockHorizon: String(blockHorizon)
|
4607
|
-
});
|
4608
|
-
return (0, import_math16.bn)(estimateGasPrice.gasPrice);
|
4609
|
-
}
|
4610
4388
|
/**
|
4611
4389
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
4612
4390
|
*
|
@@ -4626,10 +4404,10 @@ var _Provider = class {
|
|
4626
4404
|
*/
|
4627
4405
|
async produceBlocks(amount, startTime) {
|
4628
4406
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4629
|
-
blocksToProduce: (0,
|
4630
|
-
startTimestamp: startTime ?
|
4407
|
+
blocksToProduce: (0, import_math15.bn)(amount).toString(10),
|
4408
|
+
startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4631
4409
|
});
|
4632
|
-
return (0,
|
4410
|
+
return (0, import_math15.bn)(latestBlockHeight);
|
4633
4411
|
}
|
4634
4412
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4635
4413
|
async getTransactionResponse(transactionId) {
|
@@ -4643,7 +4421,7 @@ cacheInputs_fn = function(inputs) {
|
|
4643
4421
|
return;
|
4644
4422
|
}
|
4645
4423
|
inputs.forEach((input) => {
|
4646
|
-
if (input.type ===
|
4424
|
+
if (input.type === import_transactions18.InputType.Coin) {
|
4647
4425
|
this.cache?.set(input.id);
|
4648
4426
|
}
|
4649
4427
|
});
|
@@ -4653,9 +4431,9 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4653
4431
|
|
4654
4432
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4655
4433
|
var import_errors15 = require("@fuel-ts/errors");
|
4656
|
-
var
|
4657
|
-
var
|
4658
|
-
var
|
4434
|
+
var import_math16 = require("@fuel-ts/math");
|
4435
|
+
var import_transactions19 = require("@fuel-ts/transactions");
|
4436
|
+
var import_utils26 = require("@fuel-ts/utils");
|
4659
4437
|
|
4660
4438
|
// src/providers/chains.ts
|
4661
4439
|
var CHAIN_IDS = {
|
@@ -4703,18 +4481,18 @@ var assets = [
|
|
4703
4481
|
];
|
4704
4482
|
|
4705
4483
|
// src/utils/formatTransferToContractScriptData.ts
|
4706
|
-
var
|
4707
|
-
var
|
4708
|
-
var
|
4484
|
+
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
4485
|
+
var import_math17 = require("@fuel-ts/math");
|
4486
|
+
var import_utils27 = require("@fuel-ts/utils");
|
4709
4487
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4710
4488
|
var formatTransferToContractScriptData = (params) => {
|
4711
4489
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4712
|
-
const numberCoder = new
|
4713
|
-
const encoded = numberCoder.encode(new
|
4490
|
+
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
4491
|
+
const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
|
4714
4492
|
const scriptData = Uint8Array.from([
|
4715
|
-
...(0,
|
4493
|
+
...(0, import_utils27.arrayify)(hexlifiedContractId),
|
4716
4494
|
...encoded,
|
4717
|
-
...(0,
|
4495
|
+
...(0, import_utils27.arrayify)(assetId)
|
4718
4496
|
]);
|
4719
4497
|
return scriptData;
|
4720
4498
|
};
|
@@ -4899,33 +4677,36 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4899
4677
|
* @param fee - The estimated transaction fee.
|
4900
4678
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4901
4679
|
*/
|
4902
|
-
async fund(request,
|
4903
|
-
const
|
4904
|
-
|
4905
|
-
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
4906
|
-
amount: (0, import_math19.bn)(fee),
|
4680
|
+
async fund(request, coinQuantities, fee) {
|
4681
|
+
const updatedQuantities = addAmountToAsset({
|
4682
|
+
amount: (0, import_math18.bn)(fee),
|
4907
4683
|
assetId: import_configs12.BaseAssetId,
|
4908
|
-
coinQuantities
|
4684
|
+
coinQuantities
|
4909
4685
|
});
|
4910
4686
|
const quantitiesDict = {};
|
4911
|
-
|
4687
|
+
updatedQuantities.forEach(({ amount, assetId }) => {
|
4912
4688
|
quantitiesDict[assetId] = {
|
4913
4689
|
required: amount,
|
4914
|
-
owned: (0,
|
4690
|
+
owned: (0, import_math18.bn)(0)
|
4915
4691
|
};
|
4916
4692
|
});
|
4917
|
-
|
4693
|
+
const cachedUtxos = [];
|
4694
|
+
const cachedMessages = [];
|
4695
|
+
const owner = this.address.toB256();
|
4696
|
+
request.inputs.forEach((input) => {
|
4918
4697
|
const isResource = "amount" in input;
|
4919
4698
|
if (isResource) {
|
4920
4699
|
const isCoin2 = "owner" in input;
|
4921
4700
|
if (isCoin2) {
|
4922
4701
|
const assetId = String(input.assetId);
|
4923
|
-
if (quantitiesDict[assetId]) {
|
4924
|
-
const amount = (0,
|
4702
|
+
if (input.owner === owner && quantitiesDict[assetId]) {
|
4703
|
+
const amount = (0, import_math18.bn)(input.amount);
|
4925
4704
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4705
|
+
cachedUtxos.push(input.id);
|
4926
4706
|
}
|
4927
|
-
} else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
|
4707
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
|
4928
4708
|
quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
|
4709
|
+
cachedMessages.push(input.nonce);
|
4929
4710
|
}
|
4930
4711
|
}
|
4931
4712
|
});
|
@@ -4940,23 +4721,12 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4940
4721
|
});
|
4941
4722
|
const needsToBeFunded = missingQuantities.length;
|
4942
4723
|
if (needsToBeFunded) {
|
4943
|
-
const
|
4944
|
-
|
4945
|
-
|
4946
|
-
|
4947
|
-
|
4948
|
-
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
4949
|
-
const requestToBeReEstimate = (0, import_ramda4.clone)(txRequest);
|
4950
|
-
if (addedSignatures) {
|
4951
|
-
Array.from({ length: addedSignatures }).forEach(
|
4952
|
-
() => requestToBeReEstimate.addEmptyWitness()
|
4953
|
-
);
|
4724
|
+
const resources = await this.getResourcesToSpend(missingQuantities, {
|
4725
|
+
messages: cachedMessages,
|
4726
|
+
utxos: cachedUtxos
|
4727
|
+
});
|
4728
|
+
request.addResources(resources);
|
4954
4729
|
}
|
4955
|
-
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
4956
|
-
transactionRequest: requestToBeReEstimate
|
4957
|
-
});
|
4958
|
-
txRequest.maxFee = maxFee;
|
4959
|
-
return txRequest;
|
4960
4730
|
}
|
4961
4731
|
/**
|
4962
4732
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -4964,25 +4734,28 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4964
4734
|
* @param destination - The address of the destination.
|
4965
4735
|
* @param amount - The amount of coins to transfer.
|
4966
4736
|
* @param assetId - The asset ID of the coins to transfer.
|
4967
|
-
* @param txParams - The transaction parameters (gasLimit,
|
4737
|
+
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4968
4738
|
* @returns A promise that resolves to the prepared transaction request.
|
4969
4739
|
*/
|
4970
4740
|
async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
4971
|
-
const
|
4741
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
4742
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
4743
|
+
const request = new ScriptTransactionRequest(params);
|
4972
4744
|
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
|
4973
|
-
const
|
4745
|
+
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
4974
4746
|
estimateTxDependencies: true,
|
4975
4747
|
resourcesOwner: this
|
4976
4748
|
});
|
4977
|
-
|
4978
|
-
|
4979
|
-
|
4980
|
-
|
4981
|
-
|
4982
|
-
|
4983
|
-
|
4984
|
-
|
4985
|
-
await this.fund(request,
|
4749
|
+
request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
|
4750
|
+
request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
|
4751
|
+
this.validateGas({
|
4752
|
+
gasUsed,
|
4753
|
+
gasPrice: request.gasPrice,
|
4754
|
+
gasLimit: request.gasLimit,
|
4755
|
+
minGasPrice
|
4756
|
+
});
|
4757
|
+
await this.fund(request, requiredQuantities, maxFee);
|
4758
|
+
request.updatePredicateInputs(estimatedInputs);
|
4986
4759
|
return request;
|
4987
4760
|
}
|
4988
4761
|
/**
|
@@ -4995,7 +4768,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4995
4768
|
* @returns A promise that resolves to the transaction response.
|
4996
4769
|
*/
|
4997
4770
|
async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
4998
|
-
if ((0,
|
4771
|
+
if ((0, import_math18.bn)(amount).lte(0)) {
|
4999
4772
|
throw new import_errors16.FuelError(
|
5000
4773
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5001
4774
|
"Transfer amount must be a positive number."
|
@@ -5014,37 +4787,38 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5014
4787
|
* @returns A promise that resolves to the transaction response.
|
5015
4788
|
*/
|
5016
4789
|
async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
5017
|
-
if ((0,
|
4790
|
+
if ((0, import_math18.bn)(amount).lte(0)) {
|
5018
4791
|
throw new import_errors16.FuelError(
|
5019
4792
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5020
4793
|
"Transfer amount must be a positive number."
|
5021
4794
|
);
|
5022
4795
|
}
|
5023
4796
|
const contractAddress = import_address4.Address.fromAddressOrString(contractId);
|
4797
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
4798
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
5024
4799
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5025
4800
|
hexlifiedContractId: contractAddress.toB256(),
|
5026
|
-
amountToTransfer: (0,
|
4801
|
+
amountToTransfer: (0, import_math18.bn)(amount),
|
5027
4802
|
assetId
|
5028
4803
|
});
|
5029
4804
|
const request = new ScriptTransactionRequest({
|
5030
|
-
...
|
4805
|
+
...params,
|
5031
4806
|
script,
|
5032
4807
|
scriptData
|
5033
4808
|
});
|
5034
4809
|
request.addContractInputAndOutput(contractAddress);
|
5035
|
-
const
|
5036
|
-
|
5037
|
-
|
4810
|
+
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
4811
|
+
request,
|
4812
|
+
[{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
|
4813
|
+
);
|
4814
|
+
request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
|
4815
|
+
this.validateGas({
|
4816
|
+
gasUsed,
|
4817
|
+
gasPrice: request.gasPrice,
|
4818
|
+
gasLimit: request.gasLimit,
|
4819
|
+
minGasPrice
|
5038
4820
|
});
|
5039
|
-
|
5040
|
-
this.validateGas({
|
5041
|
-
gasUsed: txCost.gasUsed,
|
5042
|
-
gasLimit: request.gasLimit
|
5043
|
-
});
|
5044
|
-
}
|
5045
|
-
request.gasLimit = txCost.gasUsed;
|
5046
|
-
request.maxFee = txCost.maxFee;
|
5047
|
-
await this.fund(request, txCost);
|
4821
|
+
await this.fund(request, requiredQuantities, maxFee);
|
5048
4822
|
return this.sendTransaction(request);
|
5049
4823
|
}
|
5050
4824
|
/**
|
@@ -5056,31 +4830,34 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5056
4830
|
* @returns A promise that resolves to the transaction response.
|
5057
4831
|
*/
|
5058
4832
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4833
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
5059
4834
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5060
|
-
const recipientDataArray = (0,
|
4835
|
+
const recipientDataArray = (0, import_utils28.arrayify)(
|
5061
4836
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5062
4837
|
);
|
5063
|
-
const amountDataArray = (0,
|
5064
|
-
"0x".concat((0,
|
4838
|
+
const amountDataArray = (0, import_utils28.arrayify)(
|
4839
|
+
"0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5065
4840
|
);
|
5066
4841
|
const script = new Uint8Array([
|
5067
|
-
...(0,
|
4842
|
+
...(0, import_utils28.arrayify)(withdrawScript.bytes),
|
5068
4843
|
...recipientDataArray,
|
5069
4844
|
...amountDataArray
|
5070
4845
|
]);
|
5071
|
-
const params = { script, ...txParams };
|
4846
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
5072
4847
|
const request = new ScriptTransactionRequest(params);
|
5073
|
-
const
|
5074
|
-
const
|
5075
|
-
|
5076
|
-
|
5077
|
-
|
5078
|
-
|
5079
|
-
|
5080
|
-
|
5081
|
-
|
5082
|
-
|
5083
|
-
|
4848
|
+
const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
|
4849
|
+
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
4850
|
+
request,
|
4851
|
+
forwardingQuantities
|
4852
|
+
);
|
4853
|
+
request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
|
4854
|
+
this.validateGas({
|
4855
|
+
gasUsed,
|
4856
|
+
gasPrice: request.gasPrice,
|
4857
|
+
gasLimit: request.gasLimit,
|
4858
|
+
minGasPrice
|
4859
|
+
});
|
4860
|
+
await this.fund(request, requiredQuantities, maxFee);
|
5084
4861
|
return this.sendTransaction(request);
|
5085
4862
|
}
|
5086
4863
|
async signMessage(message) {
|
@@ -5138,7 +4915,18 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5138
4915
|
}
|
5139
4916
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5140
4917
|
}
|
5141
|
-
validateGas({
|
4918
|
+
validateGas({
|
4919
|
+
gasUsed,
|
4920
|
+
gasPrice,
|
4921
|
+
gasLimit,
|
4922
|
+
minGasPrice
|
4923
|
+
}) {
|
4924
|
+
if (minGasPrice.gt(gasPrice)) {
|
4925
|
+
throw new import_errors16.FuelError(
|
4926
|
+
import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
|
4927
|
+
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
4928
|
+
);
|
4929
|
+
}
|
5142
4930
|
if (gasUsed.gt(gasLimit)) {
|
5143
4931
|
throw new import_errors16.FuelError(
|
5144
4932
|
import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
|
@@ -5150,10 +4938,10 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5150
4938
|
|
5151
4939
|
// src/signer/signer.ts
|
5152
4940
|
var import_address5 = require("@fuel-ts/address");
|
5153
|
-
var
|
4941
|
+
var import_crypto2 = require("@fuel-ts/crypto");
|
5154
4942
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5155
|
-
var
|
5156
|
-
var
|
4943
|
+
var import_math19 = require("@fuel-ts/math");
|
4944
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5157
4945
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5158
4946
|
var Signer = class {
|
5159
4947
|
address;
|
@@ -5172,10 +4960,10 @@ var Signer = class {
|
|
5172
4960
|
privateKey = `0x${privateKey}`;
|
5173
4961
|
}
|
5174
4962
|
}
|
5175
|
-
const privateKeyBytes = (0,
|
5176
|
-
this.privateKey = (0,
|
5177
|
-
this.publicKey = (0,
|
5178
|
-
this.compressedPublicKey = (0,
|
4963
|
+
const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
|
4964
|
+
this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
|
4965
|
+
this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
4966
|
+
this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
5179
4967
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
5180
4968
|
}
|
5181
4969
|
/**
|
@@ -5189,11 +4977,11 @@ var Signer = class {
|
|
5189
4977
|
* @returns hashed signature
|
5190
4978
|
*/
|
5191
4979
|
sign(data) {
|
5192
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
5193
|
-
const r = (0,
|
5194
|
-
const s = (0,
|
4980
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
|
4981
|
+
const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
4982
|
+
const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5195
4983
|
s[0] |= (signature.recovery || 0) << 7;
|
5196
|
-
return (0,
|
4984
|
+
return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
|
5197
4985
|
}
|
5198
4986
|
/**
|
5199
4987
|
* Add point on the current elliptic curve
|
@@ -5202,8 +4990,8 @@ var Signer = class {
|
|
5202
4990
|
* @returns compressed point on the curve
|
5203
4991
|
*/
|
5204
4992
|
addPoint(point) {
|
5205
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5206
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
4993
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
|
4994
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
|
5207
4995
|
const result = p0.add(p1);
|
5208
4996
|
return `0x${result.toHex(true)}`;
|
5209
4997
|
}
|
@@ -5215,16 +5003,16 @@ var Signer = class {
|
|
5215
5003
|
* @returns public key from signature from the
|
5216
5004
|
*/
|
5217
5005
|
static recoverPublicKey(data, signature) {
|
5218
|
-
const signedMessageBytes = (0,
|
5006
|
+
const signedMessageBytes = (0, import_utils29.arrayify)(signature);
|
5219
5007
|
const r = signedMessageBytes.slice(0, 32);
|
5220
5008
|
const s = signedMessageBytes.slice(32, 64);
|
5221
5009
|
const recoveryParam = (s[0] & 128) >> 7;
|
5222
5010
|
s[0] &= 127;
|
5223
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5011
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
|
5224
5012
|
recoveryParam
|
5225
5013
|
);
|
5226
|
-
const publicKey = sig.recoverPublicKey((0,
|
5227
|
-
return (0,
|
5014
|
+
const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
|
5015
|
+
return (0, import_utils29.hexlify)(publicKey);
|
5228
5016
|
}
|
5229
5017
|
/**
|
5230
5018
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5243,7 +5031,7 @@ var Signer = class {
|
|
5243
5031
|
* @returns random 32-byte hashed
|
5244
5032
|
*/
|
5245
5033
|
static generatePrivateKey(entropy) {
|
5246
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5034
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
|
5247
5035
|
}
|
5248
5036
|
/**
|
5249
5037
|
* Extended publicKey from a compact publicKey
|
@@ -5252,16 +5040,16 @@ var Signer = class {
|
|
5252
5040
|
* @returns extended publicKey
|
5253
5041
|
*/
|
5254
5042
|
static extendPublicKey(publicKey) {
|
5255
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5256
|
-
return (0,
|
5043
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
|
5044
|
+
return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
|
5257
5045
|
}
|
5258
5046
|
};
|
5259
5047
|
|
5260
5048
|
// src/wallet/keystore-wallet.ts
|
5261
5049
|
var import_address6 = require("@fuel-ts/address");
|
5262
|
-
var
|
5050
|
+
var import_crypto3 = require("@fuel-ts/crypto");
|
5263
5051
|
var import_errors17 = require("@fuel-ts/errors");
|
5264
|
-
var
|
5052
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5265
5053
|
var import_uuid = require("uuid");
|
5266
5054
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5267
5055
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5275,22 +5063,22 @@ var removeHexPrefix = (hexString) => {
|
|
5275
5063
|
return hexString;
|
5276
5064
|
};
|
5277
5065
|
async function encryptKeystoreWallet(privateKey, address, password) {
|
5278
|
-
const privateKeyBuffer = (0,
|
5066
|
+
const privateKeyBuffer = (0, import_crypto3.bufferFromString)(removeHexPrefix(privateKey), "hex");
|
5279
5067
|
const ownerAddress = import_address6.Address.fromAddressOrString(address);
|
5280
|
-
const salt = (0,
|
5281
|
-
const key = (0,
|
5282
|
-
password: (0,
|
5068
|
+
const salt = (0, import_crypto3.randomBytes)(DEFAULT_KEY_SIZE);
|
5069
|
+
const key = (0, import_crypto3.scrypt)({
|
5070
|
+
password: (0, import_crypto3.bufferFromString)(password),
|
5283
5071
|
salt,
|
5284
5072
|
dklen: DEFAULT_KEY_SIZE,
|
5285
5073
|
n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
|
5286
5074
|
r: DEFAULT_KDF_PARAMS_R,
|
5287
5075
|
p: DEFAULT_KDF_PARAMS_P
|
5288
5076
|
});
|
5289
|
-
const iv = (0,
|
5290
|
-
const ciphertext = await (0,
|
5077
|
+
const iv = (0, import_crypto3.randomBytes)(DEFAULT_IV_SIZE);
|
5078
|
+
const ciphertext = await (0, import_crypto3.encryptJsonWalletData)(privateKeyBuffer, key, iv);
|
5291
5079
|
const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
|
5292
|
-
const macHashUint8Array = (0,
|
5293
|
-
const mac = (0,
|
5080
|
+
const macHashUint8Array = (0, import_crypto3.keccak256)(data);
|
5081
|
+
const mac = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
|
5294
5082
|
const keystore = {
|
5295
5083
|
id: (0, import_uuid.v4)(),
|
5296
5084
|
version: 3,
|
@@ -5298,15 +5086,15 @@ async function encryptKeystoreWallet(privateKey, address, password) {
|
|
5298
5086
|
crypto: {
|
5299
5087
|
cipher: "aes-128-ctr",
|
5300
5088
|
mac,
|
5301
|
-
cipherparams: { iv: (0,
|
5302
|
-
ciphertext: (0,
|
5089
|
+
cipherparams: { iv: (0, import_crypto3.stringFromBuffer)(iv, "hex") },
|
5090
|
+
ciphertext: (0, import_crypto3.stringFromBuffer)(ciphertext, "hex"),
|
5303
5091
|
kdf: "scrypt",
|
5304
5092
|
kdfparams: {
|
5305
5093
|
dklen: DEFAULT_KEY_SIZE,
|
5306
5094
|
n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
|
5307
5095
|
p: DEFAULT_KDF_PARAMS_P,
|
5308
5096
|
r: DEFAULT_KDF_PARAMS_R,
|
5309
|
-
salt: (0,
|
5097
|
+
salt: (0, import_crypto3.stringFromBuffer)(salt, "hex")
|
5310
5098
|
}
|
5311
5099
|
}
|
5312
5100
|
};
|
@@ -5322,11 +5110,11 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5322
5110
|
kdfparams: { dklen, n, r, p, salt }
|
5323
5111
|
}
|
5324
5112
|
} = keystoreWallet;
|
5325
|
-
const ciphertextBuffer = (0,
|
5326
|
-
const ivBuffer = (0,
|
5327
|
-
const saltBuffer = (0,
|
5328
|
-
const passwordBuffer = (0,
|
5329
|
-
const key = (0,
|
5113
|
+
const ciphertextBuffer = (0, import_crypto3.bufferFromString)(ciphertext, "hex");
|
5114
|
+
const ivBuffer = (0, import_crypto3.bufferFromString)(iv, "hex");
|
5115
|
+
const saltBuffer = (0, import_crypto3.bufferFromString)(salt, "hex");
|
5116
|
+
const passwordBuffer = (0, import_crypto3.bufferFromString)(password);
|
5117
|
+
const key = (0, import_crypto3.scrypt)({
|
5330
5118
|
password: passwordBuffer,
|
5331
5119
|
salt: saltBuffer,
|
5332
5120
|
n,
|
@@ -5335,16 +5123,16 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5335
5123
|
dklen
|
5336
5124
|
});
|
5337
5125
|
const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertextBuffer]);
|
5338
|
-
const macHashUint8Array = (0,
|
5339
|
-
const macHash = (0,
|
5126
|
+
const macHashUint8Array = (0, import_crypto3.keccak256)(data);
|
5127
|
+
const macHash = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
|
5340
5128
|
if (mac !== macHash) {
|
5341
5129
|
throw new import_errors17.FuelError(
|
5342
5130
|
import_errors17.ErrorCode.INVALID_PASSWORD,
|
5343
5131
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
5344
5132
|
);
|
5345
5133
|
}
|
5346
|
-
const buffer = await (0,
|
5347
|
-
const privateKey = (0,
|
5134
|
+
const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
5135
|
+
const privateKey = (0, import_utils30.hexlify)(buffer);
|
5348
5136
|
return privateKey;
|
5349
5137
|
}
|
5350
5138
|
|
@@ -5389,7 +5177,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5389
5177
|
*/
|
5390
5178
|
async signMessage(message) {
|
5391
5179
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
5392
|
-
return (0,
|
5180
|
+
return (0, import_utils31.hexlify)(signedMessage);
|
5393
5181
|
}
|
5394
5182
|
/**
|
5395
5183
|
* Signs a transaction with the wallet's private key.
|
@@ -5402,7 +5190,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5402
5190
|
const chainId = this.provider.getChainId();
|
5403
5191
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5404
5192
|
const signature = await this.signer().sign(hashedTransaction);
|
5405
|
-
return (0,
|
5193
|
+
return (0, import_utils31.hexlify)(signature);
|
5406
5194
|
}
|
5407
5195
|
/**
|
5408
5196
|
* Populates a transaction with the witnesses signature.
|
@@ -5422,7 +5210,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5422
5210
|
* @param transactionRequestLike - The transaction request to send.
|
5423
5211
|
* @returns A promise that resolves to the TransactionResponse object.
|
5424
5212
|
*/
|
5425
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
5213
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
5426
5214
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5427
5215
|
if (estimateTxDependencies) {
|
5428
5216
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -5463,16 +5251,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5463
5251
|
// src/hdwallet/hdwallet.ts
|
5464
5252
|
var import_errors20 = require("@fuel-ts/errors");
|
5465
5253
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5466
|
-
var
|
5467
|
-
var
|
5468
|
-
var
|
5254
|
+
var import_math20 = require("@fuel-ts/math");
|
5255
|
+
var import_utils35 = require("@fuel-ts/utils");
|
5256
|
+
var import_ethers3 = require("ethers");
|
5469
5257
|
|
5470
5258
|
// src/mnemonic/mnemonic.ts
|
5471
|
-
var
|
5259
|
+
var import_crypto4 = require("@fuel-ts/crypto");
|
5472
5260
|
var import_errors19 = require("@fuel-ts/errors");
|
5473
5261
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5474
|
-
var
|
5475
|
-
var
|
5262
|
+
var import_utils33 = require("@fuel-ts/utils");
|
5263
|
+
var import_ethers2 = require("ethers");
|
5476
5264
|
|
5477
5265
|
// src/wordlists/words/english.ts
|
5478
5266
|
var english = [
|
@@ -7529,7 +7317,7 @@ var english = [
|
|
7529
7317
|
// src/mnemonic/utils.ts
|
7530
7318
|
var import_errors18 = require("@fuel-ts/errors");
|
7531
7319
|
var import_hasher4 = require("@fuel-ts/hasher");
|
7532
|
-
var
|
7320
|
+
var import_utils32 = require("@fuel-ts/utils");
|
7533
7321
|
function toUtf8Bytes(stri) {
|
7534
7322
|
const str = stri.normalize("NFKD");
|
7535
7323
|
const result = [];
|
@@ -7596,14 +7384,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
7596
7384
|
}
|
7597
7385
|
}
|
7598
7386
|
const checksumBits = entropy.length / 4;
|
7599
|
-
const checksum = (0,
|
7387
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
7600
7388
|
indices[indices.length - 1] <<= checksumBits;
|
7601
7389
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7602
7390
|
return indices;
|
7603
7391
|
}
|
7604
7392
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7605
7393
|
const size = Math.ceil(11 * words.length / 8);
|
7606
|
-
const entropy = (0,
|
7394
|
+
const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
|
7607
7395
|
let offset = 0;
|
7608
7396
|
for (let i = 0; i < words.length; i += 1) {
|
7609
7397
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -7623,7 +7411,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7623
7411
|
const entropyBits = 32 * words.length / 3;
|
7624
7412
|
const checksumBits = words.length / 3;
|
7625
7413
|
const checksumMask = getUpperMask(checksumBits);
|
7626
|
-
const checksum = (0,
|
7414
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7627
7415
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7628
7416
|
throw new import_errors18.FuelError(
|
7629
7417
|
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
@@ -7698,7 +7486,7 @@ var Mnemonic = class {
|
|
7698
7486
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7699
7487
|
const words = getWords(phrase);
|
7700
7488
|
assertMnemonic(words);
|
7701
|
-
return (0,
|
7489
|
+
return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
7702
7490
|
}
|
7703
7491
|
/**
|
7704
7492
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7706,7 +7494,7 @@ var Mnemonic = class {
|
|
7706
7494
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7707
7495
|
*/
|
7708
7496
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7709
|
-
const entropyBytes = (0,
|
7497
|
+
const entropyBytes = (0, import_utils33.arrayify)(entropy);
|
7710
7498
|
assertWordList(wordlist);
|
7711
7499
|
assertEntropy(entropyBytes);
|
7712
7500
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7720,7 +7508,7 @@ var Mnemonic = class {
|
|
7720
7508
|
assertMnemonic(getWords(phrase));
|
7721
7509
|
const phraseBytes = toUtf8Bytes(getPhrase(phrase));
|
7722
7510
|
const salt = toUtf8Bytes(`mnemonic${passphrase}`);
|
7723
|
-
return (0,
|
7511
|
+
return (0, import_ethers2.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
7724
7512
|
}
|
7725
7513
|
/**
|
7726
7514
|
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
|
@@ -7775,14 +7563,14 @@ var Mnemonic = class {
|
|
7775
7563
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7776
7564
|
*/
|
7777
7565
|
static masterKeysFromSeed(seed) {
|
7778
|
-
const seedArray = (0,
|
7566
|
+
const seedArray = (0, import_utils33.arrayify)(seed);
|
7779
7567
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7780
7568
|
throw new import_errors19.FuelError(
|
7781
7569
|
import_errors19.ErrorCode.INVALID_SEED,
|
7782
7570
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7783
7571
|
);
|
7784
7572
|
}
|
7785
|
-
return (0,
|
7573
|
+
return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
|
7786
7574
|
}
|
7787
7575
|
/**
|
7788
7576
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7793,22 +7581,22 @@ var Mnemonic = class {
|
|
7793
7581
|
*/
|
7794
7582
|
static seedToExtendedKey(seed, testnet = false) {
|
7795
7583
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7796
|
-
const prefix = (0,
|
7584
|
+
const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
7797
7585
|
const depth = "0x00";
|
7798
7586
|
const fingerprint = "0x00000000";
|
7799
7587
|
const index = "0x00000000";
|
7800
7588
|
const chainCode = masterKey.slice(32);
|
7801
7589
|
const privateKey = masterKey.slice(0, 32);
|
7802
|
-
const extendedKey = (0,
|
7590
|
+
const extendedKey = (0, import_utils33.concat)([
|
7803
7591
|
prefix,
|
7804
7592
|
depth,
|
7805
7593
|
fingerprint,
|
7806
7594
|
index,
|
7807
7595
|
chainCode,
|
7808
|
-
(0,
|
7596
|
+
(0, import_utils33.concat)(["0x00", privateKey])
|
7809
7597
|
]);
|
7810
|
-
const checksum = (0,
|
7811
|
-
return (0,
|
7598
|
+
const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
7599
|
+
return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
|
7812
7600
|
}
|
7813
7601
|
/**
|
7814
7602
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -7823,7 +7611,7 @@ var Mnemonic = class {
|
|
7823
7611
|
* @returns A randomly generated mnemonic
|
7824
7612
|
*/
|
7825
7613
|
static generate(size = 32, extraEntropy = "") {
|
7826
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
7614
|
+
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
|
7827
7615
|
return Mnemonic.entropyToMnemonic(entropy);
|
7828
7616
|
}
|
7829
7617
|
};
|
@@ -7831,12 +7619,12 @@ var mnemonic_default = Mnemonic;
|
|
7831
7619
|
|
7832
7620
|
// src/hdwallet/hdwallet.ts
|
7833
7621
|
var HARDENED_INDEX = 2147483648;
|
7834
|
-
var MainnetPRV2 = (0,
|
7835
|
-
var MainnetPUB = (0,
|
7836
|
-
var TestnetPRV2 = (0,
|
7837
|
-
var TestnetPUB = (0,
|
7622
|
+
var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
|
7623
|
+
var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
|
7624
|
+
var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
|
7625
|
+
var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
|
7838
7626
|
function base58check(data) {
|
7839
|
-
return (0,
|
7627
|
+
return (0, import_ethers3.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
7840
7628
|
}
|
7841
7629
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
7842
7630
|
if (isPublic) {
|
@@ -7845,11 +7633,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
7845
7633
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
7846
7634
|
}
|
7847
7635
|
function isPublicExtendedKey(extendedKey) {
|
7848
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
7636
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
|
7849
7637
|
}
|
7850
7638
|
function isValidExtendedKey(extendedKey) {
|
7851
7639
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
7852
|
-
(0,
|
7640
|
+
(0, import_utils35.hexlify)(extendedKey.slice(0, 4))
|
7853
7641
|
);
|
7854
7642
|
}
|
7855
7643
|
function parsePath(path2, depth = 0) {
|
@@ -7867,8 +7655,8 @@ function parsePath(path2, depth = 0) {
|
|
7867
7655
|
var HDWallet = class {
|
7868
7656
|
depth = 0;
|
7869
7657
|
index = 0;
|
7870
|
-
fingerprint = (0,
|
7871
|
-
parentFingerprint = (0,
|
7658
|
+
fingerprint = (0, import_utils35.hexlify)("0x00000000");
|
7659
|
+
parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
|
7872
7660
|
privateKey;
|
7873
7661
|
publicKey;
|
7874
7662
|
chainCode;
|
@@ -7880,8 +7668,8 @@ var HDWallet = class {
|
|
7880
7668
|
constructor(config) {
|
7881
7669
|
if (config.privateKey) {
|
7882
7670
|
const signer = new Signer(config.privateKey);
|
7883
|
-
this.publicKey = (0,
|
7884
|
-
this.privateKey = (0,
|
7671
|
+
this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
|
7672
|
+
this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
|
7885
7673
|
} else {
|
7886
7674
|
if (!config.publicKey) {
|
7887
7675
|
throw new import_errors20.FuelError(
|
@@ -7889,10 +7677,10 @@ var HDWallet = class {
|
|
7889
7677
|
"Both public and private Key cannot be missing. At least one should be provided."
|
7890
7678
|
);
|
7891
7679
|
}
|
7892
|
-
this.publicKey = (0,
|
7680
|
+
this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
|
7893
7681
|
}
|
7894
7682
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
7895
|
-
this.fingerprint = (0,
|
7683
|
+
this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
7896
7684
|
this.depth = config.depth || this.depth;
|
7897
7685
|
this.index = config.index || this.index;
|
7898
7686
|
this.chainCode = config.chainCode;
|
@@ -7908,9 +7696,9 @@ var HDWallet = class {
|
|
7908
7696
|
* @returns A new instance of HDWallet on the derived index
|
7909
7697
|
*/
|
7910
7698
|
deriveIndex(index) {
|
7911
|
-
const privateKey = this.privateKey && (0,
|
7912
|
-
const publicKey = (0,
|
7913
|
-
const chainCode = (0,
|
7699
|
+
const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
|
7700
|
+
const publicKey = (0, import_utils35.arrayify)(this.publicKey);
|
7701
|
+
const chainCode = (0, import_utils35.arrayify)(this.chainCode);
|
7914
7702
|
const data = new Uint8Array(37);
|
7915
7703
|
if (index & HARDENED_INDEX) {
|
7916
7704
|
if (!privateKey) {
|
@@ -7921,15 +7709,15 @@ var HDWallet = class {
|
|
7921
7709
|
}
|
7922
7710
|
data.set(privateKey, 1);
|
7923
7711
|
} else {
|
7924
|
-
data.set((0,
|
7712
|
+
data.set((0, import_utils35.arrayify)(this.publicKey));
|
7925
7713
|
}
|
7926
|
-
data.set((0,
|
7927
|
-
const bytes = (0,
|
7714
|
+
data.set((0, import_math20.toBytes)(index, 4), 33);
|
7715
|
+
const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
|
7928
7716
|
const IL = bytes.slice(0, 32);
|
7929
7717
|
const IR = bytes.slice(32);
|
7930
7718
|
if (privateKey) {
|
7931
7719
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7932
|
-
const ki = (0,
|
7720
|
+
const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
7933
7721
|
return new HDWallet({
|
7934
7722
|
privateKey: ki,
|
7935
7723
|
chainCode: IR,
|
@@ -7938,7 +7726,7 @@ var HDWallet = class {
|
|
7938
7726
|
parentFingerprint: this.fingerprint
|
7939
7727
|
});
|
7940
7728
|
}
|
7941
|
-
const signer = new Signer((0,
|
7729
|
+
const signer = new Signer((0, import_utils35.hexlify)(IL));
|
7942
7730
|
const Ki = signer.addPoint(publicKey);
|
7943
7731
|
return new HDWallet({
|
7944
7732
|
publicKey: Ki,
|
@@ -7973,12 +7761,12 @@ var HDWallet = class {
|
|
7973
7761
|
);
|
7974
7762
|
}
|
7975
7763
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
7976
|
-
const depth = (0,
|
7764
|
+
const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
|
7977
7765
|
const parentFingerprint = this.parentFingerprint;
|
7978
|
-
const index = (0,
|
7766
|
+
const index = (0, import_math20.toHex)(this.index, 4);
|
7979
7767
|
const chainCode = this.chainCode;
|
7980
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
7981
|
-
const extendedKey = (0,
|
7768
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
|
7769
|
+
const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
7982
7770
|
return base58check(extendedKey);
|
7983
7771
|
}
|
7984
7772
|
/**
|
@@ -7990,13 +7778,13 @@ var HDWallet = class {
|
|
7990
7778
|
static fromSeed(seed) {
|
7991
7779
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
7992
7780
|
return new HDWallet({
|
7993
|
-
chainCode: (0,
|
7994
|
-
privateKey: (0,
|
7781
|
+
chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
|
7782
|
+
privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
|
7995
7783
|
});
|
7996
7784
|
}
|
7997
7785
|
static fromExtendedKey(extendedKey) {
|
7998
|
-
const decoded = (0,
|
7999
|
-
const bytes = (0,
|
7786
|
+
const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
|
7787
|
+
const bytes = (0, import_utils35.arrayify)(decoded);
|
8000
7788
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8001
7789
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8002
7790
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -8005,9 +7793,9 @@ var HDWallet = class {
|
|
8005
7793
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8006
7794
|
}
|
8007
7795
|
const depth = bytes[4];
|
8008
|
-
const parentFingerprint = (0,
|
8009
|
-
const index = parseInt((0,
|
8010
|
-
const chainCode = (0,
|
7796
|
+
const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
|
7797
|
+
const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
7798
|
+
const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
|
8011
7799
|
const key = bytes.slice(45, 78);
|
8012
7800
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8013
7801
|
throw new import_errors20.FuelError(
|
@@ -8194,21 +7982,20 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
|
|
8194
7982
|
__publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
8195
7983
|
|
8196
7984
|
// src/test-utils/seedTestWallet.ts
|
8197
|
-
var
|
7985
|
+
var import_crypto5 = require("@fuel-ts/crypto");
|
8198
7986
|
var seedTestWallet = async (wallet, quantities) => {
|
8199
7987
|
const genesisWallet = new WalletUnlocked(
|
8200
|
-
process.env.GENESIS_SECRET || (0,
|
7988
|
+
process.env.GENESIS_SECRET || (0, import_crypto5.randomBytes)(32),
|
8201
7989
|
wallet.provider
|
8202
7990
|
);
|
8203
|
-
const
|
8204
|
-
|
8205
|
-
|
8206
|
-
|
7991
|
+
const resources = await genesisWallet.getResourcesToSpend(quantities);
|
7992
|
+
const { minGasPrice } = genesisWallet.provider.getGasConfig();
|
7993
|
+
const request = new ScriptTransactionRequest({
|
7994
|
+
gasLimit: 1e4,
|
7995
|
+
gasPrice: minGasPrice
|
8207
7996
|
});
|
8208
|
-
|
8209
|
-
request.
|
8210
|
-
request.maxFee = txCost.maxFee;
|
8211
|
-
await genesisWallet.fund(request, txCost);
|
7997
|
+
request.addResources(resources);
|
7998
|
+
quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
|
8212
7999
|
await genesisWallet.sendTransaction(request, { awaitExecution: true });
|
8213
8000
|
};
|
8214
8001
|
|
@@ -8223,11 +8010,11 @@ var generateTestWallet = async (provider, quantities) => {
|
|
8223
8010
|
|
8224
8011
|
// src/test-utils/launchNode.ts
|
8225
8012
|
var import_configs13 = require("@fuel-ts/address/configs");
|
8226
|
-
var
|
8013
|
+
var import_math21 = require("@fuel-ts/math");
|
8014
|
+
var import_utils36 = require("@fuel-ts/utils");
|
8227
8015
|
var import_cli_utils = require("@fuel-ts/utils/cli-utils");
|
8228
8016
|
var import_child_process = require("child_process");
|
8229
|
-
var
|
8230
|
-
var import_ethers5 = require("ethers");
|
8017
|
+
var import_crypto6 = require("crypto");
|
8231
8018
|
var import_fs = require("fs");
|
8232
8019
|
var import_os = __toESM(require("os"));
|
8233
8020
|
var import_path = __toESM(require("path"));
|
@@ -8276,13 +8063,13 @@ var launchNode = async ({
|
|
8276
8063
|
// eslint-disable-next-line no-async-promise-executor
|
8277
8064
|
new Promise(async (resolve, reject) => {
|
8278
8065
|
const remainingArgs = extractRemainingArgs(args, [
|
8279
|
-
"--
|
8066
|
+
"--chain",
|
8280
8067
|
"--consensus-key",
|
8281
8068
|
"--db-type",
|
8282
8069
|
"--poa-instant"
|
8283
8070
|
]);
|
8284
|
-
const chainConfigPath = getFlagValueFromArgs(args, "--
|
8285
|
-
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") ||
|
8071
|
+
const chainConfigPath = getFlagValueFromArgs(args, "--chain");
|
8072
|
+
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
|
8286
8073
|
const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
|
8287
8074
|
const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
|
8288
8075
|
const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
|
@@ -8299,55 +8086,37 @@ var launchNode = async ({
|
|
8299
8086
|
})).toString();
|
8300
8087
|
let chainConfigPathToUse;
|
8301
8088
|
const prefix = basePath || import_os.default.tmpdir();
|
8302
|
-
const suffix = basePath ? "" : (0,
|
8303
|
-
const tempDirPath = import_path.default.join(prefix, ".fuels", suffix
|
8089
|
+
const suffix = basePath ? "" : (0, import_crypto6.randomUUID)();
|
8090
|
+
const tempDirPath = import_path.default.join(prefix, ".fuels", suffix);
|
8304
8091
|
if (chainConfigPath) {
|
8305
8092
|
chainConfigPathToUse = chainConfigPath;
|
8306
8093
|
} else {
|
8307
8094
|
if (!(0, import_fs.existsSync)(tempDirPath)) {
|
8308
8095
|
(0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
|
8309
8096
|
}
|
8310
|
-
|
8311
|
-
|
8312
|
-
stateConfigJson = {
|
8313
|
-
...stateConfigJson,
|
8314
|
-
coins: [
|
8315
|
-
...stateConfigJson.coins.map((coin) => ({
|
8316
|
-
...coin,
|
8317
|
-
amount: "18446744073709551615"
|
8318
|
-
}))
|
8319
|
-
],
|
8320
|
-
messages: stateConfigJson.messages.map((message) => ({
|
8321
|
-
...message,
|
8322
|
-
amount: "18446744073709551615"
|
8323
|
-
}))
|
8324
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8325
|
-
};
|
8097
|
+
const tempChainConfigFilePath = import_path.default.join(tempDirPath, "chainConfig.json");
|
8098
|
+
let chainConfig = import_utils36.defaultChainConfig;
|
8326
8099
|
if (!process.env.GENESIS_SECRET) {
|
8327
8100
|
const pk = Signer.generatePrivateKey();
|
8328
8101
|
const signer = new Signer(pk);
|
8329
|
-
process.env.GENESIS_SECRET = (0,
|
8330
|
-
|
8331
|
-
|
8332
|
-
|
8333
|
-
|
8334
|
-
|
8335
|
-
|
8336
|
-
|
8337
|
-
|
8338
|
-
|
8339
|
-
|
8102
|
+
process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
|
8103
|
+
chainConfig = {
|
8104
|
+
...import_utils36.defaultChainConfig,
|
8105
|
+
initial_state: {
|
8106
|
+
...import_utils36.defaultChainConfig.initial_state,
|
8107
|
+
coins: [
|
8108
|
+
...import_utils36.defaultChainConfig.initial_state.coins,
|
8109
|
+
{
|
8110
|
+
owner: signer.address.toHexString(),
|
8111
|
+
amount: (0, import_math21.toHex)(1e9),
|
8112
|
+
asset_id: import_configs13.BaseAssetId
|
8113
|
+
}
|
8114
|
+
]
|
8115
|
+
}
|
8116
|
+
};
|
8340
8117
|
}
|
8341
|
-
|
8342
|
-
|
8343
|
-
fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
|
8344
|
-
const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
|
8345
|
-
const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
|
8346
|
-
const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
|
8347
|
-
(0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
|
8348
|
-
(0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
|
8349
|
-
(0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
|
8350
|
-
chainConfigPathToUse = tempDirPath;
|
8118
|
+
(0, import_fs.writeFileSync)(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
|
8119
|
+
chainConfigPathToUse = tempChainConfigFilePath;
|
8351
8120
|
}
|
8352
8121
|
const child = (0, import_child_process.spawn)(
|
8353
8122
|
command,
|
@@ -8356,10 +8125,10 @@ var launchNode = async ({
|
|
8356
8125
|
["--ip", ipToUse],
|
8357
8126
|
["--port", portToUse],
|
8358
8127
|
useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
|
8359
|
-
["--min-gas-price", "
|
8128
|
+
["--min-gas-price", "0"],
|
8360
8129
|
poaInstant ? ["--poa-instant", "true"] : [],
|
8361
8130
|
["--consensus-key", consensusKey],
|
8362
|
-
["--
|
8131
|
+
["--chain", chainConfigPathToUse],
|
8363
8132
|
"--vm-backtrace",
|
8364
8133
|
"--utxo-validation",
|
8365
8134
|
"--debug",
|
@@ -8418,7 +8187,7 @@ var launchNodeAndGetWallets = async ({
|
|
8418
8187
|
walletCount = 10
|
8419
8188
|
} = {}) => {
|
8420
8189
|
const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
|
8421
|
-
const provider = await Provider.create(`http://${ip}:${port}/
|
8190
|
+
const provider = await Provider.create(`http://${ip}:${port}/graphql`);
|
8422
8191
|
const wallets = await generateWallets(walletCount, provider);
|
8423
8192
|
const cleanup = () => {
|
8424
8193
|
closeNode();
|