@fuel-ts/account 0.0.0-rc-2021-20240411154255 → 0.0.0-rc-2037-20240411163513
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 +4 -5
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +563 -841
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +565 -825
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +400 -659
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +10 -10
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +329 -911
- 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 +1 -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 +1 -6
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +30 -37
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +2 -2
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +5 -6
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +0 -3
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +0 -2
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +2 -3
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +2 -8
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +1047 -1557
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +543 -800
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +394 -651
- 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,9 +32,8 @@ import { Address as Address3 } from "@fuel-ts/address";
|
|
32
32
|
import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
|
33
33
|
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
34
34
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
35
|
-
import { bn as
|
35
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
36
36
|
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
37
|
-
import { clone as clone4 } from "ramda";
|
38
37
|
|
39
38
|
// src/providers/coin-quantity.ts
|
40
39
|
import { BaseAssetId } from "@fuel-ts/address/configs";
|
@@ -43,24 +42,24 @@ import { hexlify } from "@fuel-ts/utils";
|
|
43
42
|
var coinQuantityfy = (coinQuantityLike) => {
|
44
43
|
let assetId;
|
45
44
|
let amount;
|
46
|
-
let
|
45
|
+
let max2;
|
47
46
|
if (Array.isArray(coinQuantityLike)) {
|
48
47
|
amount = coinQuantityLike[0];
|
49
48
|
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
50
|
-
|
49
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
51
50
|
} else {
|
52
51
|
amount = coinQuantityLike.amount;
|
53
52
|
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
54
|
-
|
53
|
+
max2 = coinQuantityLike.max ?? void 0;
|
55
54
|
}
|
56
55
|
const bnAmount = bn(amount);
|
57
56
|
return {
|
58
57
|
assetId: hexlify(assetId),
|
59
58
|
amount: bnAmount.lt(1) ? bn(1) : bnAmount,
|
60
|
-
max:
|
59
|
+
max: max2 ? bn(max2) : void 0
|
61
60
|
};
|
62
61
|
};
|
63
|
-
var
|
62
|
+
var addAmountToAsset = (params) => {
|
64
63
|
const { amount, assetId } = params;
|
65
64
|
const coinQuantities = [...params.coinQuantities];
|
66
65
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -75,9 +74,9 @@ var addAmountToCoinQuantities = (params) => {
|
|
75
74
|
// src/providers/provider.ts
|
76
75
|
import { Address as Address2 } from "@fuel-ts/address";
|
77
76
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
78
|
-
import { BN, bn as
|
77
|
+
import { BN, bn as bn15, max } from "@fuel-ts/math";
|
79
78
|
import {
|
80
|
-
InputType as
|
79
|
+
InputType as InputType6,
|
81
80
|
TransactionType as TransactionType8,
|
82
81
|
InputMessageCoder,
|
83
82
|
TransactionCoder as TransactionCoder5
|
@@ -93,10 +92,14 @@ import { clone as clone3 } from "ramda";
|
|
93
92
|
import gql from "graphql-tag";
|
94
93
|
var ReceiptFragmentFragmentDoc = gql`
|
95
94
|
fragment receiptFragment on Receipt {
|
96
|
-
|
95
|
+
contract {
|
96
|
+
id
|
97
|
+
}
|
97
98
|
pc
|
98
99
|
is
|
99
|
-
to
|
100
|
+
to {
|
101
|
+
id
|
102
|
+
}
|
100
103
|
toAddress
|
101
104
|
amount
|
102
105
|
assetId
|
@@ -134,16 +137,10 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
134
137
|
id
|
135
138
|
}
|
136
139
|
time
|
137
|
-
receipts {
|
138
|
-
...receiptFragment
|
139
|
-
}
|
140
140
|
programState {
|
141
141
|
returnType
|
142
142
|
data
|
143
143
|
}
|
144
|
-
receipts {
|
145
|
-
...receiptFragment
|
146
|
-
}
|
147
144
|
}
|
148
145
|
... on FailureStatus {
|
149
146
|
block {
|
@@ -151,24 +148,26 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
151
148
|
}
|
152
149
|
time
|
153
150
|
reason
|
154
|
-
receipts {
|
155
|
-
...receiptFragment
|
156
|
-
}
|
157
151
|
}
|
158
152
|
... on SqueezedOutStatus {
|
159
153
|
reason
|
160
154
|
}
|
161
155
|
}
|
162
|
-
|
156
|
+
`;
|
163
157
|
var TransactionFragmentFragmentDoc = gql`
|
164
158
|
fragment transactionFragment on Transaction {
|
165
159
|
id
|
166
160
|
rawPayload
|
161
|
+
gasPrice
|
162
|
+
receipts {
|
163
|
+
...receiptFragment
|
164
|
+
}
|
167
165
|
status {
|
168
166
|
...transactionStatusFragment
|
169
167
|
}
|
170
168
|
}
|
171
|
-
${
|
169
|
+
${ReceiptFragmentFragmentDoc}
|
170
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
172
171
|
var InputEstimatePredicatesFragmentFragmentDoc = gql`
|
173
172
|
fragment inputEstimatePredicatesFragment on Input {
|
174
173
|
... on InputCoin {
|
@@ -186,46 +185,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
|
|
186
185
|
}
|
187
186
|
}
|
188
187
|
${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}`;
|
229
188
|
var CoinFragmentFragmentDoc = gql`
|
230
189
|
fragment coinFragment on Coin {
|
231
190
|
__typename
|
@@ -233,6 +192,7 @@ var CoinFragmentFragmentDoc = gql`
|
|
233
192
|
owner
|
234
193
|
amount
|
235
194
|
assetId
|
195
|
+
maturity
|
236
196
|
blockCreated
|
237
197
|
txCreatedIdx
|
238
198
|
}
|
@@ -271,32 +231,26 @@ var MessageProofFragmentFragmentDoc = gql`
|
|
271
231
|
messageBlockHeader {
|
272
232
|
id
|
273
233
|
daHeight
|
274
|
-
consensusParametersVersion
|
275
|
-
stateTransitionBytecodeVersion
|
276
234
|
transactionsCount
|
277
|
-
messageReceiptCount
|
278
235
|
transactionsRoot
|
279
|
-
messageOutboxRoot
|
280
|
-
eventInboxRoot
|
281
236
|
height
|
282
237
|
prevRoot
|
283
238
|
time
|
284
239
|
applicationHash
|
240
|
+
messageReceiptRoot
|
241
|
+
messageReceiptCount
|
285
242
|
}
|
286
243
|
commitBlockHeader {
|
287
244
|
id
|
288
245
|
daHeight
|
289
|
-
consensusParametersVersion
|
290
|
-
stateTransitionBytecodeVersion
|
291
246
|
transactionsCount
|
292
|
-
messageReceiptCount
|
293
247
|
transactionsRoot
|
294
|
-
messageOutboxRoot
|
295
|
-
eventInboxRoot
|
296
248
|
height
|
297
249
|
prevRoot
|
298
250
|
time
|
299
251
|
applicationHash
|
252
|
+
messageReceiptRoot
|
253
|
+
messageReceiptCount
|
300
254
|
}
|
301
255
|
sender
|
302
256
|
recipient
|
@@ -315,8 +269,8 @@ var BalanceFragmentFragmentDoc = gql`
|
|
315
269
|
var BlockFragmentFragmentDoc = gql`
|
316
270
|
fragment blockFragment on Block {
|
317
271
|
id
|
318
|
-
height
|
319
272
|
header {
|
273
|
+
height
|
320
274
|
time
|
321
275
|
}
|
322
276
|
transactions {
|
@@ -374,11 +328,6 @@ var DependentCostFragmentFragmentDoc = gql`
|
|
374
328
|
`;
|
375
329
|
var GasCostsFragmentFragmentDoc = gql`
|
376
330
|
fragment GasCostsFragment on GasCosts {
|
377
|
-
version {
|
378
|
-
... on Version {
|
379
|
-
value
|
380
|
-
}
|
381
|
-
}
|
382
331
|
add
|
383
332
|
addi
|
384
333
|
aloc
|
@@ -391,6 +340,7 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
391
340
|
cb
|
392
341
|
cfei
|
393
342
|
cfsi
|
343
|
+
croo
|
394
344
|
div
|
395
345
|
divi
|
396
346
|
ecr1
|
@@ -473,9 +423,6 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
473
423
|
ccp {
|
474
424
|
...DependentCostFragment
|
475
425
|
}
|
476
|
-
croo {
|
477
|
-
...DependentCostFragment
|
478
|
-
}
|
479
426
|
csiz {
|
480
427
|
...DependentCostFragment
|
481
428
|
}
|
@@ -535,11 +482,6 @@ var GasCostsFragmentFragmentDoc = gql`
|
|
535
482
|
${DependentCostFragmentFragmentDoc}`;
|
536
483
|
var ConsensusParametersFragmentFragmentDoc = gql`
|
537
484
|
fragment consensusParametersFragment on ConsensusParameters {
|
538
|
-
version {
|
539
|
-
... on Version {
|
540
|
-
value
|
541
|
-
}
|
542
|
-
}
|
543
485
|
txParams {
|
544
486
|
...TxParametersFragment
|
545
487
|
}
|
@@ -599,9 +541,18 @@ var NodeInfoFragmentFragmentDoc = gql`
|
|
599
541
|
fragment nodeInfoFragment on NodeInfo {
|
600
542
|
utxoValidation
|
601
543
|
vmBacktrace
|
544
|
+
minGasPrice
|
602
545
|
maxTx
|
603
546
|
maxDepth
|
604
547
|
nodeVersion
|
548
|
+
peers {
|
549
|
+
id
|
550
|
+
addresses
|
551
|
+
clientVersion
|
552
|
+
blockHeight
|
553
|
+
lastHeartbeatMs
|
554
|
+
appScore
|
555
|
+
}
|
605
556
|
}
|
606
557
|
`;
|
607
558
|
var GetVersionDocument = gql`
|
@@ -636,9 +587,13 @@ var GetTransactionWithReceiptsDocument = gql`
|
|
636
587
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
637
588
|
transaction(id: $transactionId) {
|
638
589
|
...transactionFragment
|
590
|
+
receipts {
|
591
|
+
...receiptFragment
|
592
|
+
}
|
639
593
|
}
|
640
594
|
}
|
641
|
-
${TransactionFragmentFragmentDoc}
|
595
|
+
${TransactionFragmentFragmentDoc}
|
596
|
+
${ReceiptFragmentFragmentDoc}`;
|
642
597
|
var GetTransactionsDocument = gql`
|
643
598
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
644
599
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -766,20 +721,6 @@ var GetBalanceDocument = gql`
|
|
766
721
|
}
|
767
722
|
}
|
768
723
|
${BalanceFragmentFragmentDoc}`;
|
769
|
-
var GetLatestGasPriceDocument = gql`
|
770
|
-
query getLatestGasPrice {
|
771
|
-
latestGasPrice {
|
772
|
-
gasPrice
|
773
|
-
}
|
774
|
-
}
|
775
|
-
`;
|
776
|
-
var EstimateGasPriceDocument = gql`
|
777
|
-
query estimateGasPrice($blockHorizon: U32!) {
|
778
|
-
estimateGasPrice(blockHorizon: $blockHorizon) {
|
779
|
-
gasPrice
|
780
|
-
}
|
781
|
-
}
|
782
|
-
`;
|
783
724
|
var GetBalancesDocument = gql`
|
784
725
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
785
726
|
balances(
|
@@ -834,12 +775,12 @@ var GetMessageStatusDocument = gql`
|
|
834
775
|
}
|
835
776
|
`;
|
836
777
|
var DryRunDocument = gql`
|
837
|
-
mutation dryRun($
|
838
|
-
dryRun(
|
839
|
-
...
|
778
|
+
mutation dryRun($encodedTransaction: HexString!, $utxoValidation: Boolean) {
|
779
|
+
dryRun(tx: $encodedTransaction, utxoValidation: $utxoValidation) {
|
780
|
+
...receiptFragment
|
840
781
|
}
|
841
782
|
}
|
842
|
-
${
|
783
|
+
${ReceiptFragmentFragmentDoc}`;
|
843
784
|
var SubmitDocument = gql`
|
844
785
|
mutation submit($encodedTransaction: HexString!) {
|
845
786
|
submit(tx: $encodedTransaction) {
|
@@ -922,12 +863,6 @@ function getSdk(requester) {
|
|
922
863
|
getBalance(variables, options) {
|
923
864
|
return requester(GetBalanceDocument, variables, options);
|
924
865
|
},
|
925
|
-
getLatestGasPrice(variables, options) {
|
926
|
-
return requester(GetLatestGasPriceDocument, variables, options);
|
927
|
-
},
|
928
|
-
estimateGasPrice(variables, options) {
|
929
|
-
return requester(EstimateGasPriceDocument, variables, options);
|
930
|
-
},
|
931
866
|
getBalances(variables, options) {
|
932
867
|
return requester(GetBalancesDocument, variables, options);
|
933
868
|
},
|
@@ -997,14 +932,11 @@ var _FuelGraphqlSubscriber = class {
|
|
997
932
|
let data;
|
998
933
|
let errors;
|
999
934
|
try {
|
1000
|
-
|
1001
|
-
({ data, errors } = JSON.parse(sanitizedText.replace(/^data:/, "")));
|
935
|
+
({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
|
1002
936
|
} catch (e) {
|
1003
937
|
throw new FuelError(
|
1004
938
|
ErrorCode.STREAM_PARSING_ERROR,
|
1005
|
-
`Error while parsing stream data response: ${text}
|
1006
|
-
|
1007
|
-
Thrown error: ${e}`
|
939
|
+
`Error while parsing stream data response: ${text}`
|
1008
940
|
);
|
1009
941
|
}
|
1010
942
|
if (Array.isArray(errors)) {
|
@@ -1091,6 +1023,7 @@ var MemoryCache = class {
|
|
1091
1023
|
};
|
1092
1024
|
|
1093
1025
|
// src/providers/transaction-request/input.ts
|
1026
|
+
import { BYTES_32, UTXO_ID_LEN } from "@fuel-ts/abi-coder";
|
1094
1027
|
import { ZeroBytes32 } from "@fuel-ts/address/configs";
|
1095
1028
|
import { ErrorCode as ErrorCode3, FuelError as FuelError3 } from "@fuel-ts/errors";
|
1096
1029
|
import { bn as bn2, toNumber } from "@fuel-ts/math";
|
@@ -1104,8 +1037,8 @@ var inputify = (value) => {
|
|
1104
1037
|
const predicateData = arrayify(value.predicateData ?? "0x");
|
1105
1038
|
return {
|
1106
1039
|
type: InputType.Coin,
|
1107
|
-
txID: hexlify3(arrayify(value.id).slice(0,
|
1108
|
-
outputIndex: toNumber(arrayify(value.id).slice(
|
1040
|
+
txID: hexlify3(arrayify(value.id).slice(0, BYTES_32)),
|
1041
|
+
outputIndex: toNumber(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
|
1109
1042
|
owner: hexlify3(value.owner),
|
1110
1043
|
amount: bn2(value.amount),
|
1111
1044
|
assetId: hexlify3(value.assetId),
|
@@ -1114,9 +1047,10 @@ var inputify = (value) => {
|
|
1114
1047
|
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
1115
1048
|
},
|
1116
1049
|
witnessIndex: value.witnessIndex,
|
1050
|
+
maturity: value.maturity ?? 0,
|
1117
1051
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1118
|
-
predicateLength:
|
1119
|
-
predicateDataLength:
|
1052
|
+
predicateLength: predicate.length,
|
1053
|
+
predicateDataLength: predicateData.length,
|
1120
1054
|
predicate: hexlify3(predicate),
|
1121
1055
|
predicateData: hexlify3(predicateData)
|
1122
1056
|
};
|
@@ -1147,8 +1081,8 @@ var inputify = (value) => {
|
|
1147
1081
|
nonce: hexlify3(value.nonce),
|
1148
1082
|
witnessIndex: value.witnessIndex,
|
1149
1083
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1150
|
-
predicateLength:
|
1151
|
-
predicateDataLength:
|
1084
|
+
predicateLength: predicate.length,
|
1085
|
+
predicateDataLength: predicateData.length,
|
1152
1086
|
predicate: hexlify3(predicate),
|
1153
1087
|
predicateData: hexlify3(predicateData),
|
1154
1088
|
data: hexlify3(data),
|
@@ -1222,8 +1156,10 @@ var outputify = (value) => {
|
|
1222
1156
|
};
|
1223
1157
|
|
1224
1158
|
// src/providers/transaction-request/transaction-request.ts
|
1159
|
+
import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
|
1225
1160
|
import { Address, addressify } from "@fuel-ts/address";
|
1226
1161
|
import { BaseAssetId as BaseAssetId2, ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
|
1162
|
+
import { randomBytes } from "@fuel-ts/crypto";
|
1227
1163
|
import { bn as bn7 } from "@fuel-ts/math";
|
1228
1164
|
import {
|
1229
1165
|
PolicyType,
|
@@ -1233,7 +1169,6 @@ import {
|
|
1233
1169
|
TransactionType
|
1234
1170
|
} from "@fuel-ts/transactions";
|
1235
1171
|
import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
|
1236
|
-
import { randomBytes } from "ethers";
|
1237
1172
|
|
1238
1173
|
// src/providers/resource.ts
|
1239
1174
|
var isRawCoin = (resource) => "utxoId" in resource;
|
@@ -1277,8 +1212,8 @@ function assembleReceiptByType(receipt) {
|
|
1277
1212
|
case "CALL" /* Call */: {
|
1278
1213
|
const callReceipt = {
|
1279
1214
|
type: ReceiptType.Call,
|
1280
|
-
from: hexOrZero(receipt.id
|
1281
|
-
to: hexOrZero(receipt?.to),
|
1215
|
+
from: hexOrZero(receipt.contract?.id),
|
1216
|
+
to: hexOrZero(receipt?.to?.id),
|
1282
1217
|
amount: bn4(receipt.amount),
|
1283
1218
|
assetId: hexOrZero(receipt.assetId),
|
1284
1219
|
gas: bn4(receipt.gas),
|
@@ -1292,7 +1227,7 @@ function assembleReceiptByType(receipt) {
|
|
1292
1227
|
case "RETURN" /* Return */: {
|
1293
1228
|
const returnReceipt = {
|
1294
1229
|
type: ReceiptType.Return,
|
1295
|
-
id: hexOrZero(receipt.id
|
1230
|
+
id: hexOrZero(receipt.contract?.id),
|
1296
1231
|
val: bn4(receipt.val),
|
1297
1232
|
pc: bn4(receipt.pc),
|
1298
1233
|
is: bn4(receipt.is)
|
@@ -1302,7 +1237,7 @@ function assembleReceiptByType(receipt) {
|
|
1302
1237
|
case "RETURN_DATA" /* ReturnData */: {
|
1303
1238
|
const returnDataReceipt = {
|
1304
1239
|
type: ReceiptType.ReturnData,
|
1305
|
-
id: hexOrZero(receipt.id
|
1240
|
+
id: hexOrZero(receipt.contract?.id),
|
1306
1241
|
ptr: bn4(receipt.ptr),
|
1307
1242
|
len: bn4(receipt.len),
|
1308
1243
|
digest: hexOrZero(receipt.digest),
|
@@ -1314,7 +1249,7 @@ function assembleReceiptByType(receipt) {
|
|
1314
1249
|
case "PANIC" /* Panic */: {
|
1315
1250
|
const panicReceipt = {
|
1316
1251
|
type: ReceiptType.Panic,
|
1317
|
-
id: hexOrZero(receipt.id),
|
1252
|
+
id: hexOrZero(receipt.contract?.id),
|
1318
1253
|
reason: bn4(receipt.reason),
|
1319
1254
|
pc: bn4(receipt.pc),
|
1320
1255
|
is: bn4(receipt.is),
|
@@ -1325,7 +1260,7 @@ function assembleReceiptByType(receipt) {
|
|
1325
1260
|
case "REVERT" /* Revert */: {
|
1326
1261
|
const revertReceipt = {
|
1327
1262
|
type: ReceiptType.Revert,
|
1328
|
-
id: hexOrZero(receipt.id
|
1263
|
+
id: hexOrZero(receipt.contract?.id),
|
1329
1264
|
val: bn4(receipt.ra),
|
1330
1265
|
pc: bn4(receipt.pc),
|
1331
1266
|
is: bn4(receipt.is)
|
@@ -1335,7 +1270,7 @@ function assembleReceiptByType(receipt) {
|
|
1335
1270
|
case "LOG" /* Log */: {
|
1336
1271
|
const logReceipt = {
|
1337
1272
|
type: ReceiptType.Log,
|
1338
|
-
id: hexOrZero(receipt.id
|
1273
|
+
id: hexOrZero(receipt.contract?.id),
|
1339
1274
|
val0: bn4(receipt.ra),
|
1340
1275
|
val1: bn4(receipt.rb),
|
1341
1276
|
val2: bn4(receipt.rc),
|
@@ -1348,7 +1283,7 @@ function assembleReceiptByType(receipt) {
|
|
1348
1283
|
case "LOG_DATA" /* LogData */: {
|
1349
1284
|
const logDataReceipt = {
|
1350
1285
|
type: ReceiptType.LogData,
|
1351
|
-
id: hexOrZero(receipt.id
|
1286
|
+
id: hexOrZero(receipt.contract?.id),
|
1352
1287
|
val0: bn4(receipt.ra),
|
1353
1288
|
val1: bn4(receipt.rb),
|
1354
1289
|
ptr: bn4(receipt.ptr),
|
@@ -1362,8 +1297,8 @@ function assembleReceiptByType(receipt) {
|
|
1362
1297
|
case "TRANSFER" /* Transfer */: {
|
1363
1298
|
const transferReceipt = {
|
1364
1299
|
type: ReceiptType.Transfer,
|
1365
|
-
from: hexOrZero(receipt.id
|
1366
|
-
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1300
|
+
from: hexOrZero(receipt.contract?.id),
|
1301
|
+
to: hexOrZero(receipt.toAddress || receipt?.to?.id),
|
1367
1302
|
amount: bn4(receipt.amount),
|
1368
1303
|
assetId: hexOrZero(receipt.assetId),
|
1369
1304
|
pc: bn4(receipt.pc),
|
@@ -1374,8 +1309,8 @@ function assembleReceiptByType(receipt) {
|
|
1374
1309
|
case "TRANSFER_OUT" /* TransferOut */: {
|
1375
1310
|
const transferOutReceipt = {
|
1376
1311
|
type: ReceiptType.TransferOut,
|
1377
|
-
from: hexOrZero(receipt.id
|
1378
|
-
to: hexOrZero(receipt.toAddress || receipt.to),
|
1312
|
+
from: hexOrZero(receipt.contract?.id),
|
1313
|
+
to: hexOrZero(receipt.toAddress || receipt.to?.id),
|
1379
1314
|
amount: bn4(receipt.amount),
|
1380
1315
|
assetId: hexOrZero(receipt.assetId),
|
1381
1316
|
pc: bn4(receipt.pc),
|
@@ -1418,7 +1353,7 @@ function assembleReceiptByType(receipt) {
|
|
1418
1353
|
return receiptMessageOut;
|
1419
1354
|
}
|
1420
1355
|
case "MINT" /* Mint */: {
|
1421
|
-
const contractId = hexOrZero(receipt.id
|
1356
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
1422
1357
|
const subId = hexOrZero(receipt.subId);
|
1423
1358
|
const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
|
1424
1359
|
const mintReceipt = {
|
@@ -1433,7 +1368,7 @@ function assembleReceiptByType(receipt) {
|
|
1433
1368
|
return mintReceipt;
|
1434
1369
|
}
|
1435
1370
|
case "BURN" /* Burn */: {
|
1436
|
-
const contractId = hexOrZero(receipt.id
|
1371
|
+
const contractId = hexOrZero(receipt.contract?.id);
|
1437
1372
|
const subId = hexOrZero(receipt.subId);
|
1438
1373
|
const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
|
1439
1374
|
const burnReceipt = {
|
@@ -1518,6 +1453,7 @@ var buildBlockExplorerUrl = (options = {}) => {
|
|
1518
1453
|
import { bn as bn5 } from "@fuel-ts/math";
|
1519
1454
|
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
1520
1455
|
import { arrayify as arrayify3 } from "@fuel-ts/utils";
|
1456
|
+
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => bn5(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1521
1457
|
var getGasUsedFromReceipts = (receipts) => {
|
1522
1458
|
const scriptResult = receipts.filter(
|
1523
1459
|
(receipt) => receipt.type === ReceiptType2.ScriptResult
|
@@ -1538,28 +1474,18 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
1538
1474
|
}
|
1539
1475
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
1540
1476
|
const witnessCache = [];
|
1541
|
-
const
|
1542
|
-
const isCoinOrMessage = "owner" in input || "sender" in input;
|
1543
|
-
if (isCoinOrMessage) {
|
1544
|
-
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1545
|
-
return true;
|
1546
|
-
}
|
1547
|
-
if (!witnessCache.includes(input.witnessIndex)) {
|
1548
|
-
witnessCache.push(input.witnessIndex);
|
1549
|
-
return true;
|
1550
|
-
}
|
1551
|
-
}
|
1552
|
-
return false;
|
1553
|
-
});
|
1554
|
-
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
1555
|
-
const totalGas = chargeableInputs.reduce((total, input) => {
|
1477
|
+
const totalGas = inputs.reduce((total, input) => {
|
1556
1478
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1557
1479
|
return total.add(
|
1558
|
-
|
1480
|
+
resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts(arrayify3(input.predicate).length, gasCosts.contractRoot)).add(bn5(input.predicateGasUsed))
|
1559
1481
|
);
|
1560
1482
|
}
|
1561
|
-
|
1562
|
-
|
1483
|
+
if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
|
1484
|
+
witnessCache.push(input.witnessIndex);
|
1485
|
+
return total.add(gasCosts.ecr1);
|
1486
|
+
}
|
1487
|
+
return total;
|
1488
|
+
}, bn5());
|
1563
1489
|
return totalGas;
|
1564
1490
|
}
|
1565
1491
|
function getMinGas(params) {
|
@@ -1571,20 +1497,12 @@ function getMinGas(params) {
|
|
1571
1497
|
return minGas;
|
1572
1498
|
}
|
1573
1499
|
function getMaxGas(params) {
|
1574
|
-
const {
|
1575
|
-
gasPerByte,
|
1576
|
-
witnessesLength,
|
1577
|
-
witnessLimit,
|
1578
|
-
minGas,
|
1579
|
-
gasLimit = bn5(0),
|
1580
|
-
maxGasPerTx
|
1581
|
-
} = params;
|
1500
|
+
const { gasPerByte, witnessesLength, witnessLimit, minGas, gasLimit = bn5(0) } = params;
|
1582
1501
|
let remainingAllowedWitnessGas = bn5(0);
|
1583
1502
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
1584
1503
|
remainingAllowedWitnessGas = bn5(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
1585
1504
|
}
|
1586
|
-
|
1587
|
-
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
1505
|
+
return remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
1588
1506
|
}
|
1589
1507
|
function calculateMetadataGasForTxCreate({
|
1590
1508
|
gasCosts,
|
@@ -1606,10 +1524,6 @@ function calculateMetadataGasForTxScript({
|
|
1606
1524
|
}) {
|
1607
1525
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1608
1526
|
}
|
1609
|
-
var calculateGasFee = (params) => {
|
1610
|
-
const { gas, gasPrice, priceFactor, tip } = params;
|
1611
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1612
|
-
};
|
1613
1527
|
|
1614
1528
|
// src/providers/utils/json.ts
|
1615
1529
|
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
@@ -1766,7 +1680,7 @@ var witnessify = (value) => {
|
|
1766
1680
|
// src/providers/transaction-request/transaction-request.ts
|
1767
1681
|
var BaseTransactionRequest = class {
|
1768
1682
|
/** Gas price for transaction */
|
1769
|
-
|
1683
|
+
gasPrice;
|
1770
1684
|
/** Block until which tx cannot be included */
|
1771
1685
|
maturity;
|
1772
1686
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -1785,7 +1699,7 @@ var BaseTransactionRequest = class {
|
|
1785
1699
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
1786
1700
|
*/
|
1787
1701
|
constructor({
|
1788
|
-
|
1702
|
+
gasPrice,
|
1789
1703
|
maturity,
|
1790
1704
|
maxFee,
|
1791
1705
|
witnessLimit,
|
@@ -1793,7 +1707,7 @@ var BaseTransactionRequest = class {
|
|
1793
1707
|
outputs,
|
1794
1708
|
witnesses
|
1795
1709
|
} = {}) {
|
1796
|
-
this.
|
1710
|
+
this.gasPrice = bn7(gasPrice);
|
1797
1711
|
this.maturity = maturity ?? 0;
|
1798
1712
|
this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
|
1799
1713
|
this.maxFee = maxFee ? bn7(maxFee) : void 0;
|
@@ -1804,9 +1718,9 @@ var BaseTransactionRequest = class {
|
|
1804
1718
|
static getPolicyMeta(req) {
|
1805
1719
|
let policyTypes = 0;
|
1806
1720
|
const policies = [];
|
1807
|
-
if (req.
|
1808
|
-
policyTypes += PolicyType.
|
1809
|
-
policies.push({ data: req.
|
1721
|
+
if (req.gasPrice) {
|
1722
|
+
policyTypes += PolicyType.GasPrice;
|
1723
|
+
policies.push({ data: req.gasPrice, type: PolicyType.GasPrice });
|
1810
1724
|
}
|
1811
1725
|
if (req.witnessLimit) {
|
1812
1726
|
policyTypes += PolicyType.WitnessLimit;
|
@@ -1994,9 +1908,9 @@ var BaseTransactionRequest = class {
|
|
1994
1908
|
* @param predicateData - Predicate data bytes.
|
1995
1909
|
*/
|
1996
1910
|
addCoinInput(coin) {
|
1997
|
-
const { assetId, owner, amount } = coin;
|
1911
|
+
const { assetId, owner, amount, id, predicate } = coin;
|
1998
1912
|
let witnessIndex;
|
1999
|
-
if (
|
1913
|
+
if (predicate) {
|
2000
1914
|
witnessIndex = 0;
|
2001
1915
|
} else {
|
2002
1916
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -2005,13 +1919,14 @@ var BaseTransactionRequest = class {
|
|
2005
1919
|
}
|
2006
1920
|
}
|
2007
1921
|
const input = {
|
2008
|
-
|
1922
|
+
id,
|
2009
1923
|
type: InputType2.Coin,
|
2010
1924
|
owner: owner.toB256(),
|
2011
1925
|
amount,
|
2012
1926
|
assetId,
|
2013
1927
|
txPointer: "0x00000000000000000000000000000000",
|
2014
|
-
witnessIndex
|
1928
|
+
witnessIndex,
|
1929
|
+
predicate
|
2015
1930
|
};
|
2016
1931
|
this.pushInput(input);
|
2017
1932
|
this.addChangeOutput(owner, assetId);
|
@@ -2025,10 +1940,10 @@ var BaseTransactionRequest = class {
|
|
2025
1940
|
* @param predicateData - Predicate data bytes.
|
2026
1941
|
*/
|
2027
1942
|
addMessageInput(message) {
|
2028
|
-
const { recipient, sender, amount } = message;
|
1943
|
+
const { recipient, sender, amount, predicate, nonce } = message;
|
2029
1944
|
const assetId = BaseAssetId2;
|
2030
1945
|
let witnessIndex;
|
2031
|
-
if (
|
1946
|
+
if (predicate) {
|
2032
1947
|
witnessIndex = 0;
|
2033
1948
|
} else {
|
2034
1949
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -2037,12 +1952,13 @@ var BaseTransactionRequest = class {
|
|
2037
1952
|
}
|
2038
1953
|
}
|
2039
1954
|
const input = {
|
2040
|
-
|
1955
|
+
nonce,
|
2041
1956
|
type: InputType2.Message,
|
2042
1957
|
sender: sender.toB256(),
|
2043
1958
|
recipient: recipient.toB256(),
|
2044
1959
|
amount,
|
2045
|
-
witnessIndex
|
1960
|
+
witnessIndex,
|
1961
|
+
predicate
|
2046
1962
|
};
|
2047
1963
|
this.pushInput(input);
|
2048
1964
|
this.addChangeOutput(recipient, assetId);
|
@@ -2152,7 +2068,7 @@ var BaseTransactionRequest = class {
|
|
2152
2068
|
}
|
2153
2069
|
calculateMaxGas(chainInfo, minGas) {
|
2154
2070
|
const { consensusParameters } = chainInfo;
|
2155
|
-
const { gasPerByte
|
2071
|
+
const { gasPerByte } = consensusParameters;
|
2156
2072
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2157
2073
|
(acc, wit) => acc + wit.dataLength,
|
2158
2074
|
0
|
@@ -2161,8 +2077,7 @@ var BaseTransactionRequest = class {
|
|
2161
2077
|
gasPerByte,
|
2162
2078
|
minGas,
|
2163
2079
|
witnessesLength,
|
2164
|
-
witnessLimit: this.witnessLimit
|
2165
|
-
maxGasPerTx
|
2080
|
+
witnessLimit: this.witnessLimit
|
2166
2081
|
});
|
2167
2082
|
}
|
2168
2083
|
/**
|
@@ -2180,20 +2095,17 @@ var BaseTransactionRequest = class {
|
|
2180
2095
|
});
|
2181
2096
|
const updateAssetInput = (assetId, quantity) => {
|
2182
2097
|
const assetInput = findAssetInput(assetId);
|
2183
|
-
let usedQuantity = quantity;
|
2184
|
-
if (assetId === BaseAssetId2) {
|
2185
|
-
usedQuantity = bn7("1000000000000000000");
|
2186
|
-
}
|
2187
2098
|
if (assetInput && "assetId" in assetInput) {
|
2188
|
-
assetInput.id = hexlify7(randomBytes(
|
2189
|
-
assetInput.amount =
|
2099
|
+
assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
|
2100
|
+
assetInput.amount = quantity;
|
2190
2101
|
} else {
|
2191
2102
|
this.addResources([
|
2192
2103
|
{
|
2193
|
-
id: hexlify7(randomBytes(
|
2194
|
-
amount:
|
2104
|
+
id: hexlify7(randomBytes(UTXO_ID_LEN2)),
|
2105
|
+
amount: quantity,
|
2195
2106
|
assetId,
|
2196
2107
|
owner: resourcesOwner || Address.fromRandom(),
|
2108
|
+
maturity: 0,
|
2197
2109
|
blockCreated: bn7(1),
|
2198
2110
|
txCreatedIdx: bn7(1)
|
2199
2111
|
}
|
@@ -2225,7 +2137,7 @@ var BaseTransactionRequest = class {
|
|
2225
2137
|
toJSON() {
|
2226
2138
|
return normalizeJSON(this);
|
2227
2139
|
}
|
2228
|
-
|
2140
|
+
updatePredicateInputs(inputs) {
|
2229
2141
|
this.inputs.forEach((i) => {
|
2230
2142
|
let correspondingInput;
|
2231
2143
|
switch (i.type) {
|
@@ -2247,15 +2159,6 @@ var BaseTransactionRequest = class {
|
|
2247
2159
|
}
|
2248
2160
|
});
|
2249
2161
|
}
|
2250
|
-
shiftPredicateData() {
|
2251
|
-
this.inputs.forEach((input) => {
|
2252
|
-
if ("predicateData" in input && "paddPredicateData" in input && typeof input.paddPredicateData === "function") {
|
2253
|
-
input.predicateData = input.paddPredicateData(
|
2254
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2255
|
-
);
|
2256
|
-
}
|
2257
|
-
});
|
2258
|
-
}
|
2259
2162
|
};
|
2260
2163
|
|
2261
2164
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2402,8 +2305,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2402
2305
|
return {
|
2403
2306
|
type: TransactionType3.Create,
|
2404
2307
|
...baseTransaction,
|
2308
|
+
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2405
2309
|
bytecodeWitnessIndex,
|
2406
|
-
storageSlotsCount:
|
2310
|
+
storageSlotsCount: storageSlots.length,
|
2407
2311
|
salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
|
2408
2312
|
storageSlots
|
2409
2313
|
};
|
@@ -2526,8 +2430,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2526
2430
|
type: TransactionType4.Script,
|
2527
2431
|
scriptGasLimit: this.gasLimit,
|
2528
2432
|
...super.getBaseTransaction(),
|
2529
|
-
scriptLength:
|
2530
|
-
scriptDataLength:
|
2433
|
+
scriptLength: script.length,
|
2434
|
+
scriptDataLength: scriptData.length,
|
2531
2435
|
receiptsRoot: ZeroBytes327,
|
2532
2436
|
script: hexlify10(script),
|
2533
2437
|
scriptData: hexlify10(scriptData)
|
@@ -2591,7 +2495,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2591
2495
|
}
|
2592
2496
|
calculateMaxGas(chainInfo, minGas) {
|
2593
2497
|
const { consensusParameters } = chainInfo;
|
2594
|
-
const { gasPerByte
|
2498
|
+
const { gasPerByte } = consensusParameters;
|
2595
2499
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2596
2500
|
(acc, wit) => acc + wit.dataLength,
|
2597
2501
|
0
|
@@ -2601,8 +2505,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2601
2505
|
minGas,
|
2602
2506
|
witnessesLength,
|
2603
2507
|
witnessLimit: this.witnessLimit,
|
2604
|
-
gasLimit: this.gasLimit
|
2605
|
-
maxGasPerTx
|
2508
|
+
gasLimit: this.gasLimit
|
2606
2509
|
});
|
2607
2510
|
}
|
2608
2511
|
/**
|
@@ -2659,7 +2562,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2659
2562
|
|
2660
2563
|
// src/providers/transaction-request/utils.ts
|
2661
2564
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2662
|
-
import { TransactionType as TransactionType5
|
2565
|
+
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2663
2566
|
var transactionRequestify = (obj) => {
|
2664
2567
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2665
2568
|
return obj;
|
@@ -2677,31 +2580,14 @@ var transactionRequestify = (obj) => {
|
|
2677
2580
|
}
|
2678
2581
|
}
|
2679
2582
|
};
|
2680
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2681
|
-
(acc, input) => {
|
2682
|
-
if (input.type === InputType5.Coin && input.owner === owner) {
|
2683
|
-
acc.utxos.push(input.id);
|
2684
|
-
}
|
2685
|
-
if (input.type === InputType5.Message && input.recipient === owner) {
|
2686
|
-
acc.messages.push(input.nonce);
|
2687
|
-
}
|
2688
|
-
return acc;
|
2689
|
-
},
|
2690
|
-
{
|
2691
|
-
utxos: [],
|
2692
|
-
messages: []
|
2693
|
-
}
|
2694
|
-
);
|
2695
2583
|
|
2696
2584
|
// src/providers/transaction-response/transaction-response.ts
|
2697
2585
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2698
|
-
import { bn as
|
2586
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
2699
2587
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2700
2588
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2701
2589
|
|
2702
2590
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2703
|
-
import { bn as bn14 } from "@fuel-ts/math";
|
2704
|
-
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2705
2591
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2706
2592
|
|
2707
2593
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
@@ -2710,10 +2596,9 @@ import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, Trans
|
|
2710
2596
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2711
2597
|
var calculateTransactionFee = (params) => {
|
2712
2598
|
const {
|
2713
|
-
|
2599
|
+
gasUsed,
|
2714
2600
|
rawPayload,
|
2715
|
-
|
2716
|
-
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2601
|
+
consensusParameters: { gasCosts, feeParams }
|
2717
2602
|
} = params;
|
2718
2603
|
const gasPerByte = bn11(feeParams.gasPerByte);
|
2719
2604
|
const gasPriceFactor = bn11(feeParams.gasPriceFactor);
|
@@ -2723,7 +2608,8 @@ var calculateTransactionFee = (params) => {
|
|
2723
2608
|
return {
|
2724
2609
|
fee: bn11(0),
|
2725
2610
|
minFee: bn11(0),
|
2726
|
-
maxFee: bn11(0)
|
2611
|
+
maxFee: bn11(0),
|
2612
|
+
feeFromGasUsed: bn11(0)
|
2727
2613
|
};
|
2728
2614
|
}
|
2729
2615
|
const { type, witnesses, inputs, policies } = transaction;
|
@@ -2755,6 +2641,7 @@ var calculateTransactionFee = (params) => {
|
|
2755
2641
|
metadataGas,
|
2756
2642
|
txBytesSize: transactionBytes.length
|
2757
2643
|
});
|
2644
|
+
const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
|
2758
2645
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
|
2759
2646
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2760
2647
|
const maxGas = getMaxGas({
|
@@ -2762,25 +2649,17 @@ var calculateTransactionFee = (params) => {
|
|
2762
2649
|
minGas,
|
2763
2650
|
witnessesLength,
|
2764
2651
|
gasLimit,
|
2765
|
-
witnessLimit
|
2766
|
-
maxGasPerTx
|
2767
|
-
});
|
2768
|
-
const minFee = calculateGasFee({
|
2769
|
-
gasPrice,
|
2770
|
-
gas: minGas,
|
2771
|
-
priceFactor: gasPriceFactor,
|
2772
|
-
tip
|
2773
|
-
});
|
2774
|
-
const maxFee = calculateGasFee({
|
2775
|
-
gasPrice,
|
2776
|
-
gas: maxGas,
|
2777
|
-
priceFactor: gasPriceFactor,
|
2778
|
-
tip
|
2652
|
+
witnessLimit
|
2779
2653
|
});
|
2654
|
+
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
2655
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
2656
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
2657
|
+
const fee = minFee.add(feeFromGasUsed);
|
2780
2658
|
return {
|
2659
|
+
fee,
|
2781
2660
|
minFee,
|
2782
2661
|
maxFee,
|
2783
|
-
|
2662
|
+
feeFromGasUsed
|
2784
2663
|
};
|
2785
2664
|
};
|
2786
2665
|
|
@@ -2836,7 +2715,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2836
2715
|
|
2837
2716
|
// src/providers/transaction-summary/input.ts
|
2838
2717
|
import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2839
|
-
import { InputType as
|
2718
|
+
import { InputType as InputType5 } from "@fuel-ts/transactions";
|
2840
2719
|
function getInputsByTypes(inputs, types) {
|
2841
2720
|
return inputs.filter((i) => types.includes(i.type));
|
2842
2721
|
}
|
@@ -2844,16 +2723,16 @@ function getInputsByType(inputs, type) {
|
|
2844
2723
|
return inputs.filter((i) => i.type === type);
|
2845
2724
|
}
|
2846
2725
|
function getInputsCoin(inputs) {
|
2847
|
-
return getInputsByType(inputs,
|
2726
|
+
return getInputsByType(inputs, InputType5.Coin);
|
2848
2727
|
}
|
2849
2728
|
function getInputsMessage(inputs) {
|
2850
|
-
return getInputsByType(inputs,
|
2729
|
+
return getInputsByType(inputs, InputType5.Message);
|
2851
2730
|
}
|
2852
2731
|
function getInputsCoinAndMessage(inputs) {
|
2853
|
-
return getInputsByTypes(inputs, [
|
2732
|
+
return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
|
2854
2733
|
}
|
2855
2734
|
function getInputsContract(inputs) {
|
2856
|
-
return getInputsByType(inputs,
|
2735
|
+
return getInputsByType(inputs, InputType5.Contract);
|
2857
2736
|
}
|
2858
2737
|
function getInputFromAssetId(inputs, assetId) {
|
2859
2738
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2872,7 +2751,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2872
2751
|
if (!contractInput) {
|
2873
2752
|
return void 0;
|
2874
2753
|
}
|
2875
|
-
if (contractInput.type !==
|
2754
|
+
if (contractInput.type !== InputType5.Contract) {
|
2876
2755
|
throw new FuelError9(
|
2877
2756
|
ErrorCode9.INVALID_TRANSACTION_INPUT,
|
2878
2757
|
`Contract input should be of type 'contract'.`
|
@@ -2881,10 +2760,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2881
2760
|
return contractInput;
|
2882
2761
|
}
|
2883
2762
|
function getInputAccountAddress(input) {
|
2884
|
-
if (input.type ===
|
2763
|
+
if (input.type === InputType5.Coin) {
|
2885
2764
|
return input.owner.toString();
|
2886
2765
|
}
|
2887
|
-
if (input.type ===
|
2766
|
+
if (input.type === InputType5.Message) {
|
2888
2767
|
return input.recipient.toString();
|
2889
2768
|
}
|
2890
2769
|
return "";
|
@@ -3394,9 +3273,7 @@ function assembleTransactionSummary(params) {
|
|
3394
3273
|
gqlTransactionStatus,
|
3395
3274
|
abiMap = {},
|
3396
3275
|
maxInputs,
|
3397
|
-
gasCosts
|
3398
|
-
maxGasPerTx,
|
3399
|
-
gasPrice
|
3276
|
+
gasCosts
|
3400
3277
|
} = params;
|
3401
3278
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3402
3279
|
const rawPayload = hexlify11(transactionBytes);
|
@@ -3410,14 +3287,11 @@ function assembleTransactionSummary(params) {
|
|
3410
3287
|
maxInputs
|
3411
3288
|
});
|
3412
3289
|
const typeName = getTransactionTypeName(transaction.type);
|
3413
|
-
const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3414
3290
|
const { fee } = calculateTransactionFee({
|
3415
|
-
|
3291
|
+
gasUsed,
|
3416
3292
|
rawPayload,
|
3417
|
-
tip,
|
3418
3293
|
consensusParameters: {
|
3419
3294
|
gasCosts,
|
3420
|
-
maxGasPerTx,
|
3421
3295
|
feeParams: {
|
3422
3296
|
gasPerByte,
|
3423
3297
|
gasPriceFactor
|
@@ -3477,7 +3351,7 @@ var TransactionResponse = class {
|
|
3477
3351
|
/** Current provider */
|
3478
3352
|
provider;
|
3479
3353
|
/** Gas used on the transaction */
|
3480
|
-
gasUsed =
|
3354
|
+
gasUsed = bn14(0);
|
3481
3355
|
/** The graphql Transaction with receipts object. */
|
3482
3356
|
gqlTransaction;
|
3483
3357
|
abis;
|
@@ -3555,13 +3429,8 @@ var TransactionResponse = class {
|
|
3555
3429
|
const decodedTransaction = this.decodeTransaction(
|
3556
3430
|
transaction
|
3557
3431
|
);
|
3558
|
-
|
3559
|
-
|
3560
|
-
txReceipts = transaction.status.receipts;
|
3561
|
-
}
|
3562
|
-
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3563
|
-
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3564
|
-
const gasPrice = await this.provider.getLatestGasPrice();
|
3432
|
+
const receipts = transaction.receipts?.map(processGqlReceipt) || [];
|
3433
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = this.provider.getGasConfig();
|
3565
3434
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3566
3435
|
const transactionSummary = assembleTransactionSummary({
|
3567
3436
|
id: this.id,
|
@@ -3573,9 +3442,7 @@ var TransactionResponse = class {
|
|
3573
3442
|
gasPriceFactor,
|
3574
3443
|
abiMap: contractsAbiMap,
|
3575
3444
|
maxInputs,
|
3576
|
-
gasCosts
|
3577
|
-
maxGasPerTx,
|
3578
|
-
gasPrice
|
3445
|
+
gasCosts
|
3579
3446
|
});
|
3580
3447
|
return transactionSummary;
|
3581
3448
|
}
|
@@ -3702,29 +3569,29 @@ var processGqlChain = (chain) => {
|
|
3702
3569
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3703
3570
|
return {
|
3704
3571
|
name,
|
3705
|
-
baseChainHeight:
|
3572
|
+
baseChainHeight: bn15(daHeight),
|
3706
3573
|
consensusParameters: {
|
3707
|
-
contractMaxSize:
|
3708
|
-
maxInputs:
|
3709
|
-
maxOutputs:
|
3710
|
-
maxWitnesses:
|
3711
|
-
maxGasPerTx:
|
3712
|
-
maxScriptLength:
|
3713
|
-
maxScriptDataLength:
|
3714
|
-
maxStorageSlots:
|
3715
|
-
maxPredicateLength:
|
3716
|
-
maxPredicateDataLength:
|
3717
|
-
maxGasPerPredicate:
|
3718
|
-
gasPriceFactor:
|
3719
|
-
gasPerByte:
|
3720
|
-
maxMessageDataLength:
|
3721
|
-
chainId:
|
3574
|
+
contractMaxSize: bn15(contractParams.contractMaxSize),
|
3575
|
+
maxInputs: bn15(txParams.maxInputs),
|
3576
|
+
maxOutputs: bn15(txParams.maxOutputs),
|
3577
|
+
maxWitnesses: bn15(txParams.maxWitnesses),
|
3578
|
+
maxGasPerTx: bn15(txParams.maxGasPerTx),
|
3579
|
+
maxScriptLength: bn15(scriptParams.maxScriptLength),
|
3580
|
+
maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
|
3581
|
+
maxStorageSlots: bn15(contractParams.maxStorageSlots),
|
3582
|
+
maxPredicateLength: bn15(predicateParams.maxPredicateLength),
|
3583
|
+
maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
|
3584
|
+
maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
|
3585
|
+
gasPriceFactor: bn15(feeParams.gasPriceFactor),
|
3586
|
+
gasPerByte: bn15(feeParams.gasPerByte),
|
3587
|
+
maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
|
3588
|
+
chainId: bn15(consensusParameters.chainId),
|
3722
3589
|
gasCosts
|
3723
3590
|
},
|
3724
3591
|
gasCosts,
|
3725
3592
|
latestBlock: {
|
3726
3593
|
id: latestBlock.id,
|
3727
|
-
height:
|
3594
|
+
height: bn15(latestBlock.header.height),
|
3728
3595
|
time: latestBlock.header.time,
|
3729
3596
|
transactions: latestBlock.transactions.map((i) => ({
|
3730
3597
|
id: i.id
|
@@ -3818,8 +3685,10 @@ var _Provider = class {
|
|
3818
3685
|
* Returns some helpful parameters related to gas fees.
|
3819
3686
|
*/
|
3820
3687
|
getGasConfig() {
|
3688
|
+
const { minGasPrice } = this.getNode();
|
3821
3689
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3822
3690
|
return {
|
3691
|
+
minGasPrice,
|
3823
3692
|
maxGasPerTx,
|
3824
3693
|
maxGasPerPredicate,
|
3825
3694
|
gasPriceFactor,
|
@@ -3917,7 +3786,7 @@ var _Provider = class {
|
|
3917
3786
|
*/
|
3918
3787
|
async getBlockNumber() {
|
3919
3788
|
const { chain } = await this.operations.getChain();
|
3920
|
-
return
|
3789
|
+
return bn15(chain.latestBlock.header.height, 10);
|
3921
3790
|
}
|
3922
3791
|
/**
|
3923
3792
|
* Returns the chain information.
|
@@ -3927,11 +3796,13 @@ var _Provider = class {
|
|
3927
3796
|
async fetchNode() {
|
3928
3797
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3929
3798
|
const processedNodeInfo = {
|
3930
|
-
maxDepth:
|
3931
|
-
maxTx:
|
3799
|
+
maxDepth: bn15(nodeInfo.maxDepth),
|
3800
|
+
maxTx: bn15(nodeInfo.maxTx),
|
3801
|
+
minGasPrice: bn15(nodeInfo.minGasPrice),
|
3932
3802
|
nodeVersion: nodeInfo.nodeVersion,
|
3933
3803
|
utxoValidation: nodeInfo.utxoValidation,
|
3934
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
3804
|
+
vmBacktrace: nodeInfo.vmBacktrace,
|
3805
|
+
peers: nodeInfo.peers
|
3935
3806
|
};
|
3936
3807
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
3937
3808
|
return processedNodeInfo;
|
@@ -4017,13 +3888,14 @@ var _Provider = class {
|
|
4017
3888
|
return this.estimateTxDependencies(transactionRequest);
|
4018
3889
|
}
|
4019
3890
|
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
4020
|
-
const { dryRun:
|
4021
|
-
|
3891
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3892
|
+
encodedTransaction,
|
4022
3893
|
utxoValidation: utxoValidation || false
|
4023
3894
|
});
|
4024
|
-
const
|
4025
|
-
|
4026
|
-
|
3895
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
3896
|
+
return {
|
3897
|
+
receipts
|
3898
|
+
};
|
4027
3899
|
}
|
4028
3900
|
/**
|
4029
3901
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -4049,7 +3921,7 @@ var _Provider = class {
|
|
4049
3921
|
} = response;
|
4050
3922
|
if (inputs) {
|
4051
3923
|
inputs.forEach((input, index) => {
|
4052
|
-
if ("predicateGasUsed" in input &&
|
3924
|
+
if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
|
4053
3925
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4054
3926
|
}
|
4055
3927
|
});
|
@@ -4062,6 +3934,9 @@ var _Provider = class {
|
|
4062
3934
|
* If there are missing variable outputs,
|
4063
3935
|
* `addVariableOutputs` is called on the transaction.
|
4064
3936
|
*
|
3937
|
+
* @privateRemarks
|
3938
|
+
* TODO: Investigate support for missing contract IDs
|
3939
|
+
* TODO: Add support for missing output messages
|
4065
3940
|
*
|
4066
3941
|
* @param transactionRequest - The transaction request object.
|
4067
3942
|
* @returns A promise.
|
@@ -4074,19 +3949,16 @@ var _Provider = class {
|
|
4074
3949
|
missingContractIds: []
|
4075
3950
|
};
|
4076
3951
|
}
|
3952
|
+
await this.estimatePredicates(transactionRequest);
|
4077
3953
|
let receipts = [];
|
4078
3954
|
const missingContractIds = [];
|
4079
3955
|
let outputVariables = 0;
|
4080
|
-
let dryrunStatus;
|
4081
3956
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
4082
|
-
const {
|
4083
|
-
|
4084
|
-
} = await this.operations.dryRun({
|
4085
|
-
encodedTransactions: [hexlify12(transactionRequest.toTransactionBytes())],
|
3957
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3958
|
+
encodedTransaction: hexlify12(transactionRequest.toTransactionBytes()),
|
4086
3959
|
utxoValidation: false
|
4087
3960
|
});
|
4088
|
-
receipts =
|
4089
|
-
dryrunStatus = status;
|
3961
|
+
receipts = gqlReceipts.map(processGqlReceipt);
|
4090
3962
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
4091
3963
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
4092
3964
|
if (hasMissingOutputs) {
|
@@ -4096,11 +3968,6 @@ var _Provider = class {
|
|
4096
3968
|
transactionRequest.addContractInputAndOutput(Address2.fromString(contractId));
|
4097
3969
|
missingContractIds.push(contractId);
|
4098
3970
|
});
|
4099
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
4100
|
-
transactionRequest,
|
4101
|
-
optimizeGas: false
|
4102
|
-
});
|
4103
|
-
transactionRequest.maxFee = maxFee;
|
4104
3971
|
} else {
|
4105
3972
|
break;
|
4106
3973
|
}
|
@@ -4108,133 +3975,37 @@ var _Provider = class {
|
|
4108
3975
|
return {
|
4109
3976
|
receipts,
|
4110
3977
|
outputVariables,
|
4111
|
-
missingContractIds
|
4112
|
-
dryrunStatus
|
3978
|
+
missingContractIds
|
4113
3979
|
};
|
4114
3980
|
}
|
4115
3981
|
/**
|
4116
|
-
*
|
4117
|
-
*
|
4118
|
-
*
|
4119
|
-
* further modifications are identified. The method iteratively updates these transactions
|
4120
|
-
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
4121
|
-
*
|
4122
|
-
* @param transactionRequests - Array of transaction request objects.
|
4123
|
-
* @returns A promise that resolves to an array of results for each transaction.
|
3982
|
+
* Estimates the transaction gas and fee based on the provided transaction request.
|
3983
|
+
* @param transactionRequest - The transaction request object.
|
3984
|
+
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
4124
3985
|
*/
|
4125
|
-
|
4126
|
-
const
|
4127
|
-
|
4128
|
-
outputVariables: 0,
|
4129
|
-
missingContractIds: [],
|
4130
|
-
dryrunStatus: void 0
|
4131
|
-
}));
|
4132
|
-
const allRequests = clone3(transactionRequests);
|
4133
|
-
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4134
|
-
allRequests.forEach((req, index) => {
|
4135
|
-
if (req.type === TransactionType8.Script) {
|
4136
|
-
serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
|
4137
|
-
}
|
4138
|
-
});
|
4139
|
-
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
4140
|
-
let attempt = 0;
|
4141
|
-
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
4142
|
-
const encodedTransactions = transactionsToProcess.map(
|
4143
|
-
(index) => serializedTransactionsMap.get(index)
|
4144
|
-
);
|
4145
|
-
const dryRunResults = await this.operations.dryRun({
|
4146
|
-
encodedTransactions,
|
4147
|
-
utxoValidation: false
|
4148
|
-
});
|
4149
|
-
const nextRoundTransactions = [];
|
4150
|
-
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
4151
|
-
const currentResultIndex = transactionsToProcess[i];
|
4152
|
-
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4153
|
-
results[currentResultIndex].receipts = rawReceipts.map(processGqlReceipt);
|
4154
|
-
results[currentResultIndex].dryrunStatus = status;
|
4155
|
-
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4156
|
-
results[currentResultIndex].receipts
|
4157
|
-
);
|
4158
|
-
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4159
|
-
const requestToProcess = allRequests[currentResultIndex];
|
4160
|
-
if (hasMissingOutputs && requestToProcess?.type === TransactionType8.Script) {
|
4161
|
-
results[currentResultIndex].outputVariables += missingOutputVariables.length;
|
4162
|
-
requestToProcess.addVariableOutputs(missingOutputVariables.length);
|
4163
|
-
missingOutputContractIds.forEach(({ contractId }) => {
|
4164
|
-
requestToProcess.addContractInputAndOutput(Address2.fromString(contractId));
|
4165
|
-
results[currentResultIndex].missingContractIds.push(contractId);
|
4166
|
-
});
|
4167
|
-
const { maxFee } = await this.estimateTxGasAndFee({
|
4168
|
-
transactionRequest: requestToProcess,
|
4169
|
-
optimizeGas: false
|
4170
|
-
});
|
4171
|
-
requestToProcess.maxFee = maxFee;
|
4172
|
-
serializedTransactionsMap.set(
|
4173
|
-
currentResultIndex,
|
4174
|
-
hexlify12(requestToProcess.toTransactionBytes())
|
4175
|
-
);
|
4176
|
-
nextRoundTransactions.push(currentResultIndex);
|
4177
|
-
allRequests[currentResultIndex] = requestToProcess;
|
4178
|
-
}
|
4179
|
-
}
|
4180
|
-
transactionsToProcess = nextRoundTransactions;
|
4181
|
-
attempt += 1;
|
4182
|
-
}
|
4183
|
-
return results;
|
4184
|
-
}
|
4185
|
-
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
4186
|
-
if (estimateTxDependencies) {
|
4187
|
-
return this.estimateMultipleTxDependencies(transactionRequests);
|
4188
|
-
}
|
4189
|
-
const encodedTransactions = transactionRequests.map((tx) => hexlify12(tx.toTransactionBytes()));
|
4190
|
-
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4191
|
-
encodedTransactions,
|
4192
|
-
utxoValidation: utxoValidation || false
|
4193
|
-
});
|
4194
|
-
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4195
|
-
const receipts = rawReceipts.map(processGqlReceipt);
|
4196
|
-
return { receipts, dryrunStatus: status };
|
4197
|
-
});
|
4198
|
-
return results;
|
4199
|
-
}
|
4200
|
-
async estimateTxGasAndFee(params) {
|
4201
|
-
const { transactionRequest, optimizeGas = true } = params;
|
4202
|
-
let { gasPrice } = params;
|
3986
|
+
estimateTxGasAndFee(params) {
|
3987
|
+
const { transactionRequest } = params;
|
3988
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
4203
3989
|
const chainInfo = this.getChain();
|
4204
|
-
const
|
3990
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
3991
|
+
transactionRequest.gasPrice = gasPrice;
|
4205
3992
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
4206
|
-
|
4207
|
-
gasPrice = await this.estimateGasPrice(10);
|
4208
|
-
}
|
4209
|
-
const minFee = calculateGasFee({
|
4210
|
-
gasPrice: bn16(gasPrice),
|
4211
|
-
gas: minGas,
|
4212
|
-
priceFactor: gasPriceFactor,
|
4213
|
-
tip: transactionRequest.tip
|
4214
|
-
}).add(1);
|
4215
|
-
let gasLimit = bn16(0);
|
3993
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4216
3994
|
if (transactionRequest.type === TransactionType8.Script) {
|
4217
|
-
|
4218
|
-
if (!optimizeGas) {
|
3995
|
+
if (transactionRequest.gasLimit.eq(0)) {
|
4219
3996
|
transactionRequest.gasLimit = minGas;
|
4220
|
-
gasLimit =
|
4221
|
-
|
3997
|
+
transactionRequest.gasLimit = maxGasPerTx.sub(
|
3998
|
+
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
3999
|
+
);
|
4222
4000
|
}
|
4223
4001
|
}
|
4224
4002
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4225
|
-
const maxFee =
|
4226
|
-
gasPrice: bn16(gasPrice),
|
4227
|
-
gas: maxGas,
|
4228
|
-
priceFactor: gasPriceFactor,
|
4229
|
-
tip: transactionRequest.tip
|
4230
|
-
}).add(1);
|
4003
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
4231
4004
|
return {
|
4232
4005
|
minGas,
|
4233
4006
|
minFee,
|
4234
4007
|
maxGas,
|
4235
|
-
maxFee
|
4236
|
-
gasPrice,
|
4237
|
-
gasLimit
|
4008
|
+
maxFee
|
4238
4009
|
};
|
4239
4010
|
}
|
4240
4011
|
/**
|
@@ -4252,17 +4023,15 @@ var _Provider = class {
|
|
4252
4023
|
if (estimateTxDependencies) {
|
4253
4024
|
return this.estimateTxDependencies(transactionRequest);
|
4254
4025
|
}
|
4255
|
-
const
|
4256
|
-
const { dryRun:
|
4257
|
-
|
4026
|
+
const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
|
4027
|
+
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
4028
|
+
encodedTransaction,
|
4258
4029
|
utxoValidation: true
|
4259
4030
|
});
|
4260
|
-
const
|
4261
|
-
|
4262
|
-
|
4263
|
-
|
4264
|
-
});
|
4265
|
-
return { receipts: callResult[0].receipts };
|
4031
|
+
const receipts = gqlReceipts.map(processGqlReceipt);
|
4032
|
+
return {
|
4033
|
+
receipts
|
4034
|
+
};
|
4266
4035
|
}
|
4267
4036
|
/**
|
4268
4037
|
* Returns a transaction cost to enable user
|
@@ -4279,80 +4048,77 @@ var _Provider = class {
|
|
4279
4048
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
4280
4049
|
* @returns A promise that resolves to the transaction cost object.
|
4281
4050
|
*/
|
4282
|
-
async getTransactionCost(transactionRequestLike,
|
4051
|
+
async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
|
4052
|
+
estimateTxDependencies = true,
|
4053
|
+
estimatePredicates = true,
|
4054
|
+
resourcesOwner,
|
4055
|
+
signatureCallback
|
4056
|
+
} = {}) {
|
4283
4057
|
const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
|
4058
|
+
const { minGasPrice } = this.getGasConfig();
|
4059
|
+
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
4284
4060
|
const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
|
4285
4061
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4286
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
4062
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
4287
4063
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
4288
|
-
txRequestClone.maxFee = bn16(0);
|
4289
4064
|
if (isScriptTransaction) {
|
4290
|
-
txRequestClone.gasLimit =
|
4065
|
+
txRequestClone.gasLimit = bn15(0);
|
4291
4066
|
}
|
4292
|
-
if (
|
4293
|
-
resourcesOwner
|
4067
|
+
if (estimatePredicates) {
|
4068
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4069
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
4070
|
+
}
|
4071
|
+
await this.estimatePredicates(txRequestClone);
|
4294
4072
|
}
|
4295
|
-
const signedRequest = clone3(txRequestClone);
|
4296
|
-
let addedSignatures = 0;
|
4297
4073
|
if (signatureCallback && isScriptTransaction) {
|
4298
|
-
|
4299
|
-
|
4300
|
-
|
4301
|
-
|
4302
|
-
await this.estimatePredicates(signedRequest);
|
4303
|
-
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
4304
|
-
transactionRequest: signedRequest,
|
4305
|
-
optimizeGas: false
|
4074
|
+
await signatureCallback(txRequestClone);
|
4075
|
+
}
|
4076
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
4077
|
+
transactionRequest: txRequestClone
|
4306
4078
|
});
|
4307
|
-
txRequestClone.maxFee = maxFee;
|
4308
4079
|
let receipts = [];
|
4309
4080
|
let missingContractIds = [];
|
4310
4081
|
let outputVariables = 0;
|
4311
|
-
let gasUsed =
|
4312
|
-
|
4313
|
-
|
4314
|
-
if (signatureCallback) {
|
4315
|
-
await signatureCallback(txRequestClone);
|
4316
|
-
}
|
4317
|
-
txRequestClone.gasLimit = gasLimit;
|
4082
|
+
let gasUsed = bn15(0);
|
4083
|
+
if (isScriptTransaction && estimateTxDependencies) {
|
4084
|
+
txRequestClone.gasPrice = bn15(0);
|
4318
4085
|
const result = await this.estimateTxDependencies(txRequestClone);
|
4319
4086
|
receipts = result.receipts;
|
4320
4087
|
outputVariables = result.outputVariables;
|
4321
4088
|
missingContractIds = result.missingContractIds;
|
4322
|
-
gasUsed = getGasUsedFromReceipts(receipts);
|
4089
|
+
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4323
4090
|
txRequestClone.gasLimit = gasUsed;
|
4324
|
-
|
4325
|
-
|
4326
|
-
|
4091
|
+
txRequestClone.gasPrice = setGasPrice;
|
4092
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
4093
|
+
transactionRequest: txRequestClone
|
4327
4094
|
}));
|
4328
4095
|
}
|
4329
4096
|
return {
|
4330
4097
|
requiredQuantities: allQuantities,
|
4331
4098
|
receipts,
|
4332
4099
|
gasUsed,
|
4333
|
-
|
4100
|
+
minGasPrice,
|
4101
|
+
gasPrice: setGasPrice,
|
4334
4102
|
minGas,
|
4335
4103
|
maxGas,
|
4336
4104
|
minFee,
|
4337
4105
|
maxFee,
|
4106
|
+
estimatedInputs: txRequestClone.inputs,
|
4338
4107
|
outputVariables,
|
4339
|
-
missingContractIds
|
4340
|
-
addedSignatures,
|
4341
|
-
estimatedPredicates: txRequestClone.inputs
|
4108
|
+
missingContractIds
|
4342
4109
|
};
|
4343
4110
|
}
|
4344
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
4111
|
+
async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
|
4345
4112
|
const ownerAddress = Address2.fromAddressOrString(owner);
|
4346
4113
|
const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
|
4347
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
4348
|
-
quantitiesToContract
|
4349
|
-
});
|
4114
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, forwardingQuantities);
|
4350
4115
|
transactionRequest.addResources(
|
4351
4116
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
4352
4117
|
);
|
4353
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4354
|
-
|
4355
|
-
|
4118
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4119
|
+
transactionRequest,
|
4120
|
+
forwardingQuantities
|
4121
|
+
);
|
4356
4122
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
4357
4123
|
return {
|
4358
4124
|
resources,
|
@@ -4374,10 +4140,11 @@ var _Provider = class {
|
|
4374
4140
|
return coins.map((coin) => ({
|
4375
4141
|
id: coin.utxoId,
|
4376
4142
|
assetId: coin.assetId,
|
4377
|
-
amount:
|
4143
|
+
amount: bn15(coin.amount),
|
4378
4144
|
owner: Address2.fromAddressOrString(coin.owner),
|
4379
|
-
|
4380
|
-
|
4145
|
+
maturity: bn15(coin.maturity).toNumber(),
|
4146
|
+
blockCreated: bn15(coin.blockCreated),
|
4147
|
+
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4381
4148
|
}));
|
4382
4149
|
}
|
4383
4150
|
/**
|
@@ -4414,9 +4181,9 @@ var _Provider = class {
|
|
4414
4181
|
switch (coin.__typename) {
|
4415
4182
|
case "MessageCoin":
|
4416
4183
|
return {
|
4417
|
-
amount:
|
4184
|
+
amount: bn15(coin.amount),
|
4418
4185
|
assetId: coin.assetId,
|
4419
|
-
daHeight:
|
4186
|
+
daHeight: bn15(coin.daHeight),
|
4420
4187
|
sender: Address2.fromAddressOrString(coin.sender),
|
4421
4188
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4422
4189
|
nonce: coin.nonce
|
@@ -4424,11 +4191,12 @@ var _Provider = class {
|
|
4424
4191
|
case "Coin":
|
4425
4192
|
return {
|
4426
4193
|
id: coin.utxoId,
|
4427
|
-
amount:
|
4194
|
+
amount: bn15(coin.amount),
|
4428
4195
|
assetId: coin.assetId,
|
4429
4196
|
owner: Address2.fromAddressOrString(coin.owner),
|
4430
|
-
|
4431
|
-
|
4197
|
+
maturity: bn15(coin.maturity).toNumber(),
|
4198
|
+
blockCreated: bn15(coin.blockCreated),
|
4199
|
+
txCreatedIdx: bn15(coin.txCreatedIdx)
|
4432
4200
|
};
|
4433
4201
|
default:
|
4434
4202
|
return null;
|
@@ -4445,13 +4213,13 @@ var _Provider = class {
|
|
4445
4213
|
async getBlock(idOrHeight) {
|
4446
4214
|
let variables;
|
4447
4215
|
if (typeof idOrHeight === "number") {
|
4448
|
-
variables = { height:
|
4216
|
+
variables = { height: bn15(idOrHeight).toString(10) };
|
4449
4217
|
} else if (idOrHeight === "latest") {
|
4450
4218
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4451
4219
|
} else if (idOrHeight.length === 66) {
|
4452
4220
|
variables = { blockId: idOrHeight };
|
4453
4221
|
} else {
|
4454
|
-
variables = { blockId:
|
4222
|
+
variables = { blockId: bn15(idOrHeight).toString(10) };
|
4455
4223
|
}
|
4456
4224
|
const { block } = await this.operations.getBlock(variables);
|
4457
4225
|
if (!block) {
|
@@ -4459,7 +4227,7 @@ var _Provider = class {
|
|
4459
4227
|
}
|
4460
4228
|
return {
|
4461
4229
|
id: block.id,
|
4462
|
-
height:
|
4230
|
+
height: bn15(block.header.height),
|
4463
4231
|
time: block.header.time,
|
4464
4232
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4465
4233
|
};
|
@@ -4474,7 +4242,7 @@ var _Provider = class {
|
|
4474
4242
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4475
4243
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4476
4244
|
id: block.id,
|
4477
|
-
height:
|
4245
|
+
height: bn15(block.header.height),
|
4478
4246
|
time: block.header.time,
|
4479
4247
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4480
4248
|
}));
|
@@ -4489,7 +4257,7 @@ var _Provider = class {
|
|
4489
4257
|
async getBlockWithTransactions(idOrHeight) {
|
4490
4258
|
let variables;
|
4491
4259
|
if (typeof idOrHeight === "number") {
|
4492
|
-
variables = { blockHeight:
|
4260
|
+
variables = { blockHeight: bn15(idOrHeight).toString(10) };
|
4493
4261
|
} else if (idOrHeight === "latest") {
|
4494
4262
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4495
4263
|
} else {
|
@@ -4501,7 +4269,7 @@ var _Provider = class {
|
|
4501
4269
|
}
|
4502
4270
|
return {
|
4503
4271
|
id: block.id,
|
4504
|
-
height:
|
4272
|
+
height: bn15(block.header.height, 10),
|
4505
4273
|
time: block.header.time,
|
4506
4274
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4507
4275
|
transactions: block.transactions.map(
|
@@ -4550,7 +4318,7 @@ var _Provider = class {
|
|
4550
4318
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4551
4319
|
asset: hexlify12(assetId)
|
4552
4320
|
});
|
4553
|
-
return
|
4321
|
+
return bn15(contractBalance.amount, 10);
|
4554
4322
|
}
|
4555
4323
|
/**
|
4556
4324
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4564,7 +4332,7 @@ var _Provider = class {
|
|
4564
4332
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4565
4333
|
assetId: hexlify12(assetId)
|
4566
4334
|
});
|
4567
|
-
return
|
4335
|
+
return bn15(balance.amount, 10);
|
4568
4336
|
}
|
4569
4337
|
/**
|
4570
4338
|
* Returns balances for the given owner.
|
@@ -4582,7 +4350,7 @@ var _Provider = class {
|
|
4582
4350
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4583
4351
|
return balances.map((balance) => ({
|
4584
4352
|
assetId: balance.assetId,
|
4585
|
-
amount:
|
4353
|
+
amount: bn15(balance.amount)
|
4586
4354
|
}));
|
4587
4355
|
}
|
4588
4356
|
/**
|
@@ -4604,15 +4372,15 @@ var _Provider = class {
|
|
4604
4372
|
sender: message.sender,
|
4605
4373
|
recipient: message.recipient,
|
4606
4374
|
nonce: message.nonce,
|
4607
|
-
amount:
|
4375
|
+
amount: bn15(message.amount),
|
4608
4376
|
data: message.data
|
4609
4377
|
}),
|
4610
4378
|
sender: Address2.fromAddressOrString(message.sender),
|
4611
4379
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4612
4380
|
nonce: message.nonce,
|
4613
|
-
amount:
|
4381
|
+
amount: bn15(message.amount),
|
4614
4382
|
data: InputMessageCoder.decodeData(message.data),
|
4615
|
-
daHeight:
|
4383
|
+
daHeight: bn15(message.daHeight)
|
4616
4384
|
}));
|
4617
4385
|
}
|
4618
4386
|
/**
|
@@ -4665,60 +4433,44 @@ var _Provider = class {
|
|
4665
4433
|
} = result.messageProof;
|
4666
4434
|
return {
|
4667
4435
|
messageProof: {
|
4668
|
-
proofIndex:
|
4436
|
+
proofIndex: bn15(messageProof.proofIndex),
|
4669
4437
|
proofSet: messageProof.proofSet
|
4670
4438
|
},
|
4671
4439
|
blockProof: {
|
4672
|
-
proofIndex:
|
4440
|
+
proofIndex: bn15(blockProof.proofIndex),
|
4673
4441
|
proofSet: blockProof.proofSet
|
4674
4442
|
},
|
4675
4443
|
messageBlockHeader: {
|
4676
4444
|
id: messageBlockHeader.id,
|
4677
|
-
daHeight:
|
4678
|
-
transactionsCount:
|
4445
|
+
daHeight: bn15(messageBlockHeader.daHeight),
|
4446
|
+
transactionsCount: bn15(messageBlockHeader.transactionsCount),
|
4679
4447
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4680
|
-
height:
|
4448
|
+
height: bn15(messageBlockHeader.height),
|
4681
4449
|
prevRoot: messageBlockHeader.prevRoot,
|
4682
4450
|
time: messageBlockHeader.time,
|
4683
4451
|
applicationHash: messageBlockHeader.applicationHash,
|
4684
|
-
|
4685
|
-
|
4686
|
-
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4687
|
-
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4688
|
-
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4452
|
+
messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
|
4453
|
+
messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
|
4689
4454
|
},
|
4690
4455
|
commitBlockHeader: {
|
4691
4456
|
id: commitBlockHeader.id,
|
4692
|
-
daHeight:
|
4693
|
-
transactionsCount:
|
4457
|
+
daHeight: bn15(commitBlockHeader.daHeight),
|
4458
|
+
transactionsCount: bn15(commitBlockHeader.transactionsCount),
|
4694
4459
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4695
|
-
height:
|
4460
|
+
height: bn15(commitBlockHeader.height),
|
4696
4461
|
prevRoot: commitBlockHeader.prevRoot,
|
4697
4462
|
time: commitBlockHeader.time,
|
4698
4463
|
applicationHash: commitBlockHeader.applicationHash,
|
4699
|
-
|
4700
|
-
|
4701
|
-
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4702
|
-
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4703
|
-
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4464
|
+
messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
|
4465
|
+
messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
|
4704
4466
|
},
|
4705
4467
|
sender: Address2.fromAddressOrString(sender),
|
4706
4468
|
recipient: Address2.fromAddressOrString(recipient),
|
4707
4469
|
nonce,
|
4708
|
-
amount:
|
4470
|
+
amount: bn15(amount),
|
4709
4471
|
data
|
4710
4472
|
};
|
4711
4473
|
}
|
4712
|
-
async getLatestGasPrice() {
|
4713
|
-
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4714
|
-
return bn16(latestGasPrice.gasPrice);
|
4715
|
-
}
|
4716
|
-
async estimateGasPrice(blockHorizon) {
|
4717
|
-
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4718
|
-
blockHorizon: String(blockHorizon)
|
4719
|
-
});
|
4720
|
-
return bn16(estimateGasPrice.gasPrice);
|
4721
|
-
}
|
4722
4474
|
/**
|
4723
4475
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
4724
4476
|
*
|
@@ -4738,10 +4490,10 @@ var _Provider = class {
|
|
4738
4490
|
*/
|
4739
4491
|
async produceBlocks(amount, startTime) {
|
4740
4492
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4741
|
-
blocksToProduce:
|
4493
|
+
blocksToProduce: bn15(amount).toString(10),
|
4742
4494
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4743
4495
|
});
|
4744
|
-
return
|
4496
|
+
return bn15(latestBlockHeight);
|
4745
4497
|
}
|
4746
4498
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4747
4499
|
async getTransactionResponse(transactionId) {
|
@@ -4755,7 +4507,7 @@ cacheInputs_fn = function(inputs) {
|
|
4755
4507
|
return;
|
4756
4508
|
}
|
4757
4509
|
inputs.forEach((input) => {
|
4758
|
-
if (input.type ===
|
4510
|
+
if (input.type === InputType6.Coin) {
|
4759
4511
|
this.cache?.set(input.id);
|
4760
4512
|
}
|
4761
4513
|
});
|
@@ -4765,7 +4517,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4765
4517
|
|
4766
4518
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4767
4519
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4768
|
-
import { bn as
|
4520
|
+
import { bn as bn16 } from "@fuel-ts/math";
|
4769
4521
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4770
4522
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4771
4523
|
async function getTransactionSummary(params) {
|
@@ -4783,28 +4535,21 @@ async function getTransactionSummary(params) {
|
|
4783
4535
|
arrayify12(gqlTransaction.rawPayload),
|
4784
4536
|
0
|
4785
4537
|
);
|
4786
|
-
|
4787
|
-
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
4788
|
-
txReceipts = gqlTransaction.status.receipts;
|
4789
|
-
}
|
4790
|
-
const receipts = txReceipts.map(processGqlReceipt);
|
4538
|
+
const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
|
4791
4539
|
const {
|
4792
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts
|
4540
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
4793
4541
|
} = provider.getChain();
|
4794
|
-
const gasPrice = await provider.getLatestGasPrice();
|
4795
4542
|
const transactionInfo = assembleTransactionSummary({
|
4796
4543
|
id: gqlTransaction.id,
|
4797
4544
|
receipts,
|
4798
4545
|
transaction: decodedTransaction,
|
4799
4546
|
transactionBytes: arrayify12(gqlTransaction.rawPayload),
|
4800
4547
|
gqlTransactionStatus: gqlTransaction.status,
|
4801
|
-
gasPerByte:
|
4802
|
-
gasPriceFactor:
|
4548
|
+
gasPerByte: bn16(gasPerByte),
|
4549
|
+
gasPriceFactor: bn16(gasPriceFactor),
|
4803
4550
|
abiMap,
|
4804
4551
|
maxInputs,
|
4805
|
-
gasCosts
|
4806
|
-
maxGasPerTx,
|
4807
|
-
gasPrice
|
4552
|
+
gasCosts
|
4808
4553
|
});
|
4809
4554
|
return {
|
4810
4555
|
gqlTransaction,
|
@@ -4814,11 +4559,10 @@ async function getTransactionSummary(params) {
|
|
4814
4559
|
async function getTransactionSummaryFromRequest(params) {
|
4815
4560
|
const { provider, transactionRequest, abiMap } = params;
|
4816
4561
|
const { receipts } = await provider.call(transactionRequest);
|
4817
|
-
const { gasPerByte, gasPriceFactor, gasCosts
|
4562
|
+
const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
|
4818
4563
|
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
4819
4564
|
const transaction = transactionRequest.toTransaction();
|
4820
4565
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
4821
|
-
const gasPrice = await provider.getLatestGasPrice();
|
4822
4566
|
const transactionSummary = assembleTransactionSummary({
|
4823
4567
|
receipts,
|
4824
4568
|
transaction,
|
@@ -4827,9 +4571,7 @@ async function getTransactionSummaryFromRequest(params) {
|
|
4827
4571
|
gasPerByte,
|
4828
4572
|
gasPriceFactor,
|
4829
4573
|
maxInputs,
|
4830
|
-
gasCosts
|
4831
|
-
maxGasPerTx,
|
4832
|
-
gasPrice
|
4574
|
+
gasCosts
|
4833
4575
|
});
|
4834
4576
|
return transactionSummary;
|
4835
4577
|
}
|
@@ -4838,18 +4580,13 @@ async function getTransactionsSummaries(params) {
|
|
4838
4580
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
4839
4581
|
const { edges, pageInfo } = transactionsByOwner;
|
4840
4582
|
const {
|
4841
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts
|
4583
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
4842
4584
|
} = provider.getChain();
|
4843
|
-
const gasPrice = await provider.getLatestGasPrice();
|
4844
4585
|
const transactions = edges.map((edge) => {
|
4845
4586
|
const { node: gqlTransaction } = edge;
|
4846
|
-
const { id, rawPayload, status } = gqlTransaction;
|
4587
|
+
const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
|
4847
4588
|
const [decodedTransaction] = new TransactionCoder6().decode(arrayify12(rawPayload), 0);
|
4848
|
-
|
4849
|
-
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
4850
|
-
txReceipts = gqlTransaction.status.receipts;
|
4851
|
-
}
|
4852
|
-
const receipts = txReceipts.map(processGqlReceipt);
|
4589
|
+
const receipts = gqlReceipts?.map(processGqlReceipt) || [];
|
4853
4590
|
const transactionSummary = assembleTransactionSummary({
|
4854
4591
|
id,
|
4855
4592
|
receipts,
|
@@ -4860,9 +4597,7 @@ async function getTransactionsSummaries(params) {
|
|
4860
4597
|
gasPerByte,
|
4861
4598
|
gasPriceFactor,
|
4862
4599
|
maxInputs,
|
4863
|
-
gasCosts
|
4864
|
-
maxGasPerTx,
|
4865
|
-
gasPrice
|
4600
|
+
gasCosts
|
4866
4601
|
});
|
4867
4602
|
const output = {
|
4868
4603
|
gqlTransaction,
|
@@ -5194,33 +4929,36 @@ var Account = class extends AbstractAccount {
|
|
5194
4929
|
* @param fee - The estimated transaction fee.
|
5195
4930
|
* @returns A promise that resolves when the resources are added to the transaction.
|
5196
4931
|
*/
|
5197
|
-
async fund(request,
|
5198
|
-
const
|
5199
|
-
|
5200
|
-
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5201
|
-
amount: bn18(fee),
|
4932
|
+
async fund(request, coinQuantities, fee) {
|
4933
|
+
const updatedQuantities = addAmountToAsset({
|
4934
|
+
amount: bn17(fee),
|
5202
4935
|
assetId: BaseAssetId3,
|
5203
|
-
coinQuantities
|
4936
|
+
coinQuantities
|
5204
4937
|
});
|
5205
4938
|
const quantitiesDict = {};
|
5206
|
-
|
4939
|
+
updatedQuantities.forEach(({ amount, assetId }) => {
|
5207
4940
|
quantitiesDict[assetId] = {
|
5208
4941
|
required: amount,
|
5209
|
-
owned:
|
4942
|
+
owned: bn17(0)
|
5210
4943
|
};
|
5211
4944
|
});
|
5212
|
-
|
4945
|
+
const cachedUtxos = [];
|
4946
|
+
const cachedMessages = [];
|
4947
|
+
const owner = this.address.toB256();
|
4948
|
+
request.inputs.forEach((input) => {
|
5213
4949
|
const isResource = "amount" in input;
|
5214
4950
|
if (isResource) {
|
5215
4951
|
const isCoin2 = "owner" in input;
|
5216
4952
|
if (isCoin2) {
|
5217
4953
|
const assetId = String(input.assetId);
|
5218
|
-
if (quantitiesDict[assetId]) {
|
5219
|
-
const amount =
|
4954
|
+
if (input.owner === owner && quantitiesDict[assetId]) {
|
4955
|
+
const amount = bn17(input.amount);
|
5220
4956
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4957
|
+
cachedUtxos.push(input.id);
|
5221
4958
|
}
|
5222
|
-
} else if (input.amount && quantitiesDict[BaseAssetId3]) {
|
4959
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId3]) {
|
5223
4960
|
quantitiesDict[BaseAssetId3].owned = quantitiesDict[BaseAssetId3].owned.add(input.amount);
|
4961
|
+
cachedMessages.push(input.nonce);
|
5224
4962
|
}
|
5225
4963
|
}
|
5226
4964
|
});
|
@@ -5235,23 +4973,12 @@ var Account = class extends AbstractAccount {
|
|
5235
4973
|
});
|
5236
4974
|
const needsToBeFunded = missingQuantities.length;
|
5237
4975
|
if (needsToBeFunded) {
|
5238
|
-
const
|
5239
|
-
|
5240
|
-
|
5241
|
-
|
5242
|
-
|
5243
|
-
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
5244
|
-
const requestToBeReEstimate = clone4(txRequest);
|
5245
|
-
if (addedSignatures) {
|
5246
|
-
Array.from({ length: addedSignatures }).forEach(
|
5247
|
-
() => requestToBeReEstimate.addEmptyWitness()
|
5248
|
-
);
|
4976
|
+
const resources = await this.getResourcesToSpend(missingQuantities, {
|
4977
|
+
messages: cachedMessages,
|
4978
|
+
utxos: cachedUtxos
|
4979
|
+
});
|
4980
|
+
request.addResources(resources);
|
5249
4981
|
}
|
5250
|
-
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
5251
|
-
transactionRequest: requestToBeReEstimate
|
5252
|
-
});
|
5253
|
-
txRequest.maxFee = maxFee;
|
5254
|
-
return txRequest;
|
5255
4982
|
}
|
5256
4983
|
/**
|
5257
4984
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -5259,25 +4986,28 @@ var Account = class extends AbstractAccount {
|
|
5259
4986
|
* @param destination - The address of the destination.
|
5260
4987
|
* @param amount - The amount of coins to transfer.
|
5261
4988
|
* @param assetId - The asset ID of the coins to transfer.
|
5262
|
-
* @param txParams - The transaction parameters (gasLimit,
|
4989
|
+
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
5263
4990
|
* @returns A promise that resolves to the prepared transaction request.
|
5264
4991
|
*/
|
5265
4992
|
async createTransfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
5266
|
-
const
|
4993
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
4994
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
4995
|
+
const request = new ScriptTransactionRequest(params);
|
5267
4996
|
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetId);
|
5268
|
-
const
|
4997
|
+
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
5269
4998
|
estimateTxDependencies: true,
|
5270
4999
|
resourcesOwner: this
|
5271
5000
|
});
|
5272
|
-
|
5273
|
-
|
5274
|
-
|
5275
|
-
|
5276
|
-
|
5277
|
-
|
5278
|
-
|
5279
|
-
|
5280
|
-
await this.fund(request,
|
5001
|
+
request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
|
5002
|
+
request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
|
5003
|
+
this.validateGas({
|
5004
|
+
gasUsed,
|
5005
|
+
gasPrice: request.gasPrice,
|
5006
|
+
gasLimit: request.gasLimit,
|
5007
|
+
minGasPrice
|
5008
|
+
});
|
5009
|
+
await this.fund(request, requiredQuantities, maxFee);
|
5010
|
+
request.updatePredicateInputs(estimatedInputs);
|
5281
5011
|
return request;
|
5282
5012
|
}
|
5283
5013
|
/**
|
@@ -5290,7 +5020,7 @@ var Account = class extends AbstractAccount {
|
|
5290
5020
|
* @returns A promise that resolves to the transaction response.
|
5291
5021
|
*/
|
5292
5022
|
async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
|
5293
|
-
if (
|
5023
|
+
if (bn17(amount).lte(0)) {
|
5294
5024
|
throw new FuelError15(
|
5295
5025
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5296
5026
|
"Transfer amount must be a positive number."
|
@@ -5309,37 +5039,38 @@ var Account = class extends AbstractAccount {
|
|
5309
5039
|
* @returns A promise that resolves to the transaction response.
|
5310
5040
|
*/
|
5311
5041
|
async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
|
5312
|
-
if (
|
5042
|
+
if (bn17(amount).lte(0)) {
|
5313
5043
|
throw new FuelError15(
|
5314
5044
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5315
5045
|
"Transfer amount must be a positive number."
|
5316
5046
|
);
|
5317
5047
|
}
|
5318
5048
|
const contractAddress = Address3.fromAddressOrString(contractId);
|
5049
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
5050
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
5319
5051
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5320
5052
|
hexlifiedContractId: contractAddress.toB256(),
|
5321
|
-
amountToTransfer:
|
5053
|
+
amountToTransfer: bn17(amount),
|
5322
5054
|
assetId
|
5323
5055
|
});
|
5324
5056
|
const request = new ScriptTransactionRequest({
|
5325
|
-
...
|
5057
|
+
...params,
|
5326
5058
|
script,
|
5327
5059
|
scriptData
|
5328
5060
|
});
|
5329
5061
|
request.addContractInputAndOutput(contractAddress);
|
5330
|
-
const
|
5331
|
-
|
5332
|
-
|
5062
|
+
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
5063
|
+
request,
|
5064
|
+
[{ amount: bn17(amount), assetId: String(assetId) }]
|
5065
|
+
);
|
5066
|
+
request.gasLimit = bn17(params.gasLimit ?? gasUsed);
|
5067
|
+
this.validateGas({
|
5068
|
+
gasUsed,
|
5069
|
+
gasPrice: request.gasPrice,
|
5070
|
+
gasLimit: request.gasLimit,
|
5071
|
+
minGasPrice
|
5333
5072
|
});
|
5334
|
-
|
5335
|
-
this.validateGas({
|
5336
|
-
gasUsed: txCost.gasUsed,
|
5337
|
-
gasLimit: request.gasLimit
|
5338
|
-
});
|
5339
|
-
}
|
5340
|
-
request.gasLimit = txCost.gasUsed;
|
5341
|
-
request.maxFee = txCost.maxFee;
|
5342
|
-
await this.fund(request, txCost);
|
5073
|
+
await this.fund(request, requiredQuantities, maxFee);
|
5343
5074
|
return this.sendTransaction(request);
|
5344
5075
|
}
|
5345
5076
|
/**
|
@@ -5351,31 +5082,34 @@ var Account = class extends AbstractAccount {
|
|
5351
5082
|
* @returns A promise that resolves to the transaction response.
|
5352
5083
|
*/
|
5353
5084
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5085
|
+
const { minGasPrice } = this.provider.getGasConfig();
|
5354
5086
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
5355
5087
|
const recipientDataArray = arrayify14(
|
5356
5088
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5357
5089
|
);
|
5358
5090
|
const amountDataArray = arrayify14(
|
5359
|
-
"0x".concat(
|
5091
|
+
"0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
|
5360
5092
|
);
|
5361
5093
|
const script = new Uint8Array([
|
5362
5094
|
...arrayify14(withdrawScript.bytes),
|
5363
5095
|
...recipientDataArray,
|
5364
5096
|
...amountDataArray
|
5365
5097
|
]);
|
5366
|
-
const params = { script, ...txParams };
|
5098
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
5367
5099
|
const request = new ScriptTransactionRequest(params);
|
5368
|
-
const
|
5369
|
-
const
|
5370
|
-
|
5371
|
-
|
5372
|
-
|
5373
|
-
|
5374
|
-
|
5375
|
-
|
5376
|
-
|
5377
|
-
|
5378
|
-
|
5100
|
+
const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
|
5101
|
+
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
5102
|
+
request,
|
5103
|
+
forwardingQuantities
|
5104
|
+
);
|
5105
|
+
request.gasLimit = bn17(params.gasLimit ?? gasUsed);
|
5106
|
+
this.validateGas({
|
5107
|
+
gasUsed,
|
5108
|
+
gasPrice: request.gasPrice,
|
5109
|
+
gasLimit: request.gasLimit,
|
5110
|
+
minGasPrice
|
5111
|
+
});
|
5112
|
+
await this.fund(request, requiredQuantities, maxFee);
|
5379
5113
|
return this.sendTransaction(request);
|
5380
5114
|
}
|
5381
5115
|
async signMessage(message) {
|
@@ -5433,7 +5167,18 @@ var Account = class extends AbstractAccount {
|
|
5433
5167
|
}
|
5434
5168
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5435
5169
|
}
|
5436
|
-
validateGas({
|
5170
|
+
validateGas({
|
5171
|
+
gasUsed,
|
5172
|
+
gasPrice,
|
5173
|
+
gasLimit,
|
5174
|
+
minGasPrice
|
5175
|
+
}) {
|
5176
|
+
if (minGasPrice.gt(gasPrice)) {
|
5177
|
+
throw new FuelError15(
|
5178
|
+
ErrorCode15.GAS_PRICE_TOO_LOW,
|
5179
|
+
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
5180
|
+
);
|
5181
|
+
}
|
5437
5182
|
if (gasUsed.gt(gasLimit)) {
|
5438
5183
|
throw new FuelError15(
|
5439
5184
|
ErrorCode15.GAS_LIMIT_TOO_LOW,
|
@@ -5729,7 +5474,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5729
5474
|
* @param transactionRequestLike - The transaction request to send.
|
5730
5475
|
* @returns A promise that resolves to the TransactionResponse object.
|
5731
5476
|
*/
|
5732
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
5477
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
5733
5478
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5734
5479
|
if (estimateTxDependencies) {
|
5735
5480
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -5770,7 +5515,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5770
5515
|
// src/hdwallet/hdwallet.ts
|
5771
5516
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5772
5517
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5773
|
-
import { bn as
|
5518
|
+
import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5774
5519
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5775
5520
|
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5776
5521
|
|
@@ -8242,7 +7987,7 @@ var HDWallet = class {
|
|
8242
7987
|
const IR = bytes.slice(32);
|
8243
7988
|
if (privateKey) {
|
8244
7989
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8245
|
-
const ki =
|
7990
|
+
const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
|
8246
7991
|
return new HDWallet({
|
8247
7992
|
privateKey: ki,
|
8248
7993
|
chainCode: IR,
|
@@ -8931,7 +8676,7 @@ import {
|
|
8931
8676
|
import { Address as Address9 } from "@fuel-ts/address";
|
8932
8677
|
import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
|
8933
8678
|
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
8934
|
-
import { ByteArrayCoder, InputType as
|
8679
|
+
import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
|
8935
8680
|
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
8936
8681
|
|
8937
8682
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -8991,9 +8736,10 @@ var Predicate = class extends Account {
|
|
8991
8736
|
const request = transactionRequestify(transactionRequestLike);
|
8992
8737
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
8993
8738
|
request.inputs?.forEach((input) => {
|
8994
|
-
if (input.type ===
|
8995
|
-
input.predicate =
|
8996
|
-
input.predicateData =
|
8739
|
+
if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
|
8740
|
+
input.predicate = this.bytes;
|
8741
|
+
input.predicateData = this.getPredicateData(policies.length);
|
8742
|
+
input.witnessIndex = 0;
|
8997
8743
|
}
|
8998
8744
|
});
|
8999
8745
|
return request;
|
@@ -9008,7 +8754,8 @@ var Predicate = class extends Account {
|
|
9008
8754
|
* @returns A promise that resolves to the prepared transaction request.
|
9009
8755
|
*/
|
9010
8756
|
async createTransfer(destination, amount, assetId = BaseAssetId4, txParams = {}) {
|
9011
|
-
|
8757
|
+
const request = await super.createTransfer(destination, amount, assetId, txParams);
|
8758
|
+
return this.populateTransactionPredicateData(request);
|
9012
8759
|
}
|
9013
8760
|
/**
|
9014
8761
|
* Sends a transaction with the populated predicate data.
|
@@ -9016,9 +8763,9 @@ var Predicate = class extends Account {
|
|
9016
8763
|
* @param transactionRequestLike - The transaction request-like object.
|
9017
8764
|
* @returns A promise that resolves to the transaction response.
|
9018
8765
|
*/
|
9019
|
-
sendTransaction(transactionRequestLike) {
|
9020
|
-
const transactionRequest =
|
9021
|
-
return super.sendTransaction(transactionRequest,
|
8766
|
+
sendTransaction(transactionRequestLike, options) {
|
8767
|
+
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
8768
|
+
return super.sendTransaction(transactionRequest, options);
|
9022
8769
|
}
|
9023
8770
|
/**
|
9024
8771
|
* Simulates a transaction with the populated predicate data.
|
@@ -9027,8 +8774,22 @@ var Predicate = class extends Account {
|
|
9027
8774
|
* @returns A promise that resolves to the call result.
|
9028
8775
|
*/
|
9029
8776
|
simulateTransaction(transactionRequestLike) {
|
9030
|
-
const transactionRequest =
|
9031
|
-
return super.simulateTransaction(transactionRequest
|
8777
|
+
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
8778
|
+
return super.simulateTransaction(transactionRequest);
|
8779
|
+
}
|
8780
|
+
/**
|
8781
|
+
* Retrieves resources satisfying the spend query for the account.
|
8782
|
+
*
|
8783
|
+
* @param quantities - IDs of coins to exclude.
|
8784
|
+
* @param excludedIds - IDs of resources to be excluded from the query.
|
8785
|
+
* @returns A promise that resolves to an array of Resources.
|
8786
|
+
*/
|
8787
|
+
async getResourcesToSpend(quantities, excludedIds) {
|
8788
|
+
const resources = await super.getResourcesToSpend(quantities, excludedIds);
|
8789
|
+
return resources.map((resource) => ({
|
8790
|
+
...resource,
|
8791
|
+
predicate: hexlify19(this.bytes)
|
8792
|
+
}));
|
9032
8793
|
}
|
9033
8794
|
getPredicateData(policiesLength) {
|
9034
8795
|
if (!this.predicateData.length) {
|
@@ -9074,25 +8835,6 @@ var Predicate = class extends Account {
|
|
9074
8835
|
predicateInterface: abiInterface
|
9075
8836
|
};
|
9076
8837
|
}
|
9077
|
-
/**
|
9078
|
-
* Retrieves resources satisfying the spend query for the account.
|
9079
|
-
*
|
9080
|
-
* @param quantities - IDs of coins to exclude.
|
9081
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
9082
|
-
* @returns A promise that resolves to an array of Resources.
|
9083
|
-
*/
|
9084
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
9085
|
-
const resources = await this.provider.getResourcesToSpend(
|
9086
|
-
this.address,
|
9087
|
-
quantities,
|
9088
|
-
excludedIds
|
9089
|
-
);
|
9090
|
-
return resources.map((resource) => ({
|
9091
|
-
...resource,
|
9092
|
-
predicate: hexlify19(this.bytes),
|
9093
|
-
paddPredicateData: (policiesLength) => hexlify19(this.getPredicateData(policiesLength))
|
9094
|
-
}));
|
9095
|
-
}
|
9096
8838
|
/**
|
9097
8839
|
* Sets the configurable constants for the predicate.
|
9098
8840
|
*
|
@@ -9841,7 +9583,7 @@ export {
|
|
9841
9583
|
WalletLocked,
|
9842
9584
|
WalletManager,
|
9843
9585
|
WalletUnlocked,
|
9844
|
-
|
9586
|
+
addAmountToAsset,
|
9845
9587
|
addOperation,
|
9846
9588
|
assemblePanicError,
|
9847
9589
|
assembleReceiptByType,
|
@@ -9850,10 +9592,9 @@ export {
|
|
9850
9592
|
assets,
|
9851
9593
|
buildBlockExplorerUrl,
|
9852
9594
|
cacheFor,
|
9853
|
-
cacheTxInputsFromOwner,
|
9854
|
-
calculateGasFee,
|
9855
9595
|
calculateMetadataGasForTxCreate,
|
9856
9596
|
calculateMetadataGasForTxScript,
|
9597
|
+
calculatePriceWithFactor,
|
9857
9598
|
calculateTransactionFee,
|
9858
9599
|
coinQuantityfy,
|
9859
9600
|
deferPromise,
|