@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
@@ -32486,8 +32486,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32486
32486
|
fee_params: {
|
32487
32487
|
gas_price_factor: 92,
|
32488
32488
|
gas_per_byte: 4
|
32489
|
-
}
|
32490
|
-
base_asset_id: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
32489
|
+
}
|
32491
32490
|
},
|
32492
32491
|
gas_costs: {
|
32493
32492
|
add: 1,
|
@@ -34756,6 +34755,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34756
34755
|
}
|
34757
34756
|
};
|
34758
34757
|
|
34758
|
+
// ../address/dist/configs.mjs
|
34759
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
34760
|
+
var BaseAssetId = ZeroBytes32;
|
34761
|
+
|
34759
34762
|
// ../math/dist/index.mjs
|
34760
34763
|
var import_bn = __toESM(require_bn(), 1);
|
34761
34764
|
var DEFAULT_PRECISION = 9;
|
@@ -34986,11 +34989,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34986
34989
|
let max2;
|
34987
34990
|
if (Array.isArray(coinQuantityLike)) {
|
34988
34991
|
amount = coinQuantityLike[0];
|
34989
|
-
assetId = coinQuantityLike[1];
|
34990
|
-
max2 = coinQuantityLike[2];
|
34992
|
+
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
34993
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
34991
34994
|
} else {
|
34992
34995
|
amount = coinQuantityLike.amount;
|
34993
|
-
assetId = coinQuantityLike.assetId;
|
34996
|
+
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
34994
34997
|
max2 = coinQuantityLike.max ?? void 0;
|
34995
34998
|
}
|
34996
34999
|
const bnAmount = bn(amount);
|
@@ -42316,9 +42319,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42316
42319
|
}
|
42317
42320
|
};
|
42318
42321
|
|
42319
|
-
// ../address/dist/configs.mjs
|
42320
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
42321
|
-
|
42322
42322
|
// src/providers/transaction-request/input.ts
|
42323
42323
|
var inputify = (value) => {
|
42324
42324
|
const { type: type3 } = value;
|
@@ -42329,7 +42329,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42329
42329
|
return {
|
42330
42330
|
type: InputType.Coin,
|
42331
42331
|
txID: hexlify(arrayify(value.id).slice(0, 32)),
|
42332
|
-
outputIndex: arrayify(value.id)
|
42332
|
+
outputIndex: toNumber2(arrayify(value.id).slice(32, 33)),
|
42333
42333
|
owner: hexlify(value.owner),
|
42334
42334
|
amount: bn(value.amount),
|
42335
42335
|
assetId: hexlify(value.assetId),
|
@@ -42919,8 +42919,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42919
42919
|
outputs = [];
|
42920
42920
|
/** List of witnesses */
|
42921
42921
|
witnesses = [];
|
42922
|
-
/** Base asset ID - should be fetched from the chain */
|
42923
|
-
baseAssetId;
|
42924
42922
|
/**
|
42925
42923
|
* Constructor for initializing a base transaction request.
|
42926
42924
|
*
|
@@ -42933,9 +42931,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42933
42931
|
witnessLimit,
|
42934
42932
|
inputs,
|
42935
42933
|
outputs,
|
42936
|
-
witnesses
|
42937
|
-
|
42938
|
-
}) {
|
42934
|
+
witnesses
|
42935
|
+
} = {}) {
|
42939
42936
|
this.gasPrice = bn(gasPrice);
|
42940
42937
|
this.maturity = maturity ?? 0;
|
42941
42938
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
@@ -42943,7 +42940,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42943
42940
|
this.inputs = inputs ?? [];
|
42944
42941
|
this.outputs = outputs ?? [];
|
42945
42942
|
this.witnesses = witnesses ?? [];
|
42946
|
-
this.baseAssetId = baseAssetId;
|
42947
42943
|
}
|
42948
42944
|
static getPolicyMeta(req) {
|
42949
42945
|
let policyTypes = 0;
|
@@ -43167,9 +43163,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43167
43163
|
*
|
43168
43164
|
* @param message - Message resource.
|
43169
43165
|
* @param predicate - Predicate bytes.
|
43166
|
+
* @param predicateData - Predicate data bytes.
|
43170
43167
|
*/
|
43171
43168
|
addMessageInput(message, predicate) {
|
43172
43169
|
const { recipient, sender, amount } = message;
|
43170
|
+
const assetId = BaseAssetId;
|
43173
43171
|
let witnessIndex;
|
43174
43172
|
if (predicate) {
|
43175
43173
|
witnessIndex = 0;
|
@@ -43189,7 +43187,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43189
43187
|
predicate: predicate?.bytes
|
43190
43188
|
};
|
43191
43189
|
this.pushInput(input);
|
43192
|
-
this.addChangeOutput(recipient,
|
43190
|
+
this.addChangeOutput(recipient, assetId);
|
43193
43191
|
}
|
43194
43192
|
/**
|
43195
43193
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -43250,12 +43248,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43250
43248
|
* @param amount - Amount of coin.
|
43251
43249
|
* @param assetId - Asset ID of coin.
|
43252
43250
|
*/
|
43253
|
-
addCoinOutput(to, amount, assetId) {
|
43251
|
+
addCoinOutput(to, amount, assetId = BaseAssetId) {
|
43254
43252
|
this.pushOutput({
|
43255
43253
|
type: OutputType.Coin,
|
43256
43254
|
to: addressify(to).toB256(),
|
43257
43255
|
amount,
|
43258
|
-
assetId
|
43256
|
+
assetId
|
43259
43257
|
});
|
43260
43258
|
return this;
|
43261
43259
|
}
|
@@ -43282,7 +43280,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43282
43280
|
* @param to - Address of the owner.
|
43283
43281
|
* @param assetId - Asset ID of coin.
|
43284
43282
|
*/
|
43285
|
-
addChangeOutput(to, assetId) {
|
43283
|
+
addChangeOutput(to, assetId = BaseAssetId) {
|
43286
43284
|
const changeOutput = this.getChangeOutputs().find(
|
43287
43285
|
(output3) => hexlify(output3.assetId) === assetId
|
43288
43286
|
);
|
@@ -43290,7 +43288,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43290
43288
|
this.pushOutput({
|
43291
43289
|
type: OutputType.Change,
|
43292
43290
|
to: addressify(to).toB256(),
|
43293
|
-
assetId
|
43291
|
+
assetId
|
43294
43292
|
});
|
43295
43293
|
}
|
43296
43294
|
}
|
@@ -43341,12 +43339,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43341
43339
|
* @param quantities - CoinQuantity Array.
|
43342
43340
|
*/
|
43343
43341
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
43344
|
-
let idCounter = 0;
|
43345
|
-
const generateId = () => {
|
43346
|
-
const counterString = String(idCounter++);
|
43347
|
-
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
43348
|
-
return id;
|
43349
|
-
};
|
43350
43342
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
43351
43343
|
if ("assetId" in input) {
|
43352
43344
|
return input.assetId === assetId;
|
@@ -43356,12 +43348,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43356
43348
|
const updateAssetInput = (assetId, quantity) => {
|
43357
43349
|
const assetInput = findAssetInput(assetId);
|
43358
43350
|
if (assetInput && "assetId" in assetInput) {
|
43359
|
-
assetInput.id =
|
43351
|
+
assetInput.id = hexlify(randomBytes22(33));
|
43360
43352
|
assetInput.amount = quantity;
|
43361
43353
|
} else {
|
43362
43354
|
this.addResources([
|
43363
43355
|
{
|
43364
|
-
id:
|
43356
|
+
id: hexlify(randomBytes22(33)),
|
43365
43357
|
amount: quantity,
|
43366
43358
|
assetId,
|
43367
43359
|
owner: resourcesOwner || Address.fromRandom(),
|
@@ -43372,7 +43364,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43372
43364
|
]);
|
43373
43365
|
}
|
43374
43366
|
};
|
43375
|
-
updateAssetInput(
|
43367
|
+
updateAssetInput(BaseAssetId, bn(1e11));
|
43376
43368
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
43377
43369
|
}
|
43378
43370
|
/**
|
@@ -43529,7 +43521,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43529
43521
|
*
|
43530
43522
|
* @param createTransactionRequestLike - The initial values for the instance
|
43531
43523
|
*/
|
43532
|
-
constructor({
|
43524
|
+
constructor({
|
43525
|
+
bytecodeWitnessIndex,
|
43526
|
+
salt,
|
43527
|
+
storageSlots,
|
43528
|
+
...rest
|
43529
|
+
} = {}) {
|
43533
43530
|
super(rest);
|
43534
43531
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
43535
43532
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -43644,7 +43641,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43644
43641
|
*
|
43645
43642
|
* @param scriptTransactionRequestLike - The initial values for the instance.
|
43646
43643
|
*/
|
43647
|
-
constructor({ script, scriptData, gasLimit, ...rest }) {
|
43644
|
+
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
43648
43645
|
super(rest);
|
43649
43646
|
this.gasLimit = bn(gasLimit);
|
43650
43647
|
this.script = arrayify(script ?? returnZeroScript.bytes);
|
@@ -44743,7 +44740,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44743
44740
|
gasPerByte: bn(feeParams.gasPerByte),
|
44744
44741
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
44745
44742
|
chainId: bn(consensusParameters.chainId),
|
44746
|
-
baseAssetId: consensusParameters.baseAssetId,
|
44747
44743
|
gasCosts
|
44748
44744
|
},
|
44749
44745
|
gasCosts,
|
@@ -44986,17 +44982,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44986
44982
|
} = this.getChain();
|
44987
44983
|
return chainId.toNumber();
|
44988
44984
|
}
|
44989
|
-
/**
|
44990
|
-
* Returns the base asset ID
|
44991
|
-
*
|
44992
|
-
* @returns A promise that resolves to the base asset ID
|
44993
|
-
*/
|
44994
|
-
getBaseAssetId() {
|
44995
|
-
const {
|
44996
|
-
consensusParameters: { baseAssetId }
|
44997
|
-
} = this.getChain();
|
44998
|
-
return baseAssetId;
|
44999
|
-
}
|
45000
44985
|
/**
|
45001
44986
|
* Submits a transaction to the chain to be executed.
|
45002
44987
|
*
|
@@ -45147,6 +45132,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45147
45132
|
missingContractIds
|
45148
45133
|
};
|
45149
45134
|
}
|
45135
|
+
/**
|
45136
|
+
* Estimates the transaction gas and fee based on the provided transaction request.
|
45137
|
+
* @param transactionRequest - The transaction request object.
|
45138
|
+
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
45139
|
+
*/
|
45140
|
+
estimateTxGasAndFee(params) {
|
45141
|
+
const { transactionRequest } = params;
|
45142
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
45143
|
+
const chainInfo = this.getChain();
|
45144
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
45145
|
+
transactionRequest.gasPrice = gasPrice;
|
45146
|
+
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
45147
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45148
|
+
if (transactionRequest.type === TransactionType.Script) {
|
45149
|
+
if (transactionRequest.gasLimit.eq(0)) {
|
45150
|
+
transactionRequest.gasLimit = minGas;
|
45151
|
+
transactionRequest.gasLimit = maxGasPerTx.sub(
|
45152
|
+
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
45153
|
+
);
|
45154
|
+
}
|
45155
|
+
}
|
45156
|
+
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
45157
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45158
|
+
return {
|
45159
|
+
minGas,
|
45160
|
+
minFee,
|
45161
|
+
maxGas,
|
45162
|
+
maxFee
|
45163
|
+
};
|
45164
|
+
}
|
45150
45165
|
/**
|
45151
45166
|
* Executes a signed transaction without applying the states changes
|
45152
45167
|
* on the chain.
|
@@ -45194,17 +45209,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45194
45209
|
signatureCallback
|
45195
45210
|
} = {}) {
|
45196
45211
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
45197
|
-
const
|
45198
|
-
const
|
45199
|
-
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
45212
|
+
const { minGasPrice } = this.getGasConfig();
|
45213
|
+
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
45200
45214
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
45201
45215
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
45202
45216
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
45203
45217
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
45218
|
+
if (isScriptTransaction) {
|
45219
|
+
txRequestClone.gasLimit = bn(0);
|
45220
|
+
}
|
45204
45221
|
if (estimatePredicates) {
|
45205
|
-
if (isScriptTransaction) {
|
45206
|
-
txRequestClone.gasLimit = bn(0);
|
45207
|
-
}
|
45208
45222
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
45209
45223
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
45210
45224
|
}
|
@@ -45213,36 +45227,34 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45213
45227
|
if (signatureCallback && isScriptTransaction) {
|
45214
45228
|
await signatureCallback(txRequestClone);
|
45215
45229
|
}
|
45216
|
-
|
45217
|
-
|
45230
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
45231
|
+
transactionRequest: txRequestClone
|
45232
|
+
});
|
45218
45233
|
let receipts = [];
|
45219
45234
|
let missingContractIds = [];
|
45220
45235
|
let outputVariables = 0;
|
45236
|
+
let gasUsed = bn(0);
|
45221
45237
|
if (isScriptTransaction && estimateTxDependencies) {
|
45222
45238
|
txRequestClone.gasPrice = bn(0);
|
45223
|
-
txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
45224
45239
|
const result = await this.estimateTxDependencies(txRequestClone);
|
45225
45240
|
receipts = result.receipts;
|
45226
45241
|
outputVariables = result.outputVariables;
|
45227
45242
|
missingContractIds = result.missingContractIds;
|
45243
|
+
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
45244
|
+
txRequestClone.gasLimit = gasUsed;
|
45245
|
+
txRequestClone.gasPrice = setGasPrice;
|
45246
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
45247
|
+
transactionRequest: txRequestClone
|
45248
|
+
}));
|
45228
45249
|
}
|
45229
|
-
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
45230
|
-
const usedFee = calculatePriceWithFactor(
|
45231
|
-
gasUsed,
|
45232
|
-
gasPrice,
|
45233
|
-
gasPriceFactor
|
45234
|
-
).normalizeZeroToOne();
|
45235
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45236
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45237
45250
|
return {
|
45238
45251
|
requiredQuantities: allQuantities,
|
45239
45252
|
receipts,
|
45240
45253
|
gasUsed,
|
45241
45254
|
minGasPrice,
|
45242
|
-
gasPrice,
|
45255
|
+
gasPrice: setGasPrice,
|
45243
45256
|
minGas,
|
45244
45257
|
maxGas,
|
45245
|
-
usedFee,
|
45246
45258
|
minFee,
|
45247
45259
|
maxFee,
|
45248
45260
|
estimatedInputs: txRequestClone.inputs,
|
@@ -45858,9 +45870,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45858
45870
|
* @param assetId - The asset ID to check the balance for.
|
45859
45871
|
* @returns A promise that resolves to the balance amount.
|
45860
45872
|
*/
|
45861
|
-
async getBalance(assetId) {
|
45862
|
-
const
|
45863
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
45873
|
+
async getBalance(assetId = BaseAssetId) {
|
45874
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
45864
45875
|
return amount;
|
45865
45876
|
}
|
45866
45877
|
/**
|
@@ -45898,10 +45909,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45898
45909
|
* @returns A promise that resolves when the resources are added to the transaction.
|
45899
45910
|
*/
|
45900
45911
|
async fund(request, coinQuantities, fee) {
|
45901
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
45902
45912
|
const updatedQuantities = addAmountToAsset({
|
45903
45913
|
amount: bn(fee),
|
45904
|
-
assetId:
|
45914
|
+
assetId: BaseAssetId,
|
45905
45915
|
coinQuantities
|
45906
45916
|
});
|
45907
45917
|
const quantitiesDict = {};
|
@@ -45925,8 +45935,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45925
45935
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
45926
45936
|
cachedUtxos.push(input.id);
|
45927
45937
|
}
|
45928
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
45929
|
-
quantitiesDict[
|
45938
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
|
45939
|
+
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
45930
45940
|
cachedMessages.push(input.nonce);
|
45931
45941
|
}
|
45932
45942
|
}
|
@@ -45958,13 +45968,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45958
45968
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
45959
45969
|
* @returns A promise that resolves to the prepared transaction request.
|
45960
45970
|
*/
|
45961
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
45971
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
45962
45972
|
const { minGasPrice } = this.provider.getGasConfig();
|
45963
|
-
const
|
45964
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
45965
|
-
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
45973
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
45966
45974
|
const request = new ScriptTransactionRequest(params);
|
45967
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
45975
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
45968
45976
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
45969
45977
|
estimateTxDependencies: true,
|
45970
45978
|
resourcesOwner: this
|
@@ -45990,15 +45998,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45990
45998
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
45991
45999
|
* @returns A promise that resolves to the transaction response.
|
45992
46000
|
*/
|
45993
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
46001
|
+
async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
45994
46002
|
if (bn(amount).lte(0)) {
|
45995
46003
|
throw new FuelError(
|
45996
46004
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
45997
46005
|
"Transfer amount must be a positive number."
|
45998
46006
|
);
|
45999
46007
|
}
|
46000
|
-
const
|
46001
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
46008
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
46002
46009
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
46003
46010
|
}
|
46004
46011
|
/**
|
@@ -46010,7 +46017,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46010
46017
|
* @param txParams - The optional transaction parameters.
|
46011
46018
|
* @returns A promise that resolves to the transaction response.
|
46012
46019
|
*/
|
46013
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
46020
|
+
async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
|
46014
46021
|
if (bn(amount).lte(0)) {
|
46015
46022
|
throw new FuelError(
|
46016
46023
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -46019,13 +46026,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46019
46026
|
}
|
46020
46027
|
const contractAddress = Address.fromAddressOrString(contractId);
|
46021
46028
|
const { minGasPrice } = this.provider.getGasConfig();
|
46022
|
-
const
|
46023
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
46024
|
-
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
46029
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
46025
46030
|
const { script, scriptData } = await assembleTransferToContractScript({
|
46026
46031
|
hexlifiedContractId: contractAddress.toB256(),
|
46027
46032
|
amountToTransfer: bn(amount),
|
46028
|
-
assetId
|
46033
|
+
assetId
|
46029
46034
|
});
|
46030
46035
|
const request = new ScriptTransactionRequest({
|
46031
46036
|
...params,
|
@@ -46035,7 +46040,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46035
46040
|
request.addContractInputAndOutput(contractAddress);
|
46036
46041
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
46037
46042
|
request,
|
46038
|
-
[{ amount: bn(amount), assetId: String(
|
46043
|
+
[{ amount: bn(amount), assetId: String(assetId) }]
|
46039
46044
|
);
|
46040
46045
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
46041
46046
|
this.validateGas({
|
@@ -46057,7 +46062,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46057
46062
|
*/
|
46058
46063
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
46059
46064
|
const { minGasPrice } = this.provider.getGasConfig();
|
46060
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
46061
46065
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
46062
46066
|
const recipientDataArray = arrayify(
|
46063
46067
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -46070,14 +46074,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46070
46074
|
...recipientDataArray,
|
46071
46075
|
...amountDataArray
|
46072
46076
|
]);
|
46073
|
-
const params = {
|
46074
|
-
script,
|
46075
|
-
gasPrice: minGasPrice,
|
46076
|
-
baseAssetId,
|
46077
|
-
...txParams
|
46078
|
-
};
|
46077
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
46079
46078
|
const request = new ScriptTransactionRequest(params);
|
46080
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
46079
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
|
46081
46080
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
46082
46081
|
request,
|
46083
46082
|
forwardingQuantities
|
@@ -47541,12 +47540,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47541
47540
|
};
|
47542
47541
|
|
47543
47542
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
47544
|
-
var
|
47543
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
47545
47544
|
var rnds8Pool = new Uint8Array(256);
|
47546
47545
|
var poolPtr = rnds8Pool.length;
|
47547
47546
|
function rng() {
|
47548
47547
|
if (poolPtr > rnds8Pool.length - 16) {
|
47549
|
-
|
47548
|
+
import_crypto16.default.randomFillSync(rnds8Pool);
|
47550
47549
|
poolPtr = 0;
|
47551
47550
|
}
|
47552
47551
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -47562,9 +47561,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47562
47561
|
}
|
47563
47562
|
|
47564
47563
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
47565
|
-
var
|
47564
|
+
var import_crypto17 = __toESM(__require("crypto"));
|
47566
47565
|
var native_default = {
|
47567
|
-
randomUUID:
|
47566
|
+
randomUUID: import_crypto17.default.randomUUID
|
47568
47567
|
};
|
47569
47568
|
|
47570
47569
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|
@@ -50509,9 +50508,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50509
50508
|
);
|
50510
50509
|
const resources = await genesisWallet.getResourcesToSpend(quantities);
|
50511
50510
|
const { minGasPrice } = genesisWallet.provider.getGasConfig();
|
50512
|
-
const baseAssetId = genesisWallet.provider.getBaseAssetId();
|
50513
50511
|
const request = new ScriptTransactionRequest({
|
50514
|
-
baseAssetId,
|
50515
50512
|
gasLimit: 1e4,
|
50516
50513
|
gasPrice: minGasPrice
|
50517
50514
|
});
|
@@ -50546,7 +50543,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50546
50543
|
|
50547
50544
|
// src/test-utils/launchNode.ts
|
50548
50545
|
var import_child_process = __require("child_process");
|
50549
|
-
var
|
50546
|
+
var import_crypto21 = __require("crypto");
|
50550
50547
|
var import_fs2 = __require("fs");
|
50551
50548
|
var import_os = __toESM(__require("os"));
|
50552
50549
|
var import_path8 = __toESM(__require("path"));
|
@@ -50618,7 +50615,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50618
50615
|
})).toString();
|
50619
50616
|
let chainConfigPathToUse;
|
50620
50617
|
const prefix = basePath || import_os.default.tmpdir();
|
50621
|
-
const suffix = basePath ? "" : (0,
|
50618
|
+
const suffix = basePath ? "" : (0, import_crypto21.randomUUID)();
|
50622
50619
|
const tempDirPath = import_path8.default.join(prefix, ".fuels", suffix);
|
50623
50620
|
if (chainConfigPath) {
|
50624
50621
|
chainConfigPathToUse = chainConfigPath;
|
@@ -50641,7 +50638,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50641
50638
|
{
|
50642
50639
|
owner: signer.address.toHexString(),
|
50643
50640
|
amount: toHex(1e9),
|
50644
|
-
asset_id:
|
50641
|
+
asset_id: BaseAssetId
|
50645
50642
|
}
|
50646
50643
|
]
|
50647
50644
|
}
|
@@ -50707,10 +50704,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50707
50704
|
})
|
50708
50705
|
);
|
50709
50706
|
var generateWallets = async (count, provider) => {
|
50710
|
-
const baseAssetId = provider.getBaseAssetId();
|
50711
50707
|
const wallets = [];
|
50712
50708
|
for (let i = 0; i < count; i += 1) {
|
50713
|
-
const wallet = await generateTestWallet(provider, [[1e3,
|
50709
|
+
const wallet = await generateTestWallet(provider, [[1e3, BaseAssetId]]);
|
50714
50710
|
wallets.push(wallet);
|
50715
50711
|
}
|
50716
50712
|
return wallets;
|