@fuel-ts/account 0.0.0-rc-2037-20240422095321 → 0.0.0-rc-2130-20240422142413
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/hdwallet/hdwallet.d.ts.map +1 -1
- package/dist/index.global.js +1407 -2588
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +154 -230
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -140
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/predicate/predicate.d.ts +2 -17
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +1 -2
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +0 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +0 -9
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/index.d.ts +0 -1
- package/dist/providers/transaction-request/index.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +20 -4
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/test-utils/index.d.ts +0 -1
- package/dist/test-utils/index.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 +1448 -2606
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +149 -203
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +70 -121
- 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 +15 -16
- package/dist/providers/transaction-request/helpers.d.ts +0 -10
- package/dist/providers/transaction-request/helpers.d.ts.map +0 -1
- package/dist/test-utils/resources.d.ts +0 -4
- package/dist/test-utils/resources.d.ts.map +0 -1
- package/dist/test-utils/transactionRequest.d.ts +0 -5
- package/dist/test-utils/transactionRequest.d.ts.map +0 -1
package/dist/test-utils.js
CHANGED
@@ -48,9 +48,6 @@ var __privateMethod = (obj, member, method) => {
|
|
48
48
|
// src/test-utils/index.ts
|
49
49
|
var test_utils_exports = {};
|
50
50
|
__export(test_utils_exports, {
|
51
|
-
generateFakeRequestInputCoin: () => generateFakeRequestInputCoin,
|
52
|
-
generateFakeRequestInputContract: () => generateFakeRequestInputContract,
|
53
|
-
generateFakeRequestInputMessage: () => generateFakeRequestInputMessage,
|
54
51
|
generateTestWallet: () => generateTestWallet,
|
55
52
|
killNode: () => killNode,
|
56
53
|
launchNode: () => launchNode,
|
@@ -111,11 +108,10 @@ var addAmountToAsset = (params) => {
|
|
111
108
|
var import_address3 = require("@fuel-ts/address");
|
112
109
|
var import_errors14 = require("@fuel-ts/errors");
|
113
110
|
var import_math15 = require("@fuel-ts/math");
|
114
|
-
var
|
111
|
+
var import_transactions18 = require("@fuel-ts/transactions");
|
115
112
|
var import_utils23 = require("@fuel-ts/utils");
|
116
113
|
var import_versions = require("@fuel-ts/versions");
|
117
114
|
var import_utils24 = require("@noble/curves/abstract/utils");
|
118
|
-
var import_ethers = require("ethers");
|
119
115
|
var import_graphql_request = require("graphql-request");
|
120
116
|
var import_ramda3 = require("ramda");
|
121
117
|
|
@@ -1201,7 +1197,7 @@ var import_address = require("@fuel-ts/address");
|
|
1201
1197
|
var import_configs7 = require("@fuel-ts/address/configs");
|
1202
1198
|
var import_crypto = require("@fuel-ts/crypto");
|
1203
1199
|
var import_math7 = require("@fuel-ts/math");
|
1204
|
-
var
|
1200
|
+
var import_transactions6 = require("@fuel-ts/transactions");
|
1205
1201
|
var import_utils9 = require("@fuel-ts/utils");
|
1206
1202
|
|
1207
1203
|
// src/providers/resource.ts
|
@@ -1614,12 +1610,6 @@ var NoWitnessAtIndexError = class extends Error {
|
|
1614
1610
|
name = "NoWitnessAtIndexError";
|
1615
1611
|
};
|
1616
1612
|
|
1617
|
-
// src/providers/transaction-request/helpers.ts
|
1618
|
-
var import_transactions6 = require("@fuel-ts/transactions");
|
1619
|
-
var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
|
1620
|
-
var isRequestInputMessage = (input) => input.type === import_transactions6.InputType.Message;
|
1621
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
1622
|
-
|
1623
1613
|
// src/providers/transaction-request/witness.ts
|
1624
1614
|
var import_utils8 = require("@fuel-ts/utils");
|
1625
1615
|
var witnessify = (value) => {
|
@@ -1672,20 +1662,20 @@ var BaseTransactionRequest = class {
|
|
1672
1662
|
let policyTypes = 0;
|
1673
1663
|
const policies = [];
|
1674
1664
|
if (req.gasPrice) {
|
1675
|
-
policyTypes +=
|
1676
|
-
policies.push({ data: req.gasPrice, type:
|
1665
|
+
policyTypes += import_transactions6.PolicyType.GasPrice;
|
1666
|
+
policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
|
1677
1667
|
}
|
1678
1668
|
if (req.witnessLimit) {
|
1679
|
-
policyTypes +=
|
1680
|
-
policies.push({ data: req.witnessLimit, type:
|
1669
|
+
policyTypes += import_transactions6.PolicyType.WitnessLimit;
|
1670
|
+
policies.push({ data: req.witnessLimit, type: import_transactions6.PolicyType.WitnessLimit });
|
1681
1671
|
}
|
1682
1672
|
if (req.maturity > 0) {
|
1683
|
-
policyTypes +=
|
1684
|
-
policies.push({ data: req.maturity, type:
|
1673
|
+
policyTypes += import_transactions6.PolicyType.Maturity;
|
1674
|
+
policies.push({ data: req.maturity, type: import_transactions6.PolicyType.Maturity });
|
1685
1675
|
}
|
1686
1676
|
if (req.maxFee) {
|
1687
|
-
policyTypes +=
|
1688
|
-
policies.push({ data: req.maxFee, type:
|
1677
|
+
policyTypes += import_transactions6.PolicyType.MaxFee;
|
1678
|
+
policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
|
1689
1679
|
}
|
1690
1680
|
return {
|
1691
1681
|
policyTypes,
|
@@ -1719,7 +1709,7 @@ var BaseTransactionRequest = class {
|
|
1719
1709
|
* @returns The transaction bytes.
|
1720
1710
|
*/
|
1721
1711
|
toTransactionBytes() {
|
1722
|
-
return new
|
1712
|
+
return new import_transactions6.TransactionCoder().encode(this.toTransaction());
|
1723
1713
|
}
|
1724
1714
|
/**
|
1725
1715
|
* @hidden
|
@@ -1810,7 +1800,7 @@ var BaseTransactionRequest = class {
|
|
1810
1800
|
*/
|
1811
1801
|
getCoinInputs() {
|
1812
1802
|
return this.inputs.filter(
|
1813
|
-
(input) => input.type ===
|
1803
|
+
(input) => input.type === import_transactions6.InputType.Coin
|
1814
1804
|
);
|
1815
1805
|
}
|
1816
1806
|
/**
|
@@ -1820,7 +1810,7 @@ var BaseTransactionRequest = class {
|
|
1820
1810
|
*/
|
1821
1811
|
getCoinOutputs() {
|
1822
1812
|
return this.outputs.filter(
|
1823
|
-
(output) => output.type ===
|
1813
|
+
(output) => output.type === import_transactions6.OutputType.Coin
|
1824
1814
|
);
|
1825
1815
|
}
|
1826
1816
|
/**
|
@@ -1830,7 +1820,7 @@ var BaseTransactionRequest = class {
|
|
1830
1820
|
*/
|
1831
1821
|
getChangeOutputs() {
|
1832
1822
|
return this.outputs.filter(
|
1833
|
-
(output) => output.type ===
|
1823
|
+
(output) => output.type === import_transactions6.OutputType.Change
|
1834
1824
|
);
|
1835
1825
|
}
|
1836
1826
|
/**
|
@@ -1842,9 +1832,9 @@ var BaseTransactionRequest = class {
|
|
1842
1832
|
const ownerAddress = (0, import_address.addressify)(owner);
|
1843
1833
|
const found = this.inputs.find((input) => {
|
1844
1834
|
switch (input.type) {
|
1845
|
-
case
|
1835
|
+
case import_transactions6.InputType.Coin:
|
1846
1836
|
return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
|
1847
|
-
case
|
1837
|
+
case import_transactions6.InputType.Message:
|
1848
1838
|
return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
|
1849
1839
|
default:
|
1850
1840
|
return false;
|
@@ -1860,8 +1850,8 @@ var BaseTransactionRequest = class {
|
|
1860
1850
|
* @param predicate - Predicate bytes.
|
1861
1851
|
* @param predicateData - Predicate data bytes.
|
1862
1852
|
*/
|
1863
|
-
addCoinInput(coin) {
|
1864
|
-
const { assetId, owner, amount
|
1853
|
+
addCoinInput(coin, predicate) {
|
1854
|
+
const { assetId, owner, amount } = coin;
|
1865
1855
|
let witnessIndex;
|
1866
1856
|
if (predicate) {
|
1867
1857
|
witnessIndex = 0;
|
@@ -1872,14 +1862,14 @@ var BaseTransactionRequest = class {
|
|
1872
1862
|
}
|
1873
1863
|
}
|
1874
1864
|
const input = {
|
1875
|
-
|
1876
|
-
type:
|
1865
|
+
...coin,
|
1866
|
+
type: import_transactions6.InputType.Coin,
|
1877
1867
|
owner: owner.toB256(),
|
1878
1868
|
amount,
|
1879
1869
|
assetId,
|
1880
1870
|
txPointer: "0x00000000000000000000000000000000",
|
1881
1871
|
witnessIndex,
|
1882
|
-
predicate
|
1872
|
+
predicate: predicate?.bytes
|
1883
1873
|
};
|
1884
1874
|
this.pushInput(input);
|
1885
1875
|
this.addChangeOutput(owner, assetId);
|
@@ -1892,8 +1882,8 @@ var BaseTransactionRequest = class {
|
|
1892
1882
|
* @param predicate - Predicate bytes.
|
1893
1883
|
* @param predicateData - Predicate data bytes.
|
1894
1884
|
*/
|
1895
|
-
addMessageInput(message) {
|
1896
|
-
const { recipient, sender, amount
|
1885
|
+
addMessageInput(message, predicate) {
|
1886
|
+
const { recipient, sender, amount } = message;
|
1897
1887
|
const assetId = import_configs7.BaseAssetId;
|
1898
1888
|
let witnessIndex;
|
1899
1889
|
if (predicate) {
|
@@ -1905,13 +1895,13 @@ var BaseTransactionRequest = class {
|
|
1905
1895
|
}
|
1906
1896
|
}
|
1907
1897
|
const input = {
|
1908
|
-
|
1909
|
-
type:
|
1898
|
+
...message,
|
1899
|
+
type: import_transactions6.InputType.Message,
|
1910
1900
|
sender: sender.toB256(),
|
1911
1901
|
recipient: recipient.toB256(),
|
1912
1902
|
amount,
|
1913
1903
|
witnessIndex,
|
1914
|
-
predicate
|
1904
|
+
predicate: predicate?.bytes
|
1915
1905
|
};
|
1916
1906
|
this.pushInput(input);
|
1917
1907
|
this.addChangeOutput(recipient, assetId);
|
@@ -1942,6 +1932,32 @@ var BaseTransactionRequest = class {
|
|
1942
1932
|
resources.forEach((resource) => this.addResource(resource));
|
1943
1933
|
return this;
|
1944
1934
|
}
|
1935
|
+
/**
|
1936
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
1937
|
+
* outputs from the related assetIds.
|
1938
|
+
*
|
1939
|
+
* @param resources - The resources to add.
|
1940
|
+
* @returns This transaction.
|
1941
|
+
*/
|
1942
|
+
addPredicateResource(resource, predicate) {
|
1943
|
+
if (isCoin(resource)) {
|
1944
|
+
this.addCoinInput(resource, predicate);
|
1945
|
+
} else {
|
1946
|
+
this.addMessageInput(resource, predicate);
|
1947
|
+
}
|
1948
|
+
return this;
|
1949
|
+
}
|
1950
|
+
/**
|
1951
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
1952
|
+
* from the related assetIds.
|
1953
|
+
*
|
1954
|
+
* @param resources - The resources to add.
|
1955
|
+
* @returns This transaction.
|
1956
|
+
*/
|
1957
|
+
addPredicateResources(resources, predicate) {
|
1958
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
1959
|
+
return this;
|
1960
|
+
}
|
1945
1961
|
/**
|
1946
1962
|
* Adds a coin output to the transaction.
|
1947
1963
|
*
|
@@ -1951,7 +1967,7 @@ var BaseTransactionRequest = class {
|
|
1951
1967
|
*/
|
1952
1968
|
addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
|
1953
1969
|
this.pushOutput({
|
1954
|
-
type:
|
1970
|
+
type: import_transactions6.OutputType.Coin,
|
1955
1971
|
to: (0, import_address.addressify)(to).toB256(),
|
1956
1972
|
amount,
|
1957
1973
|
assetId
|
@@ -1967,7 +1983,7 @@ var BaseTransactionRequest = class {
|
|
1967
1983
|
addCoinOutputs(to, quantities) {
|
1968
1984
|
quantities.map(coinQuantityfy).forEach((quantity) => {
|
1969
1985
|
this.pushOutput({
|
1970
|
-
type:
|
1986
|
+
type: import_transactions6.OutputType.Coin,
|
1971
1987
|
to: (0, import_address.addressify)(to).toB256(),
|
1972
1988
|
amount: quantity.amount,
|
1973
1989
|
assetId: quantity.assetId
|
@@ -1987,7 +2003,7 @@ var BaseTransactionRequest = class {
|
|
1987
2003
|
);
|
1988
2004
|
if (!changeOutput) {
|
1989
2005
|
this.pushOutput({
|
1990
|
-
type:
|
2006
|
+
type: import_transactions6.OutputType.Change,
|
1991
2007
|
to: (0, import_address.addressify)(to).toB256(),
|
1992
2008
|
assetId
|
1993
2009
|
});
|
@@ -2090,20 +2106,16 @@ var BaseTransactionRequest = class {
|
|
2090
2106
|
toJSON() {
|
2091
2107
|
return normalizeJSON(this);
|
2092
2108
|
}
|
2093
|
-
removeWitness(index) {
|
2094
|
-
this.witnesses.splice(index, 1);
|
2095
|
-
this.adjustWitnessIndexes(index);
|
2096
|
-
}
|
2097
2109
|
updatePredicateInputs(inputs) {
|
2098
2110
|
this.inputs.forEach((i) => {
|
2099
2111
|
let correspondingInput;
|
2100
2112
|
switch (i.type) {
|
2101
|
-
case
|
2102
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2113
|
+
case import_transactions6.InputType.Coin:
|
2114
|
+
correspondingInput = inputs.find((x) => x.type === import_transactions6.InputType.Coin && x.owner === i.owner);
|
2103
2115
|
break;
|
2104
|
-
case
|
2116
|
+
case import_transactions6.InputType.Message:
|
2105
2117
|
correspondingInput = inputs.find(
|
2106
|
-
(x) => x.type ===
|
2118
|
+
(x) => x.type === import_transactions6.InputType.Message && x.sender === i.sender
|
2107
2119
|
);
|
2108
2120
|
break;
|
2109
2121
|
default:
|
@@ -2116,37 +2128,30 @@ var BaseTransactionRequest = class {
|
|
2116
2128
|
}
|
2117
2129
|
});
|
2118
2130
|
}
|
2119
|
-
adjustWitnessIndexes(removedIndex) {
|
2120
|
-
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
2121
|
-
if (input.witnessIndex > removedIndex) {
|
2122
|
-
input.witnessIndex -= 1;
|
2123
|
-
}
|
2124
|
-
});
|
2125
|
-
}
|
2126
2131
|
};
|
2127
2132
|
|
2128
2133
|
// src/providers/transaction-request/create-transaction-request.ts
|
2129
2134
|
var import_configs9 = require("@fuel-ts/address/configs");
|
2130
2135
|
var import_math9 = require("@fuel-ts/math");
|
2131
|
-
var
|
2136
|
+
var import_transactions8 = require("@fuel-ts/transactions");
|
2132
2137
|
var import_utils13 = require("@fuel-ts/utils");
|
2133
2138
|
|
2134
2139
|
// src/providers/transaction-request/hash-transaction.ts
|
2135
2140
|
var import_configs8 = require("@fuel-ts/address/configs");
|
2136
2141
|
var import_hasher = require("@fuel-ts/hasher");
|
2137
2142
|
var import_math8 = require("@fuel-ts/math");
|
2138
|
-
var
|
2143
|
+
var import_transactions7 = require("@fuel-ts/transactions");
|
2139
2144
|
var import_utils11 = require("@fuel-ts/utils");
|
2140
2145
|
var import_ramda2 = require("ramda");
|
2141
2146
|
function hashTransaction(transactionRequest, chainId) {
|
2142
2147
|
const transaction = transactionRequest.toTransaction();
|
2143
|
-
if (transaction.type ===
|
2148
|
+
if (transaction.type === import_transactions7.TransactionType.Script) {
|
2144
2149
|
transaction.receiptsRoot = import_configs8.ZeroBytes32;
|
2145
2150
|
}
|
2146
2151
|
transaction.inputs = transaction.inputs.map((input) => {
|
2147
2152
|
const inputClone = (0, import_ramda2.clone)(input);
|
2148
2153
|
switch (inputClone.type) {
|
2149
|
-
case
|
2154
|
+
case import_transactions7.InputType.Coin: {
|
2150
2155
|
inputClone.txPointer = {
|
2151
2156
|
blockHeight: 0,
|
2152
2157
|
txIndex: 0
|
@@ -2154,11 +2159,11 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2154
2159
|
inputClone.predicateGasUsed = (0, import_math8.bn)(0);
|
2155
2160
|
return inputClone;
|
2156
2161
|
}
|
2157
|
-
case
|
2162
|
+
case import_transactions7.InputType.Message: {
|
2158
2163
|
inputClone.predicateGasUsed = (0, import_math8.bn)(0);
|
2159
2164
|
return inputClone;
|
2160
2165
|
}
|
2161
|
-
case
|
2166
|
+
case import_transactions7.InputType.Contract: {
|
2162
2167
|
inputClone.txPointer = {
|
2163
2168
|
blockHeight: 0,
|
2164
2169
|
txIndex: 0
|
@@ -2176,16 +2181,16 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2176
2181
|
transaction.outputs = transaction.outputs.map((output) => {
|
2177
2182
|
const outputClone = (0, import_ramda2.clone)(output);
|
2178
2183
|
switch (outputClone.type) {
|
2179
|
-
case
|
2184
|
+
case import_transactions7.OutputType.Contract: {
|
2180
2185
|
outputClone.balanceRoot = import_configs8.ZeroBytes32;
|
2181
2186
|
outputClone.stateRoot = import_configs8.ZeroBytes32;
|
2182
2187
|
return outputClone;
|
2183
2188
|
}
|
2184
|
-
case
|
2189
|
+
case import_transactions7.OutputType.Change: {
|
2185
2190
|
outputClone.amount = (0, import_math8.bn)(0);
|
2186
2191
|
return outputClone;
|
2187
2192
|
}
|
2188
|
-
case
|
2193
|
+
case import_transactions7.OutputType.Variable: {
|
2189
2194
|
outputClone.to = import_configs8.ZeroBytes32;
|
2190
2195
|
outputClone.amount = (0, import_math8.bn)(0);
|
2191
2196
|
outputClone.assetId = import_configs8.ZeroBytes32;
|
@@ -2198,7 +2203,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2198
2203
|
transaction.witnessesCount = 0;
|
2199
2204
|
transaction.witnesses = [];
|
2200
2205
|
const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
|
2201
|
-
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new
|
2206
|
+
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions7.TransactionCoder().encode(transaction)]);
|
2202
2207
|
return (0, import_hasher.sha256)(concatenatedData);
|
2203
2208
|
}
|
2204
2209
|
|
@@ -2234,7 +2239,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2234
2239
|
return new this(obj);
|
2235
2240
|
}
|
2236
2241
|
/** Type of the transaction */
|
2237
|
-
type =
|
2242
|
+
type = import_transactions8.TransactionType.Create;
|
2238
2243
|
/** Witness index of contract bytecode to create */
|
2239
2244
|
bytecodeWitnessIndex;
|
2240
2245
|
/** Salt */
|
@@ -2267,7 +2272,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2267
2272
|
const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
|
2268
2273
|
const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
|
2269
2274
|
return {
|
2270
|
-
type:
|
2275
|
+
type: import_transactions8.TransactionType.Create,
|
2271
2276
|
...baseTransaction,
|
2272
2277
|
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2273
2278
|
bytecodeWitnessIndex,
|
@@ -2283,7 +2288,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2283
2288
|
*/
|
2284
2289
|
getContractCreatedOutputs() {
|
2285
2290
|
return this.outputs.filter(
|
2286
|
-
(output) => output.type ===
|
2291
|
+
(output) => output.type === import_transactions8.OutputType.ContractCreated
|
2287
2292
|
);
|
2288
2293
|
}
|
2289
2294
|
/**
|
@@ -2304,7 +2309,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2304
2309
|
*/
|
2305
2310
|
addContractCreatedOutput(contractId, stateRoot) {
|
2306
2311
|
this.pushOutput({
|
2307
|
-
type:
|
2312
|
+
type: import_transactions8.OutputType.ContractCreated,
|
2308
2313
|
contractId,
|
2309
2314
|
stateRoot
|
2310
2315
|
});
|
@@ -2324,7 +2329,7 @@ var import_abi_coder3 = require("@fuel-ts/abi-coder");
|
|
2324
2329
|
var import_address2 = require("@fuel-ts/address");
|
2325
2330
|
var import_configs10 = require("@fuel-ts/address/configs");
|
2326
2331
|
var import_math10 = require("@fuel-ts/math");
|
2327
|
-
var
|
2332
|
+
var import_transactions9 = require("@fuel-ts/transactions");
|
2328
2333
|
var import_utils15 = require("@fuel-ts/utils");
|
2329
2334
|
|
2330
2335
|
// src/providers/transaction-request/scripts.ts
|
@@ -2362,7 +2367,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2362
2367
|
return new this(obj);
|
2363
2368
|
}
|
2364
2369
|
/** Type of the transaction */
|
2365
|
-
type =
|
2370
|
+
type = import_transactions9.TransactionType.Script;
|
2366
2371
|
/** Gas limit for transaction */
|
2367
2372
|
gasLimit;
|
2368
2373
|
/** Script to execute */
|
@@ -2391,7 +2396,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2391
2396
|
const script = (0, import_utils15.arrayify)(this.script ?? "0x");
|
2392
2397
|
const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
|
2393
2398
|
return {
|
2394
|
-
type:
|
2399
|
+
type: import_transactions9.TransactionType.Script,
|
2395
2400
|
scriptGasLimit: this.gasLimit,
|
2396
2401
|
...super.getBaseTransaction(),
|
2397
2402
|
scriptLength: script.length,
|
@@ -2408,7 +2413,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2408
2413
|
*/
|
2409
2414
|
getContractInputs() {
|
2410
2415
|
return this.inputs.filter(
|
2411
|
-
(input) => input.type ===
|
2416
|
+
(input) => input.type === import_transactions9.InputType.Contract
|
2412
2417
|
);
|
2413
2418
|
}
|
2414
2419
|
/**
|
@@ -2418,7 +2423,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2418
2423
|
*/
|
2419
2424
|
getContractOutputs() {
|
2420
2425
|
return this.outputs.filter(
|
2421
|
-
(output) => output.type ===
|
2426
|
+
(output) => output.type === import_transactions9.OutputType.Contract
|
2422
2427
|
);
|
2423
2428
|
}
|
2424
2429
|
/**
|
@@ -2428,7 +2433,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2428
2433
|
*/
|
2429
2434
|
getVariableOutputs() {
|
2430
2435
|
return this.outputs.filter(
|
2431
|
-
(output) => output.type ===
|
2436
|
+
(output) => output.type === import_transactions9.OutputType.Variable
|
2432
2437
|
);
|
2433
2438
|
}
|
2434
2439
|
/**
|
@@ -2451,7 +2456,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2451
2456
|
let outputsNumber = numberOfVariables;
|
2452
2457
|
while (outputsNumber) {
|
2453
2458
|
this.pushOutput({
|
2454
|
-
type:
|
2459
|
+
type: import_transactions9.OutputType.Variable
|
2455
2460
|
});
|
2456
2461
|
outputsNumber -= 1;
|
2457
2462
|
}
|
@@ -2484,12 +2489,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2484
2489
|
return this;
|
2485
2490
|
}
|
2486
2491
|
const inputIndex = super.pushInput({
|
2487
|
-
type:
|
2492
|
+
type: import_transactions9.InputType.Contract,
|
2488
2493
|
contractId: contractAddress.toB256(),
|
2489
2494
|
txPointer: "0x00000000000000000000000000000000"
|
2490
2495
|
});
|
2491
2496
|
this.pushOutput({
|
2492
|
-
type:
|
2497
|
+
type: import_transactions9.OutputType.Contract,
|
2493
2498
|
inputIndex
|
2494
2499
|
});
|
2495
2500
|
return this;
|
@@ -2526,17 +2531,17 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2526
2531
|
|
2527
2532
|
// src/providers/transaction-request/utils.ts
|
2528
2533
|
var import_errors9 = require("@fuel-ts/errors");
|
2529
|
-
var
|
2534
|
+
var import_transactions10 = require("@fuel-ts/transactions");
|
2530
2535
|
var transactionRequestify = (obj) => {
|
2531
2536
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2532
2537
|
return obj;
|
2533
2538
|
}
|
2534
2539
|
const { type } = obj;
|
2535
2540
|
switch (obj.type) {
|
2536
|
-
case
|
2541
|
+
case import_transactions10.TransactionType.Script: {
|
2537
2542
|
return ScriptTransactionRequest.from(obj);
|
2538
2543
|
}
|
2539
|
-
case
|
2544
|
+
case import_transactions10.TransactionType.Create: {
|
2540
2545
|
return CreateTransactionRequest.from(obj);
|
2541
2546
|
}
|
2542
2547
|
default: {
|
@@ -2548,7 +2553,7 @@ var transactionRequestify = (obj) => {
|
|
2548
2553
|
// src/providers/transaction-response/transaction-response.ts
|
2549
2554
|
var import_errors13 = require("@fuel-ts/errors");
|
2550
2555
|
var import_math14 = require("@fuel-ts/math");
|
2551
|
-
var
|
2556
|
+
var import_transactions17 = require("@fuel-ts/transactions");
|
2552
2557
|
var import_utils21 = require("@fuel-ts/utils");
|
2553
2558
|
|
2554
2559
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
@@ -2556,7 +2561,7 @@ var import_utils19 = require("@fuel-ts/utils");
|
|
2556
2561
|
|
2557
2562
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2558
2563
|
var import_math11 = require("@fuel-ts/math");
|
2559
|
-
var
|
2564
|
+
var import_transactions11 = require("@fuel-ts/transactions");
|
2560
2565
|
var import_utils16 = require("@fuel-ts/utils");
|
2561
2566
|
var calculateTransactionFee = (params) => {
|
2562
2567
|
const {
|
@@ -2567,8 +2572,8 @@ var calculateTransactionFee = (params) => {
|
|
2567
2572
|
const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
|
2568
2573
|
const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
|
2569
2574
|
const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
|
2570
|
-
const [transaction] = new
|
2571
|
-
if (transaction.type ===
|
2575
|
+
const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
|
2576
|
+
if (transaction.type === import_transactions11.TransactionType.Mint) {
|
2572
2577
|
return {
|
2573
2578
|
fee: (0, import_math11.bn)(0),
|
2574
2579
|
minFee: (0, import_math11.bn)(0),
|
@@ -2579,7 +2584,7 @@ var calculateTransactionFee = (params) => {
|
|
2579
2584
|
const { type, witnesses, inputs, policies } = transaction;
|
2580
2585
|
let metadataGas = (0, import_math11.bn)(0);
|
2581
2586
|
let gasLimit = (0, import_math11.bn)(0);
|
2582
|
-
if (type ===
|
2587
|
+
if (type === import_transactions11.TransactionType.Create) {
|
2583
2588
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2584
2589
|
const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
|
2585
2590
|
metadataGas = calculateMetadataGasForTxCreate({
|
@@ -2605,8 +2610,8 @@ var calculateTransactionFee = (params) => {
|
|
2605
2610
|
metadataGas,
|
2606
2611
|
txBytesSize: transactionBytes.length
|
2607
2612
|
});
|
2608
|
-
const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type ===
|
2609
|
-
const witnessLimit = policies.find((policy) => policy.type ===
|
2613
|
+
const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
|
2614
|
+
const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
|
2610
2615
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2611
2616
|
const maxGas = getMaxGas({
|
2612
2617
|
gasPerByte,
|
@@ -2631,7 +2636,7 @@ var calculateTransactionFee = (params) => {
|
|
2631
2636
|
var import_configs11 = require("@fuel-ts/address/configs");
|
2632
2637
|
var import_errors11 = require("@fuel-ts/errors");
|
2633
2638
|
var import_math13 = require("@fuel-ts/math");
|
2634
|
-
var
|
2639
|
+
var import_transactions14 = require("@fuel-ts/transactions");
|
2635
2640
|
|
2636
2641
|
// src/providers/transaction-summary/call.ts
|
2637
2642
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
@@ -2679,7 +2684,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2679
2684
|
|
2680
2685
|
// src/providers/transaction-summary/input.ts
|
2681
2686
|
var import_errors10 = require("@fuel-ts/errors");
|
2682
|
-
var
|
2687
|
+
var import_transactions12 = require("@fuel-ts/transactions");
|
2683
2688
|
function getInputsByTypes(inputs, types) {
|
2684
2689
|
return inputs.filter((i) => types.includes(i.type));
|
2685
2690
|
}
|
@@ -2687,16 +2692,16 @@ function getInputsByType(inputs, type) {
|
|
2687
2692
|
return inputs.filter((i) => i.type === type);
|
2688
2693
|
}
|
2689
2694
|
function getInputsCoin(inputs) {
|
2690
|
-
return getInputsByType(inputs,
|
2695
|
+
return getInputsByType(inputs, import_transactions12.InputType.Coin);
|
2691
2696
|
}
|
2692
2697
|
function getInputsMessage(inputs) {
|
2693
|
-
return getInputsByType(inputs,
|
2698
|
+
return getInputsByType(inputs, import_transactions12.InputType.Message);
|
2694
2699
|
}
|
2695
2700
|
function getInputsCoinAndMessage(inputs) {
|
2696
|
-
return getInputsByTypes(inputs, [
|
2701
|
+
return getInputsByTypes(inputs, [import_transactions12.InputType.Coin, import_transactions12.InputType.Message]);
|
2697
2702
|
}
|
2698
2703
|
function getInputsContract(inputs) {
|
2699
|
-
return getInputsByType(inputs,
|
2704
|
+
return getInputsByType(inputs, import_transactions12.InputType.Contract);
|
2700
2705
|
}
|
2701
2706
|
function getInputFromAssetId(inputs, assetId) {
|
2702
2707
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2715,7 +2720,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2715
2720
|
if (!contractInput) {
|
2716
2721
|
return void 0;
|
2717
2722
|
}
|
2718
|
-
if (contractInput.type !==
|
2723
|
+
if (contractInput.type !== import_transactions12.InputType.Contract) {
|
2719
2724
|
throw new import_errors10.FuelError(
|
2720
2725
|
import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
|
2721
2726
|
`Contract input should be of type 'contract'.`
|
@@ -2724,31 +2729,31 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2724
2729
|
return contractInput;
|
2725
2730
|
}
|
2726
2731
|
function getInputAccountAddress(input) {
|
2727
|
-
if (input.type ===
|
2732
|
+
if (input.type === import_transactions12.InputType.Coin) {
|
2728
2733
|
return input.owner.toString();
|
2729
2734
|
}
|
2730
|
-
if (input.type ===
|
2735
|
+
if (input.type === import_transactions12.InputType.Message) {
|
2731
2736
|
return input.recipient.toString();
|
2732
2737
|
}
|
2733
2738
|
return "";
|
2734
2739
|
}
|
2735
2740
|
|
2736
2741
|
// src/providers/transaction-summary/output.ts
|
2737
|
-
var
|
2742
|
+
var import_transactions13 = require("@fuel-ts/transactions");
|
2738
2743
|
function getOutputsByType(outputs, type) {
|
2739
2744
|
return outputs.filter((o) => o.type === type);
|
2740
2745
|
}
|
2741
2746
|
function getOutputsContractCreated(outputs) {
|
2742
|
-
return getOutputsByType(outputs,
|
2747
|
+
return getOutputsByType(outputs, import_transactions13.OutputType.ContractCreated);
|
2743
2748
|
}
|
2744
2749
|
function getOutputsCoin(outputs) {
|
2745
|
-
return getOutputsByType(outputs,
|
2750
|
+
return getOutputsByType(outputs, import_transactions13.OutputType.Coin);
|
2746
2751
|
}
|
2747
2752
|
function getOutputsChange(outputs) {
|
2748
|
-
return getOutputsByType(outputs,
|
2753
|
+
return getOutputsByType(outputs, import_transactions13.OutputType.Change);
|
2749
2754
|
}
|
2750
2755
|
function getOutputsContract(outputs) {
|
2751
|
-
return getOutputsByType(outputs,
|
2756
|
+
return getOutputsByType(outputs, import_transactions13.OutputType.Contract);
|
2752
2757
|
}
|
2753
2758
|
|
2754
2759
|
// src/providers/transaction-summary/operations.ts
|
@@ -2757,11 +2762,11 @@ function getReceiptsByType(receipts, type) {
|
|
2757
2762
|
}
|
2758
2763
|
function getTransactionTypeName(transactionType) {
|
2759
2764
|
switch (transactionType) {
|
2760
|
-
case
|
2765
|
+
case import_transactions14.TransactionType.Mint:
|
2761
2766
|
return "Mint" /* Mint */;
|
2762
|
-
case
|
2767
|
+
case import_transactions14.TransactionType.Create:
|
2763
2768
|
return "Create" /* Create */;
|
2764
|
-
case
|
2769
|
+
case import_transactions14.TransactionType.Script:
|
2765
2770
|
return "Script" /* Script */;
|
2766
2771
|
default:
|
2767
2772
|
throw new import_errors11.FuelError(
|
@@ -2784,10 +2789,10 @@ function isTypeScript(transactionType) {
|
|
2784
2789
|
return isType(transactionType, "Script" /* Script */);
|
2785
2790
|
}
|
2786
2791
|
function getReceiptsCall(receipts) {
|
2787
|
-
return getReceiptsByType(receipts,
|
2792
|
+
return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
|
2788
2793
|
}
|
2789
2794
|
function getReceiptsMessageOut(receipts) {
|
2790
|
-
return getReceiptsByType(receipts,
|
2795
|
+
return getReceiptsByType(receipts, import_transactions14.ReceiptType.MessageOut);
|
2791
2796
|
}
|
2792
2797
|
var mergeAssets = (op1, op2) => {
|
2793
2798
|
const assets1 = op1.assetsSent || [];
|
@@ -2983,11 +2988,11 @@ function getTransferOperations({
|
|
2983
2988
|
});
|
2984
2989
|
const transferReceipts = getReceiptsByType(
|
2985
2990
|
receipts,
|
2986
|
-
|
2991
|
+
import_transactions14.ReceiptType.Transfer
|
2987
2992
|
);
|
2988
2993
|
const transferOutReceipts = getReceiptsByType(
|
2989
2994
|
receipts,
|
2990
|
-
|
2995
|
+
import_transactions14.ReceiptType.TransferOut
|
2991
2996
|
);
|
2992
2997
|
[...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
|
2993
2998
|
const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
|
@@ -3072,17 +3077,17 @@ function getOperations({
|
|
3072
3077
|
}
|
3073
3078
|
|
3074
3079
|
// src/providers/transaction-summary/receipt.ts
|
3075
|
-
var
|
3080
|
+
var import_transactions15 = require("@fuel-ts/transactions");
|
3076
3081
|
var processGqlReceipt = (gqlReceipt) => {
|
3077
3082
|
const receipt = assembleReceiptByType(gqlReceipt);
|
3078
3083
|
switch (receipt.type) {
|
3079
|
-
case
|
3084
|
+
case import_transactions15.ReceiptType.ReturnData: {
|
3080
3085
|
return {
|
3081
3086
|
...receipt,
|
3082
3087
|
data: gqlReceipt.data || "0x"
|
3083
3088
|
};
|
3084
3089
|
}
|
3085
|
-
case
|
3090
|
+
case import_transactions15.ReceiptType.LogData: {
|
3086
3091
|
return {
|
3087
3092
|
...receipt,
|
3088
3093
|
data: gqlReceipt.data || "0x"
|
@@ -3095,7 +3100,7 @@ var processGqlReceipt = (gqlReceipt) => {
|
|
3095
3100
|
var extractMintedAssetsFromReceipts = (receipts) => {
|
3096
3101
|
const mintedAssets = [];
|
3097
3102
|
receipts.forEach((receipt) => {
|
3098
|
-
if (receipt.type ===
|
3103
|
+
if (receipt.type === import_transactions15.ReceiptType.Mint) {
|
3099
3104
|
mintedAssets.push({
|
3100
3105
|
subId: receipt.subId,
|
3101
3106
|
contractId: receipt.contractId,
|
@@ -3109,7 +3114,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
|
|
3109
3114
|
var extractBurnedAssetsFromReceipts = (receipts) => {
|
3110
3115
|
const burnedAssets = [];
|
3111
3116
|
receipts.forEach((receipt) => {
|
3112
|
-
if (receipt.type ===
|
3117
|
+
if (receipt.type === import_transactions15.ReceiptType.Burn) {
|
3113
3118
|
burnedAssets.push({
|
3114
3119
|
subId: receipt.subId,
|
3115
3120
|
contractId: receipt.contractId,
|
@@ -3248,12 +3253,12 @@ function assembleTransactionSummary(params) {
|
|
3248
3253
|
|
3249
3254
|
// src/providers/transaction-response/getDecodedLogs.ts
|
3250
3255
|
var import_abi_coder5 = require("@fuel-ts/abi-coder");
|
3251
|
-
var
|
3256
|
+
var import_transactions16 = require("@fuel-ts/transactions");
|
3252
3257
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
3253
3258
|
return receipts.reduce((logs, receipt) => {
|
3254
|
-
if (receipt.type ===
|
3259
|
+
if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
|
3255
3260
|
const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
|
3256
|
-
const data = receipt.type ===
|
3261
|
+
const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
|
3257
3262
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
|
3258
3263
|
logs.push(decodedLog);
|
3259
3264
|
}
|
@@ -3326,7 +3331,7 @@ var TransactionResponse = class {
|
|
3326
3331
|
* @returns The decoded transaction.
|
3327
3332
|
*/
|
3328
3333
|
decodeTransaction(transactionWithReceipts) {
|
3329
|
-
return new
|
3334
|
+
return new import_transactions17.TransactionCoder().decode(
|
3330
3335
|
(0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
|
3331
3336
|
0
|
3332
3337
|
)?.[0];
|
@@ -3681,21 +3686,6 @@ var _Provider = class {
|
|
3681
3686
|
} = await this.operations.getVersion();
|
3682
3687
|
return nodeVersion;
|
3683
3688
|
}
|
3684
|
-
/**
|
3685
|
-
* @hidden
|
3686
|
-
*
|
3687
|
-
* Returns the network configuration of the connected Fuel node.
|
3688
|
-
*
|
3689
|
-
* @returns A promise that resolves to the network configuration object
|
3690
|
-
*/
|
3691
|
-
async getNetwork() {
|
3692
|
-
const {
|
3693
|
-
name,
|
3694
|
-
consensusParameters: { chainId }
|
3695
|
-
} = await this.getChain();
|
3696
|
-
const network = new import_ethers.Network(name, chainId.toNumber());
|
3697
|
-
return Promise.resolve(network);
|
3698
|
-
}
|
3699
3689
|
/**
|
3700
3690
|
* Returns the block number.
|
3701
3691
|
*
|
@@ -3763,7 +3753,7 @@ var _Provider = class {
|
|
3763
3753
|
}
|
3764
3754
|
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
3765
3755
|
let abis;
|
3766
|
-
if (transactionRequest.type ===
|
3756
|
+
if (transactionRequest.type === import_transactions18.TransactionType.Script) {
|
3767
3757
|
abis = transactionRequest.abis;
|
3768
3758
|
}
|
3769
3759
|
if (awaitExecution) {
|
@@ -3859,7 +3849,7 @@ var _Provider = class {
|
|
3859
3849
|
* @returns A promise.
|
3860
3850
|
*/
|
3861
3851
|
async estimateTxDependencies(transactionRequest) {
|
3862
|
-
if (transactionRequest.type ===
|
3852
|
+
if (transactionRequest.type === import_transactions18.TransactionType.Create) {
|
3863
3853
|
return {
|
3864
3854
|
receipts: [],
|
3865
3855
|
outputVariables: 0,
|
@@ -3908,7 +3898,7 @@ var _Provider = class {
|
|
3908
3898
|
transactionRequest.gasPrice = gasPrice;
|
3909
3899
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
3910
3900
|
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
3911
|
-
if (transactionRequest.type ===
|
3901
|
+
if (transactionRequest.type === import_transactions18.TransactionType.Script) {
|
3912
3902
|
if (transactionRequest.gasLimit.eq(0)) {
|
3913
3903
|
transactionRequest.gasLimit = minGas;
|
3914
3904
|
transactionRequest.gasLimit = maxGasPerTx.sub(
|
@@ -3974,7 +3964,7 @@ var _Provider = class {
|
|
3974
3964
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
3975
3965
|
const { minGasPrice } = this.getGasConfig();
|
3976
3966
|
const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
|
3977
|
-
const isScriptTransaction = txRequestClone.type ===
|
3967
|
+
const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
|
3978
3968
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
3979
3969
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
3980
3970
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
@@ -4190,7 +4180,7 @@ var _Provider = class {
|
|
4190
4180
|
time: block.header.time,
|
4191
4181
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4192
4182
|
transactions: block.transactions.map(
|
4193
|
-
(tx) => new
|
4183
|
+
(tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
|
4194
4184
|
)
|
4195
4185
|
};
|
4196
4186
|
}
|
@@ -4205,7 +4195,7 @@ var _Provider = class {
|
|
4205
4195
|
if (!transaction) {
|
4206
4196
|
return null;
|
4207
4197
|
}
|
4208
|
-
return new
|
4198
|
+
return new import_transactions18.TransactionCoder().decode(
|
4209
4199
|
(0, import_utils23.arrayify)(transaction.rawPayload),
|
4210
4200
|
0
|
4211
4201
|
)?.[0];
|
@@ -4285,7 +4275,7 @@ var _Provider = class {
|
|
4285
4275
|
});
|
4286
4276
|
const messages = result.messages.edges.map((edge) => edge.node);
|
4287
4277
|
return messages.map((message) => ({
|
4288
|
-
messageId:
|
4278
|
+
messageId: import_transactions18.InputMessageCoder.getMessageId({
|
4289
4279
|
sender: message.sender,
|
4290
4280
|
recipient: message.recipient,
|
4291
4281
|
nonce: message.nonce,
|
@@ -4296,7 +4286,7 @@ var _Provider = class {
|
|
4296
4286
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4297
4287
|
nonce: message.nonce,
|
4298
4288
|
amount: (0, import_math15.bn)(message.amount),
|
4299
|
-
data:
|
4289
|
+
data: import_transactions18.InputMessageCoder.decodeData(message.data),
|
4300
4290
|
daHeight: (0, import_math15.bn)(message.daHeight)
|
4301
4291
|
}));
|
4302
4292
|
}
|
@@ -4424,7 +4414,7 @@ cacheInputs_fn = function(inputs) {
|
|
4424
4414
|
return;
|
4425
4415
|
}
|
4426
4416
|
inputs.forEach((input) => {
|
4427
|
-
if (input.type ===
|
4417
|
+
if (input.type === import_transactions18.InputType.Coin) {
|
4428
4418
|
this.cache?.set(input.id);
|
4429
4419
|
}
|
4430
4420
|
});
|
@@ -4435,7 +4425,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4435
4425
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4436
4426
|
var import_errors15 = require("@fuel-ts/errors");
|
4437
4427
|
var import_math16 = require("@fuel-ts/math");
|
4438
|
-
var
|
4428
|
+
var import_transactions19 = require("@fuel-ts/transactions");
|
4439
4429
|
var import_utils26 = require("@fuel-ts/utils");
|
4440
4430
|
|
4441
4431
|
// src/providers/chains.ts
|
@@ -5252,18 +5242,17 @@ var BaseWalletUnlocked = class extends Account {
|
|
5252
5242
|
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
5253
5243
|
|
5254
5244
|
// src/hdwallet/hdwallet.ts
|
5245
|
+
var import_crypto5 = require("@fuel-ts/crypto");
|
5255
5246
|
var import_errors20 = require("@fuel-ts/errors");
|
5256
5247
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5257
5248
|
var import_math20 = require("@fuel-ts/math");
|
5258
5249
|
var import_utils35 = require("@fuel-ts/utils");
|
5259
|
-
var import_ethers3 = require("ethers");
|
5260
5250
|
|
5261
5251
|
// src/mnemonic/mnemonic.ts
|
5262
5252
|
var import_crypto4 = require("@fuel-ts/crypto");
|
5263
5253
|
var import_errors19 = require("@fuel-ts/errors");
|
5264
5254
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5265
5255
|
var import_utils33 = require("@fuel-ts/utils");
|
5266
|
-
var import_ethers2 = require("ethers");
|
5267
5256
|
|
5268
5257
|
// src/wordlists/words/english.ts
|
5269
5258
|
var english = [
|
@@ -7511,7 +7500,7 @@ var Mnemonic = class {
|
|
7511
7500
|
assertMnemonic(getWords(phrase));
|
7512
7501
|
const phraseBytes = toUtf8Bytes(getPhrase(phrase));
|
7513
7502
|
const salt = toUtf8Bytes(`mnemonic${passphrase}`);
|
7514
|
-
return (0,
|
7503
|
+
return (0, import_crypto4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
7515
7504
|
}
|
7516
7505
|
/**
|
7517
7506
|
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
|
@@ -7573,7 +7562,7 @@ var Mnemonic = class {
|
|
7573
7562
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7574
7563
|
);
|
7575
7564
|
}
|
7576
|
-
return (0, import_utils33.arrayify)((0,
|
7565
|
+
return (0, import_utils33.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
|
7577
7566
|
}
|
7578
7567
|
/**
|
7579
7568
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7598,8 +7587,8 @@ var Mnemonic = class {
|
|
7598
7587
|
chainCode,
|
7599
7588
|
(0, import_utils33.concat)(["0x00", privateKey])
|
7600
7589
|
]);
|
7601
|
-
const checksum = (0,
|
7602
|
-
return (0,
|
7590
|
+
const checksum = (0, import_utils33.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
7591
|
+
return (0, import_utils33.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
|
7603
7592
|
}
|
7604
7593
|
/**
|
7605
7594
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -7627,7 +7616,7 @@ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
|
|
7627
7616
|
var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
|
7628
7617
|
var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
|
7629
7618
|
function base58check(data) {
|
7630
|
-
return (0,
|
7619
|
+
return (0, import_utils35.encodeBase58)((0, import_utils35.concat)([data, (0, import_utils35.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
7631
7620
|
}
|
7632
7621
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
7633
7622
|
if (isPublic) {
|
@@ -7683,7 +7672,7 @@ var HDWallet = class {
|
|
7683
7672
|
this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
|
7684
7673
|
}
|
7685
7674
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
7686
|
-
this.fingerprint = (0,
|
7675
|
+
this.fingerprint = (0, import_utils35.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
7687
7676
|
this.depth = config.depth || this.depth;
|
7688
7677
|
this.index = config.index || this.index;
|
7689
7678
|
this.chainCode = config.chainCode;
|
@@ -7715,7 +7704,7 @@ var HDWallet = class {
|
|
7715
7704
|
data.set((0, import_utils35.arrayify)(this.publicKey));
|
7716
7705
|
}
|
7717
7706
|
data.set((0, import_math20.toBytes)(index, 4), 33);
|
7718
|
-
const bytes = (0, import_utils35.arrayify)((0,
|
7707
|
+
const bytes = (0, import_utils35.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
|
7719
7708
|
const IL = bytes.slice(0, 32);
|
7720
7709
|
const IR = bytes.slice(32);
|
7721
7710
|
if (privateKey) {
|
@@ -7786,7 +7775,8 @@ var HDWallet = class {
|
|
7786
7775
|
});
|
7787
7776
|
}
|
7788
7777
|
static fromExtendedKey(extendedKey) {
|
7789
|
-
|
7778
|
+
let decoded = (0, import_math20.toHex)((0, import_utils35.decodeBase58)(extendedKey));
|
7779
|
+
decoded = `${decoded.substring(0, 2)}0${decoded.substring(2)}`;
|
7790
7780
|
const bytes = (0, import_utils35.arrayify)(decoded);
|
7791
7781
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
7792
7782
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
@@ -7985,12 +7975,11 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
|
|
7985
7975
|
__publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
7986
7976
|
|
7987
7977
|
// src/test-utils/seedTestWallet.ts
|
7988
|
-
var
|
7989
|
-
var seedTestWallet = async (wallet, quantities
|
7990
|
-
const toFundAccounts = Array.isArray(wallet) ? wallet : [wallet];
|
7978
|
+
var import_crypto6 = require("@fuel-ts/crypto");
|
7979
|
+
var seedTestWallet = async (wallet, quantities) => {
|
7991
7980
|
const genesisWallet = new WalletUnlocked(
|
7992
|
-
process.env.GENESIS_SECRET || (0,
|
7993
|
-
|
7981
|
+
process.env.GENESIS_SECRET || (0, import_crypto6.randomBytes)(32),
|
7982
|
+
wallet.provider
|
7994
7983
|
);
|
7995
7984
|
const resources = await genesisWallet.getResourcesToSpend(quantities);
|
7996
7985
|
const { minGasPrice } = genesisWallet.provider.getGasConfig();
|
@@ -7999,13 +7988,7 @@ var seedTestWallet = async (wallet, quantities, utxosAmount = 1) => {
|
|
7999
7988
|
gasPrice: minGasPrice
|
8000
7989
|
});
|
8001
7990
|
request.addResources(resources);
|
8002
|
-
quantities.map(coinQuantityfy).forEach(
|
8003
|
-
({ amount, assetId }) => toFundAccounts.forEach(({ address }) => {
|
8004
|
-
for (let i = 0; i < utxosAmount; i++) {
|
8005
|
-
request.addCoinOutput(address, amount.div(utxosAmount), assetId);
|
8006
|
-
}
|
8007
|
-
})
|
8008
|
-
);
|
7991
|
+
quantities.map(coinQuantityfy).forEach(({ amount, assetId }) => request.addCoinOutput(wallet.address, amount, assetId));
|
8009
7992
|
await genesisWallet.sendTransaction(request, { awaitExecution: true });
|
8010
7993
|
};
|
8011
7994
|
|
@@ -8024,7 +8007,7 @@ var import_math21 = require("@fuel-ts/math");
|
|
8024
8007
|
var import_utils36 = require("@fuel-ts/utils");
|
8025
8008
|
var import_cli_utils = require("@fuel-ts/utils/cli-utils");
|
8026
8009
|
var import_child_process = require("child_process");
|
8027
|
-
var
|
8010
|
+
var import_crypto7 = require("crypto");
|
8028
8011
|
var import_fs = require("fs");
|
8029
8012
|
var import_os = __toESM(require("os"));
|
8030
8013
|
var import_path = __toESM(require("path"));
|
@@ -8096,7 +8079,7 @@ var launchNode = async ({
|
|
8096
8079
|
})).toString();
|
8097
8080
|
let chainConfigPathToUse;
|
8098
8081
|
const prefix = basePath || import_os.default.tmpdir();
|
8099
|
-
const suffix = basePath ? "" : (0,
|
8082
|
+
const suffix = basePath ? "" : (0, import_crypto7.randomUUID)();
|
8100
8083
|
const tempDirPath = import_path.default.join(prefix, ".fuels", suffix);
|
8101
8084
|
if (chainConfigPath) {
|
8102
8085
|
chainConfigPathToUse = chainConfigPath;
|
@@ -8204,45 +8187,8 @@ var launchNodeAndGetWallets = async ({
|
|
8204
8187
|
};
|
8205
8188
|
return { wallets, stop: cleanup, provider };
|
8206
8189
|
};
|
8207
|
-
|
8208
|
-
// src/test-utils/transactionRequest.ts
|
8209
|
-
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
8210
|
-
var import_address7 = require("@fuel-ts/address");
|
8211
|
-
var import_configs14 = require("@fuel-ts/address/configs");
|
8212
|
-
var import_crypto7 = require("@fuel-ts/crypto");
|
8213
|
-
var import_math22 = require("@fuel-ts/math");
|
8214
|
-
var import_transactions21 = require("@fuel-ts/transactions");
|
8215
|
-
var import_utils37 = require("@fuel-ts/utils");
|
8216
|
-
var generateFakeRequestInputCoin = (partial = {}) => ({
|
8217
|
-
id: (0, import_utils37.hexlify)((0, import_crypto7.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
|
8218
|
-
type: import_transactions21.InputType.Coin,
|
8219
|
-
owner: (0, import_address7.getRandomB256)(),
|
8220
|
-
amount: (0, import_math22.bn)(100),
|
8221
|
-
assetId: import_configs14.ZeroBytes32,
|
8222
|
-
txPointer: "0x00000000000000000000000000000000",
|
8223
|
-
witnessIndex: 0,
|
8224
|
-
...partial
|
8225
|
-
});
|
8226
|
-
var generateFakeRequestInputMessage = (partial = {}) => ({
|
8227
|
-
nonce: (0, import_address7.getRandomB256)(),
|
8228
|
-
type: import_transactions21.InputType.Message,
|
8229
|
-
sender: (0, import_address7.getRandomB256)(),
|
8230
|
-
recipient: (0, import_address7.getRandomB256)(),
|
8231
|
-
amount: (0, import_math22.bn)(100),
|
8232
|
-
witnessIndex: 0,
|
8233
|
-
...partial
|
8234
|
-
});
|
8235
|
-
var generateFakeRequestInputContract = (partial = {}) => ({
|
8236
|
-
contractId: (0, import_address7.getRandomB256)(),
|
8237
|
-
type: import_transactions21.InputType.Contract,
|
8238
|
-
txPointer: "0x00000000000000000000000000000000",
|
8239
|
-
...partial
|
8240
|
-
});
|
8241
8190
|
// Annotate the CommonJS export names for ESM import in node:
|
8242
8191
|
0 && (module.exports = {
|
8243
|
-
generateFakeRequestInputCoin,
|
8244
|
-
generateFakeRequestInputContract,
|
8245
|
-
generateFakeRequestInputMessage,
|
8246
8192
|
generateTestWallet,
|
8247
8193
|
killNode,
|
8248
8194
|
launchNode,
|