@fuel-ts/account 0.0.0-rc-2021-20240423205052 → 0.0.0-rc-2045-20240424064755
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/README.md +1 -1
- package/dist/account.d.ts +4 -5
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +589 -861
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +517 -793
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +398 -673
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +2 -10
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +327 -821
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +2 -4
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +1 -7
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +27 -37
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/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 +29 -8
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +0 -3
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +2 -8
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +1090 -1579
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +515 -774
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +407 -666
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +16 -16
package/dist/test-utils.mjs
CHANGED
@@ -27,9 +27,8 @@ import { Address as Address3 } from "@fuel-ts/address";
|
|
27
27
|
import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
|
28
28
|
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
29
29
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
30
|
-
import { bn as
|
30
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
31
31
|
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
32
|
-
import { clone as clone4 } from "ramda";
|
33
32
|
|
34
33
|
// src/providers/coin-quantity.ts
|
35
34
|
import { BaseAssetId } from "@fuel-ts/address/configs";
|
@@ -38,24 +37,24 @@ import { hexlify } from "@fuel-ts/utils";
|
|
38
37
|
var coinQuantityfy = (coinQuantityLike) => {
|
39
38
|
let assetId;
|
40
39
|
let amount;
|
41
|
-
let
|
40
|
+
let max2;
|
42
41
|
if (Array.isArray(coinQuantityLike)) {
|
43
42
|
amount = coinQuantityLike[0];
|
44
43
|
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
45
|
-
|
44
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
46
45
|
} else {
|
47
46
|
amount = coinQuantityLike.amount;
|
48
47
|
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
49
|
-
|
48
|
+
max2 = coinQuantityLike.max ?? void 0;
|
50
49
|
}
|
51
50
|
const bnAmount = bn(amount);
|
52
51
|
return {
|
53
52
|
assetId: hexlify(assetId),
|
54
53
|
amount: bnAmount.lt(1) ? bn(1) : bnAmount,
|
55
|
-
max:
|
54
|
+
max: max2 ? bn(max2) : void 0
|
56
55
|
};
|
57
56
|
};
|
58
|
-
var
|
57
|
+
var addAmountToAsset = (params) => {
|
59
58
|
const { amount, assetId } = params;
|
60
59
|
const coinQuantities = [...params.coinQuantities];
|
61
60
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -70,9 +69,9 @@ var addAmountToCoinQuantities = (params) => {
|
|
70
69
|
// src/providers/provider.ts
|
71
70
|
import { Address as Address2 } from "@fuel-ts/address";
|
72
71
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
73
|
-
import { BN, bn as
|
72
|
+
import { BN, bn as bn15, max } from "@fuel-ts/math";
|
74
73
|
import {
|
75
|
-
InputType as
|
74
|
+
InputType as InputType6,
|
76
75
|
TransactionType as TransactionType8,
|
77
76
|
InputMessageCoder,
|
78
77
|
TransactionCoder as TransactionCoder5
|
@@ -86,40 +85,16 @@ import { clone as clone3 } from "ramda";
|
|
86
85
|
|
87
86
|
// src/providers/__generated__/operations.ts
|
88
87
|
import gql from "graphql-tag";
|
89
|
-
var TransactionStatusSubscriptionFragmentFragmentDoc = gql`
|
90
|
-
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
91
|
-
type: __typename
|
92
|
-
... on SubmittedStatus {
|
93
|
-
time
|
94
|
-
}
|
95
|
-
... on SuccessStatus {
|
96
|
-
block {
|
97
|
-
id
|
98
|
-
}
|
99
|
-
time
|
100
|
-
programState {
|
101
|
-
returnType
|
102
|
-
data
|
103
|
-
}
|
104
|
-
}
|
105
|
-
... on FailureStatus {
|
106
|
-
block {
|
107
|
-
id
|
108
|
-
}
|
109
|
-
time
|
110
|
-
reason
|
111
|
-
}
|
112
|
-
... on SqueezedOutStatus {
|
113
|
-
reason
|
114
|
-
}
|
115
|
-
}
|
116
|
-
`;
|
117
88
|
var ReceiptFragmentFragmentDoc = gql`
|
118
89
|
fragment receiptFragment on Receipt {
|
119
|
-
|
90
|
+
contract {
|
91
|
+
id
|
92
|
+
}
|
120
93
|
pc
|
121
94
|
is
|
122
|
-
to
|
95
|
+
to {
|
96
|
+
id
|
97
|
+
}
|
123
98
|
toAddress
|
124
99
|
amount
|
125
100
|
assetId
|
@@ -157,16 +132,10 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
157
132
|
id
|
158
133
|
}
|
159
134
|
time
|
160
|
-
receipts {
|
161
|
-
...receiptFragment
|
162
|
-
}
|
163
135
|
programState {
|
164
136
|
returnType
|
165
137
|
data
|
166
138
|
}
|
167
|
-
receipts {
|
168
|
-
...receiptFragment
|
169
|
-
}
|
170
139
|
}
|
171
140
|
... on FailureStatus {
|
172
141
|
block {
|
@@ -174,24 +143,26 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
174
143
|
}
|
175
144
|
time
|
176
145
|
reason
|
177
|
-
receipts {
|
178
|
-
...receiptFragment
|
179
|
-
}
|
180
146
|
}
|
181
147
|
... on SqueezedOutStatus {
|
182
148
|
reason
|
183
149
|
}
|
184
150
|
}
|
185
|
-
|
151
|
+
`;
|
186
152
|
var TransactionFragmentFragmentDoc = gql`
|
187
153
|
fragment transactionFragment on Transaction {
|
188
154
|
id
|
189
155
|
rawPayload
|
156
|
+
gasPrice
|
157
|
+
receipts {
|
158
|
+
...receiptFragment
|
159
|
+
}
|
190
160
|
status {
|
191
161
|
...transactionStatusFragment
|
192
162
|
}
|
193
163
|
}
|
194
|
-
${
|
164
|
+
${ReceiptFragmentFragmentDoc}
|
165
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
195
166
|
var InputEstimatePredicatesFragmentFragmentDoc = gql`
|
196
167
|
fragment inputEstimatePredicatesFragment on Input {
|
197
168
|
... on InputCoin {
|
@@ -209,46 +180,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
|
|
209
180
|
}
|
210
181
|
}
|
211
182
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
212
|
-
var DryRunFailureStatusFragmentFragmentDoc = gql`
|
213
|
-
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
214
|
-
reason
|
215
|
-
programState {
|
216
|
-
returnType
|
217
|
-
data
|
218
|
-
}
|
219
|
-
}
|
220
|
-
`;
|
221
|
-
var DryRunSuccessStatusFragmentFragmentDoc = gql`
|
222
|
-
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
223
|
-
programState {
|
224
|
-
returnType
|
225
|
-
data
|
226
|
-
}
|
227
|
-
}
|
228
|
-
`;
|
229
|
-
var DryRunTransactionStatusFragmentFragmentDoc = gql`
|
230
|
-
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
231
|
-
... on DryRunFailureStatus {
|
232
|
-
...dryRunFailureStatusFragment
|
233
|
-
}
|
234
|
-
... on DryRunSuccessStatus {
|
235
|
-
...dryRunSuccessStatusFragment
|
236
|
-
}
|
237
|
-
}
|
238
|
-
${DryRunFailureStatusFragmentFragmentDoc}
|
239
|
-
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
240
|
-
var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
|
241
|
-
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
242
|
-
id
|
243
|
-
status {
|
244
|
-
...dryRunTransactionStatusFragment
|
245
|
-
}
|
246
|
-
receipts {
|
247
|
-
...receiptFragment
|
248
|
-
}
|
249
|
-
}
|
250
|
-
${DryRunTransactionStatusFragmentFragmentDoc}
|
251
|
-
${ReceiptFragmentFragmentDoc}`;
|
252
183
|
var CoinFragmentFragmentDoc = gql`
|
253
184
|
fragment coinFragment on Coin {
|
254
185
|
__typename
|
@@ -256,6 +187,7 @@ var CoinFragmentFragmentDoc = gql`
|
|
256
187
|
owner
|
257
188
|
amount
|
258
189
|
assetId
|
190
|
+
maturity
|
259
191
|
blockCreated
|
260
192
|
txCreatedIdx
|
261
193
|
}
|
@@ -294,32 +226,26 @@ var MessageProofFragmentFragmentDoc = gql`
|
|
294
226
|
messageBlockHeader {
|
295
227
|
id
|
296
228
|
daHeight
|
297
|
-
consensusParametersVersion
|
298
|
-
stateTransitionBytecodeVersion
|
299
229
|
transactionsCount
|
300
|
-
messageReceiptCount
|
301
230
|
transactionsRoot
|
302
|
-
messageOutboxRoot
|
303
|
-
eventInboxRoot
|
304
231
|
height
|
305
232
|
prevRoot
|
306
233
|
time
|
307
234
|
applicationHash
|
235
|
+
messageReceiptRoot
|
236
|
+
messageReceiptCount
|
308
237
|
}
|
309
238
|
commitBlockHeader {
|
310
239
|
id
|
311
240
|
daHeight
|
312
|
-
consensusParametersVersion
|
313
|
-
stateTransitionBytecodeVersion
|
314
241
|
transactionsCount
|
315
|
-
messageReceiptCount
|
316
242
|
transactionsRoot
|
317
|
-
messageOutboxRoot
|
318
|
-
eventInboxRoot
|
319
243
|
height
|
320
244
|
prevRoot
|
321
245
|
time
|
322
246
|
applicationHash
|
247
|
+
messageReceiptRoot
|
248
|
+
messageReceiptCount
|
323
249
|
}
|
324
250
|
sender
|
325
251
|
recipient
|
@@ -338,8 +264,8 @@ var BalanceFragmentFragmentDoc = gql`
|
|
338
264
|
var BlockFragmentFragmentDoc = gql`
|
339
265
|
fragment blockFragment on Block {
|
340
266
|
id
|
341
|
-
height
|
342
267
|
header {
|
268
|
+
height
|
343
269
|
time
|
344
270
|
}
|
345
271
|
transactions {
|
@@ -397,11 +323,6 @@ var DependentCostFragmentFragmentDoc = gql`
|
|
397
323
|
`;
|
398
324
|
var GasCostsFragmentFragmentDoc = gql`
|
399
325
|
fragment GasCostsFragment on GasCosts {
|
400
|
-
version {
|
401
|
-
... on Version {
|
402
|
-
value
|
403
|
-
}
|
404
|
-
}
|
405
326
|
add
|
406
327
|
addi
|
407
328
|
aloc
|
@@ -414,6 +335,7 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
414
335
|
cb
|
415
336
|
cfei
|
416
337
|
cfsi
|
338
|
+
croo
|
417
339
|
div
|
418
340
|
divi
|
419
341
|
ecr1
|
@@ -496,9 +418,6 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
496
418
|
ccp {
|
497
419
|
...DependentCostFragment
|
498
420
|
}
|
499
|
-
croo {
|
500
|
-
...DependentCostFragment
|
501
|
-
}
|
502
421
|
csiz {
|
503
422
|
...DependentCostFragment
|
504
423
|
}
|
@@ -558,11 +477,6 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
558
477
|
${DependentCostFragmentFragmentDoc}`;
|
559
478
|
var ConsensusParametersFragmentFragmentDoc = gql`
|
560
479
|
fragment consensusParametersFragment on ConsensusParameters {
|
561
|
-
version {
|
562
|
-
... on Version {
|
563
|
-
value
|
564
|
-
}
|
565
|
-
}
|
566
480
|
txParams {
|
567
481
|
...TxParametersFragment
|
568
482
|
}
|
@@ -622,9 +536,18 @@ var NodeInfoFragmentFragmentDoc = gql`
|
|
622
536
|
fragment nodeInfoFragment on NodeInfo {
|
623
537
|
utxoValidation
|
624
538
|
vmBacktrace
|
539
|
+
minGasPrice
|
625
540
|
maxTx
|
626
541
|
maxDepth
|
627
542
|
nodeVersion
|
543
|
+
peers {
|
544
|
+
id
|
545
|
+
addresses
|
546
|
+
clientVersion
|
547
|
+
blockHeight
|
548
|
+
lastHeartbeatMs
|
549
|
+
appScore
|
550
|
+
}
|
628
551
|
}
|
629
552
|
`;
|
630
553
|
var GetVersionDocument = gql`
|
@@ -659,9 +582,13 @@ var GetTransactionWithReceiptsDocument = gql`
|
|
659
582
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
660
583
|
transaction(id: $transactionId) {
|
661
584
|
...transactionFragment
|
585
|
+
receipts {
|
586
|
+
...receiptFragment
|
587
|
+
}
|
662
588
|
}
|
663
589
|
}
|
664
|
-
${TransactionFragmentFragmentDoc}
|
590
|
+
${TransactionFragmentFragmentDoc}
|
591
|
+
${ReceiptFragmentFragmentDoc}`;
|
665
592
|
var GetTransactionsDocument = gql`
|
666
593
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
667
594
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -789,20 +716,6 @@ var GetBalanceDocument = gql`
|
|
789
716
|
}
|
790
717
|
}
|
791
718
|
${BalanceFragmentFragmentDoc}`;
|
792
|
-
var GetLatestGasPriceDocument = gql`
|
793
|
-
query getLatestGasPrice {
|
794
|
-
latestGasPrice {
|
795
|
-
gasPrice
|
796
|
-
}
|
797
|
-
}
|
798
|
-
`;
|
799
|
-
var EstimateGasPriceDocument = gql`
|
800
|
-
query estimateGasPrice($blockHorizon: U32!) {
|
801
|
-
estimateGasPrice(blockHorizon: $blockHorizon) {
|
802
|
-
gasPrice
|
803
|
-
}
|
804
|
-
}
|
805
|
-
`;
|
806
719
|
var GetBalancesDocument = gql`
|
807
720
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
808
721
|
balances(
|
@@ -857,12 +770,12 @@ var GetMessageStatusDocument = gql`
|
|
857
770
|
}
|
858
771
|
`;
|
859
772
|
var DryRunDocument = gql`
|
860
|
-
mutation dryRun($
|
861
|
-
dryRun(
|
862
|
-
...
|
773
|
+
mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
|
774
|
+
dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
|
775
|
+
...receiptFragment
|
863
776
|
}
|
864
777
|
}
|
865
|
-
${
|
778
|
+
${ReceiptFragmentFragmentDoc}`;
|
866
779
|
var SubmitDocument = gql`
|
867
780
|
mutation submit($encodedTransaction: HexString!) {
|
868
781
|
submit(tx: $encodedTransaction) {
|
@@ -881,17 +794,17 @@ var ProduceBlocksDocument = gql`
|
|
881
794
|
var SubmitAndAwaitDocument = gql`
|
882
795
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
883
796
|
submitAndAwait(tx: $encodedTransaction) {
|
884
|
-
...
|
797
|
+
...transactionStatusFragment
|
885
798
|
}
|
886
799
|
}
|
887
|
-
${
|
800
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
888
801
|
var StatusChangeDocument = gql`
|
889
802
|
subscription statusChange($transactionId: TransactionId!) {
|
890
803
|
statusChange(id: $transactionId) {
|
891
|
-
...
|
804
|
+
...transactionStatusFragment
|
892
805
|
}
|
893
806
|
}
|
894
|
-
${
|
807
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
895
808
|
function getSdk(requester) {
|
896
809
|
return {
|
897
810
|
getVersion(variables, options) {
|
@@ -945,12 +858,6 @@ function getSdk(requester) {
|
|
945
858
|
getBalance(variables, options) {
|
946
859
|
return requester(GetBalanceDocument, variables, options);
|
947
860
|
},
|
948
|
-
getLatestGasPrice(variables, options) {
|
949
|
-
return requester(GetLatestGasPriceDocument, variables, options);
|
950
|
-
},
|
951
|
-
estimateGasPrice(variables, options) {
|
952
|
-
return requester(EstimateGasPriceDocument, variables, options);
|
953
|
-
},
|
954
861
|
getBalances(variables, options) {
|
955
862
|
return requester(GetBalancesDocument, variables, options);
|
956
863
|
},
|
@@ -1144,9 +1051,10 @@ var inputify = (value) => {
|
|
1144
1051
|
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
1145
1052
|
},
|
1146
1053
|
witnessIndex: value.witnessIndex,
|
1054
|
+
maturity: value.maturity ?? 0,
|
1147
1055
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1148
|
-
predicateLength:
|
1149
|
-
predicateDataLength:
|
1056
|
+
predicateLength: predicate.length,
|
1057
|
+
predicateDataLength: predicateData.length,
|
1150
1058
|
predicate: hexlify3(predicate),
|
1151
1059
|
predicateData: hexlify3(predicateData)
|
1152
1060
|
};
|
@@ -1177,8 +1085,8 @@ var inputify = (value) => {
|
|
1177
1085
|
nonce: hexlify3(value.nonce),
|
1178
1086
|
witnessIndex: value.witnessIndex,
|
1179
1087
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1180
|
-
predicateLength:
|
1181
|
-
predicateDataLength:
|
1088
|
+
predicateLength: predicate.length,
|
1089
|
+
predicateDataLength: predicateData.length,
|
1182
1090
|
predicate: hexlify3(predicate),
|
1183
1091
|
predicateData: hexlify3(predicateData),
|
1184
1092
|
data: hexlify3(data),
|
@@ -1305,8 +1213,8 @@ function assembleReceiptByType(receipt) {
|
|
1305
1213
|
case "CALL" /* Call */: {
|
1306
1214
|
const callReceipt = {
|
1307
1215
|
type: ReceiptType.Call,
|
1308
|
-
from: hexOrZero(receipt.id
|
1309
|
-
to: hexOrZero(receipt?.to),
|
1216
|
+
from: hexOrZero(receipt.contract?.id),
|
1217
|
+
to: hexOrZero(receipt?.to?.id),
|
1310
1218
|
amount: bn4(receipt.amount),
|
1311
1219
|
assetId: hexOrZero(receipt.assetId),
|
1312
1220
|
gas: bn4(receipt.gas),
|
@@ -1320,7 +1228,7 @@ function assembleReceiptByType(receipt) {
|
|
1320
1228
|
case "RETURN" /* Return */: {
|
1321
1229
|
const returnReceipt = {
|
1322
1230
|
type: ReceiptType.Return,
|
1323
|
-
id: hexOrZero(receipt.id
|
1231
|
+
id: hexOrZero(receipt.contract?.id),
|
1324
1232
|
val: bn4(receipt.val),
|
1325
1233
|
pc: bn4(receipt.pc),
|
1326
1234
|
is: bn4(receipt.is)
|
@@ -1330,7 +1238,7 @@ function assembleReceiptByType(receipt) {
|
|
1330
1238
|
case "RETURN_DATA" /* ReturnData */: {
|
1331
1239
|
const returnDataReceipt = {
|
1332
1240
|
type: ReceiptType.ReturnData,
|
1333
|
-
id: hexOrZero(receipt.id
|
1241
|
+
id: hexOrZero(receipt.contract?.id),
|
1334
1242
|
ptr: bn4(receipt.ptr),
|
1335
1243
|
len: bn4(receipt.len),
|
1336
1244
|
digest: hexOrZero(receipt.digest),
|
@@ -1342,7 +1250,7 @@ function assembleReceiptByType(receipt) {
|
|
1342
1250
|
case "PANIC" /* Panic */: {
|
1343
1251
|
const panicReceipt = {
|
1344
1252
|
type: ReceiptType.Panic,
|
1345
|
-
id: hexOrZero(receipt.id),
|
1253
|
+
id: hexOrZero(receipt.contract?.id),
|
1346
1254
|
reason: bn4(receipt.reason),
|
1347
1255
|
pc: bn4(receipt.pc),
|
1348
1256
|
is: bn4(receipt.is),
|
@@ -1353,7 +1261,7 @@ function assembleReceiptByType(receipt) {
|
|
1353
1261
|
case "REVERT" /* Revert */: {
|
1354
1262
|
const revertReceipt = {
|
1355
1263
|
type: ReceiptType.Revert,
|
1356
|
-
id: hexOrZero(receipt.id
|
1264
|
+
id: hexOrZero(receipt.contract?.id),
|
1357
1265
|
val: bn4(receipt.ra),
|
1358
1266
|
pc: bn4(receipt.pc),
|
1359
1267
|
is: bn4(receipt.is)
|
@@ -1363,7 +1271,7 @@ function assembleReceiptByType(receipt) {
|
|
1363
1271
|
case "LOG" /* Log */: {
|
1364
1272
|
const logReceipt = {
|
1365
1273
|
type: ReceiptType.Log,
|
1366
|
-
id: hexOrZero(receipt.id
|
1274
|
+
id: hexOrZero(receipt.contract?.id),
|
1367
1275
|
val0: bn4(receipt.ra),
|
1368
1276
|
val1: bn4(receipt.rb),
|
1369
1277
|
val2: bn4(receipt.rc),
|
@@ -1376,7 +1284,7 @@ function assembleReceiptByType(receipt) {
|
|
1376
1284
|
case "LOG_DATA" /* LogData */: {
|
1377
1285
|
const logDataReceipt = {
|
1378
1286
|
type: ReceiptType.LogData,
|
1379
|
-
id: hexOrZero(receipt.id
|
1287
|
+
id: hexOrZero(receipt.contract?.id),
|
1380
1288
|
val0: bn4(receipt.ra),
|
1381
1289
|
val1: bn4(receipt.rb),
|
1382
1290
|
ptr: bn4(receipt.ptr),
|
@@ -1390,8 +1298,8 @@ function assembleReceiptByType(receipt) {
|
|
1390
1298
|
case "TRANSFER" /* Transfer */: {
|
1391
1299
|
const transferReceipt = {
|
1392
1300
|
type: ReceiptType.Transfer,
|
1393
|
-
from: hexOrZero(receipt.id
|
1394
|
-
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1301
|
+
from: hexOrZero(receipt.contract?.id),
|
1302
|
+
to: hexOrZero(receipt.toAddress || receipt?.to?.id),
|
1395
1303
|
amount: bn4(receipt.amount),
|
1396
1304
|
assetId: hexOrZero(receipt.assetId),
|
1397
1305
|
pc: bn4(receipt.pc),
|
@@ -1402,8 +1310,8 @@ function assembleReceiptByType(receipt) {
|
|
1402
1310
|
case "TRANSFER_OUT" /* TransferOut */: {
|
1403
1311
|
const transferOutReceipt = {
|
1404
1312
|
type: ReceiptType.TransferOut,
|
1405
|
-
from: hexOrZero(receipt.id
|
1406
|
-
to: hexOrZero(receipt.toAddress || receipt.to),
|
1313
|
+
from: hexOrZero(receipt.contract?.id),
|
1314
|
+
to: hexOrZero(receipt.toAddress || receipt.to?.id),
|
1407
1315
|
amount: bn4(receipt.amount),
|
1408
1316
|
assetId: hexOrZero(receipt.assetId),
|
1409
1317
|
pc: bn4(receipt.pc),
|
@@ -1446,7 +1354,7 @@ function assembleReceiptByType(receipt) {
|
|
1446
1354
|
return receiptMessageOut;
|
1447
1355
|
}
|
1448
1356
|
case "MINT" /* Mint */: {
|
1449
|
-
const contractId = hexOrZero(receipt.id
|
1357
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
1450
1358
|
const subId = hexOrZero(receipt.subId);
|
1451
1359
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
1452
1360
|
const mintReceipt = {
|
@@ -1461,7 +1369,7 @@ function assembleReceiptByType(receipt) {
|
|
1461
1369
|
return mintReceipt;
|
1462
1370
|
}
|
1463
1371
|
case "BURN" /* Burn */: {
|
1464
|
-
const contractId = hexOrZero(receipt.id
|
1372
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
1465
1373
|
const subId = hexOrZero(receipt.subId);
|
1466
1374
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
1467
1375
|
const burnReceipt = {
|
@@ -1487,6 +1395,7 @@ import { ErrorCode as ErrorCode6, FuelError as FuelError6 } from "@fuel-ts/error
|
|
1487
1395
|
import { bn as bn5 } from "@fuel-ts/math";
|
1488
1396
|
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
1489
1397
|
import { arrayify as arrayify3 } from "@fuel-ts/utils";
|
1398
|
+
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1490
1399
|
var getGasUsedFromReceipts = (receipts) => {
|
1491
1400
|
const scriptResult = receipts.filter(
|
1492
1401
|
(receipt) => receipt.type === ReceiptType2.ScriptResult
|
@@ -1507,28 +1416,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
1507
1416
|
}
|
1508
1417
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
1509
1418
|
const witnessCache = [];
|
1510
|
-
const
|
1511
|
-
const isCoinOrMessage = "owner" in input || "sender" in input;
|
1512
|
-
if (isCoinOrMessage) {
|
1513
|
-
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1514
|
-
return true;
|
1515
|
-
}
|
1516
|
-
if (!witnessCache.includes(input.witnessIndex)) {
|
1517
|
-
witnessCache.push(input.witnessIndex);
|
1518
|
-
return true;
|
1519
|
-
}
|
1520
|
-
}
|
1521
|
-
return false;
|
1522
|
-
});
|
1523
|
-
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
1524
|
-
const totalGas = chargeableInputs.reduce((total, input) => {
|
1419
|
+
const totalGas = inputs.reduce((total, input) => {
|
1525
1420
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1526
1421
|
return total.add(
|
1527
|
-
|
1422
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
|
1528
1423
|
);
|
1529
1424
|
}
|
1530
|
-
|
1531
|
-
|
1425
|
+
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
1426
|
+
witnessCache.push(input.witnessIndex);
|
1427
|
+
return total.add(gasCosts.ecr1);
|
1428
|
+
}
|
1429
|
+
return total;
|
1430
|
+
}, bn5());
|
1532
1431
|
return totalGas;
|
1533
1432
|
}
|
1534
1433
|
function getMinGas(params) {
|
@@ -1540,20 +1439,12 @@ function getMinGas(params) {
|
|
1540
1439
|
return minGas;
|
1541
1440
|
}
|
1542
1441
|
function getMaxGas(params) {
|
1543
|
-
const {
|
1544
|
-
gasPerByte,
|
1545
|
-
witnessesLength,
|
1546
|
-
witnessLimit,
|
1547
|
-
minGas,
|
1548
|
-
gasLimit = bn5(0),
|
1549
|
-
maxGasPerTx
|
1550
|
-
} = params;
|
1442
|
+
const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
|
1551
1443
|
let remainingAllowedWitnessGas = bn5(0);
|
1552
1444
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
1553
1445
|
remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
1554
1446
|
}
|
1555
|
-
|
1556
|
-
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
1447
|
+
return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
1557
1448
|
}
|
1558
1449
|
function calculateMetadataGasForTxCreate({
|
1559
1450
|
gasCosts,
|
@@ -1575,10 +1466,6 @@ function calculateMetadataGasForTxScript({
|
|
1575
1466
|
}) {
|
1576
1467
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1577
1468
|
}
|
1578
|
-
var calculateGasFee = (params) => {
|
1579
|
-
const { gas, gasPrice, priceFactor, tip } = params;
|
1580
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1581
|
-
};
|
1582
1469
|
|
1583
1470
|
// src/providers/utils/json.ts
|
1584
1471
|
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
@@ -1723,7 +1610,7 @@ var witnessify = (value) => {
|
|
1723
1610
|
// src/providers/transaction-request/transaction-request.ts
|
1724
1611
|
var BaseTransactionRequest = class {
|
1725
1612
|
/** Gas price for transaction */
|
1726
|
-
|
1613
|
+
gasPrice;
|
1727
1614
|
/** Block until which tx cannot be included */
|
1728
1615
|
maturity;
|
1729
1616
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -1742,7 +1629,7 @@ var BaseTransactionRequest = class {
|
|
1742
1629
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
1743
1630
|
*/
|
1744
1631
|
constructor({
|
1745
|
-
|
1632
|
+
gasPrice,
|
1746
1633
|
maturity,
|
1747
1634
|
maxFee,
|
1748
1635
|
witnessLimit,
|
@@ -1750,7 +1637,7 @@ var BaseTransactionRequest = class {
|
|
1750
1637
|
outputs,
|
1751
1638
|
witnesses
|
1752
1639
|
} = {}) {
|
1753
|
-
this.
|
1640
|
+
this.gasPrice = bn7(gasPrice);
|
1754
1641
|
this.maturity = maturity ?? 0;
|
1755
1642
|
this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
|
1756
1643
|
this.maxFee = maxFee ? bn7(maxFee) : void 0;
|
@@ -1761,9 +1648,9 @@ var BaseTransactionRequest = class {
|
|
1761
1648
|
static getPolicyMeta(req) {
|
1762
1649
|
let policyTypes = 0;
|
1763
1650
|
const policies = [];
|
1764
|
-
if (req.
|
1765
|
-
policyTypes += PolicyType.
|
1766
|
-
policies.push({ data: req.
|
1651
|
+
if (req.gasPrice) {
|
1652
|
+
policyTypes += PolicyType.GasPrice;
|
1653
|
+
policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
|
1767
1654
|
}
|
1768
1655
|
if (req.witnessLimit) {
|
1769
1656
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -1947,11 +1834,13 @@ var BaseTransactionRequest = class {
|
|
1947
1834
|
* assetId, if one it was not added yet.
|
1948
1835
|
*
|
1949
1836
|
* @param coin - Coin resource.
|
1837
|
+
* @param predicate - Predicate bytes.
|
1838
|
+
* @param predicateData - Predicate data bytes.
|
1950
1839
|
*/
|
1951
|
-
addCoinInput(coin) {
|
1840
|
+
addCoinInput(coin, predicate) {
|
1952
1841
|
const { assetId, owner, amount } = coin;
|
1953
1842
|
let witnessIndex;
|
1954
|
-
if (
|
1843
|
+
if (predicate) {
|
1955
1844
|
witnessIndex = 0;
|
1956
1845
|
} else {
|
1957
1846
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -1966,7 +1855,8 @@ var BaseTransactionRequest = class {
|
|
1966
1855
|
amount,
|
1967
1856
|
assetId,
|
1968
1857
|
txPointer: "0x00000000000000000000000000000000",
|
1969
|
-
witnessIndex
|
1858
|
+
witnessIndex,
|
1859
|
+
predicate: predicate?.bytes
|
1970
1860
|
};
|
1971
1861
|
this.pushInput(input);
|
1972
1862
|
this.addChangeOutput(owner, assetId);
|
@@ -1976,12 +1866,14 @@ var BaseTransactionRequest = class {
|
|
1976
1866
|
* baseAssetId, if one it was not added yet.
|
1977
1867
|
*
|
1978
1868
|
* @param message - Message resource.
|
1869
|
+
* @param predicate - Predicate bytes.
|
1870
|
+
* @param predicateData - Predicate data bytes.
|
1979
1871
|
*/
|
1980
|
-
addMessageInput(message) {
|
1872
|
+
addMessageInput(message, predicate) {
|
1981
1873
|
const { recipient, sender, amount } = message;
|
1982
1874
|
const assetId = BaseAssetId2;
|
1983
1875
|
let witnessIndex;
|
1984
|
-
if (
|
1876
|
+
if (predicate) {
|
1985
1877
|
witnessIndex = 0;
|
1986
1878
|
} else {
|
1987
1879
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -1995,7 +1887,8 @@ var BaseTransactionRequest = class {
|
|
1995
1887
|
sender: sender.toB256(),
|
1996
1888
|
recipient: recipient.toB256(),
|
1997
1889
|
amount,
|
1998
|
-
witnessIndex
|
1890
|
+
witnessIndex,
|
1891
|
+
predicate: predicate?.bytes
|
1999
1892
|
};
|
2000
1893
|
this.pushInput(input);
|
2001
1894
|
this.addChangeOutput(recipient, assetId);
|
@@ -2026,6 +1919,32 @@ var BaseTransactionRequest = class {
|
|
2026
1919
|
resources.forEach((resource) => this.addResource(resource));
|
2027
1920
|
return this;
|
2028
1921
|
}
|
1922
|
+
/**
|
1923
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
1924
|
+
* outputs from the related assetIds.
|
1925
|
+
*
|
1926
|
+
* @param resources - The resources to add.
|
1927
|
+
* @returns This transaction.
|
1928
|
+
*/
|
1929
|
+
addPredicateResource(resource, predicate) {
|
1930
|
+
if (isCoin(resource)) {
|
1931
|
+
this.addCoinInput(resource, predicate);
|
1932
|
+
} else {
|
1933
|
+
this.addMessageInput(resource, predicate);
|
1934
|
+
}
|
1935
|
+
return this;
|
1936
|
+
}
|
1937
|
+
/**
|
1938
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
1939
|
+
* from the related assetIds.
|
1940
|
+
*
|
1941
|
+
* @param resources - The resources to add.
|
1942
|
+
* @returns This transaction.
|
1943
|
+
*/
|
1944
|
+
addPredicateResources(resources, predicate) {
|
1945
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
1946
|
+
return this;
|
1947
|
+
}
|
2029
1948
|
/**
|
2030
1949
|
* Adds a coin output to the transaction.
|
2031
1950
|
*
|
@@ -2105,7 +2024,7 @@ var BaseTransactionRequest = class {
|
|
2105
2024
|
}
|
2106
2025
|
calculateMaxGas(chainInfo, minGas) {
|
2107
2026
|
const { consensusParameters } = chainInfo;
|
2108
|
-
const { gasPerByte
|
2027
|
+
const { gasPerByte } = consensusParameters;
|
2109
2028
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2110
2029
|
(acc, wit) => acc + wit.dataLength,
|
2111
2030
|
0
|
@@ -2114,8 +2033,7 @@ var BaseTransactionRequest = class {
|
|
2114
2033
|
gasPerByte,
|
2115
2034
|
minGas,
|
2116
2035
|
witnessesLength,
|
2117
|
-
witnessLimit: this.witnessLimit
|
2118
|
-
maxGasPerTx
|
2036
|
+
witnessLimit: this.witnessLimit
|
2119
2037
|
});
|
2120
2038
|
}
|
2121
2039
|
/**
|
@@ -2133,20 +2051,17 @@ var BaseTransactionRequest = class {
|
|
2133
2051
|
});
|
2134
2052
|
const updateAssetInput = (assetId, quantity) => {
|
2135
2053
|
const assetInput = findAssetInput(assetId);
|
2136
|
-
let usedQuantity = quantity;
|
2137
|
-
if (assetId === BaseAssetId2) {
|
2138
|
-
usedQuantity = bn7("1000000000000000000");
|
2139
|
-
}
|
2140
2054
|
if (assetInput && "assetId" in assetInput) {
|
2141
2055
|
assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
|
2142
|
-
assetInput.amount =
|
2056
|
+
assetInput.amount = quantity;
|
2143
2057
|
} else {
|
2144
2058
|
this.addResources([
|
2145
2059
|
{
|
2146
2060
|
id: hexlify7(randomBytes(UTXO_ID_LEN2)),
|
2147
|
-
amount:
|
2061
|
+
amount: quantity,
|
2148
2062
|
assetId,
|
2149
2063
|
owner: resourcesOwner || Address.fromRandom(),
|
2064
|
+
maturity: 0,
|
2150
2065
|
blockCreated: bn7(1),
|
2151
2066
|
txCreatedIdx: bn7(1)
|
2152
2067
|
}
|
@@ -2178,7 +2093,7 @@ var BaseTransactionRequest = class {
|
|
2178
2093
|
toJSON() {
|
2179
2094
|
return normalizeJSON(this);
|
2180
2095
|
}
|
2181
|
-
|
2096
|
+
updatePredicateInputs(inputs) {
|
2182
2097
|
this.inputs.forEach((i) => {
|
2183
2098
|
let correspondingInput;
|
2184
2099
|
switch (i.type) {
|
@@ -2200,15 +2115,6 @@ var BaseTransactionRequest = class {
|
|
2200
2115
|
}
|
2201
2116
|
});
|
2202
2117
|
}
|
2203
|
-
shiftPredicateData() {
|
2204
|
-
this.inputs.forEach((input) => {
|
2205
|
-
if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
|
2206
|
-
input.predicateData = input.paddPredicateData(
|
2207
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2208
|
-
);
|
2209
|
-
}
|
2210
|
-
});
|
2211
|
-
}
|
2212
2118
|
};
|
2213
2119
|
|
2214
2120
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2355,8 +2261,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2355
2261
|
return {
|
2356
2262
|
type: TransactionType3.Create,
|
2357
2263
|
...baseTransaction,
|
2264
|
+
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2358
2265
|
bytecodeWitnessIndex,
|
2359
|
-
storageSlotsCount:
|
2266
|
+
storageSlotsCount: storageSlots.length,
|
2360
2267
|
salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
|
2361
2268
|
storageSlots
|
2362
2269
|
};
|
@@ -2479,8 +2386,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2479
2386
|
type: TransactionType4.Script,
|
2480
2387
|
scriptGasLimit: this.gasLimit,
|
2481
2388
|
...super.getBaseTransaction(),
|
2482
|
-
scriptLength:
|
2483
|
-
scriptDataLength:
|
2389
|
+
scriptLength: script.length,
|
2390
|
+
scriptDataLength: scriptData.length,
|
2484
2391
|
receiptsRoot: ZeroBytes327,
|
2485
2392
|
script: hexlify10(script),
|
2486
2393
|
scriptData: hexlify10(scriptData)
|
@@ -2544,7 +2451,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2544
2451
|
}
|
2545
2452
|
calculateMaxGas(chainInfo, minGas) {
|
2546
2453
|
const { consensusParameters } = chainInfo;
|
2547
|
-
const { gasPerByte
|
2454
|
+
const { gasPerByte } = consensusParameters;
|
2548
2455
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2549
2456
|
(acc, wit) => acc + wit.dataLength,
|
2550
2457
|
0
|
@@ -2554,8 +2461,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2554
2461
|
minGas,
|
2555
2462
|
witnessesLength,
|
2556
2463
|
witnessLimit: this.witnessLimit,
|
2557
|
-
gasLimit: this.gasLimit
|
2558
|
-
maxGasPerTx
|
2464
|
+
gasLimit: this.gasLimit
|
2559
2465
|
});
|
2560
2466
|
}
|
2561
2467
|
/**
|
@@ -2612,7 +2518,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2612
2518
|
|
2613
2519
|
// src/providers/transaction-request/utils.ts
|
2614
2520
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2615
|
-
import { TransactionType as TransactionType5
|
2521
|
+
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2616
2522
|
var transactionRequestify = (obj) => {
|
2617
2523
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2618
2524
|
return obj;
|
@@ -2630,31 +2536,14 @@ var transactionRequestify = (obj) => {
|
|
2630
2536
|
}
|
2631
2537
|
}
|
2632
2538
|
};
|
2633
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2634
|
-
(acc, input) => {
|
2635
|
-
if (input.type === InputType5.Coin && input.owner === owner) {
|
2636
|
-
acc.utxos.push(input.id);
|
2637
|
-
}
|
2638
|
-
if (input.type === InputType5.Message && input.recipient === owner) {
|
2639
|
-
acc.messages.push(input.nonce);
|
2640
|
-
}
|
2641
|
-
return acc;
|
2642
|
-
},
|
2643
|
-
{
|
2644
|
-
utxos: [],
|
2645
|
-
messages: []
|
2646
|
-
}
|
2647
|
-
);
|
2648
2539
|
|
2649
2540
|
// src/providers/transaction-response/transaction-response.ts
|
2650
2541
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2651
|
-
import { bn as
|
2542
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
2652
2543
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2653
2544
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2654
2545
|
|
2655
2546
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2656
|
-
import { bn as bn14 } from "@fuel-ts/math";
|
2657
|
-
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2658
2547
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2659
2548
|
|
2660
2549
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
@@ -2663,10 +2552,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
|
|
2663
2552
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2664
2553
|
var calculateTransactionFee = (params) => {
|
2665
2554
|
const {
|
2666
|
-
|
2555
|
+
gasUsed,
|
2667
2556
|
rawPayload,
|
2668
|
-
|
2669
|
-
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2557
|
+
consensusParameters: { gasCosts, feeParams }
|
2670
2558
|
} = params;
|
2671
2559
|
const gasPerByte = bn11(feeParams.gasPerByte);
|
2672
2560
|
const gasPriceFactor = bn11(feeParams.gasPriceFactor);
|
@@ -2676,7 +2564,8 @@ var calculateTransactionFee = (params) => {
|
|
2676
2564
|
return {
|
2677
2565
|
fee: bn11(0),
|
2678
2566
|
minFee: bn11(0),
|
2679
|
-
maxFee: bn11(0)
|
2567
|
+
maxFee: bn11(0),
|
2568
|
+
feeFromGasUsed: bn11(0)
|
2680
2569
|
};
|
2681
2570
|
}
|
2682
2571
|
const { type, witnesses, inputs, policies } = transaction;
|
@@ -2708,6 +2597,7 @@ var calculateTransactionFee = (params) => {
|
|
2708
2597
|
metadataGas,
|
2709
2598
|
txBytesSize: transactionBytes.length
|
2710
2599
|
});
|
2600
|
+
const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
|
2711
2601
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
|
2712
2602
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2713
2603
|
const maxGas = getMaxGas({
|
@@ -2715,25 +2605,17 @@ var calculateTransactionFee = (params) => {
|
|
2715
2605
|
minGas,
|
2716
2606
|
witnessesLength,
|
2717
2607
|
gasLimit,
|
2718
|
-
witnessLimit
|
2719
|
-
maxGasPerTx
|
2720
|
-
});
|
2721
|
-
const minFee = calculateGasFee({
|
2722
|
-
gasPrice,
|
2723
|
-
gas: minGas,
|
2724
|
-
priceFactor: gasPriceFactor,
|
2725
|
-
tip
|
2726
|
-
});
|
2727
|
-
const maxFee = calculateGasFee({
|
2728
|
-
gasPrice,
|
2729
|
-
gas: maxGas,
|
2730
|
-
priceFactor: gasPriceFactor,
|
2731
|
-
tip
|
2608
|
+
witnessLimit
|
2732
2609
|
});
|
2610
|
+
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
2611
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
2612
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
2613
|
+
const fee = minFee.add(feeFromGasUsed);
|
2733
2614
|
return {
|
2615
|
+
fee,
|
2734
2616
|
minFee,
|
2735
2617
|
maxFee,
|
2736
|
-
|
2618
|
+
feeFromGasUsed
|
2737
2619
|
};
|
2738
2620
|
};
|
2739
2621
|
|
@@ -2789,7 +2671,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2789
2671
|
|
2790
2672
|
// src/providers/transaction-summary/input.ts
|
2791
2673
|
import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2792
|
-
import { InputType as
|
2674
|
+
import { InputType as InputType5 } from "@fuel-ts/transactions";
|
2793
2675
|
function getInputsByTypes(inputs, types) {
|
2794
2676
|
return inputs.filter((i) => types.includes(i.type));
|
2795
2677
|
}
|
@@ -2797,16 +2679,16 @@ function getInputsByType(inputs, type) {
|
|
2797
2679
|
return inputs.filter((i) => i.type === type);
|
2798
2680
|
}
|
2799
2681
|
function getInputsCoin(inputs) {
|
2800
|
-
return getInputsByType(inputs,
|
2682
|
+
return getInputsByType(inputs, InputType5.Coin);
|
2801
2683
|
}
|
2802
2684
|
function getInputsMessage(inputs) {
|
2803
|
-
return getInputsByType(inputs,
|
2685
|
+
return getInputsByType(inputs, InputType5.Message);
|
2804
2686
|
}
|
2805
2687
|
function getInputsCoinAndMessage(inputs) {
|
2806
|
-
return getInputsByTypes(inputs, [
|
2688
|
+
return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
|
2807
2689
|
}
|
2808
2690
|
function getInputsContract(inputs) {
|
2809
|
-
return getInputsByType(inputs,
|
2691
|
+
return getInputsByType(inputs, InputType5.Contract);
|
2810
2692
|
}
|
2811
2693
|
function getInputFromAssetId(inputs, assetId) {
|
2812
2694
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2825,7 +2707,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2825
2707
|
if (!contractInput) {
|
2826
2708
|
return void 0;
|
2827
2709
|
}
|
2828
|
-
if (contractInput.type !==
|
2710
|
+
if (contractInput.type !== InputType5.Contract) {
|
2829
2711
|
throw new FuelError9(
|
2830
2712
|
ErrorCode9.INVALID_TRANSACTION_INPUT,
|
2831
2713
|
`Contract input should be of type 'contract'.`
|
@@ -2834,10 +2716,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2834
2716
|
return contractInput;
|
2835
2717
|
}
|
2836
2718
|
function getInputAccountAddress(input) {
|
2837
|
-
if (input.type ===
|
2719
|
+
if (input.type === InputType5.Coin) {
|
2838
2720
|
return input.owner.toString();
|
2839
2721
|
}
|
2840
|
-
if (input.type ===
|
2722
|
+
if (input.type === InputType5.Message) {
|
2841
2723
|
return input.recipient.toString();
|
2842
2724
|
}
|
2843
2725
|
return "";
|
@@ -3300,9 +3182,7 @@ function assembleTransactionSummary(params) {
|
|
3300
3182
|
gqlTransactionStatus,
|
3301
3183
|
abiMap = {},
|
3302
3184
|
maxInputs,
|
3303
|
-
gasCosts
|
3304
|
-
maxGasPerTx,
|
3305
|
-
gasPrice
|
3185
|
+
gasCosts
|
3306
3186
|
} = params;
|
3307
3187
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3308
3188
|
const rawPayload = hexlify11(transactionBytes);
|
@@ -3316,14 +3196,11 @@ function assembleTransactionSummary(params) {
|
|
3316
3196
|
maxInputs
|
3317
3197
|
});
|
3318
3198
|
const typeName = getTransactionTypeName(transaction.type);
|
3319
|
-
const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3320
3199
|
const { fee } = calculateTransactionFee({
|
3321
|
-
|
3200
|
+
gasUsed,
|
3322
3201
|
rawPayload,
|
3323
|
-
tip,
|
3324
3202
|
consensusParameters: {
|
3325
3203
|
gasCosts,
|
3326
|
-
maxGasPerTx,
|
3327
3204
|
feeParams: {
|
3328
3205
|
gasPerByte,
|
3329
3206
|
gasPriceFactor
|
@@ -3383,7 +3260,7 @@ var TransactionResponse = class {
|
|
3383
3260
|
/** Current provider */
|
3384
3261
|
provider;
|
3385
3262
|
/** Gas used on the transaction */
|
3386
|
-
gasUsed =
|
3263
|
+
gasUsed = bn14(0);
|
3387
3264
|
/** The graphql Transaction with receipts object. */
|
3388
3265
|
gqlTransaction;
|
3389
3266
|
abis;
|
@@ -3461,13 +3338,8 @@ var TransactionResponse = class {
|
|
3461
3338
|
const decodedTransaction = this.decodeTransaction(
|
3462
3339
|
transaction
|
3463
3340
|
);
|
3464
|
-
|
3465
|
-
|
3466
|
-
txReceipts = transaction.status.receipts;
|
3467
|
-
}
|
3468
|
-
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3469
|
-
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3470
|
-
const gasPrice = await this.provider.getLatestGasPrice();
|
3341
|
+
const receipts = transaction.receipts?.map(processGqlReceipt) || [];
|
3342
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
|
3471
3343
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3472
3344
|
const transactionSummary = assembleTransactionSummary({
|
3473
3345
|
id: this.id,
|
@@ -3479,9 +3351,7 @@ var TransactionResponse = class {
|
|
3479
3351
|
gasPriceFactor,
|
3480
3352
|
abiMap: contractsAbiMap,
|
3481
3353
|
maxInputs,
|
3482
|
-
gasCosts
|
3483
|
-
maxGasPerTx,
|
3484
|
-
gasPrice
|
3354
|
+
gasCosts
|
3485
3355
|
});
|
3486
3356
|
return transactionSummary;
|
3487
3357
|
}
|
@@ -3608,29 +3478,29 @@ var processGqlChain = (chain) => {
|
|
3608
3478
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3609
3479
|
return {
|
3610
3480
|
name,
|
3611
|
-
baseChainHeight:
|
3481
|
+
baseChainHeight: bn15(daHeight),
|
3612
3482
|
consensusParameters: {
|
3613
|
-
contractMaxSize:
|
3614
|
-
maxInputs:
|
3615
|
-
maxOutputs:
|
3616
|
-
maxWitnesses:
|
3617
|
-
maxGasPerTx:
|
3618
|
-
maxScriptLength:
|
3619
|
-
maxScriptDataLength:
|
3620
|
-
maxStorageSlots:
|
3621
|
-
maxPredicateLength:
|
3622
|
-
maxPredicateDataLength:
|
3623
|
-
maxGasPerPredicate:
|
3624
|
-
gasPriceFactor:
|
3625
|
-
gasPerByte:
|
3626
|
-
maxMessageDataLength:
|
3627
|
-
chainId:
|
3483
|
+
contractMaxSize: bn15(contractParams.contractMaxSize),
|
3484
|
+
maxInputs: bn15(txParams.maxInputs),
|
3485
|
+
maxOutputs: bn15(txParams.maxOutputs),
|
3486
|
+
maxWitnesses: bn15(txParams.maxWitnesses),
|
3487
|
+
maxGasPerTx: bn15(txParams.maxGasPerTx),
|
3488
|
+
maxScriptLength: bn15(scriptParams.maxScriptLength),
|
3489
|
+
maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
|
3490
|
+
maxStorageSlots: bn15(contractParams.maxStorageSlots),
|
3491
|
+
maxPredicateLength: bn15(predicateParams.maxPredicateLength),
|
3492
|
+
maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
|
3493
|
+
maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
|
3494
|
+
gasPriceFactor: bn15(feeParams.gasPriceFactor),
|
3495
|
+
gasPerByte: bn15(feeParams.gasPerByte),
|
3496
|
+
maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
|
3497
|
+
chainId: bn15(consensusParameters.chainId),
|
3628
3498
|
gasCosts
|
3629
3499
|
},
|
3630
3500
|
gasCosts,
|
3631
3501
|
latestBlock: {
|
3632
3502
|
id: latestBlock.id,
|
3633
|
-
height:
|
3503
|
+
height: bn15(latestBlock.header.height),
|
3634
3504
|
time: latestBlock.header.time,
|
3635
3505
|
transactions: latestBlock.transactions.map((i) => ({
|
3636
3506
|
id: i.id
|
@@ -3724,8 +3594,10 @@ var _Provider = class {
|
|
3724
3594
|
* Returns some helpful parameters related to gas fees.
|
3725
3595
|
*/
|
3726
3596
|
getGasConfig() {
|
3597
|
+
const { minGasPrice } = this.getNode();
|
3727
3598
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3728
3599
|
return {
|
3600
|
+
minGasPrice,
|
3729
3601
|
maxGasPerTx,
|
3730
3602
|
maxGasPerPredicate,
|
3731
3603
|
gasPriceFactor,
|
@@ -3823,7 +3695,7 @@ var _Provider = class {
|
|
3823
3695
|
*/
|
3824
3696
|
async getBlockNumber() {
|
3825
3697
|
const { chain } = await this.operations.getChain();
|
3826
|
-
return
|
3698
|
+
return bn15(chain.latestBlock.header.height, 10);
|
3827
3699
|
}
|
3828
3700
|
/**
|
3829
3701
|
* Returns the chain information.
|
@@ -3833,11 +3705,13 @@ var _Provider = class {
|
|
3833
3705
|
async fetchNode() {
|
3834
3706
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3835
3707
|
const processedNodeInfo = {
|
3836
|
-
maxDepth:
|
3837
|
-
maxTx:
|
3708
|
+
maxDepth: bn15(nodeInfo.maxDepth),
|
3709
|
+
maxTx: bn15(nodeInfo.maxTx),
|
3710
|
+
minGasPrice: bn15(nodeInfo.minGasPrice),
|
3838
3711
|
nodeVersion: nodeInfo.nodeVersion,
|
3839
3712
|
utxoValidation: nodeInfo.utxoValidation,
|
3840
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
3713
|
+
vmBacktrace: nodeInfo.vmBacktrace,
|
3714
|
+
peers: nodeInfo.peers
|
3841
3715
|
};
|
3842
3716
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
3843
3717
|
return processedNodeInfo;
|
@@ -3923,13 +3797,14 @@ var _Provider = class {
|
|
3923
3797
|
return this.estimateTxDependencies(transactionRequest);
|
3924
3798
|
}
|
3925
3799
|
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
3926
|
-
const { dryRun:
|
3927
|
-
|
3800
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3801
|
+
encodedTransaction,
|
3928
3802
|
utxoValidation: utxoValidation || false
|
3929
3803
|
});
|
3930
|
-
const
|
3931
|
-
|
3932
|
-
|
3804
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
3805
|
+
return {
|
3806
|
+
receipts
|
3807
|
+
};
|
3933
3808
|
}
|
3934
3809
|
/**
|
3935
3810
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -3955,7 +3830,7 @@ var _Provider = class {
|
|
3955
3830
|
} = response;
|
3956
3831
|
if (inputs) {
|
3957
3832
|
inputs.forEach((input, index) => {
|
3958
|
-
if ("predicateGasUsed" in input &&
|
3833
|
+
if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
|
3959
3834
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3960
3835
|
}
|
3961
3836
|
});
|
@@ -3968,6 +3843,9 @@ var _Provider = class {
|
|
3968
3843
|
* If there are missing variable outputs,
|
3969
3844
|
* `addVariableOutputs` is called on the transaction.
|
3970
3845
|
*
|
3846
|
+
* @privateRemarks
|
3847
|
+
* TODO: Investigate support for missing contract IDs
|
3848
|
+
* TODO: Add support for missing output messages
|
3971
3849
|
*
|
3972
3850
|
* @param transactionRequest - The transaction request object.
|
3973
3851
|
* @returns A promise.
|
@@ -3980,19 +3858,16 @@ var _Provider = class {
|
|
3980
3858
|
missingContractIds: []
|
3981
3859
|
};
|
3982
3860
|
}
|
3861
|
+
await this.estimatePredicates(transactionRequest);
|
3983
3862
|
let receipts = [];
|
3984
3863
|
const missingContractIds = [];
|
3985
3864
|
let outputVariables = 0;
|
3986
|
-
let dryrunStatus;
|
3987
3865
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3988
|
-
const {
|
3989
|
-
|
3990
|
-
} = await this.operations.dryRun({
|
3991
|
-
encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
|
3866
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3867
|
+
encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
|
3992
3868
|
utxoValidation: false
|
3993
3869
|
});
|
3994
|
-
receipts =
|
3995
|
-
dryrunStatus = status;
|
3870
|
+
receipts = gqlReceipts.map(processGqlReceipt);
|
3996
3871
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
3997
3872
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
3998
3873
|
if (hasMissingOutputs) {
|
@@ -4002,10 +3877,6 @@ var _Provider = class {
|
|
4002
3877
|
transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
|
4003
3878
|
missingContractIds.push(contractId);
|
4004
3879
|
});
|
4005
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
4006
|
-
transactionRequest
|
4007
|
-
});
|
4008
|
-
transactionRequest.maxFee = maxFee;
|
4009
3880
|
} else {
|
4010
3881
|
break;
|
4011
3882
|
}
|
@@ -4013,139 +3884,37 @@ var _Provider = class {
|
|
4013
3884
|
return {
|
4014
3885
|
receipts,
|
4015
3886
|
outputVariables,
|
4016
|
-
missingContractIds
|
4017
|
-
dryrunStatus
|
3887
|
+
missingContractIds
|
4018
3888
|
};
|
4019
3889
|
}
|
4020
|
-
/**
|
4021
|
-
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
4022
|
-
*
|
4023
|
-
* Transactions are dry run in batches. After each dry run, transactions requiring
|
4024
|
-
* further modifications are identified. The method iteratively updates these transactions
|
4025
|
-
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
4026
|
-
*
|
4027
|
-
* @param transactionRequests - Array of transaction request objects.
|
4028
|
-
* @returns A promise that resolves to an array of results for each transaction.
|
4029
|
-
*/
|
4030
|
-
async estimateMultipleTxDependencies(transactionRequests) {
|
4031
|
-
const results = transactionRequests.map(() => ({
|
4032
|
-
receipts: [],
|
4033
|
-
outputVariables: 0,
|
4034
|
-
missingContractIds: [],
|
4035
|
-
dryrunStatus: void 0
|
4036
|
-
}));
|
4037
|
-
const allRequests = clone3(transactionRequests);
|
4038
|
-
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4039
|
-
allRequests.forEach((req, index) => {
|
4040
|
-
if (req.type === TransactionType8.Script) {
|
4041
|
-
serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
|
4042
|
-
}
|
4043
|
-
});
|
4044
|
-
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
4045
|
-
let attempt = 0;
|
4046
|
-
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
4047
|
-
const encodedTransactions = transactionsToProcess.map(
|
4048
|
-
(index) => serializedTransactionsMap.get(index)
|
4049
|
-
);
|
4050
|
-
const dryRunResults = await this.operations.dryRun({
|
4051
|
-
encodedTransactions,
|
4052
|
-
utxoValidation: false
|
4053
|
-
});
|
4054
|
-
const nextRoundTransactions = [];
|
4055
|
-
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
4056
|
-
const currentResultIndex = transactionsToProcess[i];
|
4057
|
-
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4058
|
-
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
4059
|
-
results[currentResultIndex].dryrunStatus = status;
|
4060
|
-
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4061
|
-
results[currentResultIndex].receipts
|
4062
|
-
);
|
4063
|
-
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4064
|
-
const requestToProcess = allRequests[currentResultIndex];
|
4065
|
-
if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
|
4066
|
-
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
4067
|
-
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
4068
|
-
missingOutputContractIds.forEach(({ contractId }) => {
|
4069
|
-
requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
|
4070
|
-
results[currentResultIndex].missingContractIds.push(contractId);
|
4071
|
-
});
|
4072
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
4073
|
-
transactionRequest: requestToProcess
|
4074
|
-
});
|
4075
|
-
requestToProcess.maxFee = maxFee;
|
4076
|
-
serializedTransactionsMap.set(
|
4077
|
-
currentResultIndex,
|
4078
|
-
hexlify12(requestToProcess.toTransactionBytes())
|
4079
|
-
);
|
4080
|
-
nextRoundTransactions.push(currentResultIndex);
|
4081
|
-
allRequests[currentResultIndex] = requestToProcess;
|
4082
|
-
}
|
4083
|
-
}
|
4084
|
-
transactionsToProcess = nextRoundTransactions;
|
4085
|
-
attempt += 1;
|
4086
|
-
}
|
4087
|
-
return results;
|
4088
|
-
}
|
4089
|
-
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
4090
|
-
if (estimateTxDependencies) {
|
4091
|
-
return this.estimateMultipleTxDependencies(transactionRequests);
|
4092
|
-
}
|
4093
|
-
const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
|
4094
|
-
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4095
|
-
encodedTransactions,
|
4096
|
-
utxoValidation: utxoValidation || false
|
4097
|
-
});
|
4098
|
-
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4099
|
-
const receipts = rawReceipts.map(processGqlReceipt);
|
4100
|
-
return { receipts, dryrunStatus: status };
|
4101
|
-
});
|
4102
|
-
return results;
|
4103
|
-
}
|
4104
3890
|
/**
|
4105
3891
|
* Estimates the transaction gas and fee based on the provided transaction request.
|
4106
3892
|
* @param transactionRequest - The transaction request object.
|
4107
3893
|
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
4108
3894
|
*/
|
4109
|
-
|
3895
|
+
estimateTxGasAndFee(params) {
|
4110
3896
|
const { transactionRequest } = params;
|
4111
|
-
|
3897
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
4112
3898
|
const chainInfo = this.getChain();
|
4113
|
-
const
|
3899
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
3900
|
+
transactionRequest.gasPrice = gasPrice;
|
4114
3901
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
4115
|
-
|
4116
|
-
gasPrice = await this.estimateGasPrice(10);
|
4117
|
-
}
|
4118
|
-
const minFee = calculateGasFee({
|
4119
|
-
gasPrice: bn16(gasPrice),
|
4120
|
-
gas: minGas,
|
4121
|
-
priceFactor: gasPriceFactor,
|
4122
|
-
tip: transactionRequest.tip
|
4123
|
-
}).add(1);
|
4124
|
-
let gasLimit = bn16(0);
|
3902
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4125
3903
|
if (transactionRequest.type === TransactionType8.Script) {
|
4126
|
-
gasLimit = transactionRequest.gasLimit;
|
4127
3904
|
if (transactionRequest.gasLimit.eq(0)) {
|
4128
3905
|
transactionRequest.gasLimit = minGas;
|
4129
3906
|
transactionRequest.gasLimit = maxGasPerTx.sub(
|
4130
3907
|
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
4131
3908
|
);
|
4132
|
-
gasLimit = transactionRequest.gasLimit;
|
4133
3909
|
}
|
4134
3910
|
}
|
4135
3911
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4136
|
-
const maxFee =
|
4137
|
-
gasPrice: bn16(gasPrice),
|
4138
|
-
gas: maxGas,
|
4139
|
-
priceFactor: gasPriceFactor,
|
4140
|
-
tip: transactionRequest.tip
|
4141
|
-
}).add(1);
|
3912
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4142
3913
|
return {
|
4143
3914
|
minGas,
|
4144
3915
|
minFee,
|
4145
3916
|
maxGas,
|
4146
|
-
maxFee
|
4147
|
-
gasPrice,
|
4148
|
-
gasLimit
|
3917
|
+
maxFee
|
4149
3918
|
};
|
4150
3919
|
}
|
4151
3920
|
/**
|
@@ -4163,17 +3932,15 @@ var _Provider = class {
|
|
4163
3932
|
if (estimateTxDependencies) {
|
4164
3933
|
return this.estimateTxDependencies(transactionRequest);
|
4165
3934
|
}
|
4166
|
-
const
|
4167
|
-
const { dryRun:
|
4168
|
-
|
3935
|
+
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
3936
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3937
|
+
encodedTransaction,
|
4169
3938
|
utxoValidation: true
|
4170
3939
|
});
|
4171
|
-
const
|
4172
|
-
|
4173
|
-
|
4174
|
-
|
4175
|
-
});
|
4176
|
-
return { receipts: callResult[0].receipts };
|
3940
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
3941
|
+
return {
|
3942
|
+
receipts
|
3943
|
+
};
|
4177
3944
|
}
|
4178
3945
|
/**
|
4179
3946
|
* Returns a transaction cost to enable user
|
@@ -4190,79 +3957,77 @@ var _Provider = class {
|
|
4190
3957
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
4191
3958
|
* @returns A promise that resolves to the transaction cost object.
|
4192
3959
|
*/
|
4193
|
-
async getTransactionCost(transactionRequestLike,
|
3960
|
+
async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
|
3961
|
+
estimateTxDependencies = true,
|
3962
|
+
estimatePredicates = true,
|
3963
|
+
resourcesOwner,
|
3964
|
+
signatureCallback
|
3965
|
+
} = {}) {
|
4194
3966
|
const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
|
3967
|
+
const { minGasPrice } = this.getGasConfig();
|
3968
|
+
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
4195
3969
|
const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
|
4196
3970
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4197
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
3971
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
4198
3972
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
4199
|
-
txRequestClone.maxFee = bn16(0);
|
4200
3973
|
if (isScriptTransaction) {
|
4201
|
-
txRequestClone.gasLimit =
|
3974
|
+
txRequestClone.gasLimit = bn15(0);
|
4202
3975
|
}
|
4203
|
-
if (
|
4204
|
-
resourcesOwner
|
3976
|
+
if (estimatePredicates) {
|
3977
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
3978
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
3979
|
+
}
|
3980
|
+
await this.estimatePredicates(txRequestClone);
|
4205
3981
|
}
|
4206
|
-
const signedRequest = clone3(txRequestClone);
|
4207
|
-
let addedSignatures = 0;
|
4208
3982
|
if (signatureCallback && isScriptTransaction) {
|
4209
|
-
|
4210
|
-
await signatureCallback(signedRequest);
|
4211
|
-
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
3983
|
+
await signatureCallback(txRequestClone);
|
4212
3984
|
}
|
4213
|
-
|
4214
|
-
|
4215
|
-
transactionRequest: signedRequest
|
3985
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
3986
|
+
transactionRequest: txRequestClone
|
4216
3987
|
});
|
4217
3988
|
let receipts = [];
|
4218
3989
|
let missingContractIds = [];
|
4219
3990
|
let outputVariables = 0;
|
4220
|
-
let gasUsed =
|
4221
|
-
|
4222
|
-
|
4223
|
-
if (isScriptTransaction) {
|
4224
|
-
txRequestClone.gasLimit = gasLimit;
|
4225
|
-
if (signatureCallback) {
|
4226
|
-
await signatureCallback(txRequestClone);
|
4227
|
-
}
|
3991
|
+
let gasUsed = bn15(0);
|
3992
|
+
if (isScriptTransaction && estimateTxDependencies) {
|
3993
|
+
txRequestClone.gasPrice = bn15(0);
|
4228
3994
|
const result = await this.estimateTxDependencies(txRequestClone);
|
4229
3995
|
receipts = result.receipts;
|
4230
3996
|
outputVariables = result.outputVariables;
|
4231
3997
|
missingContractIds = result.missingContractIds;
|
4232
3998
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4233
3999
|
txRequestClone.gasLimit = gasUsed;
|
4234
|
-
|
4235
|
-
|
4236
|
-
|
4000
|
+
txRequestClone.gasPrice = setGasPrice;
|
4001
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
4002
|
+
transactionRequest: txRequestClone
|
4237
4003
|
}));
|
4238
4004
|
}
|
4239
4005
|
return {
|
4240
4006
|
requiredQuantities: allQuantities,
|
4241
4007
|
receipts,
|
4242
4008
|
gasUsed,
|
4243
|
-
|
4009
|
+
minGasPrice,
|
4010
|
+
gasPrice: setGasPrice,
|
4244
4011
|
minGas,
|
4245
4012
|
maxGas,
|
4246
4013
|
minFee,
|
4247
4014
|
maxFee,
|
4015
|
+
estimatedInputs: txRequestClone.inputs,
|
4248
4016
|
outputVariables,
|
4249
|
-
missingContractIds
|
4250
|
-
addedSignatures,
|
4251
|
-
estimatedPredicates: txRequestClone.inputs
|
4017
|
+
missingContractIds
|
4252
4018
|
};
|
4253
4019
|
}
|
4254
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
4020
|
+
async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
|
4255
4021
|
const ownerAddress = Address2.fromAddressOrString(owner);
|
4256
4022
|
const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
|
4257
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
4258
|
-
quantitiesToContract
|
4259
|
-
});
|
4023
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
|
4260
4024
|
transactionRequest.addResources(
|
4261
4025
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
4262
4026
|
);
|
4263
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4264
|
-
|
4265
|
-
|
4027
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4028
|
+
transactionRequest,
|
4029
|
+
forwardingQuantities
|
4030
|
+
);
|
4266
4031
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
4267
4032
|
return {
|
4268
4033
|
resources,
|
@@ -4284,10 +4049,11 @@ var _Provider = class {
|
|
4284
4049
|
return coins.map((coin) => ({
|
4285
4050
|
id: coin.utxoId,
|
4286
4051
|
assetId: coin.assetId,
|
4287
|
-
amount:
|
4052
|
+
amount: bn15(coin.amount),
|
4288
4053
|
owner: Address2.fromAddressOrString(coin.owner),
|
4289
|
-
|
4290
|
-
|
4054
|
+
maturity: bn15(coin.maturity).toNumber(),
|
4055
|
+
blockCreated: bn15(coin.blockCreated),
|
4056
|
+
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4291
4057
|
}));
|
4292
4058
|
}
|
4293
4059
|
/**
|
@@ -4324,9 +4090,9 @@ var _Provider = class {
|
|
4324
4090
|
switch (coin.__typename) {
|
4325
4091
|
case "MessageCoin":
|
4326
4092
|
return {
|
4327
|
-
amount:
|
4093
|
+
amount: bn15(coin.amount),
|
4328
4094
|
assetId: coin.assetId,
|
4329
|
-
daHeight:
|
4095
|
+
daHeight: bn15(coin.daHeight),
|
4330
4096
|
sender: Address2.fromAddressOrString(coin.sender),
|
4331
4097
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4332
4098
|
nonce: coin.nonce
|
@@ -4334,11 +4100,12 @@ var _Provider = class {
|
|
4334
4100
|
case "Coin":
|
4335
4101
|
return {
|
4336
4102
|
id: coin.utxoId,
|
4337
|
-
amount:
|
4103
|
+
amount: bn15(coin.amount),
|
4338
4104
|
assetId: coin.assetId,
|
4339
4105
|
owner: Address2.fromAddressOrString(coin.owner),
|
4340
|
-
|
4341
|
-
|
4106
|
+
maturity: bn15(coin.maturity).toNumber(),
|
4107
|
+
blockCreated: bn15(coin.blockCreated),
|
4108
|
+
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4342
4109
|
};
|
4343
4110
|
default:
|
4344
4111
|
return null;
|
@@ -4355,13 +4122,13 @@ var _Provider = class {
|
|
4355
4122
|
async getBlock(idOrHeight) {
|
4356
4123
|
let variables;
|
4357
4124
|
if (typeof idOrHeight === "number") {
|
4358
|
-
variables = { height:
|
4125
|
+
variables = { height: bn15(idOrHeight).toString(10) };
|
4359
4126
|
} else if (idOrHeight === "latest") {
|
4360
4127
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4361
4128
|
} else if (idOrHeight.length === 66) {
|
4362
4129
|
variables = { blockId: idOrHeight };
|
4363
4130
|
} else {
|
4364
|
-
variables = { blockId:
|
4131
|
+
variables = { blockId: bn15(idOrHeight).toString(10) };
|
4365
4132
|
}
|
4366
4133
|
const { block } = await this.operations.getBlock(variables);
|
4367
4134
|
if (!block) {
|
@@ -4369,7 +4136,7 @@ var _Provider = class {
|
|
4369
4136
|
}
|
4370
4137
|
return {
|
4371
4138
|
id: block.id,
|
4372
|
-
height:
|
4139
|
+
height: bn15(block.header.height),
|
4373
4140
|
time: block.header.time,
|
4374
4141
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4375
4142
|
};
|
@@ -4384,7 +4151,7 @@ var _Provider = class {
|
|
4384
4151
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4385
4152
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4386
4153
|
id: block.id,
|
4387
|
-
height:
|
4154
|
+
height: bn15(block.header.height),
|
4388
4155
|
time: block.header.time,
|
4389
4156
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4390
4157
|
}));
|
@@ -4399,7 +4166,7 @@ var _Provider = class {
|
|
4399
4166
|
async getBlockWithTransactions(idOrHeight) {
|
4400
4167
|
let variables;
|
4401
4168
|
if (typeof idOrHeight === "number") {
|
4402
|
-
variables = { blockHeight:
|
4169
|
+
variables = { blockHeight: bn15(idOrHeight).toString(10) };
|
4403
4170
|
} else if (idOrHeight === "latest") {
|
4404
4171
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4405
4172
|
} else {
|
@@ -4411,7 +4178,7 @@ var _Provider = class {
|
|
4411
4178
|
}
|
4412
4179
|
return {
|
4413
4180
|
id: block.id,
|
4414
|
-
height:
|
4181
|
+
height: bn15(block.header.height, 10),
|
4415
4182
|
time: block.header.time,
|
4416
4183
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4417
4184
|
transactions: block.transactions.map(
|
@@ -4460,7 +4227,7 @@ var _Provider = class {
|
|
4460
4227
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4461
4228
|
asset: hexlify12(assetId)
|
4462
4229
|
});
|
4463
|
-
return
|
4230
|
+
return bn15(contractBalance.amount, 10);
|
4464
4231
|
}
|
4465
4232
|
/**
|
4466
4233
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4474,7 +4241,7 @@ var _Provider = class {
|
|
4474
4241
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4475
4242
|
assetId: hexlify12(assetId)
|
4476
4243
|
});
|
4477
|
-
return
|
4244
|
+
return bn15(balance.amount, 10);
|
4478
4245
|
}
|
4479
4246
|
/**
|
4480
4247
|
* Returns balances for the given owner.
|
@@ -4492,7 +4259,7 @@ var _Provider = class {
|
|
4492
4259
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4493
4260
|
return balances.map((balance) => ({
|
4494
4261
|
assetId: balance.assetId,
|
4495
|
-
amount:
|
4262
|
+
amount: bn15(balance.amount)
|
4496
4263
|
}));
|
4497
4264
|
}
|
4498
4265
|
/**
|
@@ -4514,15 +4281,15 @@ var _Provider = class {
|
|
4514
4281
|
sender: message.sender,
|
4515
4282
|
recipient: message.recipient,
|
4516
4283
|
nonce: message.nonce,
|
4517
|
-
amount:
|
4284
|
+
amount: bn15(message.amount),
|
4518
4285
|
data: message.data
|
4519
4286
|
}),
|
4520
4287
|
sender: Address2.fromAddressOrString(message.sender),
|
4521
4288
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4522
4289
|
nonce: message.nonce,
|
4523
|
-
amount:
|
4290
|
+
amount: bn15(message.amount),
|
4524
4291
|
data: InputMessageCoder.decodeData(message.data),
|
4525
|
-
daHeight:
|
4292
|
+
daHeight: bn15(message.daHeight)
|
4526
4293
|
}));
|
4527
4294
|
}
|
4528
4295
|
/**
|
@@ -4575,60 +4342,44 @@ var _Provider = class {
|
|
4575
4342
|
} = result.messageProof;
|
4576
4343
|
return {
|
4577
4344
|
messageProof: {
|
4578
|
-
proofIndex:
|
4345
|
+
proofIndex: bn15(messageProof.proofIndex),
|
4579
4346
|
proofSet: messageProof.proofSet
|
4580
4347
|
},
|
4581
4348
|
blockProof: {
|
4582
|
-
proofIndex:
|
4349
|
+
proofIndex: bn15(blockProof.proofIndex),
|
4583
4350
|
proofSet: blockProof.proofSet
|
4584
4351
|
},
|
4585
4352
|
messageBlockHeader: {
|
4586
4353
|
id: messageBlockHeader.id,
|
4587
|
-
daHeight:
|
4588
|
-
transactionsCount:
|
4354
|
+
daHeight: bn15(messageBlockHeader.daHeight),
|
4355
|
+
transactionsCount: bn15(messageBlockHeader.transactionsCount),
|
4589
4356
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4590
|
-
height:
|
4357
|
+
height: bn15(messageBlockHeader.height),
|
4591
4358
|
prevRoot: messageBlockHeader.prevRoot,
|
4592
4359
|
time: messageBlockHeader.time,
|
4593
4360
|
applicationHash: messageBlockHeader.applicationHash,
|
4594
|
-
|
4595
|
-
|
4596
|
-
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4597
|
-
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4598
|
-
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4361
|
+
messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
|
4362
|
+
messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
|
4599
4363
|
},
|
4600
4364
|
commitBlockHeader: {
|
4601
4365
|
id: commitBlockHeader.id,
|
4602
|
-
daHeight:
|
4603
|
-
transactionsCount:
|
4366
|
+
daHeight: bn15(commitBlockHeader.daHeight),
|
4367
|
+
transactionsCount: bn15(commitBlockHeader.transactionsCount),
|
4604
4368
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4605
|
-
height:
|
4369
|
+
height: bn15(commitBlockHeader.height),
|
4606
4370
|
prevRoot: commitBlockHeader.prevRoot,
|
4607
4371
|
time: commitBlockHeader.time,
|
4608
4372
|
applicationHash: commitBlockHeader.applicationHash,
|
4609
|
-
|
4610
|
-
|
4611
|
-
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4612
|
-
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4613
|
-
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4373
|
+
messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
|
4374
|
+
messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
|
4614
4375
|
},
|
4615
4376
|
sender: Address2.fromAddressOrString(sender),
|
4616
4377
|
recipient: Address2.fromAddressOrString(recipient),
|
4617
4378
|
nonce,
|
4618
|
-
amount:
|
4379
|
+
amount: bn15(amount),
|
4619
4380
|
data
|
4620
4381
|
};
|
4621
4382
|
}
|
4622
|
-
async getLatestGasPrice() {
|
4623
|
-
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4624
|
-
return bn16(latestGasPrice.gasPrice);
|
4625
|
-
}
|
4626
|
-
async estimateGasPrice(blockHorizon) {
|
4627
|
-
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4628
|
-
blockHorizon: String(blockHorizon)
|
4629
|
-
});
|
4630
|
-
return bn16(estimateGasPrice.gasPrice);
|
4631
|
-
}
|
4632
4383
|
/**
|
4633
4384
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
4634
4385
|
*
|
@@ -4648,10 +4399,10 @@ var _Provider = class {
|
|
4648
4399
|
*/
|
4649
4400
|
async produceBlocks(amount, startTime) {
|
4650
4401
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4651
|
-
blocksToProduce:
|
4402
|
+
blocksToProduce: bn15(amount).toString(10),
|
4652
4403
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4653
4404
|
});
|
4654
|
-
return
|
4405
|
+
return bn15(latestBlockHeight);
|
4655
4406
|
}
|
4656
4407
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4657
4408
|
async getTransactionResponse(transactionId) {
|
@@ -4665,7 +4416,7 @@ cacheInputs_fn = function(inputs) {
|
|
4665
4416
|
return;
|
4666
4417
|
}
|
4667
4418
|
inputs.forEach((input) => {
|
4668
|
-
if (input.type ===
|
4419
|
+
if (input.type === InputType6.Coin) {
|
4669
4420
|
this.cache?.set(input.id);
|
4670
4421
|
}
|
4671
4422
|
});
|
@@ -4675,7 +4426,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4675
4426
|
|
4676
4427
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4677
4428
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4678
|
-
import { bn as
|
4429
|
+
import { bn as bn16 } from "@fuel-ts/math";
|
4679
4430
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4680
4431
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4681
4432
|
|
@@ -4921,33 +4672,36 @@ var Account = class extends AbstractAccount {
|
|
4921
4672
|
* @param fee - The estimated transaction fee.
|
4922
4673
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4923
4674
|
*/
|
4924
|
-
async fund(request,
|
4925
|
-
const
|
4926
|
-
|
4927
|
-
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
4928
|
-
amount: bn18(fee),
|
4675
|
+
async fund(request, coinQuantities, fee) {
|
4676
|
+
const updatedQuantities = addAmountToAsset({
|
4677
|
+
amount: bn17(fee),
|
4929
4678
|
assetId: BaseAssetId3,
|
4930
|
-
coinQuantities
|
4679
|
+
coinQuantities
|
4931
4680
|
});
|
4932
4681
|
const quantitiesDict = {};
|
4933
|
-
|
4682
|
+
updatedQuantities.forEach(({ amount, assetId }) => {
|
4934
4683
|
quantitiesDict[assetId] = {
|
4935
4684
|
required: amount,
|
4936
|
-
owned:
|
4685
|
+
owned: bn17(0)
|
4937
4686
|
};
|
4938
4687
|
});
|
4939
|
-
|
4688
|
+
const cachedUtxos = [];
|
4689
|
+
const cachedMessages = [];
|
4690
|
+
const owner = this.address.toB256();
|
4691
|
+
request.inputs.forEach((input) => {
|
4940
4692
|
const isResource = "amount" in input;
|
4941
4693
|
if (isResource) {
|
4942
4694
|
const isCoin2 = "owner" in input;
|
4943
4695
|
if (isCoin2) {
|
4944
4696
|
const assetId = String(input.assetId);
|
4945
|
-
if (quantitiesDict[assetId]) {
|
4946
|
-
const amount =
|
4697
|
+
if (input.owner === owner && quantitiesDict[assetId]) {
|
4698
|
+
const amount = bn17(input.amount);
|
4947
4699
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4700
|
+
cachedUtxos.push(input.id);
|
4948
4701
|
}
|
4949
|
-
} else if (input.amount && quantitiesDict[BaseAssetId3]) {
|
4702
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
|
4950
4703
|
quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
|
4704
|
+
cachedMessages.push(input.nonce);
|
4951
4705
|
}
|
4952
4706
|
}
|
4953
4707
|
});
|
@@ -4962,23 +4716,12 @@ var Account = class extends AbstractAccount {
|
|
4962
4716
|
});
|
4963
4717
|
const needsToBeFunded = missingQuantities.length;
|
4964
4718
|
if (needsToBeFunded) {
|
4965
|
-
const
|
4966
|
-
|
4967
|
-
|
4968
|
-
|
4969
|
-
|
4970
|
-
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
4971
|
-
const requestToBeReEstimate = clone4(txRequest);
|
4972
|
-
if (addedSignatures) {
|
4973
|
-
Array.from({ length: addedSignatures }).forEach(
|
4974
|
-
() => requestToBeReEstimate.addEmptyWitness()
|
4975
|
-
);
|
4719
|
+
const resources = await this.getResourcesToSpend(missingQuantities, {
|
4720
|
+
messages: cachedMessages,
|
4721
|
+
utxos: cachedUtxos
|
4722
|
+
});
|
4723
|
+
request.addResources(resources);
|
4976
4724
|
}
|
4977
|
-
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
4978
|
-
transactionRequest: requestToBeReEstimate
|
4979
|
-
});
|
4980
|
-
txRequest.maxFee = maxFee;
|
4981
|
-
return txRequest;
|
4982
4725
|
}
|
4983
4726
|
/**
|
4984
4727
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -4986,25 +4729,28 @@ var Account = class extends AbstractAccount {
|
|
4986
4729
|
* @param destination - The address of the destination.
|
4987
4730
|
* @param amount - The amount of coins to transfer.
|
4988
4731
|
* @param assetId - The asset ID of the coins to transfer.
|
4989
|
-
* @param txParams - The transaction parameters (gasLimit,
|
4732
|
+
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4990
4733
|
* @returns A promise that resolves to the prepared transaction request.
|
4991
4734
|
*/
|
4992
4735
|
async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
4993
|
-
const
|
4736
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
4737
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
4738
|
+
const request = new ScriptTransactionRequest(params);
|
4994
4739
|
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
|
4995
|
-
const
|
4740
|
+
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
4996
4741
|
estimateTxDependencies: true,
|
4997
4742
|
resourcesOwner: this
|
4998
4743
|
});
|
4999
|
-
|
5000
|
-
|
5001
|
-
|
5002
|
-
|
5003
|
-
|
5004
|
-
|
5005
|
-
|
5006
|
-
|
5007
|
-
await this.fund(request,
|
4744
|
+
request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
|
4745
|
+
request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
|
4746
|
+
this.validateGas({
|
4747
|
+
gasUsed,
|
4748
|
+
gasPrice: request.gasPrice,
|
4749
|
+
gasLimit: request.gasLimit,
|
4750
|
+
minGasPrice
|
4751
|
+
});
|
4752
|
+
await this.fund(request, requiredQuantities, maxFee);
|
4753
|
+
request.updatePredicateInputs(estimatedInputs);
|
5008
4754
|
return request;
|
5009
4755
|
}
|
5010
4756
|
/**
|
@@ -5017,7 +4763,7 @@ var Account = class extends AbstractAccount {
|
|
5017
4763
|
* @returns A promise that resolves to the transaction response.
|
5018
4764
|
*/
|
5019
4765
|
async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
5020
|
-
if (
|
4766
|
+
if (bn17(amount).lte(0)) {
|
5021
4767
|
throw new FuelError15(
|
5022
4768
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5023
4769
|
"Transfer amount must be a positive number."
|
@@ -5036,37 +4782,38 @@ var Account = class extends AbstractAccount {
|
|
5036
4782
|
* @returns A promise that resolves to the transaction response.
|
5037
4783
|
*/
|
5038
4784
|
async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
|
5039
|
-
if (
|
4785
|
+
if (bn17(amount).lte(0)) {
|
5040
4786
|
throw new FuelError15(
|
5041
4787
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5042
4788
|
"Transfer amount must be a positive number."
|
5043
4789
|
);
|
5044
4790
|
}
|
5045
4791
|
const contractAddress = Address3.fromAddressOrString(contractId);
|
4792
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
4793
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
5046
4794
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5047
4795
|
hexlifiedContractId: contractAddress.toB256(),
|
5048
|
-
amountToTransfer:
|
4796
|
+
amountToTransfer: bn17(amount),
|
5049
4797
|
assetId
|
5050
4798
|
});
|
5051
4799
|
const request = new ScriptTransactionRequest({
|
5052
|
-
...
|
4800
|
+
...params,
|
5053
4801
|
script,
|
5054
4802
|
scriptData
|
5055
4803
|
});
|
5056
4804
|
request.addContractInputAndOutput(contractAddress);
|
5057
|
-
const
|
5058
|
-
|
5059
|
-
|
4805
|
+
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
4806
|
+
request,
|
4807
|
+
[{ amount: bn17(amount), assetId: String(assetId) }]
|
4808
|
+
);
|
4809
|
+
request.gasLimit = bn17(params.gasLimit ?? gasUsed);
|
4810
|
+
this.validateGas({
|
4811
|
+
gasUsed,
|
4812
|
+
gasPrice: request.gasPrice,
|
4813
|
+
gasLimit: request.gasLimit,
|
4814
|
+
minGasPrice
|
5060
4815
|
});
|
5061
|
-
|
5062
|
-
this.validateGas({
|
5063
|
-
gasUsed: txCost.gasUsed,
|
5064
|
-
gasLimit: request.gasLimit
|
5065
|
-
});
|
5066
|
-
}
|
5067
|
-
request.gasLimit = txCost.gasUsed;
|
5068
|
-
request.maxFee = txCost.maxFee;
|
5069
|
-
await this.fund(request, txCost);
|
4816
|
+
await this.fund(request, requiredQuantities, maxFee);
|
5070
4817
|
return this.sendTransaction(request);
|
5071
4818
|
}
|
5072
4819
|
/**
|
@@ -5078,31 +4825,34 @@ var Account = class extends AbstractAccount {
|
|
5078
4825
|
* @returns A promise that resolves to the transaction response.
|
5079
4826
|
*/
|
5080
4827
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4828
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
5081
4829
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
5082
4830
|
const recipientDataArray = arrayify14(
|
5083
4831
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5084
4832
|
);
|
5085
4833
|
const amountDataArray = arrayify14(
|
5086
|
-
"0x".concat(
|
4834
|
+
"0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
|
5087
4835
|
);
|
5088
4836
|
const script = new Uint8Array([
|
5089
4837
|
...arrayify14(withdrawScript.bytes),
|
5090
4838
|
...recipientDataArray,
|
5091
4839
|
...amountDataArray
|
5092
4840
|
]);
|
5093
|
-
const params = { script, ...txParams };
|
4841
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
5094
4842
|
const request = new ScriptTransactionRequest(params);
|
5095
|
-
const
|
5096
|
-
const
|
5097
|
-
|
5098
|
-
|
5099
|
-
|
5100
|
-
|
5101
|
-
|
5102
|
-
|
5103
|
-
|
5104
|
-
|
5105
|
-
|
4843
|
+
const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
|
4844
|
+
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
4845
|
+
request,
|
4846
|
+
forwardingQuantities
|
4847
|
+
);
|
4848
|
+
request.gasLimit = bn17(params.gasLimit ?? gasUsed);
|
4849
|
+
this.validateGas({
|
4850
|
+
gasUsed,
|
4851
|
+
gasPrice: request.gasPrice,
|
4852
|
+
gasLimit: request.gasLimit,
|
4853
|
+
minGasPrice
|
4854
|
+
});
|
4855
|
+
await this.fund(request, requiredQuantities, maxFee);
|
5106
4856
|
return this.sendTransaction(request);
|
5107
4857
|
}
|
5108
4858
|
async signMessage(message) {
|
@@ -5160,7 +4910,18 @@ var Account = class extends AbstractAccount {
|
|
5160
4910
|
}
|
5161
4911
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5162
4912
|
}
|
5163
|
-
validateGas({
|
4913
|
+
validateGas({
|
4914
|
+
gasUsed,
|
4915
|
+
gasPrice,
|
4916
|
+
gasLimit,
|
4917
|
+
minGasPrice
|
4918
|
+
}) {
|
4919
|
+
if (minGasPrice.gt(gasPrice)) {
|
4920
|
+
throw new FuelError15(
|
4921
|
+
ErrorCode15.GAS_PRICE_TOO_LOW,
|
4922
|
+
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
4923
|
+
);
|
4924
|
+
}
|
5164
4925
|
if (gasUsed.gt(gasLimit)) {
|
5165
4926
|
throw new FuelError15(
|
5166
4927
|
ErrorCode15.GAS_LIMIT_TOO_LOW,
|
@@ -5452,7 +5213,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5452
5213
|
* @param transactionRequestLike - The transaction request to send.
|
5453
5214
|
* @returns A promise that resolves to the TransactionResponse object.
|
5454
5215
|
*/
|
5455
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
5216
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
5456
5217
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5457
5218
|
if (estimateTxDependencies) {
|
5458
5219
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -5493,7 +5254,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5493
5254
|
// src/hdwallet/hdwallet.ts
|
5494
5255
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5495
5256
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5496
|
-
import { bn as
|
5257
|
+
import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5497
5258
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5498
5259
|
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5499
5260
|
|
@@ -7959,7 +7720,7 @@ var HDWallet = class {
|
|
7959
7720
|
const IR = bytes.slice(32);
|
7960
7721
|
if (privateKey) {
|
7961
7722
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7962
|
-
const ki =
|
7723
|
+
const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
|
7963
7724
|
return new HDWallet({
|
7964
7725
|
privateKey: ki,
|
7965
7726
|
chainCode: IR,
|
@@ -8230,15 +7991,14 @@ var seedTestWallet = async (wallet, quantities) => {
|
|
8230
7991
|
process.env.GENESIS_SECRET || randomBytes5(32),
|
8231
7992
|
wallet.provider
|
8232
7993
|
);
|
8233
|
-
const
|
8234
|
-
|
8235
|
-
|
8236
|
-
|
7994
|
+
const resources = await genesisWallet.getResourcesToSpend(quantities);
|
7995
|
+
const { minGasPrice } = genesisWallet.provider.getGasConfig();
|
7996
|
+
const request = new ScriptTransactionRequest({
|
7997
|
+
gasLimit: 1e4,
|
7998
|
+
gasPrice: minGasPrice
|
8237
7999
|
});
|
8238
|
-
|
8239
|
-
request.
|
8240
|
-
request.maxFee = txCost.maxFee;
|
8241
|
-
await genesisWallet.fund(request, txCost);
|
8000
|
+
request.addResources(resources);
|
8001
|
+
quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
|
8242
8002
|
await genesisWallet.sendTransaction(request, { awaitExecution: true });
|
8243
8003
|
};
|
8244
8004
|
|
@@ -8252,10 +8012,9 @@ var generateTestWallet = async (provider, quantities) => {
|
|
8252
8012
|
};
|
8253
8013
|
|
8254
8014
|
// src/test-utils/launchNode.ts
|
8255
|
-
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
8256
8015
|
import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
|
8257
|
-
import {
|
8258
|
-
import {
|
8016
|
+
import { toHex as toHex2 } from "@fuel-ts/math";
|
8017
|
+
import { defaultChainConfig, defaultConsensusKey, hexlify as hexlify18 } from "@fuel-ts/utils";
|
8259
8018
|
import { findBinPath } from "@fuel-ts/utils/cli-utils";
|
8260
8019
|
import { spawn } from "child_process";
|
8261
8020
|
import { randomUUID } from "crypto";
|
@@ -8307,12 +8066,12 @@ var launchNode = async ({
|
|
8307
8066
|
// eslint-disable-next-line no-async-promise-executor
|
8308
8067
|
new Promise(async (resolve, reject) => {
|
8309
8068
|
const remainingArgs = extractRemainingArgs(args, [
|
8310
|
-
"--
|
8069
|
+
"--chain",
|
8311
8070
|
"--consensus-key",
|
8312
8071
|
"--db-type",
|
8313
8072
|
"--poa-instant"
|
8314
8073
|
]);
|
8315
|
-
const chainConfigPath = getFlagValueFromArgs(args, "--
|
8074
|
+
const chainConfigPath = getFlagValueFromArgs(args, "--chain");
|
8316
8075
|
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || defaultConsensusKey;
|
8317
8076
|
const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
|
8318
8077
|
const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
|
@@ -8331,54 +8090,36 @@ var launchNode = async ({
|
|
8331
8090
|
let chainConfigPathToUse;
|
8332
8091
|
const prefix = basePath || os.tmpdir();
|
8333
8092
|
const suffix = basePath ? "" : randomUUID();
|
8334
|
-
const tempDirPath = path.join(prefix, ".fuels", suffix
|
8093
|
+
const tempDirPath = path.join(prefix, ".fuels", suffix);
|
8335
8094
|
if (chainConfigPath) {
|
8336
8095
|
chainConfigPathToUse = chainConfigPath;
|
8337
8096
|
} else {
|
8338
8097
|
if (!existsSync(tempDirPath)) {
|
8339
8098
|
mkdirSync(tempDirPath, { recursive: true });
|
8340
8099
|
}
|
8341
|
-
|
8342
|
-
|
8343
|
-
stateConfigJson = {
|
8344
|
-
...stateConfigJson,
|
8345
|
-
coins: [
|
8346
|
-
...stateConfigJson.coins.map((coin) => ({
|
8347
|
-
...coin,
|
8348
|
-
amount: "18446744073709551615"
|
8349
|
-
}))
|
8350
|
-
],
|
8351
|
-
messages: stateConfigJson.messages.map((message) => ({
|
8352
|
-
...message,
|
8353
|
-
amount: "18446744073709551615"
|
8354
|
-
}))
|
8355
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8356
|
-
};
|
8100
|
+
const tempChainConfigFilePath = path.join(tempDirPath, "chainConfig.json");
|
8101
|
+
let chainConfig = defaultChainConfig;
|
8357
8102
|
if (!process.env.GENESIS_SECRET) {
|
8358
8103
|
const pk = Signer.generatePrivateKey();
|
8359
8104
|
const signer = new Signer(pk);
|
8360
8105
|
process.env.GENESIS_SECRET = hexlify18(pk);
|
8361
|
-
|
8362
|
-
|
8363
|
-
|
8364
|
-
|
8365
|
-
|
8366
|
-
|
8367
|
-
|
8368
|
-
|
8369
|
-
|
8370
|
-
|
8106
|
+
chainConfig = {
|
8107
|
+
...defaultChainConfig,
|
8108
|
+
initial_state: {
|
8109
|
+
...defaultChainConfig.initial_state,
|
8110
|
+
coins: [
|
8111
|
+
...defaultChainConfig.initial_state.coins,
|
8112
|
+
{
|
8113
|
+
owner: signer.address.toHexString(),
|
8114
|
+
amount: toHex2(1e9),
|
8115
|
+
asset_id: BaseAssetId4
|
8116
|
+
}
|
8117
|
+
]
|
8118
|
+
}
|
8119
|
+
};
|
8371
8120
|
}
|
8372
|
-
|
8373
|
-
|
8374
|
-
fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
|
8375
|
-
const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
|
8376
|
-
const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
|
8377
|
-
const metadataWritePath = path.join(tempDirPath, "metadata.json");
|
8378
|
-
writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
|
8379
|
-
writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
|
8380
|
-
writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
|
8381
|
-
chainConfigPathToUse = tempDirPath;
|
8121
|
+
writeFileSync(tempChainConfigFilePath, JSON.stringify(chainConfig), "utf8");
|
8122
|
+
chainConfigPathToUse = tempChainConfigFilePath;
|
8382
8123
|
}
|
8383
8124
|
const child = spawn(
|
8384
8125
|
command,
|
@@ -8387,10 +8128,10 @@ var launchNode = async ({
|
|
8387
8128
|
["--ip", ipToUse],
|
8388
8129
|
["--port", portToUse],
|
8389
8130
|
useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
|
8390
|
-
["--min-gas-price", "
|
8131
|
+
["--min-gas-price", "0"],
|
8391
8132
|
poaInstant ? ["--poa-instant", "true"] : [],
|
8392
8133
|
["--consensus-key", consensusKey],
|
8393
|
-
["--
|
8134
|
+
["--chain", chainConfigPathToUse],
|
8394
8135
|
"--vm-backtrace",
|
8395
8136
|
"--utxo-validation",
|
8396
8137
|
"--debug",
|
@@ -8449,7 +8190,7 @@ var launchNodeAndGetWallets = async ({
|
|
8449
8190
|
walletCount = 10
|
8450
8191
|
} = {}) => {
|
8451
8192
|
const { cleanup: closeNode, ip, port } = await launchNode(launchNodeOptions || {});
|
8452
|
-
const provider = await Provider.create(`http://${ip}:${port}/
|
8193
|
+
const provider = await Provider.create(`http://${ip}:${port}/graphql`);
|
8453
8194
|
const wallets = await generateWallets(walletCount, provider);
|
8454
8195
|
const cleanup = () => {
|
8455
8196
|
closeNode();
|