@fuel-ts/account 0.0.0-rc-2224-20240503155836 → 0.0.0-rc-2037-20240504194803
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/dist/index.global.js +1357 -485
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +497 -334
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +394 -240
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +9 -2
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +186 -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 +24 -21
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts +4 -0
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
- package/dist/providers/transaction-request/index.d.ts +1 -0
- package/dist/providers/transaction-request/index.d.ts.map +1 -1
- 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 +4 -3
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +0 -4
- 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 +6 -5
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/seedTestWallet.d.ts +1 -1
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils.global.js +1320 -496
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +422 -326
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +334 -238
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +16 -16
- 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/test-utils.mjs
CHANGED
@@ -26,7 +26,7 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
|
|
26
26
|
import { Address as Address3 } from "@fuel-ts/address";
|
27
27
|
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
28
28
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
29
|
-
import { bn as
|
29
|
+
import { bn as bn20 } from "@fuel-ts/math";
|
30
30
|
import { arrayify as arrayify14, isDefined as isDefined2 } from "@fuel-ts/utils";
|
31
31
|
import { clone as clone4 } from "ramda";
|
32
32
|
|
@@ -68,7 +68,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
68
68
|
// src/providers/provider.ts
|
69
69
|
import { Address as Address2 } from "@fuel-ts/address";
|
70
70
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
71
|
-
import { BN, bn as
|
71
|
+
import { BN, bn as bn18 } from "@fuel-ts/math";
|
72
72
|
import {
|
73
73
|
InputType as InputType7,
|
74
74
|
TransactionType as TransactionType8,
|
@@ -134,9 +134,6 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
134
134
|
id
|
135
135
|
}
|
136
136
|
time
|
137
|
-
receipts {
|
138
|
-
...receiptFragment
|
139
|
-
}
|
140
137
|
programState {
|
141
138
|
returnType
|
142
139
|
data
|
@@ -144,11 +141,15 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
144
141
|
receipts {
|
145
142
|
...receiptFragment
|
146
143
|
}
|
144
|
+
totalGas
|
145
|
+
totalFee
|
147
146
|
}
|
148
147
|
... on FailureStatus {
|
149
148
|
block {
|
150
149
|
id
|
151
150
|
}
|
151
|
+
totalGas
|
152
|
+
totalFee
|
152
153
|
time
|
153
154
|
reason
|
154
155
|
receipts {
|
@@ -188,6 +189,8 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
|
|
188
189
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
189
190
|
var DryRunFailureStatusFragmentFragmentDoc = gql`
|
190
191
|
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
192
|
+
totalGas
|
193
|
+
totalFee
|
191
194
|
reason
|
192
195
|
programState {
|
193
196
|
returnType
|
@@ -197,6 +200,8 @@ var DryRunFailureStatusFragmentFragmentDoc = gql`
|
|
197
200
|
`;
|
198
201
|
var DryRunSuccessStatusFragmentFragmentDoc = gql`
|
199
202
|
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
203
|
+
totalGas
|
204
|
+
totalFee
|
200
205
|
programState {
|
201
206
|
returnType
|
202
207
|
data
|
@@ -332,6 +337,7 @@ var TxParametersFragmentFragmentDoc = gql`
|
|
332
337
|
maxWitnesses
|
333
338
|
maxGasPerTx
|
334
339
|
maxSize
|
340
|
+
maxBytecodeSubsections
|
335
341
|
}
|
336
342
|
`;
|
337
343
|
var PredicateParametersFragmentFragmentDoc = gql`
|
@@ -601,6 +607,14 @@ var NodeInfoFragmentFragmentDoc = gql`
|
|
601
607
|
nodeVersion
|
602
608
|
}
|
603
609
|
`;
|
610
|
+
var RelayedTransactionStatusFragmentFragmentDoc = gql`
|
611
|
+
fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
|
612
|
+
... on RelayedTransactionFailed {
|
613
|
+
blockHeight
|
614
|
+
failure
|
615
|
+
}
|
616
|
+
}
|
617
|
+
`;
|
604
618
|
var GetVersionDocument = gql`
|
605
619
|
query getVersion {
|
606
620
|
nodeInfo {
|
@@ -830,6 +844,13 @@ var GetMessageStatusDocument = gql`
|
|
830
844
|
}
|
831
845
|
}
|
832
846
|
`;
|
847
|
+
var GetRelayedTransactionStatusDocument = gql`
|
848
|
+
query getRelayedTransactionStatus($relayedTransactionId: RelayedTransactionId!) {
|
849
|
+
relayedTransactionStatus(id: $relayedTransactionId) {
|
850
|
+
...relayedTransactionStatusFragment
|
851
|
+
}
|
852
|
+
}
|
853
|
+
${RelayedTransactionStatusFragmentFragmentDoc}`;
|
833
854
|
var DryRunDocument = gql`
|
834
855
|
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
835
856
|
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
@@ -944,6 +965,9 @@ function getSdk(requester) {
|
|
944
965
|
getMessageStatus(variables, options) {
|
945
966
|
return requester(GetMessageStatusDocument, variables, options);
|
946
967
|
},
|
968
|
+
getRelayedTransactionStatus(variables, options) {
|
969
|
+
return requester(GetRelayedTransactionStatusDocument, variables, options);
|
970
|
+
},
|
947
971
|
dryRun(variables, options) {
|
948
972
|
return requester(DryRunDocument, variables, options);
|
949
973
|
},
|
@@ -1240,11 +1264,11 @@ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
|
|
1240
1264
|
import { Address, addressify } from "@fuel-ts/address";
|
1241
1265
|
import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
|
1242
1266
|
import { randomBytes } from "@fuel-ts/crypto";
|
1243
|
-
import { bn as
|
1267
|
+
import { bn as bn8 } from "@fuel-ts/math";
|
1244
1268
|
import {
|
1245
1269
|
PolicyType,
|
1246
1270
|
TransactionCoder,
|
1247
|
-
InputType as
|
1271
|
+
InputType as InputType3,
|
1248
1272
|
OutputType as OutputType2,
|
1249
1273
|
TransactionType
|
1250
1274
|
} from "@fuel-ts/transactions";
|
@@ -1694,6 +1718,36 @@ var NoWitnessAtIndexError = class extends Error {
|
|
1694
1718
|
name = "NoWitnessAtIndexError";
|
1695
1719
|
};
|
1696
1720
|
|
1721
|
+
// src/providers/transaction-request/helpers.ts
|
1722
|
+
import { bn as bn7 } from "@fuel-ts/math";
|
1723
|
+
import { InputType as InputType2 } from "@fuel-ts/transactions";
|
1724
|
+
var isRequestInputCoin = (input) => input.type === InputType2.Coin;
|
1725
|
+
var isRequestInputMessage = (input) => input.type === InputType2.Message;
|
1726
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
1727
|
+
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
1728
|
+
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
1729
|
+
return acc.add(input.amount);
|
1730
|
+
}
|
1731
|
+
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
1732
|
+
return acc.add(input.amount);
|
1733
|
+
}
|
1734
|
+
return acc;
|
1735
|
+
}, bn7(0));
|
1736
|
+
var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
1737
|
+
(acc, input) => {
|
1738
|
+
if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
|
1739
|
+
acc.utxos.push(input.id);
|
1740
|
+
} else if (isRequestInputMessage(input) && input.recipient === owner.toB256()) {
|
1741
|
+
acc.messages.push(input.nonce);
|
1742
|
+
}
|
1743
|
+
return acc;
|
1744
|
+
},
|
1745
|
+
{
|
1746
|
+
utxos: [],
|
1747
|
+
messages: []
|
1748
|
+
}
|
1749
|
+
);
|
1750
|
+
|
1697
1751
|
// src/providers/transaction-request/witness.ts
|
1698
1752
|
import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
|
1699
1753
|
var witnessify = (value) => {
|
@@ -1734,10 +1788,10 @@ var BaseTransactionRequest = class {
|
|
1734
1788
|
outputs,
|
1735
1789
|
witnesses
|
1736
1790
|
} = {}) {
|
1737
|
-
this.tip = tip ?
|
1791
|
+
this.tip = tip ? bn8(tip) : void 0;
|
1738
1792
|
this.maturity = maturity && maturity > 0 ? maturity : void 0;
|
1739
|
-
this.witnessLimit = isDefined(witnessLimit) ?
|
1740
|
-
this.maxFee =
|
1793
|
+
this.witnessLimit = isDefined(witnessLimit) ? bn8(witnessLimit) : void 0;
|
1794
|
+
this.maxFee = bn8(maxFee);
|
1741
1795
|
this.inputs = inputs ?? [];
|
1742
1796
|
this.outputs = outputs ?? [];
|
1743
1797
|
this.witnesses = witnesses ?? [];
|
@@ -1746,13 +1800,13 @@ var BaseTransactionRequest = class {
|
|
1746
1800
|
let policyTypes = 0;
|
1747
1801
|
const policies = [];
|
1748
1802
|
const { tip, witnessLimit, maturity } = req;
|
1749
|
-
if (
|
1803
|
+
if (bn8(tip).gt(0)) {
|
1750
1804
|
policyTypes += PolicyType.Tip;
|
1751
|
-
policies.push({ data:
|
1805
|
+
policies.push({ data: bn8(tip), type: PolicyType.Tip });
|
1752
1806
|
}
|
1753
|
-
if (isDefined(witnessLimit) &&
|
1807
|
+
if (isDefined(witnessLimit) && bn8(witnessLimit).gte(0)) {
|
1754
1808
|
policyTypes += PolicyType.WitnessLimit;
|
1755
|
-
policies.push({ data:
|
1809
|
+
policies.push({ data: bn8(witnessLimit), type: PolicyType.WitnessLimit });
|
1756
1810
|
}
|
1757
1811
|
if (maturity && maturity > 0) {
|
1758
1812
|
policyTypes += PolicyType.Maturity;
|
@@ -1883,7 +1937,7 @@ var BaseTransactionRequest = class {
|
|
1883
1937
|
*/
|
1884
1938
|
getCoinInputs() {
|
1885
1939
|
return this.inputs.filter(
|
1886
|
-
(input) => input.type ===
|
1940
|
+
(input) => input.type === InputType3.Coin
|
1887
1941
|
);
|
1888
1942
|
}
|
1889
1943
|
/**
|
@@ -1915,9 +1969,9 @@ var BaseTransactionRequest = class {
|
|
1915
1969
|
const ownerAddress = addressify(owner);
|
1916
1970
|
const found = this.inputs.find((input) => {
|
1917
1971
|
switch (input.type) {
|
1918
|
-
case
|
1972
|
+
case InputType3.Coin:
|
1919
1973
|
return hexlify7(input.owner) === ownerAddress.toB256();
|
1920
|
-
case
|
1974
|
+
case InputType3.Message:
|
1921
1975
|
return hexlify7(input.recipient) === ownerAddress.toB256();
|
1922
1976
|
default:
|
1923
1977
|
return false;
|
@@ -1932,7 +1986,7 @@ var BaseTransactionRequest = class {
|
|
1932
1986
|
* @param coin - Coin resource.
|
1933
1987
|
*/
|
1934
1988
|
addCoinInput(coin) {
|
1935
|
-
const { assetId, owner, amount } = coin;
|
1989
|
+
const { assetId, owner, amount, id, predicate } = coin;
|
1936
1990
|
let witnessIndex;
|
1937
1991
|
if (coin.predicate) {
|
1938
1992
|
witnessIndex = 0;
|
@@ -1943,13 +1997,14 @@ var BaseTransactionRequest = class {
|
|
1943
1997
|
}
|
1944
1998
|
}
|
1945
1999
|
const input = {
|
1946
|
-
|
1947
|
-
type:
|
2000
|
+
id,
|
2001
|
+
type: InputType3.Coin,
|
1948
2002
|
owner: owner.toB256(),
|
1949
2003
|
amount,
|
1950
2004
|
assetId,
|
1951
2005
|
txPointer: "0x00000000000000000000000000000000",
|
1952
|
-
witnessIndex
|
2006
|
+
witnessIndex,
|
2007
|
+
predicate
|
1953
2008
|
};
|
1954
2009
|
this.pushInput(input);
|
1955
2010
|
this.addChangeOutput(owner, assetId);
|
@@ -1961,7 +2016,7 @@ var BaseTransactionRequest = class {
|
|
1961
2016
|
* @param message - Message resource.
|
1962
2017
|
*/
|
1963
2018
|
addMessageInput(message) {
|
1964
|
-
const { recipient, sender, amount, assetId } = message;
|
2019
|
+
const { recipient, sender, amount, predicate, nonce, assetId } = message;
|
1965
2020
|
let witnessIndex;
|
1966
2021
|
if (message.predicate) {
|
1967
2022
|
witnessIndex = 0;
|
@@ -1972,12 +2027,13 @@ var BaseTransactionRequest = class {
|
|
1972
2027
|
}
|
1973
2028
|
}
|
1974
2029
|
const input = {
|
1975
|
-
|
1976
|
-
type:
|
2030
|
+
nonce,
|
2031
|
+
type: InputType3.Message,
|
1977
2032
|
sender: sender.toB256(),
|
1978
2033
|
recipient: recipient.toB256(),
|
1979
2034
|
amount,
|
1980
|
-
witnessIndex
|
2035
|
+
witnessIndex,
|
2036
|
+
predicate
|
1981
2037
|
};
|
1982
2038
|
this.pushInput(input);
|
1983
2039
|
this.addChangeOutput(recipient, assetId);
|
@@ -2075,8 +2131,11 @@ var BaseTransactionRequest = class {
|
|
2075
2131
|
* @hidden
|
2076
2132
|
*/
|
2077
2133
|
calculateMinGas(chainInfo) {
|
2078
|
-
const {
|
2079
|
-
const {
|
2134
|
+
const { consensusParameters } = chainInfo;
|
2135
|
+
const {
|
2136
|
+
gasCosts,
|
2137
|
+
feeParameters: { gasPerByte }
|
2138
|
+
} = consensusParameters;
|
2080
2139
|
return getMinGas({
|
2081
2140
|
gasPerByte,
|
2082
2141
|
gasCosts,
|
@@ -2087,7 +2146,10 @@ var BaseTransactionRequest = class {
|
|
2087
2146
|
}
|
2088
2147
|
calculateMaxGas(chainInfo, minGas) {
|
2089
2148
|
const { consensusParameters } = chainInfo;
|
2090
|
-
const {
|
2149
|
+
const {
|
2150
|
+
feeParameters: { gasPerByte },
|
2151
|
+
txParameters: { maxGasPerTx }
|
2152
|
+
} = consensusParameters;
|
2091
2153
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2092
2154
|
(acc, wit) => acc + wit.dataLength,
|
2093
2155
|
0
|
@@ -2118,7 +2180,7 @@ var BaseTransactionRequest = class {
|
|
2118
2180
|
const assetInput = findAssetInput(assetId);
|
2119
2181
|
let usedQuantity = quantity;
|
2120
2182
|
if (assetId === baseAssetId) {
|
2121
|
-
usedQuantity =
|
2183
|
+
usedQuantity = bn8("1000000000000000000");
|
2122
2184
|
}
|
2123
2185
|
if (assetInput && "assetId" in assetInput) {
|
2124
2186
|
assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
|
@@ -2130,13 +2192,13 @@ var BaseTransactionRequest = class {
|
|
2130
2192
|
amount: usedQuantity,
|
2131
2193
|
assetId,
|
2132
2194
|
owner: resourcesOwner || Address.fromRandom(),
|
2133
|
-
blockCreated:
|
2134
|
-
txCreatedIdx:
|
2195
|
+
blockCreated: bn8(1),
|
2196
|
+
txCreatedIdx: bn8(1)
|
2135
2197
|
}
|
2136
2198
|
]);
|
2137
2199
|
}
|
2138
2200
|
};
|
2139
|
-
updateAssetInput(baseAssetId,
|
2201
|
+
updateAssetInput(baseAssetId, bn8(1e11));
|
2140
2202
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2141
2203
|
}
|
2142
2204
|
/**
|
@@ -2147,7 +2209,7 @@ var BaseTransactionRequest = class {
|
|
2147
2209
|
*/
|
2148
2210
|
getCoinOutputsQuantities() {
|
2149
2211
|
const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
|
2150
|
-
amount:
|
2212
|
+
amount: bn8(amount),
|
2151
2213
|
assetId: assetId.toString()
|
2152
2214
|
}));
|
2153
2215
|
return coinsQuantities;
|
@@ -2161,22 +2223,33 @@ var BaseTransactionRequest = class {
|
|
2161
2223
|
toJSON() {
|
2162
2224
|
return normalizeJSON(this);
|
2163
2225
|
}
|
2226
|
+
removeWitness(index) {
|
2227
|
+
this.witnesses.splice(index, 1);
|
2228
|
+
this.adjustWitnessIndexes(index);
|
2229
|
+
}
|
2230
|
+
adjustWitnessIndexes(removedIndex) {
|
2231
|
+
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
2232
|
+
if (input.witnessIndex > removedIndex) {
|
2233
|
+
input.witnessIndex -= 1;
|
2234
|
+
}
|
2235
|
+
});
|
2236
|
+
}
|
2164
2237
|
updatePredicateGasUsed(inputs) {
|
2165
2238
|
this.inputs.forEach((i) => {
|
2166
2239
|
let correspondingInput;
|
2167
2240
|
switch (i.type) {
|
2168
|
-
case
|
2169
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2241
|
+
case InputType3.Coin:
|
2242
|
+
correspondingInput = inputs.find((x) => x.type === InputType3.Coin && x.owner === i.owner);
|
2170
2243
|
break;
|
2171
|
-
case
|
2244
|
+
case InputType3.Message:
|
2172
2245
|
correspondingInput = inputs.find(
|
2173
|
-
(x) => x.type ===
|
2246
|
+
(x) => x.type === InputType3.Message && x.sender === i.sender
|
2174
2247
|
);
|
2175
2248
|
break;
|
2176
2249
|
default:
|
2177
2250
|
return;
|
2178
2251
|
}
|
2179
|
-
if (correspondingInput && "predicateGasUsed" in correspondingInput &&
|
2252
|
+
if (correspondingInput && "predicateGasUsed" in correspondingInput && bn8(correspondingInput.predicateGasUsed).gt(0)) {
|
2180
2253
|
i.predicate = correspondingInput.predicate;
|
2181
2254
|
i.predicateData = correspondingInput.predicateData;
|
2182
2255
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
@@ -2196,15 +2269,15 @@ var BaseTransactionRequest = class {
|
|
2196
2269
|
|
2197
2270
|
// src/providers/transaction-request/create-transaction-request.ts
|
2198
2271
|
import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
|
2199
|
-
import { bn as
|
2272
|
+
import { bn as bn10 } from "@fuel-ts/math";
|
2200
2273
|
import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
|
2201
2274
|
import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
2202
2275
|
|
2203
2276
|
// src/providers/transaction-request/hash-transaction.ts
|
2204
2277
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2205
2278
|
import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
|
2206
|
-
import { bn as
|
2207
|
-
import { TransactionType as TransactionType2, InputType as
|
2279
|
+
import { bn as bn9 } from "@fuel-ts/math";
|
2280
|
+
import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
|
2208
2281
|
import { concat as concat2 } from "@fuel-ts/utils";
|
2209
2282
|
import { clone as clone2 } from "ramda";
|
2210
2283
|
function hashTransaction(transactionRequest, chainId) {
|
@@ -2215,19 +2288,19 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2215
2288
|
transaction.inputs = transaction.inputs.map((input) => {
|
2216
2289
|
const inputClone = clone2(input);
|
2217
2290
|
switch (inputClone.type) {
|
2218
|
-
case
|
2291
|
+
case InputType4.Coin: {
|
2219
2292
|
inputClone.txPointer = {
|
2220
2293
|
blockHeight: 0,
|
2221
2294
|
txIndex: 0
|
2222
2295
|
};
|
2223
|
-
inputClone.predicateGasUsed =
|
2296
|
+
inputClone.predicateGasUsed = bn9(0);
|
2224
2297
|
return inputClone;
|
2225
2298
|
}
|
2226
|
-
case
|
2227
|
-
inputClone.predicateGasUsed =
|
2299
|
+
case InputType4.Message: {
|
2300
|
+
inputClone.predicateGasUsed = bn9(0);
|
2228
2301
|
return inputClone;
|
2229
2302
|
}
|
2230
|
-
case
|
2303
|
+
case InputType4.Contract: {
|
2231
2304
|
inputClone.txPointer = {
|
2232
2305
|
blockHeight: 0,
|
2233
2306
|
txIndex: 0
|
@@ -2251,12 +2324,12 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2251
2324
|
return outputClone;
|
2252
2325
|
}
|
2253
2326
|
case OutputType3.Change: {
|
2254
|
-
outputClone.amount =
|
2327
|
+
outputClone.amount = bn9(0);
|
2255
2328
|
return outputClone;
|
2256
2329
|
}
|
2257
2330
|
case OutputType3.Variable: {
|
2258
2331
|
outputClone.to = ZeroBytes325;
|
2259
|
-
outputClone.amount =
|
2332
|
+
outputClone.amount = bn9(0);
|
2260
2333
|
outputClone.assetId = ZeroBytes325;
|
2261
2334
|
return outputClone;
|
2262
2335
|
}
|
@@ -2334,7 +2407,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2334
2407
|
type: TransactionType3.Create,
|
2335
2408
|
...baseTransaction,
|
2336
2409
|
bytecodeWitnessIndex,
|
2337
|
-
storageSlotsCount:
|
2410
|
+
storageSlotsCount: bn10(storageSlots.length),
|
2338
2411
|
salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
|
2339
2412
|
storageSlots
|
2340
2413
|
};
|
@@ -2374,7 +2447,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2374
2447
|
}
|
2375
2448
|
metadataGas(gasCosts) {
|
2376
2449
|
return calculateMetadataGasForTxCreate({
|
2377
|
-
contractBytesSize:
|
2450
|
+
contractBytesSize: bn10(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2378
2451
|
gasCosts,
|
2379
2452
|
stateRootSize: this.storageSlots.length,
|
2380
2453
|
txBytesSize: this.byteSize()
|
@@ -2386,8 +2459,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2386
2459
|
import { Interface } from "@fuel-ts/abi-coder";
|
2387
2460
|
import { addressify as addressify2 } from "@fuel-ts/address";
|
2388
2461
|
import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
2389
|
-
import { bn as
|
2390
|
-
import { InputType as
|
2462
|
+
import { bn as bn11 } from "@fuel-ts/math";
|
2463
|
+
import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
2391
2464
|
import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
|
2392
2465
|
|
2393
2466
|
// src/providers/transaction-request/scripts.ts
|
@@ -2440,7 +2513,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2440
2513
|
*/
|
2441
2514
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2442
2515
|
super(rest);
|
2443
|
-
this.gasLimit =
|
2516
|
+
this.gasLimit = bn11(gasLimit);
|
2444
2517
|
this.script = arrayify8(script ?? returnZeroScript.bytes);
|
2445
2518
|
this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
|
2446
2519
|
this.abis = rest.abis;
|
@@ -2457,8 +2530,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2457
2530
|
type: TransactionType4.Script,
|
2458
2531
|
scriptGasLimit: this.gasLimit,
|
2459
2532
|
...super.getBaseTransaction(),
|
2460
|
-
scriptLength:
|
2461
|
-
scriptDataLength:
|
2533
|
+
scriptLength: bn11(script.length),
|
2534
|
+
scriptDataLength: bn11(scriptData.length),
|
2462
2535
|
receiptsRoot: ZeroBytes327,
|
2463
2536
|
script: hexlify10(script),
|
2464
2537
|
scriptData: hexlify10(scriptData)
|
@@ -2471,7 +2544,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2471
2544
|
*/
|
2472
2545
|
getContractInputs() {
|
2473
2546
|
return this.inputs.filter(
|
2474
|
-
(input) => input.type ===
|
2547
|
+
(input) => input.type === InputType5.Contract
|
2475
2548
|
);
|
2476
2549
|
}
|
2477
2550
|
/**
|
@@ -2522,7 +2595,10 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2522
2595
|
}
|
2523
2596
|
calculateMaxGas(chainInfo, minGas) {
|
2524
2597
|
const { consensusParameters } = chainInfo;
|
2525
|
-
const {
|
2598
|
+
const {
|
2599
|
+
feeParameters: { gasPerByte },
|
2600
|
+
txParameters: { maxGasPerTx }
|
2601
|
+
} = consensusParameters;
|
2526
2602
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2527
2603
|
(acc, wit) => acc + wit.dataLength,
|
2528
2604
|
0
|
@@ -2548,7 +2624,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2548
2624
|
return this;
|
2549
2625
|
}
|
2550
2626
|
const inputIndex = super.pushInput({
|
2551
|
-
type:
|
2627
|
+
type: InputType5.Contract,
|
2552
2628
|
contractId: contractAddress.toB256(),
|
2553
2629
|
txPointer: "0x00000000000000000000000000000000"
|
2554
2630
|
});
|
@@ -2590,7 +2666,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2590
2666
|
|
2591
2667
|
// src/providers/transaction-request/utils.ts
|
2592
2668
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2593
|
-
import { TransactionType as TransactionType5
|
2669
|
+
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2594
2670
|
var transactionRequestify = (obj) => {
|
2595
2671
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2596
2672
|
return obj;
|
@@ -2608,61 +2684,46 @@ var transactionRequestify = (obj) => {
|
|
2608
2684
|
}
|
2609
2685
|
}
|
2610
2686
|
};
|
2611
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2612
|
-
(acc, input) => {
|
2613
|
-
if (input.type === InputType5.Coin && input.owner === owner.toB256()) {
|
2614
|
-
acc.utxos.push(input.id);
|
2615
|
-
}
|
2616
|
-
if (input.type === InputType5.Message && input.recipient === owner.toB256()) {
|
2617
|
-
acc.messages.push(input.nonce);
|
2618
|
-
}
|
2619
|
-
return acc;
|
2620
|
-
},
|
2621
|
-
{
|
2622
|
-
utxos: [],
|
2623
|
-
messages: []
|
2624
|
-
}
|
2625
|
-
);
|
2626
2687
|
|
2627
2688
|
// src/providers/transaction-response/transaction-response.ts
|
2628
2689
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2629
|
-
import { bn as
|
2690
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
2630
2691
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2631
2692
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2632
2693
|
|
2633
2694
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2634
|
-
import { bn as
|
2695
|
+
import { bn as bn16 } from "@fuel-ts/math";
|
2635
2696
|
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2636
2697
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2637
2698
|
|
2638
|
-
// src/providers/transaction-summary/calculate-
|
2639
|
-
import { bn as
|
2699
|
+
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
2700
|
+
import { bn as bn12 } from "@fuel-ts/math";
|
2640
2701
|
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
|
2641
2702
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2642
|
-
var
|
2703
|
+
var calculateTXFeeForSummary = (params) => {
|
2643
2704
|
const {
|
2644
2705
|
gasPrice,
|
2645
2706
|
rawPayload,
|
2646
2707
|
tip,
|
2708
|
+
totalFee,
|
2647
2709
|
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2648
2710
|
} = params;
|
2649
|
-
|
2650
|
-
|
2711
|
+
if (totalFee) {
|
2712
|
+
return totalFee;
|
2713
|
+
}
|
2714
|
+
const gasPerByte = bn12(feeParams.gasPerByte);
|
2715
|
+
const gasPriceFactor = bn12(feeParams.gasPriceFactor);
|
2651
2716
|
const transactionBytes = arrayify9(rawPayload);
|
2652
2717
|
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
2653
|
-
if (transaction.type === TransactionType6.Mint) {
|
2654
|
-
return {
|
2655
|
-
fee: bn11(0),
|
2656
|
-
minFee: bn11(0),
|
2657
|
-
maxFee: bn11(0)
|
2658
|
-
};
|
2659
|
-
}
|
2660
2718
|
const { type, witnesses, inputs, policies } = transaction;
|
2661
|
-
let metadataGas =
|
2662
|
-
let gasLimit =
|
2719
|
+
let metadataGas = bn12(0);
|
2720
|
+
let gasLimit = bn12(0);
|
2721
|
+
if (type !== TransactionType6.Create && type !== TransactionType6.Script) {
|
2722
|
+
return bn12(0);
|
2723
|
+
}
|
2663
2724
|
if (type === TransactionType6.Create) {
|
2664
2725
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2665
|
-
const contractBytesSize =
|
2726
|
+
const contractBytesSize = bn12(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
|
2666
2727
|
metadataGas = calculateMetadataGasForTxCreate({
|
2667
2728
|
contractBytesSize,
|
2668
2729
|
gasCosts,
|
@@ -2681,7 +2742,7 @@ var calculateTransactionFee = (params) => {
|
|
2681
2742
|
}
|
2682
2743
|
const minGas = getMinGas({
|
2683
2744
|
gasCosts,
|
2684
|
-
gasPerByte:
|
2745
|
+
gasPerByte: bn12(gasPerByte),
|
2685
2746
|
inputs,
|
2686
2747
|
metadataGas,
|
2687
2748
|
txBytesSize: transactionBytes.length
|
@@ -2696,34 +2757,24 @@ var calculateTransactionFee = (params) => {
|
|
2696
2757
|
witnessLimit,
|
2697
2758
|
maxGasPerTx
|
2698
2759
|
});
|
2699
|
-
const minFee = calculateGasFee({
|
2700
|
-
gasPrice,
|
2701
|
-
gas: minGas,
|
2702
|
-
priceFactor: gasPriceFactor,
|
2703
|
-
tip
|
2704
|
-
});
|
2705
2760
|
const maxFee = calculateGasFee({
|
2706
2761
|
gasPrice,
|
2707
2762
|
gas: maxGas,
|
2708
2763
|
priceFactor: gasPriceFactor,
|
2709
2764
|
tip
|
2710
2765
|
});
|
2711
|
-
return
|
2712
|
-
minFee,
|
2713
|
-
maxFee,
|
2714
|
-
fee: maxFee
|
2715
|
-
};
|
2766
|
+
return maxFee;
|
2716
2767
|
};
|
2717
2768
|
|
2718
2769
|
// src/providers/transaction-summary/operations.ts
|
2719
2770
|
import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
|
2720
2771
|
import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
|
2721
|
-
import { bn as
|
2772
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
2722
2773
|
import { ReceiptType as ReceiptType4, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
2723
2774
|
|
2724
2775
|
// src/providers/transaction-summary/call.ts
|
2725
2776
|
import { Interface as Interface2, calculateVmTxMemory } from "@fuel-ts/abi-coder";
|
2726
|
-
import { bn as
|
2777
|
+
import { bn as bn13 } from "@fuel-ts/math";
|
2727
2778
|
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2728
2779
|
const abiInterface = new Interface2(abi);
|
2729
2780
|
const callFunctionSelector = receipt.param1.toHex(8);
|
@@ -2732,7 +2783,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2732
2783
|
let encodedArgs;
|
2733
2784
|
if (functionFragment.isInputDataPointer) {
|
2734
2785
|
if (rawPayload) {
|
2735
|
-
const argsOffset =
|
2786
|
+
const argsOffset = bn13(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2736
2787
|
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2737
2788
|
}
|
2738
2789
|
} else {
|
@@ -2871,6 +2922,12 @@ function isTypeCreate(transactionType) {
|
|
2871
2922
|
function isTypeScript(transactionType) {
|
2872
2923
|
return isType(transactionType, "Script" /* Script */);
|
2873
2924
|
}
|
2925
|
+
function isTypeUpgrade(transactionType) {
|
2926
|
+
return isType(transactionType, "Upgrade" /* Upgrade */);
|
2927
|
+
}
|
2928
|
+
function isTypeUpload(transactionType) {
|
2929
|
+
return isType(transactionType, "Upload" /* Upload */);
|
2930
|
+
}
|
2874
2931
|
function getReceiptsCall(receipts) {
|
2875
2932
|
return getReceiptsByType(receipts, ReceiptType4.Call);
|
2876
2933
|
}
|
@@ -2888,7 +2945,7 @@ var mergeAssets = (op1, op2) => {
|
|
2888
2945
|
if (!matchingAsset) {
|
2889
2946
|
return asset1;
|
2890
2947
|
}
|
2891
|
-
const mergedAmount =
|
2948
|
+
const mergedAmount = bn14(asset1.amount).add(matchingAsset.amount);
|
2892
2949
|
return { ...asset1, amount: mergedAmount };
|
2893
2950
|
});
|
2894
2951
|
return mergedAssets.concat(filteredAssets);
|
@@ -3211,6 +3268,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3211
3268
|
|
3212
3269
|
// src/providers/transaction-summary/status.ts
|
3213
3270
|
import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
|
3271
|
+
import { bn as bn15 } from "@fuel-ts/math";
|
3214
3272
|
var getTransactionStatusName = (gqlStatus) => {
|
3215
3273
|
switch (gqlStatus) {
|
3216
3274
|
case "FailureStatus":
|
@@ -3232,6 +3290,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3232
3290
|
let time;
|
3233
3291
|
let blockId;
|
3234
3292
|
let status;
|
3293
|
+
let totalFee;
|
3294
|
+
let totalGas;
|
3235
3295
|
let isStatusFailure = false;
|
3236
3296
|
let isStatusSuccess = false;
|
3237
3297
|
let isStatusPending = false;
|
@@ -3242,11 +3302,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3242
3302
|
time = gqlTransactionStatus.time;
|
3243
3303
|
blockId = gqlTransactionStatus.block.id;
|
3244
3304
|
isStatusSuccess = true;
|
3305
|
+
totalFee = bn15(gqlTransactionStatus.totalFee);
|
3306
|
+
totalGas = bn15(gqlTransactionStatus.totalGas);
|
3245
3307
|
break;
|
3246
3308
|
case "FailureStatus":
|
3247
3309
|
time = gqlTransactionStatus.time;
|
3248
3310
|
blockId = gqlTransactionStatus.block.id;
|
3249
3311
|
isStatusFailure = true;
|
3312
|
+
totalFee = bn15(gqlTransactionStatus.totalFee);
|
3313
|
+
totalGas = bn15(gqlTransactionStatus.totalGas);
|
3250
3314
|
break;
|
3251
3315
|
case "SubmittedStatus":
|
3252
3316
|
time = gqlTransactionStatus.time;
|
@@ -3259,6 +3323,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3259
3323
|
time,
|
3260
3324
|
blockId,
|
3261
3325
|
status,
|
3326
|
+
totalFee,
|
3327
|
+
totalGas,
|
3262
3328
|
isStatusFailure,
|
3263
3329
|
isStatusSuccess,
|
3264
3330
|
isStatusPending
|
@@ -3294,8 +3360,10 @@ function assembleTransactionSummary(params) {
|
|
3294
3360
|
maxInputs
|
3295
3361
|
});
|
3296
3362
|
const typeName = getTransactionTypeName(transaction.type);
|
3297
|
-
const tip =
|
3298
|
-
const {
|
3363
|
+
const tip = bn16(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3364
|
+
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3365
|
+
const fee = calculateTXFeeForSummary({
|
3366
|
+
totalFee,
|
3299
3367
|
gasPrice,
|
3300
3368
|
rawPayload,
|
3301
3369
|
tip,
|
@@ -3308,7 +3376,6 @@ function assembleTransactionSummary(params) {
|
|
3308
3376
|
}
|
3309
3377
|
}
|
3310
3378
|
});
|
3311
|
-
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time } = processGraphqlStatus(gqlTransactionStatus);
|
3312
3379
|
const mintedAssets = extractMintedAssetsFromReceipts(receipts);
|
3313
3380
|
const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
|
3314
3381
|
let date;
|
@@ -3317,6 +3384,7 @@ function assembleTransactionSummary(params) {
|
|
3317
3384
|
}
|
3318
3385
|
const transactionSummary = {
|
3319
3386
|
id,
|
3387
|
+
tip,
|
3320
3388
|
fee,
|
3321
3389
|
gasUsed,
|
3322
3390
|
operations,
|
@@ -3330,6 +3398,8 @@ function assembleTransactionSummary(params) {
|
|
3330
3398
|
isTypeMint: isTypeMint(transaction.type),
|
3331
3399
|
isTypeCreate: isTypeCreate(transaction.type),
|
3332
3400
|
isTypeScript: isTypeScript(transaction.type),
|
3401
|
+
isTypeUpgrade: isTypeUpgrade(transaction.type),
|
3402
|
+
isTypeUpload: isTypeUpload(transaction.type),
|
3333
3403
|
isStatusFailure,
|
3334
3404
|
isStatusSuccess,
|
3335
3405
|
isStatusPending,
|
@@ -3361,7 +3431,7 @@ var TransactionResponse = class {
|
|
3361
3431
|
/** Current provider */
|
3362
3432
|
provider;
|
3363
3433
|
/** Gas used on the transaction */
|
3364
|
-
gasUsed =
|
3434
|
+
gasUsed = bn17(0);
|
3365
3435
|
/** The graphql Transaction with receipts object. */
|
3366
3436
|
gqlTransaction;
|
3367
3437
|
abis;
|
@@ -3446,7 +3516,7 @@ var TransactionResponse = class {
|
|
3446
3516
|
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3447
3517
|
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3448
3518
|
const gasPrice = await this.provider.getLatestGasPrice();
|
3449
|
-
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3519
|
+
const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
|
3450
3520
|
const transactionSummary = assembleTransactionSummary({
|
3451
3521
|
id: this.id,
|
3452
3522
|
receipts,
|
@@ -3582,33 +3652,60 @@ var mergeQuantities = (...coinQuantities) => {
|
|
3582
3652
|
var MAX_RETRIES = 10;
|
3583
3653
|
var processGqlChain = (chain) => {
|
3584
3654
|
const { name, daHeight, consensusParameters, latestBlock } = chain;
|
3585
|
-
const {
|
3655
|
+
const {
|
3656
|
+
contractParams,
|
3657
|
+
feeParams,
|
3658
|
+
predicateParams,
|
3659
|
+
scriptParams,
|
3660
|
+
txParams,
|
3661
|
+
gasCosts,
|
3662
|
+
baseAssetId,
|
3663
|
+
chainId,
|
3664
|
+
version
|
3665
|
+
} = consensusParameters;
|
3586
3666
|
return {
|
3587
3667
|
name,
|
3588
|
-
baseChainHeight:
|
3668
|
+
baseChainHeight: bn18(daHeight),
|
3589
3669
|
consensusParameters: {
|
3590
|
-
|
3591
|
-
|
3592
|
-
|
3593
|
-
|
3594
|
-
|
3595
|
-
|
3596
|
-
|
3597
|
-
|
3598
|
-
|
3599
|
-
|
3600
|
-
|
3601
|
-
|
3602
|
-
|
3603
|
-
|
3604
|
-
|
3605
|
-
|
3670
|
+
version,
|
3671
|
+
chainId: bn18(chainId),
|
3672
|
+
baseAssetId,
|
3673
|
+
feeParameters: {
|
3674
|
+
version: feeParams.version,
|
3675
|
+
gasPerByte: bn18(feeParams.gasPerByte),
|
3676
|
+
gasPriceFactor: bn18(feeParams.gasPriceFactor)
|
3677
|
+
},
|
3678
|
+
contractParameters: {
|
3679
|
+
version: contractParams.version,
|
3680
|
+
contractMaxSize: bn18(contractParams.contractMaxSize),
|
3681
|
+
maxStorageSlots: bn18(contractParams.maxStorageSlots)
|
3682
|
+
},
|
3683
|
+
txParameters: {
|
3684
|
+
version: txParams.version,
|
3685
|
+
maxInputs: bn18(txParams.maxInputs),
|
3686
|
+
maxOutputs: bn18(txParams.maxOutputs),
|
3687
|
+
maxWitnesses: bn18(txParams.maxWitnesses),
|
3688
|
+
maxGasPerTx: bn18(txParams.maxGasPerTx),
|
3689
|
+
maxSize: bn18(txParams.maxSize),
|
3690
|
+
maxBytecodeSubsections: bn18(txParams.maxBytecodeSubsections)
|
3691
|
+
},
|
3692
|
+
predicateParameters: {
|
3693
|
+
version: predicateParams.version,
|
3694
|
+
maxPredicateLength: bn18(predicateParams.maxPredicateLength),
|
3695
|
+
maxPredicateDataLength: bn18(predicateParams.maxPredicateDataLength),
|
3696
|
+
maxGasPerPredicate: bn18(predicateParams.maxGasPerPredicate),
|
3697
|
+
maxMessageDataLength: bn18(predicateParams.maxMessageDataLength)
|
3698
|
+
},
|
3699
|
+
scriptParameters: {
|
3700
|
+
version: scriptParams.version,
|
3701
|
+
maxScriptLength: bn18(scriptParams.maxScriptLength),
|
3702
|
+
maxScriptDataLength: bn18(scriptParams.maxScriptDataLength)
|
3703
|
+
},
|
3606
3704
|
gasCosts
|
3607
3705
|
},
|
3608
|
-
gasCosts,
|
3609
3706
|
latestBlock: {
|
3610
3707
|
id: latestBlock.id,
|
3611
|
-
height:
|
3708
|
+
height: bn18(latestBlock.height),
|
3612
3709
|
time: latestBlock.header.time,
|
3613
3710
|
transactions: latestBlock.transactions.map((i) => ({
|
3614
3711
|
id: i.id
|
@@ -3702,7 +3799,12 @@ var _Provider = class {
|
|
3702
3799
|
* Returns some helpful parameters related to gas fees.
|
3703
3800
|
*/
|
3704
3801
|
getGasConfig() {
|
3705
|
-
const {
|
3802
|
+
const {
|
3803
|
+
txParameters: { maxGasPerTx },
|
3804
|
+
predicateParameters: { maxGasPerPredicate },
|
3805
|
+
feeParameters: { gasPriceFactor, gasPerByte },
|
3806
|
+
gasCosts
|
3807
|
+
} = this.getChain().consensusParameters;
|
3706
3808
|
return {
|
3707
3809
|
maxGasPerTx,
|
3708
3810
|
maxGasPerPredicate,
|
@@ -3737,11 +3839,9 @@ var _Provider = class {
|
|
3737
3839
|
static ensureClientVersionIsSupported(nodeInfo) {
|
3738
3840
|
const { isMajorSupported, isMinorSupported, supportedVersion } = checkFuelCoreVersionCompatibility(nodeInfo.nodeVersion);
|
3739
3841
|
if (!isMajorSupported || !isMinorSupported) {
|
3740
|
-
|
3741
|
-
|
3742
|
-
|
3743
|
-
Things might or might not work as expected.
|
3744
|
-
Supported fuel-core version: ${supportedVersion}.`
|
3842
|
+
throw new FuelError13(
|
3843
|
+
FuelError13.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
|
3844
|
+
`Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
|
3745
3845
|
);
|
3746
3846
|
}
|
3747
3847
|
}
|
@@ -3799,7 +3899,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
3799
3899
|
*/
|
3800
3900
|
async getBlockNumber() {
|
3801
3901
|
const { chain } = await this.operations.getChain();
|
3802
|
-
return
|
3902
|
+
return bn18(chain.latestBlock.height, 10);
|
3803
3903
|
}
|
3804
3904
|
/**
|
3805
3905
|
* Returns the chain information.
|
@@ -3809,8 +3909,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
3809
3909
|
async fetchNode() {
|
3810
3910
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3811
3911
|
const processedNodeInfo = {
|
3812
|
-
maxDepth:
|
3813
|
-
maxTx:
|
3912
|
+
maxDepth: bn18(nodeInfo.maxDepth),
|
3913
|
+
maxTx: bn18(nodeInfo.maxTx),
|
3814
3914
|
nodeVersion: nodeInfo.nodeVersion,
|
3815
3915
|
utxoValidation: nodeInfo.utxoValidation,
|
3816
3916
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -3914,9 +4014,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
3914
4014
|
encodedTransactions: encodedTransaction,
|
3915
4015
|
utxoValidation: utxoValidation || false
|
3916
4016
|
});
|
3917
|
-
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
4017
|
+
const [{ receipts: rawReceipts, status: dryRunStatus }] = dryRunStatuses;
|
3918
4018
|
const receipts = rawReceipts.map(processGqlReceipt);
|
3919
|
-
return { receipts,
|
4019
|
+
return { receipts, dryRunStatus };
|
3920
4020
|
}
|
3921
4021
|
/**
|
3922
4022
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -3942,7 +4042,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
3942
4042
|
} = response;
|
3943
4043
|
if (inputs) {
|
3944
4044
|
inputs.forEach((input, index) => {
|
3945
|
-
if ("predicateGasUsed" in input &&
|
4045
|
+
if ("predicateGasUsed" in input && bn18(input.predicateGasUsed).gt(0)) {
|
3946
4046
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3947
4047
|
}
|
3948
4048
|
});
|
@@ -3970,7 +4070,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
3970
4070
|
let receipts = [];
|
3971
4071
|
const missingContractIds = [];
|
3972
4072
|
let outputVariables = 0;
|
3973
|
-
let
|
4073
|
+
let dryRunStatus;
|
3974
4074
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3975
4075
|
const {
|
3976
4076
|
dryRun: [{ receipts: rawReceipts, status }]
|
@@ -3979,7 +4079,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
3979
4079
|
utxoValidation: false
|
3980
4080
|
});
|
3981
4081
|
receipts = rawReceipts.map(processGqlReceipt);
|
3982
|
-
|
4082
|
+
dryRunStatus = status;
|
3983
4083
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
3984
4084
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
3985
4085
|
if (hasMissingOutputs) {
|
@@ -4001,7 +4101,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4001
4101
|
receipts,
|
4002
4102
|
outputVariables,
|
4003
4103
|
missingContractIds,
|
4004
|
-
|
4104
|
+
dryRunStatus
|
4005
4105
|
};
|
4006
4106
|
}
|
4007
4107
|
/**
|
@@ -4019,7 +4119,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4019
4119
|
receipts: [],
|
4020
4120
|
outputVariables: 0,
|
4021
4121
|
missingContractIds: [],
|
4022
|
-
|
4122
|
+
dryRunStatus: void 0
|
4023
4123
|
}));
|
4024
4124
|
const allRequests = clone3(transactionRequests);
|
4025
4125
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
@@ -4044,7 +4144,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4044
4144
|
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4045
4145
|
const result = results[requestIdx];
|
4046
4146
|
result.receipts = rawReceipts.map(processGqlReceipt);
|
4047
|
-
result.
|
4147
|
+
result.dryRunStatus = status;
|
4048
4148
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4049
4149
|
result.receipts
|
4050
4150
|
);
|
@@ -4081,7 +4181,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4081
4181
|
});
|
4082
4182
|
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4083
4183
|
const receipts = rawReceipts.map(processGqlReceipt);
|
4084
|
-
return { receipts,
|
4184
|
+
return { receipts, dryRunStatus: status };
|
4085
4185
|
});
|
4086
4186
|
return results;
|
4087
4187
|
}
|
@@ -4100,12 +4200,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4100
4200
|
gasPrice = await this.estimateGasPrice(10);
|
4101
4201
|
}
|
4102
4202
|
const minFee = calculateGasFee({
|
4103
|
-
gasPrice:
|
4203
|
+
gasPrice: bn18(gasPrice),
|
4104
4204
|
gas: minGas,
|
4105
4205
|
priceFactor: gasPriceFactor,
|
4106
4206
|
tip: transactionRequest.tip
|
4107
4207
|
}).add(1);
|
4108
|
-
let gasLimit =
|
4208
|
+
let gasLimit = bn18(0);
|
4109
4209
|
if (transactionRequest.type === TransactionType8.Script) {
|
4110
4210
|
gasLimit = transactionRequest.gasLimit;
|
4111
4211
|
if (transactionRequest.gasLimit.eq(0)) {
|
@@ -4118,7 +4218,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4118
4218
|
}
|
4119
4219
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4120
4220
|
const maxFee = calculateGasFee({
|
4121
|
-
gasPrice:
|
4221
|
+
gasPrice: bn18(gasPrice),
|
4122
4222
|
gas: maxGas,
|
4123
4223
|
priceFactor: gasPriceFactor,
|
4124
4224
|
tip: transactionRequest.tip
|
@@ -4181,9 +4281,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4181
4281
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4182
4282
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4183
4283
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4184
|
-
txRequestClone.maxFee =
|
4284
|
+
txRequestClone.maxFee = bn18(0);
|
4185
4285
|
if (isScriptTransaction) {
|
4186
|
-
txRequestClone.gasLimit =
|
4286
|
+
txRequestClone.gasLimit = bn18(0);
|
4187
4287
|
}
|
4188
4288
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4189
4289
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4200,9 +4300,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4200
4300
|
transactionRequest: signedRequest
|
4201
4301
|
});
|
4202
4302
|
let receipts = [];
|
4303
|
+
let dryRunStatus;
|
4203
4304
|
let missingContractIds = [];
|
4204
4305
|
let outputVariables = 0;
|
4205
|
-
let gasUsed =
|
4306
|
+
let gasUsed = bn18(0);
|
4206
4307
|
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4207
4308
|
txRequestClone.maxFee = maxFee;
|
4208
4309
|
if (isScriptTransaction) {
|
@@ -4210,10 +4311,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4210
4311
|
if (signatureCallback) {
|
4211
4312
|
await signatureCallback(txRequestClone);
|
4212
4313
|
}
|
4213
|
-
|
4214
|
-
receipts = result.receipts;
|
4215
|
-
outputVariables = result.outputVariables;
|
4216
|
-
missingContractIds = result.missingContractIds;
|
4314
|
+
({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
|
4217
4315
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4218
4316
|
txRequestClone.gasLimit = gasUsed;
|
4219
4317
|
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
@@ -4233,7 +4331,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4233
4331
|
outputVariables,
|
4234
4332
|
missingContractIds,
|
4235
4333
|
addedSignatures,
|
4236
|
-
estimatedPredicates: txRequestClone.inputs
|
4334
|
+
estimatedPredicates: txRequestClone.inputs,
|
4335
|
+
dryRunStatus
|
4237
4336
|
};
|
4238
4337
|
}
|
4239
4338
|
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
@@ -4269,10 +4368,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4269
4368
|
return coins.map((coin) => ({
|
4270
4369
|
id: coin.utxoId,
|
4271
4370
|
assetId: coin.assetId,
|
4272
|
-
amount:
|
4371
|
+
amount: bn18(coin.amount),
|
4273
4372
|
owner: Address2.fromAddressOrString(coin.owner),
|
4274
|
-
blockCreated:
|
4275
|
-
txCreatedIdx:
|
4373
|
+
blockCreated: bn18(coin.blockCreated),
|
4374
|
+
txCreatedIdx: bn18(coin.txCreatedIdx)
|
4276
4375
|
}));
|
4277
4376
|
}
|
4278
4377
|
/**
|
@@ -4309,9 +4408,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4309
4408
|
switch (coin.__typename) {
|
4310
4409
|
case "MessageCoin":
|
4311
4410
|
return {
|
4312
|
-
amount:
|
4411
|
+
amount: bn18(coin.amount),
|
4313
4412
|
assetId: coin.assetId,
|
4314
|
-
daHeight:
|
4413
|
+
daHeight: bn18(coin.daHeight),
|
4315
4414
|
sender: Address2.fromAddressOrString(coin.sender),
|
4316
4415
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4317
4416
|
nonce: coin.nonce
|
@@ -4319,11 +4418,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4319
4418
|
case "Coin":
|
4320
4419
|
return {
|
4321
4420
|
id: coin.utxoId,
|
4322
|
-
amount:
|
4421
|
+
amount: bn18(coin.amount),
|
4323
4422
|
assetId: coin.assetId,
|
4324
4423
|
owner: Address2.fromAddressOrString(coin.owner),
|
4325
|
-
blockCreated:
|
4326
|
-
txCreatedIdx:
|
4424
|
+
blockCreated: bn18(coin.blockCreated),
|
4425
|
+
txCreatedIdx: bn18(coin.txCreatedIdx)
|
4327
4426
|
};
|
4328
4427
|
default:
|
4329
4428
|
return null;
|
@@ -4340,13 +4439,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4340
4439
|
async getBlock(idOrHeight) {
|
4341
4440
|
let variables;
|
4342
4441
|
if (typeof idOrHeight === "number") {
|
4343
|
-
variables = { height:
|
4442
|
+
variables = { height: bn18(idOrHeight).toString(10) };
|
4344
4443
|
} else if (idOrHeight === "latest") {
|
4345
4444
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4346
4445
|
} else if (idOrHeight.length === 66) {
|
4347
4446
|
variables = { blockId: idOrHeight };
|
4348
4447
|
} else {
|
4349
|
-
variables = { blockId:
|
4448
|
+
variables = { blockId: bn18(idOrHeight).toString(10) };
|
4350
4449
|
}
|
4351
4450
|
const { block } = await this.operations.getBlock(variables);
|
4352
4451
|
if (!block) {
|
@@ -4354,7 +4453,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4354
4453
|
}
|
4355
4454
|
return {
|
4356
4455
|
id: block.id,
|
4357
|
-
height:
|
4456
|
+
height: bn18(block.height),
|
4358
4457
|
time: block.header.time,
|
4359
4458
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4360
4459
|
};
|
@@ -4369,7 +4468,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4369
4468
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4370
4469
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4371
4470
|
id: block.id,
|
4372
|
-
height:
|
4471
|
+
height: bn18(block.height),
|
4373
4472
|
time: block.header.time,
|
4374
4473
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4375
4474
|
}));
|
@@ -4384,7 +4483,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4384
4483
|
async getBlockWithTransactions(idOrHeight) {
|
4385
4484
|
let variables;
|
4386
4485
|
if (typeof idOrHeight === "number") {
|
4387
|
-
variables = { blockHeight:
|
4486
|
+
variables = { blockHeight: bn18(idOrHeight).toString(10) };
|
4388
4487
|
} else if (idOrHeight === "latest") {
|
4389
4488
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4390
4489
|
} else {
|
@@ -4396,7 +4495,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4396
4495
|
}
|
4397
4496
|
return {
|
4398
4497
|
id: block.id,
|
4399
|
-
height:
|
4498
|
+
height: bn18(block.height, 10),
|
4400
4499
|
time: block.header.time,
|
4401
4500
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4402
4501
|
transactions: block.transactions.map(
|
@@ -4445,7 +4544,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4445
4544
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4446
4545
|
asset: hexlify12(assetId)
|
4447
4546
|
});
|
4448
|
-
return
|
4547
|
+
return bn18(contractBalance.amount, 10);
|
4449
4548
|
}
|
4450
4549
|
/**
|
4451
4550
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4459,7 +4558,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4459
4558
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4460
4559
|
assetId: hexlify12(assetId)
|
4461
4560
|
});
|
4462
|
-
return
|
4561
|
+
return bn18(balance.amount, 10);
|
4463
4562
|
}
|
4464
4563
|
/**
|
4465
4564
|
* Returns balances for the given owner.
|
@@ -4477,7 +4576,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4477
4576
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4478
4577
|
return balances.map((balance) => ({
|
4479
4578
|
assetId: balance.assetId,
|
4480
|
-
amount:
|
4579
|
+
amount: bn18(balance.amount)
|
4481
4580
|
}));
|
4482
4581
|
}
|
4483
4582
|
/**
|
@@ -4499,15 +4598,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4499
4598
|
sender: message.sender,
|
4500
4599
|
recipient: message.recipient,
|
4501
4600
|
nonce: message.nonce,
|
4502
|
-
amount:
|
4601
|
+
amount: bn18(message.amount),
|
4503
4602
|
data: message.data
|
4504
4603
|
}),
|
4505
4604
|
sender: Address2.fromAddressOrString(message.sender),
|
4506
4605
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4507
4606
|
nonce: message.nonce,
|
4508
|
-
amount:
|
4607
|
+
amount: bn18(message.amount),
|
4509
4608
|
data: InputMessageCoder.decodeData(message.data),
|
4510
|
-
daHeight:
|
4609
|
+
daHeight: bn18(message.daHeight)
|
4511
4610
|
}));
|
4512
4611
|
}
|
4513
4612
|
/**
|
@@ -4560,59 +4659,59 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4560
4659
|
} = result.messageProof;
|
4561
4660
|
return {
|
4562
4661
|
messageProof: {
|
4563
|
-
proofIndex:
|
4662
|
+
proofIndex: bn18(messageProof.proofIndex),
|
4564
4663
|
proofSet: messageProof.proofSet
|
4565
4664
|
},
|
4566
4665
|
blockProof: {
|
4567
|
-
proofIndex:
|
4666
|
+
proofIndex: bn18(blockProof.proofIndex),
|
4568
4667
|
proofSet: blockProof.proofSet
|
4569
4668
|
},
|
4570
4669
|
messageBlockHeader: {
|
4571
4670
|
id: messageBlockHeader.id,
|
4572
|
-
daHeight:
|
4573
|
-
transactionsCount:
|
4671
|
+
daHeight: bn18(messageBlockHeader.daHeight),
|
4672
|
+
transactionsCount: Number(messageBlockHeader.transactionsCount),
|
4574
4673
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4575
|
-
height:
|
4674
|
+
height: bn18(messageBlockHeader.height),
|
4576
4675
|
prevRoot: messageBlockHeader.prevRoot,
|
4577
4676
|
time: messageBlockHeader.time,
|
4578
4677
|
applicationHash: messageBlockHeader.applicationHash,
|
4579
|
-
messageReceiptCount:
|
4678
|
+
messageReceiptCount: Number(messageBlockHeader.messageReceiptCount),
|
4580
4679
|
messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
|
4581
|
-
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4680
|
+
consensusParametersVersion: Number(messageBlockHeader.consensusParametersVersion),
|
4582
4681
|
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4583
|
-
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4682
|
+
stateTransitionBytecodeVersion: Number(messageBlockHeader.stateTransitionBytecodeVersion)
|
4584
4683
|
},
|
4585
4684
|
commitBlockHeader: {
|
4586
4685
|
id: commitBlockHeader.id,
|
4587
|
-
daHeight:
|
4588
|
-
transactionsCount:
|
4686
|
+
daHeight: bn18(commitBlockHeader.daHeight),
|
4687
|
+
transactionsCount: Number(commitBlockHeader.transactionsCount),
|
4589
4688
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4590
|
-
height:
|
4689
|
+
height: bn18(commitBlockHeader.height),
|
4591
4690
|
prevRoot: commitBlockHeader.prevRoot,
|
4592
4691
|
time: commitBlockHeader.time,
|
4593
4692
|
applicationHash: commitBlockHeader.applicationHash,
|
4594
|
-
messageReceiptCount:
|
4693
|
+
messageReceiptCount: Number(commitBlockHeader.messageReceiptCount),
|
4595
4694
|
messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
|
4596
|
-
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4695
|
+
consensusParametersVersion: Number(commitBlockHeader.consensusParametersVersion),
|
4597
4696
|
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4598
|
-
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4697
|
+
stateTransitionBytecodeVersion: Number(commitBlockHeader.stateTransitionBytecodeVersion)
|
4599
4698
|
},
|
4600
4699
|
sender: Address2.fromAddressOrString(sender),
|
4601
4700
|
recipient: Address2.fromAddressOrString(recipient),
|
4602
4701
|
nonce,
|
4603
|
-
amount:
|
4702
|
+
amount: bn18(amount),
|
4604
4703
|
data
|
4605
4704
|
};
|
4606
4705
|
}
|
4607
4706
|
async getLatestGasPrice() {
|
4608
4707
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4609
|
-
return
|
4708
|
+
return bn18(latestGasPrice.gasPrice);
|
4610
4709
|
}
|
4611
4710
|
async estimateGasPrice(blockHorizon) {
|
4612
4711
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4613
4712
|
blockHorizon: String(blockHorizon)
|
4614
4713
|
});
|
4615
|
-
return
|
4714
|
+
return bn18(estimateGasPrice.gasPrice);
|
4616
4715
|
}
|
4617
4716
|
/**
|
4618
4717
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4633,10 +4732,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4633
4732
|
*/
|
4634
4733
|
async produceBlocks(amount, startTime) {
|
4635
4734
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4636
|
-
blocksToProduce:
|
4735
|
+
blocksToProduce: bn18(amount).toString(10),
|
4637
4736
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4638
4737
|
});
|
4639
|
-
return
|
4738
|
+
return bn18(latestBlockHeight);
|
4640
4739
|
}
|
4641
4740
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4642
4741
|
async getTransactionResponse(transactionId) {
|
@@ -4655,6 +4754,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4655
4754
|
}
|
4656
4755
|
return message;
|
4657
4756
|
}
|
4757
|
+
async getRelayedTransactionStatus(relayedTransactionId) {
|
4758
|
+
const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
|
4759
|
+
relayedTransactionId
|
4760
|
+
});
|
4761
|
+
if (!relayedTransactionStatus) {
|
4762
|
+
return null;
|
4763
|
+
}
|
4764
|
+
return relayedTransactionStatus;
|
4765
|
+
}
|
4658
4766
|
};
|
4659
4767
|
var Provider = _Provider;
|
4660
4768
|
_cacheInputs = new WeakSet();
|
@@ -4673,7 +4781,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4673
4781
|
|
4674
4782
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4675
4783
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4676
|
-
import { bn as
|
4784
|
+
import { bn as bn19 } from "@fuel-ts/math";
|
4677
4785
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4678
4786
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4679
4787
|
|
@@ -4722,22 +4830,6 @@ var assets = [
|
|
4722
4830
|
}
|
4723
4831
|
];
|
4724
4832
|
|
4725
|
-
// src/providers/transaction-request/helpers.ts
|
4726
|
-
import { bn as bn18 } from "@fuel-ts/math";
|
4727
|
-
import { InputType as InputType8 } from "@fuel-ts/transactions";
|
4728
|
-
var isRequestInputCoin = (input) => input.type === InputType8.Coin;
|
4729
|
-
var isRequestInputMessage = (input) => input.type === InputType8.Message;
|
4730
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
4731
|
-
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
4732
|
-
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
4733
|
-
return acc.add(input.amount);
|
4734
|
-
}
|
4735
|
-
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
4736
|
-
return acc.add(input.amount);
|
4737
|
-
}
|
4738
|
-
return acc;
|
4739
|
-
}, bn18(0));
|
4740
|
-
|
4741
4833
|
// src/utils/formatTransferToContractScriptData.ts
|
4742
4834
|
import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
4743
4835
|
import { BN as BN2 } from "@fuel-ts/math";
|
@@ -4940,10 +5032,10 @@ var Account = class extends AbstractAccount {
|
|
4940
5032
|
async fund(request, params) {
|
4941
5033
|
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
4942
5034
|
const baseAssetId = this.provider.getBaseAssetId();
|
4943
|
-
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount ||
|
5035
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn20(0);
|
4944
5036
|
const txRequest = request;
|
4945
5037
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
4946
|
-
amount:
|
5038
|
+
amount: bn20(fee),
|
4947
5039
|
assetId: baseAssetId,
|
4948
5040
|
coinQuantities: requiredQuantities
|
4949
5041
|
});
|
@@ -4951,7 +5043,7 @@ var Account = class extends AbstractAccount {
|
|
4951
5043
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
4952
5044
|
quantitiesDict[assetId] = {
|
4953
5045
|
required: amount,
|
4954
|
-
owned:
|
5046
|
+
owned: bn20(0)
|
4955
5047
|
};
|
4956
5048
|
});
|
4957
5049
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
@@ -4975,7 +5067,7 @@ var Account = class extends AbstractAccount {
|
|
4975
5067
|
while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
|
4976
5068
|
const resources = await this.getResourcesToSpend(
|
4977
5069
|
missingQuantities,
|
4978
|
-
|
5070
|
+
cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
|
4979
5071
|
);
|
4980
5072
|
request.addResources(resources);
|
4981
5073
|
txRequest.shiftPredicateData();
|
@@ -5056,7 +5148,7 @@ var Account = class extends AbstractAccount {
|
|
5056
5148
|
* @returns A promise that resolves to the transaction response.
|
5057
5149
|
*/
|
5058
5150
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5059
|
-
if (
|
5151
|
+
if (bn20(amount).lte(0)) {
|
5060
5152
|
throw new FuelError15(
|
5061
5153
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5062
5154
|
"Transfer amount must be a positive number."
|
@@ -5076,7 +5168,7 @@ var Account = class extends AbstractAccount {
|
|
5076
5168
|
* @returns A promise that resolves to the transaction response.
|
5077
5169
|
*/
|
5078
5170
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5079
|
-
if (
|
5171
|
+
if (bn20(amount).lte(0)) {
|
5080
5172
|
throw new FuelError15(
|
5081
5173
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5082
5174
|
"Transfer amount must be a positive number."
|
@@ -5086,7 +5178,7 @@ var Account = class extends AbstractAccount {
|
|
5086
5178
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5087
5179
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5088
5180
|
hexlifiedContractId: contractAddress.toB256(),
|
5089
|
-
amountToTransfer:
|
5181
|
+
amountToTransfer: bn20(amount),
|
5090
5182
|
assetId: assetIdToTransfer
|
5091
5183
|
});
|
5092
5184
|
const request = new ScriptTransactionRequest({
|
@@ -5097,7 +5189,7 @@ var Account = class extends AbstractAccount {
|
|
5097
5189
|
request.addContractInputAndOutput(contractAddress);
|
5098
5190
|
const txCost = await this.provider.getTransactionCost(request, {
|
5099
5191
|
resourcesOwner: this,
|
5100
|
-
quantitiesToContract: [{ amount:
|
5192
|
+
quantitiesToContract: [{ amount: bn20(amount), assetId: String(assetIdToTransfer) }]
|
5101
5193
|
});
|
5102
5194
|
this.validateGasLimitAndMaxFee({
|
5103
5195
|
gasUsed: txCost.gasUsed,
|
@@ -5123,7 +5215,7 @@ var Account = class extends AbstractAccount {
|
|
5123
5215
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5124
5216
|
);
|
5125
5217
|
const amountDataArray = arrayify14(
|
5126
|
-
"0x".concat(
|
5218
|
+
"0x".concat(bn20(amount).toHex().substring(2).padStart(16, "0"))
|
5127
5219
|
);
|
5128
5220
|
const script = new Uint8Array([
|
5129
5221
|
...arrayify14(withdrawScript.bytes),
|
@@ -5133,7 +5225,7 @@ var Account = class extends AbstractAccount {
|
|
5133
5225
|
const params = { script, ...txParams };
|
5134
5226
|
const baseAssetId = this.provider.getBaseAssetId();
|
5135
5227
|
const request = new ScriptTransactionRequest(params);
|
5136
|
-
const quantitiesToContract = [{ amount:
|
5228
|
+
const quantitiesToContract = [{ amount: bn20(amount), assetId: baseAssetId }];
|
5137
5229
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5138
5230
|
this.validateGasLimitAndMaxFee({
|
5139
5231
|
gasUsed: txCost.gasUsed,
|
@@ -5543,7 +5635,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5543
5635
|
// src/hdwallet/hdwallet.ts
|
5544
5636
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5545
5637
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5546
|
-
import { bn as
|
5638
|
+
import { bn as bn21, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5547
5639
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5548
5640
|
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5549
5641
|
|
@@ -8009,7 +8101,7 @@ var HDWallet = class {
|
|
8009
8101
|
const IR = bytes.slice(32);
|
8010
8102
|
if (privateKey) {
|
8011
8103
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8012
|
-
const ki =
|
8104
|
+
const ki = bn21(IL).add(privateKey).mod(N).toBytes(32);
|
8013
8105
|
return new HDWallet({
|
8014
8106
|
privateKey: ki,
|
8015
8107
|
chainCode: IR,
|
@@ -8275,16 +8367,18 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
8275
8367
|
|
8276
8368
|
// src/test-utils/seedTestWallet.ts
|
8277
8369
|
import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
|
8278
|
-
var seedTestWallet = async (wallet, quantities) => {
|
8279
|
-
const
|
8280
|
-
|
8281
|
-
|
8282
|
-
);
|
8370
|
+
var seedTestWallet = async (wallet, quantities, utxosAmount = 1) => {
|
8371
|
+
const accountsToBeFunded = Array.isArray(wallet) ? wallet : [wallet];
|
8372
|
+
const [{ provider }] = accountsToBeFunded;
|
8373
|
+
const genesisWallet = new WalletUnlocked(process.env.GENESIS_SECRET || randomBytes5(32), provider);
|
8283
8374
|
const request = new ScriptTransactionRequest();
|
8284
|
-
quantities.forEach(
|
8285
|
-
|
8286
|
-
|
8287
|
-
|
8375
|
+
quantities.map(coinQuantityfy).forEach(
|
8376
|
+
({ amount, assetId }) => accountsToBeFunded.forEach(({ address }) => {
|
8377
|
+
for (let i = 0; i < utxosAmount; i++) {
|
8378
|
+
request.addCoinOutput(address, amount.div(utxosAmount), assetId);
|
8379
|
+
}
|
8380
|
+
})
|
8381
|
+
);
|
8288
8382
|
const txCost = await genesisWallet.provider.getTransactionCost(request);
|
8289
8383
|
request.gasLimit = txCost.gasUsed;
|
8290
8384
|
request.maxFee = txCost.maxFee;
|
@@ -8424,9 +8518,11 @@ var launchNode = async ({
|
|
8424
8518
|
const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
|
8425
8519
|
const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
|
8426
8520
|
const metadataWritePath = path.join(tempDirPath, "metadata.json");
|
8521
|
+
const stateTransitionWritePath = path.join(tempDirPath, "state_transition_bytecode.wasm");
|
8427
8522
|
writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
|
8428
8523
|
writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
|
8429
8524
|
writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
|
8525
|
+
writeFileSync(stateTransitionWritePath, JSON.stringify(""));
|
8430
8526
|
snapshotDirToUse = tempDirPath;
|
8431
8527
|
}
|
8432
8528
|
const child = spawn(
|