@fuel-ts/account 0.88.0 → 0.89.0
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 +67 -48
- package/dist/account.d.ts.map +1 -1
- package/dist/index.global.js +305 -138
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +257 -102
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +257 -102
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +126 -72
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts +7 -0
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +1 -0
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/operations.d.ts +4 -2
- package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
- package/dist/providers/transaction-summary/types.d.ts +1 -0
- package/dist/providers/transaction-summary/types.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +3 -3
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +456 -310
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +250 -102
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +250 -102
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +8 -0
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +15 -15
package/dist/index.js
CHANGED
@@ -2251,7 +2251,7 @@ var BaseTransactionRequest = class {
|
|
2251
2251
|
* @param coin - Coin resource.
|
2252
2252
|
*/
|
2253
2253
|
addCoinInput(coin) {
|
2254
|
-
const { assetId, owner, amount, id, predicate } = coin;
|
2254
|
+
const { assetId, owner, amount, id, predicate, predicateData } = coin;
|
2255
2255
|
let witnessIndex;
|
2256
2256
|
if (coin.predicate) {
|
2257
2257
|
witnessIndex = 0;
|
@@ -2269,7 +2269,8 @@ var BaseTransactionRequest = class {
|
|
2269
2269
|
assetId,
|
2270
2270
|
txPointer: "0x00000000000000000000000000000000",
|
2271
2271
|
witnessIndex,
|
2272
|
-
predicate
|
2272
|
+
predicate,
|
2273
|
+
predicateData
|
2273
2274
|
};
|
2274
2275
|
this.pushInput(input);
|
2275
2276
|
this.addChangeOutput(owner, assetId);
|
@@ -2281,7 +2282,7 @@ var BaseTransactionRequest = class {
|
|
2281
2282
|
* @param message - Message resource.
|
2282
2283
|
*/
|
2283
2284
|
addMessageInput(message) {
|
2284
|
-
const { recipient, sender, amount, predicate, nonce, assetId } = message;
|
2285
|
+
const { recipient, sender, amount, predicate, nonce, assetId, predicateData } = message;
|
2285
2286
|
let witnessIndex;
|
2286
2287
|
if (message.predicate) {
|
2287
2288
|
witnessIndex = 0;
|
@@ -2298,7 +2299,8 @@ var BaseTransactionRequest = class {
|
|
2298
2299
|
recipient: recipient.toB256(),
|
2299
2300
|
amount,
|
2300
2301
|
witnessIndex,
|
2301
|
-
predicate
|
2302
|
+
predicate,
|
2303
|
+
predicateData
|
2302
2304
|
};
|
2303
2305
|
this.pushInput(input);
|
2304
2306
|
this.addChangeOutput(recipient, assetId);
|
@@ -2500,23 +2502,13 @@ var BaseTransactionRequest = class {
|
|
2500
2502
|
});
|
2501
2503
|
}
|
2502
2504
|
updatePredicateGasUsed(inputs) {
|
2503
|
-
|
2504
|
-
|
2505
|
-
|
2506
|
-
|
2507
|
-
|
2508
|
-
|
2509
|
-
case import_transactions7.InputType.Message:
|
2510
|
-
correspondingInput = inputs.find(
|
2511
|
-
(x) => x.type === import_transactions7.InputType.Message && x.sender === i.sender
|
2512
|
-
);
|
2513
|
-
break;
|
2514
|
-
default:
|
2515
|
-
return;
|
2516
|
-
}
|
2505
|
+
const inputsToExtractGasUsed = inputs.filter(isRequestInputResource);
|
2506
|
+
this.inputs.filter(isRequestInputResource).forEach((i) => {
|
2507
|
+
const owner = getRequestInputResourceOwner(i);
|
2508
|
+
const correspondingInput = inputsToExtractGasUsed.find(
|
2509
|
+
(x) => isRequestInputResourceFromOwner(x, import_address.Address.fromString(String(owner)))
|
2510
|
+
);
|
2517
2511
|
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math8.bn)(correspondingInput.predicateGasUsed).gt(0)) {
|
2518
|
-
i.predicate = correspondingInput.predicate;
|
2519
|
-
i.predicateData = correspondingInput.predicateData;
|
2520
2512
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
2521
2513
|
}
|
2522
2514
|
});
|
@@ -2849,6 +2841,13 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2849
2841
|
}
|
2850
2842
|
return this.outputs.length - 1;
|
2851
2843
|
}
|
2844
|
+
/**
|
2845
|
+
* Calculates the maximum gas for the transaction.
|
2846
|
+
*
|
2847
|
+
* @param chainInfo - The chain information.
|
2848
|
+
* @param minGas - The minimum gas.
|
2849
|
+
* @returns the maximum gas.
|
2850
|
+
*/
|
2852
2851
|
calculateMaxGas(chainInfo, minGas) {
|
2853
2852
|
const { consensusParameters } = chainInfo;
|
2854
2853
|
const {
|
@@ -3266,13 +3265,13 @@ function getReceiptsTransferOut(receipts) {
|
|
3266
3265
|
}
|
3267
3266
|
function getWithdrawFromFuelOperations({
|
3268
3267
|
inputs,
|
3269
|
-
receipts
|
3268
|
+
receipts,
|
3269
|
+
baseAssetId
|
3270
3270
|
}) {
|
3271
3271
|
const messageOutReceipts = getReceiptsMessageOut(receipts);
|
3272
3272
|
const withdrawFromFuelOperations = messageOutReceipts.reduce(
|
3273
3273
|
(prevWithdrawFromFuelOps, receipt) => {
|
3274
|
-
const
|
3275
|
-
const input = getInputFromAssetId(inputs, assetId);
|
3274
|
+
const input = getInputFromAssetId(inputs, baseAssetId);
|
3276
3275
|
if (input) {
|
3277
3276
|
const inputAddress = getInputAccountAddress(input);
|
3278
3277
|
const newWithdrawFromFuelOps = addOperation(prevWithdrawFromFuelOps, {
|
@@ -3289,7 +3288,7 @@ function getWithdrawFromFuelOperations({
|
|
3289
3288
|
assetsSent: [
|
3290
3289
|
{
|
3291
3290
|
amount: receipt.amount,
|
3292
|
-
assetId
|
3291
|
+
assetId: baseAssetId
|
3293
3292
|
}
|
3294
3293
|
]
|
3295
3294
|
});
|
@@ -3485,7 +3484,8 @@ function getOperations({
|
|
3485
3484
|
receipts,
|
3486
3485
|
abiMap,
|
3487
3486
|
rawPayload,
|
3488
|
-
maxInputs
|
3487
|
+
maxInputs,
|
3488
|
+
baseAssetId
|
3489
3489
|
}) {
|
3490
3490
|
if (isTypeCreate(transactionType)) {
|
3491
3491
|
return [
|
@@ -3504,7 +3504,7 @@ function getOperations({
|
|
3504
3504
|
rawPayload,
|
3505
3505
|
maxInputs
|
3506
3506
|
}),
|
3507
|
-
...getWithdrawFromFuelOperations({ inputs, receipts })
|
3507
|
+
...getWithdrawFromFuelOperations({ inputs, receipts, baseAssetId })
|
3508
3508
|
];
|
3509
3509
|
}
|
3510
3510
|
return [...getPayProducerOperations(outputs)];
|
@@ -3640,7 +3640,8 @@ function assembleTransactionSummary(params) {
|
|
3640
3640
|
maxInputs,
|
3641
3641
|
gasCosts,
|
3642
3642
|
maxGasPerTx,
|
3643
|
-
gasPrice
|
3643
|
+
gasPrice,
|
3644
|
+
baseAssetId
|
3644
3645
|
} = params;
|
3645
3646
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3646
3647
|
const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
|
@@ -3651,7 +3652,8 @@ function assembleTransactionSummary(params) {
|
|
3651
3652
|
receipts,
|
3652
3653
|
rawPayload,
|
3653
3654
|
abiMap,
|
3654
|
-
maxInputs
|
3655
|
+
maxInputs,
|
3656
|
+
baseAssetId
|
3655
3657
|
});
|
3656
3658
|
const typeName = getTransactionTypeName(transaction.type);
|
3657
3659
|
const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions17.PolicyType.Tip)?.data);
|
@@ -3811,6 +3813,7 @@ var TransactionResponse = class {
|
|
3811
3813
|
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3812
3814
|
const gasPrice = await this.provider.getLatestGasPrice();
|
3813
3815
|
const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
|
3816
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
3814
3817
|
const transactionSummary = assembleTransactionSummary({
|
3815
3818
|
id: this.id,
|
3816
3819
|
receipts,
|
@@ -3823,7 +3826,8 @@ var TransactionResponse = class {
|
|
3823
3826
|
maxInputs,
|
3824
3827
|
gasCosts,
|
3825
3828
|
maxGasPerTx,
|
3826
|
-
gasPrice
|
3829
|
+
gasPrice,
|
3830
|
+
baseAssetId
|
3827
3831
|
});
|
3828
3832
|
return transactionSummary;
|
3829
3833
|
}
|
@@ -4011,7 +4015,6 @@ var _Provider = class {
|
|
4011
4015
|
* Constructor to initialize a Provider.
|
4012
4016
|
*
|
4013
4017
|
* @param url - GraphQL endpoint of the Fuel node
|
4014
|
-
* @param chainInfo - Chain info of the Fuel node
|
4015
4018
|
* @param options - Additional options for the provider
|
4016
4019
|
* @hidden
|
4017
4020
|
*/
|
@@ -4034,10 +4037,14 @@ var _Provider = class {
|
|
4034
4037
|
this.operations = this.createOperations();
|
4035
4038
|
this.cache = options.cacheUtxo ? new MemoryCache(options.cacheUtxo) : void 0;
|
4036
4039
|
}
|
4040
|
+
/** @hidden */
|
4037
4041
|
static clearChainAndNodeCaches() {
|
4038
4042
|
_Provider.nodeInfoCache = {};
|
4039
4043
|
_Provider.chainInfoCache = {};
|
4040
4044
|
}
|
4045
|
+
/**
|
4046
|
+
* @hidden
|
4047
|
+
*/
|
4041
4048
|
static getFetchFn(options) {
|
4042
4049
|
const { retryOptions, timeout } = options;
|
4043
4050
|
return autoRetryFetch(async (...args) => {
|
@@ -4053,8 +4060,11 @@ var _Provider = class {
|
|
4053
4060
|
}
|
4054
4061
|
/**
|
4055
4062
|
* Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
|
4063
|
+
*
|
4056
4064
|
* @param url - GraphQL endpoint of the Fuel node
|
4057
4065
|
* @param options - Additional options for the provider
|
4066
|
+
*
|
4067
|
+
* @returns A promise that resolves to a Provider instance.
|
4058
4068
|
*/
|
4059
4069
|
static async create(url, options = {}) {
|
4060
4070
|
const provider = new _Provider(url, options);
|
@@ -4063,6 +4073,8 @@ var _Provider = class {
|
|
4063
4073
|
}
|
4064
4074
|
/**
|
4065
4075
|
* Returns the cached chainInfo for the current URL.
|
4076
|
+
*
|
4077
|
+
* @returns the chain information configuration.
|
4066
4078
|
*/
|
4067
4079
|
getChain() {
|
4068
4080
|
const chain = _Provider.chainInfoCache[this.url];
|
@@ -4076,6 +4088,8 @@ var _Provider = class {
|
|
4076
4088
|
}
|
4077
4089
|
/**
|
4078
4090
|
* Returns the cached nodeInfo for the current URL.
|
4091
|
+
*
|
4092
|
+
* @returns the node information configuration.
|
4079
4093
|
*/
|
4080
4094
|
getNode() {
|
4081
4095
|
const node = _Provider.nodeInfoCache[this.url];
|
@@ -4107,6 +4121,9 @@ var _Provider = class {
|
|
4107
4121
|
}
|
4108
4122
|
/**
|
4109
4123
|
* Updates the URL for the provider and fetches the consensus parameters for the new URL, if needed.
|
4124
|
+
*
|
4125
|
+
* @param url - The URL to connect to.
|
4126
|
+
* @param options - Additional options for the provider.
|
4110
4127
|
*/
|
4111
4128
|
async connect(url, options) {
|
4112
4129
|
this.url = url;
|
@@ -4115,9 +4132,9 @@ var _Provider = class {
|
|
4115
4132
|
await this.fetchChainAndNodeInfo();
|
4116
4133
|
}
|
4117
4134
|
/**
|
4118
|
-
*
|
4135
|
+
* Return the chain and node information.
|
4119
4136
|
*
|
4120
|
-
* @returns
|
4137
|
+
* @returns A promise that resolves to the Chain and NodeInfo.
|
4121
4138
|
*/
|
4122
4139
|
async fetchChainAndNodeInfo() {
|
4123
4140
|
const chain = await this.fetchChain();
|
@@ -4128,6 +4145,9 @@ var _Provider = class {
|
|
4128
4145
|
nodeInfo
|
4129
4146
|
};
|
4130
4147
|
}
|
4148
|
+
/**
|
4149
|
+
* @hidden
|
4150
|
+
*/
|
4131
4151
|
static ensureClientVersionIsSupported(nodeInfo) {
|
4132
4152
|
const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
|
4133
4153
|
if (!isMajorSupported || !isMinorSupported) {
|
@@ -4143,6 +4163,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4143
4163
|
* Create GraphQL client and set operations.
|
4144
4164
|
*
|
4145
4165
|
* @returns The operation SDK object
|
4166
|
+
* @hidden
|
4146
4167
|
*/
|
4147
4168
|
createOperations() {
|
4148
4169
|
const fetchFn = _Provider.getFetchFn(this.options);
|
@@ -4187,18 +4208,18 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4187
4208
|
return nodeVersion;
|
4188
4209
|
}
|
4189
4210
|
/**
|
4190
|
-
* Returns the block number.
|
4211
|
+
* Returns the latest block number.
|
4191
4212
|
*
|
4192
|
-
* @returns A promise that resolves to the block number
|
4213
|
+
* @returns A promise that resolves to the latest block number.
|
4193
4214
|
*/
|
4194
4215
|
async getBlockNumber() {
|
4195
4216
|
const { chain } = await this.operations.getChain();
|
4196
4217
|
return (0, import_math17.bn)(chain.latestBlock.height, 10);
|
4197
4218
|
}
|
4198
4219
|
/**
|
4199
|
-
* Returns the
|
4200
|
-
*
|
4201
|
-
* @returns
|
4220
|
+
* Returns the node information for the current provider network.
|
4221
|
+
*
|
4222
|
+
* @returns a promise that resolves to the node information.
|
4202
4223
|
*/
|
4203
4224
|
async fetchNode() {
|
4204
4225
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
@@ -4213,9 +4234,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4213
4234
|
return processedNodeInfo;
|
4214
4235
|
}
|
4215
4236
|
/**
|
4216
|
-
*
|
4217
|
-
*
|
4218
|
-
* @returns
|
4237
|
+
* Returns the chain information for the current provider network.
|
4238
|
+
*
|
4239
|
+
* @returns a promise that resolves to the chain information.
|
4219
4240
|
*/
|
4220
4241
|
async fetchChain() {
|
4221
4242
|
const { chain } = await this.operations.getChain();
|
@@ -4224,8 +4245,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4224
4245
|
return processedChain;
|
4225
4246
|
}
|
4226
4247
|
/**
|
4227
|
-
* Returns the chain ID
|
4228
|
-
*
|
4248
|
+
* Returns the chain ID for the current provider network.
|
4249
|
+
*
|
4250
|
+
* @returns A promise that resolves to the chain ID number.
|
4229
4251
|
*/
|
4230
4252
|
getChainId() {
|
4231
4253
|
const {
|
@@ -4234,9 +4256,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4234
4256
|
return chainId.toNumber();
|
4235
4257
|
}
|
4236
4258
|
/**
|
4237
|
-
* Returns the base asset ID for the current provider network
|
4259
|
+
* Returns the base asset ID for the current provider network.
|
4238
4260
|
*
|
4239
|
-
* @returns the base asset ID
|
4261
|
+
* @returns the base asset ID.
|
4240
4262
|
*/
|
4241
4263
|
getBaseAssetId() {
|
4242
4264
|
const {
|
@@ -4251,6 +4273,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4251
4273
|
* the transaction will be mutated and those dependencies will be added.
|
4252
4274
|
*
|
4253
4275
|
* @param transactionRequestLike - The transaction request object.
|
4276
|
+
* @param sendTransactionParams - The provider send transaction parameters (optional).
|
4254
4277
|
* @returns A promise that resolves to the transaction response object.
|
4255
4278
|
*/
|
4256
4279
|
// #region Provider-sendTransaction
|
@@ -4295,7 +4318,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4295
4318
|
* the transaction will be mutated and those dependencies will be added.
|
4296
4319
|
*
|
4297
4320
|
* @param transactionRequestLike - The transaction request object.
|
4298
|
-
* @param
|
4321
|
+
* @param sendTransactionParams - The provider call parameters (optional).
|
4299
4322
|
* @returns A promise that resolves to the call result object.
|
4300
4323
|
*/
|
4301
4324
|
async call(transactionRequestLike, { utxoValidation, estimateTxDependencies = true } = {}) {
|
@@ -4315,6 +4338,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4315
4338
|
/**
|
4316
4339
|
* Verifies whether enough gas is available to complete transaction.
|
4317
4340
|
*
|
4341
|
+
* @template T - The type of the transaction request object.
|
4342
|
+
*
|
4318
4343
|
* @param transactionRequest - The transaction request object.
|
4319
4344
|
* @returns A promise that resolves to the estimated transaction request object.
|
4320
4345
|
*/
|
@@ -4349,9 +4374,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4349
4374
|
* If there are missing variable outputs,
|
4350
4375
|
* `addVariableOutputs` is called on the transaction.
|
4351
4376
|
*
|
4352
|
-
*
|
4353
4377
|
* @param transactionRequest - The transaction request object.
|
4354
|
-
* @returns A promise.
|
4378
|
+
* @returns A promise that resolves to the estimate transaction dependencies.
|
4355
4379
|
*/
|
4356
4380
|
async estimateTxDependencies(transactionRequest) {
|
4357
4381
|
if (transactionRequest.type === import_transactions20.TransactionType.Create) {
|
@@ -4464,6 +4488,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4464
4488
|
}
|
4465
4489
|
return results;
|
4466
4490
|
}
|
4491
|
+
/**
|
4492
|
+
* Dry runs multiple transactions.
|
4493
|
+
*
|
4494
|
+
* @param transactionRequests - Array of transaction request objects.
|
4495
|
+
* @param sendTransactionParams - The provider call parameters (optional).
|
4496
|
+
*
|
4497
|
+
* @returns A promise that resolves to an array of results for each transaction call.
|
4498
|
+
*/
|
4467
4499
|
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
4468
4500
|
if (estimateTxDependencies) {
|
4469
4501
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
@@ -4534,6 +4566,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4534
4566
|
* the transaction will be mutated and those dependencies will be added
|
4535
4567
|
*
|
4536
4568
|
* @param transactionRequestLike - The transaction request object.
|
4569
|
+
* @param estimateTxParams - The estimate transaction params (optional).
|
4537
4570
|
* @returns A promise that resolves to the call result object.
|
4538
4571
|
*/
|
4539
4572
|
async simulate(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
@@ -4558,14 +4591,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4558
4591
|
* to set gasLimit and also reserve balance amounts
|
4559
4592
|
* on the the transaction.
|
4560
4593
|
*
|
4561
|
-
* @privateRemarks
|
4562
|
-
* The tolerance is add on top of the gasUsed calculated
|
4563
|
-
* from the node, this create a safe margin costs like
|
4564
|
-
* change states on transfer that don't occur on the dryRun
|
4565
|
-
* transaction. The default value is 0.2 or 20%
|
4566
|
-
*
|
4567
4594
|
* @param transactionRequestLike - The transaction request object.
|
4568
|
-
* @param
|
4595
|
+
* @param transactionCostParams - The transaction cost parameters (optional).
|
4596
|
+
*
|
4569
4597
|
* @returns A promise that resolves to the transaction cost object.
|
4570
4598
|
*/
|
4571
4599
|
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
@@ -4633,6 +4661,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4633
4661
|
updateMaxFee
|
4634
4662
|
};
|
4635
4663
|
}
|
4664
|
+
/**
|
4665
|
+
* Get the required quantities and associated resources for a transaction.
|
4666
|
+
*
|
4667
|
+
* @param owner - address to add resources from.
|
4668
|
+
* @param transactionRequestLike - transaction request to populate resources for.
|
4669
|
+
* @param quantitiesToContract - quantities for the contract (optional).
|
4670
|
+
*
|
4671
|
+
* @returns a promise resolving to the required quantities for the transaction.
|
4672
|
+
*/
|
4636
4673
|
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
4637
4674
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4638
4675
|
const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
|
@@ -4654,6 +4691,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4654
4691
|
}
|
4655
4692
|
/**
|
4656
4693
|
* Returns coins for the given owner.
|
4694
|
+
*
|
4695
|
+
* @param owner - The address to get coins for.
|
4696
|
+
* @param assetId - The asset ID of coins to get (optional).
|
4697
|
+
* @param paginationArgs - Pagination arguments (optional).
|
4698
|
+
*
|
4699
|
+
* @returns A promise that resolves to the coins.
|
4657
4700
|
*/
|
4658
4701
|
async getCoins(owner, assetId, paginationArgs) {
|
4659
4702
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
@@ -4676,8 +4719,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4676
4719
|
* Returns resources for the given owner satisfying the spend query.
|
4677
4720
|
*
|
4678
4721
|
* @param owner - The address to get resources for.
|
4679
|
-
* @param quantities - The quantities to get.
|
4680
|
-
* @param excludedIds - IDs of excluded resources from the selection.
|
4722
|
+
* @param quantities - The coin quantities to get.
|
4723
|
+
* @param excludedIds - IDs of excluded resources from the selection (optional).
|
4681
4724
|
* @returns A promise that resolves to the resources.
|
4682
4725
|
*/
|
4683
4726
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
@@ -4732,7 +4775,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4732
4775
|
* Returns block matching the given ID or height.
|
4733
4776
|
*
|
4734
4777
|
* @param idOrHeight - ID or height of the block.
|
4735
|
-
* @returns A promise that resolves to the block.
|
4778
|
+
* @returns A promise that resolves to the block or null.
|
4736
4779
|
*/
|
4737
4780
|
async getBlock(idOrHeight) {
|
4738
4781
|
let variables;
|
@@ -4862,7 +4905,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4862
4905
|
* Returns balances for the given owner.
|
4863
4906
|
*
|
4864
4907
|
* @param owner - The address to get coins for.
|
4865
|
-
* @param paginationArgs - Pagination arguments.
|
4908
|
+
* @param paginationArgs - Pagination arguments (optional).
|
4866
4909
|
* @returns A promise that resolves to the balances.
|
4867
4910
|
*/
|
4868
4911
|
async getBalances(owner, paginationArgs) {
|
@@ -4881,7 +4924,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4881
4924
|
* Returns message for the given address.
|
4882
4925
|
*
|
4883
4926
|
* @param address - The address to get message from.
|
4884
|
-
* @param paginationArgs - Pagination arguments.
|
4927
|
+
* @param paginationArgs - Pagination arguments (optional).
|
4885
4928
|
* @returns A promise that resolves to the messages.
|
4886
4929
|
*/
|
4887
4930
|
async getMessages(address, paginationArgs) {
|
@@ -4912,8 +4955,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4912
4955
|
*
|
4913
4956
|
* @param transactionId - The transaction to get message from.
|
4914
4957
|
* @param messageId - The message id from MessageOut receipt.
|
4915
|
-
* @param commitBlockId - The commit block id.
|
4916
|
-
* @param commitBlockHeight - The commit block height.
|
4958
|
+
* @param commitBlockId - The commit block id (optional).
|
4959
|
+
* @param commitBlockHeight - The commit block height (optional).
|
4917
4960
|
* @returns A promise that resolves to the message proof.
|
4918
4961
|
*/
|
4919
4962
|
async getMessageProof(transactionId, nonce, commitBlockId, commitBlockHeight) {
|
@@ -5001,10 +5044,21 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5001
5044
|
data
|
5002
5045
|
};
|
5003
5046
|
}
|
5047
|
+
/**
|
5048
|
+
* Get the latest gas price from the node.
|
5049
|
+
*
|
5050
|
+
* @returns A promise that resolves to the latest gas price.
|
5051
|
+
*/
|
5004
5052
|
async getLatestGasPrice() {
|
5005
5053
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
5006
5054
|
return (0, import_math17.bn)(latestGasPrice.gasPrice);
|
5007
5055
|
}
|
5056
|
+
/**
|
5057
|
+
* Returns the estimate gas price for the given block horizon.
|
5058
|
+
*
|
5059
|
+
* @param blockHorizon - The block horizon to estimate gas price for.
|
5060
|
+
* @returns A promise that resolves to the estimated gas price.
|
5061
|
+
*/
|
5008
5062
|
async estimateGasPrice(blockHorizon) {
|
5009
5063
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
5010
5064
|
blockHorizon: String(blockHorizon)
|
@@ -5024,8 +5078,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5024
5078
|
/**
|
5025
5079
|
* Lets you produce blocks with custom timestamps and the block number of the last block produced.
|
5026
5080
|
*
|
5027
|
-
* @param amount - The amount of blocks to produce
|
5028
|
-
* @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block
|
5081
|
+
* @param amount - The amount of blocks to produce.
|
5082
|
+
* @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block (optional).
|
5029
5083
|
* @returns A promise that resolves to the block number of the last produced block.
|
5030
5084
|
*/
|
5031
5085
|
async produceBlocks(amount, startTime) {
|
@@ -5035,6 +5089,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5035
5089
|
});
|
5036
5090
|
return (0, import_math17.bn)(latestBlockHeight);
|
5037
5091
|
}
|
5092
|
+
/**
|
5093
|
+
* Get the transaction response for the given transaction ID.
|
5094
|
+
*
|
5095
|
+
* @param transactionId - The transaction ID to get the response for.
|
5096
|
+
* @returns A promise that resolves to the transaction response.
|
5097
|
+
*/
|
5038
5098
|
// eslint-disable-next-line @typescript-eslint/require-await
|
5039
5099
|
async getTransactionResponse(transactionId) {
|
5040
5100
|
return new TransactionResponse(transactionId, this);
|
@@ -5043,7 +5103,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5043
5103
|
* Returns Message for given nonce.
|
5044
5104
|
*
|
5045
5105
|
* @param nonce - The nonce of the message to retrieve.
|
5046
|
-
* @returns A promise that resolves to the Message object.
|
5106
|
+
* @returns A promise that resolves to the Message object or null.
|
5047
5107
|
*/
|
5048
5108
|
async getMessageByNonce(nonce) {
|
5049
5109
|
const { message } = await this.operations.getMessageByNonce({ nonce });
|
@@ -5052,6 +5112,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5052
5112
|
}
|
5053
5113
|
return message;
|
5054
5114
|
}
|
5115
|
+
/**
|
5116
|
+
* Get the relayed transaction for the given transaction ID.
|
5117
|
+
*
|
5118
|
+
* @param relayedTransactionId - The relayed transaction ID to get the response for.
|
5119
|
+
* @returns A promise that resolves to the relayed transaction.
|
5120
|
+
*/
|
5055
5121
|
async getRelayedTransactionStatus(relayedTransactionId) {
|
5056
5122
|
const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
|
5057
5123
|
relayedTransactionId
|
@@ -5061,6 +5127,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5061
5127
|
}
|
5062
5128
|
return relayedTransactionStatus;
|
5063
5129
|
}
|
5130
|
+
/**
|
5131
|
+
* @hidden
|
5132
|
+
*/
|
5064
5133
|
extractDryRunError(transactionRequest, receipts, dryRunStatus) {
|
5065
5134
|
const status = dryRunStatus;
|
5066
5135
|
let logs = [];
|
@@ -5090,7 +5159,9 @@ cacheInputs_fn = function(inputs) {
|
|
5090
5159
|
}
|
5091
5160
|
});
|
5092
5161
|
};
|
5162
|
+
/** @hidden */
|
5093
5163
|
__publicField(Provider, "chainInfoCache", {});
|
5164
|
+
/** @hidden */
|
5094
5165
|
__publicField(Provider, "nodeInfoCache", {});
|
5095
5166
|
|
5096
5167
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
@@ -5126,6 +5197,7 @@ async function getTransactionSummary(params) {
|
|
5126
5197
|
}
|
5127
5198
|
} = provider.getChain();
|
5128
5199
|
const gasPrice = await provider.getLatestGasPrice();
|
5200
|
+
const baseAssetId = provider.getBaseAssetId();
|
5129
5201
|
const transactionInfo = assembleTransactionSummary({
|
5130
5202
|
id: gqlTransaction.id,
|
5131
5203
|
receipts,
|
@@ -5138,7 +5210,8 @@ async function getTransactionSummary(params) {
|
|
5138
5210
|
maxInputs,
|
5139
5211
|
gasCosts,
|
5140
5212
|
maxGasPerTx,
|
5141
|
-
gasPrice
|
5213
|
+
gasPrice,
|
5214
|
+
baseAssetId
|
5142
5215
|
});
|
5143
5216
|
return {
|
5144
5217
|
gqlTransaction,
|
@@ -5153,6 +5226,7 @@ async function getTransactionSummaryFromRequest(params) {
|
|
5153
5226
|
const transaction = transactionRequest.toTransaction();
|
5154
5227
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
5155
5228
|
const gasPrice = await provider.getLatestGasPrice();
|
5229
|
+
const baseAssetId = provider.getBaseAssetId();
|
5156
5230
|
const transactionSummary = assembleTransactionSummary({
|
5157
5231
|
receipts,
|
5158
5232
|
transaction,
|
@@ -5163,7 +5237,8 @@ async function getTransactionSummaryFromRequest(params) {
|
|
5163
5237
|
maxInputs,
|
5164
5238
|
gasCosts,
|
5165
5239
|
maxGasPerTx,
|
5166
|
-
gasPrice
|
5240
|
+
gasPrice,
|
5241
|
+
baseAssetId
|
5167
5242
|
});
|
5168
5243
|
return transactionSummary;
|
5169
5244
|
}
|
@@ -5179,6 +5254,7 @@ async function getTransactionsSummaries(params) {
|
|
5179
5254
|
}
|
5180
5255
|
} = provider.getChain();
|
5181
5256
|
const gasPrice = await provider.getLatestGasPrice();
|
5257
|
+
const baseAssetId = provider.getBaseAssetId();
|
5182
5258
|
const transactions = edges.map((edge) => {
|
5183
5259
|
const { node: gqlTransaction } = edge;
|
5184
5260
|
const { id, rawPayload, status } = gqlTransaction;
|
@@ -5200,7 +5276,8 @@ async function getTransactionsSummaries(params) {
|
|
5200
5276
|
maxInputs,
|
5201
5277
|
gasCosts,
|
5202
5278
|
maxGasPerTx,
|
5203
|
-
gasPrice
|
5279
|
+
gasPrice,
|
5280
|
+
baseAssetId
|
5204
5281
|
});
|
5205
5282
|
const output = {
|
5206
5283
|
gqlTransaction,
|
@@ -5386,12 +5463,16 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5386
5463
|
* The provider used to interact with the network.
|
5387
5464
|
*/
|
5388
5465
|
_provider;
|
5466
|
+
/**
|
5467
|
+
* The connector for use with external wallets
|
5468
|
+
*/
|
5389
5469
|
_connector;
|
5390
5470
|
/**
|
5391
5471
|
* Creates a new Account instance.
|
5392
5472
|
*
|
5393
5473
|
* @param address - The address of the account.
|
5394
5474
|
* @param provider - A Provider instance (optional).
|
5475
|
+
* @param connector - A FuelConnector instance (optional).
|
5395
5476
|
*/
|
5396
5477
|
constructor(address, provider, connector) {
|
5397
5478
|
super();
|
@@ -5433,8 +5514,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5433
5514
|
/**
|
5434
5515
|
* Retrieves resources satisfying the spend query for the account.
|
5435
5516
|
*
|
5436
|
-
* @param quantities -
|
5437
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
5517
|
+
* @param quantities - Quantities of resources to be obtained.
|
5518
|
+
* @param excludedIds - IDs of resources to be excluded from the query (optional).
|
5438
5519
|
* @returns A promise that resolves to an array of Resources.
|
5439
5520
|
*/
|
5440
5521
|
async getResourcesToSpend(quantities, excludedIds) {
|
@@ -5443,7 +5524,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5443
5524
|
/**
|
5444
5525
|
* Retrieves coins owned by the account.
|
5445
5526
|
*
|
5446
|
-
* @param assetId - The asset ID of the coins to retrieve.
|
5527
|
+
* @param assetId - The asset ID of the coins to retrieve (optional).
|
5447
5528
|
* @returns A promise that resolves to an array of Coins.
|
5448
5529
|
*/
|
5449
5530
|
async getCoins(assetId) {
|
@@ -5496,7 +5577,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5496
5577
|
/**
|
5497
5578
|
* Retrieves the balance of the account for the given asset.
|
5498
5579
|
*
|
5499
|
-
* @param assetId - The asset ID to check the balance for.
|
5580
|
+
* @param assetId - The asset ID to check the balance for (optional).
|
5500
5581
|
* @returns A promise that resolves to the balance amount.
|
5501
5582
|
*/
|
5502
5583
|
async getBalance(assetId) {
|
@@ -5536,7 +5617,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5536
5617
|
* @typeParam T - The type of the TransactionRequest.
|
5537
5618
|
* @param request - The transaction request to fund.
|
5538
5619
|
* @param params - The estimated transaction parameters.
|
5539
|
-
* @returns
|
5620
|
+
* @returns A promise that resolves to the funded transaction request.
|
5540
5621
|
*/
|
5541
5622
|
async fund(request, params) {
|
5542
5623
|
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
|
@@ -5629,25 +5710,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5629
5710
|
*
|
5630
5711
|
* @param destination - The address of the destination.
|
5631
5712
|
* @param amount - The amount of coins to transfer.
|
5632
|
-
* @param assetId - The asset ID of the coins to transfer.
|
5633
|
-
* @param txParams - The transaction parameters (
|
5713
|
+
* @param assetId - The asset ID of the coins to transfer (optional).
|
5714
|
+
* @param txParams - The transaction parameters (optional).
|
5634
5715
|
* @returns A promise that resolves to the prepared transaction request.
|
5635
5716
|
*/
|
5636
5717
|
async createTransfer(destination, amount, assetId, txParams = {}) {
|
5637
5718
|
let request = new ScriptTransactionRequest(txParams);
|
5638
|
-
|
5639
|
-
request.
|
5640
|
-
const txCost = await this.provider.getTransactionCost(request, {
|
5641
|
-
estimateTxDependencies: true,
|
5642
|
-
resourcesOwner: this
|
5643
|
-
});
|
5644
|
-
request = this.validateGasLimitAndMaxFee({
|
5645
|
-
transactionRequest: request,
|
5646
|
-
gasUsed: txCost.gasUsed,
|
5647
|
-
maxFee: txCost.maxFee,
|
5648
|
-
txParams
|
5649
|
-
});
|
5650
|
-
await this.fund(request, txCost);
|
5719
|
+
request = this.addTransfer(request, { destination, amount, assetId });
|
5720
|
+
request = await this.estimateAndFundTransaction(request, txParams);
|
5651
5721
|
return request;
|
5652
5722
|
}
|
5653
5723
|
/**
|
@@ -5655,28 +5725,69 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5655
5725
|
*
|
5656
5726
|
* @param destination - The address of the destination.
|
5657
5727
|
* @param amount - The amount of coins to transfer.
|
5658
|
-
* @param assetId - The asset ID of the coins to transfer.
|
5659
|
-
* @param txParams - The transaction parameters (
|
5728
|
+
* @param assetId - The asset ID of the coins to transfer (optional).
|
5729
|
+
* @param txParams - The transaction parameters (optional).
|
5660
5730
|
* @returns A promise that resolves to the transaction response.
|
5661
5731
|
*/
|
5662
5732
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5663
|
-
|
5664
|
-
|
5665
|
-
|
5666
|
-
|
5667
|
-
|
5668
|
-
|
5669
|
-
|
5670
|
-
|
5733
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
5734
|
+
return this.sendTransaction(request, { estimateTxDependencies: false });
|
5735
|
+
}
|
5736
|
+
/**
|
5737
|
+
* Transfers multiple amounts of a token to multiple recipients.
|
5738
|
+
*
|
5739
|
+
* @param transferParams - An array of `TransferParams` objects representing the transfers to be made.
|
5740
|
+
* @param txParams - Optional transaction parameters.
|
5741
|
+
* @returns A promise that resolves to a `TransactionResponse` object representing the transaction result.
|
5742
|
+
*/
|
5743
|
+
async batchTransfer(transferParams, txParams = {}) {
|
5744
|
+
let request = new ScriptTransactionRequest(txParams);
|
5745
|
+
request = this.addBatchTransfer(request, transferParams);
|
5746
|
+
request = await this.estimateAndFundTransaction(request, txParams);
|
5671
5747
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
5672
5748
|
}
|
5749
|
+
/**
|
5750
|
+
* Adds a transfer to the given transaction request.
|
5751
|
+
*
|
5752
|
+
* @param request - The script transaction request to add transfers to.
|
5753
|
+
* @param transferParams - The object representing the transfer to be made.
|
5754
|
+
* @returns The updated transaction request with the added transfer.
|
5755
|
+
*/
|
5756
|
+
addTransfer(request, transferParams) {
|
5757
|
+
const { destination, amount, assetId } = transferParams;
|
5758
|
+
this.validateTransferAmount(amount);
|
5759
|
+
request.addCoinOutput(
|
5760
|
+
import_address4.Address.fromAddressOrString(destination),
|
5761
|
+
amount,
|
5762
|
+
assetId ?? this.provider.getBaseAssetId()
|
5763
|
+
);
|
5764
|
+
return request;
|
5765
|
+
}
|
5766
|
+
/**
|
5767
|
+
* Adds multiple transfers to a script transaction request.
|
5768
|
+
*
|
5769
|
+
* @param request - The script transaction request to add transfers to.
|
5770
|
+
* @param transferParams - An array of `TransferParams` objects representing the transfers to be made.
|
5771
|
+
* @returns The updated script transaction request.
|
5772
|
+
*/
|
5773
|
+
addBatchTransfer(request, transferParams) {
|
5774
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
5775
|
+
transferParams.forEach(({ destination, amount, assetId }) => {
|
5776
|
+
this.addTransfer(request, {
|
5777
|
+
destination,
|
5778
|
+
amount,
|
5779
|
+
assetId: assetId ?? baseAssetId
|
5780
|
+
});
|
5781
|
+
});
|
5782
|
+
return request;
|
5783
|
+
}
|
5673
5784
|
/**
|
5674
5785
|
* Transfers coins to a contract address.
|
5675
5786
|
*
|
5676
5787
|
* @param contractId - The address of the contract.
|
5677
5788
|
* @param amount - The amount of coins to transfer.
|
5678
|
-
* @param assetId - The asset ID of the coins to transfer.
|
5679
|
-
* @param txParams - The
|
5789
|
+
* @param assetId - The asset ID of the coins to transfer (optional).
|
5790
|
+
* @param txParams - The transaction parameters (optional).
|
5680
5791
|
* @returns A promise that resolves to the transaction response.
|
5681
5792
|
*/
|
5682
5793
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
@@ -5717,7 +5828,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5717
5828
|
*
|
5718
5829
|
* @param recipient - Address of the recipient on the base chain.
|
5719
5830
|
* @param amount - Amount of base asset.
|
5720
|
-
* @param txParams - The
|
5831
|
+
* @param txParams - The transaction parameters (optional).
|
5721
5832
|
* @returns A promise that resolves to the transaction response.
|
5722
5833
|
*/
|
5723
5834
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
@@ -5747,6 +5858,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5747
5858
|
await this.fund(request, txCost);
|
5748
5859
|
return this.sendTransaction(request);
|
5749
5860
|
}
|
5861
|
+
/**
|
5862
|
+
* Sign a message from the account via the connector.
|
5863
|
+
*
|
5864
|
+
* @param message - the message to sign.
|
5865
|
+
* @returns a promise that resolves to the signature.
|
5866
|
+
*
|
5867
|
+
* @hidden
|
5868
|
+
*/
|
5750
5869
|
async signMessage(message) {
|
5751
5870
|
if (!this._connector) {
|
5752
5871
|
throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
@@ -5754,7 +5873,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5754
5873
|
return this._connector.signMessage(this.address.toString(), message);
|
5755
5874
|
}
|
5756
5875
|
/**
|
5757
|
-
* Signs a transaction
|
5876
|
+
* Signs a transaction from the account via the connector..
|
5758
5877
|
*
|
5759
5878
|
* @param transactionRequestLike - The transaction request to sign.
|
5760
5879
|
* @returns A promise that resolves to the signature of the transaction.
|
@@ -5772,6 +5891,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5772
5891
|
* Sends a transaction to the network.
|
5773
5892
|
*
|
5774
5893
|
* @param transactionRequestLike - The transaction request to be sent.
|
5894
|
+
* @param sendTransactionParams - The provider send transaction parameters (optional).
|
5775
5895
|
* @returns A promise that resolves to the transaction response.
|
5776
5896
|
*/
|
5777
5897
|
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
@@ -5793,6 +5913,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5793
5913
|
* Simulates a transaction.
|
5794
5914
|
*
|
5795
5915
|
* @param transactionRequestLike - The transaction request to be simulated.
|
5916
|
+
* @param estimateTxParams - The estimate transaction params (optional).
|
5796
5917
|
* @returns A promise that resolves to the call result.
|
5797
5918
|
*/
|
5798
5919
|
async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
@@ -5802,6 +5923,31 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5802
5923
|
}
|
5803
5924
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5804
5925
|
}
|
5926
|
+
/** @hidden * */
|
5927
|
+
validateTransferAmount(amount) {
|
5928
|
+
if ((0, import_math20.bn)(amount).lte(0)) {
|
5929
|
+
throw new import_errors16.FuelError(
|
5930
|
+
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5931
|
+
"Transfer amount must be a positive number."
|
5932
|
+
);
|
5933
|
+
}
|
5934
|
+
}
|
5935
|
+
/** @hidden * */
|
5936
|
+
async estimateAndFundTransaction(transactionRequest, txParams) {
|
5937
|
+
let request = transactionRequest;
|
5938
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
5939
|
+
resourcesOwner: this
|
5940
|
+
});
|
5941
|
+
request = this.validateGasLimitAndMaxFee({
|
5942
|
+
transactionRequest: request,
|
5943
|
+
gasUsed: txCost.gasUsed,
|
5944
|
+
maxFee: txCost.maxFee,
|
5945
|
+
txParams
|
5946
|
+
});
|
5947
|
+
request = await this.fund(request, txCost);
|
5948
|
+
return request;
|
5949
|
+
}
|
5950
|
+
/** @hidden * */
|
5805
5951
|
validateGasLimitAndMaxFee({
|
5806
5952
|
gasUsed,
|
5807
5953
|
maxFee,
|
@@ -6105,6 +6251,8 @@ var BaseWalletUnlocked = class extends Account {
|
|
6105
6251
|
* Populates the witness signature for a transaction and sends it to the network using `provider.sendTransaction`.
|
6106
6252
|
*
|
6107
6253
|
* @param transactionRequestLike - The transaction request to send.
|
6254
|
+
* @param estimateTxDependencies - Whether to estimate the transaction dependencies.
|
6255
|
+
* @param awaitExecution - Whether to wait for the transaction to be executed.
|
6108
6256
|
* @returns A promise that resolves to the TransactionResponse object.
|
6109
6257
|
*/
|
6110
6258
|
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
|
@@ -6136,6 +6284,12 @@ var BaseWalletUnlocked = class extends Account {
|
|
6136
6284
|
}
|
6137
6285
|
);
|
6138
6286
|
}
|
6287
|
+
/**
|
6288
|
+
* Encrypts an unlocked wallet with a password.
|
6289
|
+
*
|
6290
|
+
* @param password - the password to encrypt the wallet with.
|
6291
|
+
* @returns - the encrypted wallet.
|
6292
|
+
*/
|
6139
6293
|
async encrypt(password) {
|
6140
6294
|
return encryptKeystoreWallet(this.privateKey, this.address, password);
|
6141
6295
|
}
|
@@ -9413,7 +9567,8 @@ var Predicate = class extends Account {
|
|
9413
9567
|
);
|
9414
9568
|
return resources.map((resource) => ({
|
9415
9569
|
...resource,
|
9416
|
-
predicate: (0, import_utils37.hexlify)(this.bytes)
|
9570
|
+
predicate: (0, import_utils37.hexlify)(this.bytes),
|
9571
|
+
predicateData: (0, import_utils37.hexlify)(this.getPredicateData())
|
9417
9572
|
}));
|
9418
9573
|
}
|
9419
9574
|
/**
|