@fuel-ts/account 0.0.0-pr-2149-20240427110619 → 0.0.0-pr-2217-20240503100416
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 +15 -12
- package/dist/account.d.ts +1 -1
- package/dist/account.d.ts.map +1 -1
- package/dist/index.global.js +1624 -1618
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +366 -207
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +347 -190
- package/dist/index.mjs.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +203 -80
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/message.d.ts +2 -2
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +30 -29
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/resource.d.ts +0 -1
- package/dist/providers/resource.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts +8 -0
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -0
- package/dist/providers/transaction-request/script-transaction-request.d.ts +2 -3
- 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 +2 -1
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -2
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts +20 -0
- package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts.map +1 -0
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/index.d.ts +1 -1
- package/dist/providers/transaction-summary/index.d.ts.map +1 -1
- package/dist/providers/transaction-summary/operations.d.ts +4 -0
- package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
- package/dist/providers/transaction-summary/status.d.ts +5 -1
- package/dist/providers/transaction-summary/status.d.ts.map +1 -1
- package/dist/providers/transaction-summary/types.d.ts +6 -1
- package/dist/providers/transaction-summary/types.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +7 -6
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/resources.d.ts +4 -0
- package/dist/test-utils/resources.d.ts.map +1 -0
- package/dist/test-utils/transactionRequest.d.ts +5 -0
- package/dist/test-utils/transactionRequest.d.ts.map +1 -0
- package/dist/test-utils.global.js +1628 -1621
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +343 -196
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +328 -181
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +17 -17
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +0 -22
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
@@ -31,8 +31,8 @@ var __privateMethod = (obj, member, method) => {
|
|
31
31
|
import { Address as Address3 } from "@fuel-ts/address";
|
32
32
|
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
33
33
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
34
|
-
import { bn as
|
35
|
-
import { arrayify as arrayify14, isDefined } from "@fuel-ts/utils";
|
34
|
+
import { bn as bn20 } from "@fuel-ts/math";
|
35
|
+
import { arrayify as arrayify14, isDefined as isDefined2 } from "@fuel-ts/utils";
|
36
36
|
import { clone as clone4 } from "ramda";
|
37
37
|
|
38
38
|
// src/providers/coin-quantity.ts
|
@@ -73,7 +73,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
73
73
|
// src/providers/provider.ts
|
74
74
|
import { Address as Address2 } from "@fuel-ts/address";
|
75
75
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
76
|
-
import { BN, bn as
|
76
|
+
import { BN, bn as bn17 } from "@fuel-ts/math";
|
77
77
|
import {
|
78
78
|
InputType as InputType7,
|
79
79
|
TransactionType as TransactionType8,
|
@@ -83,7 +83,6 @@ import {
|
|
83
83
|
import { arrayify as arrayify11, hexlify as hexlify12, DateTime as DateTime2 } from "@fuel-ts/utils";
|
84
84
|
import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
|
85
85
|
import { equalBytes } from "@noble/curves/abstract/utils";
|
86
|
-
import { Network } from "ethers";
|
87
86
|
import { GraphQLClient } from "graphql-request";
|
88
87
|
import { clone as clone3 } from "ramda";
|
89
88
|
|
@@ -140,9 +139,6 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
140
139
|
id
|
141
140
|
}
|
142
141
|
time
|
143
|
-
receipts {
|
144
|
-
...receiptFragment
|
145
|
-
}
|
146
142
|
programState {
|
147
143
|
returnType
|
148
144
|
data
|
@@ -150,11 +146,15 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
150
146
|
receipts {
|
151
147
|
...receiptFragment
|
152
148
|
}
|
149
|
+
totalGas
|
150
|
+
totalFee
|
153
151
|
}
|
154
152
|
... on FailureStatus {
|
155
153
|
block {
|
156
154
|
id
|
157
155
|
}
|
156
|
+
totalGas
|
157
|
+
totalFee
|
158
158
|
time
|
159
159
|
reason
|
160
160
|
receipts {
|
@@ -194,6 +194,8 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
|
|
194
194
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
195
195
|
var DryRunFailureStatusFragmentFragmentDoc = gql`
|
196
196
|
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
197
|
+
totalGas
|
198
|
+
totalFee
|
197
199
|
reason
|
198
200
|
programState {
|
199
201
|
returnType
|
@@ -203,6 +205,8 @@ var DryRunFailureStatusFragmentFragmentDoc = gql`
|
|
203
205
|
`;
|
204
206
|
var DryRunSuccessStatusFragmentFragmentDoc = gql`
|
205
207
|
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
208
|
+
totalGas
|
209
|
+
totalFee
|
206
210
|
programState {
|
207
211
|
returnType
|
208
212
|
data
|
@@ -338,6 +342,7 @@ var TxParametersFragmentFragmentDoc = gql`
|
|
338
342
|
maxWitnesses
|
339
343
|
maxGasPerTx
|
340
344
|
maxSize
|
345
|
+
maxBytecodeSubsections
|
341
346
|
}
|
342
347
|
`;
|
343
348
|
var PredicateParametersFragmentFragmentDoc = gql`
|
@@ -607,6 +612,14 @@ var NodeInfoFragmentFragmentDoc = gql`
|
|
607
612
|
nodeVersion
|
608
613
|
}
|
609
614
|
`;
|
615
|
+
var RelayedTransactionStatusFragmentFragmentDoc = gql`
|
616
|
+
fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
|
617
|
+
... on RelayedTransactionFailed {
|
618
|
+
blockHeight
|
619
|
+
failure
|
620
|
+
}
|
621
|
+
}
|
622
|
+
`;
|
610
623
|
var GetVersionDocument = gql`
|
611
624
|
query getVersion {
|
612
625
|
nodeInfo {
|
@@ -836,6 +849,13 @@ var GetMessageStatusDocument = gql`
|
|
836
849
|
}
|
837
850
|
}
|
838
851
|
`;
|
852
|
+
var GetRelayedTransactionStatusDocument = gql`
|
853
|
+
query getRelayedTransactionStatus($relayedTransactionId: RelayedTransactionId!) {
|
854
|
+
relayedTransactionStatus(id: $relayedTransactionId) {
|
855
|
+
...relayedTransactionStatusFragment
|
856
|
+
}
|
857
|
+
}
|
858
|
+
${RelayedTransactionStatusFragmentFragmentDoc}`;
|
839
859
|
var DryRunDocument = gql`
|
840
860
|
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
841
861
|
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
@@ -858,6 +878,13 @@ var ProduceBlocksDocument = gql`
|
|
858
878
|
)
|
859
879
|
}
|
860
880
|
`;
|
881
|
+
var GetMessageByNonceDocument = gql`
|
882
|
+
query getMessageByNonce($nonce: Nonce!) {
|
883
|
+
message(nonce: $nonce) {
|
884
|
+
...messageFragment
|
885
|
+
}
|
886
|
+
}
|
887
|
+
${MessageFragmentFragmentDoc}`;
|
861
888
|
var SubmitAndAwaitDocument = gql`
|
862
889
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
863
890
|
submitAndAwait(tx: $encodedTransaction) {
|
@@ -943,6 +970,9 @@ function getSdk(requester) {
|
|
943
970
|
getMessageStatus(variables, options) {
|
944
971
|
return requester(GetMessageStatusDocument, variables, options);
|
945
972
|
},
|
973
|
+
getRelayedTransactionStatus(variables, options) {
|
974
|
+
return requester(GetRelayedTransactionStatusDocument, variables, options);
|
975
|
+
},
|
946
976
|
dryRun(variables, options) {
|
947
977
|
return requester(DryRunDocument, variables, options);
|
948
978
|
},
|
@@ -952,6 +982,9 @@ function getSdk(requester) {
|
|
952
982
|
produceBlocks(variables, options) {
|
953
983
|
return requester(ProduceBlocksDocument, variables, options);
|
954
984
|
},
|
985
|
+
getMessageByNonce(variables, options) {
|
986
|
+
return requester(GetMessageByNonceDocument, variables, options);
|
987
|
+
},
|
955
988
|
submitAndAwait(variables, options) {
|
956
989
|
return requester(SubmitAndAwaitDocument, variables, options);
|
957
990
|
},
|
@@ -1244,7 +1277,7 @@ import {
|
|
1244
1277
|
OutputType as OutputType2,
|
1245
1278
|
TransactionType
|
1246
1279
|
} from "@fuel-ts/transactions";
|
1247
|
-
import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
|
1280
|
+
import { concat, hexlify as hexlify7, isDefined } from "@fuel-ts/utils";
|
1248
1281
|
|
1249
1282
|
// src/providers/resource.ts
|
1250
1283
|
var isRawCoin = (resource) => "utxoId" in resource;
|
@@ -1619,7 +1652,7 @@ function calculateMetadataGasForTxScript({
|
|
1619
1652
|
}
|
1620
1653
|
var calculateGasFee = (params) => {
|
1621
1654
|
const { gas, gasPrice, priceFactor, tip } = params;
|
1622
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1655
|
+
return gas.mul(gasPrice).div(priceFactor).add(bn5(tip));
|
1623
1656
|
};
|
1624
1657
|
|
1625
1658
|
// src/providers/utils/json.ts
|
@@ -1804,10 +1837,10 @@ var BaseTransactionRequest = class {
|
|
1804
1837
|
outputs,
|
1805
1838
|
witnesses
|
1806
1839
|
} = {}) {
|
1807
|
-
this.tip = bn7(tip);
|
1808
|
-
this.maturity = maturity
|
1809
|
-
this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
|
1810
|
-
this.maxFee =
|
1840
|
+
this.tip = tip ? bn7(tip) : void 0;
|
1841
|
+
this.maturity = maturity && maturity > 0 ? maturity : void 0;
|
1842
|
+
this.witnessLimit = isDefined(witnessLimit) ? bn7(witnessLimit) : void 0;
|
1843
|
+
this.maxFee = bn7(maxFee);
|
1811
1844
|
this.inputs = inputs ?? [];
|
1812
1845
|
this.outputs = outputs ?? [];
|
1813
1846
|
this.witnesses = witnesses ?? [];
|
@@ -1815,22 +1848,21 @@ var BaseTransactionRequest = class {
|
|
1815
1848
|
static getPolicyMeta(req) {
|
1816
1849
|
let policyTypes = 0;
|
1817
1850
|
const policies = [];
|
1818
|
-
|
1851
|
+
const { tip, witnessLimit, maturity } = req;
|
1852
|
+
if (bn7(tip).gt(0)) {
|
1819
1853
|
policyTypes += PolicyType.Tip;
|
1820
|
-
policies.push({ data:
|
1854
|
+
policies.push({ data: bn7(tip), type: PolicyType.Tip });
|
1821
1855
|
}
|
1822
|
-
if (
|
1856
|
+
if (isDefined(witnessLimit) && bn7(witnessLimit).gte(0)) {
|
1823
1857
|
policyTypes += PolicyType.WitnessLimit;
|
1824
|
-
policies.push({ data:
|
1858
|
+
policies.push({ data: bn7(witnessLimit), type: PolicyType.WitnessLimit });
|
1825
1859
|
}
|
1826
|
-
if (
|
1860
|
+
if (maturity && maturity > 0) {
|
1827
1861
|
policyTypes += PolicyType.Maturity;
|
1828
|
-
policies.push({ data:
|
1829
|
-
}
|
1830
|
-
if (req.maxFee) {
|
1831
|
-
policyTypes += PolicyType.MaxFee;
|
1832
|
-
policies.push({ data: req.maxFee, type: PolicyType.MaxFee });
|
1862
|
+
policies.push({ data: maturity, type: PolicyType.Maturity });
|
1833
1863
|
}
|
1864
|
+
policyTypes += PolicyType.MaxFee;
|
1865
|
+
policies.push({ data: req.maxFee, type: PolicyType.MaxFee });
|
1834
1866
|
return {
|
1835
1867
|
policyTypes,
|
1836
1868
|
policies
|
@@ -2146,8 +2178,11 @@ var BaseTransactionRequest = class {
|
|
2146
2178
|
* @hidden
|
2147
2179
|
*/
|
2148
2180
|
calculateMinGas(chainInfo) {
|
2149
|
-
const {
|
2150
|
-
const {
|
2181
|
+
const { consensusParameters } = chainInfo;
|
2182
|
+
const {
|
2183
|
+
gasCosts,
|
2184
|
+
feeParameters: { gasPerByte }
|
2185
|
+
} = consensusParameters;
|
2151
2186
|
return getMinGas({
|
2152
2187
|
gasPerByte,
|
2153
2188
|
gasCosts,
|
@@ -2158,7 +2193,10 @@ var BaseTransactionRequest = class {
|
|
2158
2193
|
}
|
2159
2194
|
calculateMaxGas(chainInfo, minGas) {
|
2160
2195
|
const { consensusParameters } = chainInfo;
|
2161
|
-
const {
|
2196
|
+
const {
|
2197
|
+
feeParameters: { gasPerByte },
|
2198
|
+
txParameters: { maxGasPerTx }
|
2199
|
+
} = consensusParameters;
|
2162
2200
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2163
2201
|
(acc, wit) => acc + wit.dataLength,
|
2164
2202
|
0
|
@@ -2593,7 +2631,11 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2593
2631
|
}
|
2594
2632
|
calculateMaxGas(chainInfo, minGas) {
|
2595
2633
|
const { consensusParameters } = chainInfo;
|
2596
|
-
const {
|
2634
|
+
const {
|
2635
|
+
// TODO: Validade if it will be simpler to pass only required props
|
2636
|
+
feeParameters: { gasPerByte },
|
2637
|
+
txParameters: { maxGasPerTx }
|
2638
|
+
} = consensusParameters;
|
2597
2639
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2598
2640
|
(acc, wit) => acc + wit.dataLength,
|
2599
2641
|
0
|
@@ -2681,10 +2723,10 @@ var transactionRequestify = (obj) => {
|
|
2681
2723
|
};
|
2682
2724
|
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2683
2725
|
(acc, input) => {
|
2684
|
-
if (input.type === InputType5.Coin && input.owner === owner) {
|
2726
|
+
if (input.type === InputType5.Coin && input.owner === owner.toB256()) {
|
2685
2727
|
acc.utxos.push(input.id);
|
2686
2728
|
}
|
2687
|
-
if (input.type === InputType5.Message && input.recipient === owner) {
|
2729
|
+
if (input.type === InputType5.Message && input.recipient === owner.toB256()) {
|
2688
2730
|
acc.messages.push(input.nonce);
|
2689
2731
|
}
|
2690
2732
|
return acc;
|
@@ -2697,40 +2739,40 @@ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
|
2697
2739
|
|
2698
2740
|
// src/providers/transaction-response/transaction-response.ts
|
2699
2741
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2700
|
-
import { bn as
|
2742
|
+
import { bn as bn16 } from "@fuel-ts/math";
|
2701
2743
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2702
2744
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2703
2745
|
|
2704
2746
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2705
|
-
import { bn as
|
2747
|
+
import { bn as bn15 } from "@fuel-ts/math";
|
2706
2748
|
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2707
2749
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2708
2750
|
|
2709
|
-
// src/providers/transaction-summary/calculate-
|
2751
|
+
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
2710
2752
|
import { bn as bn11 } from "@fuel-ts/math";
|
2711
2753
|
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
|
2712
2754
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2713
|
-
var
|
2755
|
+
var calculateTXFeeForSummary = (params) => {
|
2714
2756
|
const {
|
2715
2757
|
gasPrice,
|
2716
2758
|
rawPayload,
|
2717
2759
|
tip,
|
2760
|
+
totalFee,
|
2718
2761
|
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2719
2762
|
} = params;
|
2763
|
+
if (totalFee) {
|
2764
|
+
return totalFee;
|
2765
|
+
}
|
2720
2766
|
const gasPerByte = bn11(feeParams.gasPerByte);
|
2721
2767
|
const gasPriceFactor = bn11(feeParams.gasPriceFactor);
|
2722
2768
|
const transactionBytes = arrayify9(rawPayload);
|
2723
2769
|
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
2724
|
-
if (transaction.type === TransactionType6.Mint) {
|
2725
|
-
return {
|
2726
|
-
fee: bn11(0),
|
2727
|
-
minFee: bn11(0),
|
2728
|
-
maxFee: bn11(0)
|
2729
|
-
};
|
2730
|
-
}
|
2731
2770
|
const { type, witnesses, inputs, policies } = transaction;
|
2732
2771
|
let metadataGas = bn11(0);
|
2733
2772
|
let gasLimit = bn11(0);
|
2773
|
+
if (type !== TransactionType6.Create && type !== TransactionType6.Script) {
|
2774
|
+
return bn11(0);
|
2775
|
+
}
|
2734
2776
|
if (type === TransactionType6.Create) {
|
2735
2777
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2736
2778
|
const contractBytesSize = bn11(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
|
@@ -2767,23 +2809,13 @@ var calculateTransactionFee = (params) => {
|
|
2767
2809
|
witnessLimit,
|
2768
2810
|
maxGasPerTx
|
2769
2811
|
});
|
2770
|
-
const minFee = calculateGasFee({
|
2771
|
-
gasPrice,
|
2772
|
-
gas: minGas,
|
2773
|
-
priceFactor: gasPriceFactor,
|
2774
|
-
tip
|
2775
|
-
});
|
2776
2812
|
const maxFee = calculateGasFee({
|
2777
2813
|
gasPrice,
|
2778
2814
|
gas: maxGas,
|
2779
2815
|
priceFactor: gasPriceFactor,
|
2780
2816
|
tip
|
2781
2817
|
});
|
2782
|
-
return
|
2783
|
-
minFee,
|
2784
|
-
maxFee,
|
2785
|
-
fee: maxFee
|
2786
|
-
};
|
2818
|
+
return maxFee;
|
2787
2819
|
};
|
2788
2820
|
|
2789
2821
|
// src/providers/transaction-summary/operations.ts
|
@@ -2918,6 +2950,8 @@ var TransactionTypeName = /* @__PURE__ */ ((TransactionTypeName2) => {
|
|
2918
2950
|
TransactionTypeName2["Create"] = "Create";
|
2919
2951
|
TransactionTypeName2["Mint"] = "Mint";
|
2920
2952
|
TransactionTypeName2["Script"] = "Script";
|
2953
|
+
TransactionTypeName2["Upgrade"] = "Upgrade";
|
2954
|
+
TransactionTypeName2["Upload"] = "Upload";
|
2921
2955
|
return TransactionTypeName2;
|
2922
2956
|
})(TransactionTypeName || {});
|
2923
2957
|
var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
|
@@ -2983,6 +3017,12 @@ function isTypeCreate(transactionType) {
|
|
2983
3017
|
function isTypeScript(transactionType) {
|
2984
3018
|
return isType(transactionType, "Script" /* Script */);
|
2985
3019
|
}
|
3020
|
+
function isTypeUpgrade(transactionType) {
|
3021
|
+
return isType(transactionType, "Upgrade" /* Upgrade */);
|
3022
|
+
}
|
3023
|
+
function isTypeUpload(transactionType) {
|
3024
|
+
return isType(transactionType, "Upload" /* Upload */);
|
3025
|
+
}
|
2986
3026
|
function hasSameAssetId(a) {
|
2987
3027
|
return (b) => a.assetId === b.assetId;
|
2988
3028
|
}
|
@@ -3329,6 +3369,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3329
3369
|
|
3330
3370
|
// src/providers/transaction-summary/status.ts
|
3331
3371
|
import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
|
3372
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
3332
3373
|
var getTransactionStatusName = (gqlStatus) => {
|
3333
3374
|
switch (gqlStatus) {
|
3334
3375
|
case "FailureStatus":
|
@@ -3350,6 +3391,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3350
3391
|
let time;
|
3351
3392
|
let blockId;
|
3352
3393
|
let status;
|
3394
|
+
let totalFee;
|
3395
|
+
let totalGas;
|
3353
3396
|
let isStatusFailure = false;
|
3354
3397
|
let isStatusSuccess = false;
|
3355
3398
|
let isStatusPending = false;
|
@@ -3360,11 +3403,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3360
3403
|
time = gqlTransactionStatus.time;
|
3361
3404
|
blockId = gqlTransactionStatus.block.id;
|
3362
3405
|
isStatusSuccess = true;
|
3406
|
+
totalFee = bn14(gqlTransactionStatus.totalFee);
|
3407
|
+
totalGas = bn14(gqlTransactionStatus.totalGas);
|
3363
3408
|
break;
|
3364
3409
|
case "FailureStatus":
|
3365
3410
|
time = gqlTransactionStatus.time;
|
3366
3411
|
blockId = gqlTransactionStatus.block.id;
|
3367
3412
|
isStatusFailure = true;
|
3413
|
+
totalFee = bn14(gqlTransactionStatus.totalFee);
|
3414
|
+
totalGas = bn14(gqlTransactionStatus.totalGas);
|
3368
3415
|
break;
|
3369
3416
|
case "SubmittedStatus":
|
3370
3417
|
time = gqlTransactionStatus.time;
|
@@ -3377,6 +3424,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3377
3424
|
time,
|
3378
3425
|
blockId,
|
3379
3426
|
status,
|
3427
|
+
totalFee,
|
3428
|
+
totalGas,
|
3380
3429
|
isStatusFailure,
|
3381
3430
|
isStatusSuccess,
|
3382
3431
|
isStatusPending
|
@@ -3412,8 +3461,10 @@ function assembleTransactionSummary(params) {
|
|
3412
3461
|
maxInputs
|
3413
3462
|
});
|
3414
3463
|
const typeName = getTransactionTypeName(transaction.type);
|
3415
|
-
const tip =
|
3416
|
-
const {
|
3464
|
+
const tip = bn15(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3465
|
+
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3466
|
+
const fee = calculateTXFeeForSummary({
|
3467
|
+
totalFee,
|
3417
3468
|
gasPrice,
|
3418
3469
|
rawPayload,
|
3419
3470
|
tip,
|
@@ -3426,7 +3477,6 @@ function assembleTransactionSummary(params) {
|
|
3426
3477
|
}
|
3427
3478
|
}
|
3428
3479
|
});
|
3429
|
-
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time } = processGraphqlStatus(gqlTransactionStatus);
|
3430
3480
|
const mintedAssets = extractMintedAssetsFromReceipts(receipts);
|
3431
3481
|
const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
|
3432
3482
|
let date;
|
@@ -3435,6 +3485,7 @@ function assembleTransactionSummary(params) {
|
|
3435
3485
|
}
|
3436
3486
|
const transactionSummary = {
|
3437
3487
|
id,
|
3488
|
+
tip,
|
3438
3489
|
fee,
|
3439
3490
|
gasUsed,
|
3440
3491
|
operations,
|
@@ -3448,6 +3499,8 @@ function assembleTransactionSummary(params) {
|
|
3448
3499
|
isTypeMint: isTypeMint(transaction.type),
|
3449
3500
|
isTypeCreate: isTypeCreate(transaction.type),
|
3450
3501
|
isTypeScript: isTypeScript(transaction.type),
|
3502
|
+
isTypeUpgrade: isTypeUpgrade(transaction.type),
|
3503
|
+
isTypeUpload: isTypeUpload(transaction.type),
|
3451
3504
|
isStatusFailure,
|
3452
3505
|
isStatusSuccess,
|
3453
3506
|
isStatusPending,
|
@@ -3479,7 +3532,7 @@ var TransactionResponse = class {
|
|
3479
3532
|
/** Current provider */
|
3480
3533
|
provider;
|
3481
3534
|
/** Gas used on the transaction */
|
3482
|
-
gasUsed =
|
3535
|
+
gasUsed = bn16(0);
|
3483
3536
|
/** The graphql Transaction with receipts object. */
|
3484
3537
|
gqlTransaction;
|
3485
3538
|
abis;
|
@@ -3564,7 +3617,7 @@ var TransactionResponse = class {
|
|
3564
3617
|
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3565
3618
|
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3566
3619
|
const gasPrice = await this.provider.getLatestGasPrice();
|
3567
|
-
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3620
|
+
const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
|
3568
3621
|
const transactionSummary = assembleTransactionSummary({
|
3569
3622
|
id: this.id,
|
3570
3623
|
receipts,
|
@@ -3700,33 +3753,60 @@ var mergeQuantities = (...coinQuantities) => {
|
|
3700
3753
|
var MAX_RETRIES = 10;
|
3701
3754
|
var processGqlChain = (chain) => {
|
3702
3755
|
const { name, daHeight, consensusParameters, latestBlock } = chain;
|
3703
|
-
const {
|
3756
|
+
const {
|
3757
|
+
contractParams,
|
3758
|
+
feeParams,
|
3759
|
+
predicateParams,
|
3760
|
+
scriptParams,
|
3761
|
+
txParams,
|
3762
|
+
gasCosts,
|
3763
|
+
baseAssetId,
|
3764
|
+
chainId,
|
3765
|
+
version
|
3766
|
+
} = consensusParameters;
|
3704
3767
|
return {
|
3705
3768
|
name,
|
3706
|
-
baseChainHeight:
|
3769
|
+
baseChainHeight: bn17(daHeight),
|
3707
3770
|
consensusParameters: {
|
3708
|
-
|
3709
|
-
|
3710
|
-
|
3711
|
-
|
3712
|
-
|
3713
|
-
|
3714
|
-
|
3715
|
-
|
3716
|
-
|
3717
|
-
|
3718
|
-
|
3719
|
-
|
3720
|
-
|
3721
|
-
|
3722
|
-
|
3723
|
-
|
3771
|
+
version,
|
3772
|
+
chainId: bn17(chainId),
|
3773
|
+
baseAssetId,
|
3774
|
+
feeParameters: {
|
3775
|
+
version: feeParams.version,
|
3776
|
+
gasPerByte: bn17(feeParams.gasPerByte),
|
3777
|
+
gasPriceFactor: bn17(feeParams.gasPriceFactor)
|
3778
|
+
},
|
3779
|
+
contractParameters: {
|
3780
|
+
version: contractParams.version,
|
3781
|
+
contractMaxSize: bn17(contractParams.contractMaxSize),
|
3782
|
+
maxStorageSlots: bn17(contractParams.maxStorageSlots)
|
3783
|
+
},
|
3784
|
+
txParameters: {
|
3785
|
+
version: txParams.version,
|
3786
|
+
maxInputs: bn17(txParams.maxInputs),
|
3787
|
+
maxOutputs: bn17(txParams.maxOutputs),
|
3788
|
+
maxWitnesses: bn17(txParams.maxWitnesses),
|
3789
|
+
maxGasPerTx: bn17(txParams.maxGasPerTx),
|
3790
|
+
maxSize: bn17(txParams.maxSize),
|
3791
|
+
maxBytecodeSubsections: bn17(txParams.maxBytecodeSubsections)
|
3792
|
+
},
|
3793
|
+
predicateParameters: {
|
3794
|
+
version: predicateParams.version,
|
3795
|
+
maxPredicateLength: bn17(predicateParams.maxPredicateLength),
|
3796
|
+
maxPredicateDataLength: bn17(predicateParams.maxPredicateDataLength),
|
3797
|
+
maxGasPerPredicate: bn17(predicateParams.maxGasPerPredicate),
|
3798
|
+
maxMessageDataLength: bn17(predicateParams.maxMessageDataLength)
|
3799
|
+
},
|
3800
|
+
scriptParameters: {
|
3801
|
+
version: scriptParams.version,
|
3802
|
+
maxScriptLength: bn17(scriptParams.maxScriptLength),
|
3803
|
+
maxScriptDataLength: bn17(scriptParams.maxScriptDataLength)
|
3804
|
+
},
|
3724
3805
|
gasCosts
|
3725
3806
|
},
|
3726
|
-
gasCosts,
|
3727
3807
|
latestBlock: {
|
3728
3808
|
id: latestBlock.id,
|
3729
|
-
height:
|
3809
|
+
height: bn17(latestBlock.height),
|
3730
3810
|
time: latestBlock.header.time,
|
3731
3811
|
transactions: latestBlock.transactions.map((i) => ({
|
3732
3812
|
id: i.id
|
@@ -3820,7 +3900,12 @@ var _Provider = class {
|
|
3820
3900
|
* Returns some helpful parameters related to gas fees.
|
3821
3901
|
*/
|
3822
3902
|
getGasConfig() {
|
3823
|
-
const {
|
3903
|
+
const {
|
3904
|
+
txParameters: { maxGasPerTx },
|
3905
|
+
predicateParameters: { maxGasPerPredicate },
|
3906
|
+
feeParameters: { gasPriceFactor, gasPerByte },
|
3907
|
+
gasCosts
|
3908
|
+
} = this.getChain().consensusParameters;
|
3824
3909
|
return {
|
3825
3910
|
maxGasPerTx,
|
3826
3911
|
maxGasPerPredicate,
|
@@ -3869,7 +3954,18 @@ var _Provider = class {
|
|
3869
3954
|
createOperations() {
|
3870
3955
|
const fetchFn = _Provider.getFetchFn(this.options);
|
3871
3956
|
const gqlClient = new GraphQLClient(this.url, {
|
3872
|
-
fetch: (url, requestInit) => fetchFn(url, requestInit, this.options)
|
3957
|
+
fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
3958
|
+
responseMiddleware: (response) => {
|
3959
|
+
if ("response" in response) {
|
3960
|
+
const graphQlResponse = response.response;
|
3961
|
+
if (Array.isArray(graphQlResponse?.errors)) {
|
3962
|
+
throw new FuelError13(
|
3963
|
+
FuelError13.CODES.INVALID_REQUEST,
|
3964
|
+
graphQlResponse.errors.map((err) => err.message).join("\n\n")
|
3965
|
+
);
|
3966
|
+
}
|
3967
|
+
}
|
3968
|
+
}
|
3873
3969
|
});
|
3874
3970
|
const executeQuery = (query, vars) => {
|
3875
3971
|
const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
|
@@ -3897,21 +3993,6 @@ var _Provider = class {
|
|
3897
3993
|
} = await this.operations.getVersion();
|
3898
3994
|
return nodeVersion;
|
3899
3995
|
}
|
3900
|
-
/**
|
3901
|
-
* @hidden
|
3902
|
-
*
|
3903
|
-
* Returns the network configuration of the connected Fuel node.
|
3904
|
-
*
|
3905
|
-
* @returns A promise that resolves to the network configuration object
|
3906
|
-
*/
|
3907
|
-
async getNetwork() {
|
3908
|
-
const {
|
3909
|
-
name,
|
3910
|
-
consensusParameters: { chainId }
|
3911
|
-
} = await this.getChain();
|
3912
|
-
const network = new Network(name, chainId.toNumber());
|
3913
|
-
return Promise.resolve(network);
|
3914
|
-
}
|
3915
3996
|
/**
|
3916
3997
|
* Returns the block number.
|
3917
3998
|
*
|
@@ -3919,7 +4000,7 @@ var _Provider = class {
|
|
3919
4000
|
*/
|
3920
4001
|
async getBlockNumber() {
|
3921
4002
|
const { chain } = await this.operations.getChain();
|
3922
|
-
return
|
4003
|
+
return bn17(chain.latestBlock.height, 10);
|
3923
4004
|
}
|
3924
4005
|
/**
|
3925
4006
|
* Returns the chain information.
|
@@ -3929,8 +4010,8 @@ var _Provider = class {
|
|
3929
4010
|
async fetchNode() {
|
3930
4011
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3931
4012
|
const processedNodeInfo = {
|
3932
|
-
maxDepth:
|
3933
|
-
maxTx:
|
4013
|
+
maxDepth: bn17(nodeInfo.maxDepth),
|
4014
|
+
maxTx: bn17(nodeInfo.maxTx),
|
3934
4015
|
nodeVersion: nodeInfo.nodeVersion,
|
3935
4016
|
utxoValidation: nodeInfo.utxoValidation,
|
3936
4017
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -4034,9 +4115,9 @@ var _Provider = class {
|
|
4034
4115
|
encodedTransactions: encodedTransaction,
|
4035
4116
|
utxoValidation: utxoValidation || false
|
4036
4117
|
});
|
4037
|
-
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
4118
|
+
const [{ receipts: rawReceipts, status: dryRunStatus }] = dryRunStatuses;
|
4038
4119
|
const receipts = rawReceipts.map(processGqlReceipt);
|
4039
|
-
return { receipts,
|
4120
|
+
return { receipts, dryRunStatus };
|
4040
4121
|
}
|
4041
4122
|
/**
|
4042
4123
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -4062,7 +4143,7 @@ var _Provider = class {
|
|
4062
4143
|
} = response;
|
4063
4144
|
if (inputs) {
|
4064
4145
|
inputs.forEach((input, index) => {
|
4065
|
-
if ("predicateGasUsed" in input &&
|
4146
|
+
if ("predicateGasUsed" in input && bn17(input.predicateGasUsed).gt(0)) {
|
4066
4147
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4067
4148
|
}
|
4068
4149
|
});
|
@@ -4090,7 +4171,7 @@ var _Provider = class {
|
|
4090
4171
|
let receipts = [];
|
4091
4172
|
const missingContractIds = [];
|
4092
4173
|
let outputVariables = 0;
|
4093
|
-
let
|
4174
|
+
let dryRunStatus;
|
4094
4175
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
4095
4176
|
const {
|
4096
4177
|
dryRun: [{ receipts: rawReceipts, status }]
|
@@ -4099,7 +4180,7 @@ var _Provider = class {
|
|
4099
4180
|
utxoValidation: false
|
4100
4181
|
});
|
4101
4182
|
receipts = rawReceipts.map(processGqlReceipt);
|
4102
|
-
|
4183
|
+
dryRunStatus = status;
|
4103
4184
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
4104
4185
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
4105
4186
|
if (hasMissingOutputs) {
|
@@ -4121,7 +4202,7 @@ var _Provider = class {
|
|
4121
4202
|
receipts,
|
4122
4203
|
outputVariables,
|
4123
4204
|
missingContractIds,
|
4124
|
-
|
4205
|
+
dryRunStatus
|
4125
4206
|
};
|
4126
4207
|
}
|
4127
4208
|
/**
|
@@ -4139,7 +4220,7 @@ var _Provider = class {
|
|
4139
4220
|
receipts: [],
|
4140
4221
|
outputVariables: 0,
|
4141
4222
|
missingContractIds: [],
|
4142
|
-
|
4223
|
+
dryRunStatus: void 0
|
4143
4224
|
}));
|
4144
4225
|
const allRequests = clone3(transactionRequests);
|
4145
4226
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
@@ -4164,7 +4245,7 @@ var _Provider = class {
|
|
4164
4245
|
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4165
4246
|
const result = results[requestIdx];
|
4166
4247
|
result.receipts = rawReceipts.map(processGqlReceipt);
|
4167
|
-
result.
|
4248
|
+
result.dryRunStatus = status;
|
4168
4249
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4169
4250
|
result.receipts
|
4170
4251
|
);
|
@@ -4201,7 +4282,7 @@ var _Provider = class {
|
|
4201
4282
|
});
|
4202
4283
|
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4203
4284
|
const receipts = rawReceipts.map(processGqlReceipt);
|
4204
|
-
return { receipts,
|
4285
|
+
return { receipts, dryRunStatus: status };
|
4205
4286
|
});
|
4206
4287
|
return results;
|
4207
4288
|
}
|
@@ -4220,12 +4301,12 @@ var _Provider = class {
|
|
4220
4301
|
gasPrice = await this.estimateGasPrice(10);
|
4221
4302
|
}
|
4222
4303
|
const minFee = calculateGasFee({
|
4223
|
-
gasPrice:
|
4304
|
+
gasPrice: bn17(gasPrice),
|
4224
4305
|
gas: minGas,
|
4225
4306
|
priceFactor: gasPriceFactor,
|
4226
4307
|
tip: transactionRequest.tip
|
4227
4308
|
}).add(1);
|
4228
|
-
let gasLimit =
|
4309
|
+
let gasLimit = bn17(0);
|
4229
4310
|
if (transactionRequest.type === TransactionType8.Script) {
|
4230
4311
|
gasLimit = transactionRequest.gasLimit;
|
4231
4312
|
if (transactionRequest.gasLimit.eq(0)) {
|
@@ -4238,7 +4319,7 @@ var _Provider = class {
|
|
4238
4319
|
}
|
4239
4320
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4240
4321
|
const maxFee = calculateGasFee({
|
4241
|
-
gasPrice:
|
4322
|
+
gasPrice: bn17(gasPrice),
|
4242
4323
|
gas: maxGas,
|
4243
4324
|
priceFactor: gasPriceFactor,
|
4244
4325
|
tip: transactionRequest.tip
|
@@ -4301,9 +4382,9 @@ var _Provider = class {
|
|
4301
4382
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4302
4383
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4303
4384
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4304
|
-
txRequestClone.maxFee =
|
4385
|
+
txRequestClone.maxFee = bn17(0);
|
4305
4386
|
if (isScriptTransaction) {
|
4306
|
-
txRequestClone.gasLimit =
|
4387
|
+
txRequestClone.gasLimit = bn17(0);
|
4307
4388
|
}
|
4308
4389
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4309
4390
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4320,9 +4401,10 @@ var _Provider = class {
|
|
4320
4401
|
transactionRequest: signedRequest
|
4321
4402
|
});
|
4322
4403
|
let receipts = [];
|
4404
|
+
let dryRunStatus;
|
4323
4405
|
let missingContractIds = [];
|
4324
4406
|
let outputVariables = 0;
|
4325
|
-
let gasUsed =
|
4407
|
+
let gasUsed = bn17(0);
|
4326
4408
|
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4327
4409
|
txRequestClone.maxFee = maxFee;
|
4328
4410
|
if (isScriptTransaction) {
|
@@ -4330,10 +4412,7 @@ var _Provider = class {
|
|
4330
4412
|
if (signatureCallback) {
|
4331
4413
|
await signatureCallback(txRequestClone);
|
4332
4414
|
}
|
4333
|
-
|
4334
|
-
receipts = result.receipts;
|
4335
|
-
outputVariables = result.outputVariables;
|
4336
|
-
missingContractIds = result.missingContractIds;
|
4415
|
+
({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
|
4337
4416
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4338
4417
|
txRequestClone.gasLimit = gasUsed;
|
4339
4418
|
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
@@ -4353,7 +4432,8 @@ var _Provider = class {
|
|
4353
4432
|
outputVariables,
|
4354
4433
|
missingContractIds,
|
4355
4434
|
addedSignatures,
|
4356
|
-
estimatedPredicates: txRequestClone.inputs
|
4435
|
+
estimatedPredicates: txRequestClone.inputs,
|
4436
|
+
dryRunStatus
|
4357
4437
|
};
|
4358
4438
|
}
|
4359
4439
|
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
@@ -4389,10 +4469,10 @@ var _Provider = class {
|
|
4389
4469
|
return coins.map((coin) => ({
|
4390
4470
|
id: coin.utxoId,
|
4391
4471
|
assetId: coin.assetId,
|
4392
|
-
amount:
|
4472
|
+
amount: bn17(coin.amount),
|
4393
4473
|
owner: Address2.fromAddressOrString(coin.owner),
|
4394
|
-
blockCreated:
|
4395
|
-
txCreatedIdx:
|
4474
|
+
blockCreated: bn17(coin.blockCreated),
|
4475
|
+
txCreatedIdx: bn17(coin.txCreatedIdx)
|
4396
4476
|
}));
|
4397
4477
|
}
|
4398
4478
|
/**
|
@@ -4429,9 +4509,9 @@ var _Provider = class {
|
|
4429
4509
|
switch (coin.__typename) {
|
4430
4510
|
case "MessageCoin":
|
4431
4511
|
return {
|
4432
|
-
amount:
|
4512
|
+
amount: bn17(coin.amount),
|
4433
4513
|
assetId: coin.assetId,
|
4434
|
-
daHeight:
|
4514
|
+
daHeight: bn17(coin.daHeight),
|
4435
4515
|
sender: Address2.fromAddressOrString(coin.sender),
|
4436
4516
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4437
4517
|
nonce: coin.nonce
|
@@ -4439,11 +4519,11 @@ var _Provider = class {
|
|
4439
4519
|
case "Coin":
|
4440
4520
|
return {
|
4441
4521
|
id: coin.utxoId,
|
4442
|
-
amount:
|
4522
|
+
amount: bn17(coin.amount),
|
4443
4523
|
assetId: coin.assetId,
|
4444
4524
|
owner: Address2.fromAddressOrString(coin.owner),
|
4445
|
-
blockCreated:
|
4446
|
-
txCreatedIdx:
|
4525
|
+
blockCreated: bn17(coin.blockCreated),
|
4526
|
+
txCreatedIdx: bn17(coin.txCreatedIdx)
|
4447
4527
|
};
|
4448
4528
|
default:
|
4449
4529
|
return null;
|
@@ -4460,13 +4540,13 @@ var _Provider = class {
|
|
4460
4540
|
async getBlock(idOrHeight) {
|
4461
4541
|
let variables;
|
4462
4542
|
if (typeof idOrHeight === "number") {
|
4463
|
-
variables = { height:
|
4543
|
+
variables = { height: bn17(idOrHeight).toString(10) };
|
4464
4544
|
} else if (idOrHeight === "latest") {
|
4465
4545
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4466
4546
|
} else if (idOrHeight.length === 66) {
|
4467
4547
|
variables = { blockId: idOrHeight };
|
4468
4548
|
} else {
|
4469
|
-
variables = { blockId:
|
4549
|
+
variables = { blockId: bn17(idOrHeight).toString(10) };
|
4470
4550
|
}
|
4471
4551
|
const { block } = await this.operations.getBlock(variables);
|
4472
4552
|
if (!block) {
|
@@ -4474,7 +4554,7 @@ var _Provider = class {
|
|
4474
4554
|
}
|
4475
4555
|
return {
|
4476
4556
|
id: block.id,
|
4477
|
-
height:
|
4557
|
+
height: bn17(block.height),
|
4478
4558
|
time: block.header.time,
|
4479
4559
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4480
4560
|
};
|
@@ -4489,7 +4569,7 @@ var _Provider = class {
|
|
4489
4569
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4490
4570
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4491
4571
|
id: block.id,
|
4492
|
-
height:
|
4572
|
+
height: bn17(block.height),
|
4493
4573
|
time: block.header.time,
|
4494
4574
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4495
4575
|
}));
|
@@ -4504,7 +4584,7 @@ var _Provider = class {
|
|
4504
4584
|
async getBlockWithTransactions(idOrHeight) {
|
4505
4585
|
let variables;
|
4506
4586
|
if (typeof idOrHeight === "number") {
|
4507
|
-
variables = { blockHeight:
|
4587
|
+
variables = { blockHeight: bn17(idOrHeight).toString(10) };
|
4508
4588
|
} else if (idOrHeight === "latest") {
|
4509
4589
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4510
4590
|
} else {
|
@@ -4516,7 +4596,7 @@ var _Provider = class {
|
|
4516
4596
|
}
|
4517
4597
|
return {
|
4518
4598
|
id: block.id,
|
4519
|
-
height:
|
4599
|
+
height: bn17(block.height, 10),
|
4520
4600
|
time: block.header.time,
|
4521
4601
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4522
4602
|
transactions: block.transactions.map(
|
@@ -4565,7 +4645,7 @@ var _Provider = class {
|
|
4565
4645
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4566
4646
|
asset: hexlify12(assetId)
|
4567
4647
|
});
|
4568
|
-
return
|
4648
|
+
return bn17(contractBalance.amount, 10);
|
4569
4649
|
}
|
4570
4650
|
/**
|
4571
4651
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4579,7 +4659,7 @@ var _Provider = class {
|
|
4579
4659
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4580
4660
|
assetId: hexlify12(assetId)
|
4581
4661
|
});
|
4582
|
-
return
|
4662
|
+
return bn17(balance.amount, 10);
|
4583
4663
|
}
|
4584
4664
|
/**
|
4585
4665
|
* Returns balances for the given owner.
|
@@ -4597,7 +4677,7 @@ var _Provider = class {
|
|
4597
4677
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4598
4678
|
return balances.map((balance) => ({
|
4599
4679
|
assetId: balance.assetId,
|
4600
|
-
amount:
|
4680
|
+
amount: bn17(balance.amount)
|
4601
4681
|
}));
|
4602
4682
|
}
|
4603
4683
|
/**
|
@@ -4619,15 +4699,15 @@ var _Provider = class {
|
|
4619
4699
|
sender: message.sender,
|
4620
4700
|
recipient: message.recipient,
|
4621
4701
|
nonce: message.nonce,
|
4622
|
-
amount:
|
4702
|
+
amount: bn17(message.amount),
|
4623
4703
|
data: message.data
|
4624
4704
|
}),
|
4625
4705
|
sender: Address2.fromAddressOrString(message.sender),
|
4626
4706
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4627
4707
|
nonce: message.nonce,
|
4628
|
-
amount:
|
4708
|
+
amount: bn17(message.amount),
|
4629
4709
|
data: InputMessageCoder.decodeData(message.data),
|
4630
|
-
daHeight:
|
4710
|
+
daHeight: bn17(message.daHeight)
|
4631
4711
|
}));
|
4632
4712
|
}
|
4633
4713
|
/**
|
@@ -4680,59 +4760,59 @@ var _Provider = class {
|
|
4680
4760
|
} = result.messageProof;
|
4681
4761
|
return {
|
4682
4762
|
messageProof: {
|
4683
|
-
proofIndex:
|
4763
|
+
proofIndex: bn17(messageProof.proofIndex),
|
4684
4764
|
proofSet: messageProof.proofSet
|
4685
4765
|
},
|
4686
4766
|
blockProof: {
|
4687
|
-
proofIndex:
|
4767
|
+
proofIndex: bn17(blockProof.proofIndex),
|
4688
4768
|
proofSet: blockProof.proofSet
|
4689
4769
|
},
|
4690
4770
|
messageBlockHeader: {
|
4691
4771
|
id: messageBlockHeader.id,
|
4692
|
-
daHeight:
|
4693
|
-
transactionsCount:
|
4772
|
+
daHeight: bn17(messageBlockHeader.daHeight),
|
4773
|
+
transactionsCount: Number(messageBlockHeader.transactionsCount),
|
4694
4774
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4695
|
-
height:
|
4775
|
+
height: bn17(messageBlockHeader.height),
|
4696
4776
|
prevRoot: messageBlockHeader.prevRoot,
|
4697
4777
|
time: messageBlockHeader.time,
|
4698
4778
|
applicationHash: messageBlockHeader.applicationHash,
|
4699
|
-
messageReceiptCount:
|
4779
|
+
messageReceiptCount: Number(messageBlockHeader.messageReceiptCount),
|
4700
4780
|
messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
|
4701
|
-
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4781
|
+
consensusParametersVersion: Number(messageBlockHeader.consensusParametersVersion),
|
4702
4782
|
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4703
|
-
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4783
|
+
stateTransitionBytecodeVersion: Number(messageBlockHeader.stateTransitionBytecodeVersion)
|
4704
4784
|
},
|
4705
4785
|
commitBlockHeader: {
|
4706
4786
|
id: commitBlockHeader.id,
|
4707
|
-
daHeight:
|
4708
|
-
transactionsCount:
|
4787
|
+
daHeight: bn17(commitBlockHeader.daHeight),
|
4788
|
+
transactionsCount: Number(commitBlockHeader.transactionsCount),
|
4709
4789
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4710
|
-
height:
|
4790
|
+
height: bn17(commitBlockHeader.height),
|
4711
4791
|
prevRoot: commitBlockHeader.prevRoot,
|
4712
4792
|
time: commitBlockHeader.time,
|
4713
4793
|
applicationHash: commitBlockHeader.applicationHash,
|
4714
|
-
messageReceiptCount:
|
4794
|
+
messageReceiptCount: Number(commitBlockHeader.messageReceiptCount),
|
4715
4795
|
messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
|
4716
|
-
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4796
|
+
consensusParametersVersion: Number(commitBlockHeader.consensusParametersVersion),
|
4717
4797
|
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4718
|
-
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4798
|
+
stateTransitionBytecodeVersion: Number(commitBlockHeader.stateTransitionBytecodeVersion)
|
4719
4799
|
},
|
4720
4800
|
sender: Address2.fromAddressOrString(sender),
|
4721
4801
|
recipient: Address2.fromAddressOrString(recipient),
|
4722
4802
|
nonce,
|
4723
|
-
amount:
|
4803
|
+
amount: bn17(amount),
|
4724
4804
|
data
|
4725
4805
|
};
|
4726
4806
|
}
|
4727
4807
|
async getLatestGasPrice() {
|
4728
4808
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4729
|
-
return
|
4809
|
+
return bn17(latestGasPrice.gasPrice);
|
4730
4810
|
}
|
4731
4811
|
async estimateGasPrice(blockHorizon) {
|
4732
4812
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4733
4813
|
blockHorizon: String(blockHorizon)
|
4734
4814
|
});
|
4735
|
-
return
|
4815
|
+
return bn17(estimateGasPrice.gasPrice);
|
4736
4816
|
}
|
4737
4817
|
/**
|
4738
4818
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4753,15 +4833,37 @@ var _Provider = class {
|
|
4753
4833
|
*/
|
4754
4834
|
async produceBlocks(amount, startTime) {
|
4755
4835
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4756
|
-
blocksToProduce:
|
4836
|
+
blocksToProduce: bn17(amount).toString(10),
|
4757
4837
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4758
4838
|
});
|
4759
|
-
return
|
4839
|
+
return bn17(latestBlockHeight);
|
4760
4840
|
}
|
4761
4841
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4762
4842
|
async getTransactionResponse(transactionId) {
|
4763
4843
|
return new TransactionResponse(transactionId, this);
|
4764
4844
|
}
|
4845
|
+
/**
|
4846
|
+
* Returns Message for given nonce.
|
4847
|
+
*
|
4848
|
+
* @param nonce - The nonce of the message to retrieve.
|
4849
|
+
* @returns A promise that resolves to the Message object.
|
4850
|
+
*/
|
4851
|
+
async getMessageByNonce(nonce) {
|
4852
|
+
const { message } = await this.operations.getMessageByNonce({ nonce });
|
4853
|
+
if (!message) {
|
4854
|
+
return null;
|
4855
|
+
}
|
4856
|
+
return message;
|
4857
|
+
}
|
4858
|
+
async getRelayedTransactionStatus(relayedTransactionId) {
|
4859
|
+
const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
|
4860
|
+
relayedTransactionId
|
4861
|
+
});
|
4862
|
+
if (!relayedTransactionStatus) {
|
4863
|
+
return null;
|
4864
|
+
}
|
4865
|
+
return relayedTransactionStatus;
|
4866
|
+
}
|
4765
4867
|
};
|
4766
4868
|
var Provider = _Provider;
|
4767
4869
|
_cacheInputs = new WeakSet();
|
@@ -4780,7 +4882,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4780
4882
|
|
4781
4883
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4782
4884
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4783
|
-
import { bn as
|
4885
|
+
import { bn as bn18 } from "@fuel-ts/math";
|
4784
4886
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4785
4887
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4786
4888
|
async function getTransactionSummary(params) {
|
@@ -4804,7 +4906,11 @@ async function getTransactionSummary(params) {
|
|
4804
4906
|
}
|
4805
4907
|
const receipts = txReceipts.map(processGqlReceipt);
|
4806
4908
|
const {
|
4807
|
-
consensusParameters: {
|
4909
|
+
consensusParameters: {
|
4910
|
+
feeParameters: { gasPerByte, gasPriceFactor },
|
4911
|
+
txParameters: { maxInputs, maxGasPerTx },
|
4912
|
+
gasCosts
|
4913
|
+
}
|
4808
4914
|
} = provider.getChain();
|
4809
4915
|
const gasPrice = await provider.getLatestGasPrice();
|
4810
4916
|
const transactionInfo = assembleTransactionSummary({
|
@@ -4813,8 +4919,8 @@ async function getTransactionSummary(params) {
|
|
4813
4919
|
transaction: decodedTransaction,
|
4814
4920
|
transactionBytes: arrayify12(gqlTransaction.rawPayload),
|
4815
4921
|
gqlTransactionStatus: gqlTransaction.status,
|
4816
|
-
gasPerByte:
|
4817
|
-
gasPriceFactor:
|
4922
|
+
gasPerByte: bn18(gasPerByte),
|
4923
|
+
gasPriceFactor: bn18(gasPriceFactor),
|
4818
4924
|
abiMap,
|
4819
4925
|
maxInputs,
|
4820
4926
|
gasCosts,
|
@@ -4830,7 +4936,7 @@ async function getTransactionSummaryFromRequest(params) {
|
|
4830
4936
|
const { provider, transactionRequest, abiMap } = params;
|
4831
4937
|
const { receipts } = await provider.call(transactionRequest);
|
4832
4938
|
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
|
4833
|
-
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
4939
|
+
const maxInputs = provider.getChain().consensusParameters.txParameters.maxInputs;
|
4834
4940
|
const transaction = transactionRequest.toTransaction();
|
4835
4941
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
4836
4942
|
const gasPrice = await provider.getLatestGasPrice();
|
@@ -4853,7 +4959,11 @@ async function getTransactionsSummaries(params) {
|
|
4853
4959
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
4854
4960
|
const { edges, pageInfo } = transactionsByOwner;
|
4855
4961
|
const {
|
4856
|
-
consensusParameters: {
|
4962
|
+
consensusParameters: {
|
4963
|
+
feeParameters: { gasPerByte, gasPriceFactor },
|
4964
|
+
txParameters: { maxInputs, maxGasPerTx },
|
4965
|
+
gasCosts
|
4966
|
+
}
|
4857
4967
|
} = provider.getChain();
|
4858
4968
|
const gasPrice = await provider.getLatestGasPrice();
|
4859
4969
|
const transactions = edges.map((edge) => {
|
@@ -5012,6 +5122,22 @@ var assets = [
|
|
5012
5122
|
}
|
5013
5123
|
];
|
5014
5124
|
|
5125
|
+
// src/providers/transaction-request/helpers.ts
|
5126
|
+
import { bn as bn19 } from "@fuel-ts/math";
|
5127
|
+
import { InputType as InputType8 } from "@fuel-ts/transactions";
|
5128
|
+
var isRequestInputCoin = (input) => input.type === InputType8.Coin;
|
5129
|
+
var isRequestInputMessage = (input) => input.type === InputType8.Message;
|
5130
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
5131
|
+
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
5132
|
+
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
5133
|
+
return acc.add(input.amount);
|
5134
|
+
}
|
5135
|
+
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
5136
|
+
return acc.add(input.amount);
|
5137
|
+
}
|
5138
|
+
return acc;
|
5139
|
+
}, bn19(0));
|
5140
|
+
|
5015
5141
|
// src/utils/formatTransferToContractScriptData.ts
|
5016
5142
|
import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
5017
5143
|
import { BN as BN2 } from "@fuel-ts/math";
|
@@ -5049,6 +5175,7 @@ var assembleTransferToContractScript = async (params) => {
|
|
5049
5175
|
};
|
5050
5176
|
|
5051
5177
|
// src/account.ts
|
5178
|
+
var MAX_FUNDING_ATTEMPTS = 2;
|
5052
5179
|
var Account = class extends AbstractAccount {
|
5053
5180
|
/**
|
5054
5181
|
* The address associated with the account.
|
@@ -5206,16 +5333,17 @@ var Account = class extends AbstractAccount {
|
|
5206
5333
|
* Adds resources to the transaction enough to fund it.
|
5207
5334
|
*
|
5208
5335
|
* @param request - The transaction request.
|
5209
|
-
* @param
|
5336
|
+
* @param requiredQuantities - The coin quantities required to execute the transaction.
|
5210
5337
|
* @param fee - The estimated transaction fee.
|
5211
5338
|
* @returns A promise that resolves when the resources are added to the transaction.
|
5212
5339
|
*/
|
5213
5340
|
async fund(request, params) {
|
5214
5341
|
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
5215
5342
|
const baseAssetId = this.provider.getBaseAssetId();
|
5343
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn20(0);
|
5216
5344
|
const txRequest = request;
|
5217
5345
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5218
|
-
amount:
|
5346
|
+
amount: bn20(fee),
|
5219
5347
|
assetId: baseAssetId,
|
5220
5348
|
coinQuantities: requiredQuantities
|
5221
5349
|
});
|
@@ -5223,21 +5351,17 @@ var Account = class extends AbstractAccount {
|
|
5223
5351
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
5224
5352
|
quantitiesDict[assetId] = {
|
5225
5353
|
required: amount,
|
5226
|
-
owned:
|
5354
|
+
owned: bn20(0)
|
5227
5355
|
};
|
5228
5356
|
});
|
5229
|
-
|
5230
|
-
const
|
5231
|
-
if (!isResource) {
|
5232
|
-
return;
|
5233
|
-
}
|
5234
|
-
const isCoin2 = "owner" in input;
|
5357
|
+
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
5358
|
+
const isCoin2 = isRequestInputCoin(input);
|
5235
5359
|
const assetId = isCoin2 ? String(input.assetId) : baseAssetId;
|
5236
5360
|
if (quantitiesDict[assetId]) {
|
5237
5361
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(input.amount);
|
5238
5362
|
}
|
5239
5363
|
});
|
5240
|
-
|
5364
|
+
let missingQuantities = [];
|
5241
5365
|
Object.entries(quantitiesDict).forEach(([assetId, { owned, required }]) => {
|
5242
5366
|
if (owned.lt(required)) {
|
5243
5367
|
missingQuantities.push({
|
@@ -5246,11 +5370,42 @@ var Account = class extends AbstractAccount {
|
|
5246
5370
|
});
|
5247
5371
|
}
|
5248
5372
|
});
|
5249
|
-
|
5250
|
-
|
5251
|
-
|
5252
|
-
const resources = await this.getResourcesToSpend(
|
5253
|
-
|
5373
|
+
let needsToBeFunded = missingQuantities.length > 0;
|
5374
|
+
let fundingAttempts = 0;
|
5375
|
+
while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
|
5376
|
+
const resources = await this.getResourcesToSpend(
|
5377
|
+
missingQuantities,
|
5378
|
+
cacheTxInputsFromOwner(request.inputs, this.address)
|
5379
|
+
);
|
5380
|
+
request.addResources(resources);
|
5381
|
+
txRequest.shiftPredicateData();
|
5382
|
+
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
5383
|
+
const requestToReestimate2 = clone4(txRequest);
|
5384
|
+
if (addedSignatures) {
|
5385
|
+
Array.from({ length: addedSignatures }).forEach(
|
5386
|
+
() => requestToReestimate2.addEmptyWitness()
|
5387
|
+
);
|
5388
|
+
}
|
5389
|
+
const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
|
5390
|
+
transactionRequest: requestToReestimate2
|
5391
|
+
});
|
5392
|
+
const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
|
5393
|
+
request.inputs,
|
5394
|
+
baseAssetId,
|
5395
|
+
baseAssetId
|
5396
|
+
);
|
5397
|
+
const totalBaseAssetRequiredWithFee = requiredInBaseAsset.add(newFee);
|
5398
|
+
if (totalBaseAssetOnInputs.gt(totalBaseAssetRequiredWithFee)) {
|
5399
|
+
needsToBeFunded = false;
|
5400
|
+
} else {
|
5401
|
+
missingQuantities = [
|
5402
|
+
{
|
5403
|
+
amount: totalBaseAssetRequiredWithFee.sub(totalBaseAssetOnInputs),
|
5404
|
+
assetId: baseAssetId
|
5405
|
+
}
|
5406
|
+
];
|
5407
|
+
}
|
5408
|
+
fundingAttempts += 1;
|
5254
5409
|
}
|
5255
5410
|
txRequest.shiftPredicateData();
|
5256
5411
|
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
@@ -5301,7 +5456,7 @@ var Account = class extends AbstractAccount {
|
|
5301
5456
|
* @returns A promise that resolves to the transaction response.
|
5302
5457
|
*/
|
5303
5458
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5304
|
-
if (
|
5459
|
+
if (bn20(amount).lte(0)) {
|
5305
5460
|
throw new FuelError15(
|
5306
5461
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5307
5462
|
"Transfer amount must be a positive number."
|
@@ -5321,7 +5476,7 @@ var Account = class extends AbstractAccount {
|
|
5321
5476
|
* @returns A promise that resolves to the transaction response.
|
5322
5477
|
*/
|
5323
5478
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5324
|
-
if (
|
5479
|
+
if (bn20(amount).lte(0)) {
|
5325
5480
|
throw new FuelError15(
|
5326
5481
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5327
5482
|
"Transfer amount must be a positive number."
|
@@ -5331,7 +5486,7 @@ var Account = class extends AbstractAccount {
|
|
5331
5486
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5332
5487
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5333
5488
|
hexlifiedContractId: contractAddress.toB256(),
|
5334
|
-
amountToTransfer:
|
5489
|
+
amountToTransfer: bn20(amount),
|
5335
5490
|
assetId: assetIdToTransfer
|
5336
5491
|
});
|
5337
5492
|
const request = new ScriptTransactionRequest({
|
@@ -5342,7 +5497,7 @@ var Account = class extends AbstractAccount {
|
|
5342
5497
|
request.addContractInputAndOutput(contractAddress);
|
5343
5498
|
const txCost = await this.provider.getTransactionCost(request, {
|
5344
5499
|
resourcesOwner: this,
|
5345
|
-
quantitiesToContract: [{ amount:
|
5500
|
+
quantitiesToContract: [{ amount: bn20(amount), assetId: String(assetIdToTransfer) }]
|
5346
5501
|
});
|
5347
5502
|
this.validateGasLimitAndMaxFee({
|
5348
5503
|
gasUsed: txCost.gasUsed,
|
@@ -5368,7 +5523,7 @@ var Account = class extends AbstractAccount {
|
|
5368
5523
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5369
5524
|
);
|
5370
5525
|
const amountDataArray = arrayify14(
|
5371
|
-
"0x".concat(
|
5526
|
+
"0x".concat(bn20(amount).toHex().substring(2).padStart(16, "0"))
|
5372
5527
|
);
|
5373
5528
|
const script = new Uint8Array([
|
5374
5529
|
...arrayify14(withdrawScript.bytes),
|
@@ -5378,7 +5533,7 @@ var Account = class extends AbstractAccount {
|
|
5378
5533
|
const params = { script, ...txParams };
|
5379
5534
|
const baseAssetId = this.provider.getBaseAssetId();
|
5380
5535
|
const request = new ScriptTransactionRequest(params);
|
5381
|
-
const quantitiesToContract = [{ amount:
|
5536
|
+
const quantitiesToContract = [{ amount: bn20(amount), assetId: baseAssetId }];
|
5382
5537
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5383
5538
|
this.validateGasLimitAndMaxFee({
|
5384
5539
|
gasUsed: txCost.gasUsed,
|
@@ -5450,13 +5605,13 @@ var Account = class extends AbstractAccount {
|
|
5450
5605
|
gasUsed,
|
5451
5606
|
maxFee
|
5452
5607
|
}) {
|
5453
|
-
if (
|
5608
|
+
if (isDefined2(setGasLimit) && gasUsed.gt(setGasLimit)) {
|
5454
5609
|
throw new FuelError15(
|
5455
5610
|
ErrorCode15.GAS_LIMIT_TOO_LOW,
|
5456
5611
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5457
5612
|
);
|
5458
5613
|
}
|
5459
|
-
if (
|
5614
|
+
if (isDefined2(setMaxFee) && maxFee.gt(setMaxFee)) {
|
5460
5615
|
throw new FuelError15(
|
5461
5616
|
ErrorCode15.MAX_FEE_TOO_LOW,
|
5462
5617
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
@@ -5792,7 +5947,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5792
5947
|
// src/hdwallet/hdwallet.ts
|
5793
5948
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5794
5949
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5795
|
-
import { bn as
|
5950
|
+
import { bn as bn21, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5796
5951
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5797
5952
|
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5798
5953
|
|
@@ -8264,7 +8419,7 @@ var HDWallet = class {
|
|
8264
8419
|
const IR = bytes.slice(32);
|
8265
8420
|
if (privateKey) {
|
8266
8421
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8267
|
-
const ki =
|
8422
|
+
const ki = bn21(IL).add(privateKey).mod(N).toBytes(32);
|
8268
8423
|
return new HDWallet({
|
8269
8424
|
privateKey: ki,
|
8270
8425
|
chainCode: IR,
|
@@ -8952,7 +9107,7 @@ import {
|
|
8952
9107
|
} from "@fuel-ts/abi-coder";
|
8953
9108
|
import { Address as Address9 } from "@fuel-ts/address";
|
8954
9109
|
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
8955
|
-
import { ByteArrayCoder, InputType as
|
9110
|
+
import { ByteArrayCoder, InputType as InputType9 } from "@fuel-ts/transactions";
|
8956
9111
|
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
8957
9112
|
|
8958
9113
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -9012,7 +9167,7 @@ var Predicate = class extends Account {
|
|
9012
9167
|
const request = transactionRequestify(transactionRequestLike);
|
9013
9168
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
9014
9169
|
request.inputs?.forEach((input) => {
|
9015
|
-
if (input.type ===
|
9170
|
+
if (input.type === InputType9.Coin && hexlify19(input.owner) === this.address.toB256()) {
|
9016
9171
|
input.predicate = hexlify19(this.bytes);
|
9017
9172
|
input.predicateData = hexlify19(this.getPredicateData(policies.length));
|
9018
9173
|
}
|
@@ -9046,7 +9201,7 @@ var Predicate = class extends Account {
|
|
9046
9201
|
const mainFn = this.interface?.functions.main;
|
9047
9202
|
const paddedCode = new ByteArrayCoder(this.bytes.length).encode(this.bytes);
|
9048
9203
|
const VM_TX_MEMORY = calculateVmTxMemory2({
|
9049
|
-
maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
|
9204
|
+
maxInputs: this.provider.getChain().consensusParameters.txParameters.maxInputs.toNumber()
|
9050
9205
|
});
|
9051
9206
|
const OFFSET = VM_TX_MEMORY + SCRIPT_FIXED_SIZE + INPUT_COIN_FIXED_SIZE + WORD_SIZE + paddedCode.byteLength + policiesLength * WORD_SIZE;
|
9052
9207
|
return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
|
@@ -9863,7 +10018,7 @@ export {
|
|
9863
10018
|
calculateGasFee,
|
9864
10019
|
calculateMetadataGasForTxCreate,
|
9865
10020
|
calculateMetadataGasForTxScript,
|
9866
|
-
|
10021
|
+
calculateTXFeeForSummary,
|
9867
10022
|
coinQuantityfy,
|
9868
10023
|
deferPromise,
|
9869
10024
|
dispatchFuelConnectorEvent,
|
@@ -9923,6 +10078,8 @@ export {
|
|
9923
10078
|
isTypeCreate,
|
9924
10079
|
isTypeMint,
|
9925
10080
|
isTypeScript,
|
10081
|
+
isTypeUpgrade,
|
10082
|
+
isTypeUpload,
|
9926
10083
|
normalizeJSON,
|
9927
10084
|
outputify,
|
9928
10085
|
processGqlReceipt,
|