@fuel-ts/account 0.0.0-rc-2143-20240424161332 → 0.0.0-rc-2021-20240424162616
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 +6 -5
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +808 -553
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +769 -514
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +650 -396
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +10 -2
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +810 -359
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +4 -2
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +7 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +37 -27
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +2 -2
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +8 -29
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +3 -0
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +8 -2
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +2 -4
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +1527 -1056
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +751 -514
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +644 -407
- 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,8 +32,9 @@ 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 } from "@fuel-ts/utils";
|
35
|
+
import { bn as bn18 } from "@fuel-ts/math";
|
36
|
+
import { arrayify as arrayify14, isDefined } from "@fuel-ts/utils";
|
37
|
+
import { clone as clone4 } from "ramda";
|
37
38
|
|
38
39
|
// src/providers/coin-quantity.ts
|
39
40
|
import { BaseAssetId } from "@fuel-ts/address/configs";
|
@@ -42,24 +43,24 @@ import { hexlify } from "@fuel-ts/utils";
|
|
42
43
|
var coinQuantityfy = (coinQuantityLike) => {
|
43
44
|
let assetId;
|
44
45
|
let amount;
|
45
|
-
let
|
46
|
+
let max;
|
46
47
|
if (Array.isArray(coinQuantityLike)) {
|
47
48
|
amount = coinQuantityLike[0];
|
48
49
|
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
49
|
-
|
50
|
+
max = coinQuantityLike[2] ?? void 0;
|
50
51
|
} else {
|
51
52
|
amount = coinQuantityLike.amount;
|
52
53
|
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
53
|
-
|
54
|
+
max = coinQuantityLike.max ?? void 0;
|
54
55
|
}
|
55
56
|
const bnAmount = bn(amount);
|
56
57
|
return {
|
57
58
|
assetId: hexlify(assetId),
|
58
59
|
amount: bnAmount.lt(1) ? bn(1) : bnAmount,
|
59
|
-
max:
|
60
|
+
max: max ? bn(max) : void 0
|
60
61
|
};
|
61
62
|
};
|
62
|
-
var
|
63
|
+
var addAmountToCoinQuantities = (params) => {
|
63
64
|
const { amount, assetId } = params;
|
64
65
|
const coinQuantities = [...params.coinQuantities];
|
65
66
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -74,9 +75,9 @@ var addAmountToAsset = (params) => {
|
|
74
75
|
// src/providers/provider.ts
|
75
76
|
import { Address as Address2 } from "@fuel-ts/address";
|
76
77
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
77
|
-
import { BN, bn as
|
78
|
+
import { BN, bn as bn16 } from "@fuel-ts/math";
|
78
79
|
import {
|
79
|
-
InputType as
|
80
|
+
InputType as InputType7,
|
80
81
|
TransactionType as TransactionType8,
|
81
82
|
InputMessageCoder,
|
82
83
|
TransactionCoder as TransactionCoder5
|
@@ -90,16 +91,20 @@ import { clone as clone3 } from "ramda";
|
|
90
91
|
|
91
92
|
// src/providers/__generated__/operations.ts
|
92
93
|
import gql from "graphql-tag";
|
94
|
+
var TransactionStatusSubscriptionFragmentFragmentDoc = gql`
|
95
|
+
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
96
|
+
type: __typename
|
97
|
+
... on SqueezedOutStatus {
|
98
|
+
reason
|
99
|
+
}
|
100
|
+
}
|
101
|
+
`;
|
93
102
|
var ReceiptFragmentFragmentDoc = gql`
|
94
103
|
fragment receiptFragment on Receipt {
|
95
|
-
|
96
|
-
id
|
97
|
-
}
|
104
|
+
id
|
98
105
|
pc
|
99
106
|
is
|
100
|
-
to
|
101
|
-
id
|
102
|
-
}
|
107
|
+
to
|
103
108
|
toAddress
|
104
109
|
amount
|
105
110
|
assetId
|
@@ -137,10 +142,16 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
137
142
|
id
|
138
143
|
}
|
139
144
|
time
|
145
|
+
receipts {
|
146
|
+
...receiptFragment
|
147
|
+
}
|
140
148
|
programState {
|
141
149
|
returnType
|
142
150
|
data
|
143
151
|
}
|
152
|
+
receipts {
|
153
|
+
...receiptFragment
|
154
|
+
}
|
144
155
|
}
|
145
156
|
... on FailureStatus {
|
146
157
|
block {
|
@@ -148,26 +159,24 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
148
159
|
}
|
149
160
|
time
|
150
161
|
reason
|
162
|
+
receipts {
|
163
|
+
...receiptFragment
|
164
|
+
}
|
151
165
|
}
|
152
166
|
... on SqueezedOutStatus {
|
153
167
|
reason
|
154
168
|
}
|
155
169
|
}
|
156
|
-
`;
|
170
|
+
${ReceiptFragmentFragmentDoc}`;
|
157
171
|
var TransactionFragmentFragmentDoc = gql`
|
158
172
|
fragment transactionFragment on Transaction {
|
159
173
|
id
|
160
174
|
rawPayload
|
161
|
-
gasPrice
|
162
|
-
receipts {
|
163
|
-
...receiptFragment
|
164
|
-
}
|
165
175
|
status {
|
166
176
|
...transactionStatusFragment
|
167
177
|
}
|
168
178
|
}
|
169
|
-
${
|
170
|
-
${TransactionStatusFragmentFragmentDoc}`;
|
179
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
171
180
|
var InputEstimatePredicatesFragmentFragmentDoc = gql`
|
172
181
|
fragment inputEstimatePredicatesFragment on Input {
|
173
182
|
... on InputCoin {
|
@@ -185,6 +194,46 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
|
|
185
194
|
}
|
186
195
|
}
|
187
196
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
197
|
+
var DryRunFailureStatusFragmentFragmentDoc = gql`
|
198
|
+
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
199
|
+
reason
|
200
|
+
programState {
|
201
|
+
returnType
|
202
|
+
data
|
203
|
+
}
|
204
|
+
}
|
205
|
+
`;
|
206
|
+
var DryRunSuccessStatusFragmentFragmentDoc = gql`
|
207
|
+
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
208
|
+
programState {
|
209
|
+
returnType
|
210
|
+
data
|
211
|
+
}
|
212
|
+
}
|
213
|
+
`;
|
214
|
+
var DryRunTransactionStatusFragmentFragmentDoc = gql`
|
215
|
+
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
216
|
+
... on DryRunFailureStatus {
|
217
|
+
...dryRunFailureStatusFragment
|
218
|
+
}
|
219
|
+
... on DryRunSuccessStatus {
|
220
|
+
...dryRunSuccessStatusFragment
|
221
|
+
}
|
222
|
+
}
|
223
|
+
${DryRunFailureStatusFragmentFragmentDoc}
|
224
|
+
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
225
|
+
var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
|
226
|
+
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
227
|
+
id
|
228
|
+
status {
|
229
|
+
...dryRunTransactionStatusFragment
|
230
|
+
}
|
231
|
+
receipts {
|
232
|
+
...receiptFragment
|
233
|
+
}
|
234
|
+
}
|
235
|
+
${DryRunTransactionStatusFragmentFragmentDoc}
|
236
|
+
${ReceiptFragmentFragmentDoc}`;
|
188
237
|
var CoinFragmentFragmentDoc = gql`
|
189
238
|
fragment coinFragment on Coin {
|
190
239
|
__typename
|
@@ -192,7 +241,6 @@ var CoinFragmentFragmentDoc = gql`
|
|
192
241
|
owner
|
193
242
|
amount
|
194
243
|
assetId
|
195
|
-
maturity
|
196
244
|
blockCreated
|
197
245
|
txCreatedIdx
|
198
246
|
}
|
@@ -231,26 +279,32 @@ var MessageProofFragmentFragmentDoc = gql`
|
|
231
279
|
messageBlockHeader {
|
232
280
|
id
|
233
281
|
daHeight
|
282
|
+
consensusParametersVersion
|
283
|
+
stateTransitionBytecodeVersion
|
234
284
|
transactionsCount
|
285
|
+
messageReceiptCount
|
235
286
|
transactionsRoot
|
287
|
+
messageOutboxRoot
|
288
|
+
eventInboxRoot
|
236
289
|
height
|
237
290
|
prevRoot
|
238
291
|
time
|
239
292
|
applicationHash
|
240
|
-
messageReceiptRoot
|
241
|
-
messageReceiptCount
|
242
293
|
}
|
243
294
|
commitBlockHeader {
|
244
295
|
id
|
245
296
|
daHeight
|
297
|
+
consensusParametersVersion
|
298
|
+
stateTransitionBytecodeVersion
|
246
299
|
transactionsCount
|
300
|
+
messageReceiptCount
|
247
301
|
transactionsRoot
|
302
|
+
messageOutboxRoot
|
303
|
+
eventInboxRoot
|
248
304
|
height
|
249
305
|
prevRoot
|
250
306
|
time
|
251
307
|
applicationHash
|
252
|
-
messageReceiptRoot
|
253
|
-
messageReceiptCount
|
254
308
|
}
|
255
309
|
sender
|
256
310
|
recipient
|
@@ -269,8 +323,8 @@ var BalanceFragmentFragmentDoc = gql`
|
|
269
323
|
var BlockFragmentFragmentDoc = gql`
|
270
324
|
fragment blockFragment on Block {
|
271
325
|
id
|
326
|
+
height
|
272
327
|
header {
|
273
|
-
height
|
274
328
|
time
|
275
329
|
}
|
276
330
|
transactions {
|
@@ -280,6 +334,7 @@ var BlockFragmentFragmentDoc = gql`
|
|
280
334
|
`;
|
281
335
|
var TxParametersFragmentFragmentDoc = gql`
|
282
336
|
fragment TxParametersFragment on TxParameters {
|
337
|
+
version
|
283
338
|
maxInputs
|
284
339
|
maxOutputs
|
285
340
|
maxWitnesses
|
@@ -289,6 +344,7 @@ var TxParametersFragmentFragmentDoc = gql`
|
|
289
344
|
`;
|
290
345
|
var PredicateParametersFragmentFragmentDoc = gql`
|
291
346
|
fragment PredicateParametersFragment on PredicateParameters {
|
347
|
+
version
|
292
348
|
maxPredicateLength
|
293
349
|
maxPredicateDataLength
|
294
350
|
maxGasPerPredicate
|
@@ -297,18 +353,21 @@ var PredicateParametersFragmentFragmentDoc = gql`
|
|
297
353
|
`;
|
298
354
|
var ScriptParametersFragmentFragmentDoc = gql`
|
299
355
|
fragment ScriptParametersFragment on ScriptParameters {
|
356
|
+
version
|
300
357
|
maxScriptLength
|
301
358
|
maxScriptDataLength
|
302
359
|
}
|
303
360
|
`;
|
304
361
|
var ContractParametersFragmentFragmentDoc = gql`
|
305
362
|
fragment ContractParametersFragment on ContractParameters {
|
363
|
+
version
|
306
364
|
contractMaxSize
|
307
365
|
maxStorageSlots
|
308
366
|
}
|
309
367
|
`;
|
310
368
|
var FeeParametersFragmentFragmentDoc = gql`
|
311
369
|
fragment FeeParametersFragment on FeeParameters {
|
370
|
+
version
|
312
371
|
gasPriceFactor
|
313
372
|
gasPerByte
|
314
373
|
}
|
@@ -328,6 +387,7 @@ var DependentCostFragmentFragmentDoc = gql`
|
|
328
387
|
`;
|
329
388
|
var GasCostsFragmentFragmentDoc = gql`
|
330
389
|
fragment GasCostsFragment on GasCosts {
|
390
|
+
version
|
331
391
|
add
|
332
392
|
addi
|
333
393
|
aloc
|
@@ -340,7 +400,6 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
340
400
|
cb
|
341
401
|
cfei
|
342
402
|
cfsi
|
343
|
-
croo
|
344
403
|
div
|
345
404
|
divi
|
346
405
|
ecr1
|
@@ -423,6 +482,9 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
423
482
|
ccp {
|
424
483
|
...DependentCostFragment
|
425
484
|
}
|
485
|
+
croo {
|
486
|
+
...DependentCostFragment
|
487
|
+
}
|
426
488
|
csiz {
|
427
489
|
...DependentCostFragment
|
428
490
|
}
|
@@ -482,6 +544,7 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
482
544
|
${DependentCostFragmentFragmentDoc}`;
|
483
545
|
var ConsensusParametersFragmentFragmentDoc = gql`
|
484
546
|
fragment consensusParametersFragment on ConsensusParameters {
|
547
|
+
version
|
485
548
|
txParams {
|
486
549
|
...TxParametersFragment
|
487
550
|
}
|
@@ -541,18 +604,9 @@ var NodeInfoFragmentFragmentDoc = gql`
|
|
541
604
|
fragment nodeInfoFragment on NodeInfo {
|
542
605
|
utxoValidation
|
543
606
|
vmBacktrace
|
544
|
-
minGasPrice
|
545
607
|
maxTx
|
546
608
|
maxDepth
|
547
609
|
nodeVersion
|
548
|
-
peers {
|
549
|
-
id
|
550
|
-
addresses
|
551
|
-
clientVersion
|
552
|
-
blockHeight
|
553
|
-
lastHeartbeatMs
|
554
|
-
appScore
|
555
|
-
}
|
556
610
|
}
|
557
611
|
`;
|
558
612
|
var GetVersionDocument = gql`
|
@@ -587,13 +641,9 @@ var GetTransactionWithReceiptsDocument = gql`
|
|
587
641
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
588
642
|
transaction(id: $transactionId) {
|
589
643
|
...transactionFragment
|
590
|
-
receipts {
|
591
|
-
...receiptFragment
|
592
|
-
}
|
593
644
|
}
|
594
645
|
}
|
595
|
-
${TransactionFragmentFragmentDoc}
|
596
|
-
${ReceiptFragmentFragmentDoc}`;
|
646
|
+
${TransactionFragmentFragmentDoc}`;
|
597
647
|
var GetTransactionsDocument = gql`
|
598
648
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
599
649
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -721,6 +771,20 @@ var GetBalanceDocument = gql`
|
|
721
771
|
}
|
722
772
|
}
|
723
773
|
${BalanceFragmentFragmentDoc}`;
|
774
|
+
var GetLatestGasPriceDocument = gql`
|
775
|
+
query getLatestGasPrice {
|
776
|
+
latestGasPrice {
|
777
|
+
gasPrice
|
778
|
+
}
|
779
|
+
}
|
780
|
+
`;
|
781
|
+
var EstimateGasPriceDocument = gql`
|
782
|
+
query estimateGasPrice($blockHorizon: U32!) {
|
783
|
+
estimateGasPrice(blockHorizon: $blockHorizon) {
|
784
|
+
gasPrice
|
785
|
+
}
|
786
|
+
}
|
787
|
+
`;
|
724
788
|
var GetBalancesDocument = gql`
|
725
789
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
726
790
|
balances(
|
@@ -775,12 +839,12 @@ var GetMessageStatusDocument = gql`
|
|
775
839
|
}
|
776
840
|
`;
|
777
841
|
var DryRunDocument = gql`
|
778
|
-
mutation dryRun($
|
779
|
-
dryRun(
|
780
|
-
...
|
842
|
+
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
843
|
+
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
844
|
+
...dryRunTransactionExecutionStatusFragment
|
781
845
|
}
|
782
846
|
}
|
783
|
-
${
|
847
|
+
${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
|
784
848
|
var SubmitDocument = gql`
|
785
849
|
mutation submit($encodedTransaction: HexString!) {
|
786
850
|
submit(tx: $encodedTransaction) {
|
@@ -799,17 +863,17 @@ var ProduceBlocksDocument = gql`
|
|
799
863
|
var SubmitAndAwaitDocument = gql`
|
800
864
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
801
865
|
submitAndAwait(tx: $encodedTransaction) {
|
802
|
-
...
|
866
|
+
...transactionStatusSubscriptionFragment
|
803
867
|
}
|
804
868
|
}
|
805
|
-
${
|
869
|
+
${TransactionStatusSubscriptionFragmentFragmentDoc}`;
|
806
870
|
var StatusChangeDocument = gql`
|
807
871
|
subscription statusChange($transactionId: TransactionId!) {
|
808
872
|
statusChange(id: $transactionId) {
|
809
|
-
...
|
873
|
+
...transactionStatusSubscriptionFragment
|
810
874
|
}
|
811
875
|
}
|
812
|
-
${
|
876
|
+
${TransactionStatusSubscriptionFragmentFragmentDoc}`;
|
813
877
|
function getSdk(requester) {
|
814
878
|
return {
|
815
879
|
getVersion(variables, options) {
|
@@ -863,6 +927,12 @@ function getSdk(requester) {
|
|
863
927
|
getBalance(variables, options) {
|
864
928
|
return requester(GetBalanceDocument, variables, options);
|
865
929
|
},
|
930
|
+
getLatestGasPrice(variables, options) {
|
931
|
+
return requester(GetLatestGasPriceDocument, variables, options);
|
932
|
+
},
|
933
|
+
estimateGasPrice(variables, options) {
|
934
|
+
return requester(EstimateGasPriceDocument, variables, options);
|
935
|
+
},
|
866
936
|
getBalances(variables, options) {
|
867
937
|
return requester(GetBalancesDocument, variables, options);
|
868
938
|
},
|
@@ -1056,10 +1126,9 @@ var inputify = (value) => {
|
|
1056
1126
|
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
1057
1127
|
},
|
1058
1128
|
witnessIndex: value.witnessIndex,
|
1059
|
-
maturity: value.maturity ?? 0,
|
1060
1129
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1061
|
-
predicateLength: predicate.length,
|
1062
|
-
predicateDataLength: predicateData.length,
|
1130
|
+
predicateLength: bn2(predicate.length),
|
1131
|
+
predicateDataLength: bn2(predicateData.length),
|
1063
1132
|
predicate: hexlify3(predicate),
|
1064
1133
|
predicateData: hexlify3(predicateData)
|
1065
1134
|
};
|
@@ -1090,8 +1159,8 @@ var inputify = (value) => {
|
|
1090
1159
|
nonce: hexlify3(value.nonce),
|
1091
1160
|
witnessIndex: value.witnessIndex,
|
1092
1161
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1093
|
-
predicateLength: predicate.length,
|
1094
|
-
predicateDataLength: predicateData.length,
|
1162
|
+
predicateLength: bn2(predicate.length),
|
1163
|
+
predicateDataLength: bn2(predicateData.length),
|
1095
1164
|
predicate: hexlify3(predicate),
|
1096
1165
|
predicateData: hexlify3(predicateData),
|
1097
1166
|
data: hexlify3(data),
|
@@ -1221,8 +1290,8 @@ function assembleReceiptByType(receipt) {
|
|
1221
1290
|
case "CALL" /* Call */: {
|
1222
1291
|
const callReceipt = {
|
1223
1292
|
type: ReceiptType.Call,
|
1224
|
-
from: hexOrZero(receipt.
|
1225
|
-
to: hexOrZero(receipt?.to
|
1293
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1294
|
+
to: hexOrZero(receipt?.to),
|
1226
1295
|
amount: bn4(receipt.amount),
|
1227
1296
|
assetId: hexOrZero(receipt.assetId),
|
1228
1297
|
gas: bn4(receipt.gas),
|
@@ -1236,7 +1305,7 @@ function assembleReceiptByType(receipt) {
|
|
1236
1305
|
case "RETURN" /* Return */: {
|
1237
1306
|
const returnReceipt = {
|
1238
1307
|
type: ReceiptType.Return,
|
1239
|
-
id: hexOrZero(receipt.
|
1308
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1240
1309
|
val: bn4(receipt.val),
|
1241
1310
|
pc: bn4(receipt.pc),
|
1242
1311
|
is: bn4(receipt.is)
|
@@ -1246,7 +1315,7 @@ function assembleReceiptByType(receipt) {
|
|
1246
1315
|
case "RETURN_DATA" /* ReturnData */: {
|
1247
1316
|
const returnDataReceipt = {
|
1248
1317
|
type: ReceiptType.ReturnData,
|
1249
|
-
id: hexOrZero(receipt.
|
1318
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1250
1319
|
ptr: bn4(receipt.ptr),
|
1251
1320
|
len: bn4(receipt.len),
|
1252
1321
|
digest: hexOrZero(receipt.digest),
|
@@ -1258,7 +1327,7 @@ function assembleReceiptByType(receipt) {
|
|
1258
1327
|
case "PANIC" /* Panic */: {
|
1259
1328
|
const panicReceipt = {
|
1260
1329
|
type: ReceiptType.Panic,
|
1261
|
-
id: hexOrZero(receipt.
|
1330
|
+
id: hexOrZero(receipt.id),
|
1262
1331
|
reason: bn4(receipt.reason),
|
1263
1332
|
pc: bn4(receipt.pc),
|
1264
1333
|
is: bn4(receipt.is),
|
@@ -1269,7 +1338,7 @@ function assembleReceiptByType(receipt) {
|
|
1269
1338
|
case "REVERT" /* Revert */: {
|
1270
1339
|
const revertReceipt = {
|
1271
1340
|
type: ReceiptType.Revert,
|
1272
|
-
id: hexOrZero(receipt.
|
1341
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1273
1342
|
val: bn4(receipt.ra),
|
1274
1343
|
pc: bn4(receipt.pc),
|
1275
1344
|
is: bn4(receipt.is)
|
@@ -1279,7 +1348,7 @@ function assembleReceiptByType(receipt) {
|
|
1279
1348
|
case "LOG" /* Log */: {
|
1280
1349
|
const logReceipt = {
|
1281
1350
|
type: ReceiptType.Log,
|
1282
|
-
id: hexOrZero(receipt.
|
1351
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1283
1352
|
val0: bn4(receipt.ra),
|
1284
1353
|
val1: bn4(receipt.rb),
|
1285
1354
|
val2: bn4(receipt.rc),
|
@@ -1292,7 +1361,7 @@ function assembleReceiptByType(receipt) {
|
|
1292
1361
|
case "LOG_DATA" /* LogData */: {
|
1293
1362
|
const logDataReceipt = {
|
1294
1363
|
type: ReceiptType.LogData,
|
1295
|
-
id: hexOrZero(receipt.
|
1364
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1296
1365
|
val0: bn4(receipt.ra),
|
1297
1366
|
val1: bn4(receipt.rb),
|
1298
1367
|
ptr: bn4(receipt.ptr),
|
@@ -1306,8 +1375,8 @@ function assembleReceiptByType(receipt) {
|
|
1306
1375
|
case "TRANSFER" /* Transfer */: {
|
1307
1376
|
const transferReceipt = {
|
1308
1377
|
type: ReceiptType.Transfer,
|
1309
|
-
from: hexOrZero(receipt.
|
1310
|
-
to: hexOrZero(receipt.toAddress || receipt?.to
|
1378
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1379
|
+
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1311
1380
|
amount: bn4(receipt.amount),
|
1312
1381
|
assetId: hexOrZero(receipt.assetId),
|
1313
1382
|
pc: bn4(receipt.pc),
|
@@ -1318,8 +1387,8 @@ function assembleReceiptByType(receipt) {
|
|
1318
1387
|
case "TRANSFER_OUT" /* TransferOut */: {
|
1319
1388
|
const transferOutReceipt = {
|
1320
1389
|
type: ReceiptType.TransferOut,
|
1321
|
-
from: hexOrZero(receipt.
|
1322
|
-
to: hexOrZero(receipt.toAddress || receipt.to
|
1390
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1391
|
+
to: hexOrZero(receipt.toAddress || receipt.to),
|
1323
1392
|
amount: bn4(receipt.amount),
|
1324
1393
|
assetId: hexOrZero(receipt.assetId),
|
1325
1394
|
pc: bn4(receipt.pc),
|
@@ -1362,7 +1431,7 @@ function assembleReceiptByType(receipt) {
|
|
1362
1431
|
return receiptMessageOut;
|
1363
1432
|
}
|
1364
1433
|
case "MINT" /* Mint */: {
|
1365
|
-
const contractId = hexOrZero(receipt.
|
1434
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1366
1435
|
const subId = hexOrZero(receipt.subId);
|
1367
1436
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
1368
1437
|
const mintReceipt = {
|
@@ -1377,7 +1446,7 @@ function assembleReceiptByType(receipt) {
|
|
1377
1446
|
return mintReceipt;
|
1378
1447
|
}
|
1379
1448
|
case "BURN" /* Burn */: {
|
1380
|
-
const contractId = hexOrZero(receipt.
|
1449
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1381
1450
|
const subId = hexOrZero(receipt.subId);
|
1382
1451
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
1383
1452
|
const burnReceipt = {
|
@@ -1462,7 +1531,6 @@ var buildBlockExplorerUrl = (options = {}) => {
|
|
1462
1531
|
import { bn as bn5 } from "@fuel-ts/math";
|
1463
1532
|
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
1464
1533
|
import { arrayify as arrayify3 } from "@fuel-ts/utils";
|
1465
|
-
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1466
1534
|
var getGasUsedFromReceipts = (receipts) => {
|
1467
1535
|
const scriptResult = receipts.filter(
|
1468
1536
|
(receipt) => receipt.type === ReceiptType2.ScriptResult
|
@@ -1483,18 +1551,28 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
1483
1551
|
}
|
1484
1552
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
1485
1553
|
const witnessCache = [];
|
1486
|
-
const
|
1554
|
+
const chargeableInputs = inputs.filter((input) => {
|
1555
|
+
const isCoinOrMessage = "owner" in input || "sender" in input;
|
1556
|
+
if (isCoinOrMessage) {
|
1557
|
+
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1558
|
+
return true;
|
1559
|
+
}
|
1560
|
+
if (!witnessCache.includes(input.witnessIndex)) {
|
1561
|
+
witnessCache.push(input.witnessIndex);
|
1562
|
+
return true;
|
1563
|
+
}
|
1564
|
+
}
|
1565
|
+
return false;
|
1566
|
+
});
|
1567
|
+
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
1568
|
+
const totalGas = chargeableInputs.reduce((total, input) => {
|
1487
1569
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1488
1570
|
return total.add(
|
1489
|
-
|
1571
|
+
vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
|
1490
1572
|
);
|
1491
1573
|
}
|
1492
|
-
|
1493
|
-
|
1494
|
-
return total.add(gasCosts.ecr1);
|
1495
|
-
}
|
1496
|
-
return total;
|
1497
|
-
}, bn5());
|
1574
|
+
return total.add(gasCosts.ecr1);
|
1575
|
+
}, bn5(0));
|
1498
1576
|
return totalGas;
|
1499
1577
|
}
|
1500
1578
|
function getMinGas(params) {
|
@@ -1506,12 +1584,20 @@ function getMinGas(params) {
|
|
1506
1584
|
return minGas;
|
1507
1585
|
}
|
1508
1586
|
function getMaxGas(params) {
|
1509
|
-
const {
|
1587
|
+
const {
|
1588
|
+
gasPerByte,
|
1589
|
+
witnessesLength,
|
1590
|
+
witnessLimit,
|
1591
|
+
minGas,
|
1592
|
+
gasLimit = bn5(0),
|
1593
|
+
maxGasPerTx
|
1594
|
+
} = params;
|
1510
1595
|
let remainingAllowedWitnessGas = bn5(0);
|
1511
1596
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
1512
1597
|
remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
1513
1598
|
}
|
1514
|
-
|
1599
|
+
const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
1600
|
+
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
1515
1601
|
}
|
1516
1602
|
function calculateMetadataGasForTxCreate({
|
1517
1603
|
gasCosts,
|
@@ -1533,6 +1619,10 @@ function calculateMetadataGasForTxScript({
|
|
1533
1619
|
}) {
|
1534
1620
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1535
1621
|
}
|
1622
|
+
var calculateGasFee = (params) => {
|
1623
|
+
const { gas, gasPrice, priceFactor, tip } = params;
|
1624
|
+
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1625
|
+
};
|
1536
1626
|
|
1537
1627
|
// src/providers/utils/json.ts
|
1538
1628
|
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
@@ -1689,7 +1779,7 @@ var witnessify = (value) => {
|
|
1689
1779
|
// src/providers/transaction-request/transaction-request.ts
|
1690
1780
|
var BaseTransactionRequest = class {
|
1691
1781
|
/** Gas price for transaction */
|
1692
|
-
|
1782
|
+
tip;
|
1693
1783
|
/** Block until which tx cannot be included */
|
1694
1784
|
maturity;
|
1695
1785
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -1708,7 +1798,7 @@ var BaseTransactionRequest = class {
|
|
1708
1798
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
1709
1799
|
*/
|
1710
1800
|
constructor({
|
1711
|
-
|
1801
|
+
tip,
|
1712
1802
|
maturity,
|
1713
1803
|
maxFee,
|
1714
1804
|
witnessLimit,
|
@@ -1716,7 +1806,7 @@ var BaseTransactionRequest = class {
|
|
1716
1806
|
outputs,
|
1717
1807
|
witnesses
|
1718
1808
|
} = {}) {
|
1719
|
-
this.
|
1809
|
+
this.tip = bn7(tip);
|
1720
1810
|
this.maturity = maturity ?? 0;
|
1721
1811
|
this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
|
1722
1812
|
this.maxFee = maxFee ? bn7(maxFee) : void 0;
|
@@ -1727,9 +1817,9 @@ var BaseTransactionRequest = class {
|
|
1727
1817
|
static getPolicyMeta(req) {
|
1728
1818
|
let policyTypes = 0;
|
1729
1819
|
const policies = [];
|
1730
|
-
if (req.
|
1731
|
-
policyTypes += PolicyType.
|
1732
|
-
policies.push({ data: req.
|
1820
|
+
if (req.tip) {
|
1821
|
+
policyTypes += PolicyType.Tip;
|
1822
|
+
policies.push({ data: req.tip, type: PolicyType.Tip });
|
1733
1823
|
}
|
1734
1824
|
if (req.witnessLimit) {
|
1735
1825
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -1913,13 +2003,11 @@ var BaseTransactionRequest = class {
|
|
1913
2003
|
* assetId, if one it was not added yet.
|
1914
2004
|
*
|
1915
2005
|
* @param coin - Coin resource.
|
1916
|
-
* @param predicate - Predicate bytes.
|
1917
|
-
* @param predicateData - Predicate data bytes.
|
1918
2006
|
*/
|
1919
|
-
addCoinInput(coin
|
2007
|
+
addCoinInput(coin) {
|
1920
2008
|
const { assetId, owner, amount } = coin;
|
1921
2009
|
let witnessIndex;
|
1922
|
-
if (predicate) {
|
2010
|
+
if (coin.predicate) {
|
1923
2011
|
witnessIndex = 0;
|
1924
2012
|
} else {
|
1925
2013
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -1934,8 +2022,7 @@ var BaseTransactionRequest = class {
|
|
1934
2022
|
amount,
|
1935
2023
|
assetId,
|
1936
2024
|
txPointer: "0x00000000000000000000000000000000",
|
1937
|
-
witnessIndex
|
1938
|
-
predicate: predicate?.bytes
|
2025
|
+
witnessIndex
|
1939
2026
|
};
|
1940
2027
|
this.pushInput(input);
|
1941
2028
|
this.addChangeOutput(owner, assetId);
|
@@ -1945,14 +2032,12 @@ var BaseTransactionRequest = class {
|
|
1945
2032
|
* baseAssetId, if one it was not added yet.
|
1946
2033
|
*
|
1947
2034
|
* @param message - Message resource.
|
1948
|
-
* @param predicate - Predicate bytes.
|
1949
|
-
* @param predicateData - Predicate data bytes.
|
1950
2035
|
*/
|
1951
|
-
addMessageInput(message
|
2036
|
+
addMessageInput(message) {
|
1952
2037
|
const { recipient, sender, amount } = message;
|
1953
2038
|
const assetId = BaseAssetId2;
|
1954
2039
|
let witnessIndex;
|
1955
|
-
if (predicate) {
|
2040
|
+
if (message.predicate) {
|
1956
2041
|
witnessIndex = 0;
|
1957
2042
|
} else {
|
1958
2043
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -1966,8 +2051,7 @@ var BaseTransactionRequest = class {
|
|
1966
2051
|
sender: sender.toB256(),
|
1967
2052
|
recipient: recipient.toB256(),
|
1968
2053
|
amount,
|
1969
|
-
witnessIndex
|
1970
|
-
predicate: predicate?.bytes
|
2054
|
+
witnessIndex
|
1971
2055
|
};
|
1972
2056
|
this.pushInput(input);
|
1973
2057
|
this.addChangeOutput(recipient, assetId);
|
@@ -1998,32 +2082,6 @@ var BaseTransactionRequest = class {
|
|
1998
2082
|
resources.forEach((resource) => this.addResource(resource));
|
1999
2083
|
return this;
|
2000
2084
|
}
|
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
|
-
}
|
2027
2085
|
/**
|
2028
2086
|
* Adds a coin output to the transaction.
|
2029
2087
|
*
|
@@ -2103,7 +2161,7 @@ var BaseTransactionRequest = class {
|
|
2103
2161
|
}
|
2104
2162
|
calculateMaxGas(chainInfo, minGas) {
|
2105
2163
|
const { consensusParameters } = chainInfo;
|
2106
|
-
const { gasPerByte } = consensusParameters;
|
2164
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2107
2165
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2108
2166
|
(acc, wit) => acc + wit.dataLength,
|
2109
2167
|
0
|
@@ -2112,7 +2170,8 @@ var BaseTransactionRequest = class {
|
|
2112
2170
|
gasPerByte,
|
2113
2171
|
minGas,
|
2114
2172
|
witnessesLength,
|
2115
|
-
witnessLimit: this.witnessLimit
|
2173
|
+
witnessLimit: this.witnessLimit,
|
2174
|
+
maxGasPerTx
|
2116
2175
|
});
|
2117
2176
|
}
|
2118
2177
|
/**
|
@@ -2130,17 +2189,20 @@ var BaseTransactionRequest = class {
|
|
2130
2189
|
});
|
2131
2190
|
const updateAssetInput = (assetId, quantity) => {
|
2132
2191
|
const assetInput = findAssetInput(assetId);
|
2192
|
+
let usedQuantity = quantity;
|
2193
|
+
if (assetId === BaseAssetId2) {
|
2194
|
+
usedQuantity = bn7("1000000000000000000");
|
2195
|
+
}
|
2133
2196
|
if (assetInput && "assetId" in assetInput) {
|
2134
2197
|
assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
|
2135
|
-
assetInput.amount =
|
2198
|
+
assetInput.amount = usedQuantity;
|
2136
2199
|
} else {
|
2137
2200
|
this.addResources([
|
2138
2201
|
{
|
2139
2202
|
id: hexlify7(randomBytes(UTXO_ID_LEN2)),
|
2140
|
-
amount:
|
2203
|
+
amount: usedQuantity,
|
2141
2204
|
assetId,
|
2142
2205
|
owner: resourcesOwner || Address.fromRandom(),
|
2143
|
-
maturity: 0,
|
2144
2206
|
blockCreated: bn7(1),
|
2145
2207
|
txCreatedIdx: bn7(1)
|
2146
2208
|
}
|
@@ -2172,7 +2234,7 @@ var BaseTransactionRequest = class {
|
|
2172
2234
|
toJSON() {
|
2173
2235
|
return normalizeJSON(this);
|
2174
2236
|
}
|
2175
|
-
|
2237
|
+
updatePredicateGasUsed(inputs) {
|
2176
2238
|
this.inputs.forEach((i) => {
|
2177
2239
|
let correspondingInput;
|
2178
2240
|
switch (i.type) {
|
@@ -2194,6 +2256,15 @@ var BaseTransactionRequest = class {
|
|
2194
2256
|
}
|
2195
2257
|
});
|
2196
2258
|
}
|
2259
|
+
shiftPredicateData() {
|
2260
|
+
this.inputs.forEach((input) => {
|
2261
|
+
if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
|
2262
|
+
input.predicateData = input.padPredicateData(
|
2263
|
+
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2264
|
+
);
|
2265
|
+
}
|
2266
|
+
});
|
2267
|
+
}
|
2197
2268
|
};
|
2198
2269
|
|
2199
2270
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2340,9 +2411,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2340
2411
|
return {
|
2341
2412
|
type: TransactionType3.Create,
|
2342
2413
|
...baseTransaction,
|
2343
|
-
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2344
2414
|
bytecodeWitnessIndex,
|
2345
|
-
storageSlotsCount: storageSlots.length,
|
2415
|
+
storageSlotsCount: bn9(storageSlots.length),
|
2346
2416
|
salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
|
2347
2417
|
storageSlots
|
2348
2418
|
};
|
@@ -2465,8 +2535,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2465
2535
|
type: TransactionType4.Script,
|
2466
2536
|
scriptGasLimit: this.gasLimit,
|
2467
2537
|
...super.getBaseTransaction(),
|
2468
|
-
scriptLength: script.length,
|
2469
|
-
scriptDataLength: scriptData.length,
|
2538
|
+
scriptLength: bn10(script.length),
|
2539
|
+
scriptDataLength: bn10(scriptData.length),
|
2470
2540
|
receiptsRoot: ZeroBytes327,
|
2471
2541
|
script: hexlify10(script),
|
2472
2542
|
scriptData: hexlify10(scriptData)
|
@@ -2530,7 +2600,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2530
2600
|
}
|
2531
2601
|
calculateMaxGas(chainInfo, minGas) {
|
2532
2602
|
const { consensusParameters } = chainInfo;
|
2533
|
-
const { gasPerByte } = consensusParameters;
|
2603
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2534
2604
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2535
2605
|
(acc, wit) => acc + wit.dataLength,
|
2536
2606
|
0
|
@@ -2540,7 +2610,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2540
2610
|
minGas,
|
2541
2611
|
witnessesLength,
|
2542
2612
|
witnessLimit: this.witnessLimit,
|
2543
|
-
gasLimit: this.gasLimit
|
2613
|
+
gasLimit: this.gasLimit,
|
2614
|
+
maxGasPerTx
|
2544
2615
|
});
|
2545
2616
|
}
|
2546
2617
|
/**
|
@@ -2597,7 +2668,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2597
2668
|
|
2598
2669
|
// src/providers/transaction-request/utils.ts
|
2599
2670
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2600
|
-
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2671
|
+
import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
|
2601
2672
|
var transactionRequestify = (obj) => {
|
2602
2673
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2603
2674
|
return obj;
|
@@ -2615,14 +2686,31 @@ var transactionRequestify = (obj) => {
|
|
2615
2686
|
}
|
2616
2687
|
}
|
2617
2688
|
};
|
2689
|
+
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2690
|
+
(acc, input) => {
|
2691
|
+
if (input.type === InputType5.Coin && input.owner === owner) {
|
2692
|
+
acc.utxos.push(input.id);
|
2693
|
+
}
|
2694
|
+
if (input.type === InputType5.Message && input.recipient === owner) {
|
2695
|
+
acc.messages.push(input.nonce);
|
2696
|
+
}
|
2697
|
+
return acc;
|
2698
|
+
},
|
2699
|
+
{
|
2700
|
+
utxos: [],
|
2701
|
+
messages: []
|
2702
|
+
}
|
2703
|
+
);
|
2618
2704
|
|
2619
2705
|
// src/providers/transaction-response/transaction-response.ts
|
2620
2706
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2621
|
-
import { bn as
|
2707
|
+
import { bn as bn15 } from "@fuel-ts/math";
|
2622
2708
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2623
2709
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2624
2710
|
|
2625
2711
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2712
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
2713
|
+
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2626
2714
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2627
2715
|
|
2628
2716
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
@@ -2631,9 +2719,10 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
|
|
2631
2719
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2632
2720
|
var calculateTransactionFee = (params) => {
|
2633
2721
|
const {
|
2634
|
-
|
2722
|
+
gasPrice,
|
2635
2723
|
rawPayload,
|
2636
|
-
|
2724
|
+
tip,
|
2725
|
+
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2637
2726
|
} = params;
|
2638
2727
|
const gasPerByte = bn11(feeParams.gasPerByte);
|
2639
2728
|
const gasPriceFactor = bn11(feeParams.gasPriceFactor);
|
@@ -2643,8 +2732,7 @@ var calculateTransactionFee = (params) => {
|
|
2643
2732
|
return {
|
2644
2733
|
fee: bn11(0),
|
2645
2734
|
minFee: bn11(0),
|
2646
|
-
maxFee: bn11(0)
|
2647
|
-
feeFromGasUsed: bn11(0)
|
2735
|
+
maxFee: bn11(0)
|
2648
2736
|
};
|
2649
2737
|
}
|
2650
2738
|
const { type, witnesses, inputs, policies } = transaction;
|
@@ -2676,7 +2764,6 @@ var calculateTransactionFee = (params) => {
|
|
2676
2764
|
metadataGas,
|
2677
2765
|
txBytesSize: transactionBytes.length
|
2678
2766
|
});
|
2679
|
-
const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
|
2680
2767
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
|
2681
2768
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2682
2769
|
const maxGas = getMaxGas({
|
@@ -2684,17 +2771,25 @@ var calculateTransactionFee = (params) => {
|
|
2684
2771
|
minGas,
|
2685
2772
|
witnessesLength,
|
2686
2773
|
gasLimit,
|
2687
|
-
witnessLimit
|
2774
|
+
witnessLimit,
|
2775
|
+
maxGasPerTx
|
2776
|
+
});
|
2777
|
+
const minFee = calculateGasFee({
|
2778
|
+
gasPrice,
|
2779
|
+
gas: minGas,
|
2780
|
+
priceFactor: gasPriceFactor,
|
2781
|
+
tip
|
2782
|
+
});
|
2783
|
+
const maxFee = calculateGasFee({
|
2784
|
+
gasPrice,
|
2785
|
+
gas: maxGas,
|
2786
|
+
priceFactor: gasPriceFactor,
|
2787
|
+
tip
|
2688
2788
|
});
|
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);
|
2693
2789
|
return {
|
2694
|
-
fee,
|
2695
2790
|
minFee,
|
2696
2791
|
maxFee,
|
2697
|
-
|
2792
|
+
fee: maxFee
|
2698
2793
|
};
|
2699
2794
|
};
|
2700
2795
|
|
@@ -2750,7 +2845,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2750
2845
|
|
2751
2846
|
// src/providers/transaction-summary/input.ts
|
2752
2847
|
import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2753
|
-
import { InputType as
|
2848
|
+
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
2754
2849
|
function getInputsByTypes(inputs, types) {
|
2755
2850
|
return inputs.filter((i) => types.includes(i.type));
|
2756
2851
|
}
|
@@ -2758,16 +2853,16 @@ function getInputsByType(inputs, type) {
|
|
2758
2853
|
return inputs.filter((i) => i.type === type);
|
2759
2854
|
}
|
2760
2855
|
function getInputsCoin(inputs) {
|
2761
|
-
return getInputsByType(inputs,
|
2856
|
+
return getInputsByType(inputs, InputType6.Coin);
|
2762
2857
|
}
|
2763
2858
|
function getInputsMessage(inputs) {
|
2764
|
-
return getInputsByType(inputs,
|
2859
|
+
return getInputsByType(inputs, InputType6.Message);
|
2765
2860
|
}
|
2766
2861
|
function getInputsCoinAndMessage(inputs) {
|
2767
|
-
return getInputsByTypes(inputs, [
|
2862
|
+
return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
|
2768
2863
|
}
|
2769
2864
|
function getInputsContract(inputs) {
|
2770
|
-
return getInputsByType(inputs,
|
2865
|
+
return getInputsByType(inputs, InputType6.Contract);
|
2771
2866
|
}
|
2772
2867
|
function getInputFromAssetId(inputs, assetId) {
|
2773
2868
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2786,7 +2881,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2786
2881
|
if (!contractInput) {
|
2787
2882
|
return void 0;
|
2788
2883
|
}
|
2789
|
-
if (contractInput.type !==
|
2884
|
+
if (contractInput.type !== InputType6.Contract) {
|
2790
2885
|
throw new FuelError9(
|
2791
2886
|
ErrorCode9.INVALID_TRANSACTION_INPUT,
|
2792
2887
|
`Contract input should be of type 'contract'.`
|
@@ -2795,10 +2890,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2795
2890
|
return contractInput;
|
2796
2891
|
}
|
2797
2892
|
function getInputAccountAddress(input) {
|
2798
|
-
if (input.type ===
|
2893
|
+
if (input.type === InputType6.Coin) {
|
2799
2894
|
return input.owner.toString();
|
2800
2895
|
}
|
2801
|
-
if (input.type ===
|
2896
|
+
if (input.type === InputType6.Message) {
|
2802
2897
|
return input.recipient.toString();
|
2803
2898
|
}
|
2804
2899
|
return "";
|
@@ -3308,7 +3403,9 @@ function assembleTransactionSummary(params) {
|
|
3308
3403
|
gqlTransactionStatus,
|
3309
3404
|
abiMap = {},
|
3310
3405
|
maxInputs,
|
3311
|
-
gasCosts
|
3406
|
+
gasCosts,
|
3407
|
+
maxGasPerTx,
|
3408
|
+
gasPrice
|
3312
3409
|
} = params;
|
3313
3410
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3314
3411
|
const rawPayload = hexlify11(transactionBytes);
|
@@ -3322,11 +3419,14 @@ function assembleTransactionSummary(params) {
|
|
3322
3419
|
maxInputs
|
3323
3420
|
});
|
3324
3421
|
const typeName = getTransactionTypeName(transaction.type);
|
3422
|
+
const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3325
3423
|
const { fee } = calculateTransactionFee({
|
3326
|
-
|
3424
|
+
gasPrice,
|
3327
3425
|
rawPayload,
|
3426
|
+
tip,
|
3328
3427
|
consensusParameters: {
|
3329
3428
|
gasCosts,
|
3429
|
+
maxGasPerTx,
|
3330
3430
|
feeParams: {
|
3331
3431
|
gasPerByte,
|
3332
3432
|
gasPriceFactor
|
@@ -3386,7 +3486,7 @@ var TransactionResponse = class {
|
|
3386
3486
|
/** Current provider */
|
3387
3487
|
provider;
|
3388
3488
|
/** Gas used on the transaction */
|
3389
|
-
gasUsed =
|
3489
|
+
gasUsed = bn15(0);
|
3390
3490
|
/** The graphql Transaction with receipts object. */
|
3391
3491
|
gqlTransaction;
|
3392
3492
|
abis;
|
@@ -3464,8 +3564,13 @@ var TransactionResponse = class {
|
|
3464
3564
|
const decodedTransaction = this.decodeTransaction(
|
3465
3565
|
transaction
|
3466
3566
|
);
|
3467
|
-
|
3468
|
-
|
3567
|
+
let txReceipts = [];
|
3568
|
+
if (transaction?.status && "receipts" in transaction.status) {
|
3569
|
+
txReceipts = transaction.status.receipts;
|
3570
|
+
}
|
3571
|
+
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3572
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3573
|
+
const gasPrice = await this.provider.getLatestGasPrice();
|
3469
3574
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3470
3575
|
const transactionSummary = assembleTransactionSummary({
|
3471
3576
|
id: this.id,
|
@@ -3477,7 +3582,9 @@ var TransactionResponse = class {
|
|
3477
3582
|
gasPriceFactor,
|
3478
3583
|
abiMap: contractsAbiMap,
|
3479
3584
|
maxInputs,
|
3480
|
-
gasCosts
|
3585
|
+
gasCosts,
|
3586
|
+
maxGasPerTx,
|
3587
|
+
gasPrice
|
3481
3588
|
});
|
3482
3589
|
return transactionSummary;
|
3483
3590
|
}
|
@@ -3604,29 +3711,29 @@ var processGqlChain = (chain) => {
|
|
3604
3711
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3605
3712
|
return {
|
3606
3713
|
name,
|
3607
|
-
baseChainHeight:
|
3714
|
+
baseChainHeight: bn16(daHeight),
|
3608
3715
|
consensusParameters: {
|
3609
|
-
contractMaxSize:
|
3610
|
-
maxInputs:
|
3611
|
-
maxOutputs:
|
3612
|
-
maxWitnesses:
|
3613
|
-
maxGasPerTx:
|
3614
|
-
maxScriptLength:
|
3615
|
-
maxScriptDataLength:
|
3616
|
-
maxStorageSlots:
|
3617
|
-
maxPredicateLength:
|
3618
|
-
maxPredicateDataLength:
|
3619
|
-
maxGasPerPredicate:
|
3620
|
-
gasPriceFactor:
|
3621
|
-
gasPerByte:
|
3622
|
-
maxMessageDataLength:
|
3623
|
-
chainId:
|
3716
|
+
contractMaxSize: bn16(contractParams.contractMaxSize),
|
3717
|
+
maxInputs: bn16(txParams.maxInputs),
|
3718
|
+
maxOutputs: bn16(txParams.maxOutputs),
|
3719
|
+
maxWitnesses: bn16(txParams.maxWitnesses),
|
3720
|
+
maxGasPerTx: bn16(txParams.maxGasPerTx),
|
3721
|
+
maxScriptLength: bn16(scriptParams.maxScriptLength),
|
3722
|
+
maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
|
3723
|
+
maxStorageSlots: bn16(contractParams.maxStorageSlots),
|
3724
|
+
maxPredicateLength: bn16(predicateParams.maxPredicateLength),
|
3725
|
+
maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
|
3726
|
+
maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
|
3727
|
+
gasPriceFactor: bn16(feeParams.gasPriceFactor),
|
3728
|
+
gasPerByte: bn16(feeParams.gasPerByte),
|
3729
|
+
maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
|
3730
|
+
chainId: bn16(consensusParameters.chainId),
|
3624
3731
|
gasCosts
|
3625
3732
|
},
|
3626
3733
|
gasCosts,
|
3627
3734
|
latestBlock: {
|
3628
3735
|
id: latestBlock.id,
|
3629
|
-
height:
|
3736
|
+
height: bn16(latestBlock.height),
|
3630
3737
|
time: latestBlock.header.time,
|
3631
3738
|
transactions: latestBlock.transactions.map((i) => ({
|
3632
3739
|
id: i.id
|
@@ -3720,10 +3827,8 @@ var _Provider = class {
|
|
3720
3827
|
* Returns some helpful parameters related to gas fees.
|
3721
3828
|
*/
|
3722
3829
|
getGasConfig() {
|
3723
|
-
const { minGasPrice } = this.getNode();
|
3724
3830
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3725
3831
|
return {
|
3726
|
-
minGasPrice,
|
3727
3832
|
maxGasPerTx,
|
3728
3833
|
maxGasPerPredicate,
|
3729
3834
|
gasPriceFactor,
|
@@ -3821,7 +3926,7 @@ var _Provider = class {
|
|
3821
3926
|
*/
|
3822
3927
|
async getBlockNumber() {
|
3823
3928
|
const { chain } = await this.operations.getChain();
|
3824
|
-
return
|
3929
|
+
return bn16(chain.latestBlock.height, 10);
|
3825
3930
|
}
|
3826
3931
|
/**
|
3827
3932
|
* Returns the chain information.
|
@@ -3831,13 +3936,11 @@ var _Provider = class {
|
|
3831
3936
|
async fetchNode() {
|
3832
3937
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3833
3938
|
const processedNodeInfo = {
|
3834
|
-
maxDepth:
|
3835
|
-
maxTx:
|
3836
|
-
minGasPrice: bn15(nodeInfo.minGasPrice),
|
3939
|
+
maxDepth: bn16(nodeInfo.maxDepth),
|
3940
|
+
maxTx: bn16(nodeInfo.maxTx),
|
3837
3941
|
nodeVersion: nodeInfo.nodeVersion,
|
3838
3942
|
utxoValidation: nodeInfo.utxoValidation,
|
3839
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
3840
|
-
peers: nodeInfo.peers
|
3943
|
+
vmBacktrace: nodeInfo.vmBacktrace
|
3841
3944
|
};
|
3842
3945
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
3843
3946
|
return processedNodeInfo;
|
@@ -3923,14 +4026,13 @@ var _Provider = class {
|
|
3923
4026
|
return this.estimateTxDependencies(transactionRequest);
|
3924
4027
|
}
|
3925
4028
|
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
3926
|
-
const { dryRun:
|
3927
|
-
encodedTransaction,
|
4029
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4030
|
+
encodedTransactions: encodedTransaction,
|
3928
4031
|
utxoValidation: utxoValidation || false
|
3929
4032
|
});
|
3930
|
-
const receipts =
|
3931
|
-
|
3932
|
-
|
3933
|
-
};
|
4033
|
+
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
4034
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
4035
|
+
return { receipts, dryrunStatus: status };
|
3934
4036
|
}
|
3935
4037
|
/**
|
3936
4038
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -3956,7 +4058,7 @@ var _Provider = class {
|
|
3956
4058
|
} = response;
|
3957
4059
|
if (inputs) {
|
3958
4060
|
inputs.forEach((input, index) => {
|
3959
|
-
if ("predicateGasUsed" in input &&
|
4061
|
+
if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
|
3960
4062
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3961
4063
|
}
|
3962
4064
|
});
|
@@ -3969,9 +4071,6 @@ var _Provider = class {
|
|
3969
4071
|
* If there are missing variable outputs,
|
3970
4072
|
* `addVariableOutputs` is called on the transaction.
|
3971
4073
|
*
|
3972
|
-
* @privateRemarks
|
3973
|
-
* TODO: Investigate support for missing contract IDs
|
3974
|
-
* TODO: Add support for missing output messages
|
3975
4074
|
*
|
3976
4075
|
* @param transactionRequest - The transaction request object.
|
3977
4076
|
* @returns A promise.
|
@@ -3984,16 +4083,19 @@ var _Provider = class {
|
|
3984
4083
|
missingContractIds: []
|
3985
4084
|
};
|
3986
4085
|
}
|
3987
|
-
await this.estimatePredicates(transactionRequest);
|
3988
4086
|
let receipts = [];
|
3989
4087
|
const missingContractIds = [];
|
3990
4088
|
let outputVariables = 0;
|
4089
|
+
let dryrunStatus;
|
3991
4090
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3992
|
-
const {
|
3993
|
-
|
4091
|
+
const {
|
4092
|
+
dryRun: [{ receipts: rawReceipts, status }]
|
4093
|
+
} = await this.operations.dryRun({
|
4094
|
+
encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
|
3994
4095
|
utxoValidation: false
|
3995
4096
|
});
|
3996
|
-
receipts =
|
4097
|
+
receipts = rawReceipts.map(processGqlReceipt);
|
4098
|
+
dryrunStatus = status;
|
3997
4099
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
3998
4100
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
3999
4101
|
if (hasMissingOutputs) {
|
@@ -4003,6 +4105,10 @@ var _Provider = class {
|
|
4003
4105
|
transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
|
4004
4106
|
missingContractIds.push(contractId);
|
4005
4107
|
});
|
4108
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
4109
|
+
transactionRequest
|
4110
|
+
});
|
4111
|
+
transactionRequest.maxFee = maxFee;
|
4006
4112
|
} else {
|
4007
4113
|
break;
|
4008
4114
|
}
|
@@ -4010,37 +4116,136 @@ var _Provider = class {
|
|
4010
4116
|
return {
|
4011
4117
|
receipts,
|
4012
4118
|
outputVariables,
|
4013
|
-
missingContractIds
|
4119
|
+
missingContractIds,
|
4120
|
+
dryrunStatus
|
4014
4121
|
};
|
4015
4122
|
}
|
4123
|
+
/**
|
4124
|
+
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
4125
|
+
*
|
4126
|
+
* Transactions are dry run in batches. After each dry run, transactions requiring
|
4127
|
+
* further modifications are identified. The method iteratively updates these transactions
|
4128
|
+
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
4129
|
+
*
|
4130
|
+
* @param transactionRequests - Array of transaction request objects.
|
4131
|
+
* @returns A promise that resolves to an array of results for each transaction.
|
4132
|
+
*/
|
4133
|
+
async estimateMultipleTxDependencies(transactionRequests) {
|
4134
|
+
const results = transactionRequests.map(() => ({
|
4135
|
+
receipts: [],
|
4136
|
+
outputVariables: 0,
|
4137
|
+
missingContractIds: [],
|
4138
|
+
dryrunStatus: void 0
|
4139
|
+
}));
|
4140
|
+
const allRequests = clone3(transactionRequests);
|
4141
|
+
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4142
|
+
allRequests.forEach((req, index) => {
|
4143
|
+
if (req.type === TransactionType8.Script) {
|
4144
|
+
serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
|
4145
|
+
}
|
4146
|
+
});
|
4147
|
+
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
4148
|
+
let attempt = 0;
|
4149
|
+
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
4150
|
+
const encodedTransactions = transactionsToProcess.map(
|
4151
|
+
(index) => serializedTransactionsMap.get(index)
|
4152
|
+
);
|
4153
|
+
const dryRunResults = await this.operations.dryRun({
|
4154
|
+
encodedTransactions,
|
4155
|
+
utxoValidation: false
|
4156
|
+
});
|
4157
|
+
const nextRoundTransactions = [];
|
4158
|
+
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
4159
|
+
const requestIdx = transactionsToProcess[i];
|
4160
|
+
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4161
|
+
const result = results[requestIdx];
|
4162
|
+
result.receipts = rawReceipts.map(processGqlReceipt);
|
4163
|
+
result.dryrunStatus = status;
|
4164
|
+
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4165
|
+
result.receipts
|
4166
|
+
);
|
4167
|
+
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4168
|
+
const request = allRequests[requestIdx];
|
4169
|
+
if (hasMissingOutputs && request?.type === TransactionType8.Script) {
|
4170
|
+
result.outputVariables += missingOutputVariables.length;
|
4171
|
+
request.addVariableOutputs(missingOutputVariables.length);
|
4172
|
+
missingOutputContractIds.forEach(({ contractId }) => {
|
4173
|
+
request.addContractInputAndOutput(Address2.fromString(contractId));
|
4174
|
+
result.missingContractIds.push(contractId);
|
4175
|
+
});
|
4176
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
4177
|
+
transactionRequest: request
|
4178
|
+
});
|
4179
|
+
request.maxFee = maxFee;
|
4180
|
+
serializedTransactionsMap.set(requestIdx, hexlify12(request.toTransactionBytes()));
|
4181
|
+
nextRoundTransactions.push(requestIdx);
|
4182
|
+
}
|
4183
|
+
}
|
4184
|
+
transactionsToProcess = nextRoundTransactions;
|
4185
|
+
attempt += 1;
|
4186
|
+
}
|
4187
|
+
return results;
|
4188
|
+
}
|
4189
|
+
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
4190
|
+
if (estimateTxDependencies) {
|
4191
|
+
return this.estimateMultipleTxDependencies(transactionRequests);
|
4192
|
+
}
|
4193
|
+
const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
|
4194
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4195
|
+
encodedTransactions,
|
4196
|
+
utxoValidation: utxoValidation || false
|
4197
|
+
});
|
4198
|
+
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4199
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
4200
|
+
return { receipts, dryrunStatus: status };
|
4201
|
+
});
|
4202
|
+
return results;
|
4203
|
+
}
|
4016
4204
|
/**
|
4017
4205
|
* Estimates the transaction gas and fee based on the provided transaction request.
|
4018
4206
|
* @param transactionRequest - The transaction request object.
|
4019
4207
|
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
4020
4208
|
*/
|
4021
|
-
estimateTxGasAndFee(params) {
|
4209
|
+
async estimateTxGasAndFee(params) {
|
4022
4210
|
const { transactionRequest } = params;
|
4023
|
-
|
4211
|
+
let { gasPrice } = params;
|
4024
4212
|
const chainInfo = this.getChain();
|
4025
|
-
const
|
4026
|
-
transactionRequest.gasPrice = gasPrice;
|
4213
|
+
const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
|
4027
4214
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
4028
|
-
|
4215
|
+
if (!gasPrice) {
|
4216
|
+
gasPrice = await this.estimateGasPrice(10);
|
4217
|
+
}
|
4218
|
+
const minFee = calculateGasFee({
|
4219
|
+
gasPrice: bn16(gasPrice),
|
4220
|
+
gas: minGas,
|
4221
|
+
priceFactor: gasPriceFactor,
|
4222
|
+
tip: transactionRequest.tip
|
4223
|
+
}).add(1);
|
4224
|
+
let gasLimit = bn16(0);
|
4029
4225
|
if (transactionRequest.type === TransactionType8.Script) {
|
4226
|
+
gasLimit = transactionRequest.gasLimit;
|
4030
4227
|
if (transactionRequest.gasLimit.eq(0)) {
|
4031
4228
|
transactionRequest.gasLimit = minGas;
|
4032
4229
|
transactionRequest.gasLimit = maxGasPerTx.sub(
|
4033
4230
|
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
4034
4231
|
);
|
4232
|
+
gasLimit = transactionRequest.gasLimit;
|
4035
4233
|
}
|
4036
4234
|
}
|
4037
4235
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4038
|
-
const maxFee =
|
4236
|
+
const maxFee = calculateGasFee({
|
4237
|
+
gasPrice: bn16(gasPrice),
|
4238
|
+
gas: maxGas,
|
4239
|
+
priceFactor: gasPriceFactor,
|
4240
|
+
tip: transactionRequest.tip
|
4241
|
+
}).add(1);
|
4039
4242
|
return {
|
4040
4243
|
minGas,
|
4041
4244
|
minFee,
|
4042
4245
|
maxGas,
|
4043
|
-
maxFee
|
4246
|
+
maxFee,
|
4247
|
+
gasPrice,
|
4248
|
+
gasLimit
|
4044
4249
|
};
|
4045
4250
|
}
|
4046
4251
|
/**
|
@@ -4058,15 +4263,17 @@ var _Provider = class {
|
|
4058
4263
|
if (estimateTxDependencies) {
|
4059
4264
|
return this.estimateTxDependencies(transactionRequest);
|
4060
4265
|
}
|
4061
|
-
const
|
4062
|
-
const { dryRun:
|
4063
|
-
|
4266
|
+
const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
|
4267
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4268
|
+
encodedTransactions,
|
4064
4269
|
utxoValidation: true
|
4065
4270
|
});
|
4066
|
-
const
|
4067
|
-
|
4068
|
-
receipts
|
4069
|
-
|
4271
|
+
const callResult = dryRunStatuses.map((dryRunStatus) => {
|
4272
|
+
const { id, receipts, status } = dryRunStatus;
|
4273
|
+
const processedReceipts = receipts.map(processGqlReceipt);
|
4274
|
+
return { id, receipts: processedReceipts, status };
|
4275
|
+
});
|
4276
|
+
return { receipts: callResult[0].receipts };
|
4070
4277
|
}
|
4071
4278
|
/**
|
4072
4279
|
* Returns a transaction cost to enable user
|
@@ -4083,77 +4290,79 @@ var _Provider = class {
|
|
4083
4290
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
4084
4291
|
* @returns A promise that resolves to the transaction cost object.
|
4085
4292
|
*/
|
4086
|
-
async getTransactionCost(transactionRequestLike,
|
4087
|
-
estimateTxDependencies = true,
|
4088
|
-
estimatePredicates = true,
|
4089
|
-
resourcesOwner,
|
4090
|
-
signatureCallback
|
4091
|
-
} = {}) {
|
4293
|
+
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
4092
4294
|
const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
|
4093
|
-
const { minGasPrice } = this.getGasConfig();
|
4094
|
-
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
4095
4295
|
const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
|
4096
4296
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4097
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
4297
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4098
4298
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
4299
|
+
txRequestClone.maxFee = bn16(0);
|
4099
4300
|
if (isScriptTransaction) {
|
4100
|
-
txRequestClone.gasLimit =
|
4301
|
+
txRequestClone.gasLimit = bn16(0);
|
4101
4302
|
}
|
4102
|
-
if (
|
4103
|
-
|
4104
|
-
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
4105
|
-
}
|
4106
|
-
await this.estimatePredicates(txRequestClone);
|
4303
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4304
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
4107
4305
|
}
|
4306
|
+
const signedRequest = clone3(txRequestClone);
|
4307
|
+
let addedSignatures = 0;
|
4108
4308
|
if (signatureCallback && isScriptTransaction) {
|
4109
|
-
|
4309
|
+
const lengthBefore = signedRequest.witnesses.length;
|
4310
|
+
await signatureCallback(signedRequest);
|
4311
|
+
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
4110
4312
|
}
|
4111
|
-
|
4112
|
-
|
4313
|
+
await this.estimatePredicates(signedRequest);
|
4314
|
+
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
4315
|
+
transactionRequest: signedRequest
|
4113
4316
|
});
|
4114
4317
|
let receipts = [];
|
4115
4318
|
let missingContractIds = [];
|
4116
4319
|
let outputVariables = 0;
|
4117
|
-
let gasUsed =
|
4118
|
-
|
4119
|
-
|
4320
|
+
let gasUsed = bn16(0);
|
4321
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4322
|
+
txRequestClone.maxFee = maxFee;
|
4323
|
+
if (isScriptTransaction) {
|
4324
|
+
txRequestClone.gasLimit = gasLimit;
|
4325
|
+
if (signatureCallback) {
|
4326
|
+
await signatureCallback(txRequestClone);
|
4327
|
+
}
|
4120
4328
|
const result = await this.estimateTxDependencies(txRequestClone);
|
4121
4329
|
receipts = result.receipts;
|
4122
4330
|
outputVariables = result.outputVariables;
|
4123
4331
|
missingContractIds = result.missingContractIds;
|
4124
4332
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4125
4333
|
txRequestClone.gasLimit = gasUsed;
|
4126
|
-
|
4127
|
-
|
4128
|
-
|
4334
|
+
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
4335
|
+
transactionRequest: txRequestClone,
|
4336
|
+
gasPrice
|
4129
4337
|
}));
|
4130
4338
|
}
|
4131
4339
|
return {
|
4132
4340
|
requiredQuantities: allQuantities,
|
4133
4341
|
receipts,
|
4134
4342
|
gasUsed,
|
4135
|
-
|
4136
|
-
gasPrice: setGasPrice,
|
4343
|
+
gasPrice,
|
4137
4344
|
minGas,
|
4138
4345
|
maxGas,
|
4139
4346
|
minFee,
|
4140
4347
|
maxFee,
|
4141
|
-
estimatedInputs: txRequestClone.inputs,
|
4142
4348
|
outputVariables,
|
4143
|
-
missingContractIds
|
4349
|
+
missingContractIds,
|
4350
|
+
addedSignatures,
|
4351
|
+
estimatedPredicates: txRequestClone.inputs
|
4144
4352
|
};
|
4145
4353
|
}
|
4146
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
4354
|
+
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
4147
4355
|
const ownerAddress = Address2.fromAddressOrString(owner);
|
4148
4356
|
const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
|
4149
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
4357
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, {
|
4358
|
+
quantitiesToContract
|
4359
|
+
});
|
4150
4360
|
transactionRequest.addResources(
|
4151
4361
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
4152
4362
|
);
|
4153
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4154
|
-
|
4155
|
-
|
4156
|
-
);
|
4363
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
|
4364
|
+
quantitiesToContract
|
4365
|
+
});
|
4157
4366
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
4158
4367
|
return {
|
4159
4368
|
resources,
|
@@ -4175,11 +4384,10 @@ var _Provider = class {
|
|
4175
4384
|
return coins.map((coin) => ({
|
4176
4385
|
id: coin.utxoId,
|
4177
4386
|
assetId: coin.assetId,
|
4178
|
-
amount:
|
4387
|
+
amount: bn16(coin.amount),
|
4179
4388
|
owner: Address2.fromAddressOrString(coin.owner),
|
4180
|
-
|
4181
|
-
|
4182
|
-
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4389
|
+
blockCreated: bn16(coin.blockCreated),
|
4390
|
+
txCreatedIdx: bn16(coin.txCreatedIdx)
|
4183
4391
|
}));
|
4184
4392
|
}
|
4185
4393
|
/**
|
@@ -4216,9 +4424,9 @@ var _Provider = class {
|
|
4216
4424
|
switch (coin.__typename) {
|
4217
4425
|
case "MessageCoin":
|
4218
4426
|
return {
|
4219
|
-
amount:
|
4427
|
+
amount: bn16(coin.amount),
|
4220
4428
|
assetId: coin.assetId,
|
4221
|
-
daHeight:
|
4429
|
+
daHeight: bn16(coin.daHeight),
|
4222
4430
|
sender: Address2.fromAddressOrString(coin.sender),
|
4223
4431
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4224
4432
|
nonce: coin.nonce
|
@@ -4226,12 +4434,11 @@ var _Provider = class {
|
|
4226
4434
|
case "Coin":
|
4227
4435
|
return {
|
4228
4436
|
id: coin.utxoId,
|
4229
|
-
amount:
|
4437
|
+
amount: bn16(coin.amount),
|
4230
4438
|
assetId: coin.assetId,
|
4231
4439
|
owner: Address2.fromAddressOrString(coin.owner),
|
4232
|
-
|
4233
|
-
|
4234
|
-
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4440
|
+
blockCreated: bn16(coin.blockCreated),
|
4441
|
+
txCreatedIdx: bn16(coin.txCreatedIdx)
|
4235
4442
|
};
|
4236
4443
|
default:
|
4237
4444
|
return null;
|
@@ -4248,13 +4455,13 @@ var _Provider = class {
|
|
4248
4455
|
async getBlock(idOrHeight) {
|
4249
4456
|
let variables;
|
4250
4457
|
if (typeof idOrHeight === "number") {
|
4251
|
-
variables = { height:
|
4458
|
+
variables = { height: bn16(idOrHeight).toString(10) };
|
4252
4459
|
} else if (idOrHeight === "latest") {
|
4253
4460
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4254
4461
|
} else if (idOrHeight.length === 66) {
|
4255
4462
|
variables = { blockId: idOrHeight };
|
4256
4463
|
} else {
|
4257
|
-
variables = { blockId:
|
4464
|
+
variables = { blockId: bn16(idOrHeight).toString(10) };
|
4258
4465
|
}
|
4259
4466
|
const { block } = await this.operations.getBlock(variables);
|
4260
4467
|
if (!block) {
|
@@ -4262,7 +4469,7 @@ var _Provider = class {
|
|
4262
4469
|
}
|
4263
4470
|
return {
|
4264
4471
|
id: block.id,
|
4265
|
-
height:
|
4472
|
+
height: bn16(block.height),
|
4266
4473
|
time: block.header.time,
|
4267
4474
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4268
4475
|
};
|
@@ -4277,7 +4484,7 @@ var _Provider = class {
|
|
4277
4484
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4278
4485
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4279
4486
|
id: block.id,
|
4280
|
-
height:
|
4487
|
+
height: bn16(block.height),
|
4281
4488
|
time: block.header.time,
|
4282
4489
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4283
4490
|
}));
|
@@ -4292,7 +4499,7 @@ var _Provider = class {
|
|
4292
4499
|
async getBlockWithTransactions(idOrHeight) {
|
4293
4500
|
let variables;
|
4294
4501
|
if (typeof idOrHeight === "number") {
|
4295
|
-
variables = { blockHeight:
|
4502
|
+
variables = { blockHeight: bn16(idOrHeight).toString(10) };
|
4296
4503
|
} else if (idOrHeight === "latest") {
|
4297
4504
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4298
4505
|
} else {
|
@@ -4304,7 +4511,7 @@ var _Provider = class {
|
|
4304
4511
|
}
|
4305
4512
|
return {
|
4306
4513
|
id: block.id,
|
4307
|
-
height:
|
4514
|
+
height: bn16(block.height, 10),
|
4308
4515
|
time: block.header.time,
|
4309
4516
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4310
4517
|
transactions: block.transactions.map(
|
@@ -4353,7 +4560,7 @@ var _Provider = class {
|
|
4353
4560
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4354
4561
|
asset: hexlify12(assetId)
|
4355
4562
|
});
|
4356
|
-
return
|
4563
|
+
return bn16(contractBalance.amount, 10);
|
4357
4564
|
}
|
4358
4565
|
/**
|
4359
4566
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4367,7 +4574,7 @@ var _Provider = class {
|
|
4367
4574
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4368
4575
|
assetId: hexlify12(assetId)
|
4369
4576
|
});
|
4370
|
-
return
|
4577
|
+
return bn16(balance.amount, 10);
|
4371
4578
|
}
|
4372
4579
|
/**
|
4373
4580
|
* Returns balances for the given owner.
|
@@ -4385,7 +4592,7 @@ var _Provider = class {
|
|
4385
4592
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4386
4593
|
return balances.map((balance) => ({
|
4387
4594
|
assetId: balance.assetId,
|
4388
|
-
amount:
|
4595
|
+
amount: bn16(balance.amount)
|
4389
4596
|
}));
|
4390
4597
|
}
|
4391
4598
|
/**
|
@@ -4407,15 +4614,15 @@ var _Provider = class {
|
|
4407
4614
|
sender: message.sender,
|
4408
4615
|
recipient: message.recipient,
|
4409
4616
|
nonce: message.nonce,
|
4410
|
-
amount:
|
4617
|
+
amount: bn16(message.amount),
|
4411
4618
|
data: message.data
|
4412
4619
|
}),
|
4413
4620
|
sender: Address2.fromAddressOrString(message.sender),
|
4414
4621
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4415
4622
|
nonce: message.nonce,
|
4416
|
-
amount:
|
4623
|
+
amount: bn16(message.amount),
|
4417
4624
|
data: InputMessageCoder.decodeData(message.data),
|
4418
|
-
daHeight:
|
4625
|
+
daHeight: bn16(message.daHeight)
|
4419
4626
|
}));
|
4420
4627
|
}
|
4421
4628
|
/**
|
@@ -4468,44 +4675,60 @@ var _Provider = class {
|
|
4468
4675
|
} = result.messageProof;
|
4469
4676
|
return {
|
4470
4677
|
messageProof: {
|
4471
|
-
proofIndex:
|
4678
|
+
proofIndex: bn16(messageProof.proofIndex),
|
4472
4679
|
proofSet: messageProof.proofSet
|
4473
4680
|
},
|
4474
4681
|
blockProof: {
|
4475
|
-
proofIndex:
|
4682
|
+
proofIndex: bn16(blockProof.proofIndex),
|
4476
4683
|
proofSet: blockProof.proofSet
|
4477
4684
|
},
|
4478
4685
|
messageBlockHeader: {
|
4479
4686
|
id: messageBlockHeader.id,
|
4480
|
-
daHeight:
|
4481
|
-
transactionsCount:
|
4687
|
+
daHeight: bn16(messageBlockHeader.daHeight),
|
4688
|
+
transactionsCount: bn16(messageBlockHeader.transactionsCount),
|
4482
4689
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4483
|
-
height:
|
4690
|
+
height: bn16(messageBlockHeader.height),
|
4484
4691
|
prevRoot: messageBlockHeader.prevRoot,
|
4485
4692
|
time: messageBlockHeader.time,
|
4486
4693
|
applicationHash: messageBlockHeader.applicationHash,
|
4487
|
-
|
4488
|
-
|
4694
|
+
messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount),
|
4695
|
+
messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
|
4696
|
+
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4697
|
+
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4698
|
+
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4489
4699
|
},
|
4490
4700
|
commitBlockHeader: {
|
4491
4701
|
id: commitBlockHeader.id,
|
4492
|
-
daHeight:
|
4493
|
-
transactionsCount:
|
4702
|
+
daHeight: bn16(commitBlockHeader.daHeight),
|
4703
|
+
transactionsCount: bn16(commitBlockHeader.transactionsCount),
|
4494
4704
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4495
|
-
height:
|
4705
|
+
height: bn16(commitBlockHeader.height),
|
4496
4706
|
prevRoot: commitBlockHeader.prevRoot,
|
4497
4707
|
time: commitBlockHeader.time,
|
4498
4708
|
applicationHash: commitBlockHeader.applicationHash,
|
4499
|
-
|
4500
|
-
|
4709
|
+
messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount),
|
4710
|
+
messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
|
4711
|
+
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4712
|
+
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4713
|
+
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4501
4714
|
},
|
4502
4715
|
sender: Address2.fromAddressOrString(sender),
|
4503
4716
|
recipient: Address2.fromAddressOrString(recipient),
|
4504
4717
|
nonce,
|
4505
|
-
amount:
|
4718
|
+
amount: bn16(amount),
|
4506
4719
|
data
|
4507
4720
|
};
|
4508
4721
|
}
|
4722
|
+
async getLatestGasPrice() {
|
4723
|
+
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4724
|
+
return bn16(latestGasPrice.gasPrice);
|
4725
|
+
}
|
4726
|
+
async estimateGasPrice(blockHorizon) {
|
4727
|
+
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4728
|
+
blockHorizon: String(blockHorizon)
|
4729
|
+
});
|
4730
|
+
return bn16(estimateGasPrice.gasPrice);
|
4731
|
+
}
|
4509
4732
|
/**
|
4510
4733
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
4511
4734
|
*
|
@@ -4525,10 +4748,10 @@ var _Provider = class {
|
|
4525
4748
|
*/
|
4526
4749
|
async produceBlocks(amount, startTime) {
|
4527
4750
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4528
|
-
blocksToProduce:
|
4751
|
+
blocksToProduce: bn16(amount).toString(10),
|
4529
4752
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4530
4753
|
});
|
4531
|
-
return
|
4754
|
+
return bn16(latestBlockHeight);
|
4532
4755
|
}
|
4533
4756
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4534
4757
|
async getTransactionResponse(transactionId) {
|
@@ -4542,7 +4765,7 @@ cacheInputs_fn = function(inputs) {
|
|
4542
4765
|
return;
|
4543
4766
|
}
|
4544
4767
|
inputs.forEach((input) => {
|
4545
|
-
if (input.type ===
|
4768
|
+
if (input.type === InputType7.Coin) {
|
4546
4769
|
this.cache?.set(input.id);
|
4547
4770
|
}
|
4548
4771
|
});
|
@@ -4552,7 +4775,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4552
4775
|
|
4553
4776
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4554
4777
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4555
|
-
import { bn as
|
4778
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
4556
4779
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4557
4780
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4558
4781
|
async function getTransactionSummary(params) {
|
@@ -4570,21 +4793,28 @@ async function getTransactionSummary(params) {
|
|
4570
4793
|
arrayify12(gqlTransaction.rawPayload),
|
4571
4794
|
0
|
4572
4795
|
);
|
4573
|
-
|
4796
|
+
let txReceipts = [];
|
4797
|
+
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
4798
|
+
txReceipts = gqlTransaction.status.receipts;
|
4799
|
+
}
|
4800
|
+
const receipts = txReceipts.map(processGqlReceipt);
|
4574
4801
|
const {
|
4575
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
4802
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
4576
4803
|
} = provider.getChain();
|
4804
|
+
const gasPrice = await provider.getLatestGasPrice();
|
4577
4805
|
const transactionInfo = assembleTransactionSummary({
|
4578
4806
|
id: gqlTransaction.id,
|
4579
4807
|
receipts,
|
4580
4808
|
transaction: decodedTransaction,
|
4581
4809
|
transactionBytes: arrayify12(gqlTransaction.rawPayload),
|
4582
4810
|
gqlTransactionStatus: gqlTransaction.status,
|
4583
|
-
gasPerByte:
|
4584
|
-
gasPriceFactor:
|
4811
|
+
gasPerByte: bn17(gasPerByte),
|
4812
|
+
gasPriceFactor: bn17(gasPriceFactor),
|
4585
4813
|
abiMap,
|
4586
4814
|
maxInputs,
|
4587
|
-
gasCosts
|
4815
|
+
gasCosts,
|
4816
|
+
maxGasPerTx,
|
4817
|
+
gasPrice
|
4588
4818
|
});
|
4589
4819
|
return {
|
4590
4820
|
gqlTransaction,
|
@@ -4594,10 +4824,11 @@ async function getTransactionSummary(params) {
|
|
4594
4824
|
async function getTransactionSummaryFromRequest(params) {
|
4595
4825
|
const { provider, transactionRequest, abiMap } = params;
|
4596
4826
|
const { receipts } = await provider.call(transactionRequest);
|
4597
|
-
const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
|
4827
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
|
4598
4828
|
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
4599
4829
|
const transaction = transactionRequest.toTransaction();
|
4600
4830
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
4831
|
+
const gasPrice = await provider.getLatestGasPrice();
|
4601
4832
|
const transactionSummary = assembleTransactionSummary({
|
4602
4833
|
receipts,
|
4603
4834
|
transaction,
|
@@ -4606,7 +4837,9 @@ async function getTransactionSummaryFromRequest(params) {
|
|
4606
4837
|
gasPerByte,
|
4607
4838
|
gasPriceFactor,
|
4608
4839
|
maxInputs,
|
4609
|
-
gasCosts
|
4840
|
+
gasCosts,
|
4841
|
+
maxGasPerTx,
|
4842
|
+
gasPrice
|
4610
4843
|
});
|
4611
4844
|
return transactionSummary;
|
4612
4845
|
}
|
@@ -4615,13 +4848,18 @@ async function getTransactionsSummaries(params) {
|
|
4615
4848
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
4616
4849
|
const { edges, pageInfo } = transactionsByOwner;
|
4617
4850
|
const {
|
4618
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
4851
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
4619
4852
|
} = provider.getChain();
|
4853
|
+
const gasPrice = await provider.getLatestGasPrice();
|
4620
4854
|
const transactions = edges.map((edge) => {
|
4621
4855
|
const { node: gqlTransaction } = edge;
|
4622
|
-
const { id, rawPayload,
|
4856
|
+
const { id, rawPayload, status } = gqlTransaction;
|
4623
4857
|
const [decodedTransaction] = new TransactionCoder6().decode(arrayify12(rawPayload), 0);
|
4624
|
-
|
4858
|
+
let txReceipts = [];
|
4859
|
+
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
4860
|
+
txReceipts = gqlTransaction.status.receipts;
|
4861
|
+
}
|
4862
|
+
const receipts = txReceipts.map(processGqlReceipt);
|
4625
4863
|
const transactionSummary = assembleTransactionSummary({
|
4626
4864
|
id,
|
4627
4865
|
receipts,
|
@@ -4632,7 +4870,9 @@ async function getTransactionsSummaries(params) {
|
|
4632
4870
|
gasPerByte,
|
4633
4871
|
gasPriceFactor,
|
4634
4872
|
maxInputs,
|
4635
|
-
gasCosts
|
4873
|
+
gasCosts,
|
4874
|
+
maxGasPerTx,
|
4875
|
+
gasPrice
|
4636
4876
|
});
|
4637
4877
|
const output = {
|
4638
4878
|
gqlTransaction,
|
@@ -4964,36 +5204,33 @@ var Account = class extends AbstractAccount {
|
|
4964
5204
|
* @param fee - The estimated transaction fee.
|
4965
5205
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4966
5206
|
*/
|
4967
|
-
async fund(request,
|
4968
|
-
const
|
4969
|
-
|
5207
|
+
async fund(request, params) {
|
5208
|
+
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
5209
|
+
const txRequest = request;
|
5210
|
+
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5211
|
+
amount: bn18(fee),
|
4970
5212
|
assetId: BaseAssetId3,
|
4971
|
-
coinQuantities
|
5213
|
+
coinQuantities: requiredQuantities
|
4972
5214
|
});
|
4973
5215
|
const quantitiesDict = {};
|
4974
|
-
|
5216
|
+
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
4975
5217
|
quantitiesDict[assetId] = {
|
4976
5218
|
required: amount,
|
4977
|
-
owned:
|
5219
|
+
owned: bn18(0)
|
4978
5220
|
};
|
4979
5221
|
});
|
4980
|
-
|
4981
|
-
const cachedMessages = [];
|
4982
|
-
const owner = this.address.toB256();
|
4983
|
-
request.inputs.forEach((input) => {
|
5222
|
+
txRequest.inputs.forEach((input) => {
|
4984
5223
|
const isResource = "amount" in input;
|
4985
5224
|
if (isResource) {
|
4986
5225
|
const isCoin2 = "owner" in input;
|
4987
5226
|
if (isCoin2) {
|
4988
5227
|
const assetId = String(input.assetId);
|
4989
|
-
if (
|
4990
|
-
const amount =
|
5228
|
+
if (quantitiesDict[assetId]) {
|
5229
|
+
const amount = bn18(input.amount);
|
4991
5230
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4992
|
-
cachedUtxos.push(input.id);
|
4993
5231
|
}
|
4994
|
-
} else if (input.
|
5232
|
+
} else if (input.amount && quantitiesDict[BaseAssetId3]) {
|
4995
5233
|
quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
|
4996
|
-
cachedMessages.push(input.nonce);
|
4997
5234
|
}
|
4998
5235
|
}
|
4999
5236
|
});
|
@@ -5008,12 +5245,21 @@ var Account = class extends AbstractAccount {
|
|
5008
5245
|
});
|
5009
5246
|
const needsToBeFunded = missingQuantities.length;
|
5010
5247
|
if (needsToBeFunded) {
|
5011
|
-
const
|
5012
|
-
|
5013
|
-
|
5014
|
-
|
5015
|
-
|
5016
|
-
|
5248
|
+
const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
|
5249
|
+
const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
|
5250
|
+
txRequest.addResources(resources);
|
5251
|
+
}
|
5252
|
+
txRequest.shiftPredicateData();
|
5253
|
+
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
5254
|
+
const requestToReestimate = clone4(txRequest);
|
5255
|
+
if (addedSignatures) {
|
5256
|
+
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
5257
|
+
}
|
5258
|
+
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
5259
|
+
transactionRequest: requestToReestimate
|
5260
|
+
});
|
5261
|
+
txRequest.maxFee = maxFee;
|
5262
|
+
return txRequest;
|
5017
5263
|
}
|
5018
5264
|
/**
|
5019
5265
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -5021,28 +5267,24 @@ var Account = class extends AbstractAccount {
|
|
5021
5267
|
* @param destination - The address of the destination.
|
5022
5268
|
* @param amount - The amount of coins to transfer.
|
5023
5269
|
* @param assetId - The asset ID of the coins to transfer.
|
5024
|
-
* @param txParams - The transaction parameters (gasLimit,
|
5270
|
+
* @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
|
5025
5271
|
* @returns A promise that resolves to the prepared transaction request.
|
5026
5272
|
*/
|
5027
5273
|
async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
5028
|
-
const
|
5029
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
5030
|
-
const request = new ScriptTransactionRequest(params);
|
5274
|
+
const request = new ScriptTransactionRequest(txParams);
|
5031
5275
|
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
|
5032
|
-
const
|
5276
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
5033
5277
|
estimateTxDependencies: true,
|
5034
5278
|
resourcesOwner: this
|
5035
5279
|
});
|
5036
|
-
|
5037
|
-
|
5038
|
-
|
5039
|
-
|
5040
|
-
gasPrice: request.gasPrice,
|
5041
|
-
gasLimit: request.gasLimit,
|
5042
|
-
minGasPrice
|
5280
|
+
this.validateGasLimitAndMaxFee({
|
5281
|
+
gasUsed: txCost.gasUsed,
|
5282
|
+
maxFee: txCost.maxFee,
|
5283
|
+
txParams
|
5043
5284
|
});
|
5044
|
-
|
5045
|
-
request.
|
5285
|
+
request.gasLimit = txCost.gasUsed;
|
5286
|
+
request.maxFee = txCost.maxFee;
|
5287
|
+
await this.fund(request, txCost);
|
5046
5288
|
return request;
|
5047
5289
|
}
|
5048
5290
|
/**
|
@@ -5055,7 +5297,7 @@ var Account = class extends AbstractAccount {
|
|
5055
5297
|
* @returns A promise that resolves to the transaction response.
|
5056
5298
|
*/
|
5057
5299
|
async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
5058
|
-
if (
|
5300
|
+
if (bn18(amount).lte(0)) {
|
5059
5301
|
throw new FuelError15(
|
5060
5302
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5061
5303
|
"Transfer amount must be a positive number."
|
@@ -5074,38 +5316,36 @@ var Account = class extends AbstractAccount {
|
|
5074
5316
|
* @returns A promise that resolves to the transaction response.
|
5075
5317
|
*/
|
5076
5318
|
async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
|
5077
|
-
if (
|
5319
|
+
if (bn18(amount).lte(0)) {
|
5078
5320
|
throw new FuelError15(
|
5079
5321
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5080
5322
|
"Transfer amount must be a positive number."
|
5081
5323
|
);
|
5082
5324
|
}
|
5083
5325
|
const contractAddress = Address3.fromAddressOrString(contractId);
|
5084
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
5085
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
5086
5326
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5087
5327
|
hexlifiedContractId: contractAddress.toB256(),
|
5088
|
-
amountToTransfer:
|
5328
|
+
amountToTransfer: bn18(amount),
|
5089
5329
|
assetId
|
5090
5330
|
});
|
5091
5331
|
const request = new ScriptTransactionRequest({
|
5092
|
-
...
|
5332
|
+
...txParams,
|
5093
5333
|
script,
|
5094
5334
|
scriptData
|
5095
5335
|
});
|
5096
5336
|
request.addContractInputAndOutput(contractAddress);
|
5097
|
-
const
|
5098
|
-
|
5099
|
-
[{ amount:
|
5100
|
-
);
|
5101
|
-
|
5102
|
-
|
5103
|
-
|
5104
|
-
|
5105
|
-
gasLimit: request.gasLimit,
|
5106
|
-
minGasPrice
|
5337
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
5338
|
+
resourcesOwner: this,
|
5339
|
+
quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
|
5340
|
+
});
|
5341
|
+
this.validateGasLimitAndMaxFee({
|
5342
|
+
gasUsed: txCost.gasUsed,
|
5343
|
+
maxFee: txCost.maxFee,
|
5344
|
+
txParams
|
5107
5345
|
});
|
5108
|
-
|
5346
|
+
request.gasLimit = txCost.gasUsed;
|
5347
|
+
request.maxFee = txCost.maxFee;
|
5348
|
+
await this.fund(request, txCost);
|
5109
5349
|
return this.sendTransaction(request);
|
5110
5350
|
}
|
5111
5351
|
/**
|
@@ -5117,34 +5357,30 @@ var Account = class extends AbstractAccount {
|
|
5117
5357
|
* @returns A promise that resolves to the transaction response.
|
5118
5358
|
*/
|
5119
5359
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5120
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
5121
5360
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
5122
5361
|
const recipientDataArray = arrayify14(
|
5123
5362
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5124
5363
|
);
|
5125
5364
|
const amountDataArray = arrayify14(
|
5126
|
-
"0x".concat(
|
5365
|
+
"0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
|
5127
5366
|
);
|
5128
5367
|
const script = new Uint8Array([
|
5129
5368
|
...arrayify14(withdrawScript.bytes),
|
5130
5369
|
...recipientDataArray,
|
5131
5370
|
...amountDataArray
|
5132
5371
|
]);
|
5133
|
-
const params = { script,
|
5372
|
+
const params = { script, ...txParams };
|
5134
5373
|
const request = new ScriptTransactionRequest(params);
|
5135
|
-
const
|
5136
|
-
const
|
5137
|
-
|
5138
|
-
|
5139
|
-
|
5140
|
-
|
5141
|
-
this.validateGas({
|
5142
|
-
gasUsed,
|
5143
|
-
gasPrice: request.gasPrice,
|
5144
|
-
gasLimit: request.gasLimit,
|
5145
|
-
minGasPrice
|
5374
|
+
const quantitiesToContract = [{ amount: bn18(amount), assetId: BaseAssetId3 }];
|
5375
|
+
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5376
|
+
this.validateGasLimitAndMaxFee({
|
5377
|
+
gasUsed: txCost.gasUsed,
|
5378
|
+
maxFee: txCost.maxFee,
|
5379
|
+
txParams
|
5146
5380
|
});
|
5147
|
-
|
5381
|
+
request.maxFee = txCost.maxFee;
|
5382
|
+
request.gasLimit = txCost.gasUsed;
|
5383
|
+
await this.fund(request, txCost);
|
5148
5384
|
return this.sendTransaction(request);
|
5149
5385
|
}
|
5150
5386
|
async signMessage(message) {
|
@@ -5202,22 +5438,21 @@ var Account = class extends AbstractAccount {
|
|
5202
5438
|
}
|
5203
5439
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5204
5440
|
}
|
5205
|
-
|
5441
|
+
validateGasLimitAndMaxFee({
|
5442
|
+
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
|
5206
5443
|
gasUsed,
|
5207
|
-
|
5208
|
-
gasLimit,
|
5209
|
-
minGasPrice
|
5444
|
+
maxFee
|
5210
5445
|
}) {
|
5211
|
-
if (
|
5446
|
+
if (isDefined(setGasLimit) && gasUsed.gt(setGasLimit)) {
|
5212
5447
|
throw new FuelError15(
|
5213
|
-
ErrorCode15.
|
5214
|
-
`Gas
|
5448
|
+
ErrorCode15.GAS_LIMIT_TOO_LOW,
|
5449
|
+
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5215
5450
|
);
|
5216
5451
|
}
|
5217
|
-
if (
|
5452
|
+
if (isDefined(setMaxFee) && maxFee.gt(setMaxFee)) {
|
5218
5453
|
throw new FuelError15(
|
5219
|
-
ErrorCode15.
|
5220
|
-
`
|
5454
|
+
ErrorCode15.MAX_FEE_TOO_LOW,
|
5455
|
+
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
5221
5456
|
);
|
5222
5457
|
}
|
5223
5458
|
}
|
@@ -5509,7 +5744,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5509
5744
|
* @param transactionRequestLike - The transaction request to send.
|
5510
5745
|
* @returns A promise that resolves to the TransactionResponse object.
|
5511
5746
|
*/
|
5512
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
5747
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
|
5513
5748
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5514
5749
|
if (estimateTxDependencies) {
|
5515
5750
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -5550,7 +5785,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5550
5785
|
// src/hdwallet/hdwallet.ts
|
5551
5786
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5552
5787
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5553
|
-
import { bn as
|
5788
|
+
import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5554
5789
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5555
5790
|
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5556
5791
|
|
@@ -8022,7 +8257,7 @@ var HDWallet = class {
|
|
8022
8257
|
const IR = bytes.slice(32);
|
8023
8258
|
if (privateKey) {
|
8024
8259
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8025
|
-
const ki =
|
8260
|
+
const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
|
8026
8261
|
return new HDWallet({
|
8027
8262
|
privateKey: ki,
|
8028
8263
|
chainCode: IR,
|
@@ -8711,7 +8946,7 @@ import {
|
|
8711
8946
|
import { Address as Address9 } from "@fuel-ts/address";
|
8712
8947
|
import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
|
8713
8948
|
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
8714
|
-
import { ByteArrayCoder, InputType as
|
8949
|
+
import { ByteArrayCoder, InputType as InputType8 } from "@fuel-ts/transactions";
|
8715
8950
|
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
8716
8951
|
|
8717
8952
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -8771,9 +9006,9 @@ var Predicate = class extends Account {
|
|
8771
9006
|
const request = transactionRequestify(transactionRequestLike);
|
8772
9007
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
8773
9008
|
request.inputs?.forEach((input) => {
|
8774
|
-
if (input.type ===
|
8775
|
-
input.predicate = this.bytes;
|
8776
|
-
input.predicateData = this.getPredicateData(policies.length);
|
9009
|
+
if (input.type === InputType8.Coin && hexlify19(input.owner) === this.address.toB256()) {
|
9010
|
+
input.predicate = hexlify19(this.bytes);
|
9011
|
+
input.predicateData = hexlify19(this.getPredicateData(policies.length));
|
8777
9012
|
}
|
8778
9013
|
});
|
8779
9014
|
return request;
|
@@ -8788,8 +9023,7 @@ var Predicate = class extends Account {
|
|
8788
9023
|
* @returns A promise that resolves to the prepared transaction request.
|
8789
9024
|
*/
|
8790
9025
|
async createTransfer(destination, amount, assetId = BaseAssetId4, txParams = {}) {
|
8791
|
-
|
8792
|
-
return this.populateTransactionPredicateData(request);
|
9026
|
+
return super.createTransfer(destination, amount, assetId, txParams);
|
8793
9027
|
}
|
8794
9028
|
/**
|
8795
9029
|
* Sends a transaction with the populated predicate data.
|
@@ -8797,9 +9031,9 @@ var Predicate = class extends Account {
|
|
8797
9031
|
* @param transactionRequestLike - The transaction request-like object.
|
8798
9032
|
* @returns A promise that resolves to the transaction response.
|
8799
9033
|
*/
|
8800
|
-
sendTransaction(transactionRequestLike
|
8801
|
-
const transactionRequest =
|
8802
|
-
return super.sendTransaction(transactionRequest,
|
9034
|
+
sendTransaction(transactionRequestLike) {
|
9035
|
+
const transactionRequest = transactionRequestify(transactionRequestLike);
|
9036
|
+
return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
|
8803
9037
|
}
|
8804
9038
|
/**
|
8805
9039
|
* Simulates a transaction with the populated predicate data.
|
@@ -8808,8 +9042,8 @@ var Predicate = class extends Account {
|
|
8808
9042
|
* @returns A promise that resolves to the call result.
|
8809
9043
|
*/
|
8810
9044
|
simulateTransaction(transactionRequestLike) {
|
8811
|
-
const transactionRequest =
|
8812
|
-
return super.simulateTransaction(transactionRequest);
|
9045
|
+
const transactionRequest = transactionRequestify(transactionRequestLike);
|
9046
|
+
return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
|
8813
9047
|
}
|
8814
9048
|
getPredicateData(policiesLength) {
|
8815
9049
|
if (!this.predicateData.length) {
|
@@ -8855,6 +9089,25 @@ var Predicate = class extends Account {
|
|
8855
9089
|
predicateInterface: abiInterface
|
8856
9090
|
};
|
8857
9091
|
}
|
9092
|
+
/**
|
9093
|
+
* Retrieves resources satisfying the spend query for the account.
|
9094
|
+
*
|
9095
|
+
* @param quantities - IDs of coins to exclude.
|
9096
|
+
* @param excludedIds - IDs of resources to be excluded from the query.
|
9097
|
+
* @returns A promise that resolves to an array of Resources.
|
9098
|
+
*/
|
9099
|
+
async getResourcesToSpend(quantities, excludedIds) {
|
9100
|
+
const resources = await this.provider.getResourcesToSpend(
|
9101
|
+
this.address,
|
9102
|
+
quantities,
|
9103
|
+
excludedIds
|
9104
|
+
);
|
9105
|
+
return resources.map((resource) => ({
|
9106
|
+
...resource,
|
9107
|
+
predicate: hexlify19(this.bytes),
|
9108
|
+
padPredicateData: (policiesLength) => hexlify19(this.getPredicateData(policiesLength))
|
9109
|
+
}));
|
9110
|
+
}
|
8858
9111
|
/**
|
8859
9112
|
* Sets the configurable constants for the predicate.
|
8860
9113
|
*
|
@@ -9603,7 +9856,7 @@ export {
|
|
9603
9856
|
WalletLocked,
|
9604
9857
|
WalletManager,
|
9605
9858
|
WalletUnlocked,
|
9606
|
-
|
9859
|
+
addAmountToCoinQuantities,
|
9607
9860
|
addOperation,
|
9608
9861
|
assemblePanicError,
|
9609
9862
|
assembleReceiptByType,
|
@@ -9612,9 +9865,10 @@ export {
|
|
9612
9865
|
assets,
|
9613
9866
|
buildBlockExplorerUrl,
|
9614
9867
|
cacheFor,
|
9868
|
+
cacheTxInputsFromOwner,
|
9869
|
+
calculateGasFee,
|
9615
9870
|
calculateMetadataGasForTxCreate,
|
9616
9871
|
calculateMetadataGasForTxScript,
|
9617
|
-
calculatePriceWithFactor,
|
9618
9872
|
calculateTransactionFee,
|
9619
9873
|
coinQuantityfy,
|
9620
9874
|
deferPromise,
|