@fuel-ts/account 0.0.0-rc-1976-20240415100843 → 0.0.0-rc-2040-20240415161332
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 +75 -119
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +150 -194
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -122
- 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 +2 -20
- 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 +78 -125
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +147 -194
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +80 -127
- 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,7 +35070,6 @@ 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;
|
35070
|
-
var UTXO_ID_LEN = BYTES_32 + 1;
|
35071
35073
|
var ASSET_ID_LEN = BYTES_32;
|
35072
35074
|
var ADDRESS_LEN = BYTES_32;
|
35073
35075
|
var NONCE_LEN = BYTES_32;
|
@@ -42327,9 +42329,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42327
42329
|
}
|
42328
42330
|
};
|
42329
42331
|
|
42330
|
-
// ../address/dist/configs.mjs
|
42331
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
42332
|
-
|
42333
42332
|
// src/providers/transaction-request/input.ts
|
42334
42333
|
var inputify = (value) => {
|
42335
42334
|
const { type: type3 } = value;
|
@@ -42339,8 +42338,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42339
42338
|
const predicateData = arrayify(value.predicateData ?? "0x");
|
42340
42339
|
return {
|
42341
42340
|
type: InputType.Coin,
|
42342
|
-
txID: hexlify(arrayify(value.id).slice(0,
|
42343
|
-
outputIndex:
|
42341
|
+
txID: hexlify(arrayify(value.id).slice(0, 32)),
|
42342
|
+
outputIndex: arrayify(value.id)[32],
|
42344
42343
|
owner: hexlify(value.owner),
|
42345
42344
|
amount: bn(value.amount),
|
42346
42345
|
assetId: hexlify(value.assetId),
|
@@ -42930,8 +42929,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42930
42929
|
outputs = [];
|
42931
42930
|
/** List of witnesses */
|
42932
42931
|
witnesses = [];
|
42933
|
-
/** Base asset ID - should be fetched from the chain */
|
42934
|
-
baseAssetId;
|
42935
42932
|
/**
|
42936
42933
|
* Constructor for initializing a base transaction request.
|
42937
42934
|
*
|
@@ -42944,9 +42941,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42944
42941
|
witnessLimit,
|
42945
42942
|
inputs,
|
42946
42943
|
outputs,
|
42947
|
-
witnesses
|
42948
|
-
|
42949
|
-
}) {
|
42944
|
+
witnesses
|
42945
|
+
} = {}) {
|
42950
42946
|
this.gasPrice = bn(gasPrice);
|
42951
42947
|
this.maturity = maturity ?? 0;
|
42952
42948
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
@@ -42954,7 +42950,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42954
42950
|
this.inputs = inputs ?? [];
|
42955
42951
|
this.outputs = outputs ?? [];
|
42956
42952
|
this.witnesses = witnesses ?? [];
|
42957
|
-
this.baseAssetId = baseAssetId;
|
42958
42953
|
}
|
42959
42954
|
static getPolicyMeta(req) {
|
42960
42955
|
let policyTypes = 0;
|
@@ -43178,9 +43173,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43178
43173
|
*
|
43179
43174
|
* @param message - Message resource.
|
43180
43175
|
* @param predicate - Predicate bytes.
|
43176
|
+
* @param predicateData - Predicate data bytes.
|
43181
43177
|
*/
|
43182
43178
|
addMessageInput(message, predicate) {
|
43183
43179
|
const { recipient, sender, amount } = message;
|
43180
|
+
const assetId = BaseAssetId;
|
43184
43181
|
let witnessIndex;
|
43185
43182
|
if (predicate) {
|
43186
43183
|
witnessIndex = 0;
|
@@ -43200,7 +43197,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43200
43197
|
predicate: predicate?.bytes
|
43201
43198
|
};
|
43202
43199
|
this.pushInput(input);
|
43203
|
-
this.addChangeOutput(recipient,
|
43200
|
+
this.addChangeOutput(recipient, assetId);
|
43204
43201
|
}
|
43205
43202
|
/**
|
43206
43203
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -43261,12 +43258,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43261
43258
|
* @param amount - Amount of coin.
|
43262
43259
|
* @param assetId - Asset ID of coin.
|
43263
43260
|
*/
|
43264
|
-
addCoinOutput(to, amount, assetId) {
|
43261
|
+
addCoinOutput(to, amount, assetId = BaseAssetId) {
|
43265
43262
|
this.pushOutput({
|
43266
43263
|
type: OutputType.Coin,
|
43267
43264
|
to: addressify(to).toB256(),
|
43268
43265
|
amount,
|
43269
|
-
assetId
|
43266
|
+
assetId
|
43270
43267
|
});
|
43271
43268
|
return this;
|
43272
43269
|
}
|
@@ -43293,7 +43290,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43293
43290
|
* @param to - Address of the owner.
|
43294
43291
|
* @param assetId - Asset ID of coin.
|
43295
43292
|
*/
|
43296
|
-
addChangeOutput(to, assetId) {
|
43293
|
+
addChangeOutput(to, assetId = BaseAssetId) {
|
43297
43294
|
const changeOutput = this.getChangeOutputs().find(
|
43298
43295
|
(output3) => hexlify(output3.assetId) === assetId
|
43299
43296
|
);
|
@@ -43301,7 +43298,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43301
43298
|
this.pushOutput({
|
43302
43299
|
type: OutputType.Change,
|
43303
43300
|
to: addressify(to).toB256(),
|
43304
|
-
assetId
|
43301
|
+
assetId
|
43305
43302
|
});
|
43306
43303
|
}
|
43307
43304
|
}
|
@@ -43352,6 +43349,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43352
43349
|
* @param quantities - CoinQuantity Array.
|
43353
43350
|
*/
|
43354
43351
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
43352
|
+
let idCounter = 0;
|
43353
|
+
const generateId = () => {
|
43354
|
+
const counterString = String(idCounter++);
|
43355
|
+
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
43356
|
+
return id;
|
43357
|
+
};
|
43355
43358
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
43356
43359
|
if ("assetId" in input) {
|
43357
43360
|
return input.assetId === assetId;
|
@@ -43361,12 +43364,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43361
43364
|
const updateAssetInput = (assetId, quantity) => {
|
43362
43365
|
const assetInput = findAssetInput(assetId);
|
43363
43366
|
if (assetInput && "assetId" in assetInput) {
|
43364
|
-
assetInput.id =
|
43367
|
+
assetInput.id = generateId();
|
43365
43368
|
assetInput.amount = quantity;
|
43366
43369
|
} else {
|
43367
43370
|
this.addResources([
|
43368
43371
|
{
|
43369
|
-
id:
|
43372
|
+
id: generateId(),
|
43370
43373
|
amount: quantity,
|
43371
43374
|
assetId,
|
43372
43375
|
owner: resourcesOwner || Address.fromRandom(),
|
@@ -43377,7 +43380,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43377
43380
|
]);
|
43378
43381
|
}
|
43379
43382
|
};
|
43380
|
-
updateAssetInput(
|
43383
|
+
updateAssetInput(BaseAssetId, bn(1e11));
|
43381
43384
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
43382
43385
|
}
|
43383
43386
|
/**
|
@@ -43534,7 +43537,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43534
43537
|
*
|
43535
43538
|
* @param createTransactionRequestLike - The initial values for the instance
|
43536
43539
|
*/
|
43537
|
-
constructor({
|
43540
|
+
constructor({
|
43541
|
+
bytecodeWitnessIndex,
|
43542
|
+
salt,
|
43543
|
+
storageSlots,
|
43544
|
+
...rest
|
43545
|
+
} = {}) {
|
43538
43546
|
super(rest);
|
43539
43547
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
43540
43548
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -43649,7 +43657,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43649
43657
|
*
|
43650
43658
|
* @param scriptTransactionRequestLike - The initial values for the instance.
|
43651
43659
|
*/
|
43652
|
-
constructor({ script, scriptData, gasLimit, ...rest }) {
|
43660
|
+
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
43653
43661
|
super(rest);
|
43654
43662
|
this.gasLimit = bn(gasLimit);
|
43655
43663
|
this.script = arrayify(script ?? returnZeroScript.bytes);
|
@@ -44748,7 +44756,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44748
44756
|
gasPerByte: bn(feeParams.gasPerByte),
|
44749
44757
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
44750
44758
|
chainId: bn(consensusParameters.chainId),
|
44751
|
-
baseAssetId: consensusParameters.baseAssetId,
|
44752
44759
|
gasCosts
|
44753
44760
|
},
|
44754
44761
|
gasCosts,
|
@@ -44991,17 +44998,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44991
44998
|
} = this.getChain();
|
44992
44999
|
return chainId.toNumber();
|
44993
45000
|
}
|
44994
|
-
/**
|
44995
|
-
* Returns the base asset ID
|
44996
|
-
*
|
44997
|
-
* @returns A promise that resolves to the base asset ID
|
44998
|
-
*/
|
44999
|
-
getBaseAssetId() {
|
45000
|
-
const {
|
45001
|
-
consensusParameters: { baseAssetId }
|
45002
|
-
} = this.getChain();
|
45003
|
-
return baseAssetId;
|
45004
|
-
}
|
45005
45001
|
/**
|
45006
45002
|
* Submits a transaction to the chain to be executed.
|
45007
45003
|
*
|
@@ -45152,36 +45148,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45152
45148
|
missingContractIds
|
45153
45149
|
};
|
45154
45150
|
}
|
45155
|
-
/**
|
45156
|
-
* Estimates the transaction gas and fee based on the provided transaction request.
|
45157
|
-
* @param transactionRequest - The transaction request object.
|
45158
|
-
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
45159
|
-
*/
|
45160
|
-
estimateTxGasAndFee(params) {
|
45161
|
-
const { transactionRequest } = params;
|
45162
|
-
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
45163
|
-
const chainInfo = this.getChain();
|
45164
|
-
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
45165
|
-
transactionRequest.gasPrice = gasPrice;
|
45166
|
-
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
45167
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45168
|
-
if (transactionRequest.type === TransactionType.Script) {
|
45169
|
-
if (transactionRequest.gasLimit.eq(0)) {
|
45170
|
-
transactionRequest.gasLimit = minGas;
|
45171
|
-
transactionRequest.gasLimit = maxGasPerTx.sub(
|
45172
|
-
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
45173
|
-
);
|
45174
|
-
}
|
45175
|
-
}
|
45176
|
-
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
45177
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45178
|
-
return {
|
45179
|
-
minGas,
|
45180
|
-
minFee,
|
45181
|
-
maxGas,
|
45182
|
-
maxFee
|
45183
|
-
};
|
45184
|
-
}
|
45185
45151
|
/**
|
45186
45152
|
* Executes a signed transaction without applying the states changes
|
45187
45153
|
* on the chain.
|
@@ -45229,16 +45195,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45229
45195
|
signatureCallback
|
45230
45196
|
} = {}) {
|
45231
45197
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
45232
|
-
const
|
45233
|
-
const
|
45198
|
+
const chainInfo = this.getChain();
|
45199
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
45200
|
+
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
45234
45201
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
45235
45202
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
45236
45203
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
45237
45204
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
45238
|
-
if (isScriptTransaction) {
|
45239
|
-
txRequestClone.gasLimit = bn(0);
|
45240
|
-
}
|
45241
45205
|
if (estimatePredicates) {
|
45206
|
+
if (isScriptTransaction) {
|
45207
|
+
txRequestClone.gasLimit = bn(0);
|
45208
|
+
}
|
45242
45209
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
45243
45210
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
45244
45211
|
}
|
@@ -45247,34 +45214,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45247
45214
|
if (signatureCallback && isScriptTransaction) {
|
45248
45215
|
await signatureCallback(txRequestClone);
|
45249
45216
|
}
|
45250
|
-
|
45251
|
-
|
45252
|
-
});
|
45217
|
+
const minGas = txRequestClone.calculateMinGas(chainInfo);
|
45218
|
+
const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
|
45253
45219
|
let receipts = [];
|
45254
45220
|
let missingContractIds = [];
|
45255
45221
|
let outputVariables = 0;
|
45256
|
-
let gasUsed = bn(0);
|
45257
45222
|
if (isScriptTransaction && estimateTxDependencies) {
|
45258
45223
|
txRequestClone.gasPrice = bn(0);
|
45224
|
+
txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
45259
45225
|
const result = await this.estimateTxDependencies(txRequestClone);
|
45260
45226
|
receipts = result.receipts;
|
45261
45227
|
outputVariables = result.outputVariables;
|
45262
45228
|
missingContractIds = result.missingContractIds;
|
45263
|
-
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
45264
|
-
txRequestClone.gasLimit = gasUsed;
|
45265
|
-
txRequestClone.gasPrice = setGasPrice;
|
45266
|
-
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
45267
|
-
transactionRequest: txRequestClone
|
45268
|
-
}));
|
45269
45229
|
}
|
45230
|
+
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
45231
|
+
const usedFee = calculatePriceWithFactor(
|
45232
|
+
gasUsed,
|
45233
|
+
gasPrice,
|
45234
|
+
gasPriceFactor
|
45235
|
+
).normalizeZeroToOne();
|
45236
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45237
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45270
45238
|
return {
|
45271
45239
|
requiredQuantities: allQuantities,
|
45272
45240
|
receipts,
|
45273
45241
|
gasUsed,
|
45274
45242
|
minGasPrice,
|
45275
|
-
gasPrice
|
45243
|
+
gasPrice,
|
45276
45244
|
minGas,
|
45277
45245
|
maxGas,
|
45246
|
+
usedFee,
|
45278
45247
|
minFee,
|
45279
45248
|
maxFee,
|
45280
45249
|
estimatedInputs: txRequestClone.inputs,
|
@@ -45890,9 +45859,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45890
45859
|
* @param assetId - The asset ID to check the balance for.
|
45891
45860
|
* @returns A promise that resolves to the balance amount.
|
45892
45861
|
*/
|
45893
|
-
async getBalance(assetId) {
|
45894
|
-
const
|
45895
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
45862
|
+
async getBalance(assetId = BaseAssetId) {
|
45863
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
45896
45864
|
return amount;
|
45897
45865
|
}
|
45898
45866
|
/**
|
@@ -45930,10 +45898,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45930
45898
|
* @returns A promise that resolves when the resources are added to the transaction.
|
45931
45899
|
*/
|
45932
45900
|
async fund(request, coinQuantities, fee) {
|
45933
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
45934
45901
|
const updatedQuantities = addAmountToAsset({
|
45935
45902
|
amount: bn(fee),
|
45936
|
-
assetId:
|
45903
|
+
assetId: BaseAssetId,
|
45937
45904
|
coinQuantities
|
45938
45905
|
});
|
45939
45906
|
const quantitiesDict = {};
|
@@ -45957,8 +45924,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45957
45924
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
45958
45925
|
cachedUtxos.push(input.id);
|
45959
45926
|
}
|
45960
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
45961
|
-
quantitiesDict[
|
45927
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
|
45928
|
+
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
45962
45929
|
cachedMessages.push(input.nonce);
|
45963
45930
|
}
|
45964
45931
|
}
|
@@ -45990,13 +45957,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45990
45957
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
45991
45958
|
* @returns A promise that resolves to the prepared transaction request.
|
45992
45959
|
*/
|
45993
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
45960
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
45994
45961
|
const { minGasPrice } = this.provider.getGasConfig();
|
45995
|
-
const
|
45996
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
45997
|
-
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
45962
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
45998
45963
|
const request = new ScriptTransactionRequest(params);
|
45999
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
45964
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
46000
45965
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
46001
45966
|
estimateTxDependencies: true,
|
46002
45967
|
resourcesOwner: this
|
@@ -46022,15 +45987,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46022
45987
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
46023
45988
|
* @returns A promise that resolves to the transaction response.
|
46024
45989
|
*/
|
46025
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
45990
|
+
async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
46026
45991
|
if (bn(amount).lte(0)) {
|
46027
45992
|
throw new FuelError(
|
46028
45993
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
46029
45994
|
"Transfer amount must be a positive number."
|
46030
45995
|
);
|
46031
45996
|
}
|
46032
|
-
const
|
46033
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
45997
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
46034
45998
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
46035
45999
|
}
|
46036
46000
|
/**
|
@@ -46042,7 +46006,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46042
46006
|
* @param txParams - The optional transaction parameters.
|
46043
46007
|
* @returns A promise that resolves to the transaction response.
|
46044
46008
|
*/
|
46045
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
46009
|
+
async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
|
46046
46010
|
if (bn(amount).lte(0)) {
|
46047
46011
|
throw new FuelError(
|
46048
46012
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -46051,13 +46015,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46051
46015
|
}
|
46052
46016
|
const contractAddress = Address.fromAddressOrString(contractId);
|
46053
46017
|
const { minGasPrice } = this.provider.getGasConfig();
|
46054
|
-
const
|
46055
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
46056
|
-
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
46018
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
46057
46019
|
const { script, scriptData } = await assembleTransferToContractScript({
|
46058
46020
|
hexlifiedContractId: contractAddress.toB256(),
|
46059
46021
|
amountToTransfer: bn(amount),
|
46060
|
-
assetId
|
46022
|
+
assetId
|
46061
46023
|
});
|
46062
46024
|
const request = new ScriptTransactionRequest({
|
46063
46025
|
...params,
|
@@ -46067,7 +46029,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46067
46029
|
request.addContractInputAndOutput(contractAddress);
|
46068
46030
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
46069
46031
|
request,
|
46070
|
-
[{ amount: bn(amount), assetId: String(
|
46032
|
+
[{ amount: bn(amount), assetId: String(assetId) }]
|
46071
46033
|
);
|
46072
46034
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
46073
46035
|
this.validateGas({
|
@@ -46089,7 +46051,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46089
46051
|
*/
|
46090
46052
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
46091
46053
|
const { minGasPrice } = this.provider.getGasConfig();
|
46092
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
46093
46054
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
46094
46055
|
const recipientDataArray = arrayify(
|
46095
46056
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -46102,14 +46063,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46102
46063
|
...recipientDataArray,
|
46103
46064
|
...amountDataArray
|
46104
46065
|
]);
|
46105
|
-
const params = {
|
46106
|
-
script,
|
46107
|
-
gasPrice: minGasPrice,
|
46108
|
-
baseAssetId,
|
46109
|
-
...txParams
|
46110
|
-
};
|
46066
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
46111
46067
|
const request = new ScriptTransactionRequest(params);
|
46112
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
46068
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
|
46113
46069
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
46114
46070
|
request,
|
46115
46071
|
forwardingQuantities
|
@@ -47573,12 +47529,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47573
47529
|
};
|
47574
47530
|
|
47575
47531
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
47576
|
-
var
|
47532
|
+
var import_crypto15 = __toESM(__require("crypto"));
|
47577
47533
|
var rnds8Pool = new Uint8Array(256);
|
47578
47534
|
var poolPtr = rnds8Pool.length;
|
47579
47535
|
function rng() {
|
47580
47536
|
if (poolPtr > rnds8Pool.length - 16) {
|
47581
|
-
|
47537
|
+
import_crypto15.default.randomFillSync(rnds8Pool);
|
47582
47538
|
poolPtr = 0;
|
47583
47539
|
}
|
47584
47540
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -47594,9 +47550,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47594
47550
|
}
|
47595
47551
|
|
47596
47552
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
47597
|
-
var
|
47553
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
47598
47554
|
var native_default = {
|
47599
|
-
randomUUID:
|
47555
|
+
randomUUID: import_crypto16.default.randomUUID
|
47600
47556
|
};
|
47601
47557
|
|
47602
47558
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|
@@ -50541,9 +50497,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50541
50497
|
);
|
50542
50498
|
const resources = await genesisWallet.getResourcesToSpend(quantities);
|
50543
50499
|
const { minGasPrice } = genesisWallet.provider.getGasConfig();
|
50544
|
-
const baseAssetId = genesisWallet.provider.getBaseAssetId();
|
50545
50500
|
const request = new ScriptTransactionRequest({
|
50546
|
-
baseAssetId,
|
50547
50501
|
gasLimit: 1e4,
|
50548
50502
|
gasPrice: minGasPrice
|
50549
50503
|
});
|
@@ -50578,7 +50532,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50578
50532
|
|
50579
50533
|
// src/test-utils/launchNode.ts
|
50580
50534
|
var import_child_process = __require("child_process");
|
50581
|
-
var
|
50535
|
+
var import_crypto20 = __require("crypto");
|
50582
50536
|
var import_fs2 = __require("fs");
|
50583
50537
|
var import_os = __toESM(__require("os"));
|
50584
50538
|
var import_path8 = __toESM(__require("path"));
|
@@ -50650,7 +50604,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50650
50604
|
})).toString();
|
50651
50605
|
let chainConfigPathToUse;
|
50652
50606
|
const prefix = basePath || import_os.default.tmpdir();
|
50653
|
-
const suffix = basePath ? "" : (0,
|
50607
|
+
const suffix = basePath ? "" : (0, import_crypto20.randomUUID)();
|
50654
50608
|
const tempDirPath = import_path8.default.join(prefix, ".fuels", suffix);
|
50655
50609
|
if (chainConfigPath) {
|
50656
50610
|
chainConfigPathToUse = chainConfigPath;
|
@@ -50673,7 +50627,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50673
50627
|
{
|
50674
50628
|
owner: signer.address.toHexString(),
|
50675
50629
|
amount: toHex(1e9),
|
50676
|
-
asset_id:
|
50630
|
+
asset_id: BaseAssetId
|
50677
50631
|
}
|
50678
50632
|
]
|
50679
50633
|
}
|
@@ -50739,10 +50693,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50739
50693
|
})
|
50740
50694
|
);
|
50741
50695
|
var generateWallets = async (count, provider) => {
|
50742
|
-
const baseAssetId = provider.getBaseAssetId();
|
50743
50696
|
const wallets = [];
|
50744
50697
|
for (let i = 0; i < count; i += 1) {
|
50745
|
-
const wallet = await generateTestWallet(provider, [[1e3,
|
50698
|
+
const wallet = await generateTestWallet(provider, [[1e3, BaseAssetId]]);
|
50746
50699
|
wallets.push(wallet);
|
50747
50700
|
}
|
50748
50701
|
return wallets;
|