@fuel-ts/account 0.0.0-rc-2037-20240411135757 → 0.0.0-rc-2021-20240411141803
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/README.md +1 -1
- package/dist/account.d.ts +5 -4
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +844 -560
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +786 -518
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +666 -399
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +10 -10
- 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 +2 -1
- 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 +2 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +45 -27
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +2 -2
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +6 -5
- 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 +1562 -1046
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +764 -499
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +660 -395
- 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: arrayify(value.id)
|
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),
|
@@ -1166,6 +1225,7 @@ import {
|
|
1166
1225
|
TransactionType
|
1167
1226
|
} from "@fuel-ts/transactions";
|
1168
1227
|
import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
|
1228
|
+
import { randomBytes } from "ethers";
|
1169
1229
|
|
1170
1230
|
// src/providers/resource.ts
|
1171
1231
|
var isRawCoin = (resource) => "utxoId" in resource;
|
@@ -1209,8 +1269,8 @@ function assembleReceiptByType(receipt) {
|
|
1209
1269
|
case "CALL" /* Call */: {
|
1210
1270
|
const callReceipt = {
|
1211
1271
|
type: ReceiptType.Call,
|
1212
|
-
from: hexOrZero(receipt.
|
1213
|
-
to: hexOrZero(receipt?.to
|
1272
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1273
|
+
to: hexOrZero(receipt?.to),
|
1214
1274
|
amount: bn4(receipt.amount),
|
1215
1275
|
assetId: hexOrZero(receipt.assetId),
|
1216
1276
|
gas: bn4(receipt.gas),
|
@@ -1224,7 +1284,7 @@ function assembleReceiptByType(receipt) {
|
|
1224
1284
|
case "RETURN" /* Return */: {
|
1225
1285
|
const returnReceipt = {
|
1226
1286
|
type: ReceiptType.Return,
|
1227
|
-
id: hexOrZero(receipt.
|
1287
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1228
1288
|
val: bn4(receipt.val),
|
1229
1289
|
pc: bn4(receipt.pc),
|
1230
1290
|
is: bn4(receipt.is)
|
@@ -1234,7 +1294,7 @@ function assembleReceiptByType(receipt) {
|
|
1234
1294
|
case "RETURN_DATA" /* ReturnData */: {
|
1235
1295
|
const returnDataReceipt = {
|
1236
1296
|
type: ReceiptType.ReturnData,
|
1237
|
-
id: hexOrZero(receipt.
|
1297
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1238
1298
|
ptr: bn4(receipt.ptr),
|
1239
1299
|
len: bn4(receipt.len),
|
1240
1300
|
digest: hexOrZero(receipt.digest),
|
@@ -1246,7 +1306,7 @@ function assembleReceiptByType(receipt) {
|
|
1246
1306
|
case "PANIC" /* Panic */: {
|
1247
1307
|
const panicReceipt = {
|
1248
1308
|
type: ReceiptType.Panic,
|
1249
|
-
id: hexOrZero(receipt.
|
1309
|
+
id: hexOrZero(receipt.id),
|
1250
1310
|
reason: bn4(receipt.reason),
|
1251
1311
|
pc: bn4(receipt.pc),
|
1252
1312
|
is: bn4(receipt.is),
|
@@ -1257,7 +1317,7 @@ function assembleReceiptByType(receipt) {
|
|
1257
1317
|
case "REVERT" /* Revert */: {
|
1258
1318
|
const revertReceipt = {
|
1259
1319
|
type: ReceiptType.Revert,
|
1260
|
-
id: hexOrZero(receipt.
|
1320
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1261
1321
|
val: bn4(receipt.ra),
|
1262
1322
|
pc: bn4(receipt.pc),
|
1263
1323
|
is: bn4(receipt.is)
|
@@ -1267,7 +1327,7 @@ function assembleReceiptByType(receipt) {
|
|
1267
1327
|
case "LOG" /* Log */: {
|
1268
1328
|
const logReceipt = {
|
1269
1329
|
type: ReceiptType.Log,
|
1270
|
-
id: hexOrZero(receipt.
|
1330
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1271
1331
|
val0: bn4(receipt.ra),
|
1272
1332
|
val1: bn4(receipt.rb),
|
1273
1333
|
val2: bn4(receipt.rc),
|
@@ -1280,7 +1340,7 @@ function assembleReceiptByType(receipt) {
|
|
1280
1340
|
case "LOG_DATA" /* LogData */: {
|
1281
1341
|
const logDataReceipt = {
|
1282
1342
|
type: ReceiptType.LogData,
|
1283
|
-
id: hexOrZero(receipt.
|
1343
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1284
1344
|
val0: bn4(receipt.ra),
|
1285
1345
|
val1: bn4(receipt.rb),
|
1286
1346
|
ptr: bn4(receipt.ptr),
|
@@ -1294,8 +1354,8 @@ function assembleReceiptByType(receipt) {
|
|
1294
1354
|
case "TRANSFER" /* Transfer */: {
|
1295
1355
|
const transferReceipt = {
|
1296
1356
|
type: ReceiptType.Transfer,
|
1297
|
-
from: hexOrZero(receipt.
|
1298
|
-
to: hexOrZero(receipt.toAddress || receipt?.to
|
1357
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1358
|
+
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1299
1359
|
amount: bn4(receipt.amount),
|
1300
1360
|
assetId: hexOrZero(receipt.assetId),
|
1301
1361
|
pc: bn4(receipt.pc),
|
@@ -1306,8 +1366,8 @@ function assembleReceiptByType(receipt) {
|
|
1306
1366
|
case "TRANSFER_OUT" /* TransferOut */: {
|
1307
1367
|
const transferOutReceipt = {
|
1308
1368
|
type: ReceiptType.TransferOut,
|
1309
|
-
from: hexOrZero(receipt.
|
1310
|
-
to: hexOrZero(receipt.toAddress || receipt.to
|
1369
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1370
|
+
to: hexOrZero(receipt.toAddress || receipt.to),
|
1311
1371
|
amount: bn4(receipt.amount),
|
1312
1372
|
assetId: hexOrZero(receipt.assetId),
|
1313
1373
|
pc: bn4(receipt.pc),
|
@@ -1350,7 +1410,7 @@ function assembleReceiptByType(receipt) {
|
|
1350
1410
|
return receiptMessageOut;
|
1351
1411
|
}
|
1352
1412
|
case "MINT" /* Mint */: {
|
1353
|
-
const contractId = hexOrZero(receipt.
|
1413
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1354
1414
|
const subId = hexOrZero(receipt.subId);
|
1355
1415
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
1356
1416
|
const mintReceipt = {
|
@@ -1365,7 +1425,7 @@ function assembleReceiptByType(receipt) {
|
|
1365
1425
|
return mintReceipt;
|
1366
1426
|
}
|
1367
1427
|
case "BURN" /* Burn */: {
|
1368
|
-
const contractId = hexOrZero(receipt.
|
1428
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1369
1429
|
const subId = hexOrZero(receipt.subId);
|
1370
1430
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
1371
1431
|
const burnReceipt = {
|
@@ -1450,7 +1510,6 @@ var buildBlockExplorerUrl = (options = {}) => {
|
|
1450
1510
|
import { bn as bn5 } from "@fuel-ts/math";
|
1451
1511
|
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
1452
1512
|
import { arrayify as arrayify3 } from "@fuel-ts/utils";
|
1453
|
-
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1454
1513
|
var getGasUsedFromReceipts = (receipts) => {
|
1455
1514
|
const scriptResult = receipts.filter(
|
1456
1515
|
(receipt) => receipt.type === ReceiptType2.ScriptResult
|
@@ -1471,18 +1530,28 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
1471
1530
|
}
|
1472
1531
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
1473
1532
|
const witnessCache = [];
|
1474
|
-
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) => {
|
1475
1548
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1476
1549
|
return total.add(
|
1477
|
-
|
1550
|
+
vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
|
1478
1551
|
);
|
1479
1552
|
}
|
1480
|
-
|
1481
|
-
|
1482
|
-
return total.add(gasCosts.ecr1);
|
1483
|
-
}
|
1484
|
-
return total;
|
1485
|
-
}, bn5());
|
1553
|
+
return total.add(gasCosts.ecr1);
|
1554
|
+
}, bn5(0));
|
1486
1555
|
return totalGas;
|
1487
1556
|
}
|
1488
1557
|
function getMinGas(params) {
|
@@ -1494,12 +1563,20 @@ function getMinGas(params) {
|
|
1494
1563
|
return minGas;
|
1495
1564
|
}
|
1496
1565
|
function getMaxGas(params) {
|
1497
|
-
const {
|
1566
|
+
const {
|
1567
|
+
gasPerByte,
|
1568
|
+
witnessesLength,
|
1569
|
+
witnessLimit,
|
1570
|
+
minGas,
|
1571
|
+
gasLimit = bn5(0),
|
1572
|
+
maxGasPerTx
|
1573
|
+
} = params;
|
1498
1574
|
let remainingAllowedWitnessGas = bn5(0);
|
1499
1575
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
1500
1576
|
remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
1501
1577
|
}
|
1502
|
-
|
1578
|
+
const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
1579
|
+
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
1503
1580
|
}
|
1504
1581
|
function calculateMetadataGasForTxCreate({
|
1505
1582
|
gasCosts,
|
@@ -1521,6 +1598,10 @@ function calculateMetadataGasForTxScript({
|
|
1521
1598
|
}) {
|
1522
1599
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1523
1600
|
}
|
1601
|
+
var calculateGasFee = (params) => {
|
1602
|
+
const { gas, gasPrice, priceFactor, tip } = params;
|
1603
|
+
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1604
|
+
};
|
1524
1605
|
|
1525
1606
|
// src/providers/utils/json.ts
|
1526
1607
|
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
@@ -1677,7 +1758,7 @@ var witnessify = (value) => {
|
|
1677
1758
|
// src/providers/transaction-request/transaction-request.ts
|
1678
1759
|
var BaseTransactionRequest = class {
|
1679
1760
|
/** Gas price for transaction */
|
1680
|
-
|
1761
|
+
tip;
|
1681
1762
|
/** Block until which tx cannot be included */
|
1682
1763
|
maturity;
|
1683
1764
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -1696,7 +1777,7 @@ var BaseTransactionRequest = class {
|
|
1696
1777
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
1697
1778
|
*/
|
1698
1779
|
constructor({
|
1699
|
-
|
1780
|
+
tip,
|
1700
1781
|
maturity,
|
1701
1782
|
maxFee,
|
1702
1783
|
witnessLimit,
|
@@ -1704,7 +1785,7 @@ var BaseTransactionRequest = class {
|
|
1704
1785
|
outputs,
|
1705
1786
|
witnesses
|
1706
1787
|
} = {}) {
|
1707
|
-
this.
|
1788
|
+
this.tip = bn7(tip);
|
1708
1789
|
this.maturity = maturity ?? 0;
|
1709
1790
|
this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
|
1710
1791
|
this.maxFee = maxFee ? bn7(maxFee) : void 0;
|
@@ -1715,9 +1796,9 @@ var BaseTransactionRequest = class {
|
|
1715
1796
|
static getPolicyMeta(req) {
|
1716
1797
|
let policyTypes = 0;
|
1717
1798
|
const policies = [];
|
1718
|
-
if (req.
|
1719
|
-
policyTypes += PolicyType.
|
1720
|
-
policies.push({ data: req.
|
1799
|
+
if (req.tip) {
|
1800
|
+
policyTypes += PolicyType.Tip;
|
1801
|
+
policies.push({ data: req.tip, type: PolicyType.Tip });
|
1721
1802
|
}
|
1722
1803
|
if (req.witnessLimit) {
|
1723
1804
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -1905,9 +1986,9 @@ var BaseTransactionRequest = class {
|
|
1905
1986
|
* @param predicateData - Predicate data bytes.
|
1906
1987
|
*/
|
1907
1988
|
addCoinInput(coin) {
|
1908
|
-
const { assetId, owner, amount
|
1989
|
+
const { assetId, owner, amount } = coin;
|
1909
1990
|
let witnessIndex;
|
1910
|
-
if (predicate) {
|
1991
|
+
if (coin.predicate) {
|
1911
1992
|
witnessIndex = 0;
|
1912
1993
|
} else {
|
1913
1994
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -1916,14 +1997,13 @@ var BaseTransactionRequest = class {
|
|
1916
1997
|
}
|
1917
1998
|
}
|
1918
1999
|
const input = {
|
1919
|
-
|
2000
|
+
...coin,
|
1920
2001
|
type: InputType2.Coin,
|
1921
2002
|
owner: owner.toB256(),
|
1922
2003
|
amount,
|
1923
2004
|
assetId,
|
1924
2005
|
txPointer: "0x00000000000000000000000000000000",
|
1925
|
-
witnessIndex
|
1926
|
-
predicate
|
2006
|
+
witnessIndex
|
1927
2007
|
};
|
1928
2008
|
this.pushInput(input);
|
1929
2009
|
this.addChangeOutput(owner, assetId);
|
@@ -1937,10 +2017,10 @@ var BaseTransactionRequest = class {
|
|
1937
2017
|
* @param predicateData - Predicate data bytes.
|
1938
2018
|
*/
|
1939
2019
|
addMessageInput(message) {
|
1940
|
-
const { recipient, sender, amount
|
2020
|
+
const { recipient, sender, amount } = message;
|
1941
2021
|
const assetId = BaseAssetId2;
|
1942
2022
|
let witnessIndex;
|
1943
|
-
if (predicate) {
|
2023
|
+
if (message.predicate) {
|
1944
2024
|
witnessIndex = 0;
|
1945
2025
|
} else {
|
1946
2026
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -1949,13 +2029,12 @@ var BaseTransactionRequest = class {
|
|
1949
2029
|
}
|
1950
2030
|
}
|
1951
2031
|
const input = {
|
1952
|
-
|
2032
|
+
...message,
|
1953
2033
|
type: InputType2.Message,
|
1954
2034
|
sender: sender.toB256(),
|
1955
2035
|
recipient: recipient.toB256(),
|
1956
2036
|
amount,
|
1957
|
-
witnessIndex
|
1958
|
-
predicate
|
2037
|
+
witnessIndex
|
1959
2038
|
};
|
1960
2039
|
this.pushInput(input);
|
1961
2040
|
this.addChangeOutput(recipient, assetId);
|
@@ -2065,7 +2144,7 @@ var BaseTransactionRequest = class {
|
|
2065
2144
|
}
|
2066
2145
|
calculateMaxGas(chainInfo, minGas) {
|
2067
2146
|
const { consensusParameters } = chainInfo;
|
2068
|
-
const { gasPerByte } = consensusParameters;
|
2147
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2069
2148
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2070
2149
|
(acc, wit) => acc + wit.dataLength,
|
2071
2150
|
0
|
@@ -2074,7 +2153,8 @@ var BaseTransactionRequest = class {
|
|
2074
2153
|
gasPerByte,
|
2075
2154
|
minGas,
|
2076
2155
|
witnessesLength,
|
2077
|
-
witnessLimit: this.witnessLimit
|
2156
|
+
witnessLimit: this.witnessLimit,
|
2157
|
+
maxGasPerTx
|
2078
2158
|
});
|
2079
2159
|
}
|
2080
2160
|
/**
|
@@ -2084,12 +2164,6 @@ var BaseTransactionRequest = class {
|
|
2084
2164
|
* @param quantities - CoinQuantity Array.
|
2085
2165
|
*/
|
2086
2166
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
2087
|
-
let idCounter = 0;
|
2088
|
-
const generateId = () => {
|
2089
|
-
const counterString = String(idCounter++);
|
2090
|
-
const id = ZeroBytes324.slice(0, -counterString.length).concat(counterString);
|
2091
|
-
return id;
|
2092
|
-
};
|
2093
2167
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
2094
2168
|
if ("assetId" in input) {
|
2095
2169
|
return input.assetId === assetId;
|
@@ -2098,17 +2172,20 @@ var BaseTransactionRequest = class {
|
|
2098
2172
|
});
|
2099
2173
|
const updateAssetInput = (assetId, quantity) => {
|
2100
2174
|
const assetInput = findAssetInput(assetId);
|
2175
|
+
let usedQuantity = quantity;
|
2176
|
+
if (assetId === BaseAssetId2) {
|
2177
|
+
usedQuantity = bn7("1000000000000000000");
|
2178
|
+
}
|
2101
2179
|
if (assetInput && "assetId" in assetInput) {
|
2102
|
-
assetInput.id =
|
2103
|
-
assetInput.amount =
|
2180
|
+
assetInput.id = hexlify7(randomBytes(34));
|
2181
|
+
assetInput.amount = usedQuantity;
|
2104
2182
|
} else {
|
2105
2183
|
this.addResources([
|
2106
2184
|
{
|
2107
|
-
id:
|
2108
|
-
amount:
|
2185
|
+
id: hexlify7(randomBytes(34)),
|
2186
|
+
amount: usedQuantity,
|
2109
2187
|
assetId,
|
2110
2188
|
owner: resourcesOwner || Address.fromRandom(),
|
2111
|
-
maturity: 0,
|
2112
2189
|
blockCreated: bn7(1),
|
2113
2190
|
txCreatedIdx: bn7(1)
|
2114
2191
|
}
|
@@ -2140,7 +2217,7 @@ var BaseTransactionRequest = class {
|
|
2140
2217
|
toJSON() {
|
2141
2218
|
return normalizeJSON(this);
|
2142
2219
|
}
|
2143
|
-
|
2220
|
+
updatePredicateGasUsed(inputs) {
|
2144
2221
|
this.inputs.forEach((i) => {
|
2145
2222
|
let correspondingInput;
|
2146
2223
|
switch (i.type) {
|
@@ -2162,6 +2239,15 @@ var BaseTransactionRequest = class {
|
|
2162
2239
|
}
|
2163
2240
|
});
|
2164
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
|
+
}
|
2165
2251
|
};
|
2166
2252
|
|
2167
2253
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2308,9 +2394,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2308
2394
|
return {
|
2309
2395
|
type: TransactionType3.Create,
|
2310
2396
|
...baseTransaction,
|
2311
|
-
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2312
2397
|
bytecodeWitnessIndex,
|
2313
|
-
storageSlotsCount: storageSlots.length,
|
2398
|
+
storageSlotsCount: bn9(storageSlots.length),
|
2314
2399
|
salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
|
2315
2400
|
storageSlots
|
2316
2401
|
};
|
@@ -2433,8 +2518,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2433
2518
|
type: TransactionType4.Script,
|
2434
2519
|
scriptGasLimit: this.gasLimit,
|
2435
2520
|
...super.getBaseTransaction(),
|
2436
|
-
scriptLength: script.length,
|
2437
|
-
scriptDataLength: scriptData.length,
|
2521
|
+
scriptLength: bn10(script.length),
|
2522
|
+
scriptDataLength: bn10(scriptData.length),
|
2438
2523
|
receiptsRoot: ZeroBytes327,
|
2439
2524
|
script: hexlify10(script),
|
2440
2525
|
scriptData: hexlify10(scriptData)
|
@@ -2498,7 +2583,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2498
2583
|
}
|
2499
2584
|
calculateMaxGas(chainInfo, minGas) {
|
2500
2585
|
const { consensusParameters } = chainInfo;
|
2501
|
-
const { gasPerByte } = consensusParameters;
|
2586
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2502
2587
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2503
2588
|
(acc, wit) => acc + wit.dataLength,
|
2504
2589
|
0
|
@@ -2508,7 +2593,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2508
2593
|
minGas,
|
2509
2594
|
witnessesLength,
|
2510
2595
|
witnessLimit: this.witnessLimit,
|
2511
|
-
gasLimit: this.gasLimit
|
2596
|
+
gasLimit: this.gasLimit,
|
2597
|
+
maxGasPerTx
|
2512
2598
|
});
|
2513
2599
|
}
|
2514
2600
|
/**
|
@@ -2565,7 +2651,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2565
2651
|
|
2566
2652
|
// src/providers/transaction-request/utils.ts
|
2567
2653
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2568
|
-
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2654
|
+
import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
|
2569
2655
|
var transactionRequestify = (obj) => {
|
2570
2656
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2571
2657
|
return obj;
|
@@ -2583,14 +2669,31 @@ var transactionRequestify = (obj) => {
|
|
2583
2669
|
}
|
2584
2670
|
}
|
2585
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
|
+
);
|
2586
2687
|
|
2587
2688
|
// src/providers/transaction-response/transaction-response.ts
|
2588
2689
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2589
|
-
import { bn as
|
2690
|
+
import { bn as bn15 } from "@fuel-ts/math";
|
2590
2691
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2591
2692
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2592
2693
|
|
2593
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";
|
2594
2697
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2595
2698
|
|
2596
2699
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
@@ -2599,9 +2702,10 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
|
|
2599
2702
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2600
2703
|
var calculateTransactionFee = (params) => {
|
2601
2704
|
const {
|
2602
|
-
|
2705
|
+
gasPrice,
|
2603
2706
|
rawPayload,
|
2604
|
-
|
2707
|
+
tip,
|
2708
|
+
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2605
2709
|
} = params;
|
2606
2710
|
const gasPerByte = bn11(feeParams.gasPerByte);
|
2607
2711
|
const gasPriceFactor = bn11(feeParams.gasPriceFactor);
|
@@ -2611,8 +2715,7 @@ var calculateTransactionFee = (params) => {
|
|
2611
2715
|
return {
|
2612
2716
|
fee: bn11(0),
|
2613
2717
|
minFee: bn11(0),
|
2614
|
-
maxFee: bn11(0)
|
2615
|
-
feeFromGasUsed: bn11(0)
|
2718
|
+
maxFee: bn11(0)
|
2616
2719
|
};
|
2617
2720
|
}
|
2618
2721
|
const { type, witnesses, inputs, policies } = transaction;
|
@@ -2644,7 +2747,6 @@ var calculateTransactionFee = (params) => {
|
|
2644
2747
|
metadataGas,
|
2645
2748
|
txBytesSize: transactionBytes.length
|
2646
2749
|
});
|
2647
|
-
const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
|
2648
2750
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
|
2649
2751
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2650
2752
|
const maxGas = getMaxGas({
|
@@ -2652,17 +2754,25 @@ var calculateTransactionFee = (params) => {
|
|
2652
2754
|
minGas,
|
2653
2755
|
witnessesLength,
|
2654
2756
|
gasLimit,
|
2655
|
-
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
|
2656
2771
|
});
|
2657
|
-
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
2658
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
2659
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
2660
|
-
const fee = minFee.add(feeFromGasUsed);
|
2661
2772
|
return {
|
2662
|
-
fee,
|
2663
2773
|
minFee,
|
2664
2774
|
maxFee,
|
2665
|
-
|
2775
|
+
fee: maxFee
|
2666
2776
|
};
|
2667
2777
|
};
|
2668
2778
|
|
@@ -2718,7 +2828,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2718
2828
|
|
2719
2829
|
// src/providers/transaction-summary/input.ts
|
2720
2830
|
import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2721
|
-
import { InputType as
|
2831
|
+
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
2722
2832
|
function getInputsByTypes(inputs, types) {
|
2723
2833
|
return inputs.filter((i) => types.includes(i.type));
|
2724
2834
|
}
|
@@ -2726,16 +2836,16 @@ function getInputsByType(inputs, type) {
|
|
2726
2836
|
return inputs.filter((i) => i.type === type);
|
2727
2837
|
}
|
2728
2838
|
function getInputsCoin(inputs) {
|
2729
|
-
return getInputsByType(inputs,
|
2839
|
+
return getInputsByType(inputs, InputType6.Coin);
|
2730
2840
|
}
|
2731
2841
|
function getInputsMessage(inputs) {
|
2732
|
-
return getInputsByType(inputs,
|
2842
|
+
return getInputsByType(inputs, InputType6.Message);
|
2733
2843
|
}
|
2734
2844
|
function getInputsCoinAndMessage(inputs) {
|
2735
|
-
return getInputsByTypes(inputs, [
|
2845
|
+
return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
|
2736
2846
|
}
|
2737
2847
|
function getInputsContract(inputs) {
|
2738
|
-
return getInputsByType(inputs,
|
2848
|
+
return getInputsByType(inputs, InputType6.Contract);
|
2739
2849
|
}
|
2740
2850
|
function getInputFromAssetId(inputs, assetId) {
|
2741
2851
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2754,7 +2864,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2754
2864
|
if (!contractInput) {
|
2755
2865
|
return void 0;
|
2756
2866
|
}
|
2757
|
-
if (contractInput.type !==
|
2867
|
+
if (contractInput.type !== InputType6.Contract) {
|
2758
2868
|
throw new FuelError9(
|
2759
2869
|
ErrorCode9.INVALID_TRANSACTION_INPUT,
|
2760
2870
|
`Contract input should be of type 'contract'.`
|
@@ -2763,10 +2873,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2763
2873
|
return contractInput;
|
2764
2874
|
}
|
2765
2875
|
function getInputAccountAddress(input) {
|
2766
|
-
if (input.type ===
|
2876
|
+
if (input.type === InputType6.Coin) {
|
2767
2877
|
return input.owner.toString();
|
2768
2878
|
}
|
2769
|
-
if (input.type ===
|
2879
|
+
if (input.type === InputType6.Message) {
|
2770
2880
|
return input.recipient.toString();
|
2771
2881
|
}
|
2772
2882
|
return "";
|
@@ -3276,7 +3386,9 @@ function assembleTransactionSummary(params) {
|
|
3276
3386
|
gqlTransactionStatus,
|
3277
3387
|
abiMap = {},
|
3278
3388
|
maxInputs,
|
3279
|
-
gasCosts
|
3389
|
+
gasCosts,
|
3390
|
+
maxGasPerTx,
|
3391
|
+
gasPrice
|
3280
3392
|
} = params;
|
3281
3393
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3282
3394
|
const rawPayload = hexlify11(transactionBytes);
|
@@ -3290,11 +3402,14 @@ function assembleTransactionSummary(params) {
|
|
3290
3402
|
maxInputs
|
3291
3403
|
});
|
3292
3404
|
const typeName = getTransactionTypeName(transaction.type);
|
3405
|
+
const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3293
3406
|
const { fee } = calculateTransactionFee({
|
3294
|
-
|
3407
|
+
gasPrice,
|
3295
3408
|
rawPayload,
|
3409
|
+
tip,
|
3296
3410
|
consensusParameters: {
|
3297
3411
|
gasCosts,
|
3412
|
+
maxGasPerTx,
|
3298
3413
|
feeParams: {
|
3299
3414
|
gasPerByte,
|
3300
3415
|
gasPriceFactor
|
@@ -3354,7 +3469,7 @@ var TransactionResponse = class {
|
|
3354
3469
|
/** Current provider */
|
3355
3470
|
provider;
|
3356
3471
|
/** Gas used on the transaction */
|
3357
|
-
gasUsed =
|
3472
|
+
gasUsed = bn15(0);
|
3358
3473
|
/** The graphql Transaction with receipts object. */
|
3359
3474
|
gqlTransaction;
|
3360
3475
|
abis;
|
@@ -3432,8 +3547,13 @@ var TransactionResponse = class {
|
|
3432
3547
|
const decodedTransaction = this.decodeTransaction(
|
3433
3548
|
transaction
|
3434
3549
|
);
|
3435
|
-
|
3436
|
-
|
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();
|
3437
3557
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3438
3558
|
const transactionSummary = assembleTransactionSummary({
|
3439
3559
|
id: this.id,
|
@@ -3445,7 +3565,9 @@ var TransactionResponse = class {
|
|
3445
3565
|
gasPriceFactor,
|
3446
3566
|
abiMap: contractsAbiMap,
|
3447
3567
|
maxInputs,
|
3448
|
-
gasCosts
|
3568
|
+
gasCosts,
|
3569
|
+
maxGasPerTx,
|
3570
|
+
gasPrice
|
3449
3571
|
});
|
3450
3572
|
return transactionSummary;
|
3451
3573
|
}
|
@@ -3572,29 +3694,29 @@ var processGqlChain = (chain) => {
|
|
3572
3694
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3573
3695
|
return {
|
3574
3696
|
name,
|
3575
|
-
baseChainHeight:
|
3697
|
+
baseChainHeight: bn16(daHeight),
|
3576
3698
|
consensusParameters: {
|
3577
|
-
contractMaxSize:
|
3578
|
-
maxInputs:
|
3579
|
-
maxOutputs:
|
3580
|
-
maxWitnesses:
|
3581
|
-
maxGasPerTx:
|
3582
|
-
maxScriptLength:
|
3583
|
-
maxScriptDataLength:
|
3584
|
-
maxStorageSlots:
|
3585
|
-
maxPredicateLength:
|
3586
|
-
maxPredicateDataLength:
|
3587
|
-
maxGasPerPredicate:
|
3588
|
-
gasPriceFactor:
|
3589
|
-
gasPerByte:
|
3590
|
-
maxMessageDataLength:
|
3591
|
-
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),
|
3592
3714
|
gasCosts
|
3593
3715
|
},
|
3594
3716
|
gasCosts,
|
3595
3717
|
latestBlock: {
|
3596
3718
|
id: latestBlock.id,
|
3597
|
-
height:
|
3719
|
+
height: bn16(latestBlock.height),
|
3598
3720
|
time: latestBlock.header.time,
|
3599
3721
|
transactions: latestBlock.transactions.map((i) => ({
|
3600
3722
|
id: i.id
|
@@ -3688,10 +3810,8 @@ var _Provider = class {
|
|
3688
3810
|
* Returns some helpful parameters related to gas fees.
|
3689
3811
|
*/
|
3690
3812
|
getGasConfig() {
|
3691
|
-
const { minGasPrice } = this.getNode();
|
3692
3813
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3693
3814
|
return {
|
3694
|
-
minGasPrice,
|
3695
3815
|
maxGasPerTx,
|
3696
3816
|
maxGasPerPredicate,
|
3697
3817
|
gasPriceFactor,
|
@@ -3789,7 +3909,7 @@ var _Provider = class {
|
|
3789
3909
|
*/
|
3790
3910
|
async getBlockNumber() {
|
3791
3911
|
const { chain } = await this.operations.getChain();
|
3792
|
-
return
|
3912
|
+
return bn16(chain.latestBlock.height, 10);
|
3793
3913
|
}
|
3794
3914
|
/**
|
3795
3915
|
* Returns the chain information.
|
@@ -3799,13 +3919,11 @@ var _Provider = class {
|
|
3799
3919
|
async fetchNode() {
|
3800
3920
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3801
3921
|
const processedNodeInfo = {
|
3802
|
-
maxDepth:
|
3803
|
-
maxTx:
|
3804
|
-
minGasPrice: bn15(nodeInfo.minGasPrice),
|
3922
|
+
maxDepth: bn16(nodeInfo.maxDepth),
|
3923
|
+
maxTx: bn16(nodeInfo.maxTx),
|
3805
3924
|
nodeVersion: nodeInfo.nodeVersion,
|
3806
3925
|
utxoValidation: nodeInfo.utxoValidation,
|
3807
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
3808
|
-
peers: nodeInfo.peers
|
3926
|
+
vmBacktrace: nodeInfo.vmBacktrace
|
3809
3927
|
};
|
3810
3928
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
3811
3929
|
return processedNodeInfo;
|
@@ -3891,14 +4009,13 @@ var _Provider = class {
|
|
3891
4009
|
return this.estimateTxDependencies(transactionRequest);
|
3892
4010
|
}
|
3893
4011
|
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
3894
|
-
const { dryRun:
|
3895
|
-
encodedTransaction,
|
4012
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4013
|
+
encodedTransactions: encodedTransaction,
|
3896
4014
|
utxoValidation: utxoValidation || false
|
3897
4015
|
});
|
3898
|
-
const receipts =
|
3899
|
-
|
3900
|
-
|
3901
|
-
};
|
4016
|
+
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
4017
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
4018
|
+
return { receipts, dryrunStatus: status };
|
3902
4019
|
}
|
3903
4020
|
/**
|
3904
4021
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -3924,7 +4041,7 @@ var _Provider = class {
|
|
3924
4041
|
} = response;
|
3925
4042
|
if (inputs) {
|
3926
4043
|
inputs.forEach((input, index) => {
|
3927
|
-
if ("predicateGasUsed" in input &&
|
4044
|
+
if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
|
3928
4045
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3929
4046
|
}
|
3930
4047
|
});
|
@@ -3937,9 +4054,6 @@ var _Provider = class {
|
|
3937
4054
|
* If there are missing variable outputs,
|
3938
4055
|
* `addVariableOutputs` is called on the transaction.
|
3939
4056
|
*
|
3940
|
-
* @privateRemarks
|
3941
|
-
* TODO: Investigate support for missing contract IDs
|
3942
|
-
* TODO: Add support for missing output messages
|
3943
4057
|
*
|
3944
4058
|
* @param transactionRequest - The transaction request object.
|
3945
4059
|
* @returns A promise.
|
@@ -3952,16 +4066,19 @@ var _Provider = class {
|
|
3952
4066
|
missingContractIds: []
|
3953
4067
|
};
|
3954
4068
|
}
|
3955
|
-
await this.estimatePredicates(transactionRequest);
|
3956
4069
|
let receipts = [];
|
3957
4070
|
const missingContractIds = [];
|
3958
4071
|
let outputVariables = 0;
|
4072
|
+
let dryrunStatus;
|
3959
4073
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3960
|
-
const {
|
3961
|
-
|
4074
|
+
const {
|
4075
|
+
dryRun: [{ receipts: rawReceipts, status }]
|
4076
|
+
} = await this.operations.dryRun({
|
4077
|
+
encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
|
3962
4078
|
utxoValidation: false
|
3963
4079
|
});
|
3964
|
-
receipts =
|
4080
|
+
receipts = rawReceipts.map(processGqlReceipt);
|
4081
|
+
dryrunStatus = status;
|
3965
4082
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
3966
4083
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
3967
4084
|
if (hasMissingOutputs) {
|
@@ -3971,6 +4088,11 @@ var _Provider = class {
|
|
3971
4088
|
transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
|
3972
4089
|
missingContractIds.push(contractId);
|
3973
4090
|
});
|
4091
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
4092
|
+
transactionRequest,
|
4093
|
+
optimizeGas: false
|
4094
|
+
});
|
4095
|
+
transactionRequest.maxFee = maxFee;
|
3974
4096
|
} else {
|
3975
4097
|
break;
|
3976
4098
|
}
|
@@ -3978,7 +4100,133 @@ var _Provider = class {
|
|
3978
4100
|
return {
|
3979
4101
|
receipts,
|
3980
4102
|
outputVariables,
|
3981
|
-
missingContractIds
|
4103
|
+
missingContractIds,
|
4104
|
+
dryrunStatus
|
4105
|
+
};
|
4106
|
+
}
|
4107
|
+
/**
|
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.
|
4116
|
+
*/
|
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;
|
4195
|
+
const chainInfo = this.getChain();
|
4196
|
+
const { gasPriceFactor } = this.getGasConfig();
|
4197
|
+
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
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);
|
4208
|
+
if (transactionRequest.type === TransactionType8.Script) {
|
4209
|
+
gasLimit = transactionRequest.gasLimit;
|
4210
|
+
if (!optimizeGas) {
|
4211
|
+
transactionRequest.gasLimit = minGas;
|
4212
|
+
gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4213
|
+
transactionRequest.gasLimit = gasLimit;
|
4214
|
+
}
|
4215
|
+
}
|
4216
|
+
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4217
|
+
const maxFee = calculateGasFee({
|
4218
|
+
gasPrice: bn16(gasPrice),
|
4219
|
+
gas: maxGas,
|
4220
|
+
priceFactor: gasPriceFactor,
|
4221
|
+
tip: transactionRequest.tip
|
4222
|
+
}).add(1);
|
4223
|
+
return {
|
4224
|
+
minGas,
|
4225
|
+
minFee,
|
4226
|
+
maxGas,
|
4227
|
+
maxFee,
|
4228
|
+
gasPrice,
|
4229
|
+
gasLimit
|
3982
4230
|
};
|
3983
4231
|
}
|
3984
4232
|
/**
|
@@ -3996,15 +4244,17 @@ var _Provider = class {
|
|
3996
4244
|
if (estimateTxDependencies) {
|
3997
4245
|
return this.estimateTxDependencies(transactionRequest);
|
3998
4246
|
}
|
3999
|
-
const
|
4000
|
-
const { dryRun:
|
4001
|
-
|
4247
|
+
const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
|
4248
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4249
|
+
encodedTransactions,
|
4002
4250
|
utxoValidation: true
|
4003
4251
|
});
|
4004
|
-
const
|
4005
|
-
|
4006
|
-
receipts
|
4007
|
-
|
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 };
|
4008
4258
|
}
|
4009
4259
|
/**
|
4010
4260
|
* Returns a transaction cost to enable user
|
@@ -4021,80 +4271,80 @@ var _Provider = class {
|
|
4021
4271
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
4022
4272
|
* @returns A promise that resolves to the transaction cost object.
|
4023
4273
|
*/
|
4024
|
-
async getTransactionCost(transactionRequestLike,
|
4025
|
-
estimateTxDependencies = true,
|
4026
|
-
estimatePredicates = true,
|
4027
|
-
resourcesOwner,
|
4028
|
-
signatureCallback
|
4029
|
-
} = {}) {
|
4274
|
+
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
4030
4275
|
const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
|
4031
|
-
const chainInfo = this.getChain();
|
4032
|
-
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
4033
|
-
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
4034
4276
|
const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
|
4035
4277
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4036
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
4278
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4037
4279
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
4038
|
-
|
4039
|
-
|
4040
|
-
|
4041
|
-
}
|
4042
|
-
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4043
|
-
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
4044
|
-
}
|
4045
|
-
await this.estimatePredicates(txRequestClone);
|
4280
|
+
txRequestClone.maxFee = bn16(0);
|
4281
|
+
if (isScriptTransaction) {
|
4282
|
+
txRequestClone.gasLimit = bn16(0);
|
4046
4283
|
}
|
4047
|
-
if (
|
4048
|
-
|
4284
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4285
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
4049
4286
|
}
|
4050
|
-
const
|
4051
|
-
|
4287
|
+
const signedRequest = clone3(txRequestClone);
|
4288
|
+
let addedSignatures = 0;
|
4289
|
+
if (signatureCallback && isScriptTransaction) {
|
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
|
4298
|
+
});
|
4299
|
+
txRequestClone.maxFee = maxFee;
|
4052
4300
|
let receipts = [];
|
4053
4301
|
let missingContractIds = [];
|
4054
4302
|
let outputVariables = 0;
|
4055
|
-
|
4056
|
-
|
4057
|
-
|
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;
|
4058
4310
|
const result = await this.estimateTxDependencies(txRequestClone);
|
4059
4311
|
receipts = result.receipts;
|
4060
4312
|
outputVariables = result.outputVariables;
|
4061
4313
|
missingContractIds = result.missingContractIds;
|
4314
|
+
gasUsed = getGasUsedFromReceipts(receipts);
|
4315
|
+
txRequestClone.gasLimit = gasUsed;
|
4316
|
+
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
4317
|
+
transactionRequest: txRequestClone,
|
4318
|
+
gasPrice
|
4319
|
+
}));
|
4062
4320
|
}
|
4063
|
-
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
4064
|
-
const usedFee = calculatePriceWithFactor(
|
4065
|
-
gasUsed,
|
4066
|
-
gasPrice,
|
4067
|
-
gasPriceFactor
|
4068
|
-
).normalizeZeroToOne();
|
4069
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4070
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4071
4321
|
return {
|
4072
4322
|
requiredQuantities: allQuantities,
|
4073
4323
|
receipts,
|
4074
4324
|
gasUsed,
|
4075
|
-
minGasPrice,
|
4076
4325
|
gasPrice,
|
4077
4326
|
minGas,
|
4078
4327
|
maxGas,
|
4079
|
-
usedFee,
|
4080
4328
|
minFee,
|
4081
4329
|
maxFee,
|
4082
|
-
estimatedInputs: txRequestClone.inputs,
|
4083
4330
|
outputVariables,
|
4084
|
-
missingContractIds
|
4331
|
+
missingContractIds,
|
4332
|
+
addedSignatures,
|
4333
|
+
estimatedPredicates: txRequestClone.inputs
|
4085
4334
|
};
|
4086
4335
|
}
|
4087
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
4336
|
+
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
4088
4337
|
const ownerAddress = Address2.fromAddressOrString(owner);
|
4089
4338
|
const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
|
4090
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
4339
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, {
|
4340
|
+
quantitiesToContract
|
4341
|
+
});
|
4091
4342
|
transactionRequest.addResources(
|
4092
4343
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
4093
4344
|
);
|
4094
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4095
|
-
|
4096
|
-
|
4097
|
-
);
|
4345
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
|
4346
|
+
quantitiesToContract
|
4347
|
+
});
|
4098
4348
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
4099
4349
|
return {
|
4100
4350
|
resources,
|
@@ -4116,11 +4366,10 @@ var _Provider = class {
|
|
4116
4366
|
return coins.map((coin) => ({
|
4117
4367
|
id: coin.utxoId,
|
4118
4368
|
assetId: coin.assetId,
|
4119
|
-
amount:
|
4369
|
+
amount: bn16(coin.amount),
|
4120
4370
|
owner: Address2.fromAddressOrString(coin.owner),
|
4121
|
-
|
4122
|
-
|
4123
|
-
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4371
|
+
blockCreated: bn16(coin.blockCreated),
|
4372
|
+
txCreatedIdx: bn16(coin.txCreatedIdx)
|
4124
4373
|
}));
|
4125
4374
|
}
|
4126
4375
|
/**
|
@@ -4157,9 +4406,9 @@ var _Provider = class {
|
|
4157
4406
|
switch (coin.__typename) {
|
4158
4407
|
case "MessageCoin":
|
4159
4408
|
return {
|
4160
|
-
amount:
|
4409
|
+
amount: bn16(coin.amount),
|
4161
4410
|
assetId: coin.assetId,
|
4162
|
-
daHeight:
|
4411
|
+
daHeight: bn16(coin.daHeight),
|
4163
4412
|
sender: Address2.fromAddressOrString(coin.sender),
|
4164
4413
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4165
4414
|
nonce: coin.nonce
|
@@ -4167,12 +4416,11 @@ var _Provider = class {
|
|
4167
4416
|
case "Coin":
|
4168
4417
|
return {
|
4169
4418
|
id: coin.utxoId,
|
4170
|
-
amount:
|
4419
|
+
amount: bn16(coin.amount),
|
4171
4420
|
assetId: coin.assetId,
|
4172
4421
|
owner: Address2.fromAddressOrString(coin.owner),
|
4173
|
-
|
4174
|
-
|
4175
|
-
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4422
|
+
blockCreated: bn16(coin.blockCreated),
|
4423
|
+
txCreatedIdx: bn16(coin.txCreatedIdx)
|
4176
4424
|
};
|
4177
4425
|
default:
|
4178
4426
|
return null;
|
@@ -4189,13 +4437,13 @@ var _Provider = class {
|
|
4189
4437
|
async getBlock(idOrHeight) {
|
4190
4438
|
let variables;
|
4191
4439
|
if (typeof idOrHeight === "number") {
|
4192
|
-
variables = { height:
|
4440
|
+
variables = { height: bn16(idOrHeight).toString(10) };
|
4193
4441
|
} else if (idOrHeight === "latest") {
|
4194
4442
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4195
4443
|
} else if (idOrHeight.length === 66) {
|
4196
4444
|
variables = { blockId: idOrHeight };
|
4197
4445
|
} else {
|
4198
|
-
variables = { blockId:
|
4446
|
+
variables = { blockId: bn16(idOrHeight).toString(10) };
|
4199
4447
|
}
|
4200
4448
|
const { block } = await this.operations.getBlock(variables);
|
4201
4449
|
if (!block) {
|
@@ -4203,7 +4451,7 @@ var _Provider = class {
|
|
4203
4451
|
}
|
4204
4452
|
return {
|
4205
4453
|
id: block.id,
|
4206
|
-
height:
|
4454
|
+
height: bn16(block.height),
|
4207
4455
|
time: block.header.time,
|
4208
4456
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4209
4457
|
};
|
@@ -4218,7 +4466,7 @@ var _Provider = class {
|
|
4218
4466
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4219
4467
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4220
4468
|
id: block.id,
|
4221
|
-
height:
|
4469
|
+
height: bn16(block.height),
|
4222
4470
|
time: block.header.time,
|
4223
4471
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4224
4472
|
}));
|
@@ -4233,7 +4481,7 @@ var _Provider = class {
|
|
4233
4481
|
async getBlockWithTransactions(idOrHeight) {
|
4234
4482
|
let variables;
|
4235
4483
|
if (typeof idOrHeight === "number") {
|
4236
|
-
variables = { blockHeight:
|
4484
|
+
variables = { blockHeight: bn16(idOrHeight).toString(10) };
|
4237
4485
|
} else if (idOrHeight === "latest") {
|
4238
4486
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4239
4487
|
} else {
|
@@ -4245,7 +4493,7 @@ var _Provider = class {
|
|
4245
4493
|
}
|
4246
4494
|
return {
|
4247
4495
|
id: block.id,
|
4248
|
-
height:
|
4496
|
+
height: bn16(block.height, 10),
|
4249
4497
|
time: block.header.time,
|
4250
4498
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4251
4499
|
transactions: block.transactions.map(
|
@@ -4294,7 +4542,7 @@ var _Provider = class {
|
|
4294
4542
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4295
4543
|
asset: hexlify12(assetId)
|
4296
4544
|
});
|
4297
|
-
return
|
4545
|
+
return bn16(contractBalance.amount, 10);
|
4298
4546
|
}
|
4299
4547
|
/**
|
4300
4548
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4308,7 +4556,7 @@ var _Provider = class {
|
|
4308
4556
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4309
4557
|
assetId: hexlify12(assetId)
|
4310
4558
|
});
|
4311
|
-
return
|
4559
|
+
return bn16(balance.amount, 10);
|
4312
4560
|
}
|
4313
4561
|
/**
|
4314
4562
|
* Returns balances for the given owner.
|
@@ -4326,7 +4574,7 @@ var _Provider = class {
|
|
4326
4574
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4327
4575
|
return balances.map((balance) => ({
|
4328
4576
|
assetId: balance.assetId,
|
4329
|
-
amount:
|
4577
|
+
amount: bn16(balance.amount)
|
4330
4578
|
}));
|
4331
4579
|
}
|
4332
4580
|
/**
|
@@ -4348,15 +4596,15 @@ var _Provider = class {
|
|
4348
4596
|
sender: message.sender,
|
4349
4597
|
recipient: message.recipient,
|
4350
4598
|
nonce: message.nonce,
|
4351
|
-
amount:
|
4599
|
+
amount: bn16(message.amount),
|
4352
4600
|
data: message.data
|
4353
4601
|
}),
|
4354
4602
|
sender: Address2.fromAddressOrString(message.sender),
|
4355
4603
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4356
4604
|
nonce: message.nonce,
|
4357
|
-
amount:
|
4605
|
+
amount: bn16(message.amount),
|
4358
4606
|
data: InputMessageCoder.decodeData(message.data),
|
4359
|
-
daHeight:
|
4607
|
+
daHeight: bn16(message.daHeight)
|
4360
4608
|
}));
|
4361
4609
|
}
|
4362
4610
|
/**
|
@@ -4409,44 +4657,52 @@ var _Provider = class {
|
|
4409
4657
|
} = result.messageProof;
|
4410
4658
|
return {
|
4411
4659
|
messageProof: {
|
4412
|
-
proofIndex:
|
4660
|
+
proofIndex: bn16(messageProof.proofIndex),
|
4413
4661
|
proofSet: messageProof.proofSet
|
4414
4662
|
},
|
4415
4663
|
blockProof: {
|
4416
|
-
proofIndex:
|
4664
|
+
proofIndex: bn16(blockProof.proofIndex),
|
4417
4665
|
proofSet: blockProof.proofSet
|
4418
4666
|
},
|
4419
4667
|
messageBlockHeader: {
|
4420
4668
|
id: messageBlockHeader.id,
|
4421
|
-
daHeight:
|
4422
|
-
transactionsCount:
|
4669
|
+
daHeight: bn16(messageBlockHeader.daHeight),
|
4670
|
+
transactionsCount: bn16(messageBlockHeader.transactionsCount),
|
4423
4671
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4424
|
-
height:
|
4672
|
+
height: bn16(messageBlockHeader.height),
|
4425
4673
|
prevRoot: messageBlockHeader.prevRoot,
|
4426
4674
|
time: messageBlockHeader.time,
|
4427
4675
|
applicationHash: messageBlockHeader.applicationHash,
|
4428
|
-
|
4429
|
-
messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
|
4676
|
+
messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount)
|
4430
4677
|
},
|
4431
4678
|
commitBlockHeader: {
|
4432
4679
|
id: commitBlockHeader.id,
|
4433
|
-
daHeight:
|
4434
|
-
transactionsCount:
|
4680
|
+
daHeight: bn16(commitBlockHeader.daHeight),
|
4681
|
+
transactionsCount: bn16(commitBlockHeader.transactionsCount),
|
4435
4682
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4436
|
-
height:
|
4683
|
+
height: bn16(commitBlockHeader.height),
|
4437
4684
|
prevRoot: commitBlockHeader.prevRoot,
|
4438
4685
|
time: commitBlockHeader.time,
|
4439
4686
|
applicationHash: commitBlockHeader.applicationHash,
|
4440
|
-
|
4441
|
-
messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
|
4687
|
+
messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount)
|
4442
4688
|
},
|
4443
4689
|
sender: Address2.fromAddressOrString(sender),
|
4444
4690
|
recipient: Address2.fromAddressOrString(recipient),
|
4445
4691
|
nonce,
|
4446
|
-
amount:
|
4692
|
+
amount: bn16(amount),
|
4447
4693
|
data
|
4448
4694
|
};
|
4449
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
|
+
}
|
4450
4706
|
/**
|
4451
4707
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
4452
4708
|
*
|
@@ -4466,10 +4722,10 @@ var _Provider = class {
|
|
4466
4722
|
*/
|
4467
4723
|
async produceBlocks(amount, startTime) {
|
4468
4724
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4469
|
-
blocksToProduce:
|
4725
|
+
blocksToProduce: bn16(amount).toString(10),
|
4470
4726
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4471
4727
|
});
|
4472
|
-
return
|
4728
|
+
return bn16(latestBlockHeight);
|
4473
4729
|
}
|
4474
4730
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4475
4731
|
async getTransactionResponse(transactionId) {
|
@@ -4483,7 +4739,7 @@ cacheInputs_fn = function(inputs) {
|
|
4483
4739
|
return;
|
4484
4740
|
}
|
4485
4741
|
inputs.forEach((input) => {
|
4486
|
-
if (input.type ===
|
4742
|
+
if (input.type === InputType7.Coin) {
|
4487
4743
|
this.cache?.set(input.id);
|
4488
4744
|
}
|
4489
4745
|
});
|
@@ -4493,7 +4749,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4493
4749
|
|
4494
4750
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4495
4751
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4496
|
-
import { bn as
|
4752
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
4497
4753
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4498
4754
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4499
4755
|
async function getTransactionSummary(params) {
|
@@ -4511,21 +4767,28 @@ async function getTransactionSummary(params) {
|
|
4511
4767
|
arrayify12(gqlTransaction.rawPayload),
|
4512
4768
|
0
|
4513
4769
|
);
|
4514
|
-
|
4770
|
+
let txReceipts = [];
|
4771
|
+
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
4772
|
+
txReceipts = gqlTransaction.status.receipts;
|
4773
|
+
}
|
4774
|
+
const receipts = txReceipts.map(processGqlReceipt);
|
4515
4775
|
const {
|
4516
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
4776
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
4517
4777
|
} = provider.getChain();
|
4778
|
+
const gasPrice = await provider.getLatestGasPrice();
|
4518
4779
|
const transactionInfo = assembleTransactionSummary({
|
4519
4780
|
id: gqlTransaction.id,
|
4520
4781
|
receipts,
|
4521
4782
|
transaction: decodedTransaction,
|
4522
4783
|
transactionBytes: arrayify12(gqlTransaction.rawPayload),
|
4523
4784
|
gqlTransactionStatus: gqlTransaction.status,
|
4524
|
-
gasPerByte:
|
4525
|
-
gasPriceFactor:
|
4785
|
+
gasPerByte: bn17(gasPerByte),
|
4786
|
+
gasPriceFactor: bn17(gasPriceFactor),
|
4526
4787
|
abiMap,
|
4527
4788
|
maxInputs,
|
4528
|
-
gasCosts
|
4789
|
+
gasCosts,
|
4790
|
+
maxGasPerTx,
|
4791
|
+
gasPrice
|
4529
4792
|
});
|
4530
4793
|
return {
|
4531
4794
|
gqlTransaction,
|
@@ -4535,10 +4798,11 @@ async function getTransactionSummary(params) {
|
|
4535
4798
|
async function getTransactionSummaryFromRequest(params) {
|
4536
4799
|
const { provider, transactionRequest, abiMap } = params;
|
4537
4800
|
const { receipts } = await provider.call(transactionRequest);
|
4538
|
-
const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
|
4801
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
|
4539
4802
|
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
4540
4803
|
const transaction = transactionRequest.toTransaction();
|
4541
4804
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
4805
|
+
const gasPrice = await provider.getLatestGasPrice();
|
4542
4806
|
const transactionSummary = assembleTransactionSummary({
|
4543
4807
|
receipts,
|
4544
4808
|
transaction,
|
@@ -4547,7 +4811,9 @@ async function getTransactionSummaryFromRequest(params) {
|
|
4547
4811
|
gasPerByte,
|
4548
4812
|
gasPriceFactor,
|
4549
4813
|
maxInputs,
|
4550
|
-
gasCosts
|
4814
|
+
gasCosts,
|
4815
|
+
maxGasPerTx,
|
4816
|
+
gasPrice
|
4551
4817
|
});
|
4552
4818
|
return transactionSummary;
|
4553
4819
|
}
|
@@ -4556,13 +4822,18 @@ async function getTransactionsSummaries(params) {
|
|
4556
4822
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
4557
4823
|
const { edges, pageInfo } = transactionsByOwner;
|
4558
4824
|
const {
|
4559
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
4825
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
4560
4826
|
} = provider.getChain();
|
4827
|
+
const gasPrice = await provider.getLatestGasPrice();
|
4561
4828
|
const transactions = edges.map((edge) => {
|
4562
4829
|
const { node: gqlTransaction } = edge;
|
4563
|
-
const { id, rawPayload,
|
4830
|
+
const { id, rawPayload, status } = gqlTransaction;
|
4564
4831
|
const [decodedTransaction] = new TransactionCoder6().decode(arrayify12(rawPayload), 0);
|
4565
|
-
|
4832
|
+
let txReceipts = [];
|
4833
|
+
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
4834
|
+
txReceipts = gqlTransaction.status.receipts;
|
4835
|
+
}
|
4836
|
+
const receipts = txReceipts.map(processGqlReceipt);
|
4566
4837
|
const transactionSummary = assembleTransactionSummary({
|
4567
4838
|
id,
|
4568
4839
|
receipts,
|
@@ -4573,7 +4844,9 @@ async function getTransactionsSummaries(params) {
|
|
4573
4844
|
gasPerByte,
|
4574
4845
|
gasPriceFactor,
|
4575
4846
|
maxInputs,
|
4576
|
-
gasCosts
|
4847
|
+
gasCosts,
|
4848
|
+
maxGasPerTx,
|
4849
|
+
gasPrice
|
4577
4850
|
});
|
4578
4851
|
const output = {
|
4579
4852
|
gqlTransaction,
|
@@ -4905,36 +5178,33 @@ var Account = class extends AbstractAccount {
|
|
4905
5178
|
* @param fee - The estimated transaction fee.
|
4906
5179
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4907
5180
|
*/
|
4908
|
-
async fund(request,
|
4909
|
-
const
|
4910
|
-
|
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),
|
4911
5186
|
assetId: BaseAssetId3,
|
4912
|
-
coinQuantities
|
5187
|
+
coinQuantities: requiredQuantities
|
4913
5188
|
});
|
4914
5189
|
const quantitiesDict = {};
|
4915
|
-
|
5190
|
+
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
4916
5191
|
quantitiesDict[assetId] = {
|
4917
5192
|
required: amount,
|
4918
|
-
owned:
|
5193
|
+
owned: bn18(0)
|
4919
5194
|
};
|
4920
5195
|
});
|
4921
|
-
|
4922
|
-
const cachedMessages = [];
|
4923
|
-
const owner = this.address.toB256();
|
4924
|
-
request.inputs.forEach((input) => {
|
5196
|
+
txRequest.inputs.forEach((input) => {
|
4925
5197
|
const isResource = "amount" in input;
|
4926
5198
|
if (isResource) {
|
4927
5199
|
const isCoin2 = "owner" in input;
|
4928
5200
|
if (isCoin2) {
|
4929
5201
|
const assetId = String(input.assetId);
|
4930
|
-
if (
|
4931
|
-
const amount =
|
5202
|
+
if (quantitiesDict[assetId]) {
|
5203
|
+
const amount = bn18(input.amount);
|
4932
5204
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4933
|
-
cachedUtxos.push(input.id);
|
4934
5205
|
}
|
4935
|
-
} else if (input.
|
5206
|
+
} else if (input.amount && quantitiesDict[BaseAssetId3]) {
|
4936
5207
|
quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
|
4937
|
-
cachedMessages.push(input.nonce);
|
4938
5208
|
}
|
4939
5209
|
}
|
4940
5210
|
});
|
@@ -4949,12 +5219,23 @@ var Account = class extends AbstractAccount {
|
|
4949
5219
|
});
|
4950
5220
|
const needsToBeFunded = missingQuantities.length;
|
4951
5221
|
if (needsToBeFunded) {
|
4952
|
-
const
|
4953
|
-
|
4954
|
-
|
4955
|
-
|
4956
|
-
|
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
|
+
);
|
4957
5233
|
}
|
5234
|
+
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
5235
|
+
transactionRequest: requestToBeReEstimate
|
5236
|
+
});
|
5237
|
+
txRequest.maxFee = maxFee;
|
5238
|
+
return txRequest;
|
4958
5239
|
}
|
4959
5240
|
/**
|
4960
5241
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -4962,28 +5243,25 @@ var Account = class extends AbstractAccount {
|
|
4962
5243
|
* @param destination - The address of the destination.
|
4963
5244
|
* @param amount - The amount of coins to transfer.
|
4964
5245
|
* @param assetId - The asset ID of the coins to transfer.
|
4965
|
-
* @param txParams - The transaction parameters (gasLimit,
|
5246
|
+
* @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
|
4966
5247
|
* @returns A promise that resolves to the prepared transaction request.
|
4967
5248
|
*/
|
4968
5249
|
async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
4969
|
-
const
|
4970
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
4971
|
-
const request = new ScriptTransactionRequest(params);
|
5250
|
+
const request = new ScriptTransactionRequest(txParams);
|
4972
5251
|
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
|
4973
|
-
const
|
5252
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
4974
5253
|
estimateTxDependencies: true,
|
4975
5254
|
resourcesOwner: this
|
4976
5255
|
});
|
4977
|
-
|
4978
|
-
|
4979
|
-
|
4980
|
-
|
4981
|
-
|
4982
|
-
|
4983
|
-
|
4984
|
-
|
4985
|
-
await this.fund(request,
|
4986
|
-
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);
|
4987
5265
|
return request;
|
4988
5266
|
}
|
4989
5267
|
/**
|
@@ -4996,7 +5274,7 @@ var Account = class extends AbstractAccount {
|
|
4996
5274
|
* @returns A promise that resolves to the transaction response.
|
4997
5275
|
*/
|
4998
5276
|
async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
4999
|
-
if (
|
5277
|
+
if (bn18(amount).lte(0)) {
|
5000
5278
|
throw new FuelError15(
|
5001
5279
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5002
5280
|
"Transfer amount must be a positive number."
|
@@ -5015,38 +5293,37 @@ var Account = class extends AbstractAccount {
|
|
5015
5293
|
* @returns A promise that resolves to the transaction response.
|
5016
5294
|
*/
|
5017
5295
|
async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
|
5018
|
-
if (
|
5296
|
+
if (bn18(amount).lte(0)) {
|
5019
5297
|
throw new FuelError15(
|
5020
5298
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5021
5299
|
"Transfer amount must be a positive number."
|
5022
5300
|
);
|
5023
5301
|
}
|
5024
5302
|
const contractAddress = Address3.fromAddressOrString(contractId);
|
5025
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
5026
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
5027
5303
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5028
5304
|
hexlifiedContractId: contractAddress.toB256(),
|
5029
|
-
amountToTransfer:
|
5305
|
+
amountToTransfer: bn18(amount),
|
5030
5306
|
assetId
|
5031
5307
|
});
|
5032
5308
|
const request = new ScriptTransactionRequest({
|
5033
|
-
...
|
5309
|
+
...txParams,
|
5034
5310
|
script,
|
5035
5311
|
scriptData
|
5036
5312
|
});
|
5037
5313
|
request.addContractInputAndOutput(contractAddress);
|
5038
|
-
const
|
5039
|
-
|
5040
|
-
[{ amount:
|
5041
|
-
);
|
5042
|
-
request.gasLimit = bn17(params.gasLimit ?? gasUsed);
|
5043
|
-
this.validateGas({
|
5044
|
-
gasUsed,
|
5045
|
-
gasPrice: request.gasPrice,
|
5046
|
-
gasLimit: request.gasLimit,
|
5047
|
-
minGasPrice
|
5314
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
5315
|
+
resourcesOwner: this,
|
5316
|
+
quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
|
5048
5317
|
});
|
5049
|
-
|
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);
|
5050
5327
|
return this.sendTransaction(request);
|
5051
5328
|
}
|
5052
5329
|
/**
|
@@ -5058,34 +5335,31 @@ var Account = class extends AbstractAccount {
|
|
5058
5335
|
* @returns A promise that resolves to the transaction response.
|
5059
5336
|
*/
|
5060
5337
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5061
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
5062
5338
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
5063
5339
|
const recipientDataArray = arrayify14(
|
5064
5340
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5065
5341
|
);
|
5066
5342
|
const amountDataArray = arrayify14(
|
5067
|
-
"0x".concat(
|
5343
|
+
"0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
|
5068
5344
|
);
|
5069
5345
|
const script = new Uint8Array([
|
5070
5346
|
...arrayify14(withdrawScript.bytes),
|
5071
5347
|
...recipientDataArray,
|
5072
5348
|
...amountDataArray
|
5073
5349
|
]);
|
5074
|
-
const params = { script,
|
5350
|
+
const params = { script, ...txParams };
|
5075
5351
|
const request = new ScriptTransactionRequest(params);
|
5076
|
-
const
|
5077
|
-
const
|
5078
|
-
|
5079
|
-
|
5080
|
-
|
5081
|
-
|
5082
|
-
|
5083
|
-
|
5084
|
-
|
5085
|
-
|
5086
|
-
|
5087
|
-
});
|
5088
|
-
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);
|
5089
5363
|
return this.sendTransaction(request);
|
5090
5364
|
}
|
5091
5365
|
async signMessage(message) {
|
@@ -5143,18 +5417,7 @@ var Account = class extends AbstractAccount {
|
|
5143
5417
|
}
|
5144
5418
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5145
5419
|
}
|
5146
|
-
validateGas({
|
5147
|
-
gasUsed,
|
5148
|
-
gasPrice,
|
5149
|
-
gasLimit,
|
5150
|
-
minGasPrice
|
5151
|
-
}) {
|
5152
|
-
if (minGasPrice.gt(gasPrice)) {
|
5153
|
-
throw new FuelError15(
|
5154
|
-
ErrorCode15.GAS_PRICE_TOO_LOW,
|
5155
|
-
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
5156
|
-
);
|
5157
|
-
}
|
5420
|
+
validateGas({ gasUsed, gasLimit }) {
|
5158
5421
|
if (gasUsed.gt(gasLimit)) {
|
5159
5422
|
throw new FuelError15(
|
5160
5423
|
ErrorCode15.GAS_LIMIT_TOO_LOW,
|
@@ -5170,7 +5433,7 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
|
|
5170
5433
|
|
5171
5434
|
// src/signer/signer.ts
|
5172
5435
|
import { Address as Address4 } from "@fuel-ts/address";
|
5173
|
-
import { randomBytes } from "@fuel-ts/crypto";
|
5436
|
+
import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
|
5174
5437
|
import { hash } from "@fuel-ts/hasher";
|
5175
5438
|
import { toBytes } from "@fuel-ts/math";
|
5176
5439
|
import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
|
@@ -5263,7 +5526,7 @@ var Signer = class {
|
|
5263
5526
|
* @returns random 32-byte hashed
|
5264
5527
|
*/
|
5265
5528
|
static generatePrivateKey(entropy) {
|
5266
|
-
return entropy ? hash(concat3([
|
5529
|
+
return entropy ? hash(concat3([randomBytes2(32), arrayify15(entropy)])) : randomBytes2(32);
|
5267
5530
|
}
|
5268
5531
|
/**
|
5269
5532
|
* Extended publicKey from a compact publicKey
|
@@ -5282,7 +5545,7 @@ import { Address as Address5 } from "@fuel-ts/address";
|
|
5282
5545
|
import {
|
5283
5546
|
bufferFromString,
|
5284
5547
|
keccak256,
|
5285
|
-
randomBytes as
|
5548
|
+
randomBytes as randomBytes3,
|
5286
5549
|
scrypt,
|
5287
5550
|
stringFromBuffer,
|
5288
5551
|
decryptJsonWalletData,
|
@@ -5305,7 +5568,7 @@ var removeHexPrefix = (hexString) => {
|
|
5305
5568
|
async function encryptKeystoreWallet(privateKey, address, password) {
|
5306
5569
|
const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
|
5307
5570
|
const ownerAddress = Address5.fromAddressOrString(address);
|
5308
|
-
const salt =
|
5571
|
+
const salt = randomBytes3(DEFAULT_KEY_SIZE);
|
5309
5572
|
const key = scrypt({
|
5310
5573
|
password: bufferFromString(password),
|
5311
5574
|
salt,
|
@@ -5314,7 +5577,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
|
|
5314
5577
|
r: DEFAULT_KDF_PARAMS_R,
|
5315
5578
|
p: DEFAULT_KDF_PARAMS_P
|
5316
5579
|
});
|
5317
|
-
const iv =
|
5580
|
+
const iv = randomBytes3(DEFAULT_IV_SIZE);
|
5318
5581
|
const ciphertext = await encryptJsonWalletData(privateKeyBuffer, key, iv);
|
5319
5582
|
const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
|
5320
5583
|
const macHashUint8Array = keccak256(data);
|
@@ -5450,7 +5713,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5450
5713
|
* @param transactionRequestLike - The transaction request to send.
|
5451
5714
|
* @returns A promise that resolves to the TransactionResponse object.
|
5452
5715
|
*/
|
5453
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
5716
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
|
5454
5717
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5455
5718
|
if (estimateTxDependencies) {
|
5456
5719
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -5491,12 +5754,12 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5491
5754
|
// src/hdwallet/hdwallet.ts
|
5492
5755
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5493
5756
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5494
|
-
import { bn as
|
5757
|
+
import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5495
5758
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5496
5759
|
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5497
5760
|
|
5498
5761
|
// src/mnemonic/mnemonic.ts
|
5499
|
-
import { randomBytes as
|
5762
|
+
import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
|
5500
5763
|
import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
|
5501
5764
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
5502
5765
|
import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
|
@@ -7857,7 +8120,7 @@ var Mnemonic = class {
|
|
7857
8120
|
* @returns A randomly generated mnemonic
|
7858
8121
|
*/
|
7859
8122
|
static generate(size = 32, extraEntropy = "") {
|
7860
|
-
const entropy = extraEntropy ? sha2563(concat4([
|
8123
|
+
const entropy = extraEntropy ? sha2563(concat4([randomBytes4(size), arrayify17(extraEntropy)])) : randomBytes4(size);
|
7861
8124
|
return Mnemonic.entropyToMnemonic(entropy);
|
7862
8125
|
}
|
7863
8126
|
};
|
@@ -7963,7 +8226,7 @@ var HDWallet = class {
|
|
7963
8226
|
const IR = bytes.slice(32);
|
7964
8227
|
if (privateKey) {
|
7965
8228
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7966
|
-
const ki =
|
8229
|
+
const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
|
7967
8230
|
return new HDWallet({
|
7968
8231
|
privateKey: ki,
|
7969
8232
|
chainCode: IR,
|
@@ -8652,7 +8915,7 @@ import {
|
|
8652
8915
|
import { Address as Address9 } from "@fuel-ts/address";
|
8653
8916
|
import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
|
8654
8917
|
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
8655
|
-
import { ByteArrayCoder, InputType as
|
8918
|
+
import { ByteArrayCoder, InputType as InputType8 } from "@fuel-ts/transactions";
|
8656
8919
|
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
8657
8920
|
|
8658
8921
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -8712,10 +8975,9 @@ var Predicate = class extends Account {
|
|
8712
8975
|
const request = transactionRequestify(transactionRequestLike);
|
8713
8976
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
8714
8977
|
request.inputs?.forEach((input) => {
|
8715
|
-
if (input.type ===
|
8716
|
-
input.predicate = this.bytes;
|
8717
|
-
input.predicateData = this.getPredicateData(policies.length);
|
8718
|
-
input.witnessIndex = 0;
|
8978
|
+
if (input.type === InputType8.Coin && hexlify19(input.owner) === this.address.toB256()) {
|
8979
|
+
input.predicate = hexlify19(this.bytes);
|
8980
|
+
input.predicateData = hexlify19(this.getPredicateData(policies.length));
|
8719
8981
|
}
|
8720
8982
|
});
|
8721
8983
|
return request;
|
@@ -8730,8 +8992,7 @@ var Predicate = class extends Account {
|
|
8730
8992
|
* @returns A promise that resolves to the prepared transaction request.
|
8731
8993
|
*/
|
8732
8994
|
async createTransfer(destination, amount, assetId = BaseAssetId4, txParams = {}) {
|
8733
|
-
|
8734
|
-
return this.populateTransactionPredicateData(request);
|
8995
|
+
return super.createTransfer(destination, amount, assetId, txParams);
|
8735
8996
|
}
|
8736
8997
|
/**
|
8737
8998
|
* Sends a transaction with the populated predicate data.
|
@@ -8739,9 +9000,9 @@ var Predicate = class extends Account {
|
|
8739
9000
|
* @param transactionRequestLike - The transaction request-like object.
|
8740
9001
|
* @returns A promise that resolves to the transaction response.
|
8741
9002
|
*/
|
8742
|
-
sendTransaction(transactionRequestLike
|
8743
|
-
const transactionRequest =
|
8744
|
-
return super.sendTransaction(transactionRequest,
|
9003
|
+
sendTransaction(transactionRequestLike) {
|
9004
|
+
const transactionRequest = transactionRequestify(transactionRequestLike);
|
9005
|
+
return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
|
8745
9006
|
}
|
8746
9007
|
/**
|
8747
9008
|
* Simulates a transaction with the populated predicate data.
|
@@ -8750,22 +9011,8 @@ var Predicate = class extends Account {
|
|
8750
9011
|
* @returns A promise that resolves to the call result.
|
8751
9012
|
*/
|
8752
9013
|
simulateTransaction(transactionRequestLike) {
|
8753
|
-
const transactionRequest =
|
8754
|
-
return super.simulateTransaction(transactionRequest);
|
8755
|
-
}
|
8756
|
-
/**
|
8757
|
-
* Retrieves resources satisfying the spend query for the account.
|
8758
|
-
*
|
8759
|
-
* @param quantities - IDs of coins to exclude.
|
8760
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
8761
|
-
* @returns A promise that resolves to an array of Resources.
|
8762
|
-
*/
|
8763
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
8764
|
-
const resources = await super.getResourcesToSpend(quantities, excludedIds);
|
8765
|
-
return resources.map((resource) => ({
|
8766
|
-
...resource,
|
8767
|
-
predicate: hexlify19(this.bytes)
|
8768
|
-
}));
|
9014
|
+
const transactionRequest = transactionRequestify(transactionRequestLike);
|
9015
|
+
return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
|
8769
9016
|
}
|
8770
9017
|
getPredicateData(policiesLength) {
|
8771
9018
|
if (!this.predicateData.length) {
|
@@ -8811,6 +9058,25 @@ var Predicate = class extends Account {
|
|
8811
9058
|
predicateInterface: abiInterface
|
8812
9059
|
};
|
8813
9060
|
}
|
9061
|
+
/**
|
9062
|
+
* Retrieves resources satisfying the spend query for the account.
|
9063
|
+
*
|
9064
|
+
* @param quantities - IDs of coins to exclude.
|
9065
|
+
* @param excludedIds - IDs of resources to be excluded from the query.
|
9066
|
+
* @returns A promise that resolves to an array of Resources.
|
9067
|
+
*/
|
9068
|
+
async getResourcesToSpend(quantities, excludedIds) {
|
9069
|
+
const resources = await this.provider.getResourcesToSpend(
|
9070
|
+
this.address,
|
9071
|
+
quantities,
|
9072
|
+
excludedIds
|
9073
|
+
);
|
9074
|
+
return resources.map((resource) => ({
|
9075
|
+
...resource,
|
9076
|
+
predicate: hexlify19(this.bytes),
|
9077
|
+
paddPredicateData: (policiesLength) => hexlify19(this.getPredicateData(policiesLength))
|
9078
|
+
}));
|
9079
|
+
}
|
8814
9080
|
/**
|
8815
9081
|
* Sets the configurable constants for the predicate.
|
8816
9082
|
*
|
@@ -9559,7 +9825,7 @@ export {
|
|
9559
9825
|
WalletLocked,
|
9560
9826
|
WalletManager,
|
9561
9827
|
WalletUnlocked,
|
9562
|
-
|
9828
|
+
addAmountToCoinQuantities,
|
9563
9829
|
addOperation,
|
9564
9830
|
assemblePanicError,
|
9565
9831
|
assembleReceiptByType,
|
@@ -9568,9 +9834,10 @@ export {
|
|
9568
9834
|
assets,
|
9569
9835
|
buildBlockExplorerUrl,
|
9570
9836
|
cacheFor,
|
9837
|
+
cacheTxInputsFromOwner,
|
9838
|
+
calculateGasFee,
|
9571
9839
|
calculateMetadataGasForTxCreate,
|
9572
9840
|
calculateMetadataGasForTxScript,
|
9573
|
-
calculatePriceWithFactor,
|
9574
9841
|
calculateTransactionFee,
|
9575
9842
|
coinQuantityfy,
|
9576
9843
|
deferPromise,
|