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