@fuel-ts/account 0.0.0-rc-1976-20240424151753 → 0.0.0-rc-2143-20240424152333
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/README.md +2 -2
- package/dist/account.d.ts.map +1 -1
- package/dist/index.global.js +41 -57
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +79 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -55
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +2 -2
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +0 -7
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +5 -5
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/utils/merge-quantities.d.ts +1 -1
- package/dist/providers/utils/merge-quantities.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.global.js +44 -60
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +81 -95
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +43 -57
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +15 -15
package/README.md
CHANGED
@@ -44,14 +44,14 @@ These test utilities are exported to assist in testing apps using Fuels.
|
|
44
44
|
|
45
45
|
```ts
|
46
46
|
import { bn } from "@fuel-ts/math";
|
47
|
+
import { BaseAssetId } from "fuels";
|
47
48
|
import { seedTestWallet, generateTestWallet } from "@account/test-utils";
|
48
49
|
|
49
50
|
const provider = await Provider.create("http://127.0.0.1:4000/graphql");
|
50
51
|
|
51
52
|
// seeding
|
52
53
|
const wallet = Wallet.fromPrivateKey("0x...", provider);
|
53
|
-
|
54
|
-
seedTestWallet(wallet, [{ assetId: baseAssetId, amount: bn(100_000) }]);
|
54
|
+
seedTestWallet(wallet, [{ assetId: BaseAssetId, amount: bn(100_000) }]);
|
55
55
|
|
56
56
|
// generating
|
57
57
|
const wallet = await generateTestWallet(provider, [[1_000, BaseAssetId]]);
|
package/dist/account.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"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"}
|
package/dist/index.global.js
CHANGED
@@ -31271,6 +31271,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31271
31271
|
}
|
31272
31272
|
};
|
31273
31273
|
|
31274
|
+
// ../address/dist/configs.mjs
|
31275
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
31276
|
+
var BaseAssetId = ZeroBytes32;
|
31277
|
+
|
31274
31278
|
// ../math/dist/index.mjs
|
31275
31279
|
var import_bn = __toESM(require_bn(), 1);
|
31276
31280
|
var DEFAULT_PRECISION = 9;
|
@@ -31501,11 +31505,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31501
31505
|
let max2;
|
31502
31506
|
if (Array.isArray(coinQuantityLike)) {
|
31503
31507
|
amount = coinQuantityLike[0];
|
31504
|
-
assetId = coinQuantityLike[1];
|
31505
|
-
max2 = coinQuantityLike[2];
|
31508
|
+
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
31509
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
31506
31510
|
} else {
|
31507
31511
|
amount = coinQuantityLike.amount;
|
31508
|
-
assetId = coinQuantityLike.assetId;
|
31512
|
+
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
31509
31513
|
max2 = coinQuantityLike.max ?? void 0;
|
31510
31514
|
}
|
31511
31515
|
const bnAmount = bn(amount);
|
@@ -38884,9 +38888,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38884
38888
|
}
|
38885
38889
|
};
|
38886
38890
|
|
38887
|
-
// ../address/dist/configs.mjs
|
38888
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38889
|
-
|
38890
38891
|
// src/providers/transaction-request/input.ts
|
38891
38892
|
var inputify = (value) => {
|
38892
38893
|
const { type: type3 } = value;
|
@@ -39803,13 +39804,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39803
39804
|
}
|
39804
39805
|
/**
|
39805
39806
|
* Adds a single message input to the transaction and a change output for the
|
39806
|
-
*
|
39807
|
+
* baseAssetId, if one it was not added yet.
|
39807
39808
|
*
|
39808
39809
|
* @param message - Message resource.
|
39809
39810
|
* @param predicate - Predicate bytes.
|
39811
|
+
* @param predicateData - Predicate data bytes.
|
39810
39812
|
*/
|
39811
39813
|
addMessageInput(message, predicate) {
|
39812
|
-
const { recipient, sender, amount
|
39814
|
+
const { recipient, sender, amount } = message;
|
39815
|
+
const assetId = BaseAssetId;
|
39813
39816
|
let witnessIndex;
|
39814
39817
|
if (predicate) {
|
39815
39818
|
witnessIndex = 0;
|
@@ -39890,7 +39893,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39890
39893
|
* @param amount - Amount of coin.
|
39891
39894
|
* @param assetId - Asset ID of coin.
|
39892
39895
|
*/
|
39893
|
-
addCoinOutput(to, amount, assetId) {
|
39896
|
+
addCoinOutput(to, amount, assetId = BaseAssetId) {
|
39894
39897
|
this.pushOutput({
|
39895
39898
|
type: OutputType.Coin,
|
39896
39899
|
to: addressify(to).toB256(),
|
@@ -39922,7 +39925,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39922
39925
|
* @param to - Address of the owner.
|
39923
39926
|
* @param assetId - Asset ID of coin.
|
39924
39927
|
*/
|
39925
|
-
addChangeOutput(to, assetId) {
|
39928
|
+
addChangeOutput(to, assetId = BaseAssetId) {
|
39926
39929
|
const changeOutput = this.getChangeOutputs().find(
|
39927
39930
|
(output3) => hexlify(output3.assetId) === assetId
|
39928
39931
|
);
|
@@ -39979,9 +39982,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39979
39982
|
* quantities array.
|
39980
39983
|
*
|
39981
39984
|
* @param quantities - CoinQuantity Array.
|
39982
|
-
* @param baseAssetId - The base asset to fund the transaction.
|
39983
39985
|
*/
|
39984
|
-
fundWithFakeUtxos(quantities,
|
39986
|
+
fundWithFakeUtxos(quantities, resourcesOwner) {
|
39985
39987
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
39986
39988
|
if ("assetId" in input) {
|
39987
39989
|
return input.assetId === assetId;
|
@@ -40007,7 +40009,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40007
40009
|
]);
|
40008
40010
|
}
|
40009
40011
|
};
|
40010
|
-
updateAssetInput(
|
40012
|
+
updateAssetInput(BaseAssetId, bn(1e11));
|
40011
40013
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
40012
40014
|
}
|
40013
40015
|
/**
|
@@ -40164,7 +40166,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40164
40166
|
*
|
40165
40167
|
* @param createTransactionRequestLike - The initial values for the instance
|
40166
40168
|
*/
|
40167
|
-
constructor({
|
40169
|
+
constructor({
|
40170
|
+
bytecodeWitnessIndex,
|
40171
|
+
salt,
|
40172
|
+
storageSlots,
|
40173
|
+
...rest
|
40174
|
+
} = {}) {
|
40168
40175
|
super(rest);
|
40169
40176
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
40170
40177
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -41387,7 +41394,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41387
41394
|
}
|
41388
41395
|
|
41389
41396
|
// src/providers/utils/merge-quantities.ts
|
41390
|
-
var mergeQuantities = (
|
41397
|
+
var mergeQuantities = (arr1, arr2) => {
|
41391
41398
|
const resultMap = {};
|
41392
41399
|
function addToMap({ amount, assetId }) {
|
41393
41400
|
if (resultMap[assetId]) {
|
@@ -41396,7 +41403,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41396
41403
|
resultMap[assetId] = amount;
|
41397
41404
|
}
|
41398
41405
|
}
|
41399
|
-
|
41406
|
+
arr1.forEach(addToMap);
|
41407
|
+
arr2.forEach(addToMap);
|
41400
41408
|
return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
|
41401
41409
|
};
|
41402
41410
|
|
@@ -41424,7 +41432,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41424
41432
|
gasPerByte: bn(feeParams.gasPerByte),
|
41425
41433
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41426
41434
|
chainId: bn(consensusParameters.chainId),
|
41427
|
-
baseAssetId: consensusParameters.baseAssetId,
|
41428
41435
|
gasCosts
|
41429
41436
|
},
|
41430
41437
|
gasCosts,
|
@@ -41667,17 +41674,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41667
41674
|
} = this.getChain();
|
41668
41675
|
return chainId.toNumber();
|
41669
41676
|
}
|
41670
|
-
/**
|
41671
|
-
* Returns the base asset ID
|
41672
|
-
*
|
41673
|
-
* @returns A promise that resolves to the base asset ID
|
41674
|
-
*/
|
41675
|
-
getBaseAssetId() {
|
41676
|
-
const {
|
41677
|
-
consensusParameters: { baseAssetId }
|
41678
|
-
} = this.getChain();
|
41679
|
-
return baseAssetId;
|
41680
|
-
}
|
41681
41677
|
/**
|
41682
41678
|
* Submits a transaction to the chain to be executed.
|
41683
41679
|
*
|
@@ -41908,10 +41904,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41908
41904
|
const { minGasPrice } = this.getGasConfig();
|
41909
41905
|
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
41910
41906
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
41911
|
-
const baseAssetId = this.getBaseAssetId();
|
41912
41907
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
41913
41908
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
41914
|
-
txRequestClone.fundWithFakeUtxos(allQuantities,
|
41909
|
+
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
41915
41910
|
if (isScriptTransaction) {
|
41916
41911
|
txRequestClone.gasLimit = bn(0);
|
41917
41912
|
}
|
@@ -42735,9 +42730,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42735
42730
|
* @param assetId - The asset ID to check the balance for.
|
42736
42731
|
* @returns A promise that resolves to the balance amount.
|
42737
42732
|
*/
|
42738
|
-
async getBalance(assetId) {
|
42739
|
-
const
|
42740
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42733
|
+
async getBalance(assetId = BaseAssetId) {
|
42734
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
42741
42735
|
return amount;
|
42742
42736
|
}
|
42743
42737
|
/**
|
@@ -42775,10 +42769,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42775
42769
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42776
42770
|
*/
|
42777
42771
|
async fund(request, coinQuantities, fee) {
|
42778
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
42779
42772
|
const updatedQuantities = addAmountToAsset({
|
42780
42773
|
amount: bn(fee),
|
42781
|
-
assetId:
|
42774
|
+
assetId: BaseAssetId,
|
42782
42775
|
coinQuantities
|
42783
42776
|
});
|
42784
42777
|
const quantitiesDict = {};
|
@@ -42802,8 +42795,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42802
42795
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42803
42796
|
cachedUtxos.push(input.id);
|
42804
42797
|
}
|
42805
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
42806
|
-
quantitiesDict[
|
42798
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
|
42799
|
+
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
42807
42800
|
cachedMessages.push(input.nonce);
|
42808
42801
|
}
|
42809
42802
|
}
|
@@ -42835,12 +42828,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42835
42828
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42836
42829
|
* @returns A promise that resolves to the prepared transaction request.
|
42837
42830
|
*/
|
42838
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42831
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
42839
42832
|
const { minGasPrice } = this.provider.getGasConfig();
|
42840
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42841
42833
|
const params = { gasPrice: minGasPrice, ...txParams };
|
42842
42834
|
const request = new ScriptTransactionRequest(params);
|
42843
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
42835
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
42844
42836
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
42845
42837
|
estimateTxDependencies: true,
|
42846
42838
|
resourcesOwner: this
|
@@ -42866,15 +42858,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42866
42858
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42867
42859
|
* @returns A promise that resolves to the transaction response.
|
42868
42860
|
*/
|
42869
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
42861
|
+
async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
42870
42862
|
if (bn(amount).lte(0)) {
|
42871
42863
|
throw new FuelError(
|
42872
42864
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42873
42865
|
"Transfer amount must be a positive number."
|
42874
42866
|
);
|
42875
42867
|
}
|
42876
|
-
const
|
42877
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
42868
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
42878
42869
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42879
42870
|
}
|
42880
42871
|
/**
|
@@ -42886,7 +42877,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42886
42877
|
* @param txParams - The optional transaction parameters.
|
42887
42878
|
* @returns A promise that resolves to the transaction response.
|
42888
42879
|
*/
|
42889
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
42880
|
+
async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
|
42890
42881
|
if (bn(amount).lte(0)) {
|
42891
42882
|
throw new FuelError(
|
42892
42883
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42895,12 +42886,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42895
42886
|
}
|
42896
42887
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42897
42888
|
const { minGasPrice } = this.provider.getGasConfig();
|
42898
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42899
42889
|
const params = { gasPrice: minGasPrice, ...txParams };
|
42900
42890
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42901
42891
|
hexlifiedContractId: contractAddress.toB256(),
|
42902
42892
|
amountToTransfer: bn(amount),
|
42903
|
-
assetId
|
42893
|
+
assetId
|
42904
42894
|
});
|
42905
42895
|
const request = new ScriptTransactionRequest({
|
42906
42896
|
...params,
|
@@ -42910,7 +42900,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42910
42900
|
request.addContractInputAndOutput(contractAddress);
|
42911
42901
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42912
42902
|
request,
|
42913
|
-
[{ amount: bn(amount), assetId: String(
|
42903
|
+
[{ amount: bn(amount), assetId: String(assetId) }]
|
42914
42904
|
);
|
42915
42905
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42916
42906
|
this.validateGas({
|
@@ -42932,7 +42922,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42932
42922
|
*/
|
42933
42923
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42934
42924
|
const { minGasPrice } = this.provider.getGasConfig();
|
42935
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
42936
42925
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42937
42926
|
const recipientDataArray = arrayify(
|
42938
42927
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42945,13 +42934,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42945
42934
|
...recipientDataArray,
|
42946
42935
|
...amountDataArray
|
42947
42936
|
]);
|
42948
|
-
const params = {
|
42949
|
-
script,
|
42950
|
-
gasPrice: minGasPrice,
|
42951
|
-
...txParams
|
42952
|
-
};
|
42937
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
42953
42938
|
const request = new ScriptTransactionRequest(params);
|
42954
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
42939
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
|
42955
42940
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42956
42941
|
request,
|
42957
42942
|
forwardingQuantities
|
@@ -47914,9 +47899,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47914
47899
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47915
47900
|
* @returns A promise that resolves to the prepared transaction request.
|
47916
47901
|
*/
|
47917
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
47918
|
-
const
|
47919
|
-
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
47902
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
47903
|
+
const request = await super.createTransfer(destination, amount, assetId, txParams);
|
47920
47904
|
return this.populateTransactionPredicateData(request);
|
47921
47905
|
}
|
47922
47906
|
/**
|