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