@fuel-ts/account 0.0.0-rc-2037-20240429115810 → 0.0.0-rc-2152-20240429145747
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/dist/index.global.js +126 -1074
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +128 -218
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -123
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +2 -9
- package/dist/predicate/predicate.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 +0 -2
- 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 +136 -1073
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +125 -205
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +42 -119
- 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 -15
- 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.mjs
CHANGED
@@ -70,7 +70,7 @@ import { Address as Address2 } from "@fuel-ts/address";
|
|
70
70
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
71
71
|
import { BN, bn as bn16 } from "@fuel-ts/math";
|
72
72
|
import {
|
73
|
-
InputType as
|
73
|
+
InputType as InputType7,
|
74
74
|
TransactionType as TransactionType8,
|
75
75
|
InputMessageCoder,
|
76
76
|
TransactionCoder as TransactionCoder5
|
@@ -78,7 +78,6 @@ import {
|
|
78
78
|
import { arrayify as arrayify11, hexlify as hexlify12, DateTime as DateTime2 } from "@fuel-ts/utils";
|
79
79
|
import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
|
80
80
|
import { equalBytes } from "@noble/curves/abstract/utils";
|
81
|
-
import { Network } from "ethers";
|
82
81
|
import { GraphQLClient } from "graphql-request";
|
83
82
|
import { clone as clone3 } from "ramda";
|
84
83
|
|
@@ -1235,7 +1234,7 @@ import { bn as bn7 } from "@fuel-ts/math";
|
|
1235
1234
|
import {
|
1236
1235
|
PolicyType,
|
1237
1236
|
TransactionCoder,
|
1238
|
-
InputType as
|
1237
|
+
InputType as InputType2,
|
1239
1238
|
OutputType as OutputType2,
|
1240
1239
|
TransactionType
|
1241
1240
|
} from "@fuel-ts/transactions";
|
@@ -1685,12 +1684,6 @@ var NoWitnessAtIndexError = class extends Error {
|
|
1685
1684
|
name = "NoWitnessAtIndexError";
|
1686
1685
|
};
|
1687
1686
|
|
1688
|
-
// src/providers/transaction-request/helpers.ts
|
1689
|
-
import { InputType as InputType2 } from "@fuel-ts/transactions";
|
1690
|
-
var isRequestInputCoin = (input) => input.type === InputType2.Coin;
|
1691
|
-
var isRequestInputMessage = (input) => input.type === InputType2.Message;
|
1692
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
1693
|
-
|
1694
1687
|
// src/providers/transaction-request/witness.ts
|
1695
1688
|
import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
|
1696
1689
|
var witnessify = (value) => {
|
@@ -1881,7 +1874,7 @@ var BaseTransactionRequest = class {
|
|
1881
1874
|
*/
|
1882
1875
|
getCoinInputs() {
|
1883
1876
|
return this.inputs.filter(
|
1884
|
-
(input) => input.type ===
|
1877
|
+
(input) => input.type === InputType2.Coin
|
1885
1878
|
);
|
1886
1879
|
}
|
1887
1880
|
/**
|
@@ -1913,9 +1906,9 @@ var BaseTransactionRequest = class {
|
|
1913
1906
|
const ownerAddress = addressify(owner);
|
1914
1907
|
const found = this.inputs.find((input) => {
|
1915
1908
|
switch (input.type) {
|
1916
|
-
case
|
1909
|
+
case InputType2.Coin:
|
1917
1910
|
return hexlify7(input.owner) === ownerAddress.toB256();
|
1918
|
-
case
|
1911
|
+
case InputType2.Message:
|
1919
1912
|
return hexlify7(input.recipient) === ownerAddress.toB256();
|
1920
1913
|
default:
|
1921
1914
|
return false;
|
@@ -1930,7 +1923,7 @@ var BaseTransactionRequest = class {
|
|
1930
1923
|
* @param coin - Coin resource.
|
1931
1924
|
*/
|
1932
1925
|
addCoinInput(coin) {
|
1933
|
-
const { assetId, owner, amount
|
1926
|
+
const { assetId, owner, amount } = coin;
|
1934
1927
|
let witnessIndex;
|
1935
1928
|
if (coin.predicate) {
|
1936
1929
|
witnessIndex = 0;
|
@@ -1941,14 +1934,13 @@ var BaseTransactionRequest = class {
|
|
1941
1934
|
}
|
1942
1935
|
}
|
1943
1936
|
const input = {
|
1944
|
-
|
1945
|
-
type:
|
1937
|
+
...coin,
|
1938
|
+
type: InputType2.Coin,
|
1946
1939
|
owner: owner.toB256(),
|
1947
1940
|
amount,
|
1948
1941
|
assetId,
|
1949
1942
|
txPointer: "0x00000000000000000000000000000000",
|
1950
|
-
witnessIndex
|
1951
|
-
predicate
|
1943
|
+
witnessIndex
|
1952
1944
|
};
|
1953
1945
|
this.pushInput(input);
|
1954
1946
|
this.addChangeOutput(owner, assetId);
|
@@ -1960,7 +1952,7 @@ var BaseTransactionRequest = class {
|
|
1960
1952
|
* @param message - Message resource.
|
1961
1953
|
*/
|
1962
1954
|
addMessageInput(message) {
|
1963
|
-
const { recipient, sender, amount,
|
1955
|
+
const { recipient, sender, amount, assetId } = message;
|
1964
1956
|
let witnessIndex;
|
1965
1957
|
if (message.predicate) {
|
1966
1958
|
witnessIndex = 0;
|
@@ -1971,13 +1963,12 @@ var BaseTransactionRequest = class {
|
|
1971
1963
|
}
|
1972
1964
|
}
|
1973
1965
|
const input = {
|
1974
|
-
|
1975
|
-
type:
|
1966
|
+
...message,
|
1967
|
+
type: InputType2.Message,
|
1976
1968
|
sender: sender.toB256(),
|
1977
1969
|
recipient: recipient.toB256(),
|
1978
1970
|
amount,
|
1979
|
-
witnessIndex
|
1980
|
-
predicate
|
1971
|
+
witnessIndex
|
1981
1972
|
};
|
1982
1973
|
this.pushInput(input);
|
1983
1974
|
this.addChangeOutput(recipient, assetId);
|
@@ -2161,27 +2152,16 @@ var BaseTransactionRequest = class {
|
|
2161
2152
|
toJSON() {
|
2162
2153
|
return normalizeJSON(this);
|
2163
2154
|
}
|
2164
|
-
removeWitness(index) {
|
2165
|
-
this.witnesses.splice(index, 1);
|
2166
|
-
this.adjustWitnessIndexes(index);
|
2167
|
-
}
|
2168
|
-
adjustWitnessIndexes(removedIndex) {
|
2169
|
-
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
2170
|
-
if (input.witnessIndex > removedIndex) {
|
2171
|
-
input.witnessIndex -= 1;
|
2172
|
-
}
|
2173
|
-
});
|
2174
|
-
}
|
2175
2155
|
updatePredicateGasUsed(inputs) {
|
2176
2156
|
this.inputs.forEach((i) => {
|
2177
2157
|
let correspondingInput;
|
2178
2158
|
switch (i.type) {
|
2179
|
-
case
|
2180
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2159
|
+
case InputType2.Coin:
|
2160
|
+
correspondingInput = inputs.find((x) => x.type === InputType2.Coin && x.owner === i.owner);
|
2181
2161
|
break;
|
2182
|
-
case
|
2162
|
+
case InputType2.Message:
|
2183
2163
|
correspondingInput = inputs.find(
|
2184
|
-
(x) => x.type ===
|
2164
|
+
(x) => x.type === InputType2.Message && x.sender === i.sender
|
2185
2165
|
);
|
2186
2166
|
break;
|
2187
2167
|
default:
|
@@ -2215,7 +2195,7 @@ import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
|
2215
2195
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2216
2196
|
import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
|
2217
2197
|
import { bn as bn8 } from "@fuel-ts/math";
|
2218
|
-
import { TransactionType as TransactionType2, InputType as
|
2198
|
+
import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
|
2219
2199
|
import { concat as concat2 } from "@fuel-ts/utils";
|
2220
2200
|
import { clone as clone2 } from "ramda";
|
2221
2201
|
function hashTransaction(transactionRequest, chainId) {
|
@@ -2226,7 +2206,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2226
2206
|
transaction.inputs = transaction.inputs.map((input) => {
|
2227
2207
|
const inputClone = clone2(input);
|
2228
2208
|
switch (inputClone.type) {
|
2229
|
-
case
|
2209
|
+
case InputType3.Coin: {
|
2230
2210
|
inputClone.txPointer = {
|
2231
2211
|
blockHeight: 0,
|
2232
2212
|
txIndex: 0
|
@@ -2234,11 +2214,11 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2234
2214
|
inputClone.predicateGasUsed = bn8(0);
|
2235
2215
|
return inputClone;
|
2236
2216
|
}
|
2237
|
-
case
|
2217
|
+
case InputType3.Message: {
|
2238
2218
|
inputClone.predicateGasUsed = bn8(0);
|
2239
2219
|
return inputClone;
|
2240
2220
|
}
|
2241
|
-
case
|
2221
|
+
case InputType3.Contract: {
|
2242
2222
|
inputClone.txPointer = {
|
2243
2223
|
blockHeight: 0,
|
2244
2224
|
txIndex: 0
|
@@ -2398,7 +2378,7 @@ import { Interface } from "@fuel-ts/abi-coder";
|
|
2398
2378
|
import { addressify as addressify2 } from "@fuel-ts/address";
|
2399
2379
|
import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
2400
2380
|
import { bn as bn10 } from "@fuel-ts/math";
|
2401
|
-
import { InputType as
|
2381
|
+
import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
2402
2382
|
import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
|
2403
2383
|
|
2404
2384
|
// src/providers/transaction-request/scripts.ts
|
@@ -2482,7 +2462,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2482
2462
|
*/
|
2483
2463
|
getContractInputs() {
|
2484
2464
|
return this.inputs.filter(
|
2485
|
-
(input) => input.type ===
|
2465
|
+
(input) => input.type === InputType4.Contract
|
2486
2466
|
);
|
2487
2467
|
}
|
2488
2468
|
/**
|
@@ -2559,7 +2539,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2559
2539
|
return this;
|
2560
2540
|
}
|
2561
2541
|
const inputIndex = super.pushInput({
|
2562
|
-
type:
|
2542
|
+
type: InputType4.Contract,
|
2563
2543
|
contractId: contractAddress.toB256(),
|
2564
2544
|
txPointer: "0x00000000000000000000000000000000"
|
2565
2545
|
});
|
@@ -2601,7 +2581,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2601
2581
|
|
2602
2582
|
// src/providers/transaction-request/utils.ts
|
2603
2583
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2604
|
-
import { TransactionType as TransactionType5, InputType as
|
2584
|
+
import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
|
2605
2585
|
var transactionRequestify = (obj) => {
|
2606
2586
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2607
2587
|
return obj;
|
@@ -2621,10 +2601,10 @@ var transactionRequestify = (obj) => {
|
|
2621
2601
|
};
|
2622
2602
|
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2623
2603
|
(acc, input) => {
|
2624
|
-
if (input.type ===
|
2604
|
+
if (input.type === InputType5.Coin && input.owner === owner) {
|
2625
2605
|
acc.utxos.push(input.id);
|
2626
2606
|
}
|
2627
|
-
if (input.type ===
|
2607
|
+
if (input.type === InputType5.Message && input.recipient === owner) {
|
2628
2608
|
acc.messages.push(input.nonce);
|
2629
2609
|
}
|
2630
2610
|
return acc;
|
@@ -2778,7 +2758,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2778
2758
|
|
2779
2759
|
// src/providers/transaction-summary/input.ts
|
2780
2760
|
import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2781
|
-
import { InputType as
|
2761
|
+
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
2782
2762
|
function getInputsByTypes(inputs, types) {
|
2783
2763
|
return inputs.filter((i) => types.includes(i.type));
|
2784
2764
|
}
|
@@ -2786,16 +2766,16 @@ function getInputsByType(inputs, type) {
|
|
2786
2766
|
return inputs.filter((i) => i.type === type);
|
2787
2767
|
}
|
2788
2768
|
function getInputsCoin(inputs) {
|
2789
|
-
return getInputsByType(inputs,
|
2769
|
+
return getInputsByType(inputs, InputType6.Coin);
|
2790
2770
|
}
|
2791
2771
|
function getInputsMessage(inputs) {
|
2792
|
-
return getInputsByType(inputs,
|
2772
|
+
return getInputsByType(inputs, InputType6.Message);
|
2793
2773
|
}
|
2794
2774
|
function getInputsCoinAndMessage(inputs) {
|
2795
|
-
return getInputsByTypes(inputs, [
|
2775
|
+
return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
|
2796
2776
|
}
|
2797
2777
|
function getInputsContract(inputs) {
|
2798
|
-
return getInputsByType(inputs,
|
2778
|
+
return getInputsByType(inputs, InputType6.Contract);
|
2799
2779
|
}
|
2800
2780
|
function getInputFromAssetId(inputs, assetId) {
|
2801
2781
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2814,7 +2794,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2814
2794
|
if (!contractInput) {
|
2815
2795
|
return void 0;
|
2816
2796
|
}
|
2817
|
-
if (contractInput.type !==
|
2797
|
+
if (contractInput.type !== InputType6.Contract) {
|
2818
2798
|
throw new FuelError9(
|
2819
2799
|
ErrorCode9.INVALID_TRANSACTION_INPUT,
|
2820
2800
|
`Contract input should be of type 'contract'.`
|
@@ -2823,10 +2803,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2823
2803
|
return contractInput;
|
2824
2804
|
}
|
2825
2805
|
function getInputAccountAddress(input) {
|
2826
|
-
if (input.type ===
|
2806
|
+
if (input.type === InputType6.Coin) {
|
2827
2807
|
return input.owner.toString();
|
2828
2808
|
}
|
2829
|
-
if (input.type ===
|
2809
|
+
if (input.type === InputType6.Message) {
|
2830
2810
|
return input.recipient.toString();
|
2831
2811
|
}
|
2832
2812
|
return "";
|
@@ -3790,21 +3770,6 @@ var _Provider = class {
|
|
3790
3770
|
} = await this.operations.getVersion();
|
3791
3771
|
return nodeVersion;
|
3792
3772
|
}
|
3793
|
-
/**
|
3794
|
-
* @hidden
|
3795
|
-
*
|
3796
|
-
* Returns the network configuration of the connected Fuel node.
|
3797
|
-
*
|
3798
|
-
* @returns A promise that resolves to the network configuration object
|
3799
|
-
*/
|
3800
|
-
async getNetwork() {
|
3801
|
-
const {
|
3802
|
-
name,
|
3803
|
-
consensusParameters: { chainId }
|
3804
|
-
} = await this.getChain();
|
3805
|
-
const network = new Network(name, chainId.toNumber());
|
3806
|
-
return Promise.resolve(network);
|
3807
|
-
}
|
3808
3773
|
/**
|
3809
3774
|
* Returns the block number.
|
3810
3775
|
*
|
@@ -4663,7 +4628,7 @@ cacheInputs_fn = function(inputs) {
|
|
4663
4628
|
return;
|
4664
4629
|
}
|
4665
4630
|
inputs.forEach((input) => {
|
4666
|
-
if (input.type ===
|
4631
|
+
if (input.type === InputType7.Coin) {
|
4667
4632
|
this.cache?.set(input.id);
|
4668
4633
|
}
|
4669
4634
|
});
|
@@ -8230,21 +8195,16 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
8230
8195
|
|
8231
8196
|
// src/test-utils/seedTestWallet.ts
|
8232
8197
|
import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
|
8233
|
-
var seedTestWallet = async (wallet, quantities
|
8234
|
-
const toFundAccounts = Array.isArray(wallet) ? wallet : [wallet];
|
8198
|
+
var seedTestWallet = async (wallet, quantities) => {
|
8235
8199
|
const genesisWallet = new WalletUnlocked(
|
8236
8200
|
process.env.GENESIS_SECRET || randomBytes5(32),
|
8237
|
-
|
8238
|
-
toFundAccounts[0].provider
|
8201
|
+
wallet.provider
|
8239
8202
|
);
|
8240
8203
|
const request = new ScriptTransactionRequest();
|
8241
|
-
quantities.
|
8242
|
-
|
8243
|
-
|
8244
|
-
|
8245
|
-
}
|
8246
|
-
})
|
8247
|
-
);
|
8204
|
+
quantities.forEach((quantity) => {
|
8205
|
+
const { amount, assetId } = coinQuantityfy(quantity);
|
8206
|
+
request.addCoinOutput(wallet.address, amount, assetId);
|
8207
|
+
});
|
8248
8208
|
const txCost = await genesisWallet.provider.getTransactionCost(request);
|
8249
8209
|
request.gasLimit = txCost.gasUsed;
|
8250
8210
|
request.maxFee = txCost.maxFee;
|
@@ -8466,44 +8426,7 @@ var launchNodeAndGetWallets = async ({
|
|
8466
8426
|
};
|
8467
8427
|
return { wallets, stop: cleanup, provider };
|
8468
8428
|
};
|
8469
|
-
|
8470
|
-
// src/test-utils/transactionRequest.ts
|
8471
|
-
import { UTXO_ID_LEN as UTXO_ID_LEN4 } from "@fuel-ts/abi-coder";
|
8472
|
-
import { getRandomB256 } from "@fuel-ts/address";
|
8473
|
-
import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
|
8474
|
-
import { randomBytes as randomBytes7 } from "@fuel-ts/crypto";
|
8475
|
-
import { bn as bn20 } from "@fuel-ts/math";
|
8476
|
-
import { InputType as InputType9 } from "@fuel-ts/transactions";
|
8477
|
-
import { hexlify as hexlify19 } from "@fuel-ts/utils";
|
8478
|
-
var generateFakeRequestInputCoin = (partial = {}) => ({
|
8479
|
-
id: hexlify19(randomBytes7(UTXO_ID_LEN4)),
|
8480
|
-
type: InputType9.Coin,
|
8481
|
-
owner: getRandomB256(),
|
8482
|
-
amount: bn20(100),
|
8483
|
-
assetId: ZeroBytes329,
|
8484
|
-
txPointer: "0x00000000000000000000000000000000",
|
8485
|
-
witnessIndex: 0,
|
8486
|
-
...partial
|
8487
|
-
});
|
8488
|
-
var generateFakeRequestInputMessage = (partial = {}) => ({
|
8489
|
-
nonce: getRandomB256(),
|
8490
|
-
type: InputType9.Message,
|
8491
|
-
sender: getRandomB256(),
|
8492
|
-
recipient: getRandomB256(),
|
8493
|
-
amount: bn20(100),
|
8494
|
-
witnessIndex: 0,
|
8495
|
-
...partial
|
8496
|
-
});
|
8497
|
-
var generateFakeRequestInputContract = (partial = {}) => ({
|
8498
|
-
contractId: getRandomB256(),
|
8499
|
-
type: InputType9.Contract,
|
8500
|
-
txPointer: "0x00000000000000000000000000000000",
|
8501
|
-
...partial
|
8502
|
-
});
|
8503
8429
|
export {
|
8504
|
-
generateFakeRequestInputCoin,
|
8505
|
-
generateFakeRequestInputContract,
|
8506
|
-
generateFakeRequestInputMessage,
|
8507
8430
|
generateTestWallet,
|
8508
8431
|
killNode,
|
8509
8432
|
launchNode,
|