@fuel-ts/account 0.0.0-rc-2034-20240411020813 → 0.0.0-rc-2040-20240411095959
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 +43 -57
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +70 -94
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -60
- package/dist/index.mjs.map +1 -1
- package/dist/providers/provider.d.ts +2 -13
- 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 +45 -59
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +67 -91
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +38 -62
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
package/dist/index.global.js
CHANGED
@@ -31605,7 +31605,6 @@ 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;
|
31609
31608
|
var ASSET_ID_LEN = BYTES_32;
|
31610
31609
|
var ADDRESS_LEN = BYTES_32;
|
31611
31610
|
var NONCE_LEN = BYTES_32;
|
@@ -33230,6 +33229,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33230
33229
|
});
|
33231
33230
|
return coder.decode(bytes3, 0);
|
33232
33231
|
}
|
33232
|
+
/**
|
33233
|
+
* Checks if the function is read-only i.e. it only reads from storage, does not write to it.
|
33234
|
+
*
|
33235
|
+
* @returns True if the function is read-only or pure, false otherwise.
|
33236
|
+
*/
|
33237
|
+
isReadOnly() {
|
33238
|
+
const storageAttribute = this.attributes.find((attr) => attr.name === "storage");
|
33239
|
+
return !storageAttribute?.arguments.includes("write");
|
33240
|
+
}
|
33233
33241
|
};
|
33234
33242
|
var Interface = class {
|
33235
33243
|
functions;
|
@@ -33292,8 +33300,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33292
33300
|
);
|
33293
33301
|
}
|
33294
33302
|
return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
|
33295
|
-
isRightPadded: true
|
33296
|
-
encoding: this.jsonAbi.encoding
|
33303
|
+
isRightPadded: true
|
33297
33304
|
});
|
33298
33305
|
}
|
33299
33306
|
getTypeById(typeId) {
|
@@ -38864,8 +38871,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38864
38871
|
const predicateData = arrayify(value.predicateData ?? "0x");
|
38865
38872
|
return {
|
38866
38873
|
type: InputType.Coin,
|
38867
|
-
txID: hexlify(arrayify(value.id).slice(0,
|
38868
|
-
outputIndex:
|
38874
|
+
txID: hexlify(arrayify(value.id).slice(0, 32)),
|
38875
|
+
outputIndex: arrayify(value.id)[32],
|
38869
38876
|
owner: hexlify(value.owner),
|
38870
38877
|
amount: bn(value.amount),
|
38871
38878
|
assetId: hexlify(value.assetId),
|
@@ -39951,6 +39958,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39951
39958
|
* @param quantities - CoinQuantity Array.
|
39952
39959
|
*/
|
39953
39960
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
39961
|
+
let idCounter = 0;
|
39962
|
+
const generateId = () => {
|
39963
|
+
const counterString = String(idCounter++);
|
39964
|
+
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
39965
|
+
return id;
|
39966
|
+
};
|
39954
39967
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
39955
39968
|
if ("assetId" in input) {
|
39956
39969
|
return input.assetId === assetId;
|
@@ -39960,12 +39973,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39960
39973
|
const updateAssetInput = (assetId, quantity) => {
|
39961
39974
|
const assetInput = findAssetInput(assetId);
|
39962
39975
|
if (assetInput && "assetId" in assetInput) {
|
39963
|
-
assetInput.id =
|
39976
|
+
assetInput.id = generateId();
|
39964
39977
|
assetInput.amount = quantity;
|
39965
39978
|
} else {
|
39966
39979
|
this.addResources([
|
39967
39980
|
{
|
39968
|
-
id:
|
39981
|
+
id: generateId(),
|
39969
39982
|
amount: quantity,
|
39970
39983
|
assetId,
|
39971
39984
|
owner: resourcesOwner || Address.fromRandom(),
|
@@ -41791,36 +41804,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41791
41804
|
missingContractIds
|
41792
41805
|
};
|
41793
41806
|
}
|
41794
|
-
/**
|
41795
|
-
* Estimates the transaction gas and fee based on the provided transaction request.
|
41796
|
-
* @param transactionRequest - The transaction request object.
|
41797
|
-
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
41798
|
-
*/
|
41799
|
-
estimateTxGasAndFee(params) {
|
41800
|
-
const { transactionRequest } = params;
|
41801
|
-
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
41802
|
-
const chainInfo = this.getChain();
|
41803
|
-
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
41804
|
-
transactionRequest.gasPrice = gasPrice;
|
41805
|
-
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
41806
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41807
|
-
if (transactionRequest.type === TransactionType.Script) {
|
41808
|
-
if (transactionRequest.gasLimit.eq(0)) {
|
41809
|
-
transactionRequest.gasLimit = minGas;
|
41810
|
-
transactionRequest.gasLimit = maxGasPerTx.sub(
|
41811
|
-
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
41812
|
-
);
|
41813
|
-
}
|
41814
|
-
}
|
41815
|
-
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
41816
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41817
|
-
return {
|
41818
|
-
minGas,
|
41819
|
-
minFee,
|
41820
|
-
maxGas,
|
41821
|
-
maxFee
|
41822
|
-
};
|
41823
|
-
}
|
41824
41807
|
/**
|
41825
41808
|
* Executes a signed transaction without applying the states changes
|
41826
41809
|
* on the chain.
|
@@ -41868,16 +41851,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41868
41851
|
signatureCallback
|
41869
41852
|
} = {}) {
|
41870
41853
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
41871
|
-
const
|
41872
|
-
const
|
41854
|
+
const chainInfo = this.getChain();
|
41855
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
41856
|
+
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
41873
41857
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
41874
41858
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
41875
41859
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
41876
41860
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
41877
|
-
if (isScriptTransaction) {
|
41878
|
-
txRequestClone.gasLimit = bn(0);
|
41879
|
-
}
|
41880
41861
|
if (estimatePredicates) {
|
41862
|
+
if (isScriptTransaction) {
|
41863
|
+
txRequestClone.gasLimit = bn(0);
|
41864
|
+
}
|
41881
41865
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
41882
41866
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41883
41867
|
}
|
@@ -41886,34 +41870,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41886
41870
|
if (signatureCallback && isScriptTransaction) {
|
41887
41871
|
await signatureCallback(txRequestClone);
|
41888
41872
|
}
|
41889
|
-
|
41890
|
-
|
41891
|
-
});
|
41873
|
+
const minGas = txRequestClone.calculateMinGas(chainInfo);
|
41874
|
+
const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
|
41892
41875
|
let receipts = [];
|
41893
41876
|
let missingContractIds = [];
|
41894
41877
|
let outputVariables = 0;
|
41895
|
-
let gasUsed = bn(0);
|
41896
41878
|
if (isScriptTransaction && estimateTxDependencies) {
|
41897
41879
|
txRequestClone.gasPrice = bn(0);
|
41880
|
+
txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
41898
41881
|
const result = await this.estimateTxDependencies(txRequestClone);
|
41899
41882
|
receipts = result.receipts;
|
41900
41883
|
outputVariables = result.outputVariables;
|
41901
41884
|
missingContractIds = result.missingContractIds;
|
41902
|
-
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
41903
|
-
txRequestClone.gasLimit = gasUsed;
|
41904
|
-
txRequestClone.gasPrice = setGasPrice;
|
41905
|
-
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
41906
|
-
transactionRequest: txRequestClone
|
41907
|
-
}));
|
41908
41885
|
}
|
41886
|
+
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
41887
|
+
const usedFee = calculatePriceWithFactor(
|
41888
|
+
gasUsed,
|
41889
|
+
gasPrice,
|
41890
|
+
gasPriceFactor
|
41891
|
+
).normalizeZeroToOne();
|
41892
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41893
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41909
41894
|
return {
|
41910
41895
|
requiredQuantities: allQuantities,
|
41911
41896
|
receipts,
|
41912
41897
|
gasUsed,
|
41913
41898
|
minGasPrice,
|
41914
|
-
gasPrice
|
41899
|
+
gasPrice,
|
41915
41900
|
minGas,
|
41916
41901
|
maxGas,
|
41902
|
+
usedFee,
|
41917
41903
|
minFee,
|
41918
41904
|
maxFee,
|
41919
41905
|
estimatedInputs: txRequestClone.inputs,
|
@@ -44367,12 +44353,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44367
44353
|
};
|
44368
44354
|
|
44369
44355
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
44370
|
-
var
|
44356
|
+
var import_crypto15 = __toESM(__require("crypto"));
|
44371
44357
|
var rnds8Pool = new Uint8Array(256);
|
44372
44358
|
var poolPtr = rnds8Pool.length;
|
44373
44359
|
function rng() {
|
44374
44360
|
if (poolPtr > rnds8Pool.length - 16) {
|
44375
|
-
|
44361
|
+
import_crypto15.default.randomFillSync(rnds8Pool);
|
44376
44362
|
poolPtr = 0;
|
44377
44363
|
}
|
44378
44364
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -44388,9 +44374,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44388
44374
|
}
|
44389
44375
|
|
44390
44376
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
44391
|
-
var
|
44377
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
44392
44378
|
var native_default = {
|
44393
|
-
randomUUID:
|
44379
|
+
randomUUID: import_crypto16.default.randomUUID
|
44394
44380
|
};
|
44395
44381
|
|
44396
44382
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|