@fuel-ts/account 0.0.0-rc-2021-20240424160726 → 0.0.0-rc-2143-20240424161332
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/README.md +1 -1
- package/dist/account.d.ts +5 -6
- 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 +583 -863
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +513 -793
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +395 -674
- 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 +326 -828
- 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 +4 -2
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +1055 -1551
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +513 -775
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +406 -668
- 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/index.mjs
CHANGED
@@ -32,9 +32,8 @@ import { Address as Address3 } from "@fuel-ts/address";
|
|
32
32
|
import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
|
33
33
|
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
34
34
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
35
|
-
import { bn as
|
36
|
-
import { arrayify as arrayify14
|
37
|
-
import { clone as clone4 } from "ramda";
|
35
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
36
|
+
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
38
37
|
|
39
38
|
// src/providers/coin-quantity.ts
|
40
39
|
import { BaseAssetId } from "@fuel-ts/address/configs";
|
@@ -43,24 +42,24 @@ import { hexlify } from "@fuel-ts/utils";
|
|
43
42
|
var coinQuantityfy = (coinQuantityLike) => {
|
44
43
|
let assetId;
|
45
44
|
let amount;
|
46
|
-
let
|
45
|
+
let max2;
|
47
46
|
if (Array.isArray(coinQuantityLike)) {
|
48
47
|
amount = coinQuantityLike[0];
|
49
48
|
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
50
|
-
|
49
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
51
50
|
} else {
|
52
51
|
amount = coinQuantityLike.amount;
|
53
52
|
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
54
|
-
|
53
|
+
max2 = coinQuantityLike.max ?? void 0;
|
55
54
|
}
|
56
55
|
const bnAmount = bn(amount);
|
57
56
|
return {
|
58
57
|
assetId: hexlify(assetId),
|
59
58
|
amount: bnAmount.lt(1) ? bn(1) : bnAmount,
|
60
|
-
max:
|
59
|
+
max: max2 ? bn(max2) : void 0
|
61
60
|
};
|
62
61
|
};
|
63
|
-
var
|
62
|
+
var addAmountToAsset = (params) => {
|
64
63
|
const { amount, assetId } = params;
|
65
64
|
const coinQuantities = [...params.coinQuantities];
|
66
65
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -75,9 +74,9 @@ var addAmountToCoinQuantities = (params) => {
|
|
75
74
|
// src/providers/provider.ts
|
76
75
|
import { Address as Address2 } from "@fuel-ts/address";
|
77
76
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
78
|
-
import { BN, bn as
|
77
|
+
import { BN, bn as bn15, max } from "@fuel-ts/math";
|
79
78
|
import {
|
80
|
-
InputType as
|
79
|
+
InputType as InputType6,
|
81
80
|
TransactionType as TransactionType8,
|
82
81
|
InputMessageCoder,
|
83
82
|
TransactionCoder as TransactionCoder5
|
@@ -91,40 +90,16 @@ import { clone as clone3 } from "ramda";
|
|
91
90
|
|
92
91
|
// src/providers/__generated__/operations.ts
|
93
92
|
import gql from "graphql-tag";
|
94
|
-
var TransactionStatusSubscriptionFragmentFragmentDoc = gql`
|
95
|
-
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
96
|
-
type: __typename
|
97
|
-
... on SubmittedStatus {
|
98
|
-
time
|
99
|
-
}
|
100
|
-
... on SuccessStatus {
|
101
|
-
block {
|
102
|
-
id
|
103
|
-
}
|
104
|
-
time
|
105
|
-
programState {
|
106
|
-
returnType
|
107
|
-
data
|
108
|
-
}
|
109
|
-
}
|
110
|
-
... on FailureStatus {
|
111
|
-
block {
|
112
|
-
id
|
113
|
-
}
|
114
|
-
time
|
115
|
-
reason
|
116
|
-
}
|
117
|
-
... on SqueezedOutStatus {
|
118
|
-
reason
|
119
|
-
}
|
120
|
-
}
|
121
|
-
`;
|
122
93
|
var ReceiptFragmentFragmentDoc = gql`
|
123
94
|
fragment receiptFragment on Receipt {
|
124
|
-
|
95
|
+
contract {
|
96
|
+
id
|
97
|
+
}
|
125
98
|
pc
|
126
99
|
is
|
127
|
-
to
|
100
|
+
to {
|
101
|
+
id
|
102
|
+
}
|
128
103
|
toAddress
|
129
104
|
amount
|
130
105
|
assetId
|
@@ -162,16 +137,10 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
162
137
|
id
|
163
138
|
}
|
164
139
|
time
|
165
|
-
receipts {
|
166
|
-
...receiptFragment
|
167
|
-
}
|
168
140
|
programState {
|
169
141
|
returnType
|
170
142
|
data
|
171
143
|
}
|
172
|
-
receipts {
|
173
|
-
...receiptFragment
|
174
|
-
}
|
175
144
|
}
|
176
145
|
... on FailureStatus {
|
177
146
|
block {
|
@@ -179,24 +148,26 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
179
148
|
}
|
180
149
|
time
|
181
150
|
reason
|
182
|
-
receipts {
|
183
|
-
...receiptFragment
|
184
|
-
}
|
185
151
|
}
|
186
152
|
... on SqueezedOutStatus {
|
187
153
|
reason
|
188
154
|
}
|
189
155
|
}
|
190
|
-
|
156
|
+
`;
|
191
157
|
var TransactionFragmentFragmentDoc = gql`
|
192
158
|
fragment transactionFragment on Transaction {
|
193
159
|
id
|
194
160
|
rawPayload
|
161
|
+
gasPrice
|
162
|
+
receipts {
|
163
|
+
...receiptFragment
|
164
|
+
}
|
195
165
|
status {
|
196
166
|
...transactionStatusFragment
|
197
167
|
}
|
198
168
|
}
|
199
|
-
${
|
169
|
+
${ReceiptFragmentFragmentDoc}
|
170
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
200
171
|
var InputEstimatePredicatesFragmentFragmentDoc = gql`
|
201
172
|
fragment inputEstimatePredicatesFragment on Input {
|
202
173
|
... on InputCoin {
|
@@ -214,46 +185,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
|
|
214
185
|
}
|
215
186
|
}
|
216
187
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
217
|
-
var DryRunFailureStatusFragmentFragmentDoc = gql`
|
218
|
-
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
219
|
-
reason
|
220
|
-
programState {
|
221
|
-
returnType
|
222
|
-
data
|
223
|
-
}
|
224
|
-
}
|
225
|
-
`;
|
226
|
-
var DryRunSuccessStatusFragmentFragmentDoc = gql`
|
227
|
-
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
228
|
-
programState {
|
229
|
-
returnType
|
230
|
-
data
|
231
|
-
}
|
232
|
-
}
|
233
|
-
`;
|
234
|
-
var DryRunTransactionStatusFragmentFragmentDoc = gql`
|
235
|
-
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
236
|
-
... on DryRunFailureStatus {
|
237
|
-
...dryRunFailureStatusFragment
|
238
|
-
}
|
239
|
-
... on DryRunSuccessStatus {
|
240
|
-
...dryRunSuccessStatusFragment
|
241
|
-
}
|
242
|
-
}
|
243
|
-
${DryRunFailureStatusFragmentFragmentDoc}
|
244
|
-
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
245
|
-
var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
|
246
|
-
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
247
|
-
id
|
248
|
-
status {
|
249
|
-
...dryRunTransactionStatusFragment
|
250
|
-
}
|
251
|
-
receipts {
|
252
|
-
...receiptFragment
|
253
|
-
}
|
254
|
-
}
|
255
|
-
${DryRunTransactionStatusFragmentFragmentDoc}
|
256
|
-
${ReceiptFragmentFragmentDoc}`;
|
257
188
|
var CoinFragmentFragmentDoc = gql`
|
258
189
|
fragment coinFragment on Coin {
|
259
190
|
__typename
|
@@ -261,6 +192,7 @@ var CoinFragmentFragmentDoc = gql`
|
|
261
192
|
owner
|
262
193
|
amount
|
263
194
|
assetId
|
195
|
+
maturity
|
264
196
|
blockCreated
|
265
197
|
txCreatedIdx
|
266
198
|
}
|
@@ -299,32 +231,26 @@ var MessageProofFragmentFragmentDoc = gql`
|
|
299
231
|
messageBlockHeader {
|
300
232
|
id
|
301
233
|
daHeight
|
302
|
-
consensusParametersVersion
|
303
|
-
stateTransitionBytecodeVersion
|
304
234
|
transactionsCount
|
305
|
-
messageReceiptCount
|
306
235
|
transactionsRoot
|
307
|
-
messageOutboxRoot
|
308
|
-
eventInboxRoot
|
309
236
|
height
|
310
237
|
prevRoot
|
311
238
|
time
|
312
239
|
applicationHash
|
240
|
+
messageReceiptRoot
|
241
|
+
messageReceiptCount
|
313
242
|
}
|
314
243
|
commitBlockHeader {
|
315
244
|
id
|
316
245
|
daHeight
|
317
|
-
consensusParametersVersion
|
318
|
-
stateTransitionBytecodeVersion
|
319
246
|
transactionsCount
|
320
|
-
messageReceiptCount
|
321
247
|
transactionsRoot
|
322
|
-
messageOutboxRoot
|
323
|
-
eventInboxRoot
|
324
248
|
height
|
325
249
|
prevRoot
|
326
250
|
time
|
327
251
|
applicationHash
|
252
|
+
messageReceiptRoot
|
253
|
+
messageReceiptCount
|
328
254
|
}
|
329
255
|
sender
|
330
256
|
recipient
|
@@ -343,8 +269,8 @@ var BalanceFragmentFragmentDoc = gql`
|
|
343
269
|
var BlockFragmentFragmentDoc = gql`
|
344
270
|
fragment blockFragment on Block {
|
345
271
|
id
|
346
|
-
height
|
347
272
|
header {
|
273
|
+
height
|
348
274
|
time
|
349
275
|
}
|
350
276
|
transactions {
|
@@ -354,7 +280,6 @@ var BlockFragmentFragmentDoc = gql`
|
|
354
280
|
`;
|
355
281
|
var TxParametersFragmentFragmentDoc = gql`
|
356
282
|
fragment TxParametersFragment on TxParameters {
|
357
|
-
version
|
358
283
|
maxInputs
|
359
284
|
maxOutputs
|
360
285
|
maxWitnesses
|
@@ -364,7 +289,6 @@ var TxParametersFragmentFragmentDoc = gql`
|
|
364
289
|
`;
|
365
290
|
var PredicateParametersFragmentFragmentDoc = gql`
|
366
291
|
fragment PredicateParametersFragment on PredicateParameters {
|
367
|
-
version
|
368
292
|
maxPredicateLength
|
369
293
|
maxPredicateDataLength
|
370
294
|
maxGasPerPredicate
|
@@ -373,21 +297,18 @@ var PredicateParametersFragmentFragmentDoc = gql`
|
|
373
297
|
`;
|
374
298
|
var ScriptParametersFragmentFragmentDoc = gql`
|
375
299
|
fragment ScriptParametersFragment on ScriptParameters {
|
376
|
-
version
|
377
300
|
maxScriptLength
|
378
301
|
maxScriptDataLength
|
379
302
|
}
|
380
303
|
`;
|
381
304
|
var ContractParametersFragmentFragmentDoc = gql`
|
382
305
|
fragment ContractParametersFragment on ContractParameters {
|
383
|
-
version
|
384
306
|
contractMaxSize
|
385
307
|
maxStorageSlots
|
386
308
|
}
|
387
309
|
`;
|
388
310
|
var FeeParametersFragmentFragmentDoc = gql`
|
389
311
|
fragment FeeParametersFragment on FeeParameters {
|
390
|
-
version
|
391
312
|
gasPriceFactor
|
392
313
|
gasPerByte
|
393
314
|
}
|
@@ -407,7 +328,6 @@ var DependentCostFragmentFragmentDoc = gql`
|
|
407
328
|
`;
|
408
329
|
var GasCostsFragmentFragmentDoc = gql`
|
409
330
|
fragment GasCostsFragment on GasCosts {
|
410
|
-
version
|
411
331
|
add
|
412
332
|
addi
|
413
333
|
aloc
|
@@ -420,6 +340,7 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
420
340
|
cb
|
421
341
|
cfei
|
422
342
|
cfsi
|
343
|
+
croo
|
423
344
|
div
|
424
345
|
divi
|
425
346
|
ecr1
|
@@ -502,9 +423,6 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
502
423
|
ccp {
|
503
424
|
...DependentCostFragment
|
504
425
|
}
|
505
|
-
croo {
|
506
|
-
...DependentCostFragment
|
507
|
-
}
|
508
426
|
csiz {
|
509
427
|
...DependentCostFragment
|
510
428
|
}
|
@@ -564,7 +482,6 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
564
482
|
${DependentCostFragmentFragmentDoc}`;
|
565
483
|
var ConsensusParametersFragmentFragmentDoc = gql`
|
566
484
|
fragment consensusParametersFragment on ConsensusParameters {
|
567
|
-
version
|
568
485
|
txParams {
|
569
486
|
...TxParametersFragment
|
570
487
|
}
|
@@ -624,9 +541,18 @@ var NodeInfoFragmentFragmentDoc = gql`
|
|
624
541
|
fragment nodeInfoFragment on NodeInfo {
|
625
542
|
utxoValidation
|
626
543
|
vmBacktrace
|
544
|
+
minGasPrice
|
627
545
|
maxTx
|
628
546
|
maxDepth
|
629
547
|
nodeVersion
|
548
|
+
peers {
|
549
|
+
id
|
550
|
+
addresses
|
551
|
+
clientVersion
|
552
|
+
blockHeight
|
553
|
+
lastHeartbeatMs
|
554
|
+
appScore
|
555
|
+
}
|
630
556
|
}
|
631
557
|
`;
|
632
558
|
var GetVersionDocument = gql`
|
@@ -661,9 +587,13 @@ var GetTransactionWithReceiptsDocument = gql`
|
|
661
587
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
662
588
|
transaction(id: $transactionId) {
|
663
589
|
...transactionFragment
|
590
|
+
receipts {
|
591
|
+
...receiptFragment
|
592
|
+
}
|
664
593
|
}
|
665
594
|
}
|
666
|
-
${TransactionFragmentFragmentDoc}
|
595
|
+
${TransactionFragmentFragmentDoc}
|
596
|
+
${ReceiptFragmentFragmentDoc}`;
|
667
597
|
var GetTransactionsDocument = gql`
|
668
598
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
669
599
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -791,20 +721,6 @@ var GetBalanceDocument = gql`
|
|
791
721
|
}
|
792
722
|
}
|
793
723
|
${BalanceFragmentFragmentDoc}`;
|
794
|
-
var GetLatestGasPriceDocument = gql`
|
795
|
-
query getLatestGasPrice {
|
796
|
-
latestGasPrice {
|
797
|
-
gasPrice
|
798
|
-
}
|
799
|
-
}
|
800
|
-
`;
|
801
|
-
var EstimateGasPriceDocument = gql`
|
802
|
-
query estimateGasPrice($blockHorizon: U32!) {
|
803
|
-
estimateGasPrice(blockHorizon: $blockHorizon) {
|
804
|
-
gasPrice
|
805
|
-
}
|
806
|
-
}
|
807
|
-
`;
|
808
724
|
var GetBalancesDocument = gql`
|
809
725
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
810
726
|
balances(
|
@@ -859,12 +775,12 @@ var GetMessageStatusDocument = gql`
|
|
859
775
|
}
|
860
776
|
`;
|
861
777
|
var DryRunDocument = gql`
|
862
|
-
mutation dryRun($
|
863
|
-
dryRun(
|
864
|
-
...
|
778
|
+
mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
|
779
|
+
dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
|
780
|
+
...receiptFragment
|
865
781
|
}
|
866
782
|
}
|
867
|
-
${
|
783
|
+
${ReceiptFragmentFragmentDoc}`;
|
868
784
|
var SubmitDocument = gql`
|
869
785
|
mutation submit($encodedTransaction: HexString!) {
|
870
786
|
submit(tx: $encodedTransaction) {
|
@@ -883,17 +799,17 @@ var ProduceBlocksDocument = gql`
|
|
883
799
|
var SubmitAndAwaitDocument = gql`
|
884
800
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
885
801
|
submitAndAwait(tx: $encodedTransaction) {
|
886
|
-
...
|
802
|
+
...transactionStatusFragment
|
887
803
|
}
|
888
804
|
}
|
889
|
-
${
|
805
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
890
806
|
var StatusChangeDocument = gql`
|
891
807
|
subscription statusChange($transactionId: TransactionId!) {
|
892
808
|
statusChange(id: $transactionId) {
|
893
|
-
...
|
809
|
+
...transactionStatusFragment
|
894
810
|
}
|
895
811
|
}
|
896
|
-
${
|
812
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
897
813
|
function getSdk(requester) {
|
898
814
|
return {
|
899
815
|
getVersion(variables, options) {
|
@@ -947,12 +863,6 @@ function getSdk(requester) {
|
|
947
863
|
getBalance(variables, options) {
|
948
864
|
return requester(GetBalanceDocument, variables, options);
|
949
865
|
},
|
950
|
-
getLatestGasPrice(variables, options) {
|
951
|
-
return requester(GetLatestGasPriceDocument, variables, options);
|
952
|
-
},
|
953
|
-
estimateGasPrice(variables, options) {
|
954
|
-
return requester(EstimateGasPriceDocument, variables, options);
|
955
|
-
},
|
956
866
|
getBalances(variables, options) {
|
957
867
|
return requester(GetBalancesDocument, variables, options);
|
958
868
|
},
|
@@ -1146,9 +1056,10 @@ var inputify = (value) => {
|
|
1146
1056
|
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
1147
1057
|
},
|
1148
1058
|
witnessIndex: value.witnessIndex,
|
1059
|
+
maturity: value.maturity ?? 0,
|
1149
1060
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1150
|
-
predicateLength:
|
1151
|
-
predicateDataLength:
|
1061
|
+
predicateLength: predicate.length,
|
1062
|
+
predicateDataLength: predicateData.length,
|
1152
1063
|
predicate: hexlify3(predicate),
|
1153
1064
|
predicateData: hexlify3(predicateData)
|
1154
1065
|
};
|
@@ -1179,8 +1090,8 @@ var inputify = (value) => {
|
|
1179
1090
|
nonce: hexlify3(value.nonce),
|
1180
1091
|
witnessIndex: value.witnessIndex,
|
1181
1092
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1182
|
-
predicateLength:
|
1183
|
-
predicateDataLength:
|
1093
|
+
predicateLength: predicate.length,
|
1094
|
+
predicateDataLength: predicateData.length,
|
1184
1095
|
predicate: hexlify3(predicate),
|
1185
1096
|
predicateData: hexlify3(predicateData),
|
1186
1097
|
data: hexlify3(data),
|
@@ -1310,8 +1221,8 @@ function assembleReceiptByType(receipt) {
|
|
1310
1221
|
case "CALL" /* Call */: {
|
1311
1222
|
const callReceipt = {
|
1312
1223
|
type: ReceiptType.Call,
|
1313
|
-
from: hexOrZero(receipt.id
|
1314
|
-
to: hexOrZero(receipt?.to),
|
1224
|
+
from: hexOrZero(receipt.contract?.id),
|
1225
|
+
to: hexOrZero(receipt?.to?.id),
|
1315
1226
|
amount: bn4(receipt.amount),
|
1316
1227
|
assetId: hexOrZero(receipt.assetId),
|
1317
1228
|
gas: bn4(receipt.gas),
|
@@ -1325,7 +1236,7 @@ function assembleReceiptByType(receipt) {
|
|
1325
1236
|
case "RETURN" /* Return */: {
|
1326
1237
|
const returnReceipt = {
|
1327
1238
|
type: ReceiptType.Return,
|
1328
|
-
id: hexOrZero(receipt.id
|
1239
|
+
id: hexOrZero(receipt.contract?.id),
|
1329
1240
|
val: bn4(receipt.val),
|
1330
1241
|
pc: bn4(receipt.pc),
|
1331
1242
|
is: bn4(receipt.is)
|
@@ -1335,7 +1246,7 @@ function assembleReceiptByType(receipt) {
|
|
1335
1246
|
case "RETURN_DATA" /* ReturnData */: {
|
1336
1247
|
const returnDataReceipt = {
|
1337
1248
|
type: ReceiptType.ReturnData,
|
1338
|
-
id: hexOrZero(receipt.id
|
1249
|
+
id: hexOrZero(receipt.contract?.id),
|
1339
1250
|
ptr: bn4(receipt.ptr),
|
1340
1251
|
len: bn4(receipt.len),
|
1341
1252
|
digest: hexOrZero(receipt.digest),
|
@@ -1347,7 +1258,7 @@ function assembleReceiptByType(receipt) {
|
|
1347
1258
|
case "PANIC" /* Panic */: {
|
1348
1259
|
const panicReceipt = {
|
1349
1260
|
type: ReceiptType.Panic,
|
1350
|
-
id: hexOrZero(receipt.id),
|
1261
|
+
id: hexOrZero(receipt.contract?.id),
|
1351
1262
|
reason: bn4(receipt.reason),
|
1352
1263
|
pc: bn4(receipt.pc),
|
1353
1264
|
is: bn4(receipt.is),
|
@@ -1358,7 +1269,7 @@ function assembleReceiptByType(receipt) {
|
|
1358
1269
|
case "REVERT" /* Revert */: {
|
1359
1270
|
const revertReceipt = {
|
1360
1271
|
type: ReceiptType.Revert,
|
1361
|
-
id: hexOrZero(receipt.id
|
1272
|
+
id: hexOrZero(receipt.contract?.id),
|
1362
1273
|
val: bn4(receipt.ra),
|
1363
1274
|
pc: bn4(receipt.pc),
|
1364
1275
|
is: bn4(receipt.is)
|
@@ -1368,7 +1279,7 @@ function assembleReceiptByType(receipt) {
|
|
1368
1279
|
case "LOG" /* Log */: {
|
1369
1280
|
const logReceipt = {
|
1370
1281
|
type: ReceiptType.Log,
|
1371
|
-
id: hexOrZero(receipt.id
|
1282
|
+
id: hexOrZero(receipt.contract?.id),
|
1372
1283
|
val0: bn4(receipt.ra),
|
1373
1284
|
val1: bn4(receipt.rb),
|
1374
1285
|
val2: bn4(receipt.rc),
|
@@ -1381,7 +1292,7 @@ function assembleReceiptByType(receipt) {
|
|
1381
1292
|
case "LOG_DATA" /* LogData */: {
|
1382
1293
|
const logDataReceipt = {
|
1383
1294
|
type: ReceiptType.LogData,
|
1384
|
-
id: hexOrZero(receipt.id
|
1295
|
+
id: hexOrZero(receipt.contract?.id),
|
1385
1296
|
val0: bn4(receipt.ra),
|
1386
1297
|
val1: bn4(receipt.rb),
|
1387
1298
|
ptr: bn4(receipt.ptr),
|
@@ -1395,8 +1306,8 @@ function assembleReceiptByType(receipt) {
|
|
1395
1306
|
case "TRANSFER" /* Transfer */: {
|
1396
1307
|
const transferReceipt = {
|
1397
1308
|
type: ReceiptType.Transfer,
|
1398
|
-
from: hexOrZero(receipt.id
|
1399
|
-
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1309
|
+
from: hexOrZero(receipt.contract?.id),
|
1310
|
+
to: hexOrZero(receipt.toAddress || receipt?.to?.id),
|
1400
1311
|
amount: bn4(receipt.amount),
|
1401
1312
|
assetId: hexOrZero(receipt.assetId),
|
1402
1313
|
pc: bn4(receipt.pc),
|
@@ -1407,8 +1318,8 @@ function assembleReceiptByType(receipt) {
|
|
1407
1318
|
case "TRANSFER_OUT" /* TransferOut */: {
|
1408
1319
|
const transferOutReceipt = {
|
1409
1320
|
type: ReceiptType.TransferOut,
|
1410
|
-
from: hexOrZero(receipt.id
|
1411
|
-
to: hexOrZero(receipt.toAddress || receipt.to),
|
1321
|
+
from: hexOrZero(receipt.contract?.id),
|
1322
|
+
to: hexOrZero(receipt.toAddress || receipt.to?.id),
|
1412
1323
|
amount: bn4(receipt.amount),
|
1413
1324
|
assetId: hexOrZero(receipt.assetId),
|
1414
1325
|
pc: bn4(receipt.pc),
|
@@ -1451,7 +1362,7 @@ function assembleReceiptByType(receipt) {
|
|
1451
1362
|
return receiptMessageOut;
|
1452
1363
|
}
|
1453
1364
|
case "MINT" /* Mint */: {
|
1454
|
-
const contractId = hexOrZero(receipt.id
|
1365
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
1455
1366
|
const subId = hexOrZero(receipt.subId);
|
1456
1367
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
1457
1368
|
const mintReceipt = {
|
@@ -1466,7 +1377,7 @@ function assembleReceiptByType(receipt) {
|
|
1466
1377
|
return mintReceipt;
|
1467
1378
|
}
|
1468
1379
|
case "BURN" /* Burn */: {
|
1469
|
-
const contractId = hexOrZero(receipt.id
|
1380
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
1470
1381
|
const subId = hexOrZero(receipt.subId);
|
1471
1382
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
1472
1383
|
const burnReceipt = {
|
@@ -1551,6 +1462,7 @@ var buildBlockExplorerUrl = (options = {}) => {
|
|
1551
1462
|
import { bn as bn5 } from "@fuel-ts/math";
|
1552
1463
|
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
1553
1464
|
import { arrayify as arrayify3 } from "@fuel-ts/utils";
|
1465
|
+
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1554
1466
|
var getGasUsedFromReceipts = (receipts) => {
|
1555
1467
|
const scriptResult = receipts.filter(
|
1556
1468
|
(receipt) => receipt.type === ReceiptType2.ScriptResult
|
@@ -1571,28 +1483,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
1571
1483
|
}
|
1572
1484
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
1573
1485
|
const witnessCache = [];
|
1574
|
-
const
|
1575
|
-
const isCoinOrMessage = "owner" in input || "sender" in input;
|
1576
|
-
if (isCoinOrMessage) {
|
1577
|
-
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1578
|
-
return true;
|
1579
|
-
}
|
1580
|
-
if (!witnessCache.includes(input.witnessIndex)) {
|
1581
|
-
witnessCache.push(input.witnessIndex);
|
1582
|
-
return true;
|
1583
|
-
}
|
1584
|
-
}
|
1585
|
-
return false;
|
1586
|
-
});
|
1587
|
-
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
1588
|
-
const totalGas = chargeableInputs.reduce((total, input) => {
|
1486
|
+
const totalGas = inputs.reduce((total, input) => {
|
1589
1487
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1590
1488
|
return total.add(
|
1591
|
-
|
1489
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
|
1592
1490
|
);
|
1593
1491
|
}
|
1594
|
-
|
1595
|
-
|
1492
|
+
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
1493
|
+
witnessCache.push(input.witnessIndex);
|
1494
|
+
return total.add(gasCosts.ecr1);
|
1495
|
+
}
|
1496
|
+
return total;
|
1497
|
+
}, bn5());
|
1596
1498
|
return totalGas;
|
1597
1499
|
}
|
1598
1500
|
function getMinGas(params) {
|
@@ -1604,20 +1506,12 @@ function getMinGas(params) {
|
|
1604
1506
|
return minGas;
|
1605
1507
|
}
|
1606
1508
|
function getMaxGas(params) {
|
1607
|
-
const {
|
1608
|
-
gasPerByte,
|
1609
|
-
witnessesLength,
|
1610
|
-
witnessLimit,
|
1611
|
-
minGas,
|
1612
|
-
gasLimit = bn5(0),
|
1613
|
-
maxGasPerTx
|
1614
|
-
} = params;
|
1509
|
+
const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
|
1615
1510
|
let remainingAllowedWitnessGas = bn5(0);
|
1616
1511
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
1617
1512
|
remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
1618
1513
|
}
|
1619
|
-
|
1620
|
-
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
1514
|
+
return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
1621
1515
|
}
|
1622
1516
|
function calculateMetadataGasForTxCreate({
|
1623
1517
|
gasCosts,
|
@@ -1639,10 +1533,6 @@ function calculateMetadataGasForTxScript({
|
|
1639
1533
|
}) {
|
1640
1534
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1641
1535
|
}
|
1642
|
-
var calculateGasFee = (params) => {
|
1643
|
-
const { gas, gasPrice, priceFactor, tip } = params;
|
1644
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1645
|
-
};
|
1646
1536
|
|
1647
1537
|
// src/providers/utils/json.ts
|
1648
1538
|
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
@@ -1799,7 +1689,7 @@ var witnessify = (value) => {
|
|
1799
1689
|
// src/providers/transaction-request/transaction-request.ts
|
1800
1690
|
var BaseTransactionRequest = class {
|
1801
1691
|
/** Gas price for transaction */
|
1802
|
-
|
1692
|
+
gasPrice;
|
1803
1693
|
/** Block until which tx cannot be included */
|
1804
1694
|
maturity;
|
1805
1695
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -1818,7 +1708,7 @@ var BaseTransactionRequest = class {
|
|
1818
1708
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
1819
1709
|
*/
|
1820
1710
|
constructor({
|
1821
|
-
|
1711
|
+
gasPrice,
|
1822
1712
|
maturity,
|
1823
1713
|
maxFee,
|
1824
1714
|
witnessLimit,
|
@@ -1826,7 +1716,7 @@ var BaseTransactionRequest = class {
|
|
1826
1716
|
outputs,
|
1827
1717
|
witnesses
|
1828
1718
|
} = {}) {
|
1829
|
-
this.
|
1719
|
+
this.gasPrice = bn7(gasPrice);
|
1830
1720
|
this.maturity = maturity ?? 0;
|
1831
1721
|
this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
|
1832
1722
|
this.maxFee = maxFee ? bn7(maxFee) : void 0;
|
@@ -1837,9 +1727,9 @@ var BaseTransactionRequest = class {
|
|
1837
1727
|
static getPolicyMeta(req) {
|
1838
1728
|
let policyTypes = 0;
|
1839
1729
|
const policies = [];
|
1840
|
-
if (req.
|
1841
|
-
policyTypes += PolicyType.
|
1842
|
-
policies.push({ data: req.
|
1730
|
+
if (req.gasPrice) {
|
1731
|
+
policyTypes += PolicyType.GasPrice;
|
1732
|
+
policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
|
1843
1733
|
}
|
1844
1734
|
if (req.witnessLimit) {
|
1845
1735
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -2023,11 +1913,13 @@ var BaseTransactionRequest = class {
|
|
2023
1913
|
* assetId, if one it was not added yet.
|
2024
1914
|
*
|
2025
1915
|
* @param coin - Coin resource.
|
1916
|
+
* @param predicate - Predicate bytes.
|
1917
|
+
* @param predicateData - Predicate data bytes.
|
2026
1918
|
*/
|
2027
|
-
addCoinInput(coin) {
|
1919
|
+
addCoinInput(coin, predicate) {
|
2028
1920
|
const { assetId, owner, amount } = coin;
|
2029
1921
|
let witnessIndex;
|
2030
|
-
if (
|
1922
|
+
if (predicate) {
|
2031
1923
|
witnessIndex = 0;
|
2032
1924
|
} else {
|
2033
1925
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -2042,7 +1934,8 @@ var BaseTransactionRequest = class {
|
|
2042
1934
|
amount,
|
2043
1935
|
assetId,
|
2044
1936
|
txPointer: "0x00000000000000000000000000000000",
|
2045
|
-
witnessIndex
|
1937
|
+
witnessIndex,
|
1938
|
+
predicate: predicate?.bytes
|
2046
1939
|
};
|
2047
1940
|
this.pushInput(input);
|
2048
1941
|
this.addChangeOutput(owner, assetId);
|
@@ -2052,12 +1945,14 @@ var BaseTransactionRequest = class {
|
|
2052
1945
|
* baseAssetId, if one it was not added yet.
|
2053
1946
|
*
|
2054
1947
|
* @param message - Message resource.
|
1948
|
+
* @param predicate - Predicate bytes.
|
1949
|
+
* @param predicateData - Predicate data bytes.
|
2055
1950
|
*/
|
2056
|
-
addMessageInput(message) {
|
1951
|
+
addMessageInput(message, predicate) {
|
2057
1952
|
const { recipient, sender, amount } = message;
|
2058
1953
|
const assetId = BaseAssetId2;
|
2059
1954
|
let witnessIndex;
|
2060
|
-
if (
|
1955
|
+
if (predicate) {
|
2061
1956
|
witnessIndex = 0;
|
2062
1957
|
} else {
|
2063
1958
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -2071,7 +1966,8 @@ var BaseTransactionRequest = class {
|
|
2071
1966
|
sender: sender.toB256(),
|
2072
1967
|
recipient: recipient.toB256(),
|
2073
1968
|
amount,
|
2074
|
-
witnessIndex
|
1969
|
+
witnessIndex,
|
1970
|
+
predicate: predicate?.bytes
|
2075
1971
|
};
|
2076
1972
|
this.pushInput(input);
|
2077
1973
|
this.addChangeOutput(recipient, assetId);
|
@@ -2102,6 +1998,32 @@ var BaseTransactionRequest = class {
|
|
2102
1998
|
resources.forEach((resource) => this.addResource(resource));
|
2103
1999
|
return this;
|
2104
2000
|
}
|
2001
|
+
/**
|
2002
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
2003
|
+
* outputs from the related assetIds.
|
2004
|
+
*
|
2005
|
+
* @param resources - The resources to add.
|
2006
|
+
* @returns This transaction.
|
2007
|
+
*/
|
2008
|
+
addPredicateResource(resource, predicate) {
|
2009
|
+
if (isCoin(resource)) {
|
2010
|
+
this.addCoinInput(resource, predicate);
|
2011
|
+
} else {
|
2012
|
+
this.addMessageInput(resource, predicate);
|
2013
|
+
}
|
2014
|
+
return this;
|
2015
|
+
}
|
2016
|
+
/**
|
2017
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
2018
|
+
* from the related assetIds.
|
2019
|
+
*
|
2020
|
+
* @param resources - The resources to add.
|
2021
|
+
* @returns This transaction.
|
2022
|
+
*/
|
2023
|
+
addPredicateResources(resources, predicate) {
|
2024
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
2025
|
+
return this;
|
2026
|
+
}
|
2105
2027
|
/**
|
2106
2028
|
* Adds a coin output to the transaction.
|
2107
2029
|
*
|
@@ -2181,7 +2103,7 @@ var BaseTransactionRequest = class {
|
|
2181
2103
|
}
|
2182
2104
|
calculateMaxGas(chainInfo, minGas) {
|
2183
2105
|
const { consensusParameters } = chainInfo;
|
2184
|
-
const { gasPerByte
|
2106
|
+
const { gasPerByte } = consensusParameters;
|
2185
2107
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2186
2108
|
(acc, wit) => acc + wit.dataLength,
|
2187
2109
|
0
|
@@ -2190,8 +2112,7 @@ var BaseTransactionRequest = class {
|
|
2190
2112
|
gasPerByte,
|
2191
2113
|
minGas,
|
2192
2114
|
witnessesLength,
|
2193
|
-
witnessLimit: this.witnessLimit
|
2194
|
-
maxGasPerTx
|
2115
|
+
witnessLimit: this.witnessLimit
|
2195
2116
|
});
|
2196
2117
|
}
|
2197
2118
|
/**
|
@@ -2209,20 +2130,17 @@ var BaseTransactionRequest = class {
|
|
2209
2130
|
});
|
2210
2131
|
const updateAssetInput = (assetId, quantity) => {
|
2211
2132
|
const assetInput = findAssetInput(assetId);
|
2212
|
-
let usedQuantity = quantity;
|
2213
|
-
if (assetId === BaseAssetId2) {
|
2214
|
-
usedQuantity = bn7("1000000000000000000");
|
2215
|
-
}
|
2216
2133
|
if (assetInput && "assetId" in assetInput) {
|
2217
2134
|
assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
|
2218
|
-
assetInput.amount =
|
2135
|
+
assetInput.amount = quantity;
|
2219
2136
|
} else {
|
2220
2137
|
this.addResources([
|
2221
2138
|
{
|
2222
2139
|
id: hexlify7(randomBytes(UTXO_ID_LEN2)),
|
2223
|
-
amount:
|
2140
|
+
amount: quantity,
|
2224
2141
|
assetId,
|
2225
2142
|
owner: resourcesOwner || Address.fromRandom(),
|
2143
|
+
maturity: 0,
|
2226
2144
|
blockCreated: bn7(1),
|
2227
2145
|
txCreatedIdx: bn7(1)
|
2228
2146
|
}
|
@@ -2254,7 +2172,7 @@ var BaseTransactionRequest = class {
|
|
2254
2172
|
toJSON() {
|
2255
2173
|
return normalizeJSON(this);
|
2256
2174
|
}
|
2257
|
-
|
2175
|
+
updatePredicateInputs(inputs) {
|
2258
2176
|
this.inputs.forEach((i) => {
|
2259
2177
|
let correspondingInput;
|
2260
2178
|
switch (i.type) {
|
@@ -2276,15 +2194,6 @@ var BaseTransactionRequest = class {
|
|
2276
2194
|
}
|
2277
2195
|
});
|
2278
2196
|
}
|
2279
|
-
shiftPredicateData() {
|
2280
|
-
this.inputs.forEach((input) => {
|
2281
|
-
if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
|
2282
|
-
input.predicateData = input.padPredicateData(
|
2283
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2284
|
-
);
|
2285
|
-
}
|
2286
|
-
});
|
2287
|
-
}
|
2288
2197
|
};
|
2289
2198
|
|
2290
2199
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2431,8 +2340,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2431
2340
|
return {
|
2432
2341
|
type: TransactionType3.Create,
|
2433
2342
|
...baseTransaction,
|
2343
|
+
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2434
2344
|
bytecodeWitnessIndex,
|
2435
|
-
storageSlotsCount:
|
2345
|
+
storageSlotsCount: storageSlots.length,
|
2436
2346
|
salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
|
2437
2347
|
storageSlots
|
2438
2348
|
};
|
@@ -2555,8 +2465,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2555
2465
|
type: TransactionType4.Script,
|
2556
2466
|
scriptGasLimit: this.gasLimit,
|
2557
2467
|
...super.getBaseTransaction(),
|
2558
|
-
scriptLength:
|
2559
|
-
scriptDataLength:
|
2468
|
+
scriptLength: script.length,
|
2469
|
+
scriptDataLength: scriptData.length,
|
2560
2470
|
receiptsRoot: ZeroBytes327,
|
2561
2471
|
script: hexlify10(script),
|
2562
2472
|
scriptData: hexlify10(scriptData)
|
@@ -2620,7 +2530,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2620
2530
|
}
|
2621
2531
|
calculateMaxGas(chainInfo, minGas) {
|
2622
2532
|
const { consensusParameters } = chainInfo;
|
2623
|
-
const { gasPerByte
|
2533
|
+
const { gasPerByte } = consensusParameters;
|
2624
2534
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2625
2535
|
(acc, wit) => acc + wit.dataLength,
|
2626
2536
|
0
|
@@ -2630,8 +2540,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2630
2540
|
minGas,
|
2631
2541
|
witnessesLength,
|
2632
2542
|
witnessLimit: this.witnessLimit,
|
2633
|
-
gasLimit: this.gasLimit
|
2634
|
-
maxGasPerTx
|
2543
|
+
gasLimit: this.gasLimit
|
2635
2544
|
});
|
2636
2545
|
}
|
2637
2546
|
/**
|
@@ -2688,7 +2597,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2688
2597
|
|
2689
2598
|
// src/providers/transaction-request/utils.ts
|
2690
2599
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2691
|
-
import { TransactionType as TransactionType5
|
2600
|
+
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2692
2601
|
var transactionRequestify = (obj) => {
|
2693
2602
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2694
2603
|
return obj;
|
@@ -2706,31 +2615,14 @@ var transactionRequestify = (obj) => {
|
|
2706
2615
|
}
|
2707
2616
|
}
|
2708
2617
|
};
|
2709
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2710
|
-
(acc, input) => {
|
2711
|
-
if (input.type === InputType5.Coin && input.owner === owner) {
|
2712
|
-
acc.utxos.push(input.id);
|
2713
|
-
}
|
2714
|
-
if (input.type === InputType5.Message && input.recipient === owner) {
|
2715
|
-
acc.messages.push(input.nonce);
|
2716
|
-
}
|
2717
|
-
return acc;
|
2718
|
-
},
|
2719
|
-
{
|
2720
|
-
utxos: [],
|
2721
|
-
messages: []
|
2722
|
-
}
|
2723
|
-
);
|
2724
2618
|
|
2725
2619
|
// src/providers/transaction-response/transaction-response.ts
|
2726
2620
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2727
|
-
import { bn as
|
2621
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
2728
2622
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2729
2623
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2730
2624
|
|
2731
2625
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2732
|
-
import { bn as bn14 } from "@fuel-ts/math";
|
2733
|
-
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2734
2626
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2735
2627
|
|
2736
2628
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
@@ -2739,10 +2631,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
|
|
2739
2631
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2740
2632
|
var calculateTransactionFee = (params) => {
|
2741
2633
|
const {
|
2742
|
-
|
2634
|
+
gasUsed,
|
2743
2635
|
rawPayload,
|
2744
|
-
|
2745
|
-
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2636
|
+
consensusParameters: { gasCosts, feeParams }
|
2746
2637
|
} = params;
|
2747
2638
|
const gasPerByte = bn11(feeParams.gasPerByte);
|
2748
2639
|
const gasPriceFactor = bn11(feeParams.gasPriceFactor);
|
@@ -2752,7 +2643,8 @@ var calculateTransactionFee = (params) => {
|
|
2752
2643
|
return {
|
2753
2644
|
fee: bn11(0),
|
2754
2645
|
minFee: bn11(0),
|
2755
|
-
maxFee: bn11(0)
|
2646
|
+
maxFee: bn11(0),
|
2647
|
+
feeFromGasUsed: bn11(0)
|
2756
2648
|
};
|
2757
2649
|
}
|
2758
2650
|
const { type, witnesses, inputs, policies } = transaction;
|
@@ -2784,6 +2676,7 @@ var calculateTransactionFee = (params) => {
|
|
2784
2676
|
metadataGas,
|
2785
2677
|
txBytesSize: transactionBytes.length
|
2786
2678
|
});
|
2679
|
+
const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
|
2787
2680
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
|
2788
2681
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2789
2682
|
const maxGas = getMaxGas({
|
@@ -2791,25 +2684,17 @@ var calculateTransactionFee = (params) => {
|
|
2791
2684
|
minGas,
|
2792
2685
|
witnessesLength,
|
2793
2686
|
gasLimit,
|
2794
|
-
witnessLimit
|
2795
|
-
maxGasPerTx
|
2796
|
-
});
|
2797
|
-
const minFee = calculateGasFee({
|
2798
|
-
gasPrice,
|
2799
|
-
gas: minGas,
|
2800
|
-
priceFactor: gasPriceFactor,
|
2801
|
-
tip
|
2802
|
-
});
|
2803
|
-
const maxFee = calculateGasFee({
|
2804
|
-
gasPrice,
|
2805
|
-
gas: maxGas,
|
2806
|
-
priceFactor: gasPriceFactor,
|
2807
|
-
tip
|
2687
|
+
witnessLimit
|
2808
2688
|
});
|
2689
|
+
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
2690
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
2691
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
2692
|
+
const fee = minFee.add(feeFromGasUsed);
|
2809
2693
|
return {
|
2694
|
+
fee,
|
2810
2695
|
minFee,
|
2811
2696
|
maxFee,
|
2812
|
-
|
2697
|
+
feeFromGasUsed
|
2813
2698
|
};
|
2814
2699
|
};
|
2815
2700
|
|
@@ -2865,7 +2750,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2865
2750
|
|
2866
2751
|
// src/providers/transaction-summary/input.ts
|
2867
2752
|
import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2868
|
-
import { InputType as
|
2753
|
+
import { InputType as InputType5 } from "@fuel-ts/transactions";
|
2869
2754
|
function getInputsByTypes(inputs, types) {
|
2870
2755
|
return inputs.filter((i) => types.includes(i.type));
|
2871
2756
|
}
|
@@ -2873,16 +2758,16 @@ function getInputsByType(inputs, type) {
|
|
2873
2758
|
return inputs.filter((i) => i.type === type);
|
2874
2759
|
}
|
2875
2760
|
function getInputsCoin(inputs) {
|
2876
|
-
return getInputsByType(inputs,
|
2761
|
+
return getInputsByType(inputs, InputType5.Coin);
|
2877
2762
|
}
|
2878
2763
|
function getInputsMessage(inputs) {
|
2879
|
-
return getInputsByType(inputs,
|
2764
|
+
return getInputsByType(inputs, InputType5.Message);
|
2880
2765
|
}
|
2881
2766
|
function getInputsCoinAndMessage(inputs) {
|
2882
|
-
return getInputsByTypes(inputs, [
|
2767
|
+
return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
|
2883
2768
|
}
|
2884
2769
|
function getInputsContract(inputs) {
|
2885
|
-
return getInputsByType(inputs,
|
2770
|
+
return getInputsByType(inputs, InputType5.Contract);
|
2886
2771
|
}
|
2887
2772
|
function getInputFromAssetId(inputs, assetId) {
|
2888
2773
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2901,7 +2786,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2901
2786
|
if (!contractInput) {
|
2902
2787
|
return void 0;
|
2903
2788
|
}
|
2904
|
-
if (contractInput.type !==
|
2789
|
+
if (contractInput.type !== InputType5.Contract) {
|
2905
2790
|
throw new FuelError9(
|
2906
2791
|
ErrorCode9.INVALID_TRANSACTION_INPUT,
|
2907
2792
|
`Contract input should be of type 'contract'.`
|
@@ -2910,10 +2795,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2910
2795
|
return contractInput;
|
2911
2796
|
}
|
2912
2797
|
function getInputAccountAddress(input) {
|
2913
|
-
if (input.type ===
|
2798
|
+
if (input.type === InputType5.Coin) {
|
2914
2799
|
return input.owner.toString();
|
2915
2800
|
}
|
2916
|
-
if (input.type ===
|
2801
|
+
if (input.type === InputType5.Message) {
|
2917
2802
|
return input.recipient.toString();
|
2918
2803
|
}
|
2919
2804
|
return "";
|
@@ -3423,9 +3308,7 @@ function assembleTransactionSummary(params) {
|
|
3423
3308
|
gqlTransactionStatus,
|
3424
3309
|
abiMap = {},
|
3425
3310
|
maxInputs,
|
3426
|
-
gasCosts
|
3427
|
-
maxGasPerTx,
|
3428
|
-
gasPrice
|
3311
|
+
gasCosts
|
3429
3312
|
} = params;
|
3430
3313
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3431
3314
|
const rawPayload = hexlify11(transactionBytes);
|
@@ -3439,14 +3322,11 @@ function assembleTransactionSummary(params) {
|
|
3439
3322
|
maxInputs
|
3440
3323
|
});
|
3441
3324
|
const typeName = getTransactionTypeName(transaction.type);
|
3442
|
-
const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3443
3325
|
const { fee } = calculateTransactionFee({
|
3444
|
-
|
3326
|
+
gasUsed,
|
3445
3327
|
rawPayload,
|
3446
|
-
tip,
|
3447
3328
|
consensusParameters: {
|
3448
3329
|
gasCosts,
|
3449
|
-
maxGasPerTx,
|
3450
3330
|
feeParams: {
|
3451
3331
|
gasPerByte,
|
3452
3332
|
gasPriceFactor
|
@@ -3506,7 +3386,7 @@ var TransactionResponse = class {
|
|
3506
3386
|
/** Current provider */
|
3507
3387
|
provider;
|
3508
3388
|
/** Gas used on the transaction */
|
3509
|
-
gasUsed =
|
3389
|
+
gasUsed = bn14(0);
|
3510
3390
|
/** The graphql Transaction with receipts object. */
|
3511
3391
|
gqlTransaction;
|
3512
3392
|
abis;
|
@@ -3584,13 +3464,8 @@ var TransactionResponse = class {
|
|
3584
3464
|
const decodedTransaction = this.decodeTransaction(
|
3585
3465
|
transaction
|
3586
3466
|
);
|
3587
|
-
|
3588
|
-
|
3589
|
-
txReceipts = transaction.status.receipts;
|
3590
|
-
}
|
3591
|
-
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3592
|
-
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3593
|
-
const gasPrice = await this.provider.getLatestGasPrice();
|
3467
|
+
const receipts = transaction.receipts?.map(processGqlReceipt) || [];
|
3468
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
|
3594
3469
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3595
3470
|
const transactionSummary = assembleTransactionSummary({
|
3596
3471
|
id: this.id,
|
@@ -3602,9 +3477,7 @@ var TransactionResponse = class {
|
|
3602
3477
|
gasPriceFactor,
|
3603
3478
|
abiMap: contractsAbiMap,
|
3604
3479
|
maxInputs,
|
3605
|
-
gasCosts
|
3606
|
-
maxGasPerTx,
|
3607
|
-
gasPrice
|
3480
|
+
gasCosts
|
3608
3481
|
});
|
3609
3482
|
return transactionSummary;
|
3610
3483
|
}
|
@@ -3731,29 +3604,29 @@ var processGqlChain = (chain) => {
|
|
3731
3604
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3732
3605
|
return {
|
3733
3606
|
name,
|
3734
|
-
baseChainHeight:
|
3607
|
+
baseChainHeight: bn15(daHeight),
|
3735
3608
|
consensusParameters: {
|
3736
|
-
contractMaxSize:
|
3737
|
-
maxInputs:
|
3738
|
-
maxOutputs:
|
3739
|
-
maxWitnesses:
|
3740
|
-
maxGasPerTx:
|
3741
|
-
maxScriptLength:
|
3742
|
-
maxScriptDataLength:
|
3743
|
-
maxStorageSlots:
|
3744
|
-
maxPredicateLength:
|
3745
|
-
maxPredicateDataLength:
|
3746
|
-
maxGasPerPredicate:
|
3747
|
-
gasPriceFactor:
|
3748
|
-
gasPerByte:
|
3749
|
-
maxMessageDataLength:
|
3750
|
-
chainId:
|
3609
|
+
contractMaxSize: bn15(contractParams.contractMaxSize),
|
3610
|
+
maxInputs: bn15(txParams.maxInputs),
|
3611
|
+
maxOutputs: bn15(txParams.maxOutputs),
|
3612
|
+
maxWitnesses: bn15(txParams.maxWitnesses),
|
3613
|
+
maxGasPerTx: bn15(txParams.maxGasPerTx),
|
3614
|
+
maxScriptLength: bn15(scriptParams.maxScriptLength),
|
3615
|
+
maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
|
3616
|
+
maxStorageSlots: bn15(contractParams.maxStorageSlots),
|
3617
|
+
maxPredicateLength: bn15(predicateParams.maxPredicateLength),
|
3618
|
+
maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
|
3619
|
+
maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
|
3620
|
+
gasPriceFactor: bn15(feeParams.gasPriceFactor),
|
3621
|
+
gasPerByte: bn15(feeParams.gasPerByte),
|
3622
|
+
maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
|
3623
|
+
chainId: bn15(consensusParameters.chainId),
|
3751
3624
|
gasCosts
|
3752
3625
|
},
|
3753
3626
|
gasCosts,
|
3754
3627
|
latestBlock: {
|
3755
3628
|
id: latestBlock.id,
|
3756
|
-
height:
|
3629
|
+
height: bn15(latestBlock.header.height),
|
3757
3630
|
time: latestBlock.header.time,
|
3758
3631
|
transactions: latestBlock.transactions.map((i) => ({
|
3759
3632
|
id: i.id
|
@@ -3847,8 +3720,10 @@ var _Provider = class {
|
|
3847
3720
|
* Returns some helpful parameters related to gas fees.
|
3848
3721
|
*/
|
3849
3722
|
getGasConfig() {
|
3723
|
+
const { minGasPrice } = this.getNode();
|
3850
3724
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3851
3725
|
return {
|
3726
|
+
minGasPrice,
|
3852
3727
|
maxGasPerTx,
|
3853
3728
|
maxGasPerPredicate,
|
3854
3729
|
gasPriceFactor,
|
@@ -3946,7 +3821,7 @@ var _Provider = class {
|
|
3946
3821
|
*/
|
3947
3822
|
async getBlockNumber() {
|
3948
3823
|
const { chain } = await this.operations.getChain();
|
3949
|
-
return
|
3824
|
+
return bn15(chain.latestBlock.header.height, 10);
|
3950
3825
|
}
|
3951
3826
|
/**
|
3952
3827
|
* Returns the chain information.
|
@@ -3956,11 +3831,13 @@ var _Provider = class {
|
|
3956
3831
|
async fetchNode() {
|
3957
3832
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3958
3833
|
const processedNodeInfo = {
|
3959
|
-
maxDepth:
|
3960
|
-
maxTx:
|
3834
|
+
maxDepth: bn15(nodeInfo.maxDepth),
|
3835
|
+
maxTx: bn15(nodeInfo.maxTx),
|
3836
|
+
minGasPrice: bn15(nodeInfo.minGasPrice),
|
3961
3837
|
nodeVersion: nodeInfo.nodeVersion,
|
3962
3838
|
utxoValidation: nodeInfo.utxoValidation,
|
3963
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
3839
|
+
vmBacktrace: nodeInfo.vmBacktrace,
|
3840
|
+
peers: nodeInfo.peers
|
3964
3841
|
};
|
3965
3842
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
3966
3843
|
return processedNodeInfo;
|
@@ -4046,13 +3923,14 @@ var _Provider = class {
|
|
4046
3923
|
return this.estimateTxDependencies(transactionRequest);
|
4047
3924
|
}
|
4048
3925
|
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
4049
|
-
const { dryRun:
|
4050
|
-
|
3926
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3927
|
+
encodedTransaction,
|
4051
3928
|
utxoValidation: utxoValidation || false
|
4052
3929
|
});
|
4053
|
-
const
|
4054
|
-
|
4055
|
-
|
3930
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
3931
|
+
return {
|
3932
|
+
receipts
|
3933
|
+
};
|
4056
3934
|
}
|
4057
3935
|
/**
|
4058
3936
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -4078,7 +3956,7 @@ var _Provider = class {
|
|
4078
3956
|
} = response;
|
4079
3957
|
if (inputs) {
|
4080
3958
|
inputs.forEach((input, index) => {
|
4081
|
-
if ("predicateGasUsed" in input &&
|
3959
|
+
if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
|
4082
3960
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4083
3961
|
}
|
4084
3962
|
});
|
@@ -4091,6 +3969,9 @@ var _Provider = class {
|
|
4091
3969
|
* If there are missing variable outputs,
|
4092
3970
|
* `addVariableOutputs` is called on the transaction.
|
4093
3971
|
*
|
3972
|
+
* @privateRemarks
|
3973
|
+
* TODO: Investigate support for missing contract IDs
|
3974
|
+
* TODO: Add support for missing output messages
|
4094
3975
|
*
|
4095
3976
|
* @param transactionRequest - The transaction request object.
|
4096
3977
|
* @returns A promise.
|
@@ -4103,19 +3984,16 @@ var _Provider = class {
|
|
4103
3984
|
missingContractIds: []
|
4104
3985
|
};
|
4105
3986
|
}
|
3987
|
+
await this.estimatePredicates(transactionRequest);
|
4106
3988
|
let receipts = [];
|
4107
3989
|
const missingContractIds = [];
|
4108
3990
|
let outputVariables = 0;
|
4109
|
-
let dryrunStatus;
|
4110
3991
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
4111
|
-
const {
|
4112
|
-
|
4113
|
-
} = await this.operations.dryRun({
|
4114
|
-
encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
|
3992
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3993
|
+
encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
|
4115
3994
|
utxoValidation: false
|
4116
3995
|
});
|
4117
|
-
receipts =
|
4118
|
-
dryrunStatus = status;
|
3996
|
+
receipts = gqlReceipts.map(processGqlReceipt);
|
4119
3997
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
4120
3998
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
4121
3999
|
if (hasMissingOutputs) {
|
@@ -4125,10 +4003,6 @@ var _Provider = class {
|
|
4125
4003
|
transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
|
4126
4004
|
missingContractIds.push(contractId);
|
4127
4005
|
});
|
4128
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
4129
|
-
transactionRequest
|
4130
|
-
});
|
4131
|
-
transactionRequest.maxFee = maxFee;
|
4132
4006
|
} else {
|
4133
4007
|
break;
|
4134
4008
|
}
|
@@ -4136,139 +4010,37 @@ var _Provider = class {
|
|
4136
4010
|
return {
|
4137
4011
|
receipts,
|
4138
4012
|
outputVariables,
|
4139
|
-
missingContractIds
|
4140
|
-
dryrunStatus
|
4013
|
+
missingContractIds
|
4141
4014
|
};
|
4142
4015
|
}
|
4143
|
-
/**
|
4144
|
-
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
4145
|
-
*
|
4146
|
-
* Transactions are dry run in batches. After each dry run, transactions requiring
|
4147
|
-
* further modifications are identified. The method iteratively updates these transactions
|
4148
|
-
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
4149
|
-
*
|
4150
|
-
* @param transactionRequests - Array of transaction request objects.
|
4151
|
-
* @returns A promise that resolves to an array of results for each transaction.
|
4152
|
-
*/
|
4153
|
-
async estimateMultipleTxDependencies(transactionRequests) {
|
4154
|
-
const results = transactionRequests.map(() => ({
|
4155
|
-
receipts: [],
|
4156
|
-
outputVariables: 0,
|
4157
|
-
missingContractIds: [],
|
4158
|
-
dryrunStatus: void 0
|
4159
|
-
}));
|
4160
|
-
const allRequests = clone3(transactionRequests);
|
4161
|
-
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4162
|
-
allRequests.forEach((req, index) => {
|
4163
|
-
if (req.type === TransactionType8.Script) {
|
4164
|
-
serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
|
4165
|
-
}
|
4166
|
-
});
|
4167
|
-
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
4168
|
-
let attempt = 0;
|
4169
|
-
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
4170
|
-
const encodedTransactions = transactionsToProcess.map(
|
4171
|
-
(index) => serializedTransactionsMap.get(index)
|
4172
|
-
);
|
4173
|
-
const dryRunResults = await this.operations.dryRun({
|
4174
|
-
encodedTransactions,
|
4175
|
-
utxoValidation: false
|
4176
|
-
});
|
4177
|
-
const nextRoundTransactions = [];
|
4178
|
-
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
4179
|
-
const currentResultIndex = transactionsToProcess[i];
|
4180
|
-
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4181
|
-
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
4182
|
-
results[currentResultIndex].dryrunStatus = status;
|
4183
|
-
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4184
|
-
results[currentResultIndex].receipts
|
4185
|
-
);
|
4186
|
-
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4187
|
-
const requestToProcess = allRequests[currentResultIndex];
|
4188
|
-
if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
|
4189
|
-
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
4190
|
-
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
4191
|
-
missingOutputContractIds.forEach(({ contractId }) => {
|
4192
|
-
requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
|
4193
|
-
results[currentResultIndex].missingContractIds.push(contractId);
|
4194
|
-
});
|
4195
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
4196
|
-
transactionRequest: requestToProcess
|
4197
|
-
});
|
4198
|
-
requestToProcess.maxFee = maxFee;
|
4199
|
-
serializedTransactionsMap.set(
|
4200
|
-
currentResultIndex,
|
4201
|
-
hexlify12(requestToProcess.toTransactionBytes())
|
4202
|
-
);
|
4203
|
-
nextRoundTransactions.push(currentResultIndex);
|
4204
|
-
allRequests[currentResultIndex] = requestToProcess;
|
4205
|
-
}
|
4206
|
-
}
|
4207
|
-
transactionsToProcess = nextRoundTransactions;
|
4208
|
-
attempt += 1;
|
4209
|
-
}
|
4210
|
-
return results;
|
4211
|
-
}
|
4212
|
-
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
4213
|
-
if (estimateTxDependencies) {
|
4214
|
-
return this.estimateMultipleTxDependencies(transactionRequests);
|
4215
|
-
}
|
4216
|
-
const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
|
4217
|
-
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4218
|
-
encodedTransactions,
|
4219
|
-
utxoValidation: utxoValidation || false
|
4220
|
-
});
|
4221
|
-
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4222
|
-
const receipts = rawReceipts.map(processGqlReceipt);
|
4223
|
-
return { receipts, dryrunStatus: status };
|
4224
|
-
});
|
4225
|
-
return results;
|
4226
|
-
}
|
4227
4016
|
/**
|
4228
4017
|
* Estimates the transaction gas and fee based on the provided transaction request.
|
4229
4018
|
* @param transactionRequest - The transaction request object.
|
4230
4019
|
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
4231
4020
|
*/
|
4232
|
-
|
4021
|
+
estimateTxGasAndFee(params) {
|
4233
4022
|
const { transactionRequest } = params;
|
4234
|
-
|
4023
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
4235
4024
|
const chainInfo = this.getChain();
|
4236
|
-
const
|
4025
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
4026
|
+
transactionRequest.gasPrice = gasPrice;
|
4237
4027
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
4238
|
-
|
4239
|
-
gasPrice = await this.estimateGasPrice(10);
|
4240
|
-
}
|
4241
|
-
const minFee = calculateGasFee({
|
4242
|
-
gasPrice: bn16(gasPrice),
|
4243
|
-
gas: minGas,
|
4244
|
-
priceFactor: gasPriceFactor,
|
4245
|
-
tip: transactionRequest.tip
|
4246
|
-
}).add(1);
|
4247
|
-
let gasLimit = bn16(0);
|
4028
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4248
4029
|
if (transactionRequest.type === TransactionType8.Script) {
|
4249
|
-
gasLimit = transactionRequest.gasLimit;
|
4250
4030
|
if (transactionRequest.gasLimit.eq(0)) {
|
4251
4031
|
transactionRequest.gasLimit = minGas;
|
4252
4032
|
transactionRequest.gasLimit = maxGasPerTx.sub(
|
4253
4033
|
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
4254
4034
|
);
|
4255
|
-
gasLimit = transactionRequest.gasLimit;
|
4256
4035
|
}
|
4257
4036
|
}
|
4258
4037
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4259
|
-
const maxFee =
|
4260
|
-
gasPrice: bn16(gasPrice),
|
4261
|
-
gas: maxGas,
|
4262
|
-
priceFactor: gasPriceFactor,
|
4263
|
-
tip: transactionRequest.tip
|
4264
|
-
}).add(1);
|
4038
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4265
4039
|
return {
|
4266
4040
|
minGas,
|
4267
4041
|
minFee,
|
4268
4042
|
maxGas,
|
4269
|
-
maxFee
|
4270
|
-
gasPrice,
|
4271
|
-
gasLimit
|
4043
|
+
maxFee
|
4272
4044
|
};
|
4273
4045
|
}
|
4274
4046
|
/**
|
@@ -4286,17 +4058,15 @@ var _Provider = class {
|
|
4286
4058
|
if (estimateTxDependencies) {
|
4287
4059
|
return this.estimateTxDependencies(transactionRequest);
|
4288
4060
|
}
|
4289
|
-
const
|
4290
|
-
const { dryRun:
|
4291
|
-
|
4061
|
+
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
4062
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
4063
|
+
encodedTransaction,
|
4292
4064
|
utxoValidation: true
|
4293
4065
|
});
|
4294
|
-
const
|
4295
|
-
|
4296
|
-
|
4297
|
-
|
4298
|
-
});
|
4299
|
-
return { receipts: callResult[0].receipts };
|
4066
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
4067
|
+
return {
|
4068
|
+
receipts
|
4069
|
+
};
|
4300
4070
|
}
|
4301
4071
|
/**
|
4302
4072
|
* Returns a transaction cost to enable user
|
@@ -4313,79 +4083,77 @@ var _Provider = class {
|
|
4313
4083
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
4314
4084
|
* @returns A promise that resolves to the transaction cost object.
|
4315
4085
|
*/
|
4316
|
-
async getTransactionCost(transactionRequestLike,
|
4086
|
+
async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
|
4087
|
+
estimateTxDependencies = true,
|
4088
|
+
estimatePredicates = true,
|
4089
|
+
resourcesOwner,
|
4090
|
+
signatureCallback
|
4091
|
+
} = {}) {
|
4317
4092
|
const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
|
4093
|
+
const { minGasPrice } = this.getGasConfig();
|
4094
|
+
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
4318
4095
|
const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
|
4319
4096
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4320
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
4097
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
4321
4098
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
4322
|
-
txRequestClone.maxFee = bn16(0);
|
4323
4099
|
if (isScriptTransaction) {
|
4324
|
-
txRequestClone.gasLimit =
|
4100
|
+
txRequestClone.gasLimit = bn15(0);
|
4325
4101
|
}
|
4326
|
-
if (
|
4327
|
-
resourcesOwner
|
4102
|
+
if (estimatePredicates) {
|
4103
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4104
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
4105
|
+
}
|
4106
|
+
await this.estimatePredicates(txRequestClone);
|
4328
4107
|
}
|
4329
|
-
const signedRequest = clone3(txRequestClone);
|
4330
|
-
let addedSignatures = 0;
|
4331
4108
|
if (signatureCallback && isScriptTransaction) {
|
4332
|
-
|
4333
|
-
await signatureCallback(signedRequest);
|
4334
|
-
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
4109
|
+
await signatureCallback(txRequestClone);
|
4335
4110
|
}
|
4336
|
-
|
4337
|
-
|
4338
|
-
transactionRequest: signedRequest
|
4111
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
4112
|
+
transactionRequest: txRequestClone
|
4339
4113
|
});
|
4340
4114
|
let receipts = [];
|
4341
4115
|
let missingContractIds = [];
|
4342
4116
|
let outputVariables = 0;
|
4343
|
-
let gasUsed =
|
4344
|
-
|
4345
|
-
|
4346
|
-
if (isScriptTransaction) {
|
4347
|
-
txRequestClone.gasLimit = gasLimit;
|
4348
|
-
if (signatureCallback) {
|
4349
|
-
await signatureCallback(txRequestClone);
|
4350
|
-
}
|
4117
|
+
let gasUsed = bn15(0);
|
4118
|
+
if (isScriptTransaction && estimateTxDependencies) {
|
4119
|
+
txRequestClone.gasPrice = bn15(0);
|
4351
4120
|
const result = await this.estimateTxDependencies(txRequestClone);
|
4352
4121
|
receipts = result.receipts;
|
4353
4122
|
outputVariables = result.outputVariables;
|
4354
4123
|
missingContractIds = result.missingContractIds;
|
4355
4124
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4356
4125
|
txRequestClone.gasLimit = gasUsed;
|
4357
|
-
|
4358
|
-
|
4359
|
-
|
4126
|
+
txRequestClone.gasPrice = setGasPrice;
|
4127
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
4128
|
+
transactionRequest: txRequestClone
|
4360
4129
|
}));
|
4361
4130
|
}
|
4362
4131
|
return {
|
4363
4132
|
requiredQuantities: allQuantities,
|
4364
4133
|
receipts,
|
4365
4134
|
gasUsed,
|
4366
|
-
|
4135
|
+
minGasPrice,
|
4136
|
+
gasPrice: setGasPrice,
|
4367
4137
|
minGas,
|
4368
4138
|
maxGas,
|
4369
4139
|
minFee,
|
4370
4140
|
maxFee,
|
4141
|
+
estimatedInputs: txRequestClone.inputs,
|
4371
4142
|
outputVariables,
|
4372
|
-
missingContractIds
|
4373
|
-
addedSignatures,
|
4374
|
-
estimatedPredicates: txRequestClone.inputs
|
4143
|
+
missingContractIds
|
4375
4144
|
};
|
4376
4145
|
}
|
4377
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
4146
|
+
async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
|
4378
4147
|
const ownerAddress = Address2.fromAddressOrString(owner);
|
4379
4148
|
const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
|
4380
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
4381
|
-
quantitiesToContract
|
4382
|
-
});
|
4149
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
|
4383
4150
|
transactionRequest.addResources(
|
4384
4151
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
4385
4152
|
);
|
4386
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4387
|
-
|
4388
|
-
|
4153
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4154
|
+
transactionRequest,
|
4155
|
+
forwardingQuantities
|
4156
|
+
);
|
4389
4157
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
4390
4158
|
return {
|
4391
4159
|
resources,
|
@@ -4407,10 +4175,11 @@ var _Provider = class {
|
|
4407
4175
|
return coins.map((coin) => ({
|
4408
4176
|
id: coin.utxoId,
|
4409
4177
|
assetId: coin.assetId,
|
4410
|
-
amount:
|
4178
|
+
amount: bn15(coin.amount),
|
4411
4179
|
owner: Address2.fromAddressOrString(coin.owner),
|
4412
|
-
|
4413
|
-
|
4180
|
+
maturity: bn15(coin.maturity).toNumber(),
|
4181
|
+
blockCreated: bn15(coin.blockCreated),
|
4182
|
+
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4414
4183
|
}));
|
4415
4184
|
}
|
4416
4185
|
/**
|
@@ -4447,9 +4216,9 @@ var _Provider = class {
|
|
4447
4216
|
switch (coin.__typename) {
|
4448
4217
|
case "MessageCoin":
|
4449
4218
|
return {
|
4450
|
-
amount:
|
4219
|
+
amount: bn15(coin.amount),
|
4451
4220
|
assetId: coin.assetId,
|
4452
|
-
daHeight:
|
4221
|
+
daHeight: bn15(coin.daHeight),
|
4453
4222
|
sender: Address2.fromAddressOrString(coin.sender),
|
4454
4223
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4455
4224
|
nonce: coin.nonce
|
@@ -4457,11 +4226,12 @@ var _Provider = class {
|
|
4457
4226
|
case "Coin":
|
4458
4227
|
return {
|
4459
4228
|
id: coin.utxoId,
|
4460
|
-
amount:
|
4229
|
+
amount: bn15(coin.amount),
|
4461
4230
|
assetId: coin.assetId,
|
4462
4231
|
owner: Address2.fromAddressOrString(coin.owner),
|
4463
|
-
|
4464
|
-
|
4232
|
+
maturity: bn15(coin.maturity).toNumber(),
|
4233
|
+
blockCreated: bn15(coin.blockCreated),
|
4234
|
+
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4465
4235
|
};
|
4466
4236
|
default:
|
4467
4237
|
return null;
|
@@ -4478,13 +4248,13 @@ var _Provider = class {
|
|
4478
4248
|
async getBlock(idOrHeight) {
|
4479
4249
|
let variables;
|
4480
4250
|
if (typeof idOrHeight === "number") {
|
4481
|
-
variables = { height:
|
4251
|
+
variables = { height: bn15(idOrHeight).toString(10) };
|
4482
4252
|
} else if (idOrHeight === "latest") {
|
4483
4253
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4484
4254
|
} else if (idOrHeight.length === 66) {
|
4485
4255
|
variables = { blockId: idOrHeight };
|
4486
4256
|
} else {
|
4487
|
-
variables = { blockId:
|
4257
|
+
variables = { blockId: bn15(idOrHeight).toString(10) };
|
4488
4258
|
}
|
4489
4259
|
const { block } = await this.operations.getBlock(variables);
|
4490
4260
|
if (!block) {
|
@@ -4492,7 +4262,7 @@ var _Provider = class {
|
|
4492
4262
|
}
|
4493
4263
|
return {
|
4494
4264
|
id: block.id,
|
4495
|
-
height:
|
4265
|
+
height: bn15(block.header.height),
|
4496
4266
|
time: block.header.time,
|
4497
4267
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4498
4268
|
};
|
@@ -4507,7 +4277,7 @@ var _Provider = class {
|
|
4507
4277
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4508
4278
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4509
4279
|
id: block.id,
|
4510
|
-
height:
|
4280
|
+
height: bn15(block.header.height),
|
4511
4281
|
time: block.header.time,
|
4512
4282
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4513
4283
|
}));
|
@@ -4522,7 +4292,7 @@ var _Provider = class {
|
|
4522
4292
|
async getBlockWithTransactions(idOrHeight) {
|
4523
4293
|
let variables;
|
4524
4294
|
if (typeof idOrHeight === "number") {
|
4525
|
-
variables = { blockHeight:
|
4295
|
+
variables = { blockHeight: bn15(idOrHeight).toString(10) };
|
4526
4296
|
} else if (idOrHeight === "latest") {
|
4527
4297
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4528
4298
|
} else {
|
@@ -4534,7 +4304,7 @@ var _Provider = class {
|
|
4534
4304
|
}
|
4535
4305
|
return {
|
4536
4306
|
id: block.id,
|
4537
|
-
height:
|
4307
|
+
height: bn15(block.header.height, 10),
|
4538
4308
|
time: block.header.time,
|
4539
4309
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4540
4310
|
transactions: block.transactions.map(
|
@@ -4583,7 +4353,7 @@ var _Provider = class {
|
|
4583
4353
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4584
4354
|
asset: hexlify12(assetId)
|
4585
4355
|
});
|
4586
|
-
return
|
4356
|
+
return bn15(contractBalance.amount, 10);
|
4587
4357
|
}
|
4588
4358
|
/**
|
4589
4359
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4597,7 +4367,7 @@ var _Provider = class {
|
|
4597
4367
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4598
4368
|
assetId: hexlify12(assetId)
|
4599
4369
|
});
|
4600
|
-
return
|
4370
|
+
return bn15(balance.amount, 10);
|
4601
4371
|
}
|
4602
4372
|
/**
|
4603
4373
|
* Returns balances for the given owner.
|
@@ -4615,7 +4385,7 @@ var _Provider = class {
|
|
4615
4385
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4616
4386
|
return balances.map((balance) => ({
|
4617
4387
|
assetId: balance.assetId,
|
4618
|
-
amount:
|
4388
|
+
amount: bn15(balance.amount)
|
4619
4389
|
}));
|
4620
4390
|
}
|
4621
4391
|
/**
|
@@ -4637,15 +4407,15 @@ var _Provider = class {
|
|
4637
4407
|
sender: message.sender,
|
4638
4408
|
recipient: message.recipient,
|
4639
4409
|
nonce: message.nonce,
|
4640
|
-
amount:
|
4410
|
+
amount: bn15(message.amount),
|
4641
4411
|
data: message.data
|
4642
4412
|
}),
|
4643
4413
|
sender: Address2.fromAddressOrString(message.sender),
|
4644
4414
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4645
4415
|
nonce: message.nonce,
|
4646
|
-
amount:
|
4416
|
+
amount: bn15(message.amount),
|
4647
4417
|
data: InputMessageCoder.decodeData(message.data),
|
4648
|
-
daHeight:
|
4418
|
+
daHeight: bn15(message.daHeight)
|
4649
4419
|
}));
|
4650
4420
|
}
|
4651
4421
|
/**
|
@@ -4698,60 +4468,44 @@ var _Provider = class {
|
|
4698
4468
|
} = result.messageProof;
|
4699
4469
|
return {
|
4700
4470
|
messageProof: {
|
4701
|
-
proofIndex:
|
4471
|
+
proofIndex: bn15(messageProof.proofIndex),
|
4702
4472
|
proofSet: messageProof.proofSet
|
4703
4473
|
},
|
4704
4474
|
blockProof: {
|
4705
|
-
proofIndex:
|
4475
|
+
proofIndex: bn15(blockProof.proofIndex),
|
4706
4476
|
proofSet: blockProof.proofSet
|
4707
4477
|
},
|
4708
4478
|
messageBlockHeader: {
|
4709
4479
|
id: messageBlockHeader.id,
|
4710
|
-
daHeight:
|
4711
|
-
transactionsCount:
|
4480
|
+
daHeight: bn15(messageBlockHeader.daHeight),
|
4481
|
+
transactionsCount: bn15(messageBlockHeader.transactionsCount),
|
4712
4482
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4713
|
-
height:
|
4483
|
+
height: bn15(messageBlockHeader.height),
|
4714
4484
|
prevRoot: messageBlockHeader.prevRoot,
|
4715
4485
|
time: messageBlockHeader.time,
|
4716
4486
|
applicationHash: messageBlockHeader.applicationHash,
|
4717
|
-
|
4718
|
-
|
4719
|
-
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4720
|
-
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4721
|
-
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4487
|
+
messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
|
4488
|
+
messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
|
4722
4489
|
},
|
4723
4490
|
commitBlockHeader: {
|
4724
4491
|
id: commitBlockHeader.id,
|
4725
|
-
daHeight:
|
4726
|
-
transactionsCount:
|
4492
|
+
daHeight: bn15(commitBlockHeader.daHeight),
|
4493
|
+
transactionsCount: bn15(commitBlockHeader.transactionsCount),
|
4727
4494
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4728
|
-
height:
|
4495
|
+
height: bn15(commitBlockHeader.height),
|
4729
4496
|
prevRoot: commitBlockHeader.prevRoot,
|
4730
4497
|
time: commitBlockHeader.time,
|
4731
4498
|
applicationHash: commitBlockHeader.applicationHash,
|
4732
|
-
|
4733
|
-
|
4734
|
-
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4735
|
-
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4736
|
-
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4499
|
+
messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
|
4500
|
+
messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
|
4737
4501
|
},
|
4738
4502
|
sender: Address2.fromAddressOrString(sender),
|
4739
4503
|
recipient: Address2.fromAddressOrString(recipient),
|
4740
4504
|
nonce,
|
4741
|
-
amount:
|
4505
|
+
amount: bn15(amount),
|
4742
4506
|
data
|
4743
4507
|
};
|
4744
4508
|
}
|
4745
|
-
async getLatestGasPrice() {
|
4746
|
-
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4747
|
-
return bn16(latestGasPrice.gasPrice);
|
4748
|
-
}
|
4749
|
-
async estimateGasPrice(blockHorizon) {
|
4750
|
-
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4751
|
-
blockHorizon: String(blockHorizon)
|
4752
|
-
});
|
4753
|
-
return bn16(estimateGasPrice.gasPrice);
|
4754
|
-
}
|
4755
4509
|
/**
|
4756
4510
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
4757
4511
|
*
|
@@ -4771,10 +4525,10 @@ var _Provider = class {
|
|
4771
4525
|
*/
|
4772
4526
|
async produceBlocks(amount, startTime) {
|
4773
4527
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4774
|
-
blocksToProduce:
|
4528
|
+
blocksToProduce: bn15(amount).toString(10),
|
4775
4529
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4776
4530
|
});
|
4777
|
-
return
|
4531
|
+
return bn15(latestBlockHeight);
|
4778
4532
|
}
|
4779
4533
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4780
4534
|
async getTransactionResponse(transactionId) {
|
@@ -4788,7 +4542,7 @@ cacheInputs_fn = function(inputs) {
|
|
4788
4542
|
return;
|
4789
4543
|
}
|
4790
4544
|
inputs.forEach((input) => {
|
4791
|
-
if (input.type ===
|
4545
|
+
if (input.type === InputType6.Coin) {
|
4792
4546
|
this.cache?.set(input.id);
|
4793
4547
|
}
|
4794
4548
|
});
|
@@ -4798,7 +4552,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4798
4552
|
|
4799
4553
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4800
4554
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4801
|
-
import { bn as
|
4555
|
+
import { bn as bn16 } from "@fuel-ts/math";
|
4802
4556
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4803
4557
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4804
4558
|
async function getTransactionSummary(params) {
|
@@ -4816,28 +4570,21 @@ async function getTransactionSummary(params) {
|
|
4816
4570
|
arrayify12(gqlTransaction.rawPayload),
|
4817
4571
|
0
|
4818
4572
|
);
|
4819
|
-
|
4820
|
-
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
4821
|
-
txReceipts = gqlTransaction.status.receipts;
|
4822
|
-
}
|
4823
|
-
const receipts = txReceipts.map(processGqlReceipt);
|
4573
|
+
const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
|
4824
4574
|
const {
|
4825
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts
|
4575
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
4826
4576
|
} = provider.getChain();
|
4827
|
-
const gasPrice = await provider.getLatestGasPrice();
|
4828
4577
|
const transactionInfo = assembleTransactionSummary({
|
4829
4578
|
id: gqlTransaction.id,
|
4830
4579
|
receipts,
|
4831
4580
|
transaction: decodedTransaction,
|
4832
4581
|
transactionBytes: arrayify12(gqlTransaction.rawPayload),
|
4833
4582
|
gqlTransactionStatus: gqlTransaction.status,
|
4834
|
-
gasPerByte:
|
4835
|
-
gasPriceFactor:
|
4583
|
+
gasPerByte: bn16(gasPerByte),
|
4584
|
+
gasPriceFactor: bn16(gasPriceFactor),
|
4836
4585
|
abiMap,
|
4837
4586
|
maxInputs,
|
4838
|
-
gasCosts
|
4839
|
-
maxGasPerTx,
|
4840
|
-
gasPrice
|
4587
|
+
gasCosts
|
4841
4588
|
});
|
4842
4589
|
return {
|
4843
4590
|
gqlTransaction,
|
@@ -4847,11 +4594,10 @@ async function getTransactionSummary(params) {
|
|
4847
4594
|
async function getTransactionSummaryFromRequest(params) {
|
4848
4595
|
const { provider, transactionRequest, abiMap } = params;
|
4849
4596
|
const { receipts } = await provider.call(transactionRequest);
|
4850
|
-
const { gasPerByte, gasPriceFactor, gasCosts
|
4597
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
|
4851
4598
|
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
4852
4599
|
const transaction = transactionRequest.toTransaction();
|
4853
4600
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
4854
|
-
const gasPrice = await provider.getLatestGasPrice();
|
4855
4601
|
const transactionSummary = assembleTransactionSummary({
|
4856
4602
|
receipts,
|
4857
4603
|
transaction,
|
@@ -4860,9 +4606,7 @@ async function getTransactionSummaryFromRequest(params) {
|
|
4860
4606
|
gasPerByte,
|
4861
4607
|
gasPriceFactor,
|
4862
4608
|
maxInputs,
|
4863
|
-
gasCosts
|
4864
|
-
maxGasPerTx,
|
4865
|
-
gasPrice
|
4609
|
+
gasCosts
|
4866
4610
|
});
|
4867
4611
|
return transactionSummary;
|
4868
4612
|
}
|
@@ -4871,18 +4615,13 @@ async function getTransactionsSummaries(params) {
|
|
4871
4615
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
4872
4616
|
const { edges, pageInfo } = transactionsByOwner;
|
4873
4617
|
const {
|
4874
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts
|
4618
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
4875
4619
|
} = provider.getChain();
|
4876
|
-
const gasPrice = await provider.getLatestGasPrice();
|
4877
4620
|
const transactions = edges.map((edge) => {
|
4878
4621
|
const { node: gqlTransaction } = edge;
|
4879
|
-
const { id, rawPayload, status } = gqlTransaction;
|
4622
|
+
const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
|
4880
4623
|
const [decodedTransaction] = new TransactionCoder6().decode(arrayify12(rawPayload), 0);
|
4881
|
-
|
4882
|
-
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
4883
|
-
txReceipts = gqlTransaction.status.receipts;
|
4884
|
-
}
|
4885
|
-
const receipts = txReceipts.map(processGqlReceipt);
|
4624
|
+
const receipts = gqlReceipts?.map(processGqlReceipt) || [];
|
4886
4625
|
const transactionSummary = assembleTransactionSummary({
|
4887
4626
|
id,
|
4888
4627
|
receipts,
|
@@ -4893,9 +4632,7 @@ async function getTransactionsSummaries(params) {
|
|
4893
4632
|
gasPerByte,
|
4894
4633
|
gasPriceFactor,
|
4895
4634
|
maxInputs,
|
4896
|
-
gasCosts
|
4897
|
-
maxGasPerTx,
|
4898
|
-
gasPrice
|
4635
|
+
gasCosts
|
4899
4636
|
});
|
4900
4637
|
const output = {
|
4901
4638
|
gqlTransaction,
|
@@ -5227,33 +4964,36 @@ var Account = class extends AbstractAccount {
|
|
5227
4964
|
* @param fee - The estimated transaction fee.
|
5228
4965
|
* @returns A promise that resolves when the resources are added to the transaction.
|
5229
4966
|
*/
|
5230
|
-
async fund(request,
|
5231
|
-
const
|
5232
|
-
|
5233
|
-
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5234
|
-
amount: bn18(fee),
|
4967
|
+
async fund(request, coinQuantities, fee) {
|
4968
|
+
const updatedQuantities = addAmountToAsset({
|
4969
|
+
amount: bn17(fee),
|
5235
4970
|
assetId: BaseAssetId3,
|
5236
|
-
coinQuantities
|
4971
|
+
coinQuantities
|
5237
4972
|
});
|
5238
4973
|
const quantitiesDict = {};
|
5239
|
-
|
4974
|
+
updatedQuantities.forEach(({ amount, assetId }) => {
|
5240
4975
|
quantitiesDict[assetId] = {
|
5241
4976
|
required: amount,
|
5242
|
-
owned:
|
4977
|
+
owned: bn17(0)
|
5243
4978
|
};
|
5244
4979
|
});
|
5245
|
-
|
4980
|
+
const cachedUtxos = [];
|
4981
|
+
const cachedMessages = [];
|
4982
|
+
const owner = this.address.toB256();
|
4983
|
+
request.inputs.forEach((input) => {
|
5246
4984
|
const isResource = "amount" in input;
|
5247
4985
|
if (isResource) {
|
5248
4986
|
const isCoin2 = "owner" in input;
|
5249
4987
|
if (isCoin2) {
|
5250
4988
|
const assetId = String(input.assetId);
|
5251
|
-
if (quantitiesDict[assetId]) {
|
5252
|
-
const amount =
|
4989
|
+
if (input.owner === owner && quantitiesDict[assetId]) {
|
4990
|
+
const amount = bn17(input.amount);
|
5253
4991
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4992
|
+
cachedUtxos.push(input.id);
|
5254
4993
|
}
|
5255
|
-
} else if (input.amount && quantitiesDict[BaseAssetId3]) {
|
4994
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
|
5256
4995
|
quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
|
4996
|
+
cachedMessages.push(input.nonce);
|
5257
4997
|
}
|
5258
4998
|
}
|
5259
4999
|
});
|
@@ -5268,23 +5008,12 @@ var Account = class extends AbstractAccount {
|
|
5268
5008
|
});
|
5269
5009
|
const needsToBeFunded = missingQuantities.length;
|
5270
5010
|
if (needsToBeFunded) {
|
5271
|
-
const
|
5272
|
-
|
5273
|
-
|
5274
|
-
|
5275
|
-
|
5276
|
-
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
5277
|
-
const requestToBeReEstimate = clone4(txRequest);
|
5278
|
-
if (addedSignatures) {
|
5279
|
-
Array.from({ length: addedSignatures }).forEach(
|
5280
|
-
() => requestToBeReEstimate.addEmptyWitness()
|
5281
|
-
);
|
5011
|
+
const resources = await this.getResourcesToSpend(missingQuantities, {
|
5012
|
+
messages: cachedMessages,
|
5013
|
+
utxos: cachedUtxos
|
5014
|
+
});
|
5015
|
+
request.addResources(resources);
|
5282
5016
|
}
|
5283
|
-
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
5284
|
-
transactionRequest: requestToBeReEstimate
|
5285
|
-
});
|
5286
|
-
txRequest.maxFee = maxFee;
|
5287
|
-
return txRequest;
|
5288
5017
|
}
|
5289
5018
|
/**
|
5290
5019
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -5292,24 +5021,28 @@ var Account = class extends AbstractAccount {
|
|
5292
5021
|
* @param destination - The address of the destination.
|
5293
5022
|
* @param amount - The amount of coins to transfer.
|
5294
5023
|
* @param assetId - The asset ID of the coins to transfer.
|
5295
|
-
* @param txParams - The transaction parameters (gasLimit,
|
5024
|
+
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
5296
5025
|
* @returns A promise that resolves to the prepared transaction request.
|
5297
5026
|
*/
|
5298
5027
|
async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
5299
|
-
const
|
5028
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
5029
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
5030
|
+
const request = new ScriptTransactionRequest(params);
|
5300
5031
|
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
|
5301
|
-
const
|
5032
|
+
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
5302
5033
|
estimateTxDependencies: true,
|
5303
5034
|
resourcesOwner: this
|
5304
5035
|
});
|
5305
|
-
|
5306
|
-
|
5307
|
-
|
5308
|
-
|
5036
|
+
request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
|
5037
|
+
request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
|
5038
|
+
this.validateGas({
|
5039
|
+
gasUsed,
|
5040
|
+
gasPrice: request.gasPrice,
|
5041
|
+
gasLimit: request.gasLimit,
|
5042
|
+
minGasPrice
|
5309
5043
|
});
|
5310
|
-
request
|
5311
|
-
request.
|
5312
|
-
await this.fund(request, txCost);
|
5044
|
+
await this.fund(request, requiredQuantities, maxFee);
|
5045
|
+
request.updatePredicateInputs(estimatedInputs);
|
5313
5046
|
return request;
|
5314
5047
|
}
|
5315
5048
|
/**
|
@@ -5322,7 +5055,7 @@ var Account = class extends AbstractAccount {
|
|
5322
5055
|
* @returns A promise that resolves to the transaction response.
|
5323
5056
|
*/
|
5324
5057
|
async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
5325
|
-
if (
|
5058
|
+
if (bn17(amount).lte(0)) {
|
5326
5059
|
throw new FuelError15(
|
5327
5060
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5328
5061
|
"Transfer amount must be a positive number."
|
@@ -5341,36 +5074,38 @@ var Account = class extends AbstractAccount {
|
|
5341
5074
|
* @returns A promise that resolves to the transaction response.
|
5342
5075
|
*/
|
5343
5076
|
async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
|
5344
|
-
if (
|
5077
|
+
if (bn17(amount).lte(0)) {
|
5345
5078
|
throw new FuelError15(
|
5346
5079
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5347
5080
|
"Transfer amount must be a positive number."
|
5348
5081
|
);
|
5349
5082
|
}
|
5350
5083
|
const contractAddress = Address3.fromAddressOrString(contractId);
|
5084
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
5085
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
5351
5086
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5352
5087
|
hexlifiedContractId: contractAddress.toB256(),
|
5353
|
-
amountToTransfer:
|
5088
|
+
amountToTransfer: bn17(amount),
|
5354
5089
|
assetId
|
5355
5090
|
});
|
5356
5091
|
const request = new ScriptTransactionRequest({
|
5357
|
-
...
|
5092
|
+
...params,
|
5358
5093
|
script,
|
5359
5094
|
scriptData
|
5360
5095
|
});
|
5361
5096
|
request.addContractInputAndOutput(contractAddress);
|
5362
|
-
const
|
5363
|
-
|
5364
|
-
|
5365
|
-
|
5366
|
-
|
5367
|
-
|
5368
|
-
|
5369
|
-
|
5097
|
+
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
5098
|
+
request,
|
5099
|
+
[{ amount: bn17(amount), assetId: String(assetId) }]
|
5100
|
+
);
|
5101
|
+
request.gasLimit = bn17(params.gasLimit ?? gasUsed);
|
5102
|
+
this.validateGas({
|
5103
|
+
gasUsed,
|
5104
|
+
gasPrice: request.gasPrice,
|
5105
|
+
gasLimit: request.gasLimit,
|
5106
|
+
minGasPrice
|
5370
5107
|
});
|
5371
|
-
request
|
5372
|
-
request.maxFee = txCost.maxFee;
|
5373
|
-
await this.fund(request, txCost);
|
5108
|
+
await this.fund(request, requiredQuantities, maxFee);
|
5374
5109
|
return this.sendTransaction(request);
|
5375
5110
|
}
|
5376
5111
|
/**
|
@@ -5382,30 +5117,34 @@ var Account = class extends AbstractAccount {
|
|
5382
5117
|
* @returns A promise that resolves to the transaction response.
|
5383
5118
|
*/
|
5384
5119
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5120
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
5385
5121
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
5386
5122
|
const recipientDataArray = arrayify14(
|
5387
5123
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5388
5124
|
);
|
5389
5125
|
const amountDataArray = arrayify14(
|
5390
|
-
"0x".concat(
|
5126
|
+
"0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
|
5391
5127
|
);
|
5392
5128
|
const script = new Uint8Array([
|
5393
5129
|
...arrayify14(withdrawScript.bytes),
|
5394
5130
|
...recipientDataArray,
|
5395
5131
|
...amountDataArray
|
5396
5132
|
]);
|
5397
|
-
const params = { script, ...txParams };
|
5133
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
5398
5134
|
const request = new ScriptTransactionRequest(params);
|
5399
|
-
const
|
5400
|
-
const
|
5401
|
-
|
5402
|
-
|
5403
|
-
|
5404
|
-
|
5135
|
+
const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
|
5136
|
+
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
5137
|
+
request,
|
5138
|
+
forwardingQuantities
|
5139
|
+
);
|
5140
|
+
request.gasLimit = bn17(params.gasLimit ?? gasUsed);
|
5141
|
+
this.validateGas({
|
5142
|
+
gasUsed,
|
5143
|
+
gasPrice: request.gasPrice,
|
5144
|
+
gasLimit: request.gasLimit,
|
5145
|
+
minGasPrice
|
5405
5146
|
});
|
5406
|
-
request
|
5407
|
-
request.gasLimit = txCost.gasUsed;
|
5408
|
-
await this.fund(request, txCost);
|
5147
|
+
await this.fund(request, requiredQuantities, maxFee);
|
5409
5148
|
return this.sendTransaction(request);
|
5410
5149
|
}
|
5411
5150
|
async signMessage(message) {
|
@@ -5463,21 +5202,22 @@ var Account = class extends AbstractAccount {
|
|
5463
5202
|
}
|
5464
5203
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5465
5204
|
}
|
5466
|
-
|
5467
|
-
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
|
5205
|
+
validateGas({
|
5468
5206
|
gasUsed,
|
5469
|
-
|
5207
|
+
gasPrice,
|
5208
|
+
gasLimit,
|
5209
|
+
minGasPrice
|
5470
5210
|
}) {
|
5471
|
-
if (
|
5211
|
+
if (minGasPrice.gt(gasPrice)) {
|
5472
5212
|
throw new FuelError15(
|
5473
|
-
ErrorCode15.
|
5474
|
-
`Gas
|
5213
|
+
ErrorCode15.GAS_PRICE_TOO_LOW,
|
5214
|
+
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
5475
5215
|
);
|
5476
5216
|
}
|
5477
|
-
if (
|
5217
|
+
if (gasUsed.gt(gasLimit)) {
|
5478
5218
|
throw new FuelError15(
|
5479
|
-
ErrorCode15.
|
5480
|
-
`
|
5219
|
+
ErrorCode15.GAS_LIMIT_TOO_LOW,
|
5220
|
+
`Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
|
5481
5221
|
);
|
5482
5222
|
}
|
5483
5223
|
}
|
@@ -5769,7 +5509,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5769
5509
|
* @param transactionRequestLike - The transaction request to send.
|
5770
5510
|
* @returns A promise that resolves to the TransactionResponse object.
|
5771
5511
|
*/
|
5772
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
5512
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
5773
5513
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5774
5514
|
if (estimateTxDependencies) {
|
5775
5515
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -5810,7 +5550,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5810
5550
|
// src/hdwallet/hdwallet.ts
|
5811
5551
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5812
5552
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5813
|
-
import { bn as
|
5553
|
+
import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5814
5554
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5815
5555
|
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5816
5556
|
|
@@ -8282,7 +8022,7 @@ var HDWallet = class {
|
|
8282
8022
|
const IR = bytes.slice(32);
|
8283
8023
|
if (privateKey) {
|
8284
8024
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8285
|
-
const ki =
|
8025
|
+
const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
|
8286
8026
|
return new HDWallet({
|
8287
8027
|
privateKey: ki,
|
8288
8028
|
chainCode: IR,
|
@@ -8971,7 +8711,7 @@ import {
|
|
8971
8711
|
import { Address as Address9 } from "@fuel-ts/address";
|
8972
8712
|
import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
|
8973
8713
|
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
8974
|
-
import { ByteArrayCoder, InputType as
|
8714
|
+
import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
|
8975
8715
|
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
8976
8716
|
|
8977
8717
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -9031,9 +8771,9 @@ var Predicate = class extends Account {
|
|
9031
8771
|
const request = transactionRequestify(transactionRequestLike);
|
9032
8772
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
9033
8773
|
request.inputs?.forEach((input) => {
|
9034
|
-
if (input.type ===
|
9035
|
-
input.predicate =
|
9036
|
-
input.predicateData =
|
8774
|
+
if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
|
8775
|
+
input.predicate = this.bytes;
|
8776
|
+
input.predicateData = this.getPredicateData(policies.length);
|
9037
8777
|
}
|
9038
8778
|
});
|
9039
8779
|
return request;
|
@@ -9048,7 +8788,8 @@ var Predicate = class extends Account {
|
|
9048
8788
|
* @returns A promise that resolves to the prepared transaction request.
|
9049
8789
|
*/
|
9050
8790
|
async createTransfer(destination, amount, assetId = BaseAssetId4, txParams = {}) {
|
9051
|
-
|
8791
|
+
const request = await super.createTransfer(destination, amount, assetId, txParams);
|
8792
|
+
return this.populateTransactionPredicateData(request);
|
9052
8793
|
}
|
9053
8794
|
/**
|
9054
8795
|
* Sends a transaction with the populated predicate data.
|
@@ -9056,9 +8797,9 @@ var Predicate = class extends Account {
|
|
9056
8797
|
* @param transactionRequestLike - The transaction request-like object.
|
9057
8798
|
* @returns A promise that resolves to the transaction response.
|
9058
8799
|
*/
|
9059
|
-
sendTransaction(transactionRequestLike) {
|
9060
|
-
const transactionRequest =
|
9061
|
-
return super.sendTransaction(transactionRequest,
|
8800
|
+
sendTransaction(transactionRequestLike, options) {
|
8801
|
+
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
8802
|
+
return super.sendTransaction(transactionRequest, options);
|
9062
8803
|
}
|
9063
8804
|
/**
|
9064
8805
|
* Simulates a transaction with the populated predicate data.
|
@@ -9067,8 +8808,8 @@ var Predicate = class extends Account {
|
|
9067
8808
|
* @returns A promise that resolves to the call result.
|
9068
8809
|
*/
|
9069
8810
|
simulateTransaction(transactionRequestLike) {
|
9070
|
-
const transactionRequest =
|
9071
|
-
return super.simulateTransaction(transactionRequest
|
8811
|
+
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
8812
|
+
return super.simulateTransaction(transactionRequest);
|
9072
8813
|
}
|
9073
8814
|
getPredicateData(policiesLength) {
|
9074
8815
|
if (!this.predicateData.length) {
|
@@ -9114,25 +8855,6 @@ var Predicate = class extends Account {
|
|
9114
8855
|
predicateInterface: abiInterface
|
9115
8856
|
};
|
9116
8857
|
}
|
9117
|
-
/**
|
9118
|
-
* Retrieves resources satisfying the spend query for the account.
|
9119
|
-
*
|
9120
|
-
* @param quantities - IDs of coins to exclude.
|
9121
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
9122
|
-
* @returns A promise that resolves to an array of Resources.
|
9123
|
-
*/
|
9124
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
9125
|
-
const resources = await this.provider.getResourcesToSpend(
|
9126
|
-
this.address,
|
9127
|
-
quantities,
|
9128
|
-
excludedIds
|
9129
|
-
);
|
9130
|
-
return resources.map((resource) => ({
|
9131
|
-
...resource,
|
9132
|
-
predicate: hexlify19(this.bytes),
|
9133
|
-
padPredicateData: (policiesLength) => hexlify19(this.getPredicateData(policiesLength))
|
9134
|
-
}));
|
9135
|
-
}
|
9136
8858
|
/**
|
9137
8859
|
* Sets the configurable constants for the predicate.
|
9138
8860
|
*
|
@@ -9881,7 +9603,7 @@ export {
|
|
9881
9603
|
WalletLocked,
|
9882
9604
|
WalletManager,
|
9883
9605
|
WalletUnlocked,
|
9884
|
-
|
9606
|
+
addAmountToAsset,
|
9885
9607
|
addOperation,
|
9886
9608
|
assemblePanicError,
|
9887
9609
|
assembleReceiptByType,
|
@@ -9890,10 +9612,9 @@ export {
|
|
9890
9612
|
assets,
|
9891
9613
|
buildBlockExplorerUrl,
|
9892
9614
|
cacheFor,
|
9893
|
-
cacheTxInputsFromOwner,
|
9894
|
-
calculateGasFee,
|
9895
9615
|
calculateMetadataGasForTxCreate,
|
9896
9616
|
calculateMetadataGasForTxScript,
|
9617
|
+
calculatePriceWithFactor,
|
9897
9618
|
calculateTransactionFee,
|
9898
9619
|
coinQuantityfy,
|
9899
9620
|
deferPromise,
|