@fuel-ts/account 0.0.0-rc-2034-20240411123358 → 0.0.0-rc-2021-20240411141803
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/README.md +1 -1
- package/dist/account.d.ts +5 -4
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +819 -568
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +805 -572
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +639 -407
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +10 -2
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +888 -322
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +4 -2
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/message.d.ts +3 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +37 -30
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +2 -2
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +8 -25
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +3 -0
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +8 -2
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +1535 -1067
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +780 -565
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +631 -416
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +17 -17
package/dist/test-utils.js
CHANGED
@@ -58,15 +58,16 @@ module.exports = __toCommonJS(test_utils_exports);
|
|
58
58
|
|
59
59
|
// src/wallet/base-wallet-unlocked.ts
|
60
60
|
var import_hasher3 = require("@fuel-ts/hasher");
|
61
|
-
var
|
61
|
+
var import_utils30 = require("@fuel-ts/utils");
|
62
62
|
|
63
63
|
// src/account.ts
|
64
64
|
var import_address4 = require("@fuel-ts/address");
|
65
65
|
var import_configs12 = require("@fuel-ts/address/configs");
|
66
66
|
var import_errors16 = require("@fuel-ts/errors");
|
67
67
|
var import_interfaces = require("@fuel-ts/interfaces");
|
68
|
-
var
|
69
|
-
var
|
68
|
+
var import_math19 = require("@fuel-ts/math");
|
69
|
+
var import_utils27 = require("@fuel-ts/utils");
|
70
|
+
var import_ramda4 = require("ramda");
|
70
71
|
|
71
72
|
// src/providers/coin-quantity.ts
|
72
73
|
var import_configs = require("@fuel-ts/address/configs");
|
@@ -75,24 +76,24 @@ var import_utils = require("@fuel-ts/utils");
|
|
75
76
|
var coinQuantityfy = (coinQuantityLike) => {
|
76
77
|
let assetId;
|
77
78
|
let amount;
|
78
|
-
let
|
79
|
+
let max;
|
79
80
|
if (Array.isArray(coinQuantityLike)) {
|
80
81
|
amount = coinQuantityLike[0];
|
81
82
|
assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
|
82
|
-
|
83
|
+
max = coinQuantityLike[2] ?? void 0;
|
83
84
|
} else {
|
84
85
|
amount = coinQuantityLike.amount;
|
85
86
|
assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
|
86
|
-
|
87
|
+
max = coinQuantityLike.max ?? void 0;
|
87
88
|
}
|
88
89
|
const bnAmount = (0, import_math.bn)(amount);
|
89
90
|
return {
|
90
91
|
assetId: (0, import_utils.hexlify)(assetId),
|
91
92
|
amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
|
92
|
-
max:
|
93
|
+
max: max ? (0, import_math.bn)(max) : void 0
|
93
94
|
};
|
94
95
|
};
|
95
|
-
var
|
96
|
+
var addAmountToCoinQuantities = (params) => {
|
96
97
|
const { amount, assetId } = params;
|
97
98
|
const coinQuantities = [...params.coinQuantities];
|
98
99
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -107,12 +108,12 @@ var addAmountToAsset = (params) => {
|
|
107
108
|
// src/providers/provider.ts
|
108
109
|
var import_address3 = require("@fuel-ts/address");
|
109
110
|
var import_errors14 = require("@fuel-ts/errors");
|
110
|
-
var
|
111
|
-
var
|
112
|
-
var
|
111
|
+
var import_math16 = require("@fuel-ts/math");
|
112
|
+
var import_transactions19 = require("@fuel-ts/transactions");
|
113
|
+
var import_utils22 = require("@fuel-ts/utils");
|
113
114
|
var import_versions = require("@fuel-ts/versions");
|
114
|
-
var
|
115
|
-
var
|
115
|
+
var import_utils23 = require("@noble/curves/abstract/utils");
|
116
|
+
var import_ethers2 = require("ethers");
|
116
117
|
var import_graphql_request = require("graphql-request");
|
117
118
|
var import_ramda3 = require("ramda");
|
118
119
|
|
@@ -120,14 +121,10 @@ var import_ramda3 = require("ramda");
|
|
120
121
|
var import_graphql_tag = __toESM(require("graphql-tag"));
|
121
122
|
var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
|
122
123
|
fragment receiptFragment on Receipt {
|
123
|
-
|
124
|
-
id
|
125
|
-
}
|
124
|
+
id
|
126
125
|
pc
|
127
126
|
is
|
128
|
-
to
|
129
|
-
id
|
130
|
-
}
|
127
|
+
to
|
131
128
|
toAddress
|
132
129
|
amount
|
133
130
|
assetId
|
@@ -165,10 +162,16 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
165
162
|
id
|
166
163
|
}
|
167
164
|
time
|
165
|
+
receipts {
|
166
|
+
...receiptFragment
|
167
|
+
}
|
168
168
|
programState {
|
169
169
|
returnType
|
170
170
|
data
|
171
171
|
}
|
172
|
+
receipts {
|
173
|
+
...receiptFragment
|
174
|
+
}
|
172
175
|
}
|
173
176
|
... on FailureStatus {
|
174
177
|
block {
|
@@ -176,26 +179,24 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
176
179
|
}
|
177
180
|
time
|
178
181
|
reason
|
182
|
+
receipts {
|
183
|
+
...receiptFragment
|
184
|
+
}
|
179
185
|
}
|
180
186
|
... on SqueezedOutStatus {
|
181
187
|
reason
|
182
188
|
}
|
183
189
|
}
|
184
|
-
`;
|
190
|
+
${ReceiptFragmentFragmentDoc}`;
|
185
191
|
var TransactionFragmentFragmentDoc = import_graphql_tag.default`
|
186
192
|
fragment transactionFragment on Transaction {
|
187
193
|
id
|
188
194
|
rawPayload
|
189
|
-
gasPrice
|
190
|
-
receipts {
|
191
|
-
...receiptFragment
|
192
|
-
}
|
193
195
|
status {
|
194
196
|
...transactionStatusFragment
|
195
197
|
}
|
196
198
|
}
|
197
|
-
${
|
198
|
-
${TransactionStatusFragmentFragmentDoc}`;
|
199
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
199
200
|
var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
|
200
201
|
fragment inputEstimatePredicatesFragment on Input {
|
201
202
|
... on InputCoin {
|
@@ -213,6 +214,46 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
|
|
213
214
|
}
|
214
215
|
}
|
215
216
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
217
|
+
var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
|
218
|
+
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
219
|
+
reason
|
220
|
+
programState {
|
221
|
+
returnType
|
222
|
+
data
|
223
|
+
}
|
224
|
+
}
|
225
|
+
`;
|
226
|
+
var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
|
227
|
+
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
228
|
+
programState {
|
229
|
+
returnType
|
230
|
+
data
|
231
|
+
}
|
232
|
+
}
|
233
|
+
`;
|
234
|
+
var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
235
|
+
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
236
|
+
... on DryRunFailureStatus {
|
237
|
+
...dryRunFailureStatusFragment
|
238
|
+
}
|
239
|
+
... on DryRunSuccessStatus {
|
240
|
+
...dryRunSuccessStatusFragment
|
241
|
+
}
|
242
|
+
}
|
243
|
+
${DryRunFailureStatusFragmentFragmentDoc}
|
244
|
+
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
245
|
+
var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
246
|
+
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
247
|
+
id
|
248
|
+
status {
|
249
|
+
...dryRunTransactionStatusFragment
|
250
|
+
}
|
251
|
+
receipts {
|
252
|
+
...receiptFragment
|
253
|
+
}
|
254
|
+
}
|
255
|
+
${DryRunTransactionStatusFragmentFragmentDoc}
|
256
|
+
${ReceiptFragmentFragmentDoc}`;
|
216
257
|
var CoinFragmentFragmentDoc = import_graphql_tag.default`
|
217
258
|
fragment coinFragment on Coin {
|
218
259
|
__typename
|
@@ -220,7 +261,6 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
|
|
220
261
|
owner
|
221
262
|
amount
|
222
263
|
assetId
|
223
|
-
maturity
|
224
264
|
blockCreated
|
225
265
|
txCreatedIdx
|
226
266
|
}
|
@@ -265,7 +305,6 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
|
|
265
305
|
prevRoot
|
266
306
|
time
|
267
307
|
applicationHash
|
268
|
-
messageReceiptRoot
|
269
308
|
messageReceiptCount
|
270
309
|
}
|
271
310
|
commitBlockHeader {
|
@@ -277,7 +316,6 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
|
|
277
316
|
prevRoot
|
278
317
|
time
|
279
318
|
applicationHash
|
280
|
-
messageReceiptRoot
|
281
319
|
messageReceiptCount
|
282
320
|
}
|
283
321
|
sender
|
@@ -297,8 +335,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
|
|
297
335
|
var BlockFragmentFragmentDoc = import_graphql_tag.default`
|
298
336
|
fragment blockFragment on Block {
|
299
337
|
id
|
338
|
+
height
|
300
339
|
header {
|
301
|
-
height
|
302
340
|
time
|
303
341
|
}
|
304
342
|
transactions {
|
@@ -356,6 +394,11 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
|
|
356
394
|
`;
|
357
395
|
var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
358
396
|
fragment GasCostsFragment on GasCosts {
|
397
|
+
version {
|
398
|
+
... on Version {
|
399
|
+
value
|
400
|
+
}
|
401
|
+
}
|
359
402
|
add
|
360
403
|
addi
|
361
404
|
aloc
|
@@ -368,7 +411,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
|
368
411
|
cb
|
369
412
|
cfei
|
370
413
|
cfsi
|
371
|
-
croo
|
372
414
|
div
|
373
415
|
divi
|
374
416
|
ecr1
|
@@ -451,6 +493,9 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
|
451
493
|
ccp {
|
452
494
|
...DependentCostFragment
|
453
495
|
}
|
496
|
+
croo {
|
497
|
+
...DependentCostFragment
|
498
|
+
}
|
454
499
|
csiz {
|
455
500
|
...DependentCostFragment
|
456
501
|
}
|
@@ -510,6 +555,11 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
|
510
555
|
${DependentCostFragmentFragmentDoc}`;
|
511
556
|
var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
|
512
557
|
fragment consensusParametersFragment on ConsensusParameters {
|
558
|
+
version {
|
559
|
+
... on Version {
|
560
|
+
value
|
561
|
+
}
|
562
|
+
}
|
513
563
|
txParams {
|
514
564
|
...TxParametersFragment
|
515
565
|
}
|
@@ -569,18 +619,9 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
|
|
569
619
|
fragment nodeInfoFragment on NodeInfo {
|
570
620
|
utxoValidation
|
571
621
|
vmBacktrace
|
572
|
-
minGasPrice
|
573
622
|
maxTx
|
574
623
|
maxDepth
|
575
624
|
nodeVersion
|
576
|
-
peers {
|
577
|
-
id
|
578
|
-
addresses
|
579
|
-
clientVersion
|
580
|
-
blockHeight
|
581
|
-
lastHeartbeatMs
|
582
|
-
appScore
|
583
|
-
}
|
584
625
|
}
|
585
626
|
`;
|
586
627
|
var GetVersionDocument = import_graphql_tag.default`
|
@@ -615,13 +656,9 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
|
|
615
656
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
616
657
|
transaction(id: $transactionId) {
|
617
658
|
...transactionFragment
|
618
|
-
receipts {
|
619
|
-
...receiptFragment
|
620
|
-
}
|
621
659
|
}
|
622
660
|
}
|
623
|
-
${TransactionFragmentFragmentDoc}
|
624
|
-
${ReceiptFragmentFragmentDoc}`;
|
661
|
+
${TransactionFragmentFragmentDoc}`;
|
625
662
|
var GetTransactionsDocument = import_graphql_tag.default`
|
626
663
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
627
664
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -749,6 +786,20 @@ var GetBalanceDocument = import_graphql_tag.default`
|
|
749
786
|
}
|
750
787
|
}
|
751
788
|
${BalanceFragmentFragmentDoc}`;
|
789
|
+
var GetLatestGasPriceDocument = import_graphql_tag.default`
|
790
|
+
query getLatestGasPrice {
|
791
|
+
latestGasPrice {
|
792
|
+
gasPrice
|
793
|
+
}
|
794
|
+
}
|
795
|
+
`;
|
796
|
+
var EstimateGasPriceDocument = import_graphql_tag.default`
|
797
|
+
query estimateGasPrice($blockHorizon: U32!) {
|
798
|
+
estimateGasPrice(blockHorizon: $blockHorizon) {
|
799
|
+
gasPrice
|
800
|
+
}
|
801
|
+
}
|
802
|
+
`;
|
752
803
|
var GetBalancesDocument = import_graphql_tag.default`
|
753
804
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
754
805
|
balances(
|
@@ -803,12 +854,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
|
|
803
854
|
}
|
804
855
|
`;
|
805
856
|
var DryRunDocument = import_graphql_tag.default`
|
806
|
-
mutation dryRun($
|
807
|
-
dryRun(
|
808
|
-
...
|
857
|
+
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
858
|
+
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
859
|
+
...dryRunTransactionExecutionStatusFragment
|
809
860
|
}
|
810
861
|
}
|
811
|
-
${
|
862
|
+
${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
|
812
863
|
var SubmitDocument = import_graphql_tag.default`
|
813
864
|
mutation submit($encodedTransaction: HexString!) {
|
814
865
|
submit(tx: $encodedTransaction) {
|
@@ -891,6 +942,12 @@ function getSdk(requester) {
|
|
891
942
|
getBalance(variables, options) {
|
892
943
|
return requester(GetBalanceDocument, variables, options);
|
893
944
|
},
|
945
|
+
getLatestGasPrice(variables, options) {
|
946
|
+
return requester(GetLatestGasPriceDocument, variables, options);
|
947
|
+
},
|
948
|
+
estimateGasPrice(variables, options) {
|
949
|
+
return requester(EstimateGasPriceDocument, variables, options);
|
950
|
+
},
|
894
951
|
getBalances(variables, options) {
|
895
952
|
return requester(GetBalancesDocument, variables, options);
|
896
953
|
},
|
@@ -960,11 +1017,14 @@ var _FuelGraphqlSubscriber = class {
|
|
960
1017
|
let data;
|
961
1018
|
let errors;
|
962
1019
|
try {
|
963
|
-
|
1020
|
+
const sanitizedText = text.replace(/\s/g, "");
|
1021
|
+
({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
|
964
1022
|
} catch (e) {
|
965
1023
|
throw new import_errors.FuelError(
|
966
1024
|
import_errors.ErrorCode.STREAM_PARSING_ERROR,
|
967
|
-
`Error while parsing stream data response: ${text}
|
1025
|
+
`Error while parsing stream data response: ${text}
|
1026
|
+
|
1027
|
+
Thrown error: ${e}`
|
968
1028
|
);
|
969
1029
|
}
|
970
1030
|
if (Array.isArray(errors)) {
|
@@ -1051,7 +1111,6 @@ var MemoryCache = class {
|
|
1051
1111
|
};
|
1052
1112
|
|
1053
1113
|
// src/providers/transaction-request/input.ts
|
1054
|
-
var import_abi_coder = require("@fuel-ts/abi-coder");
|
1055
1114
|
var import_configs2 = require("@fuel-ts/address/configs");
|
1056
1115
|
var import_errors3 = require("@fuel-ts/errors");
|
1057
1116
|
var import_math2 = require("@fuel-ts/math");
|
@@ -1065,8 +1124,8 @@ var inputify = (value) => {
|
|
1065
1124
|
const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
|
1066
1125
|
return {
|
1067
1126
|
type: import_transactions.InputType.Coin,
|
1068
|
-
txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0,
|
1069
|
-
outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(
|
1127
|
+
txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, 32)),
|
1128
|
+
outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(32, 34)),
|
1070
1129
|
owner: (0, import_utils3.hexlify)(value.owner),
|
1071
1130
|
amount: (0, import_math2.bn)(value.amount),
|
1072
1131
|
assetId: (0, import_utils3.hexlify)(value.assetId),
|
@@ -1075,10 +1134,9 @@ var inputify = (value) => {
|
|
1075
1134
|
txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
|
1076
1135
|
},
|
1077
1136
|
witnessIndex: value.witnessIndex,
|
1078
|
-
maturity: value.maturity ?? 0,
|
1079
1137
|
predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
|
1080
|
-
predicateLength: predicate.length,
|
1081
|
-
predicateDataLength: predicateData.length,
|
1138
|
+
predicateLength: (0, import_math2.bn)(predicate.length),
|
1139
|
+
predicateDataLength: (0, import_math2.bn)(predicateData.length),
|
1082
1140
|
predicate: (0, import_utils3.hexlify)(predicate),
|
1083
1141
|
predicateData: (0, import_utils3.hexlify)(predicateData)
|
1084
1142
|
};
|
@@ -1109,8 +1167,8 @@ var inputify = (value) => {
|
|
1109
1167
|
nonce: (0, import_utils3.hexlify)(value.nonce),
|
1110
1168
|
witnessIndex: value.witnessIndex,
|
1111
1169
|
predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
|
1112
|
-
predicateLength: predicate.length,
|
1113
|
-
predicateDataLength: predicateData.length,
|
1170
|
+
predicateLength: (0, import_math2.bn)(predicate.length),
|
1171
|
+
predicateDataLength: (0, import_math2.bn)(predicateData.length),
|
1114
1172
|
predicate: (0, import_utils3.hexlify)(predicate),
|
1115
1173
|
predicateData: (0, import_utils3.hexlify)(predicateData),
|
1116
1174
|
data: (0, import_utils3.hexlify)(data),
|
@@ -1184,13 +1242,12 @@ var outputify = (value) => {
|
|
1184
1242
|
};
|
1185
1243
|
|
1186
1244
|
// src/providers/transaction-request/transaction-request.ts
|
1187
|
-
var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
1188
1245
|
var import_address = require("@fuel-ts/address");
|
1189
1246
|
var import_configs7 = require("@fuel-ts/address/configs");
|
1190
|
-
var import_crypto = require("@fuel-ts/crypto");
|
1191
1247
|
var import_math7 = require("@fuel-ts/math");
|
1192
1248
|
var import_transactions6 = require("@fuel-ts/transactions");
|
1193
1249
|
var import_utils9 = require("@fuel-ts/utils");
|
1250
|
+
var import_ethers = require("ethers");
|
1194
1251
|
|
1195
1252
|
// src/providers/resource.ts
|
1196
1253
|
var isCoin = (resource) => "id" in resource;
|
@@ -1226,8 +1283,8 @@ function assembleReceiptByType(receipt) {
|
|
1226
1283
|
case "CALL" /* Call */: {
|
1227
1284
|
const callReceipt = {
|
1228
1285
|
type: import_transactions3.ReceiptType.Call,
|
1229
|
-
from: hexOrZero(receipt.
|
1230
|
-
to: hexOrZero(receipt?.to
|
1286
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1287
|
+
to: hexOrZero(receipt?.to),
|
1231
1288
|
amount: (0, import_math4.bn)(receipt.amount),
|
1232
1289
|
assetId: hexOrZero(receipt.assetId),
|
1233
1290
|
gas: (0, import_math4.bn)(receipt.gas),
|
@@ -1241,7 +1298,7 @@ function assembleReceiptByType(receipt) {
|
|
1241
1298
|
case "RETURN" /* Return */: {
|
1242
1299
|
const returnReceipt = {
|
1243
1300
|
type: import_transactions3.ReceiptType.Return,
|
1244
|
-
id: hexOrZero(receipt.
|
1301
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1245
1302
|
val: (0, import_math4.bn)(receipt.val),
|
1246
1303
|
pc: (0, import_math4.bn)(receipt.pc),
|
1247
1304
|
is: (0, import_math4.bn)(receipt.is)
|
@@ -1251,7 +1308,7 @@ function assembleReceiptByType(receipt) {
|
|
1251
1308
|
case "RETURN_DATA" /* ReturnData */: {
|
1252
1309
|
const returnDataReceipt = {
|
1253
1310
|
type: import_transactions3.ReceiptType.ReturnData,
|
1254
|
-
id: hexOrZero(receipt.
|
1311
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1255
1312
|
ptr: (0, import_math4.bn)(receipt.ptr),
|
1256
1313
|
len: (0, import_math4.bn)(receipt.len),
|
1257
1314
|
digest: hexOrZero(receipt.digest),
|
@@ -1263,7 +1320,7 @@ function assembleReceiptByType(receipt) {
|
|
1263
1320
|
case "PANIC" /* Panic */: {
|
1264
1321
|
const panicReceipt = {
|
1265
1322
|
type: import_transactions3.ReceiptType.Panic,
|
1266
|
-
id: hexOrZero(receipt.
|
1323
|
+
id: hexOrZero(receipt.id),
|
1267
1324
|
reason: (0, import_math4.bn)(receipt.reason),
|
1268
1325
|
pc: (0, import_math4.bn)(receipt.pc),
|
1269
1326
|
is: (0, import_math4.bn)(receipt.is),
|
@@ -1274,7 +1331,7 @@ function assembleReceiptByType(receipt) {
|
|
1274
1331
|
case "REVERT" /* Revert */: {
|
1275
1332
|
const revertReceipt = {
|
1276
1333
|
type: import_transactions3.ReceiptType.Revert,
|
1277
|
-
id: hexOrZero(receipt.
|
1334
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1278
1335
|
val: (0, import_math4.bn)(receipt.ra),
|
1279
1336
|
pc: (0, import_math4.bn)(receipt.pc),
|
1280
1337
|
is: (0, import_math4.bn)(receipt.is)
|
@@ -1284,7 +1341,7 @@ function assembleReceiptByType(receipt) {
|
|
1284
1341
|
case "LOG" /* Log */: {
|
1285
1342
|
const logReceipt = {
|
1286
1343
|
type: import_transactions3.ReceiptType.Log,
|
1287
|
-
id: hexOrZero(receipt.
|
1344
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1288
1345
|
val0: (0, import_math4.bn)(receipt.ra),
|
1289
1346
|
val1: (0, import_math4.bn)(receipt.rb),
|
1290
1347
|
val2: (0, import_math4.bn)(receipt.rc),
|
@@ -1297,7 +1354,7 @@ function assembleReceiptByType(receipt) {
|
|
1297
1354
|
case "LOG_DATA" /* LogData */: {
|
1298
1355
|
const logDataReceipt = {
|
1299
1356
|
type: import_transactions3.ReceiptType.LogData,
|
1300
|
-
id: hexOrZero(receipt.
|
1357
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1301
1358
|
val0: (0, import_math4.bn)(receipt.ra),
|
1302
1359
|
val1: (0, import_math4.bn)(receipt.rb),
|
1303
1360
|
ptr: (0, import_math4.bn)(receipt.ptr),
|
@@ -1311,8 +1368,8 @@ function assembleReceiptByType(receipt) {
|
|
1311
1368
|
case "TRANSFER" /* Transfer */: {
|
1312
1369
|
const transferReceipt = {
|
1313
1370
|
type: import_transactions3.ReceiptType.Transfer,
|
1314
|
-
from: hexOrZero(receipt.
|
1315
|
-
to: hexOrZero(receipt.toAddress || receipt?.to
|
1371
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1372
|
+
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1316
1373
|
amount: (0, import_math4.bn)(receipt.amount),
|
1317
1374
|
assetId: hexOrZero(receipt.assetId),
|
1318
1375
|
pc: (0, import_math4.bn)(receipt.pc),
|
@@ -1323,8 +1380,8 @@ function assembleReceiptByType(receipt) {
|
|
1323
1380
|
case "TRANSFER_OUT" /* TransferOut */: {
|
1324
1381
|
const transferOutReceipt = {
|
1325
1382
|
type: import_transactions3.ReceiptType.TransferOut,
|
1326
|
-
from: hexOrZero(receipt.
|
1327
|
-
to: hexOrZero(receipt.toAddress || receipt.to
|
1383
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1384
|
+
to: hexOrZero(receipt.toAddress || receipt.to),
|
1328
1385
|
amount: (0, import_math4.bn)(receipt.amount),
|
1329
1386
|
assetId: hexOrZero(receipt.assetId),
|
1330
1387
|
pc: (0, import_math4.bn)(receipt.pc),
|
@@ -1367,7 +1424,7 @@ function assembleReceiptByType(receipt) {
|
|
1367
1424
|
return receiptMessageOut;
|
1368
1425
|
}
|
1369
1426
|
case "MINT" /* Mint */: {
|
1370
|
-
const contractId = hexOrZero(receipt.
|
1427
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1371
1428
|
const subId = hexOrZero(receipt.subId);
|
1372
1429
|
const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
|
1373
1430
|
const mintReceipt = {
|
@@ -1382,7 +1439,7 @@ function assembleReceiptByType(receipt) {
|
|
1382
1439
|
return mintReceipt;
|
1383
1440
|
}
|
1384
1441
|
case "BURN" /* Burn */: {
|
1385
|
-
const contractId = hexOrZero(receipt.
|
1442
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1386
1443
|
const subId = hexOrZero(receipt.subId);
|
1387
1444
|
const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
|
1388
1445
|
const burnReceipt = {
|
@@ -1408,7 +1465,6 @@ var import_errors6 = require("@fuel-ts/errors");
|
|
1408
1465
|
var import_math5 = require("@fuel-ts/math");
|
1409
1466
|
var import_transactions4 = require("@fuel-ts/transactions");
|
1410
1467
|
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()));
|
1412
1468
|
var getGasUsedFromReceipts = (receipts) => {
|
1413
1469
|
const scriptResult = receipts.filter(
|
1414
1470
|
(receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
|
@@ -1429,18 +1485,28 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
1429
1485
|
}
|
1430
1486
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
1431
1487
|
const witnessCache = [];
|
1432
|
-
const
|
1488
|
+
const chargeableInputs = inputs.filter((input) => {
|
1489
|
+
const isCoinOrMessage = "owner" in input || "sender" in input;
|
1490
|
+
if (isCoinOrMessage) {
|
1491
|
+
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1492
|
+
return true;
|
1493
|
+
}
|
1494
|
+
if (!witnessCache.includes(input.witnessIndex)) {
|
1495
|
+
witnessCache.push(input.witnessIndex);
|
1496
|
+
return true;
|
1497
|
+
}
|
1498
|
+
}
|
1499
|
+
return false;
|
1500
|
+
});
|
1501
|
+
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
1502
|
+
const totalGas = chargeableInputs.reduce((total, input) => {
|
1433
1503
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1434
1504
|
return total.add(
|
1435
|
-
|
1505
|
+
vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
|
1436
1506
|
);
|
1437
1507
|
}
|
1438
|
-
|
1439
|
-
|
1440
|
-
return total.add(gasCosts.ecr1);
|
1441
|
-
}
|
1442
|
-
return total;
|
1443
|
-
}, (0, import_math5.bn)());
|
1508
|
+
return total.add(gasCosts.ecr1);
|
1509
|
+
}, (0, import_math5.bn)(0));
|
1444
1510
|
return totalGas;
|
1445
1511
|
}
|
1446
1512
|
function getMinGas(params) {
|
@@ -1452,12 +1518,20 @@ function getMinGas(params) {
|
|
1452
1518
|
return minGas;
|
1453
1519
|
}
|
1454
1520
|
function getMaxGas(params) {
|
1455
|
-
const {
|
1521
|
+
const {
|
1522
|
+
gasPerByte,
|
1523
|
+
witnessesLength,
|
1524
|
+
witnessLimit,
|
1525
|
+
minGas,
|
1526
|
+
gasLimit = (0, import_math5.bn)(0),
|
1527
|
+
maxGasPerTx
|
1528
|
+
} = params;
|
1456
1529
|
let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
|
1457
1530
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
1458
1531
|
remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
1459
1532
|
}
|
1460
|
-
|
1533
|
+
const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
1534
|
+
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
1461
1535
|
}
|
1462
1536
|
function calculateMetadataGasForTxCreate({
|
1463
1537
|
gasCosts,
|
@@ -1479,6 +1553,10 @@ function calculateMetadataGasForTxScript({
|
|
1479
1553
|
}) {
|
1480
1554
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1481
1555
|
}
|
1556
|
+
var calculateGasFee = (params) => {
|
1557
|
+
const { gas, gasPrice, priceFactor, tip } = params;
|
1558
|
+
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1559
|
+
};
|
1482
1560
|
|
1483
1561
|
// src/providers/utils/json.ts
|
1484
1562
|
var import_utils7 = require("@fuel-ts/utils");
|
@@ -1615,7 +1693,7 @@ var witnessify = (value) => {
|
|
1615
1693
|
// src/providers/transaction-request/transaction-request.ts
|
1616
1694
|
var BaseTransactionRequest = class {
|
1617
1695
|
/** Gas price for transaction */
|
1618
|
-
|
1696
|
+
tip;
|
1619
1697
|
/** Block until which tx cannot be included */
|
1620
1698
|
maturity;
|
1621
1699
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -1634,7 +1712,7 @@ var BaseTransactionRequest = class {
|
|
1634
1712
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
1635
1713
|
*/
|
1636
1714
|
constructor({
|
1637
|
-
|
1715
|
+
tip,
|
1638
1716
|
maturity,
|
1639
1717
|
maxFee,
|
1640
1718
|
witnessLimit,
|
@@ -1642,7 +1720,7 @@ var BaseTransactionRequest = class {
|
|
1642
1720
|
outputs,
|
1643
1721
|
witnesses
|
1644
1722
|
} = {}) {
|
1645
|
-
this.
|
1723
|
+
this.tip = (0, import_math7.bn)(tip);
|
1646
1724
|
this.maturity = maturity ?? 0;
|
1647
1725
|
this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
|
1648
1726
|
this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
|
@@ -1653,9 +1731,9 @@ var BaseTransactionRequest = class {
|
|
1653
1731
|
static getPolicyMeta(req) {
|
1654
1732
|
let policyTypes = 0;
|
1655
1733
|
const policies = [];
|
1656
|
-
if (req.
|
1657
|
-
policyTypes += import_transactions6.PolicyType.
|
1658
|
-
policies.push({ data: req.
|
1734
|
+
if (req.tip) {
|
1735
|
+
policyTypes += import_transactions6.PolicyType.Tip;
|
1736
|
+
policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
|
1659
1737
|
}
|
1660
1738
|
if (req.witnessLimit) {
|
1661
1739
|
policyTypes += import_transactions6.PolicyType.WitnessLimit;
|
@@ -1842,10 +1920,10 @@ var BaseTransactionRequest = class {
|
|
1842
1920
|
* @param predicate - Predicate bytes.
|
1843
1921
|
* @param predicateData - Predicate data bytes.
|
1844
1922
|
*/
|
1845
|
-
addCoinInput(coin
|
1923
|
+
addCoinInput(coin) {
|
1846
1924
|
const { assetId, owner, amount } = coin;
|
1847
1925
|
let witnessIndex;
|
1848
|
-
if (predicate) {
|
1926
|
+
if (coin.predicate) {
|
1849
1927
|
witnessIndex = 0;
|
1850
1928
|
} else {
|
1851
1929
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -1860,8 +1938,7 @@ var BaseTransactionRequest = class {
|
|
1860
1938
|
amount,
|
1861
1939
|
assetId,
|
1862
1940
|
txPointer: "0x00000000000000000000000000000000",
|
1863
|
-
witnessIndex
|
1864
|
-
predicate: predicate?.bytes
|
1941
|
+
witnessIndex
|
1865
1942
|
};
|
1866
1943
|
this.pushInput(input);
|
1867
1944
|
this.addChangeOutput(owner, assetId);
|
@@ -1874,11 +1951,11 @@ var BaseTransactionRequest = class {
|
|
1874
1951
|
* @param predicate - Predicate bytes.
|
1875
1952
|
* @param predicateData - Predicate data bytes.
|
1876
1953
|
*/
|
1877
|
-
addMessageInput(message
|
1954
|
+
addMessageInput(message) {
|
1878
1955
|
const { recipient, sender, amount } = message;
|
1879
1956
|
const assetId = import_configs7.BaseAssetId;
|
1880
1957
|
let witnessIndex;
|
1881
|
-
if (predicate) {
|
1958
|
+
if (message.predicate) {
|
1882
1959
|
witnessIndex = 0;
|
1883
1960
|
} else {
|
1884
1961
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -1892,8 +1969,7 @@ var BaseTransactionRequest = class {
|
|
1892
1969
|
sender: sender.toB256(),
|
1893
1970
|
recipient: recipient.toB256(),
|
1894
1971
|
amount,
|
1895
|
-
witnessIndex
|
1896
|
-
predicate: predicate?.bytes
|
1972
|
+
witnessIndex
|
1897
1973
|
};
|
1898
1974
|
this.pushInput(input);
|
1899
1975
|
this.addChangeOutput(recipient, assetId);
|
@@ -1924,32 +2000,6 @@ var BaseTransactionRequest = class {
|
|
1924
2000
|
resources.forEach((resource) => this.addResource(resource));
|
1925
2001
|
return this;
|
1926
2002
|
}
|
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
|
-
}
|
1953
2003
|
/**
|
1954
2004
|
* Adds a coin output to the transaction.
|
1955
2005
|
*
|
@@ -2029,7 +2079,7 @@ var BaseTransactionRequest = class {
|
|
2029
2079
|
}
|
2030
2080
|
calculateMaxGas(chainInfo, minGas) {
|
2031
2081
|
const { consensusParameters } = chainInfo;
|
2032
|
-
const { gasPerByte } = consensusParameters;
|
2082
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2033
2083
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2034
2084
|
(acc, wit) => acc + wit.dataLength,
|
2035
2085
|
0
|
@@ -2038,7 +2088,8 @@ var BaseTransactionRequest = class {
|
|
2038
2088
|
gasPerByte,
|
2039
2089
|
minGas,
|
2040
2090
|
witnessesLength,
|
2041
|
-
witnessLimit: this.witnessLimit
|
2091
|
+
witnessLimit: this.witnessLimit,
|
2092
|
+
maxGasPerTx
|
2042
2093
|
});
|
2043
2094
|
}
|
2044
2095
|
/**
|
@@ -2056,17 +2107,20 @@ var BaseTransactionRequest = class {
|
|
2056
2107
|
});
|
2057
2108
|
const updateAssetInput = (assetId, quantity) => {
|
2058
2109
|
const assetInput = findAssetInput(assetId);
|
2110
|
+
let usedQuantity = quantity;
|
2111
|
+
if (assetId === import_configs7.BaseAssetId) {
|
2112
|
+
usedQuantity = (0, import_math7.bn)("1000000000000000000");
|
2113
|
+
}
|
2059
2114
|
if (assetInput && "assetId" in assetInput) {
|
2060
|
-
assetInput.id = (0, import_utils9.hexlify)((0,
|
2061
|
-
assetInput.amount =
|
2115
|
+
assetInput.id = (0, import_utils9.hexlify)((0, import_ethers.randomBytes)(34));
|
2116
|
+
assetInput.amount = usedQuantity;
|
2062
2117
|
} else {
|
2063
2118
|
this.addResources([
|
2064
2119
|
{
|
2065
|
-
id: (0, import_utils9.hexlify)((0,
|
2066
|
-
amount:
|
2120
|
+
id: (0, import_utils9.hexlify)((0, import_ethers.randomBytes)(34)),
|
2121
|
+
amount: usedQuantity,
|
2067
2122
|
assetId,
|
2068
2123
|
owner: resourcesOwner || import_address.Address.fromRandom(),
|
2069
|
-
maturity: 0,
|
2070
2124
|
blockCreated: (0, import_math7.bn)(1),
|
2071
2125
|
txCreatedIdx: (0, import_math7.bn)(1)
|
2072
2126
|
}
|
@@ -2098,7 +2152,7 @@ var BaseTransactionRequest = class {
|
|
2098
2152
|
toJSON() {
|
2099
2153
|
return normalizeJSON(this);
|
2100
2154
|
}
|
2101
|
-
|
2155
|
+
updatePredicateGasUsed(inputs) {
|
2102
2156
|
this.inputs.forEach((i) => {
|
2103
2157
|
let correspondingInput;
|
2104
2158
|
switch (i.type) {
|
@@ -2120,6 +2174,15 @@ var BaseTransactionRequest = class {
|
|
2120
2174
|
}
|
2121
2175
|
});
|
2122
2176
|
}
|
2177
|
+
shiftPredicateData() {
|
2178
|
+
this.inputs.forEach((input) => {
|
2179
|
+
if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
|
2180
|
+
input.predicateData = input.paddPredicateData(
|
2181
|
+
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2182
|
+
);
|
2183
|
+
}
|
2184
|
+
});
|
2185
|
+
}
|
2123
2186
|
};
|
2124
2187
|
|
2125
2188
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2266,9 +2329,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2266
2329
|
return {
|
2267
2330
|
type: import_transactions8.TransactionType.Create,
|
2268
2331
|
...baseTransaction,
|
2269
|
-
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2270
2332
|
bytecodeWitnessIndex,
|
2271
|
-
storageSlotsCount: storageSlots.length,
|
2333
|
+
storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
|
2272
2334
|
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
|
2273
2335
|
storageSlots
|
2274
2336
|
};
|
@@ -2317,7 +2379,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2317
2379
|
};
|
2318
2380
|
|
2319
2381
|
// src/providers/transaction-request/script-transaction-request.ts
|
2320
|
-
var
|
2382
|
+
var import_abi_coder = require("@fuel-ts/abi-coder");
|
2321
2383
|
var import_address2 = require("@fuel-ts/address");
|
2322
2384
|
var import_configs10 = require("@fuel-ts/address/configs");
|
2323
2385
|
var import_math10 = require("@fuel-ts/math");
|
@@ -2391,8 +2453,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2391
2453
|
type: import_transactions9.TransactionType.Script,
|
2392
2454
|
scriptGasLimit: this.gasLimit,
|
2393
2455
|
...super.getBaseTransaction(),
|
2394
|
-
scriptLength: script.length,
|
2395
|
-
scriptDataLength: scriptData.length,
|
2456
|
+
scriptLength: (0, import_math10.bn)(script.length),
|
2457
|
+
scriptDataLength: (0, import_math10.bn)(scriptData.length),
|
2396
2458
|
receiptsRoot: import_configs10.ZeroBytes32,
|
2397
2459
|
script: (0, import_utils15.hexlify)(script),
|
2398
2460
|
scriptData: (0, import_utils15.hexlify)(scriptData)
|
@@ -2456,7 +2518,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2456
2518
|
}
|
2457
2519
|
calculateMaxGas(chainInfo, minGas) {
|
2458
2520
|
const { consensusParameters } = chainInfo;
|
2459
|
-
const { gasPerByte } = consensusParameters;
|
2521
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2460
2522
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2461
2523
|
(acc, wit) => acc + wit.dataLength,
|
2462
2524
|
0
|
@@ -2466,7 +2528,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2466
2528
|
minGas,
|
2467
2529
|
witnessesLength,
|
2468
2530
|
witnessLimit: this.witnessLimit,
|
2469
|
-
gasLimit: this.gasLimit
|
2531
|
+
gasLimit: this.gasLimit,
|
2532
|
+
maxGasPerTx
|
2470
2533
|
});
|
2471
2534
|
}
|
2472
2535
|
/**
|
@@ -2509,7 +2572,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2509
2572
|
* @returns The current instance of the `ScriptTransactionRequest`.
|
2510
2573
|
*/
|
2511
2574
|
setData(abi, args) {
|
2512
|
-
const abiInterface = new
|
2575
|
+
const abiInterface = new import_abi_coder.Interface(abi);
|
2513
2576
|
this.scriptData = abiInterface.functions.main.encodeArguments(args);
|
2514
2577
|
return this;
|
2515
2578
|
}
|
@@ -2541,15 +2604,32 @@ var transactionRequestify = (obj) => {
|
|
2541
2604
|
}
|
2542
2605
|
}
|
2543
2606
|
};
|
2607
|
+
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2608
|
+
(acc, input) => {
|
2609
|
+
if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
|
2610
|
+
acc.utxos.push(input.id);
|
2611
|
+
}
|
2612
|
+
if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
|
2613
|
+
acc.messages.push(input.nonce);
|
2614
|
+
}
|
2615
|
+
return acc;
|
2616
|
+
},
|
2617
|
+
{
|
2618
|
+
utxos: [],
|
2619
|
+
messages: []
|
2620
|
+
}
|
2621
|
+
);
|
2544
2622
|
|
2545
2623
|
// src/providers/transaction-response/transaction-response.ts
|
2546
2624
|
var import_errors13 = require("@fuel-ts/errors");
|
2547
|
-
var
|
2548
|
-
var
|
2549
|
-
var
|
2625
|
+
var import_math15 = require("@fuel-ts/math");
|
2626
|
+
var import_transactions18 = require("@fuel-ts/transactions");
|
2627
|
+
var import_utils20 = require("@fuel-ts/utils");
|
2550
2628
|
|
2551
2629
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2552
|
-
var
|
2630
|
+
var import_math14 = require("@fuel-ts/math");
|
2631
|
+
var import_transactions16 = require("@fuel-ts/transactions");
|
2632
|
+
var import_utils18 = require("@fuel-ts/utils");
|
2553
2633
|
|
2554
2634
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2555
2635
|
var import_math11 = require("@fuel-ts/math");
|
@@ -2557,9 +2637,10 @@ var import_transactions11 = require("@fuel-ts/transactions");
|
|
2557
2637
|
var import_utils16 = require("@fuel-ts/utils");
|
2558
2638
|
var calculateTransactionFee = (params) => {
|
2559
2639
|
const {
|
2560
|
-
|
2640
|
+
gasPrice,
|
2561
2641
|
rawPayload,
|
2562
|
-
|
2642
|
+
tip,
|
2643
|
+
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2563
2644
|
} = params;
|
2564
2645
|
const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
|
2565
2646
|
const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
|
@@ -2569,8 +2650,7 @@ var calculateTransactionFee = (params) => {
|
|
2569
2650
|
return {
|
2570
2651
|
fee: (0, import_math11.bn)(0),
|
2571
2652
|
minFee: (0, import_math11.bn)(0),
|
2572
|
-
maxFee: (0, import_math11.bn)(0)
|
2573
|
-
feeFromGasUsed: (0, import_math11.bn)(0)
|
2653
|
+
maxFee: (0, import_math11.bn)(0)
|
2574
2654
|
};
|
2575
2655
|
}
|
2576
2656
|
const { type, witnesses, inputs, policies } = transaction;
|
@@ -2602,7 +2682,6 @@ var calculateTransactionFee = (params) => {
|
|
2602
2682
|
metadataGas,
|
2603
2683
|
txBytesSize: transactionBytes.length
|
2604
2684
|
});
|
2605
|
-
const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
|
2606
2685
|
const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
|
2607
2686
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2608
2687
|
const maxGas = getMaxGas({
|
@@ -2610,17 +2689,25 @@ var calculateTransactionFee = (params) => {
|
|
2610
2689
|
minGas,
|
2611
2690
|
witnessesLength,
|
2612
2691
|
gasLimit,
|
2613
|
-
witnessLimit
|
2692
|
+
witnessLimit,
|
2693
|
+
maxGasPerTx
|
2694
|
+
});
|
2695
|
+
const minFee = calculateGasFee({
|
2696
|
+
gasPrice,
|
2697
|
+
gas: minGas,
|
2698
|
+
priceFactor: gasPriceFactor,
|
2699
|
+
tip
|
2700
|
+
});
|
2701
|
+
const maxFee = calculateGasFee({
|
2702
|
+
gasPrice,
|
2703
|
+
gas: maxGas,
|
2704
|
+
priceFactor: gasPriceFactor,
|
2705
|
+
tip
|
2614
2706
|
});
|
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);
|
2619
2707
|
return {
|
2620
|
-
fee,
|
2621
2708
|
minFee,
|
2622
2709
|
maxFee,
|
2623
|
-
|
2710
|
+
fee: maxFee
|
2624
2711
|
};
|
2625
2712
|
};
|
2626
2713
|
|
@@ -2631,17 +2718,17 @@ var import_math13 = require("@fuel-ts/math");
|
|
2631
2718
|
var import_transactions14 = require("@fuel-ts/transactions");
|
2632
2719
|
|
2633
2720
|
// src/providers/transaction-summary/call.ts
|
2634
|
-
var
|
2721
|
+
var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
2635
2722
|
var import_math12 = require("@fuel-ts/math");
|
2636
2723
|
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2637
|
-
const abiInterface = new
|
2724
|
+
const abiInterface = new import_abi_coder2.Interface(abi);
|
2638
2725
|
const callFunctionSelector = receipt.param1.toHex(8);
|
2639
2726
|
const functionFragment = abiInterface.getFunction(callFunctionSelector);
|
2640
2727
|
const inputs = functionFragment.jsonFn.inputs;
|
2641
2728
|
let encodedArgs;
|
2642
2729
|
if (functionFragment.isInputDataPointer) {
|
2643
2730
|
if (rawPayload) {
|
2644
|
-
const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0,
|
2731
|
+
const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2645
2732
|
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2646
2733
|
}
|
2647
2734
|
} else {
|
@@ -3187,10 +3274,12 @@ function assembleTransactionSummary(params) {
|
|
3187
3274
|
gqlTransactionStatus,
|
3188
3275
|
abiMap = {},
|
3189
3276
|
maxInputs,
|
3190
|
-
gasCosts
|
3277
|
+
gasCosts,
|
3278
|
+
maxGasPerTx,
|
3279
|
+
gasPrice
|
3191
3280
|
} = params;
|
3192
3281
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3193
|
-
const rawPayload = (0,
|
3282
|
+
const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
|
3194
3283
|
const operations = getOperations({
|
3195
3284
|
transactionType: transaction.type,
|
3196
3285
|
inputs: transaction.inputs || [],
|
@@ -3201,11 +3290,14 @@ function assembleTransactionSummary(params) {
|
|
3201
3290
|
maxInputs
|
3202
3291
|
});
|
3203
3292
|
const typeName = getTransactionTypeName(transaction.type);
|
3293
|
+
const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
|
3204
3294
|
const { fee } = calculateTransactionFee({
|
3205
|
-
|
3295
|
+
gasPrice,
|
3206
3296
|
rawPayload,
|
3297
|
+
tip,
|
3207
3298
|
consensusParameters: {
|
3208
3299
|
gasCosts,
|
3300
|
+
maxGasPerTx,
|
3209
3301
|
feeParams: {
|
3210
3302
|
gasPerByte,
|
3211
3303
|
gasPriceFactor
|
@@ -3217,7 +3309,7 @@ function assembleTransactionSummary(params) {
|
|
3217
3309
|
const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
|
3218
3310
|
let date;
|
3219
3311
|
if (time) {
|
3220
|
-
date =
|
3312
|
+
date = import_utils18.DateTime.fromTai64(time);
|
3221
3313
|
}
|
3222
3314
|
const transactionSummary = {
|
3223
3315
|
id,
|
@@ -3244,13 +3336,13 @@ function assembleTransactionSummary(params) {
|
|
3244
3336
|
}
|
3245
3337
|
|
3246
3338
|
// src/providers/transaction-response/getDecodedLogs.ts
|
3247
|
-
var
|
3248
|
-
var
|
3339
|
+
var import_abi_coder3 = require("@fuel-ts/abi-coder");
|
3340
|
+
var import_transactions17 = require("@fuel-ts/transactions");
|
3249
3341
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
3250
3342
|
return receipts.reduce((logs, receipt) => {
|
3251
|
-
if (receipt.type ===
|
3252
|
-
const interfaceToUse = new
|
3253
|
-
const data = receipt.type ===
|
3343
|
+
if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
|
3344
|
+
const interfaceToUse = new import_abi_coder3.Interface(externalAbis[receipt.id] || mainAbi);
|
3345
|
+
const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
|
3254
3346
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
|
3255
3347
|
logs.push(decodedLog);
|
3256
3348
|
}
|
@@ -3265,7 +3357,7 @@ var TransactionResponse = class {
|
|
3265
3357
|
/** Current provider */
|
3266
3358
|
provider;
|
3267
3359
|
/** Gas used on the transaction */
|
3268
|
-
gasUsed = (0,
|
3360
|
+
gasUsed = (0, import_math15.bn)(0);
|
3269
3361
|
/** The graphql Transaction with receipts object. */
|
3270
3362
|
gqlTransaction;
|
3271
3363
|
abis;
|
@@ -3323,8 +3415,8 @@ var TransactionResponse = class {
|
|
3323
3415
|
* @returns The decoded transaction.
|
3324
3416
|
*/
|
3325
3417
|
decodeTransaction(transactionWithReceipts) {
|
3326
|
-
return new
|
3327
|
-
(0,
|
3418
|
+
return new import_transactions18.TransactionCoder().decode(
|
3419
|
+
(0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
|
3328
3420
|
0
|
3329
3421
|
)?.[0];
|
3330
3422
|
}
|
@@ -3343,20 +3435,27 @@ var TransactionResponse = class {
|
|
3343
3435
|
const decodedTransaction = this.decodeTransaction(
|
3344
3436
|
transaction
|
3345
3437
|
);
|
3346
|
-
|
3347
|
-
|
3438
|
+
let txReceipts = [];
|
3439
|
+
if (transaction?.status && "receipts" in transaction.status) {
|
3440
|
+
txReceipts = transaction.status.receipts;
|
3441
|
+
}
|
3442
|
+
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3443
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3444
|
+
const gasPrice = await this.provider.getLatestGasPrice();
|
3348
3445
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3349
3446
|
const transactionSummary = assembleTransactionSummary({
|
3350
3447
|
id: this.id,
|
3351
3448
|
receipts,
|
3352
3449
|
transaction: decodedTransaction,
|
3353
|
-
transactionBytes: (0,
|
3450
|
+
transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
|
3354
3451
|
gqlTransactionStatus: transaction.status,
|
3355
3452
|
gasPerByte,
|
3356
3453
|
gasPriceFactor,
|
3357
3454
|
abiMap: contractsAbiMap,
|
3358
3455
|
maxInputs,
|
3359
|
-
gasCosts
|
3456
|
+
gasCosts,
|
3457
|
+
maxGasPerTx,
|
3458
|
+
gasPrice
|
3360
3459
|
});
|
3361
3460
|
return transactionSummary;
|
3362
3461
|
}
|
@@ -3483,29 +3582,29 @@ var processGqlChain = (chain) => {
|
|
3483
3582
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3484
3583
|
return {
|
3485
3584
|
name,
|
3486
|
-
baseChainHeight: (0,
|
3585
|
+
baseChainHeight: (0, import_math16.bn)(daHeight),
|
3487
3586
|
consensusParameters: {
|
3488
|
-
contractMaxSize: (0,
|
3489
|
-
maxInputs: (0,
|
3490
|
-
maxOutputs: (0,
|
3491
|
-
maxWitnesses: (0,
|
3492
|
-
maxGasPerTx: (0,
|
3493
|
-
maxScriptLength: (0,
|
3494
|
-
maxScriptDataLength: (0,
|
3495
|
-
maxStorageSlots: (0,
|
3496
|
-
maxPredicateLength: (0,
|
3497
|
-
maxPredicateDataLength: (0,
|
3498
|
-
maxGasPerPredicate: (0,
|
3499
|
-
gasPriceFactor: (0,
|
3500
|
-
gasPerByte: (0,
|
3501
|
-
maxMessageDataLength: (0,
|
3502
|
-
chainId: (0,
|
3587
|
+
contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
|
3588
|
+
maxInputs: (0, import_math16.bn)(txParams.maxInputs),
|
3589
|
+
maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
|
3590
|
+
maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
|
3591
|
+
maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
|
3592
|
+
maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
|
3593
|
+
maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
|
3594
|
+
maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
|
3595
|
+
maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
|
3596
|
+
maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
|
3597
|
+
maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
|
3598
|
+
gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
|
3599
|
+
gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
|
3600
|
+
maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
|
3601
|
+
chainId: (0, import_math16.bn)(consensusParameters.chainId),
|
3503
3602
|
gasCosts
|
3504
3603
|
},
|
3505
3604
|
gasCosts,
|
3506
3605
|
latestBlock: {
|
3507
3606
|
id: latestBlock.id,
|
3508
|
-
height: (0,
|
3607
|
+
height: (0, import_math16.bn)(latestBlock.height),
|
3509
3608
|
time: latestBlock.header.time,
|
3510
3609
|
transactions: latestBlock.transactions.map((i) => ({
|
3511
3610
|
id: i.id
|
@@ -3599,10 +3698,8 @@ var _Provider = class {
|
|
3599
3698
|
* Returns some helpful parameters related to gas fees.
|
3600
3699
|
*/
|
3601
3700
|
getGasConfig() {
|
3602
|
-
const { minGasPrice } = this.getNode();
|
3603
3701
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3604
3702
|
return {
|
3605
|
-
minGasPrice,
|
3606
3703
|
maxGasPerTx,
|
3607
3704
|
maxGasPerPredicate,
|
3608
3705
|
gasPriceFactor,
|
@@ -3690,7 +3787,7 @@ var _Provider = class {
|
|
3690
3787
|
name,
|
3691
3788
|
consensusParameters: { chainId }
|
3692
3789
|
} = await this.getChain();
|
3693
|
-
const network = new
|
3790
|
+
const network = new import_ethers2.Network(name, chainId.toNumber());
|
3694
3791
|
return Promise.resolve(network);
|
3695
3792
|
}
|
3696
3793
|
/**
|
@@ -3700,7 +3797,7 @@ var _Provider = class {
|
|
3700
3797
|
*/
|
3701
3798
|
async getBlockNumber() {
|
3702
3799
|
const { chain } = await this.operations.getChain();
|
3703
|
-
return (0,
|
3800
|
+
return (0, import_math16.bn)(chain.latestBlock.height, 10);
|
3704
3801
|
}
|
3705
3802
|
/**
|
3706
3803
|
* Returns the chain information.
|
@@ -3710,13 +3807,11 @@ var _Provider = class {
|
|
3710
3807
|
async fetchNode() {
|
3711
3808
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3712
3809
|
const processedNodeInfo = {
|
3713
|
-
maxDepth: (0,
|
3714
|
-
maxTx: (0,
|
3715
|
-
minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
|
3810
|
+
maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
|
3811
|
+
maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
|
3716
3812
|
nodeVersion: nodeInfo.nodeVersion,
|
3717
3813
|
utxoValidation: nodeInfo.utxoValidation,
|
3718
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
3719
|
-
peers: nodeInfo.peers
|
3814
|
+
vmBacktrace: nodeInfo.vmBacktrace
|
3720
3815
|
};
|
3721
3816
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
3722
3817
|
return processedNodeInfo;
|
@@ -3758,9 +3853,9 @@ var _Provider = class {
|
|
3758
3853
|
if (estimateTxDependencies) {
|
3759
3854
|
await this.estimateTxDependencies(transactionRequest);
|
3760
3855
|
}
|
3761
|
-
const encodedTransaction = (0,
|
3856
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3762
3857
|
let abis;
|
3763
|
-
if (transactionRequest.type ===
|
3858
|
+
if (transactionRequest.type === import_transactions19.TransactionType.Script) {
|
3764
3859
|
abis = transactionRequest.abis;
|
3765
3860
|
}
|
3766
3861
|
if (awaitExecution) {
|
@@ -3801,15 +3896,14 @@ var _Provider = class {
|
|
3801
3896
|
if (estimateTxDependencies) {
|
3802
3897
|
return this.estimateTxDependencies(transactionRequest);
|
3803
3898
|
}
|
3804
|
-
const encodedTransaction = (0,
|
3805
|
-
const { dryRun:
|
3806
|
-
encodedTransaction,
|
3899
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3900
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
3901
|
+
encodedTransactions: encodedTransaction,
|
3807
3902
|
utxoValidation: utxoValidation || false
|
3808
3903
|
});
|
3809
|
-
const receipts =
|
3810
|
-
|
3811
|
-
|
3812
|
-
};
|
3904
|
+
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
3905
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
3906
|
+
return { receipts, dryrunStatus: status };
|
3813
3907
|
}
|
3814
3908
|
/**
|
3815
3909
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -3820,13 +3914,13 @@ var _Provider = class {
|
|
3820
3914
|
async estimatePredicates(transactionRequest) {
|
3821
3915
|
const shouldEstimatePredicates = Boolean(
|
3822
3916
|
transactionRequest.inputs.find(
|
3823
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
3917
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math16.BN(input.predicateGasUsed).isZero()
|
3824
3918
|
)
|
3825
3919
|
);
|
3826
3920
|
if (!shouldEstimatePredicates) {
|
3827
3921
|
return transactionRequest;
|
3828
3922
|
}
|
3829
|
-
const encodedTransaction = (0,
|
3923
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3830
3924
|
const response = await this.operations.estimatePredicates({
|
3831
3925
|
encodedTransaction
|
3832
3926
|
});
|
@@ -3835,7 +3929,7 @@ var _Provider = class {
|
|
3835
3929
|
} = response;
|
3836
3930
|
if (inputs) {
|
3837
3931
|
inputs.forEach((input, index) => {
|
3838
|
-
if ("predicateGasUsed" in input && (0,
|
3932
|
+
if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
|
3839
3933
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3840
3934
|
}
|
3841
3935
|
});
|
@@ -3848,31 +3942,31 @@ var _Provider = class {
|
|
3848
3942
|
* If there are missing variable outputs,
|
3849
3943
|
* `addVariableOutputs` is called on the transaction.
|
3850
3944
|
*
|
3851
|
-
* @privateRemarks
|
3852
|
-
* TODO: Investigate support for missing contract IDs
|
3853
|
-
* TODO: Add support for missing output messages
|
3854
3945
|
*
|
3855
3946
|
* @param transactionRequest - The transaction request object.
|
3856
3947
|
* @returns A promise.
|
3857
3948
|
*/
|
3858
3949
|
async estimateTxDependencies(transactionRequest) {
|
3859
|
-
if (transactionRequest.type ===
|
3950
|
+
if (transactionRequest.type === import_transactions19.TransactionType.Create) {
|
3860
3951
|
return {
|
3861
3952
|
receipts: [],
|
3862
3953
|
outputVariables: 0,
|
3863
3954
|
missingContractIds: []
|
3864
3955
|
};
|
3865
3956
|
}
|
3866
|
-
await this.estimatePredicates(transactionRequest);
|
3867
3957
|
let receipts = [];
|
3868
3958
|
const missingContractIds = [];
|
3869
3959
|
let outputVariables = 0;
|
3960
|
+
let dryrunStatus;
|
3870
3961
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3871
|
-
const {
|
3872
|
-
|
3962
|
+
const {
|
3963
|
+
dryRun: [{ receipts: rawReceipts, status }]
|
3964
|
+
} = await this.operations.dryRun({
|
3965
|
+
encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
|
3873
3966
|
utxoValidation: false
|
3874
3967
|
});
|
3875
|
-
receipts =
|
3968
|
+
receipts = rawReceipts.map(processGqlReceipt);
|
3969
|
+
dryrunStatus = status;
|
3876
3970
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
3877
3971
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
3878
3972
|
if (hasMissingOutputs) {
|
@@ -3882,6 +3976,11 @@ var _Provider = class {
|
|
3882
3976
|
transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
|
3883
3977
|
missingContractIds.push(contractId);
|
3884
3978
|
});
|
3979
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
3980
|
+
transactionRequest,
|
3981
|
+
optimizeGas: false
|
3982
|
+
});
|
3983
|
+
transactionRequest.maxFee = maxFee;
|
3885
3984
|
} else {
|
3886
3985
|
break;
|
3887
3986
|
}
|
@@ -3889,37 +3988,133 @@ var _Provider = class {
|
|
3889
3988
|
return {
|
3890
3989
|
receipts,
|
3891
3990
|
outputVariables,
|
3892
|
-
missingContractIds
|
3991
|
+
missingContractIds,
|
3992
|
+
dryrunStatus
|
3893
3993
|
};
|
3894
3994
|
}
|
3895
3995
|
/**
|
3896
|
-
*
|
3897
|
-
*
|
3898
|
-
*
|
3996
|
+
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
3997
|
+
*
|
3998
|
+
* Transactions are dry run in batches. After each dry run, transactions requiring
|
3999
|
+
* further modifications are identified. The method iteratively updates these transactions
|
4000
|
+
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
4001
|
+
*
|
4002
|
+
* @param transactionRequests - Array of transaction request objects.
|
4003
|
+
* @returns A promise that resolves to an array of results for each transaction.
|
3899
4004
|
*/
|
3900
|
-
|
3901
|
-
const
|
3902
|
-
|
4005
|
+
async estimateMultipleTxDependencies(transactionRequests) {
|
4006
|
+
const results = transactionRequests.map(() => ({
|
4007
|
+
receipts: [],
|
4008
|
+
outputVariables: 0,
|
4009
|
+
missingContractIds: [],
|
4010
|
+
dryrunStatus: void 0
|
4011
|
+
}));
|
4012
|
+
const allRequests = (0, import_ramda3.clone)(transactionRequests);
|
4013
|
+
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4014
|
+
allRequests.forEach((req, index) => {
|
4015
|
+
if (req.type === import_transactions19.TransactionType.Script) {
|
4016
|
+
serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
|
4017
|
+
}
|
4018
|
+
});
|
4019
|
+
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
4020
|
+
let attempt = 0;
|
4021
|
+
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
4022
|
+
const encodedTransactions = transactionsToProcess.map(
|
4023
|
+
(index) => serializedTransactionsMap.get(index)
|
4024
|
+
);
|
4025
|
+
const dryRunResults = await this.operations.dryRun({
|
4026
|
+
encodedTransactions,
|
4027
|
+
utxoValidation: false
|
4028
|
+
});
|
4029
|
+
const nextRoundTransactions = [];
|
4030
|
+
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
4031
|
+
const currentResultIndex = transactionsToProcess[i];
|
4032
|
+
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4033
|
+
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
4034
|
+
results[currentResultIndex].dryrunStatus = status;
|
4035
|
+
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4036
|
+
results[currentResultIndex].receipts
|
4037
|
+
);
|
4038
|
+
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4039
|
+
const requestToProcess = allRequests[currentResultIndex];
|
4040
|
+
if (hasMissingOutputs && requestToProcess?.type === import_transactions19.TransactionType.Script) {
|
4041
|
+
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
4042
|
+
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
4043
|
+
missingOutputContractIds.forEach(({ contractId }) => {
|
4044
|
+
requestToProcess.addContractInputAndOutput(import_address3.Address.fromString(contractId));
|
4045
|
+
results[currentResultIndex].missingContractIds.push(contractId);
|
4046
|
+
});
|
4047
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
4048
|
+
transactionRequest: requestToProcess,
|
4049
|
+
optimizeGas: false
|
4050
|
+
});
|
4051
|
+
requestToProcess.maxFee = maxFee;
|
4052
|
+
serializedTransactionsMap.set(
|
4053
|
+
currentResultIndex,
|
4054
|
+
(0, import_utils22.hexlify)(requestToProcess.toTransactionBytes())
|
4055
|
+
);
|
4056
|
+
nextRoundTransactions.push(currentResultIndex);
|
4057
|
+
allRequests[currentResultIndex] = requestToProcess;
|
4058
|
+
}
|
4059
|
+
}
|
4060
|
+
transactionsToProcess = nextRoundTransactions;
|
4061
|
+
attempt += 1;
|
4062
|
+
}
|
4063
|
+
return results;
|
4064
|
+
}
|
4065
|
+
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
4066
|
+
if (estimateTxDependencies) {
|
4067
|
+
return this.estimateMultipleTxDependencies(transactionRequests);
|
4068
|
+
}
|
4069
|
+
const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
|
4070
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4071
|
+
encodedTransactions,
|
4072
|
+
utxoValidation: utxoValidation || false
|
4073
|
+
});
|
4074
|
+
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4075
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
4076
|
+
return { receipts, dryrunStatus: status };
|
4077
|
+
});
|
4078
|
+
return results;
|
4079
|
+
}
|
4080
|
+
async estimateTxGasAndFee(params) {
|
4081
|
+
const { transactionRequest, optimizeGas = true } = params;
|
4082
|
+
let { gasPrice } = params;
|
3903
4083
|
const chainInfo = this.getChain();
|
3904
|
-
const
|
3905
|
-
transactionRequest.gasPrice = gasPrice;
|
4084
|
+
const { gasPriceFactor } = this.getGasConfig();
|
3906
4085
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
3907
|
-
|
3908
|
-
|
3909
|
-
|
4086
|
+
if (!gasPrice) {
|
4087
|
+
gasPrice = await this.estimateGasPrice(10);
|
4088
|
+
}
|
4089
|
+
const minFee = calculateGasFee({
|
4090
|
+
gasPrice: (0, import_math16.bn)(gasPrice),
|
4091
|
+
gas: minGas,
|
4092
|
+
priceFactor: gasPriceFactor,
|
4093
|
+
tip: transactionRequest.tip
|
4094
|
+
}).add(1);
|
4095
|
+
let gasLimit = (0, import_math16.bn)(0);
|
4096
|
+
if (transactionRequest.type === import_transactions19.TransactionType.Script) {
|
4097
|
+
gasLimit = transactionRequest.gasLimit;
|
4098
|
+
if (!optimizeGas) {
|
3910
4099
|
transactionRequest.gasLimit = minGas;
|
3911
|
-
|
3912
|
-
|
3913
|
-
);
|
4100
|
+
gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4101
|
+
transactionRequest.gasLimit = gasLimit;
|
3914
4102
|
}
|
3915
4103
|
}
|
3916
4104
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
3917
|
-
const maxFee =
|
4105
|
+
const maxFee = calculateGasFee({
|
4106
|
+
gasPrice: (0, import_math16.bn)(gasPrice),
|
4107
|
+
gas: maxGas,
|
4108
|
+
priceFactor: gasPriceFactor,
|
4109
|
+
tip: transactionRequest.tip
|
4110
|
+
}).add(1);
|
3918
4111
|
return {
|
3919
4112
|
minGas,
|
3920
4113
|
minFee,
|
3921
4114
|
maxGas,
|
3922
|
-
maxFee
|
4115
|
+
maxFee,
|
4116
|
+
gasPrice,
|
4117
|
+
gasLimit
|
3923
4118
|
};
|
3924
4119
|
}
|
3925
4120
|
/**
|
@@ -3937,15 +4132,17 @@ var _Provider = class {
|
|
3937
4132
|
if (estimateTxDependencies) {
|
3938
4133
|
return this.estimateTxDependencies(transactionRequest);
|
3939
4134
|
}
|
3940
|
-
const
|
3941
|
-
const { dryRun:
|
3942
|
-
|
4135
|
+
const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
|
4136
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4137
|
+
encodedTransactions,
|
3943
4138
|
utxoValidation: true
|
3944
4139
|
});
|
3945
|
-
const
|
3946
|
-
|
3947
|
-
receipts
|
3948
|
-
|
4140
|
+
const callResult = dryRunStatuses.map((dryRunStatus) => {
|
4141
|
+
const { id, receipts, status } = dryRunStatus;
|
4142
|
+
const processedReceipts = receipts.map(processGqlReceipt);
|
4143
|
+
return { id, receipts: processedReceipts, status };
|
4144
|
+
});
|
4145
|
+
return { receipts: callResult[0].receipts };
|
3949
4146
|
}
|
3950
4147
|
/**
|
3951
4148
|
* Returns a transaction cost to enable user
|
@@ -3962,77 +4159,80 @@ var _Provider = class {
|
|
3962
4159
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
3963
4160
|
* @returns A promise that resolves to the transaction cost object.
|
3964
4161
|
*/
|
3965
|
-
async getTransactionCost(transactionRequestLike,
|
3966
|
-
estimateTxDependencies = true,
|
3967
|
-
estimatePredicates = true,
|
3968
|
-
resourcesOwner,
|
3969
|
-
signatureCallback
|
3970
|
-
} = {}) {
|
4162
|
+
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
3971
4163
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
3972
|
-
const
|
3973
|
-
const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
|
3974
|
-
const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
|
4164
|
+
const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
|
3975
4165
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
3976
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
4166
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
3977
4167
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
4168
|
+
txRequestClone.maxFee = (0, import_math16.bn)(0);
|
3978
4169
|
if (isScriptTransaction) {
|
3979
|
-
txRequestClone.gasLimit = (0,
|
4170
|
+
txRequestClone.gasLimit = (0, import_math16.bn)(0);
|
3980
4171
|
}
|
3981
|
-
if (
|
3982
|
-
|
3983
|
-
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
3984
|
-
}
|
3985
|
-
await this.estimatePredicates(txRequestClone);
|
4172
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4173
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
3986
4174
|
}
|
4175
|
+
const signedRequest = (0, import_ramda3.clone)(txRequestClone);
|
4176
|
+
let addedSignatures = 0;
|
3987
4177
|
if (signatureCallback && isScriptTransaction) {
|
3988
|
-
|
3989
|
-
|
3990
|
-
|
3991
|
-
|
4178
|
+
const lengthBefore = signedRequest.witnesses.length;
|
4179
|
+
await signatureCallback(signedRequest);
|
4180
|
+
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
4181
|
+
}
|
4182
|
+
await this.estimatePredicates(signedRequest);
|
4183
|
+
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
4184
|
+
transactionRequest: signedRequest,
|
4185
|
+
optimizeGas: false
|
3992
4186
|
});
|
4187
|
+
txRequestClone.maxFee = maxFee;
|
3993
4188
|
let receipts = [];
|
3994
4189
|
let missingContractIds = [];
|
3995
4190
|
let outputVariables = 0;
|
3996
|
-
let gasUsed = (0,
|
3997
|
-
|
3998
|
-
|
4191
|
+
let gasUsed = (0, import_math16.bn)(0);
|
4192
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4193
|
+
if (isScriptTransaction) {
|
4194
|
+
if (signatureCallback) {
|
4195
|
+
await signatureCallback(txRequestClone);
|
4196
|
+
}
|
4197
|
+
txRequestClone.gasLimit = gasLimit;
|
3999
4198
|
const result = await this.estimateTxDependencies(txRequestClone);
|
4000
4199
|
receipts = result.receipts;
|
4001
4200
|
outputVariables = result.outputVariables;
|
4002
4201
|
missingContractIds = result.missingContractIds;
|
4003
|
-
gasUsed =
|
4202
|
+
gasUsed = getGasUsedFromReceipts(receipts);
|
4004
4203
|
txRequestClone.gasLimit = gasUsed;
|
4005
|
-
|
4006
|
-
|
4007
|
-
|
4204
|
+
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
4205
|
+
transactionRequest: txRequestClone,
|
4206
|
+
gasPrice
|
4008
4207
|
}));
|
4009
4208
|
}
|
4010
4209
|
return {
|
4011
4210
|
requiredQuantities: allQuantities,
|
4012
4211
|
receipts,
|
4013
4212
|
gasUsed,
|
4014
|
-
|
4015
|
-
gasPrice: setGasPrice,
|
4213
|
+
gasPrice,
|
4016
4214
|
minGas,
|
4017
4215
|
maxGas,
|
4018
4216
|
minFee,
|
4019
4217
|
maxFee,
|
4020
|
-
estimatedInputs: txRequestClone.inputs,
|
4021
4218
|
outputVariables,
|
4022
|
-
missingContractIds
|
4219
|
+
missingContractIds,
|
4220
|
+
addedSignatures,
|
4221
|
+
estimatedPredicates: txRequestClone.inputs
|
4023
4222
|
};
|
4024
4223
|
}
|
4025
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
4224
|
+
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
4026
4225
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4027
4226
|
const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
|
4028
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
4227
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, {
|
4228
|
+
quantitiesToContract
|
4229
|
+
});
|
4029
4230
|
transactionRequest.addResources(
|
4030
4231
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
4031
4232
|
);
|
4032
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4033
|
-
|
4034
|
-
|
4035
|
-
);
|
4233
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
|
4234
|
+
quantitiesToContract
|
4235
|
+
});
|
4036
4236
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
4037
4237
|
return {
|
4038
4238
|
resources,
|
@@ -4048,17 +4248,16 @@ var _Provider = class {
|
|
4048
4248
|
const result = await this.operations.getCoins({
|
4049
4249
|
first: 10,
|
4050
4250
|
...paginationArgs,
|
4051
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
4251
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
|
4052
4252
|
});
|
4053
4253
|
const coins = result.coins.edges.map((edge) => edge.node);
|
4054
4254
|
return coins.map((coin) => ({
|
4055
4255
|
id: coin.utxoId,
|
4056
4256
|
assetId: coin.assetId,
|
4057
|
-
amount: (0,
|
4257
|
+
amount: (0, import_math16.bn)(coin.amount),
|
4058
4258
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4059
|
-
|
4060
|
-
|
4061
|
-
txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
|
4259
|
+
blockCreated: (0, import_math16.bn)(coin.blockCreated),
|
4260
|
+
txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
|
4062
4261
|
}));
|
4063
4262
|
}
|
4064
4263
|
/**
|
@@ -4072,19 +4271,19 @@ var _Provider = class {
|
|
4072
4271
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4073
4272
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4074
4273
|
const excludeInput = {
|
4075
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
4076
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
4274
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
|
4275
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
|
4077
4276
|
};
|
4078
4277
|
if (this.cache) {
|
4079
4278
|
const uniqueUtxos = new Set(
|
4080
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
4279
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
|
4081
4280
|
);
|
4082
4281
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
4083
4282
|
}
|
4084
4283
|
const coinsQuery = {
|
4085
4284
|
owner: ownerAddress.toB256(),
|
4086
4285
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4087
|
-
assetId: (0,
|
4286
|
+
assetId: (0, import_utils22.hexlify)(assetId),
|
4088
4287
|
amount: amount.toString(10),
|
4089
4288
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4090
4289
|
})),
|
@@ -4095,9 +4294,9 @@ var _Provider = class {
|
|
4095
4294
|
switch (coin.__typename) {
|
4096
4295
|
case "MessageCoin":
|
4097
4296
|
return {
|
4098
|
-
amount: (0,
|
4297
|
+
amount: (0, import_math16.bn)(coin.amount),
|
4099
4298
|
assetId: coin.assetId,
|
4100
|
-
daHeight: (0,
|
4299
|
+
daHeight: (0, import_math16.bn)(coin.daHeight),
|
4101
4300
|
sender: import_address3.Address.fromAddressOrString(coin.sender),
|
4102
4301
|
recipient: import_address3.Address.fromAddressOrString(coin.recipient),
|
4103
4302
|
nonce: coin.nonce
|
@@ -4105,12 +4304,11 @@ var _Provider = class {
|
|
4105
4304
|
case "Coin":
|
4106
4305
|
return {
|
4107
4306
|
id: coin.utxoId,
|
4108
|
-
amount: (0,
|
4307
|
+
amount: (0, import_math16.bn)(coin.amount),
|
4109
4308
|
assetId: coin.assetId,
|
4110
4309
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4111
|
-
|
4112
|
-
|
4113
|
-
txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
|
4310
|
+
blockCreated: (0, import_math16.bn)(coin.blockCreated),
|
4311
|
+
txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
|
4114
4312
|
};
|
4115
4313
|
default:
|
4116
4314
|
return null;
|
@@ -4127,13 +4325,13 @@ var _Provider = class {
|
|
4127
4325
|
async getBlock(idOrHeight) {
|
4128
4326
|
let variables;
|
4129
4327
|
if (typeof idOrHeight === "number") {
|
4130
|
-
variables = { height: (0,
|
4328
|
+
variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
|
4131
4329
|
} else if (idOrHeight === "latest") {
|
4132
4330
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4133
4331
|
} else if (idOrHeight.length === 66) {
|
4134
4332
|
variables = { blockId: idOrHeight };
|
4135
4333
|
} else {
|
4136
|
-
variables = { blockId: (0,
|
4334
|
+
variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
|
4137
4335
|
}
|
4138
4336
|
const { block } = await this.operations.getBlock(variables);
|
4139
4337
|
if (!block) {
|
@@ -4141,7 +4339,7 @@ var _Provider = class {
|
|
4141
4339
|
}
|
4142
4340
|
return {
|
4143
4341
|
id: block.id,
|
4144
|
-
height: (0,
|
4342
|
+
height: (0, import_math16.bn)(block.height),
|
4145
4343
|
time: block.header.time,
|
4146
4344
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4147
4345
|
};
|
@@ -4156,7 +4354,7 @@ var _Provider = class {
|
|
4156
4354
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4157
4355
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4158
4356
|
id: block.id,
|
4159
|
-
height: (0,
|
4357
|
+
height: (0, import_math16.bn)(block.height),
|
4160
4358
|
time: block.header.time,
|
4161
4359
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4162
4360
|
}));
|
@@ -4171,7 +4369,7 @@ var _Provider = class {
|
|
4171
4369
|
async getBlockWithTransactions(idOrHeight) {
|
4172
4370
|
let variables;
|
4173
4371
|
if (typeof idOrHeight === "number") {
|
4174
|
-
variables = { blockHeight: (0,
|
4372
|
+
variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
|
4175
4373
|
} else if (idOrHeight === "latest") {
|
4176
4374
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4177
4375
|
} else {
|
@@ -4183,11 +4381,11 @@ var _Provider = class {
|
|
4183
4381
|
}
|
4184
4382
|
return {
|
4185
4383
|
id: block.id,
|
4186
|
-
height: (0,
|
4384
|
+
height: (0, import_math16.bn)(block.height, 10),
|
4187
4385
|
time: block.header.time,
|
4188
4386
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4189
4387
|
transactions: block.transactions.map(
|
4190
|
-
(tx) => new
|
4388
|
+
(tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
|
4191
4389
|
)
|
4192
4390
|
};
|
4193
4391
|
}
|
@@ -4202,8 +4400,8 @@ var _Provider = class {
|
|
4202
4400
|
if (!transaction) {
|
4203
4401
|
return null;
|
4204
4402
|
}
|
4205
|
-
return new
|
4206
|
-
(0,
|
4403
|
+
return new import_transactions19.TransactionCoder().decode(
|
4404
|
+
(0, import_utils22.arrayify)(transaction.rawPayload),
|
4207
4405
|
0
|
4208
4406
|
)?.[0];
|
4209
4407
|
}
|
@@ -4230,9 +4428,9 @@ var _Provider = class {
|
|
4230
4428
|
async getContractBalance(contractId, assetId) {
|
4231
4429
|
const { contractBalance } = await this.operations.getContractBalance({
|
4232
4430
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4233
|
-
asset: (0,
|
4431
|
+
asset: (0, import_utils22.hexlify)(assetId)
|
4234
4432
|
});
|
4235
|
-
return (0,
|
4433
|
+
return (0, import_math16.bn)(contractBalance.amount, 10);
|
4236
4434
|
}
|
4237
4435
|
/**
|
4238
4436
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4244,9 +4442,9 @@ var _Provider = class {
|
|
4244
4442
|
async getBalance(owner, assetId) {
|
4245
4443
|
const { balance } = await this.operations.getBalance({
|
4246
4444
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4247
|
-
assetId: (0,
|
4445
|
+
assetId: (0, import_utils22.hexlify)(assetId)
|
4248
4446
|
});
|
4249
|
-
return (0,
|
4447
|
+
return (0, import_math16.bn)(balance.amount, 10);
|
4250
4448
|
}
|
4251
4449
|
/**
|
4252
4450
|
* Returns balances for the given owner.
|
@@ -4264,7 +4462,7 @@ var _Provider = class {
|
|
4264
4462
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4265
4463
|
return balances.map((balance) => ({
|
4266
4464
|
assetId: balance.assetId,
|
4267
|
-
amount: (0,
|
4465
|
+
amount: (0, import_math16.bn)(balance.amount)
|
4268
4466
|
}));
|
4269
4467
|
}
|
4270
4468
|
/**
|
@@ -4282,19 +4480,19 @@ var _Provider = class {
|
|
4282
4480
|
});
|
4283
4481
|
const messages = result.messages.edges.map((edge) => edge.node);
|
4284
4482
|
return messages.map((message) => ({
|
4285
|
-
messageId:
|
4483
|
+
messageId: import_transactions19.InputMessageCoder.getMessageId({
|
4286
4484
|
sender: message.sender,
|
4287
4485
|
recipient: message.recipient,
|
4288
4486
|
nonce: message.nonce,
|
4289
|
-
amount: (0,
|
4487
|
+
amount: (0, import_math16.bn)(message.amount),
|
4290
4488
|
data: message.data
|
4291
4489
|
}),
|
4292
4490
|
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4293
4491
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4294
4492
|
nonce: message.nonce,
|
4295
|
-
amount: (0,
|
4296
|
-
data:
|
4297
|
-
daHeight: (0,
|
4493
|
+
amount: (0, import_math16.bn)(message.amount),
|
4494
|
+
data: import_transactions19.InputMessageCoder.decodeData(message.data),
|
4495
|
+
daHeight: (0, import_math16.bn)(message.daHeight)
|
4298
4496
|
}));
|
4299
4497
|
}
|
4300
4498
|
/**
|
@@ -4347,44 +4545,52 @@ var _Provider = class {
|
|
4347
4545
|
} = result.messageProof;
|
4348
4546
|
return {
|
4349
4547
|
messageProof: {
|
4350
|
-
proofIndex: (0,
|
4548
|
+
proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
|
4351
4549
|
proofSet: messageProof.proofSet
|
4352
4550
|
},
|
4353
4551
|
blockProof: {
|
4354
|
-
proofIndex: (0,
|
4552
|
+
proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
|
4355
4553
|
proofSet: blockProof.proofSet
|
4356
4554
|
},
|
4357
4555
|
messageBlockHeader: {
|
4358
4556
|
id: messageBlockHeader.id,
|
4359
|
-
daHeight: (0,
|
4360
|
-
transactionsCount: (0,
|
4557
|
+
daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
|
4558
|
+
transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
|
4361
4559
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4362
|
-
height: (0,
|
4560
|
+
height: (0, import_math16.bn)(messageBlockHeader.height),
|
4363
4561
|
prevRoot: messageBlockHeader.prevRoot,
|
4364
4562
|
time: messageBlockHeader.time,
|
4365
4563
|
applicationHash: messageBlockHeader.applicationHash,
|
4366
|
-
|
4367
|
-
messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
|
4564
|
+
messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount)
|
4368
4565
|
},
|
4369
4566
|
commitBlockHeader: {
|
4370
4567
|
id: commitBlockHeader.id,
|
4371
|
-
daHeight: (0,
|
4372
|
-
transactionsCount: (0,
|
4568
|
+
daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
|
4569
|
+
transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
|
4373
4570
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4374
|
-
height: (0,
|
4571
|
+
height: (0, import_math16.bn)(commitBlockHeader.height),
|
4375
4572
|
prevRoot: commitBlockHeader.prevRoot,
|
4376
4573
|
time: commitBlockHeader.time,
|
4377
4574
|
applicationHash: commitBlockHeader.applicationHash,
|
4378
|
-
|
4379
|
-
messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
|
4575
|
+
messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount)
|
4380
4576
|
},
|
4381
4577
|
sender: import_address3.Address.fromAddressOrString(sender),
|
4382
4578
|
recipient: import_address3.Address.fromAddressOrString(recipient),
|
4383
4579
|
nonce,
|
4384
|
-
amount: (0,
|
4580
|
+
amount: (0, import_math16.bn)(amount),
|
4385
4581
|
data
|
4386
4582
|
};
|
4387
4583
|
}
|
4584
|
+
async getLatestGasPrice() {
|
4585
|
+
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4586
|
+
return (0, import_math16.bn)(latestGasPrice.gasPrice);
|
4587
|
+
}
|
4588
|
+
async estimateGasPrice(blockHorizon) {
|
4589
|
+
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4590
|
+
blockHorizon: String(blockHorizon)
|
4591
|
+
});
|
4592
|
+
return (0, import_math16.bn)(estimateGasPrice.gasPrice);
|
4593
|
+
}
|
4388
4594
|
/**
|
4389
4595
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
4390
4596
|
*
|
@@ -4404,10 +4610,10 @@ var _Provider = class {
|
|
4404
4610
|
*/
|
4405
4611
|
async produceBlocks(amount, startTime) {
|
4406
4612
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4407
|
-
blocksToProduce: (0,
|
4408
|
-
startTimestamp: startTime ?
|
4613
|
+
blocksToProduce: (0, import_math16.bn)(amount).toString(10),
|
4614
|
+
startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4409
4615
|
});
|
4410
|
-
return (0,
|
4616
|
+
return (0, import_math16.bn)(latestBlockHeight);
|
4411
4617
|
}
|
4412
4618
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4413
4619
|
async getTransactionResponse(transactionId) {
|
@@ -4421,7 +4627,7 @@ cacheInputs_fn = function(inputs) {
|
|
4421
4627
|
return;
|
4422
4628
|
}
|
4423
4629
|
inputs.forEach((input) => {
|
4424
|
-
if (input.type ===
|
4630
|
+
if (input.type === import_transactions19.InputType.Coin) {
|
4425
4631
|
this.cache?.set(input.id);
|
4426
4632
|
}
|
4427
4633
|
});
|
@@ -4431,9 +4637,9 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4431
4637
|
|
4432
4638
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4433
4639
|
var import_errors15 = require("@fuel-ts/errors");
|
4434
|
-
var
|
4435
|
-
var
|
4436
|
-
var
|
4640
|
+
var import_math17 = require("@fuel-ts/math");
|
4641
|
+
var import_transactions20 = require("@fuel-ts/transactions");
|
4642
|
+
var import_utils25 = require("@fuel-ts/utils");
|
4437
4643
|
|
4438
4644
|
// src/providers/chains.ts
|
4439
4645
|
var CHAIN_IDS = {
|
@@ -4481,18 +4687,18 @@ var assets = [
|
|
4481
4687
|
];
|
4482
4688
|
|
4483
4689
|
// src/utils/formatTransferToContractScriptData.ts
|
4484
|
-
var
|
4485
|
-
var
|
4486
|
-
var
|
4690
|
+
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
4691
|
+
var import_math18 = require("@fuel-ts/math");
|
4692
|
+
var import_utils26 = require("@fuel-ts/utils");
|
4487
4693
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4488
4694
|
var formatTransferToContractScriptData = (params) => {
|
4489
4695
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4490
|
-
const numberCoder = new
|
4491
|
-
const encoded = numberCoder.encode(new
|
4696
|
+
const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
|
4697
|
+
const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
|
4492
4698
|
const scriptData = Uint8Array.from([
|
4493
|
-
...(0,
|
4699
|
+
...(0, import_utils26.arrayify)(hexlifiedContractId),
|
4494
4700
|
...encoded,
|
4495
|
-
...(0,
|
4701
|
+
...(0, import_utils26.arrayify)(assetId)
|
4496
4702
|
]);
|
4497
4703
|
return scriptData;
|
4498
4704
|
};
|
@@ -4677,36 +4883,33 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4677
4883
|
* @param fee - The estimated transaction fee.
|
4678
4884
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4679
4885
|
*/
|
4680
|
-
async fund(request,
|
4681
|
-
const
|
4682
|
-
|
4886
|
+
async fund(request, params) {
|
4887
|
+
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
4888
|
+
const txRequest = request;
|
4889
|
+
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
4890
|
+
amount: (0, import_math19.bn)(fee),
|
4683
4891
|
assetId: import_configs12.BaseAssetId,
|
4684
|
-
coinQuantities
|
4892
|
+
coinQuantities: requiredQuantities
|
4685
4893
|
});
|
4686
4894
|
const quantitiesDict = {};
|
4687
|
-
|
4895
|
+
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
4688
4896
|
quantitiesDict[assetId] = {
|
4689
4897
|
required: amount,
|
4690
|
-
owned: (0,
|
4898
|
+
owned: (0, import_math19.bn)(0)
|
4691
4899
|
};
|
4692
4900
|
});
|
4693
|
-
|
4694
|
-
const cachedMessages = [];
|
4695
|
-
const owner = this.address.toB256();
|
4696
|
-
request.inputs.forEach((input) => {
|
4901
|
+
txRequest.inputs.forEach((input) => {
|
4697
4902
|
const isResource = "amount" in input;
|
4698
4903
|
if (isResource) {
|
4699
4904
|
const isCoin2 = "owner" in input;
|
4700
4905
|
if (isCoin2) {
|
4701
4906
|
const assetId = String(input.assetId);
|
4702
|
-
if (
|
4703
|
-
const amount = (0,
|
4907
|
+
if (quantitiesDict[assetId]) {
|
4908
|
+
const amount = (0, import_math19.bn)(input.amount);
|
4704
4909
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4705
|
-
cachedUtxos.push(input.id);
|
4706
4910
|
}
|
4707
|
-
} else if (input.
|
4911
|
+
} else if (input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
|
4708
4912
|
quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
|
4709
|
-
cachedMessages.push(input.nonce);
|
4710
4913
|
}
|
4711
4914
|
}
|
4712
4915
|
});
|
@@ -4721,12 +4924,23 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4721
4924
|
});
|
4722
4925
|
const needsToBeFunded = missingQuantities.length;
|
4723
4926
|
if (needsToBeFunded) {
|
4724
|
-
const
|
4725
|
-
|
4726
|
-
|
4727
|
-
|
4728
|
-
|
4927
|
+
const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
|
4928
|
+
const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
|
4929
|
+
txRequest.addResources(resources);
|
4930
|
+
}
|
4931
|
+
txRequest.shiftPredicateData();
|
4932
|
+
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
4933
|
+
const requestToBeReEstimate = (0, import_ramda4.clone)(txRequest);
|
4934
|
+
if (addedSignatures) {
|
4935
|
+
Array.from({ length: addedSignatures }).forEach(
|
4936
|
+
() => requestToBeReEstimate.addEmptyWitness()
|
4937
|
+
);
|
4729
4938
|
}
|
4939
|
+
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
4940
|
+
transactionRequest: requestToBeReEstimate
|
4941
|
+
});
|
4942
|
+
txRequest.maxFee = maxFee;
|
4943
|
+
return txRequest;
|
4730
4944
|
}
|
4731
4945
|
/**
|
4732
4946
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -4734,28 +4948,25 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4734
4948
|
* @param destination - The address of the destination.
|
4735
4949
|
* @param amount - The amount of coins to transfer.
|
4736
4950
|
* @param assetId - The asset ID of the coins to transfer.
|
4737
|
-
* @param txParams - The transaction parameters (gasLimit,
|
4951
|
+
* @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
|
4738
4952
|
* @returns A promise that resolves to the prepared transaction request.
|
4739
4953
|
*/
|
4740
4954
|
async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
4741
|
-
const
|
4742
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
4743
|
-
const request = new ScriptTransactionRequest(params);
|
4955
|
+
const request = new ScriptTransactionRequest(txParams);
|
4744
4956
|
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
|
4745
|
-
const
|
4957
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
4746
4958
|
estimateTxDependencies: true,
|
4747
4959
|
resourcesOwner: this
|
4748
4960
|
});
|
4749
|
-
|
4750
|
-
|
4751
|
-
|
4752
|
-
|
4753
|
-
|
4754
|
-
|
4755
|
-
|
4756
|
-
|
4757
|
-
await this.fund(request,
|
4758
|
-
request.updatePredicateInputs(estimatedInputs);
|
4961
|
+
if ("gasLimit" in txParams) {
|
4962
|
+
this.validateGas({
|
4963
|
+
gasUsed: txCost.gasUsed,
|
4964
|
+
gasLimit: request.gasLimit
|
4965
|
+
});
|
4966
|
+
}
|
4967
|
+
request.gasLimit = txCost.gasUsed;
|
4968
|
+
request.maxFee = txCost.maxFee;
|
4969
|
+
await this.fund(request, txCost);
|
4759
4970
|
return request;
|
4760
4971
|
}
|
4761
4972
|
/**
|
@@ -4768,7 +4979,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4768
4979
|
* @returns A promise that resolves to the transaction response.
|
4769
4980
|
*/
|
4770
4981
|
async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
4771
|
-
if ((0,
|
4982
|
+
if ((0, import_math19.bn)(amount).lte(0)) {
|
4772
4983
|
throw new import_errors16.FuelError(
|
4773
4984
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
4774
4985
|
"Transfer amount must be a positive number."
|
@@ -4787,38 +4998,37 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4787
4998
|
* @returns A promise that resolves to the transaction response.
|
4788
4999
|
*/
|
4789
5000
|
async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
4790
|
-
if ((0,
|
5001
|
+
if ((0, import_math19.bn)(amount).lte(0)) {
|
4791
5002
|
throw new import_errors16.FuelError(
|
4792
5003
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
4793
5004
|
"Transfer amount must be a positive number."
|
4794
5005
|
);
|
4795
5006
|
}
|
4796
5007
|
const contractAddress = import_address4.Address.fromAddressOrString(contractId);
|
4797
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
4798
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
4799
5008
|
const { script, scriptData } = await assembleTransferToContractScript({
|
4800
5009
|
hexlifiedContractId: contractAddress.toB256(),
|
4801
|
-
amountToTransfer: (0,
|
5010
|
+
amountToTransfer: (0, import_math19.bn)(amount),
|
4802
5011
|
assetId
|
4803
5012
|
});
|
4804
5013
|
const request = new ScriptTransactionRequest({
|
4805
|
-
...
|
5014
|
+
...txParams,
|
4806
5015
|
script,
|
4807
5016
|
scriptData
|
4808
5017
|
});
|
4809
5018
|
request.addContractInputAndOutput(contractAddress);
|
4810
|
-
const
|
4811
|
-
|
4812
|
-
[{ amount: (0,
|
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
|
5019
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
5020
|
+
resourcesOwner: this,
|
5021
|
+
quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetId) }]
|
4820
5022
|
});
|
4821
|
-
|
5023
|
+
if (txParams.gasLimit) {
|
5024
|
+
this.validateGas({
|
5025
|
+
gasUsed: txCost.gasUsed,
|
5026
|
+
gasLimit: request.gasLimit
|
5027
|
+
});
|
5028
|
+
}
|
5029
|
+
request.gasLimit = txCost.gasUsed;
|
5030
|
+
request.maxFee = txCost.maxFee;
|
5031
|
+
await this.fund(request, txCost);
|
4822
5032
|
return this.sendTransaction(request);
|
4823
5033
|
}
|
4824
5034
|
/**
|
@@ -4830,34 +5040,31 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4830
5040
|
* @returns A promise that resolves to the transaction response.
|
4831
5041
|
*/
|
4832
5042
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4833
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
4834
5043
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
4835
|
-
const recipientDataArray = (0,
|
5044
|
+
const recipientDataArray = (0, import_utils27.arrayify)(
|
4836
5045
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
4837
5046
|
);
|
4838
|
-
const amountDataArray = (0,
|
4839
|
-
"0x".concat((0,
|
5047
|
+
const amountDataArray = (0, import_utils27.arrayify)(
|
5048
|
+
"0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
4840
5049
|
);
|
4841
5050
|
const script = new Uint8Array([
|
4842
|
-
...(0,
|
5051
|
+
...(0, import_utils27.arrayify)(withdrawScript.bytes),
|
4843
5052
|
...recipientDataArray,
|
4844
5053
|
...amountDataArray
|
4845
5054
|
]);
|
4846
|
-
const params = { script,
|
5055
|
+
const params = { script, ...txParams };
|
4847
5056
|
const request = new ScriptTransactionRequest(params);
|
4848
|
-
const
|
4849
|
-
const
|
4850
|
-
|
4851
|
-
|
4852
|
-
|
4853
|
-
|
4854
|
-
|
4855
|
-
|
4856
|
-
|
4857
|
-
|
4858
|
-
|
4859
|
-
});
|
4860
|
-
await this.fund(request, requiredQuantities, maxFee);
|
5057
|
+
const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: import_configs12.BaseAssetId }];
|
5058
|
+
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5059
|
+
if (txParams.gasLimit) {
|
5060
|
+
this.validateGas({
|
5061
|
+
gasUsed: txCost.gasUsed,
|
5062
|
+
gasLimit: request.gasLimit
|
5063
|
+
});
|
5064
|
+
}
|
5065
|
+
request.maxFee = txCost.maxFee;
|
5066
|
+
request.gasLimit = txCost.gasUsed;
|
5067
|
+
await this.fund(request, txCost);
|
4861
5068
|
return this.sendTransaction(request);
|
4862
5069
|
}
|
4863
5070
|
async signMessage(message) {
|
@@ -4915,18 +5122,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4915
5122
|
}
|
4916
5123
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
4917
5124
|
}
|
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
|
-
}
|
5125
|
+
validateGas({ gasUsed, gasLimit }) {
|
4930
5126
|
if (gasUsed.gt(gasLimit)) {
|
4931
5127
|
throw new import_errors16.FuelError(
|
4932
5128
|
import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
|
@@ -4938,10 +5134,10 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4938
5134
|
|
4939
5135
|
// src/signer/signer.ts
|
4940
5136
|
var import_address5 = require("@fuel-ts/address");
|
4941
|
-
var
|
5137
|
+
var import_crypto = require("@fuel-ts/crypto");
|
4942
5138
|
var import_hasher2 = require("@fuel-ts/hasher");
|
4943
|
-
var
|
4944
|
-
var
|
5139
|
+
var import_math20 = require("@fuel-ts/math");
|
5140
|
+
var import_utils28 = require("@fuel-ts/utils");
|
4945
5141
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
4946
5142
|
var Signer = class {
|
4947
5143
|
address;
|
@@ -4960,10 +5156,10 @@ var Signer = class {
|
|
4960
5156
|
privateKey = `0x${privateKey}`;
|
4961
5157
|
}
|
4962
5158
|
}
|
4963
|
-
const privateKeyBytes = (0,
|
4964
|
-
this.privateKey = (0,
|
4965
|
-
this.publicKey = (0,
|
4966
|
-
this.compressedPublicKey = (0,
|
5159
|
+
const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
|
5160
|
+
this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
|
5161
|
+
this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5162
|
+
this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
4967
5163
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
4968
5164
|
}
|
4969
5165
|
/**
|
@@ -4977,11 +5173,11 @@ var Signer = class {
|
|
4977
5173
|
* @returns hashed signature
|
4978
5174
|
*/
|
4979
5175
|
sign(data) {
|
4980
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
4981
|
-
const r = (0,
|
4982
|
-
const s = (0,
|
5176
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
|
5177
|
+
const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5178
|
+
const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
4983
5179
|
s[0] |= (signature.recovery || 0) << 7;
|
4984
|
-
return (0,
|
5180
|
+
return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
|
4985
5181
|
}
|
4986
5182
|
/**
|
4987
5183
|
* Add point on the current elliptic curve
|
@@ -4990,8 +5186,8 @@ var Signer = class {
|
|
4990
5186
|
* @returns compressed point on the curve
|
4991
5187
|
*/
|
4992
5188
|
addPoint(point) {
|
4993
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
4994
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5189
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
|
5190
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
|
4995
5191
|
const result = p0.add(p1);
|
4996
5192
|
return `0x${result.toHex(true)}`;
|
4997
5193
|
}
|
@@ -5003,16 +5199,16 @@ var Signer = class {
|
|
5003
5199
|
* @returns public key from signature from the
|
5004
5200
|
*/
|
5005
5201
|
static recoverPublicKey(data, signature) {
|
5006
|
-
const signedMessageBytes = (0,
|
5202
|
+
const signedMessageBytes = (0, import_utils28.arrayify)(signature);
|
5007
5203
|
const r = signedMessageBytes.slice(0, 32);
|
5008
5204
|
const s = signedMessageBytes.slice(32, 64);
|
5009
5205
|
const recoveryParam = (s[0] & 128) >> 7;
|
5010
5206
|
s[0] &= 127;
|
5011
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5207
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
|
5012
5208
|
recoveryParam
|
5013
5209
|
);
|
5014
|
-
const publicKey = sig.recoverPublicKey((0,
|
5015
|
-
return (0,
|
5210
|
+
const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
|
5211
|
+
return (0, import_utils28.hexlify)(publicKey);
|
5016
5212
|
}
|
5017
5213
|
/**
|
5018
5214
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5031,7 +5227,7 @@ var Signer = class {
|
|
5031
5227
|
* @returns random 32-byte hashed
|
5032
5228
|
*/
|
5033
5229
|
static generatePrivateKey(entropy) {
|
5034
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5230
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
|
5035
5231
|
}
|
5036
5232
|
/**
|
5037
5233
|
* Extended publicKey from a compact publicKey
|
@@ -5040,16 +5236,16 @@ var Signer = class {
|
|
5040
5236
|
* @returns extended publicKey
|
5041
5237
|
*/
|
5042
5238
|
static extendPublicKey(publicKey) {
|
5043
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5044
|
-
return (0,
|
5239
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
|
5240
|
+
return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
|
5045
5241
|
}
|
5046
5242
|
};
|
5047
5243
|
|
5048
5244
|
// src/wallet/keystore-wallet.ts
|
5049
5245
|
var import_address6 = require("@fuel-ts/address");
|
5050
|
-
var
|
5246
|
+
var import_crypto2 = require("@fuel-ts/crypto");
|
5051
5247
|
var import_errors17 = require("@fuel-ts/errors");
|
5052
|
-
var
|
5248
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5053
5249
|
var import_uuid = require("uuid");
|
5054
5250
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5055
5251
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5063,22 +5259,22 @@ var removeHexPrefix = (hexString) => {
|
|
5063
5259
|
return hexString;
|
5064
5260
|
};
|
5065
5261
|
async function encryptKeystoreWallet(privateKey, address, password) {
|
5066
|
-
const privateKeyBuffer = (0,
|
5262
|
+
const privateKeyBuffer = (0, import_crypto2.bufferFromString)(removeHexPrefix(privateKey), "hex");
|
5067
5263
|
const ownerAddress = import_address6.Address.fromAddressOrString(address);
|
5068
|
-
const salt = (0,
|
5069
|
-
const key = (0,
|
5070
|
-
password: (0,
|
5264
|
+
const salt = (0, import_crypto2.randomBytes)(DEFAULT_KEY_SIZE);
|
5265
|
+
const key = (0, import_crypto2.scrypt)({
|
5266
|
+
password: (0, import_crypto2.bufferFromString)(password),
|
5071
5267
|
salt,
|
5072
5268
|
dklen: DEFAULT_KEY_SIZE,
|
5073
5269
|
n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
|
5074
5270
|
r: DEFAULT_KDF_PARAMS_R,
|
5075
5271
|
p: DEFAULT_KDF_PARAMS_P
|
5076
5272
|
});
|
5077
|
-
const iv = (0,
|
5078
|
-
const ciphertext = await (0,
|
5273
|
+
const iv = (0, import_crypto2.randomBytes)(DEFAULT_IV_SIZE);
|
5274
|
+
const ciphertext = await (0, import_crypto2.encryptJsonWalletData)(privateKeyBuffer, key, iv);
|
5079
5275
|
const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
|
5080
|
-
const macHashUint8Array = (0,
|
5081
|
-
const mac = (0,
|
5276
|
+
const macHashUint8Array = (0, import_crypto2.keccak256)(data);
|
5277
|
+
const mac = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
|
5082
5278
|
const keystore = {
|
5083
5279
|
id: (0, import_uuid.v4)(),
|
5084
5280
|
version: 3,
|
@@ -5086,15 +5282,15 @@ async function encryptKeystoreWallet(privateKey, address, password) {
|
|
5086
5282
|
crypto: {
|
5087
5283
|
cipher: "aes-128-ctr",
|
5088
5284
|
mac,
|
5089
|
-
cipherparams: { iv: (0,
|
5090
|
-
ciphertext: (0,
|
5285
|
+
cipherparams: { iv: (0, import_crypto2.stringFromBuffer)(iv, "hex") },
|
5286
|
+
ciphertext: (0, import_crypto2.stringFromBuffer)(ciphertext, "hex"),
|
5091
5287
|
kdf: "scrypt",
|
5092
5288
|
kdfparams: {
|
5093
5289
|
dklen: DEFAULT_KEY_SIZE,
|
5094
5290
|
n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
|
5095
5291
|
p: DEFAULT_KDF_PARAMS_P,
|
5096
5292
|
r: DEFAULT_KDF_PARAMS_R,
|
5097
|
-
salt: (0,
|
5293
|
+
salt: (0, import_crypto2.stringFromBuffer)(salt, "hex")
|
5098
5294
|
}
|
5099
5295
|
}
|
5100
5296
|
};
|
@@ -5110,11 +5306,11 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5110
5306
|
kdfparams: { dklen, n, r, p, salt }
|
5111
5307
|
}
|
5112
5308
|
} = keystoreWallet;
|
5113
|
-
const ciphertextBuffer = (0,
|
5114
|
-
const ivBuffer = (0,
|
5115
|
-
const saltBuffer = (0,
|
5116
|
-
const passwordBuffer = (0,
|
5117
|
-
const key = (0,
|
5309
|
+
const ciphertextBuffer = (0, import_crypto2.bufferFromString)(ciphertext, "hex");
|
5310
|
+
const ivBuffer = (0, import_crypto2.bufferFromString)(iv, "hex");
|
5311
|
+
const saltBuffer = (0, import_crypto2.bufferFromString)(salt, "hex");
|
5312
|
+
const passwordBuffer = (0, import_crypto2.bufferFromString)(password);
|
5313
|
+
const key = (0, import_crypto2.scrypt)({
|
5118
5314
|
password: passwordBuffer,
|
5119
5315
|
salt: saltBuffer,
|
5120
5316
|
n,
|
@@ -5123,16 +5319,16 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5123
5319
|
dklen
|
5124
5320
|
});
|
5125
5321
|
const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertextBuffer]);
|
5126
|
-
const macHashUint8Array = (0,
|
5127
|
-
const macHash = (0,
|
5322
|
+
const macHashUint8Array = (0, import_crypto2.keccak256)(data);
|
5323
|
+
const macHash = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
|
5128
5324
|
if (mac !== macHash) {
|
5129
5325
|
throw new import_errors17.FuelError(
|
5130
5326
|
import_errors17.ErrorCode.INVALID_PASSWORD,
|
5131
5327
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
5132
5328
|
);
|
5133
5329
|
}
|
5134
|
-
const buffer = await (0,
|
5135
|
-
const privateKey = (0,
|
5330
|
+
const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
5331
|
+
const privateKey = (0, import_utils29.hexlify)(buffer);
|
5136
5332
|
return privateKey;
|
5137
5333
|
}
|
5138
5334
|
|
@@ -5177,7 +5373,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5177
5373
|
*/
|
5178
5374
|
async signMessage(message) {
|
5179
5375
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
5180
|
-
return (0,
|
5376
|
+
return (0, import_utils30.hexlify)(signedMessage);
|
5181
5377
|
}
|
5182
5378
|
/**
|
5183
5379
|
* Signs a transaction with the wallet's private key.
|
@@ -5190,7 +5386,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5190
5386
|
const chainId = this.provider.getChainId();
|
5191
5387
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5192
5388
|
const signature = await this.signer().sign(hashedTransaction);
|
5193
|
-
return (0,
|
5389
|
+
return (0, import_utils30.hexlify)(signature);
|
5194
5390
|
}
|
5195
5391
|
/**
|
5196
5392
|
* Populates a transaction with the witnesses signature.
|
@@ -5210,7 +5406,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5210
5406
|
* @param transactionRequestLike - The transaction request to send.
|
5211
5407
|
* @returns A promise that resolves to the TransactionResponse object.
|
5212
5408
|
*/
|
5213
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
5409
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
|
5214
5410
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5215
5411
|
if (estimateTxDependencies) {
|
5216
5412
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -5251,16 +5447,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5251
5447
|
// src/hdwallet/hdwallet.ts
|
5252
5448
|
var import_errors20 = require("@fuel-ts/errors");
|
5253
5449
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5254
|
-
var
|
5255
|
-
var
|
5256
|
-
var
|
5450
|
+
var import_math21 = require("@fuel-ts/math");
|
5451
|
+
var import_utils34 = require("@fuel-ts/utils");
|
5452
|
+
var import_ethers4 = require("ethers");
|
5257
5453
|
|
5258
5454
|
// src/mnemonic/mnemonic.ts
|
5259
|
-
var
|
5455
|
+
var import_crypto3 = require("@fuel-ts/crypto");
|
5260
5456
|
var import_errors19 = require("@fuel-ts/errors");
|
5261
5457
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5262
|
-
var
|
5263
|
-
var
|
5458
|
+
var import_utils32 = require("@fuel-ts/utils");
|
5459
|
+
var import_ethers3 = require("ethers");
|
5264
5460
|
|
5265
5461
|
// src/wordlists/words/english.ts
|
5266
5462
|
var english = [
|
@@ -7317,7 +7513,7 @@ var english = [
|
|
7317
7513
|
// src/mnemonic/utils.ts
|
7318
7514
|
var import_errors18 = require("@fuel-ts/errors");
|
7319
7515
|
var import_hasher4 = require("@fuel-ts/hasher");
|
7320
|
-
var
|
7516
|
+
var import_utils31 = require("@fuel-ts/utils");
|
7321
7517
|
function toUtf8Bytes(stri) {
|
7322
7518
|
const str = stri.normalize("NFKD");
|
7323
7519
|
const result = [];
|
@@ -7384,14 +7580,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
7384
7580
|
}
|
7385
7581
|
}
|
7386
7582
|
const checksumBits = entropy.length / 4;
|
7387
|
-
const checksum = (0,
|
7583
|
+
const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
7388
7584
|
indices[indices.length - 1] <<= checksumBits;
|
7389
7585
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7390
7586
|
return indices;
|
7391
7587
|
}
|
7392
7588
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7393
7589
|
const size = Math.ceil(11 * words.length / 8);
|
7394
|
-
const entropy = (0,
|
7590
|
+
const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
|
7395
7591
|
let offset = 0;
|
7396
7592
|
for (let i = 0; i < words.length; i += 1) {
|
7397
7593
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -7411,7 +7607,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7411
7607
|
const entropyBits = 32 * words.length / 3;
|
7412
7608
|
const checksumBits = words.length / 3;
|
7413
7609
|
const checksumMask = getUpperMask(checksumBits);
|
7414
|
-
const checksum = (0,
|
7610
|
+
const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7415
7611
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7416
7612
|
throw new import_errors18.FuelError(
|
7417
7613
|
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
@@ -7486,7 +7682,7 @@ var Mnemonic = class {
|
|
7486
7682
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7487
7683
|
const words = getWords(phrase);
|
7488
7684
|
assertMnemonic(words);
|
7489
|
-
return (0,
|
7685
|
+
return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
7490
7686
|
}
|
7491
7687
|
/**
|
7492
7688
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7494,7 +7690,7 @@ var Mnemonic = class {
|
|
7494
7690
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7495
7691
|
*/
|
7496
7692
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7497
|
-
const entropyBytes = (0,
|
7693
|
+
const entropyBytes = (0, import_utils32.arrayify)(entropy);
|
7498
7694
|
assertWordList(wordlist);
|
7499
7695
|
assertEntropy(entropyBytes);
|
7500
7696
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7508,7 +7704,7 @@ var Mnemonic = class {
|
|
7508
7704
|
assertMnemonic(getWords(phrase));
|
7509
7705
|
const phraseBytes = toUtf8Bytes(getPhrase(phrase));
|
7510
7706
|
const salt = toUtf8Bytes(`mnemonic${passphrase}`);
|
7511
|
-
return (0,
|
7707
|
+
return (0, import_ethers3.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
7512
7708
|
}
|
7513
7709
|
/**
|
7514
7710
|
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
|
@@ -7563,14 +7759,14 @@ var Mnemonic = class {
|
|
7563
7759
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7564
7760
|
*/
|
7565
7761
|
static masterKeysFromSeed(seed) {
|
7566
|
-
const seedArray = (0,
|
7762
|
+
const seedArray = (0, import_utils32.arrayify)(seed);
|
7567
7763
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7568
7764
|
throw new import_errors19.FuelError(
|
7569
7765
|
import_errors19.ErrorCode.INVALID_SEED,
|
7570
7766
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7571
7767
|
);
|
7572
7768
|
}
|
7573
|
-
return (0,
|
7769
|
+
return (0, import_utils32.arrayify)((0, import_ethers3.computeHmac)("sha512", MasterSecret, seedArray));
|
7574
7770
|
}
|
7575
7771
|
/**
|
7576
7772
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7581,22 +7777,22 @@ var Mnemonic = class {
|
|
7581
7777
|
*/
|
7582
7778
|
static seedToExtendedKey(seed, testnet = false) {
|
7583
7779
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7584
|
-
const prefix = (0,
|
7780
|
+
const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
7585
7781
|
const depth = "0x00";
|
7586
7782
|
const fingerprint = "0x00000000";
|
7587
7783
|
const index = "0x00000000";
|
7588
7784
|
const chainCode = masterKey.slice(32);
|
7589
7785
|
const privateKey = masterKey.slice(0, 32);
|
7590
|
-
const extendedKey = (0,
|
7786
|
+
const extendedKey = (0, import_utils32.concat)([
|
7591
7787
|
prefix,
|
7592
7788
|
depth,
|
7593
7789
|
fingerprint,
|
7594
7790
|
index,
|
7595
7791
|
chainCode,
|
7596
|
-
(0,
|
7792
|
+
(0, import_utils32.concat)(["0x00", privateKey])
|
7597
7793
|
]);
|
7598
|
-
const checksum = (0,
|
7599
|
-
return (0,
|
7794
|
+
const checksum = (0, import_ethers3.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
7795
|
+
return (0, import_ethers3.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
|
7600
7796
|
}
|
7601
7797
|
/**
|
7602
7798
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -7611,7 +7807,7 @@ var Mnemonic = class {
|
|
7611
7807
|
* @returns A randomly generated mnemonic
|
7612
7808
|
*/
|
7613
7809
|
static generate(size = 32, extraEntropy = "") {
|
7614
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
7810
|
+
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
|
7615
7811
|
return Mnemonic.entropyToMnemonic(entropy);
|
7616
7812
|
}
|
7617
7813
|
};
|
@@ -7619,12 +7815,12 @@ var mnemonic_default = Mnemonic;
|
|
7619
7815
|
|
7620
7816
|
// src/hdwallet/hdwallet.ts
|
7621
7817
|
var HARDENED_INDEX = 2147483648;
|
7622
|
-
var MainnetPRV2 = (0,
|
7623
|
-
var MainnetPUB = (0,
|
7624
|
-
var TestnetPRV2 = (0,
|
7625
|
-
var TestnetPUB = (0,
|
7818
|
+
var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
|
7819
|
+
var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
|
7820
|
+
var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
|
7821
|
+
var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
|
7626
7822
|
function base58check(data) {
|
7627
|
-
return (0,
|
7823
|
+
return (0, import_ethers4.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers4.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
7628
7824
|
}
|
7629
7825
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
7630
7826
|
if (isPublic) {
|
@@ -7633,11 +7829,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
7633
7829
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
7634
7830
|
}
|
7635
7831
|
function isPublicExtendedKey(extendedKey) {
|
7636
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
7832
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
|
7637
7833
|
}
|
7638
7834
|
function isValidExtendedKey(extendedKey) {
|
7639
7835
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
7640
|
-
(0,
|
7836
|
+
(0, import_utils34.hexlify)(extendedKey.slice(0, 4))
|
7641
7837
|
);
|
7642
7838
|
}
|
7643
7839
|
function parsePath(path2, depth = 0) {
|
@@ -7655,8 +7851,8 @@ function parsePath(path2, depth = 0) {
|
|
7655
7851
|
var HDWallet = class {
|
7656
7852
|
depth = 0;
|
7657
7853
|
index = 0;
|
7658
|
-
fingerprint = (0,
|
7659
|
-
parentFingerprint = (0,
|
7854
|
+
fingerprint = (0, import_utils34.hexlify)("0x00000000");
|
7855
|
+
parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
|
7660
7856
|
privateKey;
|
7661
7857
|
publicKey;
|
7662
7858
|
chainCode;
|
@@ -7668,8 +7864,8 @@ var HDWallet = class {
|
|
7668
7864
|
constructor(config) {
|
7669
7865
|
if (config.privateKey) {
|
7670
7866
|
const signer = new Signer(config.privateKey);
|
7671
|
-
this.publicKey = (0,
|
7672
|
-
this.privateKey = (0,
|
7867
|
+
this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
|
7868
|
+
this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
|
7673
7869
|
} else {
|
7674
7870
|
if (!config.publicKey) {
|
7675
7871
|
throw new import_errors20.FuelError(
|
@@ -7677,10 +7873,10 @@ var HDWallet = class {
|
|
7677
7873
|
"Both public and private Key cannot be missing. At least one should be provided."
|
7678
7874
|
);
|
7679
7875
|
}
|
7680
|
-
this.publicKey = (0,
|
7876
|
+
this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
|
7681
7877
|
}
|
7682
7878
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
7683
|
-
this.fingerprint = (0,
|
7879
|
+
this.fingerprint = (0, import_ethers4.dataSlice)((0, import_ethers4.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
7684
7880
|
this.depth = config.depth || this.depth;
|
7685
7881
|
this.index = config.index || this.index;
|
7686
7882
|
this.chainCode = config.chainCode;
|
@@ -7696,9 +7892,9 @@ var HDWallet = class {
|
|
7696
7892
|
* @returns A new instance of HDWallet on the derived index
|
7697
7893
|
*/
|
7698
7894
|
deriveIndex(index) {
|
7699
|
-
const privateKey = this.privateKey && (0,
|
7700
|
-
const publicKey = (0,
|
7701
|
-
const chainCode = (0,
|
7895
|
+
const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
|
7896
|
+
const publicKey = (0, import_utils34.arrayify)(this.publicKey);
|
7897
|
+
const chainCode = (0, import_utils34.arrayify)(this.chainCode);
|
7702
7898
|
const data = new Uint8Array(37);
|
7703
7899
|
if (index & HARDENED_INDEX) {
|
7704
7900
|
if (!privateKey) {
|
@@ -7709,15 +7905,15 @@ var HDWallet = class {
|
|
7709
7905
|
}
|
7710
7906
|
data.set(privateKey, 1);
|
7711
7907
|
} else {
|
7712
|
-
data.set((0,
|
7908
|
+
data.set((0, import_utils34.arrayify)(this.publicKey));
|
7713
7909
|
}
|
7714
|
-
data.set((0,
|
7715
|
-
const bytes = (0,
|
7910
|
+
data.set((0, import_math21.toBytes)(index, 4), 33);
|
7911
|
+
const bytes = (0, import_utils34.arrayify)((0, import_ethers4.computeHmac)("sha512", chainCode, data));
|
7716
7912
|
const IL = bytes.slice(0, 32);
|
7717
7913
|
const IR = bytes.slice(32);
|
7718
7914
|
if (privateKey) {
|
7719
7915
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7720
|
-
const ki = (0,
|
7916
|
+
const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
7721
7917
|
return new HDWallet({
|
7722
7918
|
privateKey: ki,
|
7723
7919
|
chainCode: IR,
|
@@ -7726,7 +7922,7 @@ var HDWallet = class {
|
|
7726
7922
|
parentFingerprint: this.fingerprint
|
7727
7923
|
});
|
7728
7924
|
}
|
7729
|
-
const signer = new Signer((0,
|
7925
|
+
const signer = new Signer((0, import_utils34.hexlify)(IL));
|
7730
7926
|
const Ki = signer.addPoint(publicKey);
|
7731
7927
|
return new HDWallet({
|
7732
7928
|
publicKey: Ki,
|
@@ -7761,12 +7957,12 @@ var HDWallet = class {
|
|
7761
7957
|
);
|
7762
7958
|
}
|
7763
7959
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
7764
|
-
const depth = (0,
|
7960
|
+
const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
|
7765
7961
|
const parentFingerprint = this.parentFingerprint;
|
7766
|
-
const index = (0,
|
7962
|
+
const index = (0, import_math21.toHex)(this.index, 4);
|
7767
7963
|
const chainCode = this.chainCode;
|
7768
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
7769
|
-
const extendedKey = (0,
|
7964
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
|
7965
|
+
const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
7770
7966
|
return base58check(extendedKey);
|
7771
7967
|
}
|
7772
7968
|
/**
|
@@ -7778,13 +7974,13 @@ var HDWallet = class {
|
|
7778
7974
|
static fromSeed(seed) {
|
7779
7975
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
7780
7976
|
return new HDWallet({
|
7781
|
-
chainCode: (0,
|
7782
|
-
privateKey: (0,
|
7977
|
+
chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
|
7978
|
+
privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
|
7783
7979
|
});
|
7784
7980
|
}
|
7785
7981
|
static fromExtendedKey(extendedKey) {
|
7786
|
-
const decoded = (0,
|
7787
|
-
const bytes = (0,
|
7982
|
+
const decoded = (0, import_ethers4.toBeHex)((0, import_ethers4.decodeBase58)(extendedKey));
|
7983
|
+
const bytes = (0, import_utils34.arrayify)(decoded);
|
7788
7984
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
7789
7985
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
7790
7986
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -7793,9 +7989,9 @@ var HDWallet = class {
|
|
7793
7989
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
7794
7990
|
}
|
7795
7991
|
const depth = bytes[4];
|
7796
|
-
const parentFingerprint = (0,
|
7797
|
-
const index = parseInt((0,
|
7798
|
-
const chainCode = (0,
|
7992
|
+
const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
|
7993
|
+
const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
7994
|
+
const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
|
7799
7995
|
const key = bytes.slice(45, 78);
|
7800
7996
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
7801
7997
|
throw new import_errors20.FuelError(
|
@@ -7982,20 +8178,21 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
|
|
7982
8178
|
__publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
7983
8179
|
|
7984
8180
|
// src/test-utils/seedTestWallet.ts
|
7985
|
-
var
|
8181
|
+
var import_crypto4 = require("@fuel-ts/crypto");
|
7986
8182
|
var seedTestWallet = async (wallet, quantities) => {
|
7987
8183
|
const genesisWallet = new WalletUnlocked(
|
7988
|
-
process.env.GENESIS_SECRET || (0,
|
8184
|
+
process.env.GENESIS_SECRET || (0, import_crypto4.randomBytes)(32),
|
7989
8185
|
wallet.provider
|
7990
8186
|
);
|
7991
|
-
const
|
7992
|
-
|
7993
|
-
|
7994
|
-
|
7995
|
-
gasPrice: minGasPrice
|
8187
|
+
const request = new ScriptTransactionRequest();
|
8188
|
+
quantities.forEach((quantity) => {
|
8189
|
+
const { amount, assetId } = coinQuantityfy(quantity);
|
8190
|
+
request.addCoinOutput(wallet.address, amount, assetId);
|
7996
8191
|
});
|
7997
|
-
|
7998
|
-
|
8192
|
+
const txCost = await genesisWallet.provider.getTransactionCost(request);
|
8193
|
+
request.gasLimit = txCost.gasUsed;
|
8194
|
+
request.maxFee = txCost.maxFee;
|
8195
|
+
await genesisWallet.fund(request, txCost);
|
7999
8196
|
await genesisWallet.sendTransaction(request, { awaitExecution: true });
|
8000
8197
|
};
|
8001
8198
|
|
@@ -8010,11 +8207,11 @@ var generateTestWallet = async (provider, quantities) => {
|
|
8010
8207
|
|
8011
8208
|
// src/test-utils/launchNode.ts
|
8012
8209
|
var import_configs13 = require("@fuel-ts/address/configs");
|
8013
|
-
var
|
8014
|
-
var import_utils36 = require("@fuel-ts/utils");
|
8210
|
+
var import_utils35 = require("@fuel-ts/utils");
|
8015
8211
|
var import_cli_utils = require("@fuel-ts/utils/cli-utils");
|
8016
8212
|
var import_child_process = require("child_process");
|
8017
|
-
var
|
8213
|
+
var import_crypto5 = require("crypto");
|
8214
|
+
var import_ethers5 = require("ethers");
|
8018
8215
|
var import_fs = require("fs");
|
8019
8216
|
var import_os = __toESM(require("os"));
|
8020
8217
|
var import_path = __toESM(require("path"));
|
@@ -8063,13 +8260,13 @@ var launchNode = async ({
|
|
8063
8260
|
// eslint-disable-next-line no-async-promise-executor
|
8064
8261
|
new Promise(async (resolve, reject) => {
|
8065
8262
|
const remainingArgs = extractRemainingArgs(args, [
|
8066
|
-
"--
|
8263
|
+
"--snapshot",
|
8067
8264
|
"--consensus-key",
|
8068
8265
|
"--db-type",
|
8069
8266
|
"--poa-instant"
|
8070
8267
|
]);
|
8071
|
-
const chainConfigPath = getFlagValueFromArgs(args, "--
|
8072
|
-
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") ||
|
8268
|
+
const chainConfigPath = getFlagValueFromArgs(args, "--snapshot");
|
8269
|
+
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils35.defaultConsensusKey;
|
8073
8270
|
const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
|
8074
8271
|
const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
|
8075
8272
|
const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
|
@@ -8086,37 +8283,55 @@ var launchNode = async ({
|
|
8086
8283
|
})).toString();
|
8087
8284
|
let chainConfigPathToUse;
|
8088
8285
|
const prefix = basePath || import_os.default.tmpdir();
|
8089
|
-
const suffix = basePath ? "" : (0,
|
8090
|
-
const tempDirPath = import_path.default.join(prefix, ".fuels", suffix);
|
8286
|
+
const suffix = basePath ? "" : (0, import_crypto5.randomUUID)();
|
8287
|
+
const tempDirPath = import_path.default.join(prefix, ".fuels", suffix, "chainConfigs");
|
8091
8288
|
if (chainConfigPath) {
|
8092
8289
|
chainConfigPathToUse = chainConfigPath;
|
8093
8290
|
} else {
|
8094
8291
|
if (!(0, import_fs.existsSync)(tempDirPath)) {
|
8095
8292
|
(0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
|
8096
8293
|
}
|
8097
|
-
|
8098
|
-
|
8294
|
+
let { stateConfigJson } = import_utils35.defaultChainConfigs;
|
8295
|
+
const { chainConfigJson, metadataJson } = import_utils35.defaultChainConfigs;
|
8296
|
+
stateConfigJson = {
|
8297
|
+
...stateConfigJson,
|
8298
|
+
coins: [
|
8299
|
+
...stateConfigJson.coins.map((coin) => ({
|
8300
|
+
...coin,
|
8301
|
+
amount: "18446744073709551615"
|
8302
|
+
}))
|
8303
|
+
],
|
8304
|
+
messages: stateConfigJson.messages.map((message) => ({
|
8305
|
+
...message,
|
8306
|
+
amount: "18446744073709551615"
|
8307
|
+
}))
|
8308
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8309
|
+
};
|
8099
8310
|
if (!process.env.GENESIS_SECRET) {
|
8100
8311
|
const pk = Signer.generatePrivateKey();
|
8101
8312
|
const signer = new Signer(pk);
|
8102
|
-
process.env.GENESIS_SECRET = (0,
|
8103
|
-
|
8104
|
-
|
8105
|
-
|
8106
|
-
|
8107
|
-
|
8108
|
-
|
8109
|
-
|
8110
|
-
|
8111
|
-
|
8112
|
-
|
8113
|
-
}
|
8114
|
-
]
|
8115
|
-
}
|
8116
|
-
};
|
8313
|
+
process.env.GENESIS_SECRET = (0, import_utils35.hexlify)(pk);
|
8314
|
+
stateConfigJson.coins.push({
|
8315
|
+
tx_id: (0, import_utils35.hexlify)((0, import_ethers5.randomBytes)(34)),
|
8316
|
+
owner: signer.address.toHexString(),
|
8317
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8318
|
+
amount: "18446744073709551615",
|
8319
|
+
asset_id: import_configs13.BaseAssetId,
|
8320
|
+
output_index: 0,
|
8321
|
+
tx_pointer_block_height: 0,
|
8322
|
+
tx_pointer_tx_idx: 0
|
8323
|
+
});
|
8117
8324
|
}
|
8118
|
-
|
8119
|
-
|
8325
|
+
let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
|
8326
|
+
const regexMakeNumber = /("amount":)"(\d+)"/gm;
|
8327
|
+
fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
|
8328
|
+
const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
|
8329
|
+
const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
|
8330
|
+
const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
|
8331
|
+
(0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
|
8332
|
+
(0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
|
8333
|
+
(0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
|
8334
|
+
chainConfigPathToUse = tempDirPath;
|
8120
8335
|
}
|
8121
8336
|
const child = (0, import_child_process.spawn)(
|
8122
8337
|
command,
|
@@ -8125,10 +8340,10 @@ var launchNode = async ({
|
|
8125
8340
|
["--ip", ipToUse],
|
8126
8341
|
["--port", portToUse],
|
8127
8342
|
useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
|
8128
|
-
["--min-gas-price", "
|
8343
|
+
["--min-gas-price", "1"],
|
8129
8344
|
poaInstant ? ["--poa-instant", "true"] : [],
|
8130
8345
|
["--consensus-key", consensusKey],
|
8131
|
-
["--
|
8346
|
+
["--snapshot", chainConfigPathToUse],
|
8132
8347
|
"--vm-backtrace",
|
8133
8348
|
"--utxo-validation",
|
8134
8349
|
"--debug",
|
@@ -8187,7 +8402,7 @@ var launchNodeAndGetWallets = async ({
|
|
8187
8402
|
walletCount = 10
|
8188
8403
|
} = {}) => {
|
8189
8404
|
const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
|
8190
|
-
const provider = await Provider.create(`http://${ip}:${port}/graphql`);
|
8405
|
+
const provider = await Provider.create(`http://${ip}:${port}/v1/graphql`);
|
8191
8406
|
const wallets = await generateWallets(walletCount, provider);
|
8192
8407
|
const cleanup = () => {
|
8193
8408
|
closeNode();
|