@fuel-ts/account 0.0.0-rc-1976-20240410143455 → 0.0.0-rc-2034-20240410172045
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/account.d.ts.map +1 -1
- package/dist/index.global.js +95 -96
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +157 -155
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +99 -97
- 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 +13 -9
- 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/script-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +2 -5
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils.global.js +98 -102
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +158 -159
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +101 -102
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
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":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,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B,MAAM,EAAE,YAAY;IACpB,gBAAgB;IAChB,QAAQ,GAAE,YAAiB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;IAyCzB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOnD;;;;;OAKG;IACG,eAAe,CAAC,sBAAsB,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC;IAUtF;;;;;OAKG;IACG,eAAe,CACnB,sBAAsB,EAAE,sBAAsB,EAC9C,EAAE,sBAA6B,EAAE,cAAc,EAAE,GAAE,oBAAyB,GAC3E,OAAO,CAAC,mBAAmB,CAAC;IAgB/B;;;;;OAKG;IACG,mBAAmB,CACvB,sBAAsB,EAAE,sBAAsB,EAC9C,EAAE,sBAA6B,EAAE,GAAE,yBAA8B,GAChE,OAAO,CAAC,UAAU,CAAC;IAQtB,OAAO,CAAC,WAAW;CAyBpB"}
|
package/dist/index.global.js
CHANGED
@@ -31272,6 +31272,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31272
31272
|
}
|
31273
31273
|
};
|
31274
31274
|
|
31275
|
+
// ../address/dist/configs.mjs
|
31276
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
31277
|
+
var BaseAssetId = ZeroBytes32;
|
31278
|
+
|
31275
31279
|
// ../math/dist/index.mjs
|
31276
31280
|
var import_bn = __toESM(require_bn(), 1);
|
31277
31281
|
var DEFAULT_PRECISION = 9;
|
@@ -31502,11 +31506,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31502
31506
|
let max2;
|
31503
31507
|
if (Array.isArray(coinQuantityLike)) {
|
31504
31508
|
amount = coinQuantityLike[0];
|
31505
|
-
assetId = coinQuantityLike[1];
|
31506
|
-
max2 = coinQuantityLike[2];
|
31509
|
+
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
31510
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
31507
31511
|
} else {
|
31508
31512
|
amount = coinQuantityLike.amount;
|
31509
|
-
assetId = coinQuantityLike.assetId;
|
31513
|
+
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
31510
31514
|
max2 = coinQuantityLike.max ?? void 0;
|
31511
31515
|
}
|
31512
31516
|
const bnAmount = bn(amount);
|
@@ -38850,9 +38854,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38850
38854
|
}
|
38851
38855
|
};
|
38852
38856
|
|
38853
|
-
// ../address/dist/configs.mjs
|
38854
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38855
|
-
|
38856
38857
|
// src/providers/transaction-request/input.ts
|
38857
38858
|
var inputify = (value) => {
|
38858
38859
|
const { type: type3 } = value;
|
@@ -38863,7 +38864,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38863
38864
|
return {
|
38864
38865
|
type: InputType.Coin,
|
38865
38866
|
txID: hexlify(arrayify(value.id).slice(0, 32)),
|
38866
|
-
outputIndex: arrayify(value.id)
|
38867
|
+
outputIndex: toNumber2(arrayify(value.id).slice(32, 33)),
|
38867
38868
|
owner: hexlify(value.owner),
|
38868
38869
|
amount: bn(value.amount),
|
38869
38870
|
assetId: hexlify(value.assetId),
|
@@ -39529,8 +39530,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39529
39530
|
outputs = [];
|
39530
39531
|
/** List of witnesses */
|
39531
39532
|
witnesses = [];
|
39532
|
-
/** Base asset ID - should be fetched from the chain */
|
39533
|
-
baseAssetId;
|
39534
39533
|
/**
|
39535
39534
|
* Constructor for initializing a base transaction request.
|
39536
39535
|
*
|
@@ -39543,9 +39542,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39543
39542
|
witnessLimit,
|
39544
39543
|
inputs,
|
39545
39544
|
outputs,
|
39546
|
-
witnesses
|
39547
|
-
|
39548
|
-
}) {
|
39545
|
+
witnesses
|
39546
|
+
} = {}) {
|
39549
39547
|
this.gasPrice = bn(gasPrice);
|
39550
39548
|
this.maturity = maturity ?? 0;
|
39551
39549
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
@@ -39553,7 +39551,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39553
39551
|
this.inputs = inputs ?? [];
|
39554
39552
|
this.outputs = outputs ?? [];
|
39555
39553
|
this.witnesses = witnesses ?? [];
|
39556
|
-
this.baseAssetId = baseAssetId;
|
39557
39554
|
}
|
39558
39555
|
static getPolicyMeta(req) {
|
39559
39556
|
let policyTypes = 0;
|
@@ -39777,9 +39774,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39777
39774
|
*
|
39778
39775
|
* @param message - Message resource.
|
39779
39776
|
* @param predicate - Predicate bytes.
|
39777
|
+
* @param predicateData - Predicate data bytes.
|
39780
39778
|
*/
|
39781
39779
|
addMessageInput(message, predicate) {
|
39782
39780
|
const { recipient, sender, amount } = message;
|
39781
|
+
const assetId = BaseAssetId;
|
39783
39782
|
let witnessIndex;
|
39784
39783
|
if (predicate) {
|
39785
39784
|
witnessIndex = 0;
|
@@ -39799,7 +39798,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39799
39798
|
predicate: predicate?.bytes
|
39800
39799
|
};
|
39801
39800
|
this.pushInput(input);
|
39802
|
-
this.addChangeOutput(recipient,
|
39801
|
+
this.addChangeOutput(recipient, assetId);
|
39803
39802
|
}
|
39804
39803
|
/**
|
39805
39804
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -39860,12 +39859,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39860
39859
|
* @param amount - Amount of coin.
|
39861
39860
|
* @param assetId - Asset ID of coin.
|
39862
39861
|
*/
|
39863
|
-
addCoinOutput(to, amount, assetId) {
|
39862
|
+
addCoinOutput(to, amount, assetId = BaseAssetId) {
|
39864
39863
|
this.pushOutput({
|
39865
39864
|
type: OutputType.Coin,
|
39866
39865
|
to: addressify(to).toB256(),
|
39867
39866
|
amount,
|
39868
|
-
assetId
|
39867
|
+
assetId
|
39869
39868
|
});
|
39870
39869
|
return this;
|
39871
39870
|
}
|
@@ -39892,7 +39891,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39892
39891
|
* @param to - Address of the owner.
|
39893
39892
|
* @param assetId - Asset ID of coin.
|
39894
39893
|
*/
|
39895
|
-
addChangeOutput(to, assetId) {
|
39894
|
+
addChangeOutput(to, assetId = BaseAssetId) {
|
39896
39895
|
const changeOutput = this.getChangeOutputs().find(
|
39897
39896
|
(output3) => hexlify(output3.assetId) === assetId
|
39898
39897
|
);
|
@@ -39900,7 +39899,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39900
39899
|
this.pushOutput({
|
39901
39900
|
type: OutputType.Change,
|
39902
39901
|
to: addressify(to).toB256(),
|
39903
|
-
assetId
|
39902
|
+
assetId
|
39904
39903
|
});
|
39905
39904
|
}
|
39906
39905
|
}
|
@@ -39951,12 +39950,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39951
39950
|
* @param quantities - CoinQuantity Array.
|
39952
39951
|
*/
|
39953
39952
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
39954
|
-
let idCounter = 0;
|
39955
|
-
const generateId = () => {
|
39956
|
-
const counterString = String(idCounter++);
|
39957
|
-
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
39958
|
-
return id;
|
39959
|
-
};
|
39960
39953
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
39961
39954
|
if ("assetId" in input) {
|
39962
39955
|
return input.assetId === assetId;
|
@@ -39966,12 +39959,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39966
39959
|
const updateAssetInput = (assetId, quantity) => {
|
39967
39960
|
const assetInput = findAssetInput(assetId);
|
39968
39961
|
if (assetInput && "assetId" in assetInput) {
|
39969
|
-
assetInput.id =
|
39962
|
+
assetInput.id = hexlify(randomBytes22(33));
|
39970
39963
|
assetInput.amount = quantity;
|
39971
39964
|
} else {
|
39972
39965
|
this.addResources([
|
39973
39966
|
{
|
39974
|
-
id:
|
39967
|
+
id: hexlify(randomBytes22(33)),
|
39975
39968
|
amount: quantity,
|
39976
39969
|
assetId,
|
39977
39970
|
owner: resourcesOwner || Address.fromRandom(),
|
@@ -39982,7 +39975,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39982
39975
|
]);
|
39983
39976
|
}
|
39984
39977
|
};
|
39985
|
-
updateAssetInput(
|
39978
|
+
updateAssetInput(BaseAssetId, bn(1e11));
|
39986
39979
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
39987
39980
|
}
|
39988
39981
|
/**
|
@@ -40139,7 +40132,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40139
40132
|
*
|
40140
40133
|
* @param createTransactionRequestLike - The initial values for the instance
|
40141
40134
|
*/
|
40142
|
-
constructor({
|
40135
|
+
constructor({
|
40136
|
+
bytecodeWitnessIndex,
|
40137
|
+
salt,
|
40138
|
+
storageSlots,
|
40139
|
+
...rest
|
40140
|
+
} = {}) {
|
40143
40141
|
super(rest);
|
40144
40142
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
40145
40143
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -40254,7 +40252,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40254
40252
|
*
|
40255
40253
|
* @param scriptTransactionRequestLike - The initial values for the instance.
|
40256
40254
|
*/
|
40257
|
-
constructor({ script, scriptData, gasLimit, ...rest }) {
|
40255
|
+
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
40258
40256
|
super(rest);
|
40259
40257
|
this.gasLimit = bn(gasLimit);
|
40260
40258
|
this.script = arrayify(script ?? returnZeroScript.bytes);
|
@@ -41400,7 +41398,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41400
41398
|
gasPerByte: bn(feeParams.gasPerByte),
|
41401
41399
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41402
41400
|
chainId: bn(consensusParameters.chainId),
|
41403
|
-
baseAssetId: consensusParameters.baseAssetId,
|
41404
41401
|
gasCosts
|
41405
41402
|
},
|
41406
41403
|
gasCosts,
|
@@ -41643,17 +41640,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41643
41640
|
} = this.getChain();
|
41644
41641
|
return chainId.toNumber();
|
41645
41642
|
}
|
41646
|
-
/**
|
41647
|
-
* Returns the base asset ID
|
41648
|
-
*
|
41649
|
-
* @returns A promise that resolves to the base asset ID
|
41650
|
-
*/
|
41651
|
-
getBaseAssetId() {
|
41652
|
-
const {
|
41653
|
-
consensusParameters: { baseAssetId }
|
41654
|
-
} = this.getChain();
|
41655
|
-
return baseAssetId;
|
41656
|
-
}
|
41657
41643
|
/**
|
41658
41644
|
* Submits a transaction to the chain to be executed.
|
41659
41645
|
*
|
@@ -41804,6 +41790,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41804
41790
|
missingContractIds
|
41805
41791
|
};
|
41806
41792
|
}
|
41793
|
+
/**
|
41794
|
+
* Estimates the transaction gas and fee based on the provided transaction request.
|
41795
|
+
* @param transactionRequest - The transaction request object.
|
41796
|
+
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
41797
|
+
*/
|
41798
|
+
estimateTxGasAndFee(params) {
|
41799
|
+
const { transactionRequest } = params;
|
41800
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
41801
|
+
const chainInfo = this.getChain();
|
41802
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
41803
|
+
transactionRequest.gasPrice = gasPrice;
|
41804
|
+
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
41805
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41806
|
+
if (transactionRequest.type === TransactionType.Script) {
|
41807
|
+
if (transactionRequest.gasLimit.eq(0)) {
|
41808
|
+
transactionRequest.gasLimit = minGas;
|
41809
|
+
transactionRequest.gasLimit = maxGasPerTx.sub(
|
41810
|
+
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
41811
|
+
);
|
41812
|
+
}
|
41813
|
+
}
|
41814
|
+
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
41815
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41816
|
+
return {
|
41817
|
+
minGas,
|
41818
|
+
minFee,
|
41819
|
+
maxGas,
|
41820
|
+
maxFee
|
41821
|
+
};
|
41822
|
+
}
|
41807
41823
|
/**
|
41808
41824
|
* Executes a signed transaction without applying the states changes
|
41809
41825
|
* on the chain.
|
@@ -41851,17 +41867,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41851
41867
|
signatureCallback
|
41852
41868
|
} = {}) {
|
41853
41869
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
41854
|
-
const
|
41855
|
-
const
|
41856
|
-
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
41870
|
+
const { minGasPrice } = this.getGasConfig();
|
41871
|
+
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
41857
41872
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
41858
41873
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
41859
41874
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
41860
41875
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
41876
|
+
if (isScriptTransaction) {
|
41877
|
+
txRequestClone.gasLimit = bn(0);
|
41878
|
+
}
|
41861
41879
|
if (estimatePredicates) {
|
41862
|
-
if (isScriptTransaction) {
|
41863
|
-
txRequestClone.gasLimit = bn(0);
|
41864
|
-
}
|
41865
41880
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
41866
41881
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41867
41882
|
}
|
@@ -41870,36 +41885,34 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41870
41885
|
if (signatureCallback && isScriptTransaction) {
|
41871
41886
|
await signatureCallback(txRequestClone);
|
41872
41887
|
}
|
41873
|
-
|
41874
|
-
|
41888
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
41889
|
+
transactionRequest: txRequestClone
|
41890
|
+
});
|
41875
41891
|
let receipts = [];
|
41876
41892
|
let missingContractIds = [];
|
41877
41893
|
let outputVariables = 0;
|
41894
|
+
let gasUsed = bn(0);
|
41878
41895
|
if (isScriptTransaction && estimateTxDependencies) {
|
41879
41896
|
txRequestClone.gasPrice = bn(0);
|
41880
|
-
txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
41881
41897
|
const result = await this.estimateTxDependencies(txRequestClone);
|
41882
41898
|
receipts = result.receipts;
|
41883
41899
|
outputVariables = result.outputVariables;
|
41884
41900
|
missingContractIds = result.missingContractIds;
|
41901
|
+
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
41902
|
+
txRequestClone.gasLimit = gasUsed;
|
41903
|
+
txRequestClone.gasPrice = setGasPrice;
|
41904
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
41905
|
+
transactionRequest: txRequestClone
|
41906
|
+
}));
|
41885
41907
|
}
|
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();
|
41894
41908
|
return {
|
41895
41909
|
requiredQuantities: allQuantities,
|
41896
41910
|
receipts,
|
41897
41911
|
gasUsed,
|
41898
41912
|
minGasPrice,
|
41899
|
-
gasPrice,
|
41913
|
+
gasPrice: setGasPrice,
|
41900
41914
|
minGas,
|
41901
41915
|
maxGas,
|
41902
|
-
usedFee,
|
41903
41916
|
minFee,
|
41904
41917
|
maxFee,
|
41905
41918
|
estimatedInputs: txRequestClone.inputs,
|
@@ -42683,9 +42696,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42683
42696
|
* @param assetId - The asset ID to check the balance for.
|
42684
42697
|
* @returns A promise that resolves to the balance amount.
|
42685
42698
|
*/
|
42686
|
-
async getBalance(assetId) {
|
42687
|
-
const
|
42688
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42699
|
+
async getBalance(assetId = BaseAssetId) {
|
42700
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
42689
42701
|
return amount;
|
42690
42702
|
}
|
42691
42703
|
/**
|
@@ -42723,10 +42735,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42723
42735
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42724
42736
|
*/
|
42725
42737
|
async fund(request, coinQuantities, fee) {
|
42726
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
42727
42738
|
const updatedQuantities = addAmountToAsset({
|
42728
42739
|
amount: bn(fee),
|
42729
|
-
assetId:
|
42740
|
+
assetId: BaseAssetId,
|
42730
42741
|
coinQuantities
|
42731
42742
|
});
|
42732
42743
|
const quantitiesDict = {};
|
@@ -42750,8 +42761,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42750
42761
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42751
42762
|
cachedUtxos.push(input.id);
|
42752
42763
|
}
|
42753
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
42754
|
-
quantitiesDict[
|
42764
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
|
42765
|
+
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
42755
42766
|
cachedMessages.push(input.nonce);
|
42756
42767
|
}
|
42757
42768
|
}
|
@@ -42783,13 +42794,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42783
42794
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42784
42795
|
* @returns A promise that resolves to the prepared transaction request.
|
42785
42796
|
*/
|
42786
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42797
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
42787
42798
|
const { minGasPrice } = this.provider.getGasConfig();
|
42788
|
-
const
|
42789
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42790
|
-
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42799
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
42791
42800
|
const request = new ScriptTransactionRequest(params);
|
42792
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
42801
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
42793
42802
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
42794
42803
|
estimateTxDependencies: true,
|
42795
42804
|
resourcesOwner: this
|
@@ -42815,15 +42824,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42815
42824
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42816
42825
|
* @returns A promise that resolves to the transaction response.
|
42817
42826
|
*/
|
42818
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
42827
|
+
async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
42819
42828
|
if (bn(amount).lte(0)) {
|
42820
42829
|
throw new FuelError(
|
42821
42830
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42822
42831
|
"Transfer amount must be a positive number."
|
42823
42832
|
);
|
42824
42833
|
}
|
42825
|
-
const
|
42826
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
42834
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
42827
42835
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42828
42836
|
}
|
42829
42837
|
/**
|
@@ -42835,7 +42843,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42835
42843
|
* @param txParams - The optional transaction parameters.
|
42836
42844
|
* @returns A promise that resolves to the transaction response.
|
42837
42845
|
*/
|
42838
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
42846
|
+
async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
|
42839
42847
|
if (bn(amount).lte(0)) {
|
42840
42848
|
throw new FuelError(
|
42841
42849
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42844,13 +42852,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42844
42852
|
}
|
42845
42853
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42846
42854
|
const { minGasPrice } = this.provider.getGasConfig();
|
42847
|
-
const
|
42848
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42849
|
-
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42855
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
42850
42856
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42851
42857
|
hexlifiedContractId: contractAddress.toB256(),
|
42852
42858
|
amountToTransfer: bn(amount),
|
42853
|
-
assetId
|
42859
|
+
assetId
|
42854
42860
|
});
|
42855
42861
|
const request = new ScriptTransactionRequest({
|
42856
42862
|
...params,
|
@@ -42860,7 +42866,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42860
42866
|
request.addContractInputAndOutput(contractAddress);
|
42861
42867
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42862
42868
|
request,
|
42863
|
-
[{ amount: bn(amount), assetId: String(
|
42869
|
+
[{ amount: bn(amount), assetId: String(assetId) }]
|
42864
42870
|
);
|
42865
42871
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42866
42872
|
this.validateGas({
|
@@ -42882,7 +42888,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42882
42888
|
*/
|
42883
42889
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42884
42890
|
const { minGasPrice } = this.provider.getGasConfig();
|
42885
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
42886
42891
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42887
42892
|
const recipientDataArray = arrayify(
|
42888
42893
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42895,14 +42900,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42895
42900
|
...recipientDataArray,
|
42896
42901
|
...amountDataArray
|
42897
42902
|
]);
|
42898
|
-
const params = {
|
42899
|
-
script,
|
42900
|
-
gasPrice: minGasPrice,
|
42901
|
-
baseAssetId,
|
42902
|
-
...txParams
|
42903
|
-
};
|
42903
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
42904
42904
|
const request = new ScriptTransactionRequest(params);
|
42905
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
42905
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
|
42906
42906
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42907
42907
|
request,
|
42908
42908
|
forwardingQuantities
|
@@ -44366,12 +44366,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44366
44366
|
};
|
44367
44367
|
|
44368
44368
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
44369
|
-
var
|
44369
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
44370
44370
|
var rnds8Pool = new Uint8Array(256);
|
44371
44371
|
var poolPtr = rnds8Pool.length;
|
44372
44372
|
function rng() {
|
44373
44373
|
if (poolPtr > rnds8Pool.length - 16) {
|
44374
|
-
|
44374
|
+
import_crypto16.default.randomFillSync(rnds8Pool);
|
44375
44375
|
poolPtr = 0;
|
44376
44376
|
}
|
44377
44377
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -44387,9 +44387,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44387
44387
|
}
|
44388
44388
|
|
44389
44389
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
44390
|
-
var
|
44390
|
+
var import_crypto17 = __toESM(__require("crypto"));
|
44391
44391
|
var native_default = {
|
44392
|
-
randomUUID:
|
44392
|
+
randomUUID: import_crypto17.default.randomUUID
|
44393
44393
|
};
|
44394
44394
|
|
44395
44395
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|
@@ -47865,9 +47865,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47865
47865
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47866
47866
|
* @returns A promise that resolves to the prepared transaction request.
|
47867
47867
|
*/
|
47868
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
47869
|
-
const
|
47870
|
-
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
47868
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
47869
|
+
const request = await super.createTransfer(destination, amount, assetId, txParams);
|
47871
47870
|
return this.populateTransactionPredicateData(request);
|
47872
47871
|
}
|
47873
47872
|
/**
|