@fuel-ts/account 0.0.0-rc-1976-20240411153008 → 0.0.0-rc-2037-20240411163513
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 +120 -131
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +197 -204
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +125 -132
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +9 -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/coin.d.ts +2 -1
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +1 -0
- package/dist/providers/message.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 +4 -25
- 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 +108 -137
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +179 -204
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +112 -137
- 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;
|
@@ -42326,9 +42330,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42326
42330
|
}
|
42327
42331
|
};
|
42328
42332
|
|
42329
|
-
// ../address/dist/configs.mjs
|
42330
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
42331
|
-
|
42332
42333
|
// src/providers/transaction-request/input.ts
|
42333
42334
|
var inputify = (value) => {
|
42334
42335
|
const { type: type3 } = value;
|
@@ -42338,8 +42339,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42338
42339
|
const predicateData = arrayify(value.predicateData ?? "0x");
|
42339
42340
|
return {
|
42340
42341
|
type: InputType.Coin,
|
42341
|
-
txID: hexlify(arrayify(value.id).slice(0,
|
42342
|
-
outputIndex: arrayify(value.id)
|
42342
|
+
txID: hexlify(arrayify(value.id).slice(0, BYTES_32)),
|
42343
|
+
outputIndex: toNumber2(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
|
42343
42344
|
owner: hexlify(value.owner),
|
42344
42345
|
amount: bn(value.amount),
|
42345
42346
|
assetId: hexlify(value.assetId),
|
@@ -42929,8 +42930,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42929
42930
|
outputs = [];
|
42930
42931
|
/** List of witnesses */
|
42931
42932
|
witnesses = [];
|
42932
|
-
/** Base asset ID - should be fetched from the chain */
|
42933
|
-
baseAssetId;
|
42934
42933
|
/**
|
42935
42934
|
* Constructor for initializing a base transaction request.
|
42936
42935
|
*
|
@@ -42943,9 +42942,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42943
42942
|
witnessLimit,
|
42944
42943
|
inputs,
|
42945
42944
|
outputs,
|
42946
|
-
witnesses
|
42947
|
-
|
42948
|
-
}) {
|
42945
|
+
witnesses
|
42946
|
+
} = {}) {
|
42949
42947
|
this.gasPrice = bn(gasPrice);
|
42950
42948
|
this.maturity = maturity ?? 0;
|
42951
42949
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
@@ -42953,7 +42951,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42953
42951
|
this.inputs = inputs ?? [];
|
42954
42952
|
this.outputs = outputs ?? [];
|
42955
42953
|
this.witnesses = witnesses ?? [];
|
42956
|
-
this.baseAssetId = baseAssetId;
|
42957
42954
|
}
|
42958
42955
|
static getPolicyMeta(req) {
|
42959
42956
|
let policyTypes = 0;
|
@@ -43147,8 +43144,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43147
43144
|
* @param predicate - Predicate bytes.
|
43148
43145
|
* @param predicateData - Predicate data bytes.
|
43149
43146
|
*/
|
43150
|
-
addCoinInput(coin
|
43151
|
-
const { assetId, owner, amount } = coin;
|
43147
|
+
addCoinInput(coin) {
|
43148
|
+
const { assetId, owner, amount, id, predicate } = coin;
|
43152
43149
|
let witnessIndex;
|
43153
43150
|
if (predicate) {
|
43154
43151
|
witnessIndex = 0;
|
@@ -43159,14 +43156,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43159
43156
|
}
|
43160
43157
|
}
|
43161
43158
|
const input = {
|
43162
|
-
|
43159
|
+
id,
|
43163
43160
|
type: InputType.Coin,
|
43164
43161
|
owner: owner.toB256(),
|
43165
43162
|
amount,
|
43166
43163
|
assetId,
|
43167
43164
|
txPointer: "0x00000000000000000000000000000000",
|
43168
43165
|
witnessIndex,
|
43169
|
-
predicate
|
43166
|
+
predicate
|
43170
43167
|
};
|
43171
43168
|
this.pushInput(input);
|
43172
43169
|
this.addChangeOutput(owner, assetId);
|
@@ -43177,9 +43174,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43177
43174
|
*
|
43178
43175
|
* @param message - Message resource.
|
43179
43176
|
* @param predicate - Predicate bytes.
|
43177
|
+
* @param predicateData - Predicate data bytes.
|
43180
43178
|
*/
|
43181
|
-
addMessageInput(message
|
43182
|
-
const { recipient, sender, amount } = message;
|
43179
|
+
addMessageInput(message) {
|
43180
|
+
const { recipient, sender, amount, predicate, nonce } = message;
|
43181
|
+
const assetId = BaseAssetId;
|
43183
43182
|
let witnessIndex;
|
43184
43183
|
if (predicate) {
|
43185
43184
|
witnessIndex = 0;
|
@@ -43190,16 +43189,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43190
43189
|
}
|
43191
43190
|
}
|
43192
43191
|
const input = {
|
43193
|
-
|
43192
|
+
nonce,
|
43194
43193
|
type: InputType.Message,
|
43195
43194
|
sender: sender.toB256(),
|
43196
43195
|
recipient: recipient.toB256(),
|
43197
43196
|
amount,
|
43198
43197
|
witnessIndex,
|
43199
|
-
predicate
|
43198
|
+
predicate
|
43200
43199
|
};
|
43201
43200
|
this.pushInput(input);
|
43202
|
-
this.addChangeOutput(recipient,
|
43201
|
+
this.addChangeOutput(recipient, assetId);
|
43203
43202
|
}
|
43204
43203
|
/**
|
43205
43204
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -43227,32 +43226,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43227
43226
|
resources.forEach((resource) => this.addResource(resource));
|
43228
43227
|
return this;
|
43229
43228
|
}
|
43230
|
-
/**
|
43231
|
-
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
43232
|
-
* outputs from the related assetIds.
|
43233
|
-
*
|
43234
|
-
* @param resources - The resources to add.
|
43235
|
-
* @returns This transaction.
|
43236
|
-
*/
|
43237
|
-
addPredicateResource(resource, predicate) {
|
43238
|
-
if (isCoin(resource)) {
|
43239
|
-
this.addCoinInput(resource, predicate);
|
43240
|
-
} else {
|
43241
|
-
this.addMessageInput(resource, predicate);
|
43242
|
-
}
|
43243
|
-
return this;
|
43244
|
-
}
|
43245
|
-
/**
|
43246
|
-
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
43247
|
-
* from the related assetIds.
|
43248
|
-
*
|
43249
|
-
* @param resources - The resources to add.
|
43250
|
-
* @returns This transaction.
|
43251
|
-
*/
|
43252
|
-
addPredicateResources(resources, predicate) {
|
43253
|
-
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
43254
|
-
return this;
|
43255
|
-
}
|
43256
43229
|
/**
|
43257
43230
|
* Adds a coin output to the transaction.
|
43258
43231
|
*
|
@@ -43260,12 +43233,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43260
43233
|
* @param amount - Amount of coin.
|
43261
43234
|
* @param assetId - Asset ID of coin.
|
43262
43235
|
*/
|
43263
|
-
addCoinOutput(to, amount, assetId) {
|
43236
|
+
addCoinOutput(to, amount, assetId = BaseAssetId) {
|
43264
43237
|
this.pushOutput({
|
43265
43238
|
type: OutputType.Coin,
|
43266
43239
|
to: addressify(to).toB256(),
|
43267
43240
|
amount,
|
43268
|
-
assetId
|
43241
|
+
assetId
|
43269
43242
|
});
|
43270
43243
|
return this;
|
43271
43244
|
}
|
@@ -43292,7 +43265,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43292
43265
|
* @param to - Address of the owner.
|
43293
43266
|
* @param assetId - Asset ID of coin.
|
43294
43267
|
*/
|
43295
|
-
addChangeOutput(to, assetId) {
|
43268
|
+
addChangeOutput(to, assetId = BaseAssetId) {
|
43296
43269
|
const changeOutput = this.getChangeOutputs().find(
|
43297
43270
|
(output3) => hexlify(output3.assetId) === assetId
|
43298
43271
|
);
|
@@ -43300,7 +43273,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43300
43273
|
this.pushOutput({
|
43301
43274
|
type: OutputType.Change,
|
43302
43275
|
to: addressify(to).toB256(),
|
43303
|
-
assetId
|
43276
|
+
assetId
|
43304
43277
|
});
|
43305
43278
|
}
|
43306
43279
|
}
|
@@ -43351,12 +43324,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43351
43324
|
* @param quantities - CoinQuantity Array.
|
43352
43325
|
*/
|
43353
43326
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
43354
|
-
let idCounter = 0;
|
43355
|
-
const generateId = () => {
|
43356
|
-
const counterString = String(idCounter++);
|
43357
|
-
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
43358
|
-
return id;
|
43359
|
-
};
|
43360
43327
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
43361
43328
|
if ("assetId" in input) {
|
43362
43329
|
return input.assetId === assetId;
|
@@ -43366,12 +43333,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43366
43333
|
const updateAssetInput = (assetId, quantity) => {
|
43367
43334
|
const assetInput = findAssetInput(assetId);
|
43368
43335
|
if (assetInput && "assetId" in assetInput) {
|
43369
|
-
assetInput.id =
|
43336
|
+
assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
|
43370
43337
|
assetInput.amount = quantity;
|
43371
43338
|
} else {
|
43372
43339
|
this.addResources([
|
43373
43340
|
{
|
43374
|
-
id:
|
43341
|
+
id: hexlify(randomBytes22(UTXO_ID_LEN)),
|
43375
43342
|
amount: quantity,
|
43376
43343
|
assetId,
|
43377
43344
|
owner: resourcesOwner || Address.fromRandom(),
|
@@ -43382,7 +43349,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43382
43349
|
]);
|
43383
43350
|
}
|
43384
43351
|
};
|
43385
|
-
updateAssetInput(
|
43352
|
+
updateAssetInput(BaseAssetId, bn(1e11));
|
43386
43353
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
43387
43354
|
}
|
43388
43355
|
/**
|
@@ -43539,7 +43506,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43539
43506
|
*
|
43540
43507
|
* @param createTransactionRequestLike - The initial values for the instance
|
43541
43508
|
*/
|
43542
|
-
constructor({
|
43509
|
+
constructor({
|
43510
|
+
bytecodeWitnessIndex,
|
43511
|
+
salt,
|
43512
|
+
storageSlots,
|
43513
|
+
...rest
|
43514
|
+
} = {}) {
|
43543
43515
|
super(rest);
|
43544
43516
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
43545
43517
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -43654,7 +43626,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
43654
43626
|
*
|
43655
43627
|
* @param scriptTransactionRequestLike - The initial values for the instance.
|
43656
43628
|
*/
|
43657
|
-
constructor({ script, scriptData, gasLimit, ...rest }) {
|
43629
|
+
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
43658
43630
|
super(rest);
|
43659
43631
|
this.gasLimit = bn(gasLimit);
|
43660
43632
|
this.script = arrayify(script ?? returnZeroScript.bytes);
|
@@ -44753,7 +44725,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44753
44725
|
gasPerByte: bn(feeParams.gasPerByte),
|
44754
44726
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
44755
44727
|
chainId: bn(consensusParameters.chainId),
|
44756
|
-
baseAssetId: consensusParameters.baseAssetId,
|
44757
44728
|
gasCosts
|
44758
44729
|
},
|
44759
44730
|
gasCosts,
|
@@ -44996,17 +44967,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44996
44967
|
} = this.getChain();
|
44997
44968
|
return chainId.toNumber();
|
44998
44969
|
}
|
44999
|
-
/**
|
45000
|
-
* Returns the base asset ID
|
45001
|
-
*
|
45002
|
-
* @returns A promise that resolves to the base asset ID
|
45003
|
-
*/
|
45004
|
-
getBaseAssetId() {
|
45005
|
-
const {
|
45006
|
-
consensusParameters: { baseAssetId }
|
45007
|
-
} = this.getChain();
|
45008
|
-
return baseAssetId;
|
45009
|
-
}
|
45010
44970
|
/**
|
45011
44971
|
* Submits a transaction to the chain to be executed.
|
45012
44972
|
*
|
@@ -45157,6 +45117,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45157
45117
|
missingContractIds
|
45158
45118
|
};
|
45159
45119
|
}
|
45120
|
+
/**
|
45121
|
+
* Estimates the transaction gas and fee based on the provided transaction request.
|
45122
|
+
* @param transactionRequest - The transaction request object.
|
45123
|
+
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
45124
|
+
*/
|
45125
|
+
estimateTxGasAndFee(params) {
|
45126
|
+
const { transactionRequest } = params;
|
45127
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
45128
|
+
const chainInfo = this.getChain();
|
45129
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
45130
|
+
transactionRequest.gasPrice = gasPrice;
|
45131
|
+
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
45132
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45133
|
+
if (transactionRequest.type === TransactionType.Script) {
|
45134
|
+
if (transactionRequest.gasLimit.eq(0)) {
|
45135
|
+
transactionRequest.gasLimit = minGas;
|
45136
|
+
transactionRequest.gasLimit = maxGasPerTx.sub(
|
45137
|
+
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
45138
|
+
);
|
45139
|
+
}
|
45140
|
+
}
|
45141
|
+
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
45142
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45143
|
+
return {
|
45144
|
+
minGas,
|
45145
|
+
minFee,
|
45146
|
+
maxGas,
|
45147
|
+
maxFee
|
45148
|
+
};
|
45149
|
+
}
|
45160
45150
|
/**
|
45161
45151
|
* Executes a signed transaction without applying the states changes
|
45162
45152
|
* on the chain.
|
@@ -45204,17 +45194,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45204
45194
|
signatureCallback
|
45205
45195
|
} = {}) {
|
45206
45196
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
45207
|
-
const
|
45208
|
-
const
|
45209
|
-
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
45197
|
+
const { minGasPrice } = this.getGasConfig();
|
45198
|
+
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
45210
45199
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
45211
45200
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
45212
45201
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
45213
45202
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
45203
|
+
if (isScriptTransaction) {
|
45204
|
+
txRequestClone.gasLimit = bn(0);
|
45205
|
+
}
|
45214
45206
|
if (estimatePredicates) {
|
45215
|
-
if (isScriptTransaction) {
|
45216
|
-
txRequestClone.gasLimit = bn(0);
|
45217
|
-
}
|
45218
45207
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
45219
45208
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
45220
45209
|
}
|
@@ -45223,36 +45212,34 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45223
45212
|
if (signatureCallback && isScriptTransaction) {
|
45224
45213
|
await signatureCallback(txRequestClone);
|
45225
45214
|
}
|
45226
|
-
|
45227
|
-
|
45215
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
45216
|
+
transactionRequest: txRequestClone
|
45217
|
+
});
|
45228
45218
|
let receipts = [];
|
45229
45219
|
let missingContractIds = [];
|
45230
45220
|
let outputVariables = 0;
|
45221
|
+
let gasUsed = bn(0);
|
45231
45222
|
if (isScriptTransaction && estimateTxDependencies) {
|
45232
45223
|
txRequestClone.gasPrice = bn(0);
|
45233
|
-
txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
45234
45224
|
const result = await this.estimateTxDependencies(txRequestClone);
|
45235
45225
|
receipts = result.receipts;
|
45236
45226
|
outputVariables = result.outputVariables;
|
45237
45227
|
missingContractIds = result.missingContractIds;
|
45228
|
+
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
45229
|
+
txRequestClone.gasLimit = gasUsed;
|
45230
|
+
txRequestClone.gasPrice = setGasPrice;
|
45231
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
45232
|
+
transactionRequest: txRequestClone
|
45233
|
+
}));
|
45238
45234
|
}
|
45239
|
-
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
45240
|
-
const usedFee = calculatePriceWithFactor(
|
45241
|
-
gasUsed,
|
45242
|
-
gasPrice,
|
45243
|
-
gasPriceFactor
|
45244
|
-
).normalizeZeroToOne();
|
45245
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45246
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45247
45235
|
return {
|
45248
45236
|
requiredQuantities: allQuantities,
|
45249
45237
|
receipts,
|
45250
45238
|
gasUsed,
|
45251
45239
|
minGasPrice,
|
45252
|
-
gasPrice,
|
45240
|
+
gasPrice: setGasPrice,
|
45253
45241
|
minGas,
|
45254
45242
|
maxGas,
|
45255
|
-
usedFee,
|
45256
45243
|
minFee,
|
45257
45244
|
maxFee,
|
45258
45245
|
estimatedInputs: txRequestClone.inputs,
|
@@ -45868,9 +45855,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45868
45855
|
* @param assetId - The asset ID to check the balance for.
|
45869
45856
|
* @returns A promise that resolves to the balance amount.
|
45870
45857
|
*/
|
45871
|
-
async getBalance(assetId) {
|
45872
|
-
const
|
45873
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
45858
|
+
async getBalance(assetId = BaseAssetId) {
|
45859
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
45874
45860
|
return amount;
|
45875
45861
|
}
|
45876
45862
|
/**
|
@@ -45908,10 +45894,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45908
45894
|
* @returns A promise that resolves when the resources are added to the transaction.
|
45909
45895
|
*/
|
45910
45896
|
async fund(request, coinQuantities, fee) {
|
45911
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
45912
45897
|
const updatedQuantities = addAmountToAsset({
|
45913
45898
|
amount: bn(fee),
|
45914
|
-
assetId:
|
45899
|
+
assetId: BaseAssetId,
|
45915
45900
|
coinQuantities
|
45916
45901
|
});
|
45917
45902
|
const quantitiesDict = {};
|
@@ -45935,8 +45920,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45935
45920
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
45936
45921
|
cachedUtxos.push(input.id);
|
45937
45922
|
}
|
45938
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
45939
|
-
quantitiesDict[
|
45923
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[BaseAssetId]) {
|
45924
|
+
quantitiesDict[BaseAssetId].owned = quantitiesDict[BaseAssetId].owned.add(input.amount);
|
45940
45925
|
cachedMessages.push(input.nonce);
|
45941
45926
|
}
|
45942
45927
|
}
|
@@ -45968,13 +45953,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
45968
45953
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
45969
45954
|
* @returns A promise that resolves to the prepared transaction request.
|
45970
45955
|
*/
|
45971
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
45956
|
+
async createTransfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
45972
45957
|
const { minGasPrice } = this.provider.getGasConfig();
|
45973
|
-
const
|
45974
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
45975
|
-
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
45958
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
45976
45959
|
const request = new ScriptTransactionRequest(params);
|
45977
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
45960
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
|
45978
45961
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
45979
45962
|
estimateTxDependencies: true,
|
45980
45963
|
resourcesOwner: this
|
@@ -46000,15 +45983,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46000
45983
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
46001
45984
|
* @returns A promise that resolves to the transaction response.
|
46002
45985
|
*/
|
46003
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
45986
|
+
async transfer(destination, amount, assetId = BaseAssetId, txParams = {}) {
|
46004
45987
|
if (bn(amount).lte(0)) {
|
46005
45988
|
throw new FuelError(
|
46006
45989
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
46007
45990
|
"Transfer amount must be a positive number."
|
46008
45991
|
);
|
46009
45992
|
}
|
46010
|
-
const
|
46011
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
45993
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
46012
45994
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
46013
45995
|
}
|
46014
45996
|
/**
|
@@ -46020,7 +46002,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46020
46002
|
* @param txParams - The optional transaction parameters.
|
46021
46003
|
* @returns A promise that resolves to the transaction response.
|
46022
46004
|
*/
|
46023
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
46005
|
+
async transferToContract(contractId, amount, assetId = BaseAssetId, txParams = {}) {
|
46024
46006
|
if (bn(amount).lte(0)) {
|
46025
46007
|
throw new FuelError(
|
46026
46008
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -46029,13 +46011,11 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46029
46011
|
}
|
46030
46012
|
const contractAddress = Address.fromAddressOrString(contractId);
|
46031
46013
|
const { minGasPrice } = this.provider.getGasConfig();
|
46032
|
-
const
|
46033
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
46034
|
-
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
46014
|
+
const params = { gasPrice: minGasPrice, ...txParams };
|
46035
46015
|
const { script, scriptData } = await assembleTransferToContractScript({
|
46036
46016
|
hexlifiedContractId: contractAddress.toB256(),
|
46037
46017
|
amountToTransfer: bn(amount),
|
46038
|
-
assetId
|
46018
|
+
assetId
|
46039
46019
|
});
|
46040
46020
|
const request = new ScriptTransactionRequest({
|
46041
46021
|
...params,
|
@@ -46045,7 +46025,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46045
46025
|
request.addContractInputAndOutput(contractAddress);
|
46046
46026
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
46047
46027
|
request,
|
46048
|
-
[{ amount: bn(amount), assetId: String(
|
46028
|
+
[{ amount: bn(amount), assetId: String(assetId) }]
|
46049
46029
|
);
|
46050
46030
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
46051
46031
|
this.validateGas({
|
@@ -46067,7 +46047,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46067
46047
|
*/
|
46068
46048
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
46069
46049
|
const { minGasPrice } = this.provider.getGasConfig();
|
46070
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
46071
46050
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
46072
46051
|
const recipientDataArray = arrayify(
|
46073
46052
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -46080,14 +46059,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
46080
46059
|
...recipientDataArray,
|
46081
46060
|
...amountDataArray
|
46082
46061
|
]);
|
46083
|
-
const params = {
|
46084
|
-
script,
|
46085
|
-
gasPrice: minGasPrice,
|
46086
|
-
baseAssetId,
|
46087
|
-
...txParams
|
46088
|
-
};
|
46062
|
+
const params = { script, gasPrice: minGasPrice, ...txParams };
|
46089
46063
|
const request = new ScriptTransactionRequest(params);
|
46090
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
46064
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
|
46091
46065
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
46092
46066
|
request,
|
46093
46067
|
forwardingQuantities
|
@@ -47551,12 +47525,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47551
47525
|
};
|
47552
47526
|
|
47553
47527
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
47554
|
-
var
|
47528
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
47555
47529
|
var rnds8Pool = new Uint8Array(256);
|
47556
47530
|
var poolPtr = rnds8Pool.length;
|
47557
47531
|
function rng() {
|
47558
47532
|
if (poolPtr > rnds8Pool.length - 16) {
|
47559
|
-
|
47533
|
+
import_crypto16.default.randomFillSync(rnds8Pool);
|
47560
47534
|
poolPtr = 0;
|
47561
47535
|
}
|
47562
47536
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -47572,9 +47546,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47572
47546
|
}
|
47573
47547
|
|
47574
47548
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
47575
|
-
var
|
47549
|
+
var import_crypto17 = __toESM(__require("crypto"));
|
47576
47550
|
var native_default = {
|
47577
|
-
randomUUID:
|
47551
|
+
randomUUID: import_crypto17.default.randomUUID
|
47578
47552
|
};
|
47579
47553
|
|
47580
47554
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|
@@ -50519,9 +50493,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50519
50493
|
);
|
50520
50494
|
const resources = await genesisWallet.getResourcesToSpend(quantities);
|
50521
50495
|
const { minGasPrice } = genesisWallet.provider.getGasConfig();
|
50522
|
-
const baseAssetId = genesisWallet.provider.getBaseAssetId();
|
50523
50496
|
const request = new ScriptTransactionRequest({
|
50524
|
-
baseAssetId,
|
50525
50497
|
gasLimit: 1e4,
|
50526
50498
|
gasPrice: minGasPrice
|
50527
50499
|
});
|
@@ -50556,7 +50528,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50556
50528
|
|
50557
50529
|
// src/test-utils/launchNode.ts
|
50558
50530
|
var import_child_process = __require("child_process");
|
50559
|
-
var
|
50531
|
+
var import_crypto21 = __require("crypto");
|
50560
50532
|
var import_fs2 = __require("fs");
|
50561
50533
|
var import_os = __toESM(__require("os"));
|
50562
50534
|
var import_path8 = __toESM(__require("path"));
|
@@ -50628,7 +50600,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50628
50600
|
})).toString();
|
50629
50601
|
let chainConfigPathToUse;
|
50630
50602
|
const prefix = basePath || import_os.default.tmpdir();
|
50631
|
-
const suffix = basePath ? "" : (0,
|
50603
|
+
const suffix = basePath ? "" : (0, import_crypto21.randomUUID)();
|
50632
50604
|
const tempDirPath = import_path8.default.join(prefix, ".fuels", suffix);
|
50633
50605
|
if (chainConfigPath) {
|
50634
50606
|
chainConfigPathToUse = chainConfigPath;
|
@@ -50651,7 +50623,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50651
50623
|
{
|
50652
50624
|
owner: signer.address.toHexString(),
|
50653
50625
|
amount: toHex(1e9),
|
50654
|
-
asset_id:
|
50626
|
+
asset_id: BaseAssetId
|
50655
50627
|
}
|
50656
50628
|
]
|
50657
50629
|
}
|
@@ -50717,10 +50689,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
50717
50689
|
})
|
50718
50690
|
);
|
50719
50691
|
var generateWallets = async (count, provider) => {
|
50720
|
-
const baseAssetId = provider.getBaseAssetId();
|
50721
50692
|
const wallets = [];
|
50722
50693
|
for (let i = 0; i < count; i += 1) {
|
50723
|
-
const wallet = await generateTestWallet(provider, [[1e3,
|
50694
|
+
const wallet = await generateTestWallet(provider, [[1e3, BaseAssetId]]);
|
50724
50695
|
wallets.push(wallet);
|
50725
50696
|
}
|
50726
50697
|
return wallets;
|