@fuel-ts/account 0.0.0-rc-2037-20240430094729 → 0.0.0-rc-2143-20240430130957
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 +8 -69
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +118 -192
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -107
- 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 +1 -1
- 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/launchNode.d.ts +4 -2
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/seedTestWallet.d.ts +1 -1
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils.global.js +14 -63
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +117 -180
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +44 -104
- 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
|
@@ -1244,7 +1244,7 @@ import { bn as bn7 } from "@fuel-ts/math";
|
|
1244
1244
|
import {
|
1245
1245
|
PolicyType,
|
1246
1246
|
TransactionCoder,
|
1247
|
-
InputType as
|
1247
|
+
InputType as InputType2,
|
1248
1248
|
OutputType as OutputType2,
|
1249
1249
|
TransactionType
|
1250
1250
|
} from "@fuel-ts/transactions";
|
@@ -1694,12 +1694,6 @@ var NoWitnessAtIndexError = class extends Error {
|
|
1694
1694
|
name = "NoWitnessAtIndexError";
|
1695
1695
|
};
|
1696
1696
|
|
1697
|
-
// src/providers/transaction-request/helpers.ts
|
1698
|
-
import { InputType as InputType2 } from "@fuel-ts/transactions";
|
1699
|
-
var isRequestInputCoin = (input) => input.type === InputType2.Coin;
|
1700
|
-
var isRequestInputMessage = (input) => input.type === InputType2.Message;
|
1701
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
1702
|
-
|
1703
1697
|
// src/providers/transaction-request/witness.ts
|
1704
1698
|
import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
|
1705
1699
|
var witnessify = (value) => {
|
@@ -1890,7 +1884,7 @@ var BaseTransactionRequest = class {
|
|
1890
1884
|
*/
|
1891
1885
|
getCoinInputs() {
|
1892
1886
|
return this.inputs.filter(
|
1893
|
-
(input) => input.type ===
|
1887
|
+
(input) => input.type === InputType2.Coin
|
1894
1888
|
);
|
1895
1889
|
}
|
1896
1890
|
/**
|
@@ -1922,9 +1916,9 @@ var BaseTransactionRequest = class {
|
|
1922
1916
|
const ownerAddress = addressify(owner);
|
1923
1917
|
const found = this.inputs.find((input) => {
|
1924
1918
|
switch (input.type) {
|
1925
|
-
case
|
1919
|
+
case InputType2.Coin:
|
1926
1920
|
return hexlify7(input.owner) === ownerAddress.toB256();
|
1927
|
-
case
|
1921
|
+
case InputType2.Message:
|
1928
1922
|
return hexlify7(input.recipient) === ownerAddress.toB256();
|
1929
1923
|
default:
|
1930
1924
|
return false;
|
@@ -1939,7 +1933,7 @@ var BaseTransactionRequest = class {
|
|
1939
1933
|
* @param coin - Coin resource.
|
1940
1934
|
*/
|
1941
1935
|
addCoinInput(coin) {
|
1942
|
-
const { assetId, owner, amount
|
1936
|
+
const { assetId, owner, amount } = coin;
|
1943
1937
|
let witnessIndex;
|
1944
1938
|
if (coin.predicate) {
|
1945
1939
|
witnessIndex = 0;
|
@@ -1950,14 +1944,13 @@ var BaseTransactionRequest = class {
|
|
1950
1944
|
}
|
1951
1945
|
}
|
1952
1946
|
const input = {
|
1953
|
-
|
1954
|
-
type:
|
1947
|
+
...coin,
|
1948
|
+
type: InputType2.Coin,
|
1955
1949
|
owner: owner.toB256(),
|
1956
1950
|
amount,
|
1957
1951
|
assetId,
|
1958
1952
|
txPointer: "0x00000000000000000000000000000000",
|
1959
|
-
witnessIndex
|
1960
|
-
predicate
|
1953
|
+
witnessIndex
|
1961
1954
|
};
|
1962
1955
|
this.pushInput(input);
|
1963
1956
|
this.addChangeOutput(owner, assetId);
|
@@ -1969,7 +1962,7 @@ var BaseTransactionRequest = class {
|
|
1969
1962
|
* @param message - Message resource.
|
1970
1963
|
*/
|
1971
1964
|
addMessageInput(message) {
|
1972
|
-
const { recipient, sender, amount,
|
1965
|
+
const { recipient, sender, amount, assetId } = message;
|
1973
1966
|
let witnessIndex;
|
1974
1967
|
if (message.predicate) {
|
1975
1968
|
witnessIndex = 0;
|
@@ -1980,13 +1973,12 @@ var BaseTransactionRequest = class {
|
|
1980
1973
|
}
|
1981
1974
|
}
|
1982
1975
|
const input = {
|
1983
|
-
|
1984
|
-
type:
|
1976
|
+
...message,
|
1977
|
+
type: InputType2.Message,
|
1985
1978
|
sender: sender.toB256(),
|
1986
1979
|
recipient: recipient.toB256(),
|
1987
1980
|
amount,
|
1988
|
-
witnessIndex
|
1989
|
-
predicate
|
1981
|
+
witnessIndex
|
1990
1982
|
};
|
1991
1983
|
this.pushInput(input);
|
1992
1984
|
this.addChangeOutput(recipient, assetId);
|
@@ -2170,27 +2162,16 @@ var BaseTransactionRequest = class {
|
|
2170
2162
|
toJSON() {
|
2171
2163
|
return normalizeJSON(this);
|
2172
2164
|
}
|
2173
|
-
removeWitness(index) {
|
2174
|
-
this.witnesses.splice(index, 1);
|
2175
|
-
this.adjustWitnessIndexes(index);
|
2176
|
-
}
|
2177
|
-
adjustWitnessIndexes(removedIndex) {
|
2178
|
-
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
2179
|
-
if (input.witnessIndex > removedIndex) {
|
2180
|
-
input.witnessIndex -= 1;
|
2181
|
-
}
|
2182
|
-
});
|
2183
|
-
}
|
2184
2165
|
updatePredicateGasUsed(inputs) {
|
2185
2166
|
this.inputs.forEach((i) => {
|
2186
2167
|
let correspondingInput;
|
2187
2168
|
switch (i.type) {
|
2188
|
-
case
|
2189
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2169
|
+
case InputType2.Coin:
|
2170
|
+
correspondingInput = inputs.find((x) => x.type === InputType2.Coin && x.owner === i.owner);
|
2190
2171
|
break;
|
2191
|
-
case
|
2172
|
+
case InputType2.Message:
|
2192
2173
|
correspondingInput = inputs.find(
|
2193
|
-
(x) => x.type ===
|
2174
|
+
(x) => x.type === InputType2.Message && x.sender === i.sender
|
2194
2175
|
);
|
2195
2176
|
break;
|
2196
2177
|
default:
|
@@ -2224,7 +2205,7 @@ import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
|
2224
2205
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2225
2206
|
import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
|
2226
2207
|
import { bn as bn8 } from "@fuel-ts/math";
|
2227
|
-
import { TransactionType as TransactionType2, InputType as
|
2208
|
+
import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
|
2228
2209
|
import { concat as concat2 } from "@fuel-ts/utils";
|
2229
2210
|
import { clone as clone2 } from "ramda";
|
2230
2211
|
function hashTransaction(transactionRequest, chainId) {
|
@@ -2235,7 +2216,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2235
2216
|
transaction.inputs = transaction.inputs.map((input) => {
|
2236
2217
|
const inputClone = clone2(input);
|
2237
2218
|
switch (inputClone.type) {
|
2238
|
-
case
|
2219
|
+
case InputType3.Coin: {
|
2239
2220
|
inputClone.txPointer = {
|
2240
2221
|
blockHeight: 0,
|
2241
2222
|
txIndex: 0
|
@@ -2243,11 +2224,11 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2243
2224
|
inputClone.predicateGasUsed = bn8(0);
|
2244
2225
|
return inputClone;
|
2245
2226
|
}
|
2246
|
-
case
|
2227
|
+
case InputType3.Message: {
|
2247
2228
|
inputClone.predicateGasUsed = bn8(0);
|
2248
2229
|
return inputClone;
|
2249
2230
|
}
|
2250
|
-
case
|
2231
|
+
case InputType3.Contract: {
|
2251
2232
|
inputClone.txPointer = {
|
2252
2233
|
blockHeight: 0,
|
2253
2234
|
txIndex: 0
|
@@ -2407,7 +2388,7 @@ import { Interface } from "@fuel-ts/abi-coder";
|
|
2407
2388
|
import { addressify as addressify2 } from "@fuel-ts/address";
|
2408
2389
|
import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
2409
2390
|
import { bn as bn10 } from "@fuel-ts/math";
|
2410
|
-
import { InputType as
|
2391
|
+
import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
2411
2392
|
import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
|
2412
2393
|
|
2413
2394
|
// src/providers/transaction-request/scripts.ts
|
@@ -2491,7 +2472,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2491
2472
|
*/
|
2492
2473
|
getContractInputs() {
|
2493
2474
|
return this.inputs.filter(
|
2494
|
-
(input) => input.type ===
|
2475
|
+
(input) => input.type === InputType4.Contract
|
2495
2476
|
);
|
2496
2477
|
}
|
2497
2478
|
/**
|
@@ -2568,7 +2549,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2568
2549
|
return this;
|
2569
2550
|
}
|
2570
2551
|
const inputIndex = super.pushInput({
|
2571
|
-
type:
|
2552
|
+
type: InputType4.Contract,
|
2572
2553
|
contractId: contractAddress.toB256(),
|
2573
2554
|
txPointer: "0x00000000000000000000000000000000"
|
2574
2555
|
});
|
@@ -2610,7 +2591,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2610
2591
|
|
2611
2592
|
// src/providers/transaction-request/utils.ts
|
2612
2593
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2613
|
-
import { TransactionType as TransactionType5, InputType as
|
2594
|
+
import { TransactionType as TransactionType5, InputType as InputType5 } from "@fuel-ts/transactions";
|
2614
2595
|
var transactionRequestify = (obj) => {
|
2615
2596
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2616
2597
|
return obj;
|
@@ -2630,10 +2611,10 @@ var transactionRequestify = (obj) => {
|
|
2630
2611
|
};
|
2631
2612
|
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2632
2613
|
(acc, input) => {
|
2633
|
-
if (input.type ===
|
2614
|
+
if (input.type === InputType5.Coin && input.owner === owner) {
|
2634
2615
|
acc.utxos.push(input.id);
|
2635
2616
|
}
|
2636
|
-
if (input.type ===
|
2617
|
+
if (input.type === InputType5.Message && input.recipient === owner) {
|
2637
2618
|
acc.messages.push(input.nonce);
|
2638
2619
|
}
|
2639
2620
|
return acc;
|
@@ -2787,7 +2768,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2787
2768
|
|
2788
2769
|
// src/providers/transaction-summary/input.ts
|
2789
2770
|
import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2790
|
-
import { InputType as
|
2771
|
+
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
2791
2772
|
function getInputsByTypes(inputs, types) {
|
2792
2773
|
return inputs.filter((i) => types.includes(i.type));
|
2793
2774
|
}
|
@@ -2795,16 +2776,16 @@ function getInputsByType(inputs, type) {
|
|
2795
2776
|
return inputs.filter((i) => i.type === type);
|
2796
2777
|
}
|
2797
2778
|
function getInputsCoin(inputs) {
|
2798
|
-
return getInputsByType(inputs,
|
2779
|
+
return getInputsByType(inputs, InputType6.Coin);
|
2799
2780
|
}
|
2800
2781
|
function getInputsMessage(inputs) {
|
2801
|
-
return getInputsByType(inputs,
|
2782
|
+
return getInputsByType(inputs, InputType6.Message);
|
2802
2783
|
}
|
2803
2784
|
function getInputsCoinAndMessage(inputs) {
|
2804
|
-
return getInputsByTypes(inputs, [
|
2785
|
+
return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
|
2805
2786
|
}
|
2806
2787
|
function getInputsContract(inputs) {
|
2807
|
-
return getInputsByType(inputs,
|
2788
|
+
return getInputsByType(inputs, InputType6.Contract);
|
2808
2789
|
}
|
2809
2790
|
function getInputFromAssetId(inputs, assetId) {
|
2810
2791
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2823,7 +2804,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2823
2804
|
if (!contractInput) {
|
2824
2805
|
return void 0;
|
2825
2806
|
}
|
2826
|
-
if (contractInput.type !==
|
2807
|
+
if (contractInput.type !== InputType6.Contract) {
|
2827
2808
|
throw new FuelError9(
|
2828
2809
|
ErrorCode9.INVALID_TRANSACTION_INPUT,
|
2829
2810
|
`Contract input should be of type 'contract'.`
|
@@ -2832,10 +2813,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2832
2813
|
return contractInput;
|
2833
2814
|
}
|
2834
2815
|
function getInputAccountAddress(input) {
|
2835
|
-
if (input.type ===
|
2816
|
+
if (input.type === InputType6.Coin) {
|
2836
2817
|
return input.owner.toString();
|
2837
2818
|
}
|
2838
|
-
if (input.type ===
|
2819
|
+
if (input.type === InputType6.Message) {
|
2839
2820
|
return input.recipient.toString();
|
2840
2821
|
}
|
2841
2822
|
return "";
|
@@ -4670,7 +4651,7 @@ cacheInputs_fn = function(inputs) {
|
|
4670
4651
|
return;
|
4671
4652
|
}
|
4672
4653
|
inputs.forEach((input) => {
|
4673
|
-
if (input.type ===
|
4654
|
+
if (input.type === InputType7.Coin) {
|
4674
4655
|
this.cache?.set(input.id);
|
4675
4656
|
}
|
4676
4657
|
});
|
@@ -8237,21 +8218,16 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
8237
8218
|
|
8238
8219
|
// src/test-utils/seedTestWallet.ts
|
8239
8220
|
import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
|
8240
|
-
var seedTestWallet = async (wallet, quantities
|
8241
|
-
const toFundAccounts = Array.isArray(wallet) ? wallet : [wallet];
|
8221
|
+
var seedTestWallet = async (wallet, quantities) => {
|
8242
8222
|
const genesisWallet = new WalletUnlocked(
|
8243
8223
|
process.env.GENESIS_SECRET || randomBytes5(32),
|
8244
|
-
|
8245
|
-
toFundAccounts[0].provider
|
8224
|
+
wallet.provider
|
8246
8225
|
);
|
8247
8226
|
const request = new ScriptTransactionRequest();
|
8248
|
-
quantities.
|
8249
|
-
|
8250
|
-
|
8251
|
-
|
8252
|
-
}
|
8253
|
-
})
|
8254
|
-
);
|
8227
|
+
quantities.forEach((quantity) => {
|
8228
|
+
const { amount, assetId } = coinQuantityfy(quantity);
|
8229
|
+
request.addCoinOutput(wallet.address, amount, assetId);
|
8230
|
+
});
|
8255
8231
|
const txCost = await genesisWallet.provider.getTransactionCost(request);
|
8256
8232
|
request.gasLimit = txCost.gasUsed;
|
8257
8233
|
request.maxFee = txCost.maxFee;
|
@@ -8315,6 +8291,7 @@ var launchNode = async ({
|
|
8315
8291
|
ip,
|
8316
8292
|
port,
|
8317
8293
|
args = [],
|
8294
|
+
fuelCorePath = void 0,
|
8318
8295
|
useSystemFuelCore = false,
|
8319
8296
|
loggingEnabled = true,
|
8320
8297
|
debugEnabled = false,
|
@@ -8335,7 +8312,7 @@ var launchNode = async ({
|
|
8335
8312
|
const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
|
8336
8313
|
const poaInstant = poaInstantFlagValue === "true" || poaInstantFlagValue === void 0;
|
8337
8314
|
const graphQLStartSubstring = "Binding GraphQL provider to";
|
8338
|
-
const binPath = findBinPath("fuels-core", __dirname);
|
8315
|
+
const binPath = fuelCorePath ?? findBinPath("fuels-core", __dirname);
|
8339
8316
|
const command = useSystemFuelCore ? "fuel-core" : binPath;
|
8340
8317
|
const ipToUse = ip || "0.0.0.0";
|
8341
8318
|
const portToUse = port || (await getPortPromise({
|
@@ -8473,44 +8450,7 @@ var launchNodeAndGetWallets = async ({
|
|
8473
8450
|
};
|
8474
8451
|
return { wallets, stop: cleanup, provider };
|
8475
8452
|
};
|
8476
|
-
|
8477
|
-
// src/test-utils/transactionRequest.ts
|
8478
|
-
import { UTXO_ID_LEN as UTXO_ID_LEN4 } from "@fuel-ts/abi-coder";
|
8479
|
-
import { getRandomB256 } from "@fuel-ts/address";
|
8480
|
-
import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
|
8481
|
-
import { randomBytes as randomBytes7 } from "@fuel-ts/crypto";
|
8482
|
-
import { bn as bn20 } from "@fuel-ts/math";
|
8483
|
-
import { InputType as InputType9 } from "@fuel-ts/transactions";
|
8484
|
-
import { hexlify as hexlify19 } from "@fuel-ts/utils";
|
8485
|
-
var generateFakeRequestInputCoin = (partial = {}) => ({
|
8486
|
-
id: hexlify19(randomBytes7(UTXO_ID_LEN4)),
|
8487
|
-
type: InputType9.Coin,
|
8488
|
-
owner: getRandomB256(),
|
8489
|
-
amount: bn20(100),
|
8490
|
-
assetId: ZeroBytes329,
|
8491
|
-
txPointer: "0x00000000000000000000000000000000",
|
8492
|
-
witnessIndex: 0,
|
8493
|
-
...partial
|
8494
|
-
});
|
8495
|
-
var generateFakeRequestInputMessage = (partial = {}) => ({
|
8496
|
-
nonce: getRandomB256(),
|
8497
|
-
type: InputType9.Message,
|
8498
|
-
sender: getRandomB256(),
|
8499
|
-
recipient: getRandomB256(),
|
8500
|
-
amount: bn20(100),
|
8501
|
-
witnessIndex: 0,
|
8502
|
-
...partial
|
8503
|
-
});
|
8504
|
-
var generateFakeRequestInputContract = (partial = {}) => ({
|
8505
|
-
contractId: getRandomB256(),
|
8506
|
-
type: InputType9.Contract,
|
8507
|
-
txPointer: "0x00000000000000000000000000000000",
|
8508
|
-
...partial
|
8509
|
-
});
|
8510
8453
|
export {
|
8511
|
-
generateFakeRequestInputCoin,
|
8512
|
-
generateFakeRequestInputContract,
|
8513
|
-
generateFakeRequestInputMessage,
|
8514
8454
|
generateTestWallet,
|
8515
8455
|
killNode,
|
8516
8456
|
launchNode,
|