@fuel-ts/account 0.0.0-rc-2034-20240411123358 → 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 +819 -568
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +805 -572
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +639 -407
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +10 -2
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +888 -322
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +4 -2
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/message.d.ts +3 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +37 -30
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +2 -2
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +8 -25
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +3 -0
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +8 -2
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +1535 -1067
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +780 -565
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +631 -416
- 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)) {
|
@@ -1023,7 +1083,6 @@ var MemoryCache = class {
|
|
1023
1083
|
};
|
1024
1084
|
|
1025
1085
|
// src/providers/transaction-request/input.ts
|
1026
|
-
import { BYTES_32, UTXO_ID_LEN } from "@fuel-ts/abi-coder";
|
1027
1086
|
import { ZeroBytes32 } from "@fuel-ts/address/configs";
|
1028
1087
|
import { ErrorCode as ErrorCode3, FuelError as FuelError3 } from "@fuel-ts/errors";
|
1029
1088
|
import { bn as bn2, toNumber } from "@fuel-ts/math";
|
@@ -1037,8 +1096,8 @@ var inputify = (value) => {
|
|
1037
1096
|
const predicateData = arrayify(value.predicateData ?? "0x");
|
1038
1097
|
return {
|
1039
1098
|
type: InputType.Coin,
|
1040
|
-
txID: hexlify3(arrayify(value.id).slice(0,
|
1041
|
-
outputIndex: toNumber(arrayify(value.id).slice(
|
1099
|
+
txID: hexlify3(arrayify(value.id).slice(0, 32)),
|
1100
|
+
outputIndex: toNumber(arrayify(value.id).slice(32, 34)),
|
1042
1101
|
owner: hexlify3(value.owner),
|
1043
1102
|
amount: bn2(value.amount),
|
1044
1103
|
assetId: hexlify3(value.assetId),
|
@@ -1047,10 +1106,9 @@ var inputify = (value) => {
|
|
1047
1106
|
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
1048
1107
|
},
|
1049
1108
|
witnessIndex: value.witnessIndex,
|
1050
|
-
maturity: value.maturity ?? 0,
|
1051
1109
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1052
|
-
predicateLength: predicate.length,
|
1053
|
-
predicateDataLength: predicateData.length,
|
1110
|
+
predicateLength: bn2(predicate.length),
|
1111
|
+
predicateDataLength: bn2(predicateData.length),
|
1054
1112
|
predicate: hexlify3(predicate),
|
1055
1113
|
predicateData: hexlify3(predicateData)
|
1056
1114
|
};
|
@@ -1081,8 +1139,8 @@ var inputify = (value) => {
|
|
1081
1139
|
nonce: hexlify3(value.nonce),
|
1082
1140
|
witnessIndex: value.witnessIndex,
|
1083
1141
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1084
|
-
predicateLength: predicate.length,
|
1085
|
-
predicateDataLength: predicateData.length,
|
1142
|
+
predicateLength: bn2(predicate.length),
|
1143
|
+
predicateDataLength: bn2(predicateData.length),
|
1086
1144
|
predicate: hexlify3(predicate),
|
1087
1145
|
predicateData: hexlify3(predicateData),
|
1088
1146
|
data: hexlify3(data),
|
@@ -1156,10 +1214,8 @@ var outputify = (value) => {
|
|
1156
1214
|
};
|
1157
1215
|
|
1158
1216
|
// src/providers/transaction-request/transaction-request.ts
|
1159
|
-
import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
|
1160
1217
|
import { Address, addressify } from "@fuel-ts/address";
|
1161
1218
|
import { BaseAssetId as BaseAssetId2, ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
|
1162
|
-
import { randomBytes } from "@fuel-ts/crypto";
|
1163
1219
|
import { bn as bn7 } from "@fuel-ts/math";
|
1164
1220
|
import {
|
1165
1221
|
PolicyType,
|
@@ -1169,6 +1225,7 @@ import {
|
|
1169
1225
|
TransactionType
|
1170
1226
|
} from "@fuel-ts/transactions";
|
1171
1227
|
import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
|
1228
|
+
import { randomBytes } from "ethers";
|
1172
1229
|
|
1173
1230
|
// src/providers/resource.ts
|
1174
1231
|
var isRawCoin = (resource) => "utxoId" in resource;
|
@@ -1212,8 +1269,8 @@ function assembleReceiptByType(receipt) {
|
|
1212
1269
|
case "CALL" /* Call */: {
|
1213
1270
|
const callReceipt = {
|
1214
1271
|
type: ReceiptType.Call,
|
1215
|
-
from: hexOrZero(receipt.
|
1216
|
-
to: hexOrZero(receipt?.to
|
1272
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1273
|
+
to: hexOrZero(receipt?.to),
|
1217
1274
|
amount: bn4(receipt.amount),
|
1218
1275
|
assetId: hexOrZero(receipt.assetId),
|
1219
1276
|
gas: bn4(receipt.gas),
|
@@ -1227,7 +1284,7 @@ function assembleReceiptByType(receipt) {
|
|
1227
1284
|
case "RETURN" /* Return */: {
|
1228
1285
|
const returnReceipt = {
|
1229
1286
|
type: ReceiptType.Return,
|
1230
|
-
id: hexOrZero(receipt.
|
1287
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1231
1288
|
val: bn4(receipt.val),
|
1232
1289
|
pc: bn4(receipt.pc),
|
1233
1290
|
is: bn4(receipt.is)
|
@@ -1237,7 +1294,7 @@ function assembleReceiptByType(receipt) {
|
|
1237
1294
|
case "RETURN_DATA" /* ReturnData */: {
|
1238
1295
|
const returnDataReceipt = {
|
1239
1296
|
type: ReceiptType.ReturnData,
|
1240
|
-
id: hexOrZero(receipt.
|
1297
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1241
1298
|
ptr: bn4(receipt.ptr),
|
1242
1299
|
len: bn4(receipt.len),
|
1243
1300
|
digest: hexOrZero(receipt.digest),
|
@@ -1249,7 +1306,7 @@ function assembleReceiptByType(receipt) {
|
|
1249
1306
|
case "PANIC" /* Panic */: {
|
1250
1307
|
const panicReceipt = {
|
1251
1308
|
type: ReceiptType.Panic,
|
1252
|
-
id: hexOrZero(receipt.
|
1309
|
+
id: hexOrZero(receipt.id),
|
1253
1310
|
reason: bn4(receipt.reason),
|
1254
1311
|
pc: bn4(receipt.pc),
|
1255
1312
|
is: bn4(receipt.is),
|
@@ -1260,7 +1317,7 @@ function assembleReceiptByType(receipt) {
|
|
1260
1317
|
case "REVERT" /* Revert */: {
|
1261
1318
|
const revertReceipt = {
|
1262
1319
|
type: ReceiptType.Revert,
|
1263
|
-
id: hexOrZero(receipt.
|
1320
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1264
1321
|
val: bn4(receipt.ra),
|
1265
1322
|
pc: bn4(receipt.pc),
|
1266
1323
|
is: bn4(receipt.is)
|
@@ -1270,7 +1327,7 @@ function assembleReceiptByType(receipt) {
|
|
1270
1327
|
case "LOG" /* Log */: {
|
1271
1328
|
const logReceipt = {
|
1272
1329
|
type: ReceiptType.Log,
|
1273
|
-
id: hexOrZero(receipt.
|
1330
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1274
1331
|
val0: bn4(receipt.ra),
|
1275
1332
|
val1: bn4(receipt.rb),
|
1276
1333
|
val2: bn4(receipt.rc),
|
@@ -1283,7 +1340,7 @@ function assembleReceiptByType(receipt) {
|
|
1283
1340
|
case "LOG_DATA" /* LogData */: {
|
1284
1341
|
const logDataReceipt = {
|
1285
1342
|
type: ReceiptType.LogData,
|
1286
|
-
id: hexOrZero(receipt.
|
1343
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1287
1344
|
val0: bn4(receipt.ra),
|
1288
1345
|
val1: bn4(receipt.rb),
|
1289
1346
|
ptr: bn4(receipt.ptr),
|
@@ -1297,8 +1354,8 @@ function assembleReceiptByType(receipt) {
|
|
1297
1354
|
case "TRANSFER" /* Transfer */: {
|
1298
1355
|
const transferReceipt = {
|
1299
1356
|
type: ReceiptType.Transfer,
|
1300
|
-
from: hexOrZero(receipt.
|
1301
|
-
to: hexOrZero(receipt.toAddress || receipt?.to
|
1357
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1358
|
+
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1302
1359
|
amount: bn4(receipt.amount),
|
1303
1360
|
assetId: hexOrZero(receipt.assetId),
|
1304
1361
|
pc: bn4(receipt.pc),
|
@@ -1309,8 +1366,8 @@ function assembleReceiptByType(receipt) {
|
|
1309
1366
|
case "TRANSFER_OUT" /* TransferOut */: {
|
1310
1367
|
const transferOutReceipt = {
|
1311
1368
|
type: ReceiptType.TransferOut,
|
1312
|
-
from: hexOrZero(receipt.
|
1313
|
-
to: hexOrZero(receipt.toAddress || receipt.to
|
1369
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1370
|
+
to: hexOrZero(receipt.toAddress || receipt.to),
|
1314
1371
|
amount: bn4(receipt.amount),
|
1315
1372
|
assetId: hexOrZero(receipt.assetId),
|
1316
1373
|
pc: bn4(receipt.pc),
|
@@ -1353,7 +1410,7 @@ function assembleReceiptByType(receipt) {
|
|
1353
1410
|
return receiptMessageOut;
|
1354
1411
|
}
|
1355
1412
|
case "MINT" /* Mint */: {
|
1356
|
-
const contractId = hexOrZero(receipt.
|
1413
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1357
1414
|
const subId = hexOrZero(receipt.subId);
|
1358
1415
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
1359
1416
|
const mintReceipt = {
|
@@ -1368,7 +1425,7 @@ function assembleReceiptByType(receipt) {
|
|
1368
1425
|
return mintReceipt;
|
1369
1426
|
}
|
1370
1427
|
case "BURN" /* Burn */: {
|
1371
|
-
const contractId = hexOrZero(receipt.
|
1428
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1372
1429
|
const subId = hexOrZero(receipt.subId);
|
1373
1430
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
1374
1431
|
const burnReceipt = {
|
@@ -1453,7 +1510,6 @@ var buildBlockExplorerUrl = (options = {}) => {
|
|
1453
1510
|
import { bn as bn5 } from "@fuel-ts/math";
|
1454
1511
|
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
1455
1512
|
import { arrayify as arrayify3 } from "@fuel-ts/utils";
|
1456
|
-
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1457
1513
|
var getGasUsedFromReceipts = (receipts) => {
|
1458
1514
|
const scriptResult = receipts.filter(
|
1459
1515
|
(receipt) => receipt.type === ReceiptType2.ScriptResult
|
@@ -1474,18 +1530,28 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
1474
1530
|
}
|
1475
1531
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
1476
1532
|
const witnessCache = [];
|
1477
|
-
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) => {
|
1478
1548
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1479
1549
|
return total.add(
|
1480
|
-
|
1550
|
+
vmInitializationCost.add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
|
1481
1551
|
);
|
1482
1552
|
}
|
1483
|
-
|
1484
|
-
|
1485
|
-
return total.add(gasCosts.ecr1);
|
1486
|
-
}
|
1487
|
-
return total;
|
1488
|
-
}, bn5());
|
1553
|
+
return total.add(gasCosts.ecr1);
|
1554
|
+
}, bn5(0));
|
1489
1555
|
return totalGas;
|
1490
1556
|
}
|
1491
1557
|
function getMinGas(params) {
|
@@ -1497,12 +1563,20 @@ function getMinGas(params) {
|
|
1497
1563
|
return minGas;
|
1498
1564
|
}
|
1499
1565
|
function getMaxGas(params) {
|
1500
|
-
const {
|
1566
|
+
const {
|
1567
|
+
gasPerByte,
|
1568
|
+
witnessesLength,
|
1569
|
+
witnessLimit,
|
1570
|
+
minGas,
|
1571
|
+
gasLimit = bn5(0),
|
1572
|
+
maxGasPerTx
|
1573
|
+
} = params;
|
1501
1574
|
let remainingAllowedWitnessGas = bn5(0);
|
1502
1575
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
1503
1576
|
remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
1504
1577
|
}
|
1505
|
-
|
1578
|
+
const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
1579
|
+
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
1506
1580
|
}
|
1507
1581
|
function calculateMetadataGasForTxCreate({
|
1508
1582
|
gasCosts,
|
@@ -1524,6 +1598,10 @@ function calculateMetadataGasForTxScript({
|
|
1524
1598
|
}) {
|
1525
1599
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1526
1600
|
}
|
1601
|
+
var calculateGasFee = (params) => {
|
1602
|
+
const { gas, gasPrice, priceFactor, tip } = params;
|
1603
|
+
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1604
|
+
};
|
1527
1605
|
|
1528
1606
|
// src/providers/utils/json.ts
|
1529
1607
|
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
@@ -1680,7 +1758,7 @@ var witnessify = (value) => {
|
|
1680
1758
|
// src/providers/transaction-request/transaction-request.ts
|
1681
1759
|
var BaseTransactionRequest = class {
|
1682
1760
|
/** Gas price for transaction */
|
1683
|
-
|
1761
|
+
tip;
|
1684
1762
|
/** Block until which tx cannot be included */
|
1685
1763
|
maturity;
|
1686
1764
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -1699,7 +1777,7 @@ var BaseTransactionRequest = class {
|
|
1699
1777
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
1700
1778
|
*/
|
1701
1779
|
constructor({
|
1702
|
-
|
1780
|
+
tip,
|
1703
1781
|
maturity,
|
1704
1782
|
maxFee,
|
1705
1783
|
witnessLimit,
|
@@ -1707,7 +1785,7 @@ var BaseTransactionRequest = class {
|
|
1707
1785
|
outputs,
|
1708
1786
|
witnesses
|
1709
1787
|
} = {}) {
|
1710
|
-
this.
|
1788
|
+
this.tip = bn7(tip);
|
1711
1789
|
this.maturity = maturity ?? 0;
|
1712
1790
|
this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
|
1713
1791
|
this.maxFee = maxFee ? bn7(maxFee) : void 0;
|
@@ -1718,9 +1796,9 @@ var BaseTransactionRequest = class {
|
|
1718
1796
|
static getPolicyMeta(req) {
|
1719
1797
|
let policyTypes = 0;
|
1720
1798
|
const policies = [];
|
1721
|
-
if (req.
|
1722
|
-
policyTypes += PolicyType.
|
1723
|
-
policies.push({ data: req.
|
1799
|
+
if (req.tip) {
|
1800
|
+
policyTypes += PolicyType.Tip;
|
1801
|
+
policies.push({ data: req.tip, type: PolicyType.Tip });
|
1724
1802
|
}
|
1725
1803
|
if (req.witnessLimit) {
|
1726
1804
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -1907,10 +1985,10 @@ var BaseTransactionRequest = class {
|
|
1907
1985
|
* @param predicate - Predicate bytes.
|
1908
1986
|
* @param predicateData - Predicate data bytes.
|
1909
1987
|
*/
|
1910
|
-
addCoinInput(coin
|
1988
|
+
addCoinInput(coin) {
|
1911
1989
|
const { assetId, owner, amount } = coin;
|
1912
1990
|
let witnessIndex;
|
1913
|
-
if (predicate) {
|
1991
|
+
if (coin.predicate) {
|
1914
1992
|
witnessIndex = 0;
|
1915
1993
|
} else {
|
1916
1994
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -1925,8 +2003,7 @@ var BaseTransactionRequest = class {
|
|
1925
2003
|
amount,
|
1926
2004
|
assetId,
|
1927
2005
|
txPointer: "0x00000000000000000000000000000000",
|
1928
|
-
witnessIndex
|
1929
|
-
predicate: predicate?.bytes
|
2006
|
+
witnessIndex
|
1930
2007
|
};
|
1931
2008
|
this.pushInput(input);
|
1932
2009
|
this.addChangeOutput(owner, assetId);
|
@@ -1939,11 +2016,11 @@ var BaseTransactionRequest = class {
|
|
1939
2016
|
* @param predicate - Predicate bytes.
|
1940
2017
|
* @param predicateData - Predicate data bytes.
|
1941
2018
|
*/
|
1942
|
-
addMessageInput(message
|
2019
|
+
addMessageInput(message) {
|
1943
2020
|
const { recipient, sender, amount } = message;
|
1944
2021
|
const assetId = BaseAssetId2;
|
1945
2022
|
let witnessIndex;
|
1946
|
-
if (predicate) {
|
2023
|
+
if (message.predicate) {
|
1947
2024
|
witnessIndex = 0;
|
1948
2025
|
} else {
|
1949
2026
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -1957,8 +2034,7 @@ var BaseTransactionRequest = class {
|
|
1957
2034
|
sender: sender.toB256(),
|
1958
2035
|
recipient: recipient.toB256(),
|
1959
2036
|
amount,
|
1960
|
-
witnessIndex
|
1961
|
-
predicate: predicate?.bytes
|
2037
|
+
witnessIndex
|
1962
2038
|
};
|
1963
2039
|
this.pushInput(input);
|
1964
2040
|
this.addChangeOutput(recipient, assetId);
|
@@ -1989,32 +2065,6 @@ var BaseTransactionRequest = class {
|
|
1989
2065
|
resources.forEach((resource) => this.addResource(resource));
|
1990
2066
|
return this;
|
1991
2067
|
}
|
1992
|
-
/**
|
1993
|
-
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
1994
|
-
* outputs from the related assetIds.
|
1995
|
-
*
|
1996
|
-
* @param resources - The resources to add.
|
1997
|
-
* @returns This transaction.
|
1998
|
-
*/
|
1999
|
-
addPredicateResource(resource, predicate) {
|
2000
|
-
if (isCoin(resource)) {
|
2001
|
-
this.addCoinInput(resource, predicate);
|
2002
|
-
} else {
|
2003
|
-
this.addMessageInput(resource, predicate);
|
2004
|
-
}
|
2005
|
-
return this;
|
2006
|
-
}
|
2007
|
-
/**
|
2008
|
-
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
2009
|
-
* from the related assetIds.
|
2010
|
-
*
|
2011
|
-
* @param resources - The resources to add.
|
2012
|
-
* @returns This transaction.
|
2013
|
-
*/
|
2014
|
-
addPredicateResources(resources, predicate) {
|
2015
|
-
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
2016
|
-
return this;
|
2017
|
-
}
|
2018
2068
|
/**
|
2019
2069
|
* Adds a coin output to the transaction.
|
2020
2070
|
*
|
@@ -2094,7 +2144,7 @@ var BaseTransactionRequest = class {
|
|
2094
2144
|
}
|
2095
2145
|
calculateMaxGas(chainInfo, minGas) {
|
2096
2146
|
const { consensusParameters } = chainInfo;
|
2097
|
-
const { gasPerByte } = consensusParameters;
|
2147
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2098
2148
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2099
2149
|
(acc, wit) => acc + wit.dataLength,
|
2100
2150
|
0
|
@@ -2103,7 +2153,8 @@ var BaseTransactionRequest = class {
|
|
2103
2153
|
gasPerByte,
|
2104
2154
|
minGas,
|
2105
2155
|
witnessesLength,
|
2106
|
-
witnessLimit: this.witnessLimit
|
2156
|
+
witnessLimit: this.witnessLimit,
|
2157
|
+
maxGasPerTx
|
2107
2158
|
});
|
2108
2159
|
}
|
2109
2160
|
/**
|
@@ -2121,17 +2172,20 @@ var BaseTransactionRequest = class {
|
|
2121
2172
|
});
|
2122
2173
|
const updateAssetInput = (assetId, quantity) => {
|
2123
2174
|
const assetInput = findAssetInput(assetId);
|
2175
|
+
let usedQuantity = quantity;
|
2176
|
+
if (assetId === BaseAssetId2) {
|
2177
|
+
usedQuantity = bn7("1000000000000000000");
|
2178
|
+
}
|
2124
2179
|
if (assetInput && "assetId" in assetInput) {
|
2125
|
-
assetInput.id = hexlify7(randomBytes(
|
2126
|
-
assetInput.amount =
|
2180
|
+
assetInput.id = hexlify7(randomBytes(34));
|
2181
|
+
assetInput.amount = usedQuantity;
|
2127
2182
|
} else {
|
2128
2183
|
this.addResources([
|
2129
2184
|
{
|
2130
|
-
id: hexlify7(randomBytes(
|
2131
|
-
amount:
|
2185
|
+
id: hexlify7(randomBytes(34)),
|
2186
|
+
amount: usedQuantity,
|
2132
2187
|
assetId,
|
2133
2188
|
owner: resourcesOwner || Address.fromRandom(),
|
2134
|
-
maturity: 0,
|
2135
2189
|
blockCreated: bn7(1),
|
2136
2190
|
txCreatedIdx: bn7(1)
|
2137
2191
|
}
|
@@ -2163,7 +2217,7 @@ var BaseTransactionRequest = class {
|
|
2163
2217
|
toJSON() {
|
2164
2218
|
return normalizeJSON(this);
|
2165
2219
|
}
|
2166
|
-
|
2220
|
+
updatePredicateGasUsed(inputs) {
|
2167
2221
|
this.inputs.forEach((i) => {
|
2168
2222
|
let correspondingInput;
|
2169
2223
|
switch (i.type) {
|
@@ -2185,6 +2239,15 @@ var BaseTransactionRequest = class {
|
|
2185
2239
|
}
|
2186
2240
|
});
|
2187
2241
|
}
|
2242
|
+
shiftPredicateData() {
|
2243
|
+
this.inputs.forEach((input) => {
|
2244
|
+
if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
|
2245
|
+
input.predicateData = input.paddPredicateData(
|
2246
|
+
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2247
|
+
);
|
2248
|
+
}
|
2249
|
+
});
|
2250
|
+
}
|
2188
2251
|
};
|
2189
2252
|
|
2190
2253
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2331,9 +2394,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2331
2394
|
return {
|
2332
2395
|
type: TransactionType3.Create,
|
2333
2396
|
...baseTransaction,
|
2334
|
-
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2335
2397
|
bytecodeWitnessIndex,
|
2336
|
-
storageSlotsCount: storageSlots.length,
|
2398
|
+
storageSlotsCount: bn9(storageSlots.length),
|
2337
2399
|
salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
|
2338
2400
|
storageSlots
|
2339
2401
|
};
|
@@ -2456,8 +2518,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2456
2518
|
type: TransactionType4.Script,
|
2457
2519
|
scriptGasLimit: this.gasLimit,
|
2458
2520
|
...super.getBaseTransaction(),
|
2459
|
-
scriptLength: script.length,
|
2460
|
-
scriptDataLength: scriptData.length,
|
2521
|
+
scriptLength: bn10(script.length),
|
2522
|
+
scriptDataLength: bn10(scriptData.length),
|
2461
2523
|
receiptsRoot: ZeroBytes327,
|
2462
2524
|
script: hexlify10(script),
|
2463
2525
|
scriptData: hexlify10(scriptData)
|
@@ -2521,7 +2583,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2521
2583
|
}
|
2522
2584
|
calculateMaxGas(chainInfo, minGas) {
|
2523
2585
|
const { consensusParameters } = chainInfo;
|
2524
|
-
const { gasPerByte } = consensusParameters;
|
2586
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2525
2587
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2526
2588
|
(acc, wit) => acc + wit.dataLength,
|
2527
2589
|
0
|
@@ -2531,7 +2593,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2531
2593
|
minGas,
|
2532
2594
|
witnessesLength,
|
2533
2595
|
witnessLimit: this.witnessLimit,
|
2534
|
-
gasLimit: this.gasLimit
|
2596
|
+
gasLimit: this.gasLimit,
|
2597
|
+
maxGasPerTx
|
2535
2598
|
});
|
2536
2599
|
}
|
2537
2600
|
/**
|
@@ -2588,7 +2651,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2588
2651
|
|
2589
2652
|
// src/providers/transaction-request/utils.ts
|
2590
2653
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2591
|
-
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2654
|
+
import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
|
2592
2655
|
var transactionRequestify = (obj) => {
|
2593
2656
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2594
2657
|
return obj;
|
@@ -2606,14 +2669,31 @@ var transactionRequestify = (obj) => {
|
|
2606
2669
|
}
|
2607
2670
|
}
|
2608
2671
|
};
|
2672
|
+
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2673
|
+
(acc, input) => {
|
2674
|
+
if (input.type === InputType5.Coin && input.owner === owner) {
|
2675
|
+
acc.utxos.push(input.id);
|
2676
|
+
}
|
2677
|
+
if (input.type === InputType5.Message && input.recipient === owner) {
|
2678
|
+
acc.messages.push(input.nonce);
|
2679
|
+
}
|
2680
|
+
return acc;
|
2681
|
+
},
|
2682
|
+
{
|
2683
|
+
utxos: [],
|
2684
|
+
messages: []
|
2685
|
+
}
|
2686
|
+
);
|
2609
2687
|
|
2610
2688
|
// src/providers/transaction-response/transaction-response.ts
|
2611
2689
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2612
|
-
import { bn as
|
2690
|
+
import { bn as bn15 } from "@fuel-ts/math";
|
2613
2691
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2614
2692
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2615
2693
|
|
2616
2694
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2695
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
2696
|
+
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2617
2697
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2618
2698
|
|
2619
2699
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
@@ -2622,9 +2702,10 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
|
|
2622
2702
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2623
2703
|
var calculateTransactionFee = (params) => {
|
2624
2704
|
const {
|
2625
|
-
|
2705
|
+
gasPrice,
|
2626
2706
|
rawPayload,
|
2627
|
-
|
2707
|
+
tip,
|
2708
|
+
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2628
2709
|
} = params;
|
2629
2710
|
const gasPerByte = bn11(feeParams.gasPerByte);
|
2630
2711
|
const gasPriceFactor = bn11(feeParams.gasPriceFactor);
|
@@ -2634,8 +2715,7 @@ var calculateTransactionFee = (params) => {
|
|
2634
2715
|
return {
|
2635
2716
|
fee: bn11(0),
|
2636
2717
|
minFee: bn11(0),
|
2637
|
-
maxFee: bn11(0)
|
2638
|
-
feeFromGasUsed: bn11(0)
|
2718
|
+
maxFee: bn11(0)
|
2639
2719
|
};
|
2640
2720
|
}
|
2641
2721
|
const { type, witnesses, inputs, policies } = transaction;
|
@@ -2667,7 +2747,6 @@ var calculateTransactionFee = (params) => {
|
|
2667
2747
|
metadataGas,
|
2668
2748
|
txBytesSize: transactionBytes.length
|
2669
2749
|
});
|
2670
|
-
const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
|
2671
2750
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
|
2672
2751
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2673
2752
|
const maxGas = getMaxGas({
|
@@ -2675,17 +2754,25 @@ var calculateTransactionFee = (params) => {
|
|
2675
2754
|
minGas,
|
2676
2755
|
witnessesLength,
|
2677
2756
|
gasLimit,
|
2678
|
-
witnessLimit
|
2757
|
+
witnessLimit,
|
2758
|
+
maxGasPerTx
|
2759
|
+
});
|
2760
|
+
const minFee = calculateGasFee({
|
2761
|
+
gasPrice,
|
2762
|
+
gas: minGas,
|
2763
|
+
priceFactor: gasPriceFactor,
|
2764
|
+
tip
|
2765
|
+
});
|
2766
|
+
const maxFee = calculateGasFee({
|
2767
|
+
gasPrice,
|
2768
|
+
gas: maxGas,
|
2769
|
+
priceFactor: gasPriceFactor,
|
2770
|
+
tip
|
2679
2771
|
});
|
2680
|
-
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
2681
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
2682
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
2683
|
-
const fee = minFee.add(feeFromGasUsed);
|
2684
2772
|
return {
|
2685
|
-
fee,
|
2686
2773
|
minFee,
|
2687
2774
|
maxFee,
|
2688
|
-
|
2775
|
+
fee: maxFee
|
2689
2776
|
};
|
2690
2777
|
};
|
2691
2778
|
|
@@ -2741,7 +2828,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2741
2828
|
|
2742
2829
|
// src/providers/transaction-summary/input.ts
|
2743
2830
|
import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2744
|
-
import { InputType as
|
2831
|
+
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
2745
2832
|
function getInputsByTypes(inputs, types) {
|
2746
2833
|
return inputs.filter((i) => types.includes(i.type));
|
2747
2834
|
}
|
@@ -2749,16 +2836,16 @@ function getInputsByType(inputs, type) {
|
|
2749
2836
|
return inputs.filter((i) => i.type === type);
|
2750
2837
|
}
|
2751
2838
|
function getInputsCoin(inputs) {
|
2752
|
-
return getInputsByType(inputs,
|
2839
|
+
return getInputsByType(inputs, InputType6.Coin);
|
2753
2840
|
}
|
2754
2841
|
function getInputsMessage(inputs) {
|
2755
|
-
return getInputsByType(inputs,
|
2842
|
+
return getInputsByType(inputs, InputType6.Message);
|
2756
2843
|
}
|
2757
2844
|
function getInputsCoinAndMessage(inputs) {
|
2758
|
-
return getInputsByTypes(inputs, [
|
2845
|
+
return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
|
2759
2846
|
}
|
2760
2847
|
function getInputsContract(inputs) {
|
2761
|
-
return getInputsByType(inputs,
|
2848
|
+
return getInputsByType(inputs, InputType6.Contract);
|
2762
2849
|
}
|
2763
2850
|
function getInputFromAssetId(inputs, assetId) {
|
2764
2851
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2777,7 +2864,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2777
2864
|
if (!contractInput) {
|
2778
2865
|
return void 0;
|
2779
2866
|
}
|
2780
|
-
if (contractInput.type !==
|
2867
|
+
if (contractInput.type !== InputType6.Contract) {
|
2781
2868
|
throw new FuelError9(
|
2782
2869
|
ErrorCode9.INVALID_TRANSACTION_INPUT,
|
2783
2870
|
`Contract input should be of type 'contract'.`
|
@@ -2786,10 +2873,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2786
2873
|
return contractInput;
|
2787
2874
|
}
|
2788
2875
|
function getInputAccountAddress(input) {
|
2789
|
-
if (input.type ===
|
2876
|
+
if (input.type === InputType6.Coin) {
|
2790
2877
|
return input.owner.toString();
|
2791
2878
|
}
|
2792
|
-
if (input.type ===
|
2879
|
+
if (input.type === InputType6.Message) {
|
2793
2880
|
return input.recipient.toString();
|
2794
2881
|
}
|
2795
2882
|
return "";
|
@@ -3299,7 +3386,9 @@ function assembleTransactionSummary(params) {
|
|
3299
3386
|
gqlTransactionStatus,
|
3300
3387
|
abiMap = {},
|
3301
3388
|
maxInputs,
|
3302
|
-
gasCosts
|
3389
|
+
gasCosts,
|
3390
|
+
maxGasPerTx,
|
3391
|
+
gasPrice
|
3303
3392
|
} = params;
|
3304
3393
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3305
3394
|
const rawPayload = hexlify11(transactionBytes);
|
@@ -3313,11 +3402,14 @@ function assembleTransactionSummary(params) {
|
|
3313
3402
|
maxInputs
|
3314
3403
|
});
|
3315
3404
|
const typeName = getTransactionTypeName(transaction.type);
|
3405
|
+
const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3316
3406
|
const { fee } = calculateTransactionFee({
|
3317
|
-
|
3407
|
+
gasPrice,
|
3318
3408
|
rawPayload,
|
3409
|
+
tip,
|
3319
3410
|
consensusParameters: {
|
3320
3411
|
gasCosts,
|
3412
|
+
maxGasPerTx,
|
3321
3413
|
feeParams: {
|
3322
3414
|
gasPerByte,
|
3323
3415
|
gasPriceFactor
|
@@ -3377,7 +3469,7 @@ var TransactionResponse = class {
|
|
3377
3469
|
/** Current provider */
|
3378
3470
|
provider;
|
3379
3471
|
/** Gas used on the transaction */
|
3380
|
-
gasUsed =
|
3472
|
+
gasUsed = bn15(0);
|
3381
3473
|
/** The graphql Transaction with receipts object. */
|
3382
3474
|
gqlTransaction;
|
3383
3475
|
abis;
|
@@ -3455,8 +3547,13 @@ var TransactionResponse = class {
|
|
3455
3547
|
const decodedTransaction = this.decodeTransaction(
|
3456
3548
|
transaction
|
3457
3549
|
);
|
3458
|
-
|
3459
|
-
|
3550
|
+
let txReceipts = [];
|
3551
|
+
if (transaction?.status && "receipts" in transaction.status) {
|
3552
|
+
txReceipts = transaction.status.receipts;
|
3553
|
+
}
|
3554
|
+
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3555
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3556
|
+
const gasPrice = await this.provider.getLatestGasPrice();
|
3460
3557
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3461
3558
|
const transactionSummary = assembleTransactionSummary({
|
3462
3559
|
id: this.id,
|
@@ -3468,7 +3565,9 @@ var TransactionResponse = class {
|
|
3468
3565
|
gasPriceFactor,
|
3469
3566
|
abiMap: contractsAbiMap,
|
3470
3567
|
maxInputs,
|
3471
|
-
gasCosts
|
3568
|
+
gasCosts,
|
3569
|
+
maxGasPerTx,
|
3570
|
+
gasPrice
|
3472
3571
|
});
|
3473
3572
|
return transactionSummary;
|
3474
3573
|
}
|
@@ -3595,29 +3694,29 @@ var processGqlChain = (chain) => {
|
|
3595
3694
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3596
3695
|
return {
|
3597
3696
|
name,
|
3598
|
-
baseChainHeight:
|
3697
|
+
baseChainHeight: bn16(daHeight),
|
3599
3698
|
consensusParameters: {
|
3600
|
-
contractMaxSize:
|
3601
|
-
maxInputs:
|
3602
|
-
maxOutputs:
|
3603
|
-
maxWitnesses:
|
3604
|
-
maxGasPerTx:
|
3605
|
-
maxScriptLength:
|
3606
|
-
maxScriptDataLength:
|
3607
|
-
maxStorageSlots:
|
3608
|
-
maxPredicateLength:
|
3609
|
-
maxPredicateDataLength:
|
3610
|
-
maxGasPerPredicate:
|
3611
|
-
gasPriceFactor:
|
3612
|
-
gasPerByte:
|
3613
|
-
maxMessageDataLength:
|
3614
|
-
chainId:
|
3699
|
+
contractMaxSize: bn16(contractParams.contractMaxSize),
|
3700
|
+
maxInputs: bn16(txParams.maxInputs),
|
3701
|
+
maxOutputs: bn16(txParams.maxOutputs),
|
3702
|
+
maxWitnesses: bn16(txParams.maxWitnesses),
|
3703
|
+
maxGasPerTx: bn16(txParams.maxGasPerTx),
|
3704
|
+
maxScriptLength: bn16(scriptParams.maxScriptLength),
|
3705
|
+
maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
|
3706
|
+
maxStorageSlots: bn16(contractParams.maxStorageSlots),
|
3707
|
+
maxPredicateLength: bn16(predicateParams.maxPredicateLength),
|
3708
|
+
maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
|
3709
|
+
maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
|
3710
|
+
gasPriceFactor: bn16(feeParams.gasPriceFactor),
|
3711
|
+
gasPerByte: bn16(feeParams.gasPerByte),
|
3712
|
+
maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
|
3713
|
+
chainId: bn16(consensusParameters.chainId),
|
3615
3714
|
gasCosts
|
3616
3715
|
},
|
3617
3716
|
gasCosts,
|
3618
3717
|
latestBlock: {
|
3619
3718
|
id: latestBlock.id,
|
3620
|
-
height:
|
3719
|
+
height: bn16(latestBlock.height),
|
3621
3720
|
time: latestBlock.header.time,
|
3622
3721
|
transactions: latestBlock.transactions.map((i) => ({
|
3623
3722
|
id: i.id
|
@@ -3711,10 +3810,8 @@ var _Provider = class {
|
|
3711
3810
|
* Returns some helpful parameters related to gas fees.
|
3712
3811
|
*/
|
3713
3812
|
getGasConfig() {
|
3714
|
-
const { minGasPrice } = this.getNode();
|
3715
3813
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3716
3814
|
return {
|
3717
|
-
minGasPrice,
|
3718
3815
|
maxGasPerTx,
|
3719
3816
|
maxGasPerPredicate,
|
3720
3817
|
gasPriceFactor,
|
@@ -3812,7 +3909,7 @@ var _Provider = class {
|
|
3812
3909
|
*/
|
3813
3910
|
async getBlockNumber() {
|
3814
3911
|
const { chain } = await this.operations.getChain();
|
3815
|
-
return
|
3912
|
+
return bn16(chain.latestBlock.height, 10);
|
3816
3913
|
}
|
3817
3914
|
/**
|
3818
3915
|
* Returns the chain information.
|
@@ -3822,13 +3919,11 @@ var _Provider = class {
|
|
3822
3919
|
async fetchNode() {
|
3823
3920
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3824
3921
|
const processedNodeInfo = {
|
3825
|
-
maxDepth:
|
3826
|
-
maxTx:
|
3827
|
-
minGasPrice: bn15(nodeInfo.minGasPrice),
|
3922
|
+
maxDepth: bn16(nodeInfo.maxDepth),
|
3923
|
+
maxTx: bn16(nodeInfo.maxTx),
|
3828
3924
|
nodeVersion: nodeInfo.nodeVersion,
|
3829
3925
|
utxoValidation: nodeInfo.utxoValidation,
|
3830
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
3831
|
-
peers: nodeInfo.peers
|
3926
|
+
vmBacktrace: nodeInfo.vmBacktrace
|
3832
3927
|
};
|
3833
3928
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
3834
3929
|
return processedNodeInfo;
|
@@ -3914,14 +4009,13 @@ var _Provider = class {
|
|
3914
4009
|
return this.estimateTxDependencies(transactionRequest);
|
3915
4010
|
}
|
3916
4011
|
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
3917
|
-
const { dryRun:
|
3918
|
-
encodedTransaction,
|
4012
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4013
|
+
encodedTransactions: encodedTransaction,
|
3919
4014
|
utxoValidation: utxoValidation || false
|
3920
4015
|
});
|
3921
|
-
const receipts =
|
3922
|
-
|
3923
|
-
|
3924
|
-
};
|
4016
|
+
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
4017
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
4018
|
+
return { receipts, dryrunStatus: status };
|
3925
4019
|
}
|
3926
4020
|
/**
|
3927
4021
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -3947,7 +4041,7 @@ var _Provider = class {
|
|
3947
4041
|
} = response;
|
3948
4042
|
if (inputs) {
|
3949
4043
|
inputs.forEach((input, index) => {
|
3950
|
-
if ("predicateGasUsed" in input &&
|
4044
|
+
if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
|
3951
4045
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3952
4046
|
}
|
3953
4047
|
});
|
@@ -3960,9 +4054,6 @@ var _Provider = class {
|
|
3960
4054
|
* If there are missing variable outputs,
|
3961
4055
|
* `addVariableOutputs` is called on the transaction.
|
3962
4056
|
*
|
3963
|
-
* @privateRemarks
|
3964
|
-
* TODO: Investigate support for missing contract IDs
|
3965
|
-
* TODO: Add support for missing output messages
|
3966
4057
|
*
|
3967
4058
|
* @param transactionRequest - The transaction request object.
|
3968
4059
|
* @returns A promise.
|
@@ -3975,16 +4066,19 @@ var _Provider = class {
|
|
3975
4066
|
missingContractIds: []
|
3976
4067
|
};
|
3977
4068
|
}
|
3978
|
-
await this.estimatePredicates(transactionRequest);
|
3979
4069
|
let receipts = [];
|
3980
4070
|
const missingContractIds = [];
|
3981
4071
|
let outputVariables = 0;
|
4072
|
+
let dryrunStatus;
|
3982
4073
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3983
|
-
const {
|
3984
|
-
|
4074
|
+
const {
|
4075
|
+
dryRun: [{ receipts: rawReceipts, status }]
|
4076
|
+
} = await this.operations.dryRun({
|
4077
|
+
encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
|
3985
4078
|
utxoValidation: false
|
3986
4079
|
});
|
3987
|
-
receipts =
|
4080
|
+
receipts = rawReceipts.map(processGqlReceipt);
|
4081
|
+
dryrunStatus = status;
|
3988
4082
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
3989
4083
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
3990
4084
|
if (hasMissingOutputs) {
|
@@ -3994,6 +4088,11 @@ var _Provider = class {
|
|
3994
4088
|
transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
|
3995
4089
|
missingContractIds.push(contractId);
|
3996
4090
|
});
|
4091
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
4092
|
+
transactionRequest,
|
4093
|
+
optimizeGas: false
|
4094
|
+
});
|
4095
|
+
transactionRequest.maxFee = maxFee;
|
3997
4096
|
} else {
|
3998
4097
|
break;
|
3999
4098
|
}
|
@@ -4001,37 +4100,133 @@ var _Provider = class {
|
|
4001
4100
|
return {
|
4002
4101
|
receipts,
|
4003
4102
|
outputVariables,
|
4004
|
-
missingContractIds
|
4103
|
+
missingContractIds,
|
4104
|
+
dryrunStatus
|
4005
4105
|
};
|
4006
4106
|
}
|
4007
4107
|
/**
|
4008
|
-
*
|
4009
|
-
*
|
4010
|
-
*
|
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.
|
4011
4116
|
*/
|
4012
|
-
|
4013
|
-
const
|
4014
|
-
|
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;
|
4015
4195
|
const chainInfo = this.getChain();
|
4016
|
-
const
|
4017
|
-
transactionRequest.gasPrice = gasPrice;
|
4196
|
+
const { gasPriceFactor } = this.getGasConfig();
|
4018
4197
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
4019
|
-
|
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);
|
4020
4208
|
if (transactionRequest.type === TransactionType8.Script) {
|
4021
|
-
|
4209
|
+
gasLimit = transactionRequest.gasLimit;
|
4210
|
+
if (!optimizeGas) {
|
4022
4211
|
transactionRequest.gasLimit = minGas;
|
4023
|
-
|
4024
|
-
|
4025
|
-
);
|
4212
|
+
gasLimit = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4213
|
+
transactionRequest.gasLimit = gasLimit;
|
4026
4214
|
}
|
4027
4215
|
}
|
4028
4216
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4029
|
-
const maxFee =
|
4217
|
+
const maxFee = calculateGasFee({
|
4218
|
+
gasPrice: bn16(gasPrice),
|
4219
|
+
gas: maxGas,
|
4220
|
+
priceFactor: gasPriceFactor,
|
4221
|
+
tip: transactionRequest.tip
|
4222
|
+
}).add(1);
|
4030
4223
|
return {
|
4031
4224
|
minGas,
|
4032
4225
|
minFee,
|
4033
4226
|
maxGas,
|
4034
|
-
maxFee
|
4227
|
+
maxFee,
|
4228
|
+
gasPrice,
|
4229
|
+
gasLimit
|
4035
4230
|
};
|
4036
4231
|
}
|
4037
4232
|
/**
|
@@ -4049,15 +4244,17 @@ var _Provider = class {
|
|
4049
4244
|
if (estimateTxDependencies) {
|
4050
4245
|
return this.estimateTxDependencies(transactionRequest);
|
4051
4246
|
}
|
4052
|
-
const
|
4053
|
-
const { dryRun:
|
4054
|
-
|
4247
|
+
const encodedTransactions = [hexlify12(transactionRequest.toTransactionBytes())];
|
4248
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4249
|
+
encodedTransactions,
|
4055
4250
|
utxoValidation: true
|
4056
4251
|
});
|
4057
|
-
const
|
4058
|
-
|
4059
|
-
receipts
|
4060
|
-
|
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 };
|
4061
4258
|
}
|
4062
4259
|
/**
|
4063
4260
|
* Returns a transaction cost to enable user
|
@@ -4074,77 +4271,80 @@ var _Provider = class {
|
|
4074
4271
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
4075
4272
|
* @returns A promise that resolves to the transaction cost object.
|
4076
4273
|
*/
|
4077
|
-
async getTransactionCost(transactionRequestLike,
|
4078
|
-
estimateTxDependencies = true,
|
4079
|
-
estimatePredicates = true,
|
4080
|
-
resourcesOwner,
|
4081
|
-
signatureCallback
|
4082
|
-
} = {}) {
|
4274
|
+
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
4083
4275
|
const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
|
4084
|
-
const { minGasPrice } = this.getGasConfig();
|
4085
|
-
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
4086
4276
|
const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
|
4087
4277
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4088
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
4278
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4089
4279
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
4280
|
+
txRequestClone.maxFee = bn16(0);
|
4090
4281
|
if (isScriptTransaction) {
|
4091
|
-
txRequestClone.gasLimit =
|
4282
|
+
txRequestClone.gasLimit = bn16(0);
|
4092
4283
|
}
|
4093
|
-
if (
|
4094
|
-
|
4095
|
-
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
4096
|
-
}
|
4097
|
-
await this.estimatePredicates(txRequestClone);
|
4284
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4285
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
4098
4286
|
}
|
4287
|
+
const signedRequest = clone3(txRequestClone);
|
4288
|
+
let addedSignatures = 0;
|
4099
4289
|
if (signatureCallback && isScriptTransaction) {
|
4100
|
-
|
4101
|
-
|
4102
|
-
|
4103
|
-
|
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
|
4104
4298
|
});
|
4299
|
+
txRequestClone.maxFee = maxFee;
|
4105
4300
|
let receipts = [];
|
4106
4301
|
let missingContractIds = [];
|
4107
4302
|
let outputVariables = 0;
|
4108
|
-
let gasUsed =
|
4109
|
-
|
4110
|
-
|
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;
|
4111
4310
|
const result = await this.estimateTxDependencies(txRequestClone);
|
4112
4311
|
receipts = result.receipts;
|
4113
4312
|
outputVariables = result.outputVariables;
|
4114
4313
|
missingContractIds = result.missingContractIds;
|
4115
|
-
gasUsed =
|
4314
|
+
gasUsed = getGasUsedFromReceipts(receipts);
|
4116
4315
|
txRequestClone.gasLimit = gasUsed;
|
4117
|
-
|
4118
|
-
|
4119
|
-
|
4316
|
+
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
4317
|
+
transactionRequest: txRequestClone,
|
4318
|
+
gasPrice
|
4120
4319
|
}));
|
4121
4320
|
}
|
4122
4321
|
return {
|
4123
4322
|
requiredQuantities: allQuantities,
|
4124
4323
|
receipts,
|
4125
4324
|
gasUsed,
|
4126
|
-
|
4127
|
-
gasPrice: setGasPrice,
|
4325
|
+
gasPrice,
|
4128
4326
|
minGas,
|
4129
4327
|
maxGas,
|
4130
4328
|
minFee,
|
4131
4329
|
maxFee,
|
4132
|
-
estimatedInputs: txRequestClone.inputs,
|
4133
4330
|
outputVariables,
|
4134
|
-
missingContractIds
|
4331
|
+
missingContractIds,
|
4332
|
+
addedSignatures,
|
4333
|
+
estimatedPredicates: txRequestClone.inputs
|
4135
4334
|
};
|
4136
4335
|
}
|
4137
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
4336
|
+
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
4138
4337
|
const ownerAddress = Address2.fromAddressOrString(owner);
|
4139
4338
|
const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
|
4140
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
4339
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, {
|
4340
|
+
quantitiesToContract
|
4341
|
+
});
|
4141
4342
|
transactionRequest.addResources(
|
4142
4343
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
4143
4344
|
);
|
4144
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4145
|
-
|
4146
|
-
|
4147
|
-
);
|
4345
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
|
4346
|
+
quantitiesToContract
|
4347
|
+
});
|
4148
4348
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
4149
4349
|
return {
|
4150
4350
|
resources,
|
@@ -4166,11 +4366,10 @@ var _Provider = class {
|
|
4166
4366
|
return coins.map((coin) => ({
|
4167
4367
|
id: coin.utxoId,
|
4168
4368
|
assetId: coin.assetId,
|
4169
|
-
amount:
|
4369
|
+
amount: bn16(coin.amount),
|
4170
4370
|
owner: Address2.fromAddressOrString(coin.owner),
|
4171
|
-
|
4172
|
-
|
4173
|
-
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4371
|
+
blockCreated: bn16(coin.blockCreated),
|
4372
|
+
txCreatedIdx: bn16(coin.txCreatedIdx)
|
4174
4373
|
}));
|
4175
4374
|
}
|
4176
4375
|
/**
|
@@ -4207,9 +4406,9 @@ var _Provider = class {
|
|
4207
4406
|
switch (coin.__typename) {
|
4208
4407
|
case "MessageCoin":
|
4209
4408
|
return {
|
4210
|
-
amount:
|
4409
|
+
amount: bn16(coin.amount),
|
4211
4410
|
assetId: coin.assetId,
|
4212
|
-
daHeight:
|
4411
|
+
daHeight: bn16(coin.daHeight),
|
4213
4412
|
sender: Address2.fromAddressOrString(coin.sender),
|
4214
4413
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4215
4414
|
nonce: coin.nonce
|
@@ -4217,12 +4416,11 @@ var _Provider = class {
|
|
4217
4416
|
case "Coin":
|
4218
4417
|
return {
|
4219
4418
|
id: coin.utxoId,
|
4220
|
-
amount:
|
4419
|
+
amount: bn16(coin.amount),
|
4221
4420
|
assetId: coin.assetId,
|
4222
4421
|
owner: Address2.fromAddressOrString(coin.owner),
|
4223
|
-
|
4224
|
-
|
4225
|
-
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4422
|
+
blockCreated: bn16(coin.blockCreated),
|
4423
|
+
txCreatedIdx: bn16(coin.txCreatedIdx)
|
4226
4424
|
};
|
4227
4425
|
default:
|
4228
4426
|
return null;
|
@@ -4239,13 +4437,13 @@ var _Provider = class {
|
|
4239
4437
|
async getBlock(idOrHeight) {
|
4240
4438
|
let variables;
|
4241
4439
|
if (typeof idOrHeight === "number") {
|
4242
|
-
variables = { height:
|
4440
|
+
variables = { height: bn16(idOrHeight).toString(10) };
|
4243
4441
|
} else if (idOrHeight === "latest") {
|
4244
4442
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4245
4443
|
} else if (idOrHeight.length === 66) {
|
4246
4444
|
variables = { blockId: idOrHeight };
|
4247
4445
|
} else {
|
4248
|
-
variables = { blockId:
|
4446
|
+
variables = { blockId: bn16(idOrHeight).toString(10) };
|
4249
4447
|
}
|
4250
4448
|
const { block } = await this.operations.getBlock(variables);
|
4251
4449
|
if (!block) {
|
@@ -4253,7 +4451,7 @@ var _Provider = class {
|
|
4253
4451
|
}
|
4254
4452
|
return {
|
4255
4453
|
id: block.id,
|
4256
|
-
height:
|
4454
|
+
height: bn16(block.height),
|
4257
4455
|
time: block.header.time,
|
4258
4456
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4259
4457
|
};
|
@@ -4268,7 +4466,7 @@ var _Provider = class {
|
|
4268
4466
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4269
4467
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4270
4468
|
id: block.id,
|
4271
|
-
height:
|
4469
|
+
height: bn16(block.height),
|
4272
4470
|
time: block.header.time,
|
4273
4471
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4274
4472
|
}));
|
@@ -4283,7 +4481,7 @@ var _Provider = class {
|
|
4283
4481
|
async getBlockWithTransactions(idOrHeight) {
|
4284
4482
|
let variables;
|
4285
4483
|
if (typeof idOrHeight === "number") {
|
4286
|
-
variables = { blockHeight:
|
4484
|
+
variables = { blockHeight: bn16(idOrHeight).toString(10) };
|
4287
4485
|
} else if (idOrHeight === "latest") {
|
4288
4486
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4289
4487
|
} else {
|
@@ -4295,7 +4493,7 @@ var _Provider = class {
|
|
4295
4493
|
}
|
4296
4494
|
return {
|
4297
4495
|
id: block.id,
|
4298
|
-
height:
|
4496
|
+
height: bn16(block.height, 10),
|
4299
4497
|
time: block.header.time,
|
4300
4498
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4301
4499
|
transactions: block.transactions.map(
|
@@ -4344,7 +4542,7 @@ var _Provider = class {
|
|
4344
4542
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4345
4543
|
asset: hexlify12(assetId)
|
4346
4544
|
});
|
4347
|
-
return
|
4545
|
+
return bn16(contractBalance.amount, 10);
|
4348
4546
|
}
|
4349
4547
|
/**
|
4350
4548
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4358,7 +4556,7 @@ var _Provider = class {
|
|
4358
4556
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4359
4557
|
assetId: hexlify12(assetId)
|
4360
4558
|
});
|
4361
|
-
return
|
4559
|
+
return bn16(balance.amount, 10);
|
4362
4560
|
}
|
4363
4561
|
/**
|
4364
4562
|
* Returns balances for the given owner.
|
@@ -4376,7 +4574,7 @@ var _Provider = class {
|
|
4376
4574
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4377
4575
|
return balances.map((balance) => ({
|
4378
4576
|
assetId: balance.assetId,
|
4379
|
-
amount:
|
4577
|
+
amount: bn16(balance.amount)
|
4380
4578
|
}));
|
4381
4579
|
}
|
4382
4580
|
/**
|
@@ -4398,15 +4596,15 @@ var _Provider = class {
|
|
4398
4596
|
sender: message.sender,
|
4399
4597
|
recipient: message.recipient,
|
4400
4598
|
nonce: message.nonce,
|
4401
|
-
amount:
|
4599
|
+
amount: bn16(message.amount),
|
4402
4600
|
data: message.data
|
4403
4601
|
}),
|
4404
4602
|
sender: Address2.fromAddressOrString(message.sender),
|
4405
4603
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4406
4604
|
nonce: message.nonce,
|
4407
|
-
amount:
|
4605
|
+
amount: bn16(message.amount),
|
4408
4606
|
data: InputMessageCoder.decodeData(message.data),
|
4409
|
-
daHeight:
|
4607
|
+
daHeight: bn16(message.daHeight)
|
4410
4608
|
}));
|
4411
4609
|
}
|
4412
4610
|
/**
|
@@ -4459,44 +4657,52 @@ var _Provider = class {
|
|
4459
4657
|
} = result.messageProof;
|
4460
4658
|
return {
|
4461
4659
|
messageProof: {
|
4462
|
-
proofIndex:
|
4660
|
+
proofIndex: bn16(messageProof.proofIndex),
|
4463
4661
|
proofSet: messageProof.proofSet
|
4464
4662
|
},
|
4465
4663
|
blockProof: {
|
4466
|
-
proofIndex:
|
4664
|
+
proofIndex: bn16(blockProof.proofIndex),
|
4467
4665
|
proofSet: blockProof.proofSet
|
4468
4666
|
},
|
4469
4667
|
messageBlockHeader: {
|
4470
4668
|
id: messageBlockHeader.id,
|
4471
|
-
daHeight:
|
4472
|
-
transactionsCount:
|
4669
|
+
daHeight: bn16(messageBlockHeader.daHeight),
|
4670
|
+
transactionsCount: bn16(messageBlockHeader.transactionsCount),
|
4473
4671
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4474
|
-
height:
|
4672
|
+
height: bn16(messageBlockHeader.height),
|
4475
4673
|
prevRoot: messageBlockHeader.prevRoot,
|
4476
4674
|
time: messageBlockHeader.time,
|
4477
4675
|
applicationHash: messageBlockHeader.applicationHash,
|
4478
|
-
|
4479
|
-
messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
|
4676
|
+
messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount)
|
4480
4677
|
},
|
4481
4678
|
commitBlockHeader: {
|
4482
4679
|
id: commitBlockHeader.id,
|
4483
|
-
daHeight:
|
4484
|
-
transactionsCount:
|
4680
|
+
daHeight: bn16(commitBlockHeader.daHeight),
|
4681
|
+
transactionsCount: bn16(commitBlockHeader.transactionsCount),
|
4485
4682
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4486
|
-
height:
|
4683
|
+
height: bn16(commitBlockHeader.height),
|
4487
4684
|
prevRoot: commitBlockHeader.prevRoot,
|
4488
4685
|
time: commitBlockHeader.time,
|
4489
4686
|
applicationHash: commitBlockHeader.applicationHash,
|
4490
|
-
|
4491
|
-
messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
|
4687
|
+
messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount)
|
4492
4688
|
},
|
4493
4689
|
sender: Address2.fromAddressOrString(sender),
|
4494
4690
|
recipient: Address2.fromAddressOrString(recipient),
|
4495
4691
|
nonce,
|
4496
|
-
amount:
|
4692
|
+
amount: bn16(amount),
|
4497
4693
|
data
|
4498
4694
|
};
|
4499
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
|
+
}
|
4500
4706
|
/**
|
4501
4707
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
4502
4708
|
*
|
@@ -4516,10 +4722,10 @@ var _Provider = class {
|
|
4516
4722
|
*/
|
4517
4723
|
async produceBlocks(amount, startTime) {
|
4518
4724
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4519
|
-
blocksToProduce:
|
4725
|
+
blocksToProduce: bn16(amount).toString(10),
|
4520
4726
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4521
4727
|
});
|
4522
|
-
return
|
4728
|
+
return bn16(latestBlockHeight);
|
4523
4729
|
}
|
4524
4730
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4525
4731
|
async getTransactionResponse(transactionId) {
|
@@ -4533,7 +4739,7 @@ cacheInputs_fn = function(inputs) {
|
|
4533
4739
|
return;
|
4534
4740
|
}
|
4535
4741
|
inputs.forEach((input) => {
|
4536
|
-
if (input.type ===
|
4742
|
+
if (input.type === InputType7.Coin) {
|
4537
4743
|
this.cache?.set(input.id);
|
4538
4744
|
}
|
4539
4745
|
});
|
@@ -4543,7 +4749,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4543
4749
|
|
4544
4750
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4545
4751
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4546
|
-
import { bn as
|
4752
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
4547
4753
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4548
4754
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4549
4755
|
async function getTransactionSummary(params) {
|
@@ -4561,21 +4767,28 @@ async function getTransactionSummary(params) {
|
|
4561
4767
|
arrayify12(gqlTransaction.rawPayload),
|
4562
4768
|
0
|
4563
4769
|
);
|
4564
|
-
|
4770
|
+
let txReceipts = [];
|
4771
|
+
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
4772
|
+
txReceipts = gqlTransaction.status.receipts;
|
4773
|
+
}
|
4774
|
+
const receipts = txReceipts.map(processGqlReceipt);
|
4565
4775
|
const {
|
4566
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
4776
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
4567
4777
|
} = provider.getChain();
|
4778
|
+
const gasPrice = await provider.getLatestGasPrice();
|
4568
4779
|
const transactionInfo = assembleTransactionSummary({
|
4569
4780
|
id: gqlTransaction.id,
|
4570
4781
|
receipts,
|
4571
4782
|
transaction: decodedTransaction,
|
4572
4783
|
transactionBytes: arrayify12(gqlTransaction.rawPayload),
|
4573
4784
|
gqlTransactionStatus: gqlTransaction.status,
|
4574
|
-
gasPerByte:
|
4575
|
-
gasPriceFactor:
|
4785
|
+
gasPerByte: bn17(gasPerByte),
|
4786
|
+
gasPriceFactor: bn17(gasPriceFactor),
|
4576
4787
|
abiMap,
|
4577
4788
|
maxInputs,
|
4578
|
-
gasCosts
|
4789
|
+
gasCosts,
|
4790
|
+
maxGasPerTx,
|
4791
|
+
gasPrice
|
4579
4792
|
});
|
4580
4793
|
return {
|
4581
4794
|
gqlTransaction,
|
@@ -4585,10 +4798,11 @@ async function getTransactionSummary(params) {
|
|
4585
4798
|
async function getTransactionSummaryFromRequest(params) {
|
4586
4799
|
const { provider, transactionRequest, abiMap } = params;
|
4587
4800
|
const { receipts } = await provider.call(transactionRequest);
|
4588
|
-
const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
|
4801
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
|
4589
4802
|
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
4590
4803
|
const transaction = transactionRequest.toTransaction();
|
4591
4804
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
4805
|
+
const gasPrice = await provider.getLatestGasPrice();
|
4592
4806
|
const transactionSummary = assembleTransactionSummary({
|
4593
4807
|
receipts,
|
4594
4808
|
transaction,
|
@@ -4597,7 +4811,9 @@ async function getTransactionSummaryFromRequest(params) {
|
|
4597
4811
|
gasPerByte,
|
4598
4812
|
gasPriceFactor,
|
4599
4813
|
maxInputs,
|
4600
|
-
gasCosts
|
4814
|
+
gasCosts,
|
4815
|
+
maxGasPerTx,
|
4816
|
+
gasPrice
|
4601
4817
|
});
|
4602
4818
|
return transactionSummary;
|
4603
4819
|
}
|
@@ -4606,13 +4822,18 @@ async function getTransactionsSummaries(params) {
|
|
4606
4822
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
4607
4823
|
const { edges, pageInfo } = transactionsByOwner;
|
4608
4824
|
const {
|
4609
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
4825
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
4610
4826
|
} = provider.getChain();
|
4827
|
+
const gasPrice = await provider.getLatestGasPrice();
|
4611
4828
|
const transactions = edges.map((edge) => {
|
4612
4829
|
const { node: gqlTransaction } = edge;
|
4613
|
-
const { id, rawPayload,
|
4830
|
+
const { id, rawPayload, status } = gqlTransaction;
|
4614
4831
|
const [decodedTransaction] = new TransactionCoder6().decode(arrayify12(rawPayload), 0);
|
4615
|
-
|
4832
|
+
let txReceipts = [];
|
4833
|
+
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
4834
|
+
txReceipts = gqlTransaction.status.receipts;
|
4835
|
+
}
|
4836
|
+
const receipts = txReceipts.map(processGqlReceipt);
|
4616
4837
|
const transactionSummary = assembleTransactionSummary({
|
4617
4838
|
id,
|
4618
4839
|
receipts,
|
@@ -4623,7 +4844,9 @@ async function getTransactionsSummaries(params) {
|
|
4623
4844
|
gasPerByte,
|
4624
4845
|
gasPriceFactor,
|
4625
4846
|
maxInputs,
|
4626
|
-
gasCosts
|
4847
|
+
gasCosts,
|
4848
|
+
maxGasPerTx,
|
4849
|
+
gasPrice
|
4627
4850
|
});
|
4628
4851
|
const output = {
|
4629
4852
|
gqlTransaction,
|
@@ -4955,36 +5178,33 @@ var Account = class extends AbstractAccount {
|
|
4955
5178
|
* @param fee - The estimated transaction fee.
|
4956
5179
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4957
5180
|
*/
|
4958
|
-
async fund(request,
|
4959
|
-
const
|
4960
|
-
|
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),
|
4961
5186
|
assetId: BaseAssetId3,
|
4962
|
-
coinQuantities
|
5187
|
+
coinQuantities: requiredQuantities
|
4963
5188
|
});
|
4964
5189
|
const quantitiesDict = {};
|
4965
|
-
|
5190
|
+
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
4966
5191
|
quantitiesDict[assetId] = {
|
4967
5192
|
required: amount,
|
4968
|
-
owned:
|
5193
|
+
owned: bn18(0)
|
4969
5194
|
};
|
4970
5195
|
});
|
4971
|
-
|
4972
|
-
const cachedMessages = [];
|
4973
|
-
const owner = this.address.toB256();
|
4974
|
-
request.inputs.forEach((input) => {
|
5196
|
+
txRequest.inputs.forEach((input) => {
|
4975
5197
|
const isResource = "amount" in input;
|
4976
5198
|
if (isResource) {
|
4977
5199
|
const isCoin2 = "owner" in input;
|
4978
5200
|
if (isCoin2) {
|
4979
5201
|
const assetId = String(input.assetId);
|
4980
|
-
if (
|
4981
|
-
const amount =
|
5202
|
+
if (quantitiesDict[assetId]) {
|
5203
|
+
const amount = bn18(input.amount);
|
4982
5204
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4983
|
-
cachedUtxos.push(input.id);
|
4984
5205
|
}
|
4985
|
-
} else if (input.
|
5206
|
+
} else if (input.amount && quantitiesDict[BaseAssetId3]) {
|
4986
5207
|
quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
|
4987
|
-
cachedMessages.push(input.nonce);
|
4988
5208
|
}
|
4989
5209
|
}
|
4990
5210
|
});
|
@@ -4999,12 +5219,23 @@ var Account = class extends AbstractAccount {
|
|
4999
5219
|
});
|
5000
5220
|
const needsToBeFunded = missingQuantities.length;
|
5001
5221
|
if (needsToBeFunded) {
|
5002
|
-
const
|
5003
|
-
|
5004
|
-
|
5005
|
-
|
5006
|
-
|
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
|
+
);
|
5007
5233
|
}
|
5234
|
+
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
5235
|
+
transactionRequest: requestToBeReEstimate
|
5236
|
+
});
|
5237
|
+
txRequest.maxFee = maxFee;
|
5238
|
+
return txRequest;
|
5008
5239
|
}
|
5009
5240
|
/**
|
5010
5241
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -5012,28 +5243,25 @@ var Account = class extends AbstractAccount {
|
|
5012
5243
|
* @param destination - The address of the destination.
|
5013
5244
|
* @param amount - The amount of coins to transfer.
|
5014
5245
|
* @param assetId - The asset ID of the coins to transfer.
|
5015
|
-
* @param txParams - The transaction parameters (gasLimit,
|
5246
|
+
* @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
|
5016
5247
|
* @returns A promise that resolves to the prepared transaction request.
|
5017
5248
|
*/
|
5018
5249
|
async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
5019
|
-
const
|
5020
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
5021
|
-
const request = new ScriptTransactionRequest(params);
|
5250
|
+
const request = new ScriptTransactionRequest(txParams);
|
5022
5251
|
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
|
5023
|
-
const
|
5252
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
5024
5253
|
estimateTxDependencies: true,
|
5025
5254
|
resourcesOwner: this
|
5026
5255
|
});
|
5027
|
-
|
5028
|
-
|
5029
|
-
|
5030
|
-
|
5031
|
-
|
5032
|
-
|
5033
|
-
|
5034
|
-
|
5035
|
-
await this.fund(request,
|
5036
|
-
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);
|
5037
5265
|
return request;
|
5038
5266
|
}
|
5039
5267
|
/**
|
@@ -5046,7 +5274,7 @@ var Account = class extends AbstractAccount {
|
|
5046
5274
|
* @returns A promise that resolves to the transaction response.
|
5047
5275
|
*/
|
5048
5276
|
async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
5049
|
-
if (
|
5277
|
+
if (bn18(amount).lte(0)) {
|
5050
5278
|
throw new FuelError15(
|
5051
5279
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5052
5280
|
"Transfer amount must be a positive number."
|
@@ -5065,38 +5293,37 @@ var Account = class extends AbstractAccount {
|
|
5065
5293
|
* @returns A promise that resolves to the transaction response.
|
5066
5294
|
*/
|
5067
5295
|
async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
|
5068
|
-
if (
|
5296
|
+
if (bn18(amount).lte(0)) {
|
5069
5297
|
throw new FuelError15(
|
5070
5298
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5071
5299
|
"Transfer amount must be a positive number."
|
5072
5300
|
);
|
5073
5301
|
}
|
5074
5302
|
const contractAddress = Address3.fromAddressOrString(contractId);
|
5075
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
5076
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
5077
5303
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5078
5304
|
hexlifiedContractId: contractAddress.toB256(),
|
5079
|
-
amountToTransfer:
|
5305
|
+
amountToTransfer: bn18(amount),
|
5080
5306
|
assetId
|
5081
5307
|
});
|
5082
5308
|
const request = new ScriptTransactionRequest({
|
5083
|
-
...
|
5309
|
+
...txParams,
|
5084
5310
|
script,
|
5085
5311
|
scriptData
|
5086
5312
|
});
|
5087
5313
|
request.addContractInputAndOutput(contractAddress);
|
5088
|
-
const
|
5089
|
-
|
5090
|
-
[{ amount:
|
5091
|
-
);
|
5092
|
-
request.gasLimit = bn17(params.gasLimit ?? gasUsed);
|
5093
|
-
this.validateGas({
|
5094
|
-
gasUsed,
|
5095
|
-
gasPrice: request.gasPrice,
|
5096
|
-
gasLimit: request.gasLimit,
|
5097
|
-
minGasPrice
|
5314
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
5315
|
+
resourcesOwner: this,
|
5316
|
+
quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetId) }]
|
5098
5317
|
});
|
5099
|
-
|
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);
|
5100
5327
|
return this.sendTransaction(request);
|
5101
5328
|
}
|
5102
5329
|
/**
|
@@ -5108,34 +5335,31 @@ var Account = class extends AbstractAccount {
|
|
5108
5335
|
* @returns A promise that resolves to the transaction response.
|
5109
5336
|
*/
|
5110
5337
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5111
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
5112
5338
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
5113
5339
|
const recipientDataArray = arrayify14(
|
5114
5340
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5115
5341
|
);
|
5116
5342
|
const amountDataArray = arrayify14(
|
5117
|
-
"0x".concat(
|
5343
|
+
"0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
|
5118
5344
|
);
|
5119
5345
|
const script = new Uint8Array([
|
5120
5346
|
...arrayify14(withdrawScript.bytes),
|
5121
5347
|
...recipientDataArray,
|
5122
5348
|
...amountDataArray
|
5123
5349
|
]);
|
5124
|
-
const params = { script,
|
5350
|
+
const params = { script, ...txParams };
|
5125
5351
|
const request = new ScriptTransactionRequest(params);
|
5126
|
-
const
|
5127
|
-
const
|
5128
|
-
|
5129
|
-
|
5130
|
-
|
5131
|
-
|
5132
|
-
|
5133
|
-
|
5134
|
-
|
5135
|
-
|
5136
|
-
|
5137
|
-
});
|
5138
|
-
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);
|
5139
5363
|
return this.sendTransaction(request);
|
5140
5364
|
}
|
5141
5365
|
async signMessage(message) {
|
@@ -5193,18 +5417,7 @@ var Account = class extends AbstractAccount {
|
|
5193
5417
|
}
|
5194
5418
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5195
5419
|
}
|
5196
|
-
validateGas({
|
5197
|
-
gasUsed,
|
5198
|
-
gasPrice,
|
5199
|
-
gasLimit,
|
5200
|
-
minGasPrice
|
5201
|
-
}) {
|
5202
|
-
if (minGasPrice.gt(gasPrice)) {
|
5203
|
-
throw new FuelError15(
|
5204
|
-
ErrorCode15.GAS_PRICE_TOO_LOW,
|
5205
|
-
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
5206
|
-
);
|
5207
|
-
}
|
5420
|
+
validateGas({ gasUsed, gasLimit }) {
|
5208
5421
|
if (gasUsed.gt(gasLimit)) {
|
5209
5422
|
throw new FuelError15(
|
5210
5423
|
ErrorCode15.GAS_LIMIT_TOO_LOW,
|
@@ -5500,7 +5713,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5500
5713
|
* @param transactionRequestLike - The transaction request to send.
|
5501
5714
|
* @returns A promise that resolves to the TransactionResponse object.
|
5502
5715
|
*/
|
5503
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
5716
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
|
5504
5717
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5505
5718
|
if (estimateTxDependencies) {
|
5506
5719
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -5541,7 +5754,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5541
5754
|
// src/hdwallet/hdwallet.ts
|
5542
5755
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5543
5756
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5544
|
-
import { bn as
|
5757
|
+
import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5545
5758
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5546
5759
|
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5547
5760
|
|
@@ -8013,7 +8226,7 @@ var HDWallet = class {
|
|
8013
8226
|
const IR = bytes.slice(32);
|
8014
8227
|
if (privateKey) {
|
8015
8228
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8016
|
-
const ki =
|
8229
|
+
const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
|
8017
8230
|
return new HDWallet({
|
8018
8231
|
privateKey: ki,
|
8019
8232
|
chainCode: IR,
|
@@ -8702,7 +8915,7 @@ import {
|
|
8702
8915
|
import { Address as Address9 } from "@fuel-ts/address";
|
8703
8916
|
import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
|
8704
8917
|
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
8705
|
-
import { ByteArrayCoder, InputType as
|
8918
|
+
import { ByteArrayCoder, InputType as InputType8 } from "@fuel-ts/transactions";
|
8706
8919
|
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
8707
8920
|
|
8708
8921
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -8762,9 +8975,9 @@ var Predicate = class extends Account {
|
|
8762
8975
|
const request = transactionRequestify(transactionRequestLike);
|
8763
8976
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
8764
8977
|
request.inputs?.forEach((input) => {
|
8765
|
-
if (input.type ===
|
8766
|
-
input.predicate = this.bytes;
|
8767
|
-
input.predicateData = this.getPredicateData(policies.length);
|
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));
|
8768
8981
|
}
|
8769
8982
|
});
|
8770
8983
|
return request;
|
@@ -8779,8 +8992,7 @@ var Predicate = class extends Account {
|
|
8779
8992
|
* @returns A promise that resolves to the prepared transaction request.
|
8780
8993
|
*/
|
8781
8994
|
async createTransfer(destination, amount, assetId = BaseAssetId4, txParams = {}) {
|
8782
|
-
|
8783
|
-
return this.populateTransactionPredicateData(request);
|
8995
|
+
return super.createTransfer(destination, amount, assetId, txParams);
|
8784
8996
|
}
|
8785
8997
|
/**
|
8786
8998
|
* Sends a transaction with the populated predicate data.
|
@@ -8788,9 +9000,9 @@ var Predicate = class extends Account {
|
|
8788
9000
|
* @param transactionRequestLike - The transaction request-like object.
|
8789
9001
|
* @returns A promise that resolves to the transaction response.
|
8790
9002
|
*/
|
8791
|
-
sendTransaction(transactionRequestLike
|
8792
|
-
const transactionRequest =
|
8793
|
-
return super.sendTransaction(transactionRequest,
|
9003
|
+
sendTransaction(transactionRequestLike) {
|
9004
|
+
const transactionRequest = transactionRequestify(transactionRequestLike);
|
9005
|
+
return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
|
8794
9006
|
}
|
8795
9007
|
/**
|
8796
9008
|
* Simulates a transaction with the populated predicate data.
|
@@ -8799,8 +9011,8 @@ var Predicate = class extends Account {
|
|
8799
9011
|
* @returns A promise that resolves to the call result.
|
8800
9012
|
*/
|
8801
9013
|
simulateTransaction(transactionRequestLike) {
|
8802
|
-
const transactionRequest =
|
8803
|
-
return super.simulateTransaction(transactionRequest);
|
9014
|
+
const transactionRequest = transactionRequestify(transactionRequestLike);
|
9015
|
+
return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
|
8804
9016
|
}
|
8805
9017
|
getPredicateData(policiesLength) {
|
8806
9018
|
if (!this.predicateData.length) {
|
@@ -8846,6 +9058,25 @@ var Predicate = class extends Account {
|
|
8846
9058
|
predicateInterface: abiInterface
|
8847
9059
|
};
|
8848
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
|
+
}
|
8849
9080
|
/**
|
8850
9081
|
* Sets the configurable constants for the predicate.
|
8851
9082
|
*
|
@@ -9594,7 +9825,7 @@ export {
|
|
9594
9825
|
WalletLocked,
|
9595
9826
|
WalletManager,
|
9596
9827
|
WalletUnlocked,
|
9597
|
-
|
9828
|
+
addAmountToCoinQuantities,
|
9598
9829
|
addOperation,
|
9599
9830
|
assemblePanicError,
|
9600
9831
|
assembleReceiptByType,
|
@@ -9603,9 +9834,10 @@ export {
|
|
9603
9834
|
assets,
|
9604
9835
|
buildBlockExplorerUrl,
|
9605
9836
|
cacheFor,
|
9837
|
+
cacheTxInputsFromOwner,
|
9838
|
+
calculateGasFee,
|
9606
9839
|
calculateMetadataGasForTxCreate,
|
9607
9840
|
calculateMetadataGasForTxScript,
|
9608
|
-
calculatePriceWithFactor,
|
9609
9841
|
calculateTransactionFee,
|
9610
9842
|
coinQuantityfy,
|
9611
9843
|
deferPromise,
|