@fuel-ts/account 0.0.0-rc-1976-20240410103621 → 0.0.0-rc-2034-20240410113328
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 +113 -90
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +132 -127
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -84
- 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 +15 -9
- package/dist/providers/provider.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.global.js +116 -94
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +132 -128
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +91 -87
- 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,
|
@@ -32711,7 +32710,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32711
32710
|
var defaultConsensusKey = "0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298";
|
32712
32711
|
|
32713
32712
|
// ../crypto/dist/index.mjs
|
32714
|
-
var
|
32713
|
+
var import_crypto9 = __toESM(__require("crypto"), 1);
|
32715
32714
|
|
32716
32715
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/_version.js
|
32717
32716
|
var version = "6.7.1";
|
@@ -33783,6 +33782,27 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33783
33782
|
};
|
33784
33783
|
Object.freeze(pbkdf22);
|
33785
33784
|
|
33785
|
+
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/crypto/random.js
|
33786
|
+
var locked5 = false;
|
33787
|
+
var _randomBytes = function(length) {
|
33788
|
+
return new Uint8Array((0, import_crypto2.randomBytes)(length));
|
33789
|
+
};
|
33790
|
+
var __randomBytes = _randomBytes;
|
33791
|
+
function randomBytes3(length) {
|
33792
|
+
return __randomBytes(length);
|
33793
|
+
}
|
33794
|
+
randomBytes3._ = _randomBytes;
|
33795
|
+
randomBytes3.lock = function() {
|
33796
|
+
locked5 = true;
|
33797
|
+
};
|
33798
|
+
randomBytes3.register = function(func) {
|
33799
|
+
if (locked5) {
|
33800
|
+
throw new Error("randomBytes is locked");
|
33801
|
+
}
|
33802
|
+
__randomBytes = func;
|
33803
|
+
};
|
33804
|
+
Object.freeze(randomBytes3);
|
33805
|
+
|
33786
33806
|
// ../../node_modules/.pnpm/ethers@6.7.1/node_modules/ethers/lib.esm/address/address.js
|
33787
33807
|
var BN_03 = BigInt(0);
|
33788
33808
|
var BN_36 = BigInt(36);
|
@@ -34367,8 +34387,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34367
34387
|
}
|
34368
34388
|
|
34369
34389
|
// ../crypto/dist/index.mjs
|
34370
|
-
var import_crypto9 = __toESM(__require("crypto"), 1);
|
34371
34390
|
var import_crypto10 = __toESM(__require("crypto"), 1);
|
34391
|
+
var import_crypto11 = __toESM(__require("crypto"), 1);
|
34372
34392
|
var scrypt3 = (params) => {
|
34373
34393
|
const { password, salt, n, p, r, dklen } = params;
|
34374
34394
|
const derivedKey = scrypt(password, salt, { N: n, r, p, dkLen: dklen });
|
@@ -34377,7 +34397,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34377
34397
|
var keccak2562 = (data) => keccak_256(data);
|
34378
34398
|
var bufferFromString = (string, encoding = "base64") => Uint8Array.from(Buffer.from(string, encoding));
|
34379
34399
|
var randomBytes4 = (length) => {
|
34380
|
-
const randomValues = Uint8Array.from(
|
34400
|
+
const randomValues = Uint8Array.from(import_crypto10.default.randomBytes(length));
|
34381
34401
|
return randomValues;
|
34382
34402
|
};
|
34383
34403
|
var stringFromBuffer = (buffer, encoding = "base64") => Buffer.from(buffer).toString(encoding);
|
@@ -34392,7 +34412,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34392
34412
|
const salt = randomBytes4(32);
|
34393
34413
|
const secret = keyFromPassword(password, salt);
|
34394
34414
|
const dataBuffer = Uint8Array.from(Buffer.from(JSON.stringify(data), "utf-8"));
|
34395
|
-
const cipher = await
|
34415
|
+
const cipher = await import_crypto9.default.createCipheriv(ALGORITHM, secret, iv);
|
34396
34416
|
let cipherData = cipher.update(dataBuffer);
|
34397
34417
|
cipherData = Buffer.concat([cipherData, cipher.final()]);
|
34398
34418
|
return {
|
@@ -34406,7 +34426,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34406
34426
|
const salt = bufferFromString(keystore.salt);
|
34407
34427
|
const secret = keyFromPassword(password, salt);
|
34408
34428
|
const encryptedText = bufferFromString(keystore.data);
|
34409
|
-
const decipher = await
|
34429
|
+
const decipher = await import_crypto9.default.createDecipheriv(ALGORITHM, secret, iv);
|
34410
34430
|
const decrypted = decipher.update(encryptedText);
|
34411
34431
|
const deBuff = Buffer.concat([decrypted, decipher.final()]);
|
34412
34432
|
const decryptedData = Buffer.from(deBuff).toString("utf-8");
|
@@ -34417,12 +34437,12 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34417
34437
|
}
|
34418
34438
|
};
|
34419
34439
|
async function encryptJsonWalletData(data, key, iv) {
|
34420
|
-
const cipher = await
|
34440
|
+
const cipher = await import_crypto11.default.createCipheriv("aes-128-ctr", key.subarray(0, 16), iv);
|
34421
34441
|
const encrypted = Buffer.concat([cipher.update(data), cipher.final()]);
|
34422
34442
|
return new Uint8Array(encrypted);
|
34423
34443
|
}
|
34424
34444
|
async function decryptJsonWalletData(data, key, iv) {
|
34425
|
-
const decipher =
|
34445
|
+
const decipher = import_crypto11.default.createDecipheriv("aes-128-ctr", key.subarray(0, 16), iv);
|
34426
34446
|
const decrypted = await Buffer.concat([decipher.update(data), decipher.final()]);
|
34427
34447
|
return new Uint8Array(decrypted);
|
34428
34448
|
}
|
@@ -34756,6 +34776,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34756
34776
|
}
|
34757
34777
|
};
|
34758
34778
|
|
34779
|
+
// ../address/dist/configs.mjs
|
34780
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
34781
|
+
var BaseAssetId = ZeroBytes32;
|
34782
|
+
|
34759
34783
|
// ../math/dist/index.mjs
|
34760
34784
|
var import_bn = __toESM(require_bn(), 1);
|
34761
34785
|
var DEFAULT_PRECISION = 9;
|
@@ -34986,11 +35010,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34986
35010
|
let max2;
|
34987
35011
|
if (Array.isArray(coinQuantityLike)) {
|
34988
35012
|
amount = coinQuantityLike[0];
|
34989
|
-
assetId = coinQuantityLike[1];
|
34990
|
-
max2 = coinQuantityLike[2];
|
35013
|
+
assetId = coinQuantityLike[1] ?? BaseAssetId;
|
35014
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
34991
35015
|
} else {
|
34992
35016
|
amount = coinQuantityLike.amount;
|
34993
|
-
assetId = coinQuantityLike.assetId;
|
35017
|
+
assetId = coinQuantityLike.assetId ?? BaseAssetId;
|
34994
35018
|
max2 = coinQuantityLike.max ?? void 0;
|
34995
35019
|
}
|
34996
35020
|
const bnAmount = bn(amount);
|
@@ -42312,9 +42336,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42312
42336
|
}
|
42313
42337
|
};
|
42314
42338
|
|
42315
|
-
// ../address/dist/configs.mjs
|
42316
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
42317
|
-
|
42318
42339
|
// src/providers/transaction-request/input.ts
|
42319
42340
|
var inputify = (value) => {
|
42320
42341
|
const { type: type3 } = value;
|
@@ -42325,7 +42346,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42325
42346
|
return {
|
42326
42347
|
type: InputType.Coin,
|
42327
42348
|
txID: hexlify(arrayify(value.id).slice(0, 32)),
|
42328
|
-
outputIndex: arrayify(value.id)
|
42349
|
+
outputIndex: toNumber2(arrayify(value.id).slice(32, 33)),
|
42329
42350
|
owner: hexlify(value.owner),
|
42330
42351
|
amount: bn(value.amount),
|
42331
42352
|
assetId: hexlify(value.assetId),
|
@@ -42915,8 +42936,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42915
42936
|
outputs = [];
|
42916
42937
|
/** List of witnesses */
|
42917
42938
|
witnesses = [];
|
42918
|
-
/** Base asset ID - should be fetched from the chain */
|
42919
|
-
baseAssetId = ZeroBytes32;
|
42920
42939
|
/**
|
42921
42940
|
* Constructor for initializing a base transaction request.
|
42922
42941
|
*
|
@@ -42929,8 +42948,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42929
42948
|
witnessLimit,
|
42930
42949
|
inputs,
|
42931
42950
|
outputs,
|
42932
|
-
witnesses
|
42933
|
-
baseAssetId
|
42951
|
+
witnesses
|
42934
42952
|
} = {}) {
|
42935
42953
|
this.gasPrice = bn(gasPrice);
|
42936
42954
|
this.maturity = maturity ?? 0;
|
@@ -42939,7 +42957,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42939
42957
|
this.inputs = inputs ?? [];
|
42940
42958
|
this.outputs = outputs ?? [];
|
42941
42959
|
this.witnesses = witnesses ?? [];
|
42942
|
-
this.baseAssetId = baseAssetId ?? ZeroBytes32;
|
42943
42960
|
}
|
42944
42961
|
static getPolicyMeta(req) {
|
42945
42962
|
let policyTypes = 0;
|
@@ -43164,9 +43181,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43164
43181
|
*
|
43165
43182
|
* @param message - Message resource.
|
43166
43183
|
* @param predicate - Predicate bytes.
|
43184
|
+
* @param predicateData - Predicate data bytes.
|
43167
43185
|
*/
|
43168
43186
|
addMessageInput(message, predicate) {
|
43169
43187
|
const { recipient, sender, amount } = message;
|
43188
|
+
const assetId = BaseAssetId;
|
43170
43189
|
let witnessIndex;
|
43171
43190
|
if (predicate) {
|
43172
43191
|
witnessIndex = 0;
|
@@ -43187,7 +43206,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43187
43206
|
predicateData: predicate?.predicateDataBytes
|
43188
43207
|
};
|
43189
43208
|
this.pushInput(input);
|
43190
|
-
this.addChangeOutput(recipient,
|
43209
|
+
this.addChangeOutput(recipient, assetId);
|
43191
43210
|
}
|
43192
43211
|
/**
|
43193
43212
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -43248,12 +43267,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43248
43267
|
* @param amount - Amount of coin.
|
43249
43268
|
* @param assetId - Asset ID of coin.
|
43250
43269
|
*/
|
43251
|
-
addCoinOutput(to, amount, assetId) {
|
43270
|
+
addCoinOutput(to, amount, assetId = BaseAssetId) {
|
43252
43271
|
this.pushOutput({
|
43253
43272
|
type: OutputType.Coin,
|
43254
43273
|
to: addressify(to).toB256(),
|
43255
43274
|
amount,
|
43256
|
-
assetId
|
43275
|
+
assetId
|
43257
43276
|
});
|
43258
43277
|
return this;
|
43259
43278
|
}
|
@@ -43280,7 +43299,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43280
43299
|
* @param to - Address of the owner.
|
43281
43300
|
* @param assetId - Asset ID of coin.
|
43282
43301
|
*/
|
43283
|
-
addChangeOutput(to, assetId) {
|
43302
|
+
addChangeOutput(to, assetId = BaseAssetId) {
|
43284
43303
|
const changeOutput = this.getChangeOutputs().find(
|
43285
43304
|
(output3) => hexlify(output3.assetId) === assetId
|
43286
43305
|
);
|
@@ -43288,7 +43307,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43288
43307
|
this.pushOutput({
|
43289
43308
|
type: OutputType.Change,
|
43290
43309
|
to: addressify(to).toB256(),
|
43291
|
-
assetId
|
43310
|
+
assetId
|
43292
43311
|
});
|
43293
43312
|
}
|
43294
43313
|
}
|
@@ -43339,12 +43358,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43339
43358
|
* @param quantities - CoinQuantity Array.
|
43340
43359
|
*/
|
43341
43360
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
43342
|
-
let idCounter = 0;
|
43343
|
-
const generateId = () => {
|
43344
|
-
const counterString = String(idCounter++);
|
43345
|
-
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
43346
|
-
return id;
|
43347
|
-
};
|
43348
43361
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
43349
43362
|
if ("assetId" in input) {
|
43350
43363
|
return input.assetId === assetId;
|
@@ -43354,12 +43367,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43354
43367
|
const updateAssetInput = (assetId, quantity) => {
|
43355
43368
|
const assetInput = findAssetInput(assetId);
|
43356
43369
|
if (assetInput && "assetId" in assetInput) {
|
43357
|
-
assetInput.id =
|
43370
|
+
assetInput.id = hexlify(randomBytes3(33));
|
43358
43371
|
assetInput.amount = quantity;
|
43359
43372
|
} else {
|
43360
43373
|
this.addResources([
|
43361
43374
|
{
|
43362
|
-
id:
|
43375
|
+
id: hexlify(randomBytes3(33)),
|
43363
43376
|
amount: quantity,
|
43364
43377
|
assetId,
|
43365
43378
|
owner: resourcesOwner || Address.fromRandom(),
|
@@ -43370,7 +43383,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43370
43383
|
]);
|
43371
43384
|
}
|
43372
43385
|
};
|
43373
|
-
updateAssetInput(
|
43386
|
+
updateAssetInput(BaseAssetId, bn(1e11));
|
43374
43387
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
43375
43388
|
}
|
43376
43389
|
/**
|
@@ -44746,7 +44759,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44746
44759
|
gasPerByte: bn(feeParams.gasPerByte),
|
44747
44760
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
44748
44761
|
chainId: bn(consensusParameters.chainId),
|
44749
|
-
baseAssetId: consensusParameters.baseAssetId,
|
44750
44762
|
gasCosts
|
44751
44763
|
},
|
44752
44764
|
gasCosts,
|
@@ -44989,17 +45001,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44989
45001
|
} = this.getChain();
|
44990
45002
|
return chainId.toNumber();
|
44991
45003
|
}
|
44992
|
-
/**
|
44993
|
-
* Returns the base asset ID
|
44994
|
-
*
|
44995
|
-
* @returns A promise that resolves to the base asset ID
|
44996
|
-
*/
|
44997
|
-
getBaseAssetId() {
|
44998
|
-
const {
|
44999
|
-
consensusParameters: { baseAssetId }
|
45000
|
-
} = this.getChain();
|
45001
|
-
return baseAssetId;
|
45002
|
-
}
|
45003
45004
|
/**
|
45004
45005
|
* Submits a transaction to the chain to be executed.
|
45005
45006
|
*
|
@@ -45150,6 +45151,37 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45150
45151
|
missingContractIds
|
45151
45152
|
};
|
45152
45153
|
}
|
45154
|
+
/**
|
45155
|
+
* Estimates the transaction gas and fee based on the provided transaction request.
|
45156
|
+
* @param transactionRequest - The transaction request object.
|
45157
|
+
* @param optimizeGas - Optional. Specifies whether to optimize the gas. Default is false.
|
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
|
+
}
|
45153
45185
|
/**
|
45154
45186
|
* Executes a signed transaction without applying the states changes
|
45155
45187
|
* on the chain.
|
@@ -45197,17 +45229,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45197
45229
|
signatureCallback
|
45198
45230
|
} = {}) {
|
45199
45231
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
45200
|
-
const
|
45201
|
-
const
|
45202
|
-
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
45232
|
+
const { minGasPrice } = this.getGasConfig();
|
45233
|
+
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
45203
45234
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
45204
45235
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
45205
45236
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
45206
45237
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
45238
|
+
if (isScriptTransaction) {
|
45239
|
+
txRequestClone.gasLimit = bn(0);
|
45240
|
+
}
|
45207
45241
|
if (estimatePredicates) {
|
45208
|
-
if (isScriptTransaction) {
|
45209
|
-
txRequestClone.gasLimit = bn(0);
|
45210
|
-
}
|
45211
45242
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
45212
45243
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
45213
45244
|
}
|
@@ -45216,36 +45247,34 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45216
45247
|
if (signatureCallback && isScriptTransaction) {
|
45217
45248
|
await signatureCallback(txRequestClone);
|
45218
45249
|
}
|
45219
|
-
|
45220
|
-
|
45250
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
45251
|
+
transactionRequest: txRequestClone
|
45252
|
+
});
|
45221
45253
|
let receipts = [];
|
45222
45254
|
let missingContractIds = [];
|
45223
45255
|
let outputVariables = 0;
|
45256
|
+
let gasUsed = bn(0);
|
45224
45257
|
if (isScriptTransaction && estimateTxDependencies) {
|
45225
45258
|
txRequestClone.gasPrice = bn(0);
|
45226
|
-
txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
45227
45259
|
const result = await this.estimateTxDependencies(txRequestClone);
|
45228
45260
|
receipts = result.receipts;
|
45229
45261
|
outputVariables = result.outputVariables;
|
45230
45262
|
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
|
+
}));
|
45231
45269
|
}
|
45232
|
-
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
45233
|
-
const usedFee = calculatePriceWithFactor(
|
45234
|
-
gasUsed,
|
45235
|
-
gasPrice,
|
45236
|
-
gasPriceFactor
|
45237
|
-
).normalizeZeroToOne();
|
45238
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45239
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45240
45270
|
return {
|
45241
45271
|
requiredQuantities: allQuantities,
|
45242
45272
|
receipts,
|
45243
45273
|
gasUsed,
|
45244
45274
|
minGasPrice,
|
45245
|
-
gasPrice,
|
45275
|
+
gasPrice: setGasPrice,
|
45246
45276
|
minGas,
|
45247
45277
|
maxGas,
|
45248
|
-
usedFee,
|
45249
45278
|
minFee,
|
45250
45279
|
maxFee,
|
45251
45280
|
estimatedInputs: txRequestClone.inputs,
|
@@ -45861,9 +45890,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45861
45890
|
* @param assetId - The asset ID to check the balance for.
|
45862
45891
|
* @returns A promise that resolves to the balance amount.
|
45863
45892
|
*/
|
45864
|
-
async getBalance(assetId) {
|
45865
|
-
const
|
45866
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
45893
|
+
async getBalance(assetId = BaseAssetId) {
|
45894
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
45867
45895
|
return amount;
|
45868
45896
|
}
|
45869
45897
|
/**
|
@@ -45901,10 +45929,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45901
45929
|
* @returns A promise that resolves when the resources are added to the transaction.
|
45902
45930
|
*/
|
45903
45931
|
async fund(request, coinQuantities, fee) {
|
45904
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
45905
45932
|
const updatedQuantities = addAmountToAsset({
|
45906
45933
|
amount: bn(fee),
|
45907
|
-
assetId:
|
45934
|
+
assetId: BaseAssetId,
|
45908
45935
|
coinQuantities
|
45909
45936
|
});
|
45910
45937
|
const quantitiesDict = {};
|
@@ -45928,8 +45955,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45928
45955
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
45929
45956
|
cachedUtxos.push(input.id);
|
45930
45957
|
}
|
45931
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
45932
|
-
quantitiesDict[
|
45958
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
|
45959
|
+
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
45933
45960
|
cachedMessages.push(input.nonce);
|
45934
45961
|
}
|
45935
45962
|
}
|
@@ -45961,12 +45988,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45961
45988
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
45962
45989
|
* @returns A promise that resolves to the prepared transaction request.
|
45963
45990
|
*/
|
45964
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
45991
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
45965
45992
|
const { minGasPrice } = this.provider.getGasConfig();
|
45966
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
45967
45993
|
const params = { gasPrice: minGasPrice, ...txParams };
|
45968
45994
|
const request = new ScriptTransactionRequest(params);
|
45969
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
45995
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
45970
45996
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
45971
45997
|
estimateTxDependencies: true,
|
45972
45998
|
resourcesOwner: this
|
@@ -45992,15 +46018,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45992
46018
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
45993
46019
|
* @returns A promise that resolves to the transaction response.
|
45994
46020
|
*/
|
45995
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
46021
|
+
async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
45996
46022
|
if (bn(amount).lte(0)) {
|
45997
46023
|
throw new FuelError(
|
45998
46024
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
45999
46025
|
"Transfer amount must be a positive number."
|
46000
46026
|
);
|
46001
46027
|
}
|
46002
|
-
const
|
46003
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
46028
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
46004
46029
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
46005
46030
|
}
|
46006
46031
|
/**
|
@@ -46012,7 +46037,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46012
46037
|
* @param txParams - The optional transaction parameters.
|
46013
46038
|
* @returns A promise that resolves to the transaction response.
|
46014
46039
|
*/
|
46015
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
46040
|
+
async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
|
46016
46041
|
if (bn(amount).lte(0)) {
|
46017
46042
|
throw new FuelError(
|
46018
46043
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -46021,12 +46046,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46021
46046
|
}
|
46022
46047
|
const contractAddress = Address.fromAddressOrString(contractId);
|
46023
46048
|
const { minGasPrice } = this.provider.getGasConfig();
|
46024
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
46025
46049
|
const params = { gasPrice: minGasPrice, ...txParams };
|
46026
46050
|
const { script, scriptData } = await assembleTransferToContractScript({
|
46027
46051
|
hexlifiedContractId: contractAddress.toB256(),
|
46028
46052
|
amountToTransfer: bn(amount),
|
46029
|
-
assetId
|
46053
|
+
assetId
|
46030
46054
|
});
|
46031
46055
|
const request = new ScriptTransactionRequest({
|
46032
46056
|
...params,
|
@@ -46036,7 +46060,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46036
46060
|
request.addContractInputAndOutput(contractAddress);
|
46037
46061
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
46038
46062
|
request,
|
46039
|
-
[{ amount: bn(amount), assetId: String(
|
46063
|
+
[{ amount: bn(amount), assetId: String(assetId) }]
|
46040
46064
|
);
|
46041
46065
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
46042
46066
|
this.validateGas({
|
@@ -46058,7 +46082,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46058
46082
|
*/
|
46059
46083
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
46060
46084
|
const { minGasPrice } = this.provider.getGasConfig();
|
46061
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
46062
46085
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
46063
46086
|
const recipientDataArray = arrayify(
|
46064
46087
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -46073,7 +46096,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46073
46096
|
]);
|
46074
46097
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
46075
46098
|
const request = new ScriptTransactionRequest(params);
|
46076
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
46099
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
|
46077
46100
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
46078
46101
|
request,
|
46079
46102
|
forwardingQuantities
|
@@ -47537,12 +47560,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47537
47560
|
};
|
47538
47561
|
|
47539
47562
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
47540
|
-
var
|
47563
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
47541
47564
|
var rnds8Pool = new Uint8Array(256);
|
47542
47565
|
var poolPtr = rnds8Pool.length;
|
47543
47566
|
function rng() {
|
47544
47567
|
if (poolPtr > rnds8Pool.length - 16) {
|
47545
|
-
|
47568
|
+
import_crypto16.default.randomFillSync(rnds8Pool);
|
47546
47569
|
poolPtr = 0;
|
47547
47570
|
}
|
47548
47571
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -47558,9 +47581,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47558
47581
|
}
|
47559
47582
|
|
47560
47583
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
47561
|
-
var
|
47584
|
+
var import_crypto17 = __toESM(__require("crypto"));
|
47562
47585
|
var native_default = {
|
47563
|
-
randomUUID:
|
47586
|
+
randomUUID: import_crypto17.default.randomUUID
|
47564
47587
|
};
|
47565
47588
|
|
47566
47589
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|
@@ -50540,7 +50563,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50540
50563
|
|
50541
50564
|
// src/test-utils/launchNode.ts
|
50542
50565
|
var import_child_process = __require("child_process");
|
50543
|
-
var
|
50566
|
+
var import_crypto21 = __require("crypto");
|
50544
50567
|
var import_fs2 = __require("fs");
|
50545
50568
|
var import_os = __toESM(__require("os"));
|
50546
50569
|
var import_path8 = __toESM(__require("path"));
|
@@ -50612,7 +50635,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50612
50635
|
})).toString();
|
50613
50636
|
let chainConfigPathToUse;
|
50614
50637
|
const prefix = basePath || import_os.default.tmpdir();
|
50615
|
-
const suffix = basePath ? "" : (0,
|
50638
|
+
const suffix = basePath ? "" : (0, import_crypto21.randomUUID)();
|
50616
50639
|
const tempDirPath = import_path8.default.join(prefix, ".fuels", suffix);
|
50617
50640
|
if (chainConfigPath) {
|
50618
50641
|
chainConfigPathToUse = chainConfigPath;
|
@@ -50635,7 +50658,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50635
50658
|
{
|
50636
50659
|
owner: signer.address.toHexString(),
|
50637
50660
|
amount: toHex(1e9),
|
50638
|
-
asset_id:
|
50661
|
+
asset_id: BaseAssetId
|
50639
50662
|
}
|
50640
50663
|
]
|
50641
50664
|
}
|
@@ -50701,10 +50724,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50701
50724
|
})
|
50702
50725
|
);
|
50703
50726
|
var generateWallets = async (count, provider) => {
|
50704
|
-
const baseAssetId = provider.getBaseAssetId();
|
50705
50727
|
const wallets = [];
|
50706
50728
|
for (let i = 0; i < count; i += 1) {
|
50707
|
-
const wallet = await generateTestWallet(provider, [[1e3,
|
50729
|
+
const wallet = await generateTestWallet(provider, [[1e3, BaseAssetId]]);
|
50708
50730
|
wallets.push(wallet);
|
50709
50731
|
}
|
50710
50732
|
return wallets;
|