@fuel-ts/account 0.0.0-rc-2034-20240410113328 → 0.0.0-rc-2021-20240410132122
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/README.md +1 -1
- package/dist/account.d.ts +5 -4
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +798 -564
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +759 -525
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +639 -406
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +10 -2
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +888 -322
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +4 -2
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/message.d.ts +3 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +36 -31
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +2 -2
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +8 -25
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +3 -0
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +8 -2
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +1512 -1063
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +735 -521
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +629 -415
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +17 -17
package/dist/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
|
35
|
+
import { bn as bn18 } from "@fuel-ts/math";
|
36
36
|
import { arrayify as arrayify14 } 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
|
@@ -92,14 +93,10 @@ import { clone as clone3 } from "ramda";
|
|
92
93
|
import gql from "graphql-tag";
|
93
94
|
var ReceiptFragmentFragmentDoc = gql`
|
94
95
|
fragment receiptFragment on Receipt {
|
95
|
-
|
96
|
-
id
|
97
|
-
}
|
96
|
+
id
|
98
97
|
pc
|
99
98
|
is
|
100
|
-
to
|
101
|
-
id
|
102
|
-
}
|
99
|
+
to
|
103
100
|
toAddress
|
104
101
|
amount
|
105
102
|
assetId
|
@@ -137,10 +134,16 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
137
134
|
id
|
138
135
|
}
|
139
136
|
time
|
137
|
+
receipts {
|
138
|
+
...receiptFragment
|
139
|
+
}
|
140
140
|
programState {
|
141
141
|
returnType
|
142
142
|
data
|
143
143
|
}
|
144
|
+
receipts {
|
145
|
+
...receiptFragment
|
146
|
+
}
|
144
147
|
}
|
145
148
|
... on FailureStatus {
|
146
149
|
block {
|
@@ -148,26 +151,24 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
148
151
|
}
|
149
152
|
time
|
150
153
|
reason
|
154
|
+
receipts {
|
155
|
+
...receiptFragment
|
156
|
+
}
|
151
157
|
}
|
152
158
|
... on SqueezedOutStatus {
|
153
159
|
reason
|
154
160
|
}
|
155
161
|
}
|
156
|
-
`;
|
162
|
+
${ReceiptFragmentFragmentDoc}`;
|
157
163
|
var TransactionFragmentFragmentDoc = gql`
|
158
164
|
fragment transactionFragment on Transaction {
|
159
165
|
id
|
160
166
|
rawPayload
|
161
|
-
gasPrice
|
162
|
-
receipts {
|
163
|
-
...receiptFragment
|
164
|
-
}
|
165
167
|
status {
|
166
168
|
...transactionStatusFragment
|
167
169
|
}
|
168
170
|
}
|
169
|
-
${
|
170
|
-
${TransactionStatusFragmentFragmentDoc}`;
|
171
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
171
172
|
var InputEstimatePredicatesFragmentFragmentDoc = gql`
|
172
173
|
fragment inputEstimatePredicatesFragment on Input {
|
173
174
|
... on InputCoin {
|
@@ -185,6 +186,46 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
|
|
185
186
|
}
|
186
187
|
}
|
187
188
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
189
|
+
var DryRunFailureStatusFragmentFragmentDoc = gql`
|
190
|
+
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
191
|
+
reason
|
192
|
+
programState {
|
193
|
+
returnType
|
194
|
+
data
|
195
|
+
}
|
196
|
+
}
|
197
|
+
`;
|
198
|
+
var DryRunSuccessStatusFragmentFragmentDoc = gql`
|
199
|
+
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
200
|
+
programState {
|
201
|
+
returnType
|
202
|
+
data
|
203
|
+
}
|
204
|
+
}
|
205
|
+
`;
|
206
|
+
var DryRunTransactionStatusFragmentFragmentDoc = gql`
|
207
|
+
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
208
|
+
... on DryRunFailureStatus {
|
209
|
+
...dryRunFailureStatusFragment
|
210
|
+
}
|
211
|
+
... on DryRunSuccessStatus {
|
212
|
+
...dryRunSuccessStatusFragment
|
213
|
+
}
|
214
|
+
}
|
215
|
+
${DryRunFailureStatusFragmentFragmentDoc}
|
216
|
+
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
217
|
+
var DryRunTransactionExecutionStatusFragmentFragmentDoc = gql`
|
218
|
+
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
219
|
+
id
|
220
|
+
status {
|
221
|
+
...dryRunTransactionStatusFragment
|
222
|
+
}
|
223
|
+
receipts {
|
224
|
+
...receiptFragment
|
225
|
+
}
|
226
|
+
}
|
227
|
+
${DryRunTransactionStatusFragmentFragmentDoc}
|
228
|
+
${ReceiptFragmentFragmentDoc}`;
|
188
229
|
var CoinFragmentFragmentDoc = gql`
|
189
230
|
fragment coinFragment on Coin {
|
190
231
|
__typename
|
@@ -192,7 +233,6 @@ var CoinFragmentFragmentDoc = gql`
|
|
192
233
|
owner
|
193
234
|
amount
|
194
235
|
assetId
|
195
|
-
maturity
|
196
236
|
blockCreated
|
197
237
|
txCreatedIdx
|
198
238
|
}
|
@@ -237,7 +277,6 @@ var MessageProofFragmentFragmentDoc = gql`
|
|
237
277
|
prevRoot
|
238
278
|
time
|
239
279
|
applicationHash
|
240
|
-
messageReceiptRoot
|
241
280
|
messageReceiptCount
|
242
281
|
}
|
243
282
|
commitBlockHeader {
|
@@ -249,7 +288,6 @@ var MessageProofFragmentFragmentDoc = gql`
|
|
249
288
|
prevRoot
|
250
289
|
time
|
251
290
|
applicationHash
|
252
|
-
messageReceiptRoot
|
253
291
|
messageReceiptCount
|
254
292
|
}
|
255
293
|
sender
|
@@ -269,8 +307,8 @@ var BalanceFragmentFragmentDoc = gql`
|
|
269
307
|
var BlockFragmentFragmentDoc = gql`
|
270
308
|
fragment blockFragment on Block {
|
271
309
|
id
|
310
|
+
height
|
272
311
|
header {
|
273
|
-
height
|
274
312
|
time
|
275
313
|
}
|
276
314
|
transactions {
|
@@ -328,6 +366,11 @@ var DependentCostFragmentFragmentDoc = gql`
|
|
328
366
|
`;
|
329
367
|
var GasCostsFragmentFragmentDoc = gql`
|
330
368
|
fragment GasCostsFragment on GasCosts {
|
369
|
+
version {
|
370
|
+
... on Version {
|
371
|
+
value
|
372
|
+
}
|
373
|
+
}
|
331
374
|
add
|
332
375
|
addi
|
333
376
|
aloc
|
@@ -340,7 +383,6 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
340
383
|
cb
|
341
384
|
cfei
|
342
385
|
cfsi
|
343
|
-
croo
|
344
386
|
div
|
345
387
|
divi
|
346
388
|
ecr1
|
@@ -423,6 +465,9 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
423
465
|
ccp {
|
424
466
|
...DependentCostFragment
|
425
467
|
}
|
468
|
+
croo {
|
469
|
+
...DependentCostFragment
|
470
|
+
}
|
426
471
|
csiz {
|
427
472
|
...DependentCostFragment
|
428
473
|
}
|
@@ -482,6 +527,11 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
482
527
|
${DependentCostFragmentFragmentDoc}`;
|
483
528
|
var ConsensusParametersFragmentFragmentDoc = gql`
|
484
529
|
fragment consensusParametersFragment on ConsensusParameters {
|
530
|
+
version {
|
531
|
+
... on Version {
|
532
|
+
value
|
533
|
+
}
|
534
|
+
}
|
485
535
|
txParams {
|
486
536
|
...TxParametersFragment
|
487
537
|
}
|
@@ -541,18 +591,9 @@ var NodeInfoFragmentFragmentDoc = gql`
|
|
541
591
|
fragment nodeInfoFragment on NodeInfo {
|
542
592
|
utxoValidation
|
543
593
|
vmBacktrace
|
544
|
-
minGasPrice
|
545
594
|
maxTx
|
546
595
|
maxDepth
|
547
596
|
nodeVersion
|
548
|
-
peers {
|
549
|
-
id
|
550
|
-
addresses
|
551
|
-
clientVersion
|
552
|
-
blockHeight
|
553
|
-
lastHeartbeatMs
|
554
|
-
appScore
|
555
|
-
}
|
556
597
|
}
|
557
598
|
`;
|
558
599
|
var GetVersionDocument = gql`
|
@@ -587,13 +628,9 @@ var GetTransactionWithReceiptsDocument = gql`
|
|
587
628
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
588
629
|
transaction(id: $transactionId) {
|
589
630
|
...transactionFragment
|
590
|
-
receipts {
|
591
|
-
...receiptFragment
|
592
|
-
}
|
593
631
|
}
|
594
632
|
}
|
595
|
-
${TransactionFragmentFragmentDoc}
|
596
|
-
${ReceiptFragmentFragmentDoc}`;
|
633
|
+
${TransactionFragmentFragmentDoc}`;
|
597
634
|
var GetTransactionsDocument = gql`
|
598
635
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
599
636
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -721,6 +758,20 @@ var GetBalanceDocument = gql`
|
|
721
758
|
}
|
722
759
|
}
|
723
760
|
${BalanceFragmentFragmentDoc}`;
|
761
|
+
var GetLatestGasPriceDocument = gql`
|
762
|
+
query getLatestGasPrice {
|
763
|
+
latestGasPrice {
|
764
|
+
gasPrice
|
765
|
+
}
|
766
|
+
}
|
767
|
+
`;
|
768
|
+
var EstimateGasPriceDocument = gql`
|
769
|
+
query estimateGasPrice($blockHorizon: U32!) {
|
770
|
+
estimateGasPrice(blockHorizon: $blockHorizon) {
|
771
|
+
gasPrice
|
772
|
+
}
|
773
|
+
}
|
774
|
+
`;
|
724
775
|
var GetBalancesDocument = gql`
|
725
776
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
726
777
|
balances(
|
@@ -775,12 +826,12 @@ var GetMessageStatusDocument = gql`
|
|
775
826
|
}
|
776
827
|
`;
|
777
828
|
var DryRunDocument = gql`
|
778
|
-
mutation dryRun($
|
779
|
-
dryRun(
|
780
|
-
...
|
829
|
+
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
830
|
+
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
831
|
+
...dryRunTransactionExecutionStatusFragment
|
781
832
|
}
|
782
833
|
}
|
783
|
-
${
|
834
|
+
${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
|
784
835
|
var SubmitDocument = gql`
|
785
836
|
mutation submit($encodedTransaction: HexString!) {
|
786
837
|
submit(tx: $encodedTransaction) {
|
@@ -863,6 +914,12 @@ function getSdk(requester) {
|
|
863
914
|
getBalance(variables, options) {
|
864
915
|
return requester(GetBalanceDocument, variables, options);
|
865
916
|
},
|
917
|
+
getLatestGasPrice(variables, options) {
|
918
|
+
return requester(GetLatestGasPriceDocument, variables, options);
|
919
|
+
},
|
920
|
+
estimateGasPrice(variables, options) {
|
921
|
+
return requester(EstimateGasPriceDocument, variables, options);
|
922
|
+
},
|
866
923
|
getBalances(variables, options) {
|
867
924
|
return requester(GetBalancesDocument, variables, options);
|
868
925
|
},
|
@@ -932,11 +989,14 @@ var _FuelGraphqlSubscriber = class {
|
|
932
989
|
let data;
|
933
990
|
let errors;
|
934
991
|
try {
|
935
|
-
|
992
|
+
const sanitizedText = text.replace(/\s/g, "");
|
993
|
+
({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
|
936
994
|
} catch (e) {
|
937
995
|
throw new FuelError(
|
938
996
|
ErrorCode.STREAM_PARSING_ERROR,
|
939
|
-
`Error while parsing stream data response: ${text}
|
997
|
+
`Error while parsing stream data response: ${text}
|
998
|
+
|
999
|
+
Thrown error: ${e}`
|
940
1000
|
);
|
941
1001
|
}
|
942
1002
|
if (Array.isArray(errors)) {
|
@@ -1037,7 +1097,7 @@ var inputify = (value) => {
|
|
1037
1097
|
return {
|
1038
1098
|
type: InputType.Coin,
|
1039
1099
|
txID: hexlify3(arrayify(value.id).slice(0, 32)),
|
1040
|
-
outputIndex: toNumber(arrayify(value.id).slice(32,
|
1100
|
+
outputIndex: toNumber(arrayify(value.id).slice(32, 34)),
|
1041
1101
|
owner: hexlify3(value.owner),
|
1042
1102
|
amount: bn2(value.amount),
|
1043
1103
|
assetId: hexlify3(value.assetId),
|
@@ -1046,10 +1106,9 @@ var inputify = (value) => {
|
|
1046
1106
|
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
1047
1107
|
},
|
1048
1108
|
witnessIndex: value.witnessIndex,
|
1049
|
-
maturity: value.maturity ?? 0,
|
1050
1109
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1051
|
-
predicateLength: predicate.length,
|
1052
|
-
predicateDataLength: predicateData.length,
|
1110
|
+
predicateLength: bn2(predicate.length),
|
1111
|
+
predicateDataLength: bn2(predicateData.length),
|
1053
1112
|
predicate: hexlify3(predicate),
|
1054
1113
|
predicateData: hexlify3(predicateData)
|
1055
1114
|
};
|
@@ -1080,8 +1139,8 @@ var inputify = (value) => {
|
|
1080
1139
|
nonce: hexlify3(value.nonce),
|
1081
1140
|
witnessIndex: value.witnessIndex,
|
1082
1141
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1083
|
-
predicateLength: predicate.length,
|
1084
|
-
predicateDataLength: predicateData.length,
|
1142
|
+
predicateLength: bn2(predicate.length),
|
1143
|
+
predicateDataLength: bn2(predicateData.length),
|
1085
1144
|
predicate: hexlify3(predicate),
|
1086
1145
|
predicateData: hexlify3(predicateData),
|
1087
1146
|
data: hexlify3(data),
|
@@ -1210,8 +1269,8 @@ function assembleReceiptByType(receipt) {
|
|
1210
1269
|
case "CALL" /* Call */: {
|
1211
1270
|
const callReceipt = {
|
1212
1271
|
type: ReceiptType.Call,
|
1213
|
-
from: hexOrZero(receipt.
|
1214
|
-
to: hexOrZero(receipt?.to
|
1272
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1273
|
+
to: hexOrZero(receipt?.to),
|
1215
1274
|
amount: bn4(receipt.amount),
|
1216
1275
|
assetId: hexOrZero(receipt.assetId),
|
1217
1276
|
gas: bn4(receipt.gas),
|
@@ -1225,7 +1284,7 @@ function assembleReceiptByType(receipt) {
|
|
1225
1284
|
case "RETURN" /* Return */: {
|
1226
1285
|
const returnReceipt = {
|
1227
1286
|
type: ReceiptType.Return,
|
1228
|
-
id: hexOrZero(receipt.
|
1287
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1229
1288
|
val: bn4(receipt.val),
|
1230
1289
|
pc: bn4(receipt.pc),
|
1231
1290
|
is: bn4(receipt.is)
|
@@ -1235,7 +1294,7 @@ function assembleReceiptByType(receipt) {
|
|
1235
1294
|
case "RETURN_DATA" /* ReturnData */: {
|
1236
1295
|
const returnDataReceipt = {
|
1237
1296
|
type: ReceiptType.ReturnData,
|
1238
|
-
id: hexOrZero(receipt.
|
1297
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1239
1298
|
ptr: bn4(receipt.ptr),
|
1240
1299
|
len: bn4(receipt.len),
|
1241
1300
|
digest: hexOrZero(receipt.digest),
|
@@ -1247,7 +1306,7 @@ function assembleReceiptByType(receipt) {
|
|
1247
1306
|
case "PANIC" /* Panic */: {
|
1248
1307
|
const panicReceipt = {
|
1249
1308
|
type: ReceiptType.Panic,
|
1250
|
-
id: hexOrZero(receipt.
|
1309
|
+
id: hexOrZero(receipt.id),
|
1251
1310
|
reason: bn4(receipt.reason),
|
1252
1311
|
pc: bn4(receipt.pc),
|
1253
1312
|
is: bn4(receipt.is),
|
@@ -1258,7 +1317,7 @@ function assembleReceiptByType(receipt) {
|
|
1258
1317
|
case "REVERT" /* Revert */: {
|
1259
1318
|
const revertReceipt = {
|
1260
1319
|
type: ReceiptType.Revert,
|
1261
|
-
id: hexOrZero(receipt.
|
1320
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1262
1321
|
val: bn4(receipt.ra),
|
1263
1322
|
pc: bn4(receipt.pc),
|
1264
1323
|
is: bn4(receipt.is)
|
@@ -1268,7 +1327,7 @@ function assembleReceiptByType(receipt) {
|
|
1268
1327
|
case "LOG" /* Log */: {
|
1269
1328
|
const logReceipt = {
|
1270
1329
|
type: ReceiptType.Log,
|
1271
|
-
id: hexOrZero(receipt.
|
1330
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1272
1331
|
val0: bn4(receipt.ra),
|
1273
1332
|
val1: bn4(receipt.rb),
|
1274
1333
|
val2: bn4(receipt.rc),
|
@@ -1281,7 +1340,7 @@ function assembleReceiptByType(receipt) {
|
|
1281
1340
|
case "LOG_DATA" /* LogData */: {
|
1282
1341
|
const logDataReceipt = {
|
1283
1342
|
type: ReceiptType.LogData,
|
1284
|
-
id: hexOrZero(receipt.
|
1343
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1285
1344
|
val0: bn4(receipt.ra),
|
1286
1345
|
val1: bn4(receipt.rb),
|
1287
1346
|
ptr: bn4(receipt.ptr),
|
@@ -1295,8 +1354,8 @@ function assembleReceiptByType(receipt) {
|
|
1295
1354
|
case "TRANSFER" /* Transfer */: {
|
1296
1355
|
const transferReceipt = {
|
1297
1356
|
type: ReceiptType.Transfer,
|
1298
|
-
from: hexOrZero(receipt.
|
1299
|
-
to: hexOrZero(receipt.toAddress || receipt?.to
|
1357
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1358
|
+
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1300
1359
|
amount: bn4(receipt.amount),
|
1301
1360
|
assetId: hexOrZero(receipt.assetId),
|
1302
1361
|
pc: bn4(receipt.pc),
|
@@ -1307,8 +1366,8 @@ function assembleReceiptByType(receipt) {
|
|
1307
1366
|
case "TRANSFER_OUT" /* TransferOut */: {
|
1308
1367
|
const transferOutReceipt = {
|
1309
1368
|
type: ReceiptType.TransferOut,
|
1310
|
-
from: hexOrZero(receipt.
|
1311
|
-
to: hexOrZero(receipt.toAddress || receipt.to
|
1369
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1370
|
+
to: hexOrZero(receipt.toAddress || receipt.to),
|
1312
1371
|
amount: bn4(receipt.amount),
|
1313
1372
|
assetId: hexOrZero(receipt.assetId),
|
1314
1373
|
pc: bn4(receipt.pc),
|
@@ -1351,7 +1410,7 @@ function assembleReceiptByType(receipt) {
|
|
1351
1410
|
return receiptMessageOut;
|
1352
1411
|
}
|
1353
1412
|
case "MINT" /* Mint */: {
|
1354
|
-
const contractId = hexOrZero(receipt.
|
1413
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1355
1414
|
const subId = hexOrZero(receipt.subId);
|
1356
1415
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
1357
1416
|
const mintReceipt = {
|
@@ -1366,7 +1425,7 @@ function assembleReceiptByType(receipt) {
|
|
1366
1425
|
return mintReceipt;
|
1367
1426
|
}
|
1368
1427
|
case "BURN" /* Burn */: {
|
1369
|
-
const contractId = hexOrZero(receipt.
|
1428
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1370
1429
|
const subId = hexOrZero(receipt.subId);
|
1371
1430
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
1372
1431
|
const burnReceipt = {
|
@@ -1451,7 +1510,6 @@ var buildBlockExplorerUrl = (options = {}) => {
|
|
1451
1510
|
import { bn as bn5 } from "@fuel-ts/math";
|
1452
1511
|
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
1453
1512
|
import { arrayify as arrayify3 } from "@fuel-ts/utils";
|
1454
|
-
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1455
1513
|
var getGasUsedFromReceipts = (receipts) => {
|
1456
1514
|
const scriptResult = receipts.filter(
|
1457
1515
|
(receipt) => receipt.type === ReceiptType2.ScriptResult
|
@@ -1472,18 +1530,28 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
1472
1530
|
}
|
1473
1531
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
1474
1532
|
const witnessCache = [];
|
1475
|
-
const
|
1533
|
+
const chargeableInputs = inputs.filter((input) => {
|
1534
|
+
const isCoinOrMessage = "owner" in input || "sender" in input;
|
1535
|
+
if (isCoinOrMessage) {
|
1536
|
+
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1537
|
+
return true;
|
1538
|
+
}
|
1539
|
+
if (!witnessCache.includes(input.witnessIndex)) {
|
1540
|
+
witnessCache.push(input.witnessIndex);
|
1541
|
+
return true;
|
1542
|
+
}
|
1543
|
+
}
|
1544
|
+
return false;
|
1545
|
+
});
|
1546
|
+
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
1547
|
+
const totalGas = chargeableInputs.reduce((total, input) => {
|
1476
1548
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1477
1549
|
return total.add(
|
1478
|
-
|
1550
|
+
vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
|
1479
1551
|
);
|
1480
1552
|
}
|
1481
|
-
|
1482
|
-
|
1483
|
-
return total.add(gasCosts.ecr1);
|
1484
|
-
}
|
1485
|
-
return total;
|
1486
|
-
}, bn5());
|
1553
|
+
return total.add(gasCosts.ecr1);
|
1554
|
+
}, bn5(0));
|
1487
1555
|
return totalGas;
|
1488
1556
|
}
|
1489
1557
|
function getMinGas(params) {
|
@@ -1495,12 +1563,20 @@ function getMinGas(params) {
|
|
1495
1563
|
return minGas;
|
1496
1564
|
}
|
1497
1565
|
function getMaxGas(params) {
|
1498
|
-
const {
|
1566
|
+
const {
|
1567
|
+
gasPerByte,
|
1568
|
+
witnessesLength,
|
1569
|
+
witnessLimit,
|
1570
|
+
minGas,
|
1571
|
+
gasLimit = bn5(0),
|
1572
|
+
maxGasPerTx
|
1573
|
+
} = params;
|
1499
1574
|
let remainingAllowedWitnessGas = bn5(0);
|
1500
1575
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
1501
1576
|
remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
1502
1577
|
}
|
1503
|
-
|
1578
|
+
const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
1579
|
+
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
1504
1580
|
}
|
1505
1581
|
function calculateMetadataGasForTxCreate({
|
1506
1582
|
gasCosts,
|
@@ -1522,6 +1598,10 @@ function calculateMetadataGasForTxScript({
|
|
1522
1598
|
}) {
|
1523
1599
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1524
1600
|
}
|
1601
|
+
var calculateGasFee = (params) => {
|
1602
|
+
const { gas, gasPrice, priceFactor, tip } = params;
|
1603
|
+
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1604
|
+
};
|
1525
1605
|
|
1526
1606
|
// src/providers/utils/json.ts
|
1527
1607
|
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
@@ -1678,7 +1758,7 @@ var witnessify = (value) => {
|
|
1678
1758
|
// src/providers/transaction-request/transaction-request.ts
|
1679
1759
|
var BaseTransactionRequest = class {
|
1680
1760
|
/** Gas price for transaction */
|
1681
|
-
|
1761
|
+
tip;
|
1682
1762
|
/** Block until which tx cannot be included */
|
1683
1763
|
maturity;
|
1684
1764
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -1697,7 +1777,7 @@ var BaseTransactionRequest = class {
|
|
1697
1777
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
1698
1778
|
*/
|
1699
1779
|
constructor({
|
1700
|
-
|
1780
|
+
tip,
|
1701
1781
|
maturity,
|
1702
1782
|
maxFee,
|
1703
1783
|
witnessLimit,
|
@@ -1705,7 +1785,7 @@ var BaseTransactionRequest = class {
|
|
1705
1785
|
outputs,
|
1706
1786
|
witnesses
|
1707
1787
|
} = {}) {
|
1708
|
-
this.
|
1788
|
+
this.tip = bn7(tip);
|
1709
1789
|
this.maturity = maturity ?? 0;
|
1710
1790
|
this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
|
1711
1791
|
this.maxFee = maxFee ? bn7(maxFee) : void 0;
|
@@ -1716,9 +1796,9 @@ var BaseTransactionRequest = class {
|
|
1716
1796
|
static getPolicyMeta(req) {
|
1717
1797
|
let policyTypes = 0;
|
1718
1798
|
const policies = [];
|
1719
|
-
if (req.
|
1720
|
-
policyTypes += PolicyType.
|
1721
|
-
policies.push({ data: req.
|
1799
|
+
if (req.tip) {
|
1800
|
+
policyTypes += PolicyType.Tip;
|
1801
|
+
policies.push({ data: req.tip, type: PolicyType.Tip });
|
1722
1802
|
}
|
1723
1803
|
if (req.witnessLimit) {
|
1724
1804
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -1905,10 +1985,10 @@ var BaseTransactionRequest = class {
|
|
1905
1985
|
* @param predicate - Predicate bytes.
|
1906
1986
|
* @param predicateData - Predicate data bytes.
|
1907
1987
|
*/
|
1908
|
-
addCoinInput(coin
|
1988
|
+
addCoinInput(coin) {
|
1909
1989
|
const { assetId, owner, amount } = coin;
|
1910
1990
|
let witnessIndex;
|
1911
|
-
if (predicate) {
|
1991
|
+
if (coin.predicate) {
|
1912
1992
|
witnessIndex = 0;
|
1913
1993
|
} else {
|
1914
1994
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -1923,9 +2003,7 @@ var BaseTransactionRequest = class {
|
|
1923
2003
|
amount,
|
1924
2004
|
assetId,
|
1925
2005
|
txPointer: "0x00000000000000000000000000000000",
|
1926
|
-
witnessIndex
|
1927
|
-
predicate: predicate?.bytes,
|
1928
|
-
predicateData: predicate?.predicateDataBytes
|
2006
|
+
witnessIndex
|
1929
2007
|
};
|
1930
2008
|
this.pushInput(input);
|
1931
2009
|
this.addChangeOutput(owner, assetId);
|
@@ -1938,11 +2016,11 @@ var BaseTransactionRequest = class {
|
|
1938
2016
|
* @param predicate - Predicate bytes.
|
1939
2017
|
* @param predicateData - Predicate data bytes.
|
1940
2018
|
*/
|
1941
|
-
addMessageInput(message
|
2019
|
+
addMessageInput(message) {
|
1942
2020
|
const { recipient, sender, amount } = message;
|
1943
2021
|
const assetId = BaseAssetId2;
|
1944
2022
|
let witnessIndex;
|
1945
|
-
if (predicate) {
|
2023
|
+
if (message.predicate) {
|
1946
2024
|
witnessIndex = 0;
|
1947
2025
|
} else {
|
1948
2026
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -1956,9 +2034,7 @@ var BaseTransactionRequest = class {
|
|
1956
2034
|
sender: sender.toB256(),
|
1957
2035
|
recipient: recipient.toB256(),
|
1958
2036
|
amount,
|
1959
|
-
witnessIndex
|
1960
|
-
predicate: predicate?.bytes,
|
1961
|
-
predicateData: predicate?.predicateDataBytes
|
2037
|
+
witnessIndex
|
1962
2038
|
};
|
1963
2039
|
this.pushInput(input);
|
1964
2040
|
this.addChangeOutput(recipient, assetId);
|
@@ -1989,32 +2065,6 @@ var BaseTransactionRequest = class {
|
|
1989
2065
|
resources.forEach((resource) => this.addResource(resource));
|
1990
2066
|
return this;
|
1991
2067
|
}
|
1992
|
-
/**
|
1993
|
-
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
1994
|
-
* outputs from the related assetIds.
|
1995
|
-
*
|
1996
|
-
* @param resources - The resources to add.
|
1997
|
-
* @returns This transaction.
|
1998
|
-
*/
|
1999
|
-
addPredicateResource(resource, predicate) {
|
2000
|
-
if (isCoin(resource)) {
|
2001
|
-
this.addCoinInput(resource, predicate);
|
2002
|
-
} else {
|
2003
|
-
this.addMessageInput(resource, predicate);
|
2004
|
-
}
|
2005
|
-
return this;
|
2006
|
-
}
|
2007
|
-
/**
|
2008
|
-
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
2009
|
-
* from the related assetIds.
|
2010
|
-
*
|
2011
|
-
* @param resources - The resources to add.
|
2012
|
-
* @returns This transaction.
|
2013
|
-
*/
|
2014
|
-
addPredicateResources(resources, predicate) {
|
2015
|
-
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
2016
|
-
return this;
|
2017
|
-
}
|
2018
2068
|
/**
|
2019
2069
|
* Adds a coin output to the transaction.
|
2020
2070
|
*
|
@@ -2094,7 +2144,7 @@ var BaseTransactionRequest = class {
|
|
2094
2144
|
}
|
2095
2145
|
calculateMaxGas(chainInfo, minGas) {
|
2096
2146
|
const { consensusParameters } = chainInfo;
|
2097
|
-
const { gasPerByte } = consensusParameters;
|
2147
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2098
2148
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2099
2149
|
(acc, wit) => acc + wit.dataLength,
|
2100
2150
|
0
|
@@ -2103,7 +2153,8 @@ var BaseTransactionRequest = class {
|
|
2103
2153
|
gasPerByte,
|
2104
2154
|
minGas,
|
2105
2155
|
witnessesLength,
|
2106
|
-
witnessLimit: this.witnessLimit
|
2156
|
+
witnessLimit: this.witnessLimit,
|
2157
|
+
maxGasPerTx
|
2107
2158
|
});
|
2108
2159
|
}
|
2109
2160
|
/**
|
@@ -2121,17 +2172,20 @@ var BaseTransactionRequest = class {
|
|
2121
2172
|
});
|
2122
2173
|
const updateAssetInput = (assetId, quantity) => {
|
2123
2174
|
const assetInput = findAssetInput(assetId);
|
2175
|
+
let usedQuantity = quantity;
|
2176
|
+
if (assetId === BaseAssetId2) {
|
2177
|
+
usedQuantity = bn7("1000000000000000000");
|
2178
|
+
}
|
2124
2179
|
if (assetInput && "assetId" in assetInput) {
|
2125
|
-
assetInput.id = hexlify7(randomBytes(
|
2126
|
-
assetInput.amount =
|
2180
|
+
assetInput.id = hexlify7(randomBytes(34));
|
2181
|
+
assetInput.amount = usedQuantity;
|
2127
2182
|
} else {
|
2128
2183
|
this.addResources([
|
2129
2184
|
{
|
2130
|
-
id: hexlify7(randomBytes(
|
2131
|
-
amount:
|
2185
|
+
id: hexlify7(randomBytes(34)),
|
2186
|
+
amount: usedQuantity,
|
2132
2187
|
assetId,
|
2133
2188
|
owner: resourcesOwner || Address.fromRandom(),
|
2134
|
-
maturity: 0,
|
2135
2189
|
blockCreated: bn7(1),
|
2136
2190
|
txCreatedIdx: bn7(1)
|
2137
2191
|
}
|
@@ -2163,7 +2217,7 @@ var BaseTransactionRequest = class {
|
|
2163
2217
|
toJSON() {
|
2164
2218
|
return normalizeJSON(this);
|
2165
2219
|
}
|
2166
|
-
|
2220
|
+
updatePredicateGasUsed(inputs) {
|
2167
2221
|
this.inputs.forEach((i) => {
|
2168
2222
|
let correspondingInput;
|
2169
2223
|
switch (i.type) {
|
@@ -2185,6 +2239,15 @@ var BaseTransactionRequest = class {
|
|
2185
2239
|
}
|
2186
2240
|
});
|
2187
2241
|
}
|
2242
|
+
shiftPredicateData() {
|
2243
|
+
this.inputs.forEach((input) => {
|
2244
|
+
if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
|
2245
|
+
input.predicateData = input.paddPredicateData(
|
2246
|
+
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2247
|
+
);
|
2248
|
+
}
|
2249
|
+
});
|
2250
|
+
}
|
2188
2251
|
};
|
2189
2252
|
|
2190
2253
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2331,9 +2394,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2331
2394
|
return {
|
2332
2395
|
type: TransactionType3.Create,
|
2333
2396
|
...baseTransaction,
|
2334
|
-
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2335
2397
|
bytecodeWitnessIndex,
|
2336
|
-
storageSlotsCount: storageSlots.length,
|
2398
|
+
storageSlotsCount: bn9(storageSlots.length),
|
2337
2399
|
salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
|
2338
2400
|
storageSlots
|
2339
2401
|
};
|
@@ -2456,8 +2518,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2456
2518
|
type: TransactionType4.Script,
|
2457
2519
|
scriptGasLimit: this.gasLimit,
|
2458
2520
|
...super.getBaseTransaction(),
|
2459
|
-
scriptLength: script.length,
|
2460
|
-
scriptDataLength: scriptData.length,
|
2521
|
+
scriptLength: bn10(script.length),
|
2522
|
+
scriptDataLength: bn10(scriptData.length),
|
2461
2523
|
receiptsRoot: ZeroBytes327,
|
2462
2524
|
script: hexlify10(script),
|
2463
2525
|
scriptData: hexlify10(scriptData)
|
@@ -2521,7 +2583,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2521
2583
|
}
|
2522
2584
|
calculateMaxGas(chainInfo, minGas) {
|
2523
2585
|
const { consensusParameters } = chainInfo;
|
2524
|
-
const { gasPerByte } = consensusParameters;
|
2586
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2525
2587
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2526
2588
|
(acc, wit) => acc + wit.dataLength,
|
2527
2589
|
0
|
@@ -2531,7 +2593,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2531
2593
|
minGas,
|
2532
2594
|
witnessesLength,
|
2533
2595
|
witnessLimit: this.witnessLimit,
|
2534
|
-
gasLimit: this.gasLimit
|
2596
|
+
gasLimit: this.gasLimit,
|
2597
|
+
maxGasPerTx
|
2535
2598
|
});
|
2536
2599
|
}
|
2537
2600
|
/**
|
@@ -2588,7 +2651,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2588
2651
|
|
2589
2652
|
// src/providers/transaction-request/utils.ts
|
2590
2653
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2591
|
-
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2654
|
+
import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
|
2592
2655
|
var transactionRequestify = (obj) => {
|
2593
2656
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2594
2657
|
return obj;
|
@@ -2606,14 +2669,31 @@ var transactionRequestify = (obj) => {
|
|
2606
2669
|
}
|
2607
2670
|
}
|
2608
2671
|
};
|
2672
|
+
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2673
|
+
(acc, input) => {
|
2674
|
+
if (input.type === InputType5.Coin && input.owner === owner) {
|
2675
|
+
acc.utxos.push(input.id);
|
2676
|
+
}
|
2677
|
+
if (input.type === InputType5.Message && input.recipient === owner) {
|
2678
|
+
acc.messages.push(input.nonce);
|
2679
|
+
}
|
2680
|
+
return acc;
|
2681
|
+
},
|
2682
|
+
{
|
2683
|
+
utxos: [],
|
2684
|
+
messages: []
|
2685
|
+
}
|
2686
|
+
);
|
2609
2687
|
|
2610
2688
|
// src/providers/transaction-response/transaction-response.ts
|
2611
2689
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2612
|
-
import { bn as
|
2690
|
+
import { bn as bn15 } from "@fuel-ts/math";
|
2613
2691
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2614
2692
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2615
2693
|
|
2616
2694
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2695
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
2696
|
+
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2617
2697
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2618
2698
|
|
2619
2699
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
@@ -2622,9 +2702,10 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
|
|
2622
2702
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2623
2703
|
var calculateTransactionFee = (params) => {
|
2624
2704
|
const {
|
2625
|
-
|
2705
|
+
gasPrice,
|
2626
2706
|
rawPayload,
|
2627
|
-
|
2707
|
+
tip,
|
2708
|
+
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2628
2709
|
} = params;
|
2629
2710
|
const gasPerByte = bn11(feeParams.gasPerByte);
|
2630
2711
|
const gasPriceFactor = bn11(feeParams.gasPriceFactor);
|
@@ -2634,8 +2715,7 @@ var calculateTransactionFee = (params) => {
|
|
2634
2715
|
return {
|
2635
2716
|
fee: bn11(0),
|
2636
2717
|
minFee: bn11(0),
|
2637
|
-
maxFee: bn11(0)
|
2638
|
-
feeFromGasUsed: bn11(0)
|
2718
|
+
maxFee: bn11(0)
|
2639
2719
|
};
|
2640
2720
|
}
|
2641
2721
|
const { type, witnesses, inputs, policies } = transaction;
|
@@ -2667,7 +2747,6 @@ var calculateTransactionFee = (params) => {
|
|
2667
2747
|
metadataGas,
|
2668
2748
|
txBytesSize: transactionBytes.length
|
2669
2749
|
});
|
2670
|
-
const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
|
2671
2750
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
|
2672
2751
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2673
2752
|
const maxGas = getMaxGas({
|
@@ -2675,17 +2754,25 @@ var calculateTransactionFee = (params) => {
|
|
2675
2754
|
minGas,
|
2676
2755
|
witnessesLength,
|
2677
2756
|
gasLimit,
|
2678
|
-
witnessLimit
|
2757
|
+
witnessLimit,
|
2758
|
+
maxGasPerTx
|
2759
|
+
});
|
2760
|
+
const minFee = calculateGasFee({
|
2761
|
+
gasPrice,
|
2762
|
+
gas: minGas,
|
2763
|
+
priceFactor: gasPriceFactor,
|
2764
|
+
tip
|
2765
|
+
});
|
2766
|
+
const maxFee = calculateGasFee({
|
2767
|
+
gasPrice,
|
2768
|
+
gas: maxGas,
|
2769
|
+
priceFactor: gasPriceFactor,
|
2770
|
+
tip
|
2679
2771
|
});
|
2680
|
-
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
2681
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
2682
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
2683
|
-
const fee = minFee.add(feeFromGasUsed);
|
2684
2772
|
return {
|
2685
|
-
fee,
|
2686
2773
|
minFee,
|
2687
2774
|
maxFee,
|
2688
|
-
|
2775
|
+
fee: maxFee
|
2689
2776
|
};
|
2690
2777
|
};
|
2691
2778
|
|
@@ -2741,7 +2828,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2741
2828
|
|
2742
2829
|
// src/providers/transaction-summary/input.ts
|
2743
2830
|
import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2744
|
-
import { InputType as
|
2831
|
+
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
2745
2832
|
function getInputsByTypes(inputs, types) {
|
2746
2833
|
return inputs.filter((i) => types.includes(i.type));
|
2747
2834
|
}
|
@@ -2749,16 +2836,16 @@ function getInputsByType(inputs, type) {
|
|
2749
2836
|
return inputs.filter((i) => i.type === type);
|
2750
2837
|
}
|
2751
2838
|
function getInputsCoin(inputs) {
|
2752
|
-
return getInputsByType(inputs,
|
2839
|
+
return getInputsByType(inputs, InputType6.Coin);
|
2753
2840
|
}
|
2754
2841
|
function getInputsMessage(inputs) {
|
2755
|
-
return getInputsByType(inputs,
|
2842
|
+
return getInputsByType(inputs, InputType6.Message);
|
2756
2843
|
}
|
2757
2844
|
function getInputsCoinAndMessage(inputs) {
|
2758
|
-
return getInputsByTypes(inputs, [
|
2845
|
+
return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
|
2759
2846
|
}
|
2760
2847
|
function getInputsContract(inputs) {
|
2761
|
-
return getInputsByType(inputs,
|
2848
|
+
return getInputsByType(inputs, InputType6.Contract);
|
2762
2849
|
}
|
2763
2850
|
function getInputFromAssetId(inputs, assetId) {
|
2764
2851
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2777,7 +2864,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2777
2864
|
if (!contractInput) {
|
2778
2865
|
return void 0;
|
2779
2866
|
}
|
2780
|
-
if (contractInput.type !==
|
2867
|
+
if (contractInput.type !== InputType6.Contract) {
|
2781
2868
|
throw new FuelError9(
|
2782
2869
|
ErrorCode9.INVALID_TRANSACTION_INPUT,
|
2783
2870
|
`Contract input should be of type 'contract'.`
|
@@ -2786,10 +2873,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2786
2873
|
return contractInput;
|
2787
2874
|
}
|
2788
2875
|
function getInputAccountAddress(input) {
|
2789
|
-
if (input.type ===
|
2876
|
+
if (input.type === InputType6.Coin) {
|
2790
2877
|
return input.owner.toString();
|
2791
2878
|
}
|
2792
|
-
if (input.type ===
|
2879
|
+
if (input.type === InputType6.Message) {
|
2793
2880
|
return input.recipient.toString();
|
2794
2881
|
}
|
2795
2882
|
return "";
|
@@ -3299,7 +3386,9 @@ function assembleTransactionSummary(params) {
|
|
3299
3386
|
gqlTransactionStatus,
|
3300
3387
|
abiMap = {},
|
3301
3388
|
maxInputs,
|
3302
|
-
gasCosts
|
3389
|
+
gasCosts,
|
3390
|
+
maxGasPerTx,
|
3391
|
+
gasPrice
|
3303
3392
|
} = params;
|
3304
3393
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3305
3394
|
const rawPayload = hexlify11(transactionBytes);
|
@@ -3313,11 +3402,14 @@ function assembleTransactionSummary(params) {
|
|
3313
3402
|
maxInputs
|
3314
3403
|
});
|
3315
3404
|
const typeName = getTransactionTypeName(transaction.type);
|
3405
|
+
const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3316
3406
|
const { fee } = calculateTransactionFee({
|
3317
|
-
|
3407
|
+
gasPrice,
|
3318
3408
|
rawPayload,
|
3409
|
+
tip,
|
3319
3410
|
consensusParameters: {
|
3320
3411
|
gasCosts,
|
3412
|
+
maxGasPerTx,
|
3321
3413
|
feeParams: {
|
3322
3414
|
gasPerByte,
|
3323
3415
|
gasPriceFactor
|
@@ -3377,7 +3469,7 @@ var TransactionResponse = class {
|
|
3377
3469
|
/** Current provider */
|
3378
3470
|
provider;
|
3379
3471
|
/** Gas used on the transaction */
|
3380
|
-
gasUsed =
|
3472
|
+
gasUsed = bn15(0);
|
3381
3473
|
/** The graphql Transaction with receipts object. */
|
3382
3474
|
gqlTransaction;
|
3383
3475
|
abis;
|
@@ -3455,8 +3547,13 @@ var TransactionResponse = class {
|
|
3455
3547
|
const decodedTransaction = this.decodeTransaction(
|
3456
3548
|
transaction
|
3457
3549
|
);
|
3458
|
-
|
3459
|
-
|
3550
|
+
let txReceipts = [];
|
3551
|
+
if (transaction?.status && "receipts" in transaction.status) {
|
3552
|
+
txReceipts = transaction.status.receipts;
|
3553
|
+
}
|
3554
|
+
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3555
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3556
|
+
const gasPrice = await this.provider.getLatestGasPrice();
|
3460
3557
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3461
3558
|
const transactionSummary = assembleTransactionSummary({
|
3462
3559
|
id: this.id,
|
@@ -3468,7 +3565,9 @@ var TransactionResponse = class {
|
|
3468
3565
|
gasPriceFactor,
|
3469
3566
|
abiMap: contractsAbiMap,
|
3470
3567
|
maxInputs,
|
3471
|
-
gasCosts
|
3568
|
+
gasCosts,
|
3569
|
+
maxGasPerTx,
|
3570
|
+
gasPrice
|
3472
3571
|
});
|
3473
3572
|
return transactionSummary;
|
3474
3573
|
}
|
@@ -3595,29 +3694,29 @@ var processGqlChain = (chain) => {
|
|
3595
3694
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3596
3695
|
return {
|
3597
3696
|
name,
|
3598
|
-
baseChainHeight:
|
3697
|
+
baseChainHeight: bn16(daHeight),
|
3599
3698
|
consensusParameters: {
|
3600
|
-
contractMaxSize:
|
3601
|
-
maxInputs:
|
3602
|
-
maxOutputs:
|
3603
|
-
maxWitnesses:
|
3604
|
-
maxGasPerTx:
|
3605
|
-
maxScriptLength:
|
3606
|
-
maxScriptDataLength:
|
3607
|
-
maxStorageSlots:
|
3608
|
-
maxPredicateLength:
|
3609
|
-
maxPredicateDataLength:
|
3610
|
-
maxGasPerPredicate:
|
3611
|
-
gasPriceFactor:
|
3612
|
-
gasPerByte:
|
3613
|
-
maxMessageDataLength:
|
3614
|
-
chainId:
|
3699
|
+
contractMaxSize: bn16(contractParams.contractMaxSize),
|
3700
|
+
maxInputs: bn16(txParams.maxInputs),
|
3701
|
+
maxOutputs: bn16(txParams.maxOutputs),
|
3702
|
+
maxWitnesses: bn16(txParams.maxWitnesses),
|
3703
|
+
maxGasPerTx: bn16(txParams.maxGasPerTx),
|
3704
|
+
maxScriptLength: bn16(scriptParams.maxScriptLength),
|
3705
|
+
maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
|
3706
|
+
maxStorageSlots: bn16(contractParams.maxStorageSlots),
|
3707
|
+
maxPredicateLength: bn16(predicateParams.maxPredicateLength),
|
3708
|
+
maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
|
3709
|
+
maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
|
3710
|
+
gasPriceFactor: bn16(feeParams.gasPriceFactor),
|
3711
|
+
gasPerByte: bn16(feeParams.gasPerByte),
|
3712
|
+
maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
|
3713
|
+
chainId: bn16(consensusParameters.chainId),
|
3615
3714
|
gasCosts
|
3616
3715
|
},
|
3617
3716
|
gasCosts,
|
3618
3717
|
latestBlock: {
|
3619
3718
|
id: latestBlock.id,
|
3620
|
-
height:
|
3719
|
+
height: bn16(latestBlock.height),
|
3621
3720
|
time: latestBlock.header.time,
|
3622
3721
|
transactions: latestBlock.transactions.map((i) => ({
|
3623
3722
|
id: i.id
|
@@ -3711,10 +3810,8 @@ var _Provider = class {
|
|
3711
3810
|
* Returns some helpful parameters related to gas fees.
|
3712
3811
|
*/
|
3713
3812
|
getGasConfig() {
|
3714
|
-
const { minGasPrice } = this.getNode();
|
3715
3813
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3716
3814
|
return {
|
3717
|
-
minGasPrice,
|
3718
3815
|
maxGasPerTx,
|
3719
3816
|
maxGasPerPredicate,
|
3720
3817
|
gasPriceFactor,
|
@@ -3812,7 +3909,7 @@ var _Provider = class {
|
|
3812
3909
|
*/
|
3813
3910
|
async getBlockNumber() {
|
3814
3911
|
const { chain } = await this.operations.getChain();
|
3815
|
-
return
|
3912
|
+
return bn16(chain.latestBlock.height, 10);
|
3816
3913
|
}
|
3817
3914
|
/**
|
3818
3915
|
* Returns the chain information.
|
@@ -3822,13 +3919,11 @@ var _Provider = class {
|
|
3822
3919
|
async fetchNode() {
|
3823
3920
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3824
3921
|
const processedNodeInfo = {
|
3825
|
-
maxDepth:
|
3826
|
-
maxTx:
|
3827
|
-
minGasPrice: bn15(nodeInfo.minGasPrice),
|
3922
|
+
maxDepth: bn16(nodeInfo.maxDepth),
|
3923
|
+
maxTx: bn16(nodeInfo.maxTx),
|
3828
3924
|
nodeVersion: nodeInfo.nodeVersion,
|
3829
3925
|
utxoValidation: nodeInfo.utxoValidation,
|
3830
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
3831
|
-
peers: nodeInfo.peers
|
3926
|
+
vmBacktrace: nodeInfo.vmBacktrace
|
3832
3927
|
};
|
3833
3928
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
3834
3929
|
return processedNodeInfo;
|
@@ -3914,14 +4009,13 @@ var _Provider = class {
|
|
3914
4009
|
return this.estimateTxDependencies(transactionRequest);
|
3915
4010
|
}
|
3916
4011
|
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
3917
|
-
const { dryRun:
|
3918
|
-
encodedTransaction,
|
4012
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4013
|
+
encodedTransactions: encodedTransaction,
|
3919
4014
|
utxoValidation: utxoValidation || false
|
3920
4015
|
});
|
3921
|
-
const receipts =
|
3922
|
-
|
3923
|
-
|
3924
|
-
};
|
4016
|
+
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
4017
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
4018
|
+
return { receipts, dryrunStatus: status };
|
3925
4019
|
}
|
3926
4020
|
/**
|
3927
4021
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -3947,7 +4041,7 @@ var _Provider = class {
|
|
3947
4041
|
} = response;
|
3948
4042
|
if (inputs) {
|
3949
4043
|
inputs.forEach((input, index) => {
|
3950
|
-
if ("predicateGasUsed" in input &&
|
4044
|
+
if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
|
3951
4045
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3952
4046
|
}
|
3953
4047
|
});
|
@@ -3960,9 +4054,6 @@ var _Provider = class {
|
|
3960
4054
|
* If there are missing variable outputs,
|
3961
4055
|
* `addVariableOutputs` is called on the transaction.
|
3962
4056
|
*
|
3963
|
-
* @privateRemarks
|
3964
|
-
* TODO: Investigate support for missing contract IDs
|
3965
|
-
* TODO: Add support for missing output messages
|
3966
4057
|
*
|
3967
4058
|
* @param transactionRequest - The transaction request object.
|
3968
4059
|
* @returns A promise.
|
@@ -3975,16 +4066,19 @@ var _Provider = class {
|
|
3975
4066
|
missingContractIds: []
|
3976
4067
|
};
|
3977
4068
|
}
|
3978
|
-
await this.estimatePredicates(transactionRequest);
|
3979
4069
|
let receipts = [];
|
3980
4070
|
const missingContractIds = [];
|
3981
4071
|
let outputVariables = 0;
|
4072
|
+
let dryrunStatus;
|
3982
4073
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3983
|
-
const {
|
3984
|
-
|
4074
|
+
const {
|
4075
|
+
dryRun: [{ receipts: rawReceipts, status }]
|
4076
|
+
} = await this.operations.dryRun({
|
4077
|
+
encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
|
3985
4078
|
utxoValidation: false
|
3986
4079
|
});
|
3987
|
-
receipts =
|
4080
|
+
receipts = rawReceipts.map(processGqlReceipt);
|
4081
|
+
dryrunStatus = status;
|
3988
4082
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
3989
4083
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
3990
4084
|
if (hasMissingOutputs) {
|
@@ -3994,6 +4088,11 @@ var _Provider = class {
|
|
3994
4088
|
transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
|
3995
4089
|
missingContractIds.push(contractId);
|
3996
4090
|
});
|
4091
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
4092
|
+
transactionRequest,
|
4093
|
+
optimizeGas: false
|
4094
|
+
});
|
4095
|
+
transactionRequest.maxFee = maxFee;
|
3997
4096
|
} else {
|
3998
4097
|
break;
|
3999
4098
|
}
|
@@ -4001,38 +4100,133 @@ var _Provider = class {
|
|
4001
4100
|
return {
|
4002
4101
|
receipts,
|
4003
4102
|
outputVariables,
|
4004
|
-
missingContractIds
|
4103
|
+
missingContractIds,
|
4104
|
+
dryrunStatus
|
4005
4105
|
};
|
4006
4106
|
}
|
4007
4107
|
/**
|
4008
|
-
*
|
4009
|
-
*
|
4010
|
-
*
|
4011
|
-
*
|
4108
|
+
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
4109
|
+
*
|
4110
|
+
* Transactions are dry run in batches. After each dry run, transactions requiring
|
4111
|
+
* further modifications are identified. The method iteratively updates these transactions
|
4112
|
+
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
4113
|
+
*
|
4114
|
+
* @param transactionRequests - Array of transaction request objects.
|
4115
|
+
* @returns A promise that resolves to an array of results for each transaction.
|
4012
4116
|
*/
|
4013
|
-
|
4014
|
-
const
|
4015
|
-
|
4117
|
+
async estimateMultipleTxDependencies(transactionRequests) {
|
4118
|
+
const results = transactionRequests.map(() => ({
|
4119
|
+
receipts: [],
|
4120
|
+
outputVariables: 0,
|
4121
|
+
missingContractIds: [],
|
4122
|
+
dryrunStatus: void 0
|
4123
|
+
}));
|
4124
|
+
const allRequests = clone3(transactionRequests);
|
4125
|
+
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4126
|
+
allRequests.forEach((req, index) => {
|
4127
|
+
if (req.type === TransactionType8.Script) {
|
4128
|
+
serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
|
4129
|
+
}
|
4130
|
+
});
|
4131
|
+
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
4132
|
+
let attempt = 0;
|
4133
|
+
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
4134
|
+
const encodedTransactions = transactionsToProcess.map(
|
4135
|
+
(index) => serializedTransactionsMap.get(index)
|
4136
|
+
);
|
4137
|
+
const dryRunResults = await this.operations.dryRun({
|
4138
|
+
encodedTransactions,
|
4139
|
+
utxoValidation: false
|
4140
|
+
});
|
4141
|
+
const nextRoundTransactions = [];
|
4142
|
+
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
4143
|
+
const currentResultIndex = transactionsToProcess[i];
|
4144
|
+
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4145
|
+
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
4146
|
+
results[currentResultIndex].dryrunStatus = status;
|
4147
|
+
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4148
|
+
results[currentResultIndex].receipts
|
4149
|
+
);
|
4150
|
+
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4151
|
+
const requestToProcess = allRequests[currentResultIndex];
|
4152
|
+
if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
|
4153
|
+
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
4154
|
+
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
4155
|
+
missingOutputContractIds.forEach(({ contractId }) => {
|
4156
|
+
requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
|
4157
|
+
results[currentResultIndex].missingContractIds.push(contractId);
|
4158
|
+
});
|
4159
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
4160
|
+
transactionRequest: requestToProcess,
|
4161
|
+
optimizeGas: false
|
4162
|
+
});
|
4163
|
+
requestToProcess.maxFee = maxFee;
|
4164
|
+
serializedTransactionsMap.set(
|
4165
|
+
currentResultIndex,
|
4166
|
+
hexlify12(requestToProcess.toTransactionBytes())
|
4167
|
+
);
|
4168
|
+
nextRoundTransactions.push(currentResultIndex);
|
4169
|
+
allRequests[currentResultIndex] = requestToProcess;
|
4170
|
+
}
|
4171
|
+
}
|
4172
|
+
transactionsToProcess = nextRoundTransactions;
|
4173
|
+
attempt += 1;
|
4174
|
+
}
|
4175
|
+
return results;
|
4176
|
+
}
|
4177
|
+
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
4178
|
+
if (estimateTxDependencies) {
|
4179
|
+
return this.estimateMultipleTxDependencies(transactionRequests);
|
4180
|
+
}
|
4181
|
+
const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
|
4182
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4183
|
+
encodedTransactions,
|
4184
|
+
utxoValidation: utxoValidation || false
|
4185
|
+
});
|
4186
|
+
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4187
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
4188
|
+
return { receipts, dryrunStatus: status };
|
4189
|
+
});
|
4190
|
+
return results;
|
4191
|
+
}
|
4192
|
+
async estimateTxGasAndFee(params) {
|
4193
|
+
const { transactionRequest, optimizeGas = true } = params;
|
4194
|
+
let { gasPrice } = params;
|
4016
4195
|
const chainInfo = this.getChain();
|
4017
|
-
const
|
4018
|
-
transactionRequest.gasPrice = gasPrice;
|
4196
|
+
const { gasPriceFactor } = this.getGasConfig();
|
4019
4197
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
4020
|
-
|
4198
|
+
if (!gasPrice) {
|
4199
|
+
gasPrice = await this.estimateGasPrice(10);
|
4200
|
+
}
|
4201
|
+
const minFee = calculateGasFee({
|
4202
|
+
gasPrice: bn16(gasPrice),
|
4203
|
+
gas: minGas,
|
4204
|
+
priceFactor: gasPriceFactor,
|
4205
|
+
tip: transactionRequest.tip
|
4206
|
+
}).add(1);
|
4207
|
+
let gasLimit = bn16(0);
|
4021
4208
|
if (transactionRequest.type === TransactionType8.Script) {
|
4022
|
-
|
4209
|
+
gasLimit = transactionRequest.gasLimit;
|
4210
|
+
if (!optimizeGas) {
|
4023
4211
|
transactionRequest.gasLimit = minGas;
|
4024
|
-
|
4025
|
-
|
4026
|
-
);
|
4212
|
+
gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4213
|
+
transactionRequest.gasLimit = gasLimit;
|
4027
4214
|
}
|
4028
4215
|
}
|
4029
4216
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4030
|
-
const maxFee =
|
4217
|
+
const maxFee = calculateGasFee({
|
4218
|
+
gasPrice: bn16(gasPrice),
|
4219
|
+
gas: maxGas,
|
4220
|
+
priceFactor: gasPriceFactor,
|
4221
|
+
tip: transactionRequest.tip
|
4222
|
+
}).add(1);
|
4031
4223
|
return {
|
4032
4224
|
minGas,
|
4033
4225
|
minFee,
|
4034
4226
|
maxGas,
|
4035
|
-
maxFee
|
4227
|
+
maxFee,
|
4228
|
+
gasPrice,
|
4229
|
+
gasLimit
|
4036
4230
|
};
|
4037
4231
|
}
|
4038
4232
|
/**
|
@@ -4050,15 +4244,17 @@ var _Provider = class {
|
|
4050
4244
|
if (estimateTxDependencies) {
|
4051
4245
|
return this.estimateTxDependencies(transactionRequest);
|
4052
4246
|
}
|
4053
|
-
const
|
4054
|
-
const { dryRun:
|
4055
|
-
|
4247
|
+
const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
|
4248
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4249
|
+
encodedTransactions,
|
4056
4250
|
utxoValidation: true
|
4057
4251
|
});
|
4058
|
-
const
|
4059
|
-
|
4060
|
-
receipts
|
4061
|
-
|
4252
|
+
const callResult = dryRunStatuses.map((dryRunStatus) => {
|
4253
|
+
const { id, receipts, status } = dryRunStatus;
|
4254
|
+
const processedReceipts = receipts.map(processGqlReceipt);
|
4255
|
+
return { id, receipts: processedReceipts, status };
|
4256
|
+
});
|
4257
|
+
return { receipts: callResult[0].receipts };
|
4062
4258
|
}
|
4063
4259
|
/**
|
4064
4260
|
* Returns a transaction cost to enable user
|
@@ -4075,77 +4271,80 @@ var _Provider = class {
|
|
4075
4271
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
4076
4272
|
* @returns A promise that resolves to the transaction cost object.
|
4077
4273
|
*/
|
4078
|
-
async getTransactionCost(transactionRequestLike,
|
4079
|
-
estimateTxDependencies = true,
|
4080
|
-
estimatePredicates = true,
|
4081
|
-
resourcesOwner,
|
4082
|
-
signatureCallback
|
4083
|
-
} = {}) {
|
4274
|
+
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
4084
4275
|
const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
|
4085
|
-
const { minGasPrice } = this.getGasConfig();
|
4086
|
-
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
4087
4276
|
const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
|
4088
4277
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4089
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
4278
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4090
4279
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
4280
|
+
txRequestClone.maxFee = bn16(0);
|
4091
4281
|
if (isScriptTransaction) {
|
4092
|
-
txRequestClone.gasLimit =
|
4282
|
+
txRequestClone.gasLimit = bn16(0);
|
4093
4283
|
}
|
4094
|
-
if (
|
4095
|
-
|
4096
|
-
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
4097
|
-
}
|
4098
|
-
await this.estimatePredicates(txRequestClone);
|
4284
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4285
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
4099
4286
|
}
|
4287
|
+
const signedRequest = clone3(txRequestClone);
|
4288
|
+
let addedSignatures = 0;
|
4100
4289
|
if (signatureCallback && isScriptTransaction) {
|
4101
|
-
|
4102
|
-
|
4103
|
-
|
4104
|
-
|
4290
|
+
const lengthBefore = signedRequest.witnesses.length;
|
4291
|
+
await signatureCallback(signedRequest);
|
4292
|
+
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
4293
|
+
}
|
4294
|
+
await this.estimatePredicates(signedRequest);
|
4295
|
+
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
4296
|
+
transactionRequest: signedRequest,
|
4297
|
+
optimizeGas: false
|
4105
4298
|
});
|
4299
|
+
txRequestClone.maxFee = maxFee;
|
4106
4300
|
let receipts = [];
|
4107
4301
|
let missingContractIds = [];
|
4108
4302
|
let outputVariables = 0;
|
4109
|
-
let gasUsed =
|
4110
|
-
|
4111
|
-
|
4303
|
+
let gasUsed = bn16(0);
|
4304
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4305
|
+
if (isScriptTransaction) {
|
4306
|
+
if (signatureCallback) {
|
4307
|
+
await signatureCallback(txRequestClone);
|
4308
|
+
}
|
4309
|
+
txRequestClone.gasLimit = gasLimit;
|
4112
4310
|
const result = await this.estimateTxDependencies(txRequestClone);
|
4113
4311
|
receipts = result.receipts;
|
4114
4312
|
outputVariables = result.outputVariables;
|
4115
4313
|
missingContractIds = result.missingContractIds;
|
4116
|
-
gasUsed =
|
4314
|
+
gasUsed = getGasUsedFromReceipts(receipts);
|
4117
4315
|
txRequestClone.gasLimit = gasUsed;
|
4118
|
-
|
4119
|
-
|
4120
|
-
|
4316
|
+
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
4317
|
+
transactionRequest: txRequestClone,
|
4318
|
+
gasPrice
|
4121
4319
|
}));
|
4122
4320
|
}
|
4123
4321
|
return {
|
4124
4322
|
requiredQuantities: allQuantities,
|
4125
4323
|
receipts,
|
4126
4324
|
gasUsed,
|
4127
|
-
|
4128
|
-
gasPrice: setGasPrice,
|
4325
|
+
gasPrice,
|
4129
4326
|
minGas,
|
4130
4327
|
maxGas,
|
4131
4328
|
minFee,
|
4132
4329
|
maxFee,
|
4133
|
-
estimatedInputs: txRequestClone.inputs,
|
4134
4330
|
outputVariables,
|
4135
|
-
missingContractIds
|
4331
|
+
missingContractIds,
|
4332
|
+
addedSignatures,
|
4333
|
+
estimatedPredicates: txRequestClone.inputs
|
4136
4334
|
};
|
4137
4335
|
}
|
4138
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
4336
|
+
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
4139
4337
|
const ownerAddress = Address2.fromAddressOrString(owner);
|
4140
4338
|
const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
|
4141
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
4339
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, {
|
4340
|
+
quantitiesToContract
|
4341
|
+
});
|
4142
4342
|
transactionRequest.addResources(
|
4143
4343
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
4144
4344
|
);
|
4145
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4146
|
-
|
4147
|
-
|
4148
|
-
);
|
4345
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
|
4346
|
+
quantitiesToContract
|
4347
|
+
});
|
4149
4348
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
4150
4349
|
return {
|
4151
4350
|
resources,
|
@@ -4167,11 +4366,10 @@ var _Provider = class {
|
|
4167
4366
|
return coins.map((coin) => ({
|
4168
4367
|
id: coin.utxoId,
|
4169
4368
|
assetId: coin.assetId,
|
4170
|
-
amount:
|
4369
|
+
amount: bn16(coin.amount),
|
4171
4370
|
owner: Address2.fromAddressOrString(coin.owner),
|
4172
|
-
|
4173
|
-
|
4174
|
-
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4371
|
+
blockCreated: bn16(coin.blockCreated),
|
4372
|
+
txCreatedIdx: bn16(coin.txCreatedIdx)
|
4175
4373
|
}));
|
4176
4374
|
}
|
4177
4375
|
/**
|
@@ -4208,9 +4406,9 @@ var _Provider = class {
|
|
4208
4406
|
switch (coin.__typename) {
|
4209
4407
|
case "MessageCoin":
|
4210
4408
|
return {
|
4211
|
-
amount:
|
4409
|
+
amount: bn16(coin.amount),
|
4212
4410
|
assetId: coin.assetId,
|
4213
|
-
daHeight:
|
4411
|
+
daHeight: bn16(coin.daHeight),
|
4214
4412
|
sender: Address2.fromAddressOrString(coin.sender),
|
4215
4413
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4216
4414
|
nonce: coin.nonce
|
@@ -4218,12 +4416,11 @@ var _Provider = class {
|
|
4218
4416
|
case "Coin":
|
4219
4417
|
return {
|
4220
4418
|
id: coin.utxoId,
|
4221
|
-
amount:
|
4419
|
+
amount: bn16(coin.amount),
|
4222
4420
|
assetId: coin.assetId,
|
4223
4421
|
owner: Address2.fromAddressOrString(coin.owner),
|
4224
|
-
|
4225
|
-
|
4226
|
-
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4422
|
+
blockCreated: bn16(coin.blockCreated),
|
4423
|
+
txCreatedIdx: bn16(coin.txCreatedIdx)
|
4227
4424
|
};
|
4228
4425
|
default:
|
4229
4426
|
return null;
|
@@ -4240,13 +4437,13 @@ var _Provider = class {
|
|
4240
4437
|
async getBlock(idOrHeight) {
|
4241
4438
|
let variables;
|
4242
4439
|
if (typeof idOrHeight === "number") {
|
4243
|
-
variables = { height:
|
4440
|
+
variables = { height: bn16(idOrHeight).toString(10) };
|
4244
4441
|
} else if (idOrHeight === "latest") {
|
4245
4442
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4246
4443
|
} else if (idOrHeight.length === 66) {
|
4247
4444
|
variables = { blockId: idOrHeight };
|
4248
4445
|
} else {
|
4249
|
-
variables = { blockId:
|
4446
|
+
variables = { blockId: bn16(idOrHeight).toString(10) };
|
4250
4447
|
}
|
4251
4448
|
const { block } = await this.operations.getBlock(variables);
|
4252
4449
|
if (!block) {
|
@@ -4254,7 +4451,7 @@ var _Provider = class {
|
|
4254
4451
|
}
|
4255
4452
|
return {
|
4256
4453
|
id: block.id,
|
4257
|
-
height:
|
4454
|
+
height: bn16(block.height),
|
4258
4455
|
time: block.header.time,
|
4259
4456
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4260
4457
|
};
|
@@ -4269,7 +4466,7 @@ var _Provider = class {
|
|
4269
4466
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4270
4467
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4271
4468
|
id: block.id,
|
4272
|
-
height:
|
4469
|
+
height: bn16(block.height),
|
4273
4470
|
time: block.header.time,
|
4274
4471
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4275
4472
|
}));
|
@@ -4284,7 +4481,7 @@ var _Provider = class {
|
|
4284
4481
|
async getBlockWithTransactions(idOrHeight) {
|
4285
4482
|
let variables;
|
4286
4483
|
if (typeof idOrHeight === "number") {
|
4287
|
-
variables = { blockHeight:
|
4484
|
+
variables = { blockHeight: bn16(idOrHeight).toString(10) };
|
4288
4485
|
} else if (idOrHeight === "latest") {
|
4289
4486
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4290
4487
|
} else {
|
@@ -4296,7 +4493,7 @@ var _Provider = class {
|
|
4296
4493
|
}
|
4297
4494
|
return {
|
4298
4495
|
id: block.id,
|
4299
|
-
height:
|
4496
|
+
height: bn16(block.height, 10),
|
4300
4497
|
time: block.header.time,
|
4301
4498
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4302
4499
|
transactions: block.transactions.map(
|
@@ -4345,7 +4542,7 @@ var _Provider = class {
|
|
4345
4542
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4346
4543
|
asset: hexlify12(assetId)
|
4347
4544
|
});
|
4348
|
-
return
|
4545
|
+
return bn16(contractBalance.amount, 10);
|
4349
4546
|
}
|
4350
4547
|
/**
|
4351
4548
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4359,7 +4556,7 @@ var _Provider = class {
|
|
4359
4556
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4360
4557
|
assetId: hexlify12(assetId)
|
4361
4558
|
});
|
4362
|
-
return
|
4559
|
+
return bn16(balance.amount, 10);
|
4363
4560
|
}
|
4364
4561
|
/**
|
4365
4562
|
* Returns balances for the given owner.
|
@@ -4377,7 +4574,7 @@ var _Provider = class {
|
|
4377
4574
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4378
4575
|
return balances.map((balance) => ({
|
4379
4576
|
assetId: balance.assetId,
|
4380
|
-
amount:
|
4577
|
+
amount: bn16(balance.amount)
|
4381
4578
|
}));
|
4382
4579
|
}
|
4383
4580
|
/**
|
@@ -4399,15 +4596,15 @@ var _Provider = class {
|
|
4399
4596
|
sender: message.sender,
|
4400
4597
|
recipient: message.recipient,
|
4401
4598
|
nonce: message.nonce,
|
4402
|
-
amount:
|
4599
|
+
amount: bn16(message.amount),
|
4403
4600
|
data: message.data
|
4404
4601
|
}),
|
4405
4602
|
sender: Address2.fromAddressOrString(message.sender),
|
4406
4603
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4407
4604
|
nonce: message.nonce,
|
4408
|
-
amount:
|
4605
|
+
amount: bn16(message.amount),
|
4409
4606
|
data: InputMessageCoder.decodeData(message.data),
|
4410
|
-
daHeight:
|
4607
|
+
daHeight: bn16(message.daHeight)
|
4411
4608
|
}));
|
4412
4609
|
}
|
4413
4610
|
/**
|
@@ -4460,44 +4657,52 @@ var _Provider = class {
|
|
4460
4657
|
} = result.messageProof;
|
4461
4658
|
return {
|
4462
4659
|
messageProof: {
|
4463
|
-
proofIndex:
|
4660
|
+
proofIndex: bn16(messageProof.proofIndex),
|
4464
4661
|
proofSet: messageProof.proofSet
|
4465
4662
|
},
|
4466
4663
|
blockProof: {
|
4467
|
-
proofIndex:
|
4664
|
+
proofIndex: bn16(blockProof.proofIndex),
|
4468
4665
|
proofSet: blockProof.proofSet
|
4469
4666
|
},
|
4470
4667
|
messageBlockHeader: {
|
4471
4668
|
id: messageBlockHeader.id,
|
4472
|
-
daHeight:
|
4473
|
-
transactionsCount:
|
4669
|
+
daHeight: bn16(messageBlockHeader.daHeight),
|
4670
|
+
transactionsCount: bn16(messageBlockHeader.transactionsCount),
|
4474
4671
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4475
|
-
height:
|
4672
|
+
height: bn16(messageBlockHeader.height),
|
4476
4673
|
prevRoot: messageBlockHeader.prevRoot,
|
4477
4674
|
time: messageBlockHeader.time,
|
4478
4675
|
applicationHash: messageBlockHeader.applicationHash,
|
4479
|
-
|
4480
|
-
messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
|
4676
|
+
messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount)
|
4481
4677
|
},
|
4482
4678
|
commitBlockHeader: {
|
4483
4679
|
id: commitBlockHeader.id,
|
4484
|
-
daHeight:
|
4485
|
-
transactionsCount:
|
4680
|
+
daHeight: bn16(commitBlockHeader.daHeight),
|
4681
|
+
transactionsCount: bn16(commitBlockHeader.transactionsCount),
|
4486
4682
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4487
|
-
height:
|
4683
|
+
height: bn16(commitBlockHeader.height),
|
4488
4684
|
prevRoot: commitBlockHeader.prevRoot,
|
4489
4685
|
time: commitBlockHeader.time,
|
4490
4686
|
applicationHash: commitBlockHeader.applicationHash,
|
4491
|
-
|
4492
|
-
messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
|
4687
|
+
messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount)
|
4493
4688
|
},
|
4494
4689
|
sender: Address2.fromAddressOrString(sender),
|
4495
4690
|
recipient: Address2.fromAddressOrString(recipient),
|
4496
4691
|
nonce,
|
4497
|
-
amount:
|
4692
|
+
amount: bn16(amount),
|
4498
4693
|
data
|
4499
4694
|
};
|
4500
4695
|
}
|
4696
|
+
async getLatestGasPrice() {
|
4697
|
+
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4698
|
+
return bn16(latestGasPrice.gasPrice);
|
4699
|
+
}
|
4700
|
+
async estimateGasPrice(blockHorizon) {
|
4701
|
+
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4702
|
+
blockHorizon: String(blockHorizon)
|
4703
|
+
});
|
4704
|
+
return bn16(estimateGasPrice.gasPrice);
|
4705
|
+
}
|
4501
4706
|
/**
|
4502
4707
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
4503
4708
|
*
|
@@ -4517,10 +4722,10 @@ var _Provider = class {
|
|
4517
4722
|
*/
|
4518
4723
|
async produceBlocks(amount, startTime) {
|
4519
4724
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4520
|
-
blocksToProduce:
|
4725
|
+
blocksToProduce: bn16(amount).toString(10),
|
4521
4726
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4522
4727
|
});
|
4523
|
-
return
|
4728
|
+
return bn16(latestBlockHeight);
|
4524
4729
|
}
|
4525
4730
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4526
4731
|
async getTransactionResponse(transactionId) {
|
@@ -4534,7 +4739,7 @@ cacheInputs_fn = function(inputs) {
|
|
4534
4739
|
return;
|
4535
4740
|
}
|
4536
4741
|
inputs.forEach((input) => {
|
4537
|
-
if (input.type ===
|
4742
|
+
if (input.type === InputType7.Coin) {
|
4538
4743
|
this.cache?.set(input.id);
|
4539
4744
|
}
|
4540
4745
|
});
|
@@ -4544,7 +4749,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4544
4749
|
|
4545
4750
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4546
4751
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4547
|
-
import { bn as
|
4752
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
4548
4753
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4549
4754
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4550
4755
|
async function getTransactionSummary(params) {
|
@@ -4562,21 +4767,28 @@ async function getTransactionSummary(params) {
|
|
4562
4767
|
arrayify12(gqlTransaction.rawPayload),
|
4563
4768
|
0
|
4564
4769
|
);
|
4565
|
-
|
4770
|
+
let txReceipts = [];
|
4771
|
+
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
4772
|
+
txReceipts = gqlTransaction.status.receipts;
|
4773
|
+
}
|
4774
|
+
const receipts = txReceipts.map(processGqlReceipt);
|
4566
4775
|
const {
|
4567
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
4776
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
4568
4777
|
} = provider.getChain();
|
4778
|
+
const gasPrice = await provider.getLatestGasPrice();
|
4569
4779
|
const transactionInfo = assembleTransactionSummary({
|
4570
4780
|
id: gqlTransaction.id,
|
4571
4781
|
receipts,
|
4572
4782
|
transaction: decodedTransaction,
|
4573
4783
|
transactionBytes: arrayify12(gqlTransaction.rawPayload),
|
4574
4784
|
gqlTransactionStatus: gqlTransaction.status,
|
4575
|
-
gasPerByte:
|
4576
|
-
gasPriceFactor:
|
4785
|
+
gasPerByte: bn17(gasPerByte),
|
4786
|
+
gasPriceFactor: bn17(gasPriceFactor),
|
4577
4787
|
abiMap,
|
4578
4788
|
maxInputs,
|
4579
|
-
gasCosts
|
4789
|
+
gasCosts,
|
4790
|
+
maxGasPerTx,
|
4791
|
+
gasPrice
|
4580
4792
|
});
|
4581
4793
|
return {
|
4582
4794
|
gqlTransaction,
|
@@ -4586,10 +4798,11 @@ async function getTransactionSummary(params) {
|
|
4586
4798
|
async function getTransactionSummaryFromRequest(params) {
|
4587
4799
|
const { provider, transactionRequest, abiMap } = params;
|
4588
4800
|
const { receipts } = await provider.call(transactionRequest);
|
4589
|
-
const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
|
4801
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
|
4590
4802
|
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
4591
4803
|
const transaction = transactionRequest.toTransaction();
|
4592
4804
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
4805
|
+
const gasPrice = await provider.getLatestGasPrice();
|
4593
4806
|
const transactionSummary = assembleTransactionSummary({
|
4594
4807
|
receipts,
|
4595
4808
|
transaction,
|
@@ -4598,7 +4811,9 @@ async function getTransactionSummaryFromRequest(params) {
|
|
4598
4811
|
gasPerByte,
|
4599
4812
|
gasPriceFactor,
|
4600
4813
|
maxInputs,
|
4601
|
-
gasCosts
|
4814
|
+
gasCosts,
|
4815
|
+
maxGasPerTx,
|
4816
|
+
gasPrice
|
4602
4817
|
});
|
4603
4818
|
return transactionSummary;
|
4604
4819
|
}
|
@@ -4607,13 +4822,18 @@ async function getTransactionsSummaries(params) {
|
|
4607
4822
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
4608
4823
|
const { edges, pageInfo } = transactionsByOwner;
|
4609
4824
|
const {
|
4610
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
4825
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
4611
4826
|
} = provider.getChain();
|
4827
|
+
const gasPrice = await provider.getLatestGasPrice();
|
4612
4828
|
const transactions = edges.map((edge) => {
|
4613
4829
|
const { node: gqlTransaction } = edge;
|
4614
|
-
const { id, rawPayload,
|
4830
|
+
const { id, rawPayload, status } = gqlTransaction;
|
4615
4831
|
const [decodedTransaction] = new TransactionCoder6().decode(arrayify12(rawPayload), 0);
|
4616
|
-
|
4832
|
+
let txReceipts = [];
|
4833
|
+
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
4834
|
+
txReceipts = gqlTransaction.status.receipts;
|
4835
|
+
}
|
4836
|
+
const receipts = txReceipts.map(processGqlReceipt);
|
4617
4837
|
const transactionSummary = assembleTransactionSummary({
|
4618
4838
|
id,
|
4619
4839
|
receipts,
|
@@ -4624,7 +4844,9 @@ async function getTransactionsSummaries(params) {
|
|
4624
4844
|
gasPerByte,
|
4625
4845
|
gasPriceFactor,
|
4626
4846
|
maxInputs,
|
4627
|
-
gasCosts
|
4847
|
+
gasCosts,
|
4848
|
+
maxGasPerTx,
|
4849
|
+
gasPrice
|
4628
4850
|
});
|
4629
4851
|
const output = {
|
4630
4852
|
gqlTransaction,
|
@@ -4956,36 +5178,33 @@ var Account = class extends AbstractAccount {
|
|
4956
5178
|
* @param fee - The estimated transaction fee.
|
4957
5179
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4958
5180
|
*/
|
4959
|
-
async fund(request,
|
4960
|
-
const
|
4961
|
-
|
5181
|
+
async fund(request, params) {
|
5182
|
+
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
5183
|
+
const txRequest = request;
|
5184
|
+
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5185
|
+
amount: bn18(fee),
|
4962
5186
|
assetId: BaseAssetId3,
|
4963
|
-
coinQuantities
|
5187
|
+
coinQuantities: requiredQuantities
|
4964
5188
|
});
|
4965
5189
|
const quantitiesDict = {};
|
4966
|
-
|
5190
|
+
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
4967
5191
|
quantitiesDict[assetId] = {
|
4968
5192
|
required: amount,
|
4969
|
-
owned:
|
5193
|
+
owned: bn18(0)
|
4970
5194
|
};
|
4971
5195
|
});
|
4972
|
-
|
4973
|
-
const cachedMessages = [];
|
4974
|
-
const owner = this.address.toB256();
|
4975
|
-
request.inputs.forEach((input) => {
|
5196
|
+
txRequest.inputs.forEach((input) => {
|
4976
5197
|
const isResource = "amount" in input;
|
4977
5198
|
if (isResource) {
|
4978
5199
|
const isCoin2 = "owner" in input;
|
4979
5200
|
if (isCoin2) {
|
4980
5201
|
const assetId = String(input.assetId);
|
4981
|
-
if (
|
4982
|
-
const amount =
|
5202
|
+
if (quantitiesDict[assetId]) {
|
5203
|
+
const amount = bn18(input.amount);
|
4983
5204
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4984
|
-
cachedUtxos.push(input.id);
|
4985
5205
|
}
|
4986
|
-
} else if (input.
|
5206
|
+
} else if (input.amount && quantitiesDict[BaseAssetId3]) {
|
4987
5207
|
quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
|
4988
|
-
cachedMessages.push(input.nonce);
|
4989
5208
|
}
|
4990
5209
|
}
|
4991
5210
|
});
|
@@ -5000,12 +5219,23 @@ var Account = class extends AbstractAccount {
|
|
5000
5219
|
});
|
5001
5220
|
const needsToBeFunded = missingQuantities.length;
|
5002
5221
|
if (needsToBeFunded) {
|
5003
|
-
const
|
5004
|
-
|
5005
|
-
|
5006
|
-
|
5007
|
-
|
5222
|
+
const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
|
5223
|
+
const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
|
5224
|
+
txRequest.addResources(resources);
|
5225
|
+
}
|
5226
|
+
txRequest.shiftPredicateData();
|
5227
|
+
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
5228
|
+
const requestToBeReEstimate = clone4(txRequest);
|
5229
|
+
if (addedSignatures) {
|
5230
|
+
Array.from({ length: addedSignatures }).forEach(
|
5231
|
+
() => requestToBeReEstimate.addEmptyWitness()
|
5232
|
+
);
|
5008
5233
|
}
|
5234
|
+
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
5235
|
+
transactionRequest: requestToBeReEstimate
|
5236
|
+
});
|
5237
|
+
txRequest.maxFee = maxFee;
|
5238
|
+
return txRequest;
|
5009
5239
|
}
|
5010
5240
|
/**
|
5011
5241
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -5013,28 +5243,25 @@ var Account = class extends AbstractAccount {
|
|
5013
5243
|
* @param destination - The address of the destination.
|
5014
5244
|
* @param amount - The amount of coins to transfer.
|
5015
5245
|
* @param assetId - The asset ID of the coins to transfer.
|
5016
|
-
* @param txParams - The transaction parameters (gasLimit,
|
5246
|
+
* @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
|
5017
5247
|
* @returns A promise that resolves to the prepared transaction request.
|
5018
5248
|
*/
|
5019
5249
|
async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
5020
|
-
const
|
5021
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
5022
|
-
const request = new ScriptTransactionRequest(params);
|
5250
|
+
const request = new ScriptTransactionRequest(txParams);
|
5023
5251
|
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
|
5024
|
-
const
|
5252
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
5025
5253
|
estimateTxDependencies: true,
|
5026
5254
|
resourcesOwner: this
|
5027
5255
|
});
|
5028
|
-
|
5029
|
-
|
5030
|
-
|
5031
|
-
|
5032
|
-
|
5033
|
-
|
5034
|
-
|
5035
|
-
|
5036
|
-
await this.fund(request,
|
5037
|
-
request.updatePredicateInputs(estimatedInputs);
|
5256
|
+
if ("gasLimit" in txParams) {
|
5257
|
+
this.validateGas({
|
5258
|
+
gasUsed: txCost.gasUsed,
|
5259
|
+
gasLimit: request.gasLimit
|
5260
|
+
});
|
5261
|
+
}
|
5262
|
+
request.gasLimit = txCost.gasUsed;
|
5263
|
+
request.maxFee = txCost.maxFee;
|
5264
|
+
await this.fund(request, txCost);
|
5038
5265
|
return request;
|
5039
5266
|
}
|
5040
5267
|
/**
|
@@ -5047,7 +5274,7 @@ var Account = class extends AbstractAccount {
|
|
5047
5274
|
* @returns A promise that resolves to the transaction response.
|
5048
5275
|
*/
|
5049
5276
|
async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
5050
|
-
if (
|
5277
|
+
if (bn18(amount).lte(0)) {
|
5051
5278
|
throw new FuelError15(
|
5052
5279
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5053
5280
|
"Transfer amount must be a positive number."
|
@@ -5066,38 +5293,37 @@ var Account = class extends AbstractAccount {
|
|
5066
5293
|
* @returns A promise that resolves to the transaction response.
|
5067
5294
|
*/
|
5068
5295
|
async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
|
5069
|
-
if (
|
5296
|
+
if (bn18(amount).lte(0)) {
|
5070
5297
|
throw new FuelError15(
|
5071
5298
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5072
5299
|
"Transfer amount must be a positive number."
|
5073
5300
|
);
|
5074
5301
|
}
|
5075
5302
|
const contractAddress = Address3.fromAddressOrString(contractId);
|
5076
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
5077
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
5078
5303
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5079
5304
|
hexlifiedContractId: contractAddress.toB256(),
|
5080
|
-
amountToTransfer:
|
5305
|
+
amountToTransfer: bn18(amount),
|
5081
5306
|
assetId
|
5082
5307
|
});
|
5083
5308
|
const request = new ScriptTransactionRequest({
|
5084
|
-
...
|
5309
|
+
...txParams,
|
5085
5310
|
script,
|
5086
5311
|
scriptData
|
5087
5312
|
});
|
5088
5313
|
request.addContractInputAndOutput(contractAddress);
|
5089
|
-
const
|
5090
|
-
|
5091
|
-
[{ amount:
|
5092
|
-
);
|
5093
|
-
request.gasLimit = bn17(params.gasLimit ?? gasUsed);
|
5094
|
-
this.validateGas({
|
5095
|
-
gasUsed,
|
5096
|
-
gasPrice: request.gasPrice,
|
5097
|
-
gasLimit: request.gasLimit,
|
5098
|
-
minGasPrice
|
5314
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
5315
|
+
resourcesOwner: this,
|
5316
|
+
quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
|
5099
5317
|
});
|
5100
|
-
|
5318
|
+
if (txParams.gasLimit) {
|
5319
|
+
this.validateGas({
|
5320
|
+
gasUsed: txCost.gasUsed,
|
5321
|
+
gasLimit: request.gasLimit
|
5322
|
+
});
|
5323
|
+
}
|
5324
|
+
request.gasLimit = txCost.gasUsed;
|
5325
|
+
request.maxFee = txCost.maxFee;
|
5326
|
+
await this.fund(request, txCost);
|
5101
5327
|
return this.sendTransaction(request);
|
5102
5328
|
}
|
5103
5329
|
/**
|
@@ -5109,34 +5335,31 @@ var Account = class extends AbstractAccount {
|
|
5109
5335
|
* @returns A promise that resolves to the transaction response.
|
5110
5336
|
*/
|
5111
5337
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5112
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
5113
5338
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
5114
5339
|
const recipientDataArray = arrayify14(
|
5115
5340
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5116
5341
|
);
|
5117
5342
|
const amountDataArray = arrayify14(
|
5118
|
-
"0x".concat(
|
5343
|
+
"0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
|
5119
5344
|
);
|
5120
5345
|
const script = new Uint8Array([
|
5121
5346
|
...arrayify14(withdrawScript.bytes),
|
5122
5347
|
...recipientDataArray,
|
5123
5348
|
...amountDataArray
|
5124
5349
|
]);
|
5125
|
-
const params = { script,
|
5350
|
+
const params = { script, ...txParams };
|
5126
5351
|
const request = new ScriptTransactionRequest(params);
|
5127
|
-
const
|
5128
|
-
const
|
5129
|
-
|
5130
|
-
|
5131
|
-
|
5132
|
-
|
5133
|
-
|
5134
|
-
|
5135
|
-
|
5136
|
-
|
5137
|
-
|
5138
|
-
});
|
5139
|
-
await this.fund(request, requiredQuantities, maxFee);
|
5352
|
+
const quantitiesToContract = [{ amount: bn18(amount), assetId: BaseAssetId3 }];
|
5353
|
+
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5354
|
+
if (txParams.gasLimit) {
|
5355
|
+
this.validateGas({
|
5356
|
+
gasUsed: txCost.gasUsed,
|
5357
|
+
gasLimit: request.gasLimit
|
5358
|
+
});
|
5359
|
+
}
|
5360
|
+
request.maxFee = txCost.maxFee;
|
5361
|
+
request.gasLimit = txCost.gasUsed;
|
5362
|
+
await this.fund(request, txCost);
|
5140
5363
|
return this.sendTransaction(request);
|
5141
5364
|
}
|
5142
5365
|
async signMessage(message) {
|
@@ -5194,18 +5417,7 @@ var Account = class extends AbstractAccount {
|
|
5194
5417
|
}
|
5195
5418
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5196
5419
|
}
|
5197
|
-
validateGas({
|
5198
|
-
gasUsed,
|
5199
|
-
gasPrice,
|
5200
|
-
gasLimit,
|
5201
|
-
minGasPrice
|
5202
|
-
}) {
|
5203
|
-
if (minGasPrice.gt(gasPrice)) {
|
5204
|
-
throw new FuelError15(
|
5205
|
-
ErrorCode15.GAS_PRICE_TOO_LOW,
|
5206
|
-
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
5207
|
-
);
|
5208
|
-
}
|
5420
|
+
validateGas({ gasUsed, gasLimit }) {
|
5209
5421
|
if (gasUsed.gt(gasLimit)) {
|
5210
5422
|
throw new FuelError15(
|
5211
5423
|
ErrorCode15.GAS_LIMIT_TOO_LOW,
|
@@ -5501,7 +5713,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5501
5713
|
* @param transactionRequestLike - The transaction request to send.
|
5502
5714
|
* @returns A promise that resolves to the TransactionResponse object.
|
5503
5715
|
*/
|
5504
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
5716
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
|
5505
5717
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5506
5718
|
if (estimateTxDependencies) {
|
5507
5719
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -5542,7 +5754,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5542
5754
|
// src/hdwallet/hdwallet.ts
|
5543
5755
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5544
5756
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5545
|
-
import { bn as
|
5757
|
+
import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5546
5758
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5547
5759
|
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5548
5760
|
|
@@ -8014,7 +8226,7 @@ var HDWallet = class {
|
|
8014
8226
|
const IR = bytes.slice(32);
|
8015
8227
|
if (privateKey) {
|
8016
8228
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8017
|
-
const ki =
|
8229
|
+
const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
|
8018
8230
|
return new HDWallet({
|
8019
8231
|
privateKey: ki,
|
8020
8232
|
chainCode: IR,
|
@@ -8703,7 +8915,7 @@ import {
|
|
8703
8915
|
import { Address as Address9 } from "@fuel-ts/address";
|
8704
8916
|
import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
|
8705
8917
|
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
8706
|
-
import { ByteArrayCoder, InputType as
|
8918
|
+
import { ByteArrayCoder, InputType as InputType8 } from "@fuel-ts/transactions";
|
8707
8919
|
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
8708
8920
|
|
8709
8921
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -8752,6 +8964,7 @@ var Predicate = class extends Account {
|
|
8752
8964
|
this.interface = predicateInterface;
|
8753
8965
|
if (inputData !== void 0 && inputData.length > 0) {
|
8754
8966
|
this.predicateData = inputData;
|
8967
|
+
this.predicateDataBytes = this.getPredicateData(0);
|
8755
8968
|
}
|
8756
8969
|
}
|
8757
8970
|
/**
|
@@ -8764,9 +8977,9 @@ var Predicate = class extends Account {
|
|
8764
8977
|
const request = transactionRequestify(transactionRequestLike);
|
8765
8978
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
8766
8979
|
request.inputs?.forEach((input) => {
|
8767
|
-
if (input.type ===
|
8768
|
-
input.predicate = this.bytes;
|
8769
|
-
input.predicateData = this.getPredicateData(policies.length);
|
8980
|
+
if (input.type === InputType8.Coin && hexlify19(input.owner) === this.address.toB256()) {
|
8981
|
+
input.predicate = hexlify19(this.bytes);
|
8982
|
+
input.predicateData = hexlify19(this.getPredicateData(policies.length));
|
8770
8983
|
}
|
8771
8984
|
});
|
8772
8985
|
return request;
|
@@ -8781,8 +8994,7 @@ var Predicate = class extends Account {
|
|
8781
8994
|
* @returns A promise that resolves to the prepared transaction request.
|
8782
8995
|
*/
|
8783
8996
|
async createTransfer(destination, amount, assetId = BaseAssetId4, txParams = {}) {
|
8784
|
-
|
8785
|
-
return this.populateTransactionPredicateData(request);
|
8997
|
+
return super.createTransfer(destination, amount, assetId, txParams);
|
8786
8998
|
}
|
8787
8999
|
/**
|
8788
9000
|
* Sends a transaction with the populated predicate data.
|
@@ -8790,9 +9002,9 @@ var Predicate = class extends Account {
|
|
8790
9002
|
* @param transactionRequestLike - The transaction request-like object.
|
8791
9003
|
* @returns A promise that resolves to the transaction response.
|
8792
9004
|
*/
|
8793
|
-
sendTransaction(transactionRequestLike
|
8794
|
-
const transactionRequest =
|
8795
|
-
return super.sendTransaction(transactionRequest,
|
9005
|
+
sendTransaction(transactionRequestLike) {
|
9006
|
+
const transactionRequest = transactionRequestify(transactionRequestLike);
|
9007
|
+
return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
|
8796
9008
|
}
|
8797
9009
|
/**
|
8798
9010
|
* Simulates a transaction with the populated predicate data.
|
@@ -8801,8 +9013,8 @@ var Predicate = class extends Account {
|
|
8801
9013
|
* @returns A promise that resolves to the call result.
|
8802
9014
|
*/
|
8803
9015
|
simulateTransaction(transactionRequestLike) {
|
8804
|
-
const transactionRequest =
|
8805
|
-
return super.simulateTransaction(transactionRequest);
|
9016
|
+
const transactionRequest = transactionRequestify(transactionRequestLike);
|
9017
|
+
return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
|
8806
9018
|
}
|
8807
9019
|
getPredicateData(policiesLength) {
|
8808
9020
|
if (!this.predicateData.length) {
|
@@ -8848,6 +9060,26 @@ var Predicate = class extends Account {
|
|
8848
9060
|
predicateInterface: abiInterface
|
8849
9061
|
};
|
8850
9062
|
}
|
9063
|
+
/**
|
9064
|
+
* Retrieves resources satisfying the spend query for the account.
|
9065
|
+
*
|
9066
|
+
* @param quantities - IDs of coins to exclude.
|
9067
|
+
* @param excludedIds - IDs of resources to be excluded from the query.
|
9068
|
+
* @returns A promise that resolves to an array of Resources.
|
9069
|
+
*/
|
9070
|
+
async getResourcesToSpend(quantities, excludedIds) {
|
9071
|
+
const resources = await this.provider.getResourcesToSpend(
|
9072
|
+
this.address,
|
9073
|
+
quantities,
|
9074
|
+
excludedIds
|
9075
|
+
);
|
9076
|
+
return resources.map((resource) => ({
|
9077
|
+
...resource,
|
9078
|
+
predicate: hexlify19(this.bytes),
|
9079
|
+
predicateData: hexlify19(this.predicateDataBytes),
|
9080
|
+
paddPredicateData: (policiesLength) => hexlify19(this.getPredicateData(policiesLength))
|
9081
|
+
}));
|
9082
|
+
}
|
8851
9083
|
/**
|
8852
9084
|
* Sets the configurable constants for the predicate.
|
8853
9085
|
*
|
@@ -9596,7 +9828,7 @@ export {
|
|
9596
9828
|
WalletLocked,
|
9597
9829
|
WalletManager,
|
9598
9830
|
WalletUnlocked,
|
9599
|
-
|
9831
|
+
addAmountToCoinQuantities,
|
9600
9832
|
addOperation,
|
9601
9833
|
assemblePanicError,
|
9602
9834
|
assembleReceiptByType,
|
@@ -9605,9 +9837,10 @@ export {
|
|
9605
9837
|
assets,
|
9606
9838
|
buildBlockExplorerUrl,
|
9607
9839
|
cacheFor,
|
9840
|
+
cacheTxInputsFromOwner,
|
9841
|
+
calculateGasFee,
|
9608
9842
|
calculateMetadataGasForTxCreate,
|
9609
9843
|
calculateMetadataGasForTxScript,
|
9610
|
-
calculatePriceWithFactor,
|
9611
9844
|
calculateTransactionFee,
|
9612
9845
|
coinQuantityfy,
|
9613
9846
|
deferPromise,
|