@fuel-ts/account 0.0.0-rc-2040-20240411104812 → 0.0.0-rc-2034-20240411105200
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 +56 -35
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +94 -70
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -36
- package/dist/index.mjs.map +1 -1
- package/dist/providers/provider.d.ts +13 -2
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/test-utils.global.js +58 -37
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +91 -67
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +62 -38
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
package/dist/index.global.js
CHANGED
@@ -31605,6 +31605,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31605
31605
|
var ENCODING_V1 = "1";
|
31606
31606
|
var WORD_SIZE = 8;
|
31607
31607
|
var BYTES_32 = 32;
|
31608
|
+
var UTXO_ID_LEN = BYTES_32 + 1;
|
31608
31609
|
var ASSET_ID_LEN = BYTES_32;
|
31609
31610
|
var ADDRESS_LEN = BYTES_32;
|
31610
31611
|
var NONCE_LEN = BYTES_32;
|
@@ -33301,8 +33302,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33301
33302
|
}
|
33302
33303
|
return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
|
33303
33304
|
isRightPadded: true,
|
33304
|
-
|
33305
|
-
encoding: ENCODING_V0
|
33305
|
+
encoding: this.jsonAbi.encoding
|
33306
33306
|
});
|
33307
33307
|
}
|
33308
33308
|
getTypeById(typeId) {
|
@@ -38873,8 +38873,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38873
38873
|
const predicateData = arrayify(value.predicateData ?? "0x");
|
38874
38874
|
return {
|
38875
38875
|
type: InputType.Coin,
|
38876
|
-
txID: hexlify(arrayify(value.id).slice(0,
|
38877
|
-
outputIndex: arrayify(value.id)
|
38876
|
+
txID: hexlify(arrayify(value.id).slice(0, BYTES_32)),
|
38877
|
+
outputIndex: toNumber2(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
|
38878
38878
|
owner: hexlify(value.owner),
|
38879
38879
|
amount: bn(value.amount),
|
38880
38880
|
assetId: hexlify(value.assetId),
|
@@ -39960,12 +39960,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39960
39960
|
* @param quantities - CoinQuantity Array.
|
39961
39961
|
*/
|
39962
39962
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
39963
|
-
let idCounter = 0;
|
39964
|
-
const generateId = () => {
|
39965
|
-
const counterString = String(idCounter++);
|
39966
|
-
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
39967
|
-
return id;
|
39968
|
-
};
|
39969
39963
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
39970
39964
|
if ("assetId" in input) {
|
39971
39965
|
return input.assetId === assetId;
|
@@ -39975,12 +39969,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39975
39969
|
const updateAssetInput = (assetId, quantity) => {
|
39976
39970
|
const assetInput = findAssetInput(assetId);
|
39977
39971
|
if (assetInput && "assetId" in assetInput) {
|
39978
|
-
assetInput.id =
|
39972
|
+
assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
|
39979
39973
|
assetInput.amount = quantity;
|
39980
39974
|
} else {
|
39981
39975
|
this.addResources([
|
39982
39976
|
{
|
39983
|
-
id:
|
39977
|
+
id: hexlify(randomBytes22(UTXO_ID_LEN)),
|
39984
39978
|
amount: quantity,
|
39985
39979
|
assetId,
|
39986
39980
|
owner: resourcesOwner || Address.fromRandom(),
|
@@ -41806,6 +41800,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41806
41800
|
missingContractIds
|
41807
41801
|
};
|
41808
41802
|
}
|
41803
|
+
/**
|
41804
|
+
* Estimates the transaction gas and fee based on the provided transaction request.
|
41805
|
+
* @param transactionRequest - The transaction request object.
|
41806
|
+
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
41807
|
+
*/
|
41808
|
+
estimateTxGasAndFee(params) {
|
41809
|
+
const { transactionRequest } = params;
|
41810
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
41811
|
+
const chainInfo = this.getChain();
|
41812
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
41813
|
+
transactionRequest.gasPrice = gasPrice;
|
41814
|
+
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
41815
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41816
|
+
if (transactionRequest.type === TransactionType.Script) {
|
41817
|
+
if (transactionRequest.gasLimit.eq(0)) {
|
41818
|
+
transactionRequest.gasLimit = minGas;
|
41819
|
+
transactionRequest.gasLimit = maxGasPerTx.sub(
|
41820
|
+
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
41821
|
+
);
|
41822
|
+
}
|
41823
|
+
}
|
41824
|
+
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
41825
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41826
|
+
return {
|
41827
|
+
minGas,
|
41828
|
+
minFee,
|
41829
|
+
maxGas,
|
41830
|
+
maxFee
|
41831
|
+
};
|
41832
|
+
}
|
41809
41833
|
/**
|
41810
41834
|
* Executes a signed transaction without applying the states changes
|
41811
41835
|
* on the chain.
|
@@ -41853,17 +41877,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41853
41877
|
signatureCallback
|
41854
41878
|
} = {}) {
|
41855
41879
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
41856
|
-
const
|
41857
|
-
const
|
41858
|
-
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
41880
|
+
const { minGasPrice } = this.getGasConfig();
|
41881
|
+
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
41859
41882
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
41860
41883
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
41861
41884
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
41862
41885
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
41886
|
+
if (isScriptTransaction) {
|
41887
|
+
txRequestClone.gasLimit = bn(0);
|
41888
|
+
}
|
41863
41889
|
if (estimatePredicates) {
|
41864
|
-
if (isScriptTransaction) {
|
41865
|
-
txRequestClone.gasLimit = bn(0);
|
41866
|
-
}
|
41867
41890
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
41868
41891
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41869
41892
|
}
|
@@ -41872,36 +41895,34 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41872
41895
|
if (signatureCallback && isScriptTransaction) {
|
41873
41896
|
await signatureCallback(txRequestClone);
|
41874
41897
|
}
|
41875
|
-
|
41876
|
-
|
41898
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
41899
|
+
transactionRequest: txRequestClone
|
41900
|
+
});
|
41877
41901
|
let receipts = [];
|
41878
41902
|
let missingContractIds = [];
|
41879
41903
|
let outputVariables = 0;
|
41904
|
+
let gasUsed = bn(0);
|
41880
41905
|
if (isScriptTransaction && estimateTxDependencies) {
|
41881
41906
|
txRequestClone.gasPrice = bn(0);
|
41882
|
-
txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
41883
41907
|
const result = await this.estimateTxDependencies(txRequestClone);
|
41884
41908
|
receipts = result.receipts;
|
41885
41909
|
outputVariables = result.outputVariables;
|
41886
41910
|
missingContractIds = result.missingContractIds;
|
41911
|
+
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
41912
|
+
txRequestClone.gasLimit = gasUsed;
|
41913
|
+
txRequestClone.gasPrice = setGasPrice;
|
41914
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
41915
|
+
transactionRequest: txRequestClone
|
41916
|
+
}));
|
41887
41917
|
}
|
41888
|
-
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
41889
|
-
const usedFee = calculatePriceWithFactor(
|
41890
|
-
gasUsed,
|
41891
|
-
gasPrice,
|
41892
|
-
gasPriceFactor
|
41893
|
-
).normalizeZeroToOne();
|
41894
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41895
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41896
41918
|
return {
|
41897
41919
|
requiredQuantities: allQuantities,
|
41898
41920
|
receipts,
|
41899
41921
|
gasUsed,
|
41900
41922
|
minGasPrice,
|
41901
|
-
gasPrice,
|
41923
|
+
gasPrice: setGasPrice,
|
41902
41924
|
minGas,
|
41903
41925
|
maxGas,
|
41904
|
-
usedFee,
|
41905
41926
|
minFee,
|
41906
41927
|
maxFee,
|
41907
41928
|
estimatedInputs: txRequestClone.inputs,
|
@@ -44355,12 +44376,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44355
44376
|
};
|
44356
44377
|
|
44357
44378
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
44358
|
-
var
|
44379
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
44359
44380
|
var rnds8Pool = new Uint8Array(256);
|
44360
44381
|
var poolPtr = rnds8Pool.length;
|
44361
44382
|
function rng() {
|
44362
44383
|
if (poolPtr > rnds8Pool.length - 16) {
|
44363
|
-
|
44384
|
+
import_crypto16.default.randomFillSync(rnds8Pool);
|
44364
44385
|
poolPtr = 0;
|
44365
44386
|
}
|
44366
44387
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -44376,9 +44397,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44376
44397
|
}
|
44377
44398
|
|
44378
44399
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
44379
|
-
var
|
44400
|
+
var import_crypto17 = __toESM(__require("crypto"));
|
44380
44401
|
var native_default = {
|
44381
|
-
randomUUID:
|
44402
|
+
randomUUID: import_crypto17.default.randomUUID
|
44382
44403
|
};
|
44383
44404
|
|
44384
44405
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|