@fuel-ts/account 0.0.0-rc-1356-20240522164420 → 0.0.0-rc-1356-20240523144307
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 +32 -49
- package/dist/account.d.ts.map +1 -1
- package/dist/index.global.js +144 -49
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +144 -49
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +144 -49
- package/dist/index.mjs.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/test-utils.global.js +144 -49
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +144 -49
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +144 -49
- 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.mjs
CHANGED
@@ -2697,6 +2697,13 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2697
2697
|
}
|
2698
2698
|
return this.outputs.length - 1;
|
2699
2699
|
}
|
2700
|
+
/**
|
2701
|
+
* Calculates the maximum gas for the transaction.
|
2702
|
+
*
|
2703
|
+
* @param chainInfo - The chain information.
|
2704
|
+
* @param minGas - The minimum gas.
|
2705
|
+
* @returns the maximum gas.
|
2706
|
+
*/
|
2700
2707
|
calculateMaxGas(chainInfo, minGas) {
|
2701
2708
|
const { consensusParameters } = chainInfo;
|
2702
2709
|
const {
|
@@ -3860,7 +3867,6 @@ var _Provider = class {
|
|
3860
3867
|
* Constructor to initialize a Provider.
|
3861
3868
|
*
|
3862
3869
|
* @param url - GraphQL endpoint of the Fuel node
|
3863
|
-
* @param chainInfo - Chain info of the Fuel node
|
3864
3870
|
* @param options - Additional options for the provider
|
3865
3871
|
* @hidden
|
3866
3872
|
*/
|
@@ -3883,10 +3889,14 @@ var _Provider = class {
|
|
3883
3889
|
this.operations = this.createOperations();
|
3884
3890
|
this.cache = options.cacheUtxo ? new MemoryCache(options.cacheUtxo) : void 0;
|
3885
3891
|
}
|
3892
|
+
/** @hidden */
|
3886
3893
|
static clearChainAndNodeCaches() {
|
3887
3894
|
_Provider.nodeInfoCache = {};
|
3888
3895
|
_Provider.chainInfoCache = {};
|
3889
3896
|
}
|
3897
|
+
/**
|
3898
|
+
* @hidden
|
3899
|
+
*/
|
3890
3900
|
static getFetchFn(options) {
|
3891
3901
|
const { retryOptions, timeout } = options;
|
3892
3902
|
return autoRetryFetch(async (...args) => {
|
@@ -3902,8 +3912,11 @@ var _Provider = class {
|
|
3902
3912
|
}
|
3903
3913
|
/**
|
3904
3914
|
* Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
|
3915
|
+
*
|
3905
3916
|
* @param url - GraphQL endpoint of the Fuel node
|
3906
3917
|
* @param options - Additional options for the provider
|
3918
|
+
*
|
3919
|
+
* @returns A promise that resolves to a Provider instance.
|
3907
3920
|
*/
|
3908
3921
|
static async create(url, options = {}) {
|
3909
3922
|
const provider = new _Provider(url, options);
|
@@ -3912,6 +3925,8 @@ var _Provider = class {
|
|
3912
3925
|
}
|
3913
3926
|
/**
|
3914
3927
|
* Returns the cached chainInfo for the current URL.
|
3928
|
+
*
|
3929
|
+
* @returns the chain information configuration.
|
3915
3930
|
*/
|
3916
3931
|
getChain() {
|
3917
3932
|
const chain = _Provider.chainInfoCache[this.url];
|
@@ -3925,6 +3940,8 @@ var _Provider = class {
|
|
3925
3940
|
}
|
3926
3941
|
/**
|
3927
3942
|
* Returns the cached nodeInfo for the current URL.
|
3943
|
+
*
|
3944
|
+
* @returns the node information configuration.
|
3928
3945
|
*/
|
3929
3946
|
getNode() {
|
3930
3947
|
const node = _Provider.nodeInfoCache[this.url];
|
@@ -3956,6 +3973,9 @@ var _Provider = class {
|
|
3956
3973
|
}
|
3957
3974
|
/**
|
3958
3975
|
* Updates the URL for the provider and fetches the consensus parameters for the new URL, if needed.
|
3976
|
+
*
|
3977
|
+
* @param url - The URL to connect to.
|
3978
|
+
* @param options - Additional options for the provider.
|
3959
3979
|
*/
|
3960
3980
|
async connect(url, options) {
|
3961
3981
|
this.url = url;
|
@@ -3964,9 +3984,9 @@ var _Provider = class {
|
|
3964
3984
|
await this.fetchChainAndNodeInfo();
|
3965
3985
|
}
|
3966
3986
|
/**
|
3967
|
-
*
|
3987
|
+
* Return the chain and node information.
|
3968
3988
|
*
|
3969
|
-
* @returns
|
3989
|
+
* @returns A promise that resolves to the Chain and NodeInfo.
|
3970
3990
|
*/
|
3971
3991
|
async fetchChainAndNodeInfo() {
|
3972
3992
|
const chain = await this.fetchChain();
|
@@ -3977,6 +3997,9 @@ var _Provider = class {
|
|
3977
3997
|
nodeInfo
|
3978
3998
|
};
|
3979
3999
|
}
|
4000
|
+
/**
|
4001
|
+
* @hidden
|
4002
|
+
*/
|
3980
4003
|
static ensureClientVersionIsSupported(nodeInfo) {
|
3981
4004
|
const { isMajorSupported, isMinorSupported, supportedVersion } = checkFuelCoreVersionCompatibility(nodeInfo.nodeVersion);
|
3982
4005
|
if (!isMajorSupported || !isMinorSupported) {
|
@@ -3992,6 +4015,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
3992
4015
|
* Create GraphQL client and set operations.
|
3993
4016
|
*
|
3994
4017
|
* @returns The operation SDK object
|
4018
|
+
* @hidden
|
3995
4019
|
*/
|
3996
4020
|
createOperations() {
|
3997
4021
|
const fetchFn = _Provider.getFetchFn(this.options);
|
@@ -4036,18 +4060,18 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4036
4060
|
return nodeVersion;
|
4037
4061
|
}
|
4038
4062
|
/**
|
4039
|
-
* Returns the block number.
|
4063
|
+
* Returns the latest block number.
|
4040
4064
|
*
|
4041
|
-
* @returns A promise that resolves to the block number
|
4065
|
+
* @returns A promise that resolves to the latest block number.
|
4042
4066
|
*/
|
4043
4067
|
async getBlockNumber() {
|
4044
4068
|
const { chain } = await this.operations.getChain();
|
4045
4069
|
return bn17(chain.latestBlock.height, 10);
|
4046
4070
|
}
|
4047
4071
|
/**
|
4048
|
-
* Returns the
|
4049
|
-
*
|
4050
|
-
* @returns
|
4072
|
+
* Returns the node information for the current provider network.
|
4073
|
+
*
|
4074
|
+
* @returns a promise that resolves to the node information.
|
4051
4075
|
*/
|
4052
4076
|
async fetchNode() {
|
4053
4077
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
@@ -4062,9 +4086,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4062
4086
|
return processedNodeInfo;
|
4063
4087
|
}
|
4064
4088
|
/**
|
4065
|
-
*
|
4066
|
-
*
|
4067
|
-
* @returns
|
4089
|
+
* Returns the chain information for the current provider network.
|
4090
|
+
*
|
4091
|
+
* @returns a promise that resolves to the chain information.
|
4068
4092
|
*/
|
4069
4093
|
async fetchChain() {
|
4070
4094
|
const { chain } = await this.operations.getChain();
|
@@ -4073,8 +4097,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4073
4097
|
return processedChain;
|
4074
4098
|
}
|
4075
4099
|
/**
|
4076
|
-
* Returns the chain ID
|
4077
|
-
*
|
4100
|
+
* Returns the chain ID for the current provider network.
|
4101
|
+
*
|
4102
|
+
* @returns A promise that resolves to the chain ID number.
|
4078
4103
|
*/
|
4079
4104
|
getChainId() {
|
4080
4105
|
const {
|
@@ -4083,9 +4108,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4083
4108
|
return chainId.toNumber();
|
4084
4109
|
}
|
4085
4110
|
/**
|
4086
|
-
* Returns the base asset ID for the current provider network
|
4111
|
+
* Returns the base asset ID for the current provider network.
|
4087
4112
|
*
|
4088
|
-
* @returns the base asset ID
|
4113
|
+
* @returns the base asset ID.
|
4089
4114
|
*/
|
4090
4115
|
getBaseAssetId() {
|
4091
4116
|
const {
|
@@ -4100,6 +4125,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4100
4125
|
* the transaction will be mutated and those dependencies will be added.
|
4101
4126
|
*
|
4102
4127
|
* @param transactionRequestLike - The transaction request object.
|
4128
|
+
* @param sendTransactionParams - The provider send transaction parameters (optional).
|
4103
4129
|
* @returns A promise that resolves to the transaction response object.
|
4104
4130
|
*/
|
4105
4131
|
// #region Provider-sendTransaction
|
@@ -4144,7 +4170,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4144
4170
|
* the transaction will be mutated and those dependencies will be added.
|
4145
4171
|
*
|
4146
4172
|
* @param transactionRequestLike - The transaction request object.
|
4147
|
-
* @param
|
4173
|
+
* @param sendTransactionParams - The provider call parameters (optional).
|
4148
4174
|
* @returns A promise that resolves to the call result object.
|
4149
4175
|
*/
|
4150
4176
|
async call(transactionRequestLike, { utxoValidation, estimateTxDependencies = true } = {}) {
|
@@ -4164,6 +4190,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4164
4190
|
/**
|
4165
4191
|
* Verifies whether enough gas is available to complete transaction.
|
4166
4192
|
*
|
4193
|
+
* @template T - The type of the transaction request object.
|
4194
|
+
*
|
4167
4195
|
* @param transactionRequest - The transaction request object.
|
4168
4196
|
* @returns A promise that resolves to the estimated transaction request object.
|
4169
4197
|
*/
|
@@ -4198,9 +4226,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4198
4226
|
* If there are missing variable outputs,
|
4199
4227
|
* `addVariableOutputs` is called on the transaction.
|
4200
4228
|
*
|
4201
|
-
*
|
4202
4229
|
* @param transactionRequest - The transaction request object.
|
4203
|
-
* @returns A promise.
|
4230
|
+
* @returns A promise that resolves to the estimate transaction dependencies.
|
4204
4231
|
*/
|
4205
4232
|
async estimateTxDependencies(transactionRequest) {
|
4206
4233
|
if (transactionRequest.type === TransactionType8.Create) {
|
@@ -4313,6 +4340,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4313
4340
|
}
|
4314
4341
|
return results;
|
4315
4342
|
}
|
4343
|
+
/**
|
4344
|
+
* Dry runs multiple transactions.
|
4345
|
+
*
|
4346
|
+
* @param transactionRequests - Array of transaction request objects.
|
4347
|
+
* @param sendTransactionParams - The provider call parameters (optional).
|
4348
|
+
*
|
4349
|
+
* @returns A promise that resolves to an array of results for each transaction call.
|
4350
|
+
*/
|
4316
4351
|
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
4317
4352
|
if (estimateTxDependencies) {
|
4318
4353
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
@@ -4383,6 +4418,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4383
4418
|
* the transaction will be mutated and those dependencies will be added
|
4384
4419
|
*
|
4385
4420
|
* @param transactionRequestLike - The transaction request object.
|
4421
|
+
* @param estimateTxParams - The estimate transaction params (optional).
|
4386
4422
|
* @returns A promise that resolves to the call result object.
|
4387
4423
|
*/
|
4388
4424
|
async simulate(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
@@ -4407,14 +4443,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4407
4443
|
* to set gasLimit and also reserve balance amounts
|
4408
4444
|
* on the the transaction.
|
4409
4445
|
*
|
4410
|
-
* @privateRemarks
|
4411
|
-
* The tolerance is add on top of the gasUsed calculated
|
4412
|
-
* from the node, this create a safe margin costs like
|
4413
|
-
* change states on transfer that don't occur on the dryRun
|
4414
|
-
* transaction. The default value is 0.2 or 20%
|
4415
|
-
*
|
4416
4446
|
* @param transactionRequestLike - The transaction request object.
|
4417
|
-
* @param
|
4447
|
+
* @param transactionCostParams - The transaction cost parameters (optional).
|
4448
|
+
*
|
4418
4449
|
* @returns A promise that resolves to the transaction cost object.
|
4419
4450
|
*/
|
4420
4451
|
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
@@ -4482,6 +4513,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4482
4513
|
updateMaxFee
|
4483
4514
|
};
|
4484
4515
|
}
|
4516
|
+
/**
|
4517
|
+
* Get the required quantities and associated resources for a transaction.
|
4518
|
+
*
|
4519
|
+
* @param owner - address to add resources from.
|
4520
|
+
* @param transactionRequestLike - transaction request to populate resources for.
|
4521
|
+
* @param quantitiesToContract - quantities for the contract (optional).
|
4522
|
+
*
|
4523
|
+
* @returns a promise resolving to the required quantities for the transaction.
|
4524
|
+
*/
|
4485
4525
|
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
4486
4526
|
const ownerAddress = Address2.fromAddressOrString(owner);
|
4487
4527
|
const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
|
@@ -4503,6 +4543,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4503
4543
|
}
|
4504
4544
|
/**
|
4505
4545
|
* Returns coins for the given owner.
|
4546
|
+
*
|
4547
|
+
* @param owner - The address to get coins for.
|
4548
|
+
* @param assetId - The asset ID of coins to get (optional).
|
4549
|
+
* @param paginationArgs - Pagination arguments (optional).
|
4550
|
+
*
|
4551
|
+
* @returns A promise that resolves to the coins.
|
4506
4552
|
*/
|
4507
4553
|
async getCoins(owner, assetId, paginationArgs) {
|
4508
4554
|
const ownerAddress = Address2.fromAddressOrString(owner);
|
@@ -4525,8 +4571,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4525
4571
|
* Returns resources for the given owner satisfying the spend query.
|
4526
4572
|
*
|
4527
4573
|
* @param owner - The address to get resources for.
|
4528
|
-
* @param quantities - The quantities to get.
|
4529
|
-
* @param excludedIds - IDs of excluded resources from the selection.
|
4574
|
+
* @param quantities - The coin quantities to get.
|
4575
|
+
* @param excludedIds - IDs of excluded resources from the selection (optional).
|
4530
4576
|
* @returns A promise that resolves to the resources.
|
4531
4577
|
*/
|
4532
4578
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
@@ -4581,7 +4627,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4581
4627
|
* Returns block matching the given ID or height.
|
4582
4628
|
*
|
4583
4629
|
* @param idOrHeight - ID or height of the block.
|
4584
|
-
* @returns A promise that resolves to the block.
|
4630
|
+
* @returns A promise that resolves to the block or null.
|
4585
4631
|
*/
|
4586
4632
|
async getBlock(idOrHeight) {
|
4587
4633
|
let variables;
|
@@ -4711,7 +4757,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4711
4757
|
* Returns balances for the given owner.
|
4712
4758
|
*
|
4713
4759
|
* @param owner - The address to get coins for.
|
4714
|
-
* @param paginationArgs - Pagination arguments.
|
4760
|
+
* @param paginationArgs - Pagination arguments (optional).
|
4715
4761
|
* @returns A promise that resolves to the balances.
|
4716
4762
|
*/
|
4717
4763
|
async getBalances(owner, paginationArgs) {
|
@@ -4730,7 +4776,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4730
4776
|
* Returns message for the given address.
|
4731
4777
|
*
|
4732
4778
|
* @param address - The address to get message from.
|
4733
|
-
* @param paginationArgs - Pagination arguments.
|
4779
|
+
* @param paginationArgs - Pagination arguments (optional).
|
4734
4780
|
* @returns A promise that resolves to the messages.
|
4735
4781
|
*/
|
4736
4782
|
async getMessages(address, paginationArgs) {
|
@@ -4761,8 +4807,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4761
4807
|
*
|
4762
4808
|
* @param transactionId - The transaction to get message from.
|
4763
4809
|
* @param messageId - The message id from MessageOut receipt.
|
4764
|
-
* @param commitBlockId - The commit block id.
|
4765
|
-
* @param commitBlockHeight - The commit block height.
|
4810
|
+
* @param commitBlockId - The commit block id (optional).
|
4811
|
+
* @param commitBlockHeight - The commit block height (optional).
|
4766
4812
|
* @returns A promise that resolves to the message proof.
|
4767
4813
|
*/
|
4768
4814
|
async getMessageProof(transactionId, nonce, commitBlockId, commitBlockHeight) {
|
@@ -4850,10 +4896,21 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4850
4896
|
data
|
4851
4897
|
};
|
4852
4898
|
}
|
4899
|
+
/**
|
4900
|
+
* Get the latest gas price from the node.
|
4901
|
+
*
|
4902
|
+
* @returns A promise that resolves to the latest gas price.
|
4903
|
+
*/
|
4853
4904
|
async getLatestGasPrice() {
|
4854
4905
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4855
4906
|
return bn17(latestGasPrice.gasPrice);
|
4856
4907
|
}
|
4908
|
+
/**
|
4909
|
+
* Returns the estimate gas price for the given block horizon.
|
4910
|
+
*
|
4911
|
+
* @param blockHorizon - The block horizon to estimate gas price for.
|
4912
|
+
* @returns A promise that resolves to the estimated gas price.
|
4913
|
+
*/
|
4857
4914
|
async estimateGasPrice(blockHorizon) {
|
4858
4915
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4859
4916
|
blockHorizon: String(blockHorizon)
|
@@ -4873,8 +4930,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4873
4930
|
/**
|
4874
4931
|
* Lets you produce blocks with custom timestamps and the block number of the last block produced.
|
4875
4932
|
*
|
4876
|
-
* @param amount - The amount of blocks to produce
|
4877
|
-
* @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block
|
4933
|
+
* @param amount - The amount of blocks to produce.
|
4934
|
+
* @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block (optional).
|
4878
4935
|
* @returns A promise that resolves to the block number of the last produced block.
|
4879
4936
|
*/
|
4880
4937
|
async produceBlocks(amount, startTime) {
|
@@ -4884,6 +4941,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4884
4941
|
});
|
4885
4942
|
return bn17(latestBlockHeight);
|
4886
4943
|
}
|
4944
|
+
/**
|
4945
|
+
* Get the transaction response for the given transaction ID.
|
4946
|
+
*
|
4947
|
+
* @param transactionId - The transaction ID to get the response for.
|
4948
|
+
* @returns A promise that resolves to the transaction response.
|
4949
|
+
*/
|
4887
4950
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4888
4951
|
async getTransactionResponse(transactionId) {
|
4889
4952
|
return new TransactionResponse(transactionId, this);
|
@@ -4892,7 +4955,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4892
4955
|
* Returns Message for given nonce.
|
4893
4956
|
*
|
4894
4957
|
* @param nonce - The nonce of the message to retrieve.
|
4895
|
-
* @returns A promise that resolves to the Message object.
|
4958
|
+
* @returns A promise that resolves to the Message object or null.
|
4896
4959
|
*/
|
4897
4960
|
async getMessageByNonce(nonce) {
|
4898
4961
|
const { message } = await this.operations.getMessageByNonce({ nonce });
|
@@ -4901,6 +4964,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4901
4964
|
}
|
4902
4965
|
return message;
|
4903
4966
|
}
|
4967
|
+
/**
|
4968
|
+
* Get the relayed transaction for the given transaction ID.
|
4969
|
+
*
|
4970
|
+
* @param relayedTransactionId - The relayed transaction ID to get the response for.
|
4971
|
+
* @returns A promise that resolves to the relayed transaction.
|
4972
|
+
*/
|
4904
4973
|
async getRelayedTransactionStatus(relayedTransactionId) {
|
4905
4974
|
const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
|
4906
4975
|
relayedTransactionId
|
@@ -4910,6 +4979,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4910
4979
|
}
|
4911
4980
|
return relayedTransactionStatus;
|
4912
4981
|
}
|
4982
|
+
/**
|
4983
|
+
* @hidden
|
4984
|
+
*/
|
4913
4985
|
extractDryRunError(transactionRequest, receipts, dryRunStatus) {
|
4914
4986
|
const status = dryRunStatus;
|
4915
4987
|
let logs = [];
|
@@ -4939,7 +5011,9 @@ cacheInputs_fn = function(inputs) {
|
|
4939
5011
|
}
|
4940
5012
|
});
|
4941
5013
|
};
|
5014
|
+
/** @hidden */
|
4942
5015
|
__publicField(Provider, "chainInfoCache", {});
|
5016
|
+
/** @hidden */
|
4943
5017
|
__publicField(Provider, "nodeInfoCache", {});
|
4944
5018
|
|
4945
5019
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
@@ -5235,12 +5309,16 @@ var Account = class extends AbstractAccount {
|
|
5235
5309
|
* The provider used to interact with the network.
|
5236
5310
|
*/
|
5237
5311
|
_provider;
|
5312
|
+
/**
|
5313
|
+
* The connector for use with external wallets
|
5314
|
+
*/
|
5238
5315
|
_connector;
|
5239
5316
|
/**
|
5240
5317
|
* Creates a new Account instance.
|
5241
5318
|
*
|
5242
5319
|
* @param address - The address of the account.
|
5243
5320
|
* @param provider - A Provider instance (optional).
|
5321
|
+
* @param connector - A FuelConnector instance (optional).
|
5244
5322
|
*/
|
5245
5323
|
constructor(address, provider, connector) {
|
5246
5324
|
super();
|
@@ -5282,8 +5360,8 @@ var Account = class extends AbstractAccount {
|
|
5282
5360
|
/**
|
5283
5361
|
* Retrieves resources satisfying the spend query for the account.
|
5284
5362
|
*
|
5285
|
-
* @param quantities -
|
5286
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
5363
|
+
* @param quantities - Quantities of resources to be obtained.
|
5364
|
+
* @param excludedIds - IDs of resources to be excluded from the query (optional).
|
5287
5365
|
* @returns A promise that resolves to an array of Resources.
|
5288
5366
|
*/
|
5289
5367
|
async getResourcesToSpend(quantities, excludedIds) {
|
@@ -5292,7 +5370,7 @@ var Account = class extends AbstractAccount {
|
|
5292
5370
|
/**
|
5293
5371
|
* Retrieves coins owned by the account.
|
5294
5372
|
*
|
5295
|
-
* @param assetId - The asset ID of the coins to retrieve.
|
5373
|
+
* @param assetId - The asset ID of the coins to retrieve (optional).
|
5296
5374
|
* @returns A promise that resolves to an array of Coins.
|
5297
5375
|
*/
|
5298
5376
|
async getCoins(assetId) {
|
@@ -5345,7 +5423,7 @@ var Account = class extends AbstractAccount {
|
|
5345
5423
|
/**
|
5346
5424
|
* Retrieves the balance of the account for the given asset.
|
5347
5425
|
*
|
5348
|
-
* @param assetId - The asset ID to check the balance for.
|
5426
|
+
* @param assetId - The asset ID to check the balance for (optional).
|
5349
5427
|
* @returns A promise that resolves to the balance amount.
|
5350
5428
|
*/
|
5351
5429
|
async getBalance(assetId) {
|
@@ -5385,7 +5463,7 @@ var Account = class extends AbstractAccount {
|
|
5385
5463
|
* @typeParam T - The type of the TransactionRequest.
|
5386
5464
|
* @param request - The transaction request to fund.
|
5387
5465
|
* @param params - The estimated transaction parameters.
|
5388
|
-
* @returns
|
5466
|
+
* @returns A promise that resolves to the funded transaction request.
|
5389
5467
|
*/
|
5390
5468
|
async fund(request, params) {
|
5391
5469
|
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
|
@@ -5478,8 +5556,8 @@ var Account = class extends AbstractAccount {
|
|
5478
5556
|
*
|
5479
5557
|
* @param destination - The address of the destination.
|
5480
5558
|
* @param amount - The amount of coins to transfer.
|
5481
|
-
* @param assetId - The asset ID of the coins to transfer.
|
5482
|
-
* @param txParams - The transaction parameters (
|
5559
|
+
* @param assetId - The asset ID of the coins to transfer (optional).
|
5560
|
+
* @param txParams - The transaction parameters (optional).
|
5483
5561
|
* @returns A promise that resolves to the prepared transaction request.
|
5484
5562
|
*/
|
5485
5563
|
async createTransfer(destination, amount, assetId, txParams = {}) {
|
@@ -5493,8 +5571,8 @@ var Account = class extends AbstractAccount {
|
|
5493
5571
|
*
|
5494
5572
|
* @param destination - The address of the destination.
|
5495
5573
|
* @param amount - The amount of coins to transfer.
|
5496
|
-
* @param assetId - The asset ID of the coins to transfer.
|
5497
|
-
* @param txParams - The transaction parameters (
|
5574
|
+
* @param assetId - The asset ID of the coins to transfer (optional).
|
5575
|
+
* @param txParams - The transaction parameters (optional).
|
5498
5576
|
* @returns A promise that resolves to the transaction response.
|
5499
5577
|
*/
|
5500
5578
|
async transfer(destination, amount, assetId, txParams = {}) {
|
@@ -5554,8 +5632,8 @@ var Account = class extends AbstractAccount {
|
|
5554
5632
|
*
|
5555
5633
|
* @param contractId - The address of the contract.
|
5556
5634
|
* @param amount - The amount of coins to transfer.
|
5557
|
-
* @param assetId - The asset ID of the coins to transfer.
|
5558
|
-
* @param txParams - The
|
5635
|
+
* @param assetId - The asset ID of the coins to transfer (optional).
|
5636
|
+
* @param txParams - The transaction parameters (optional).
|
5559
5637
|
* @returns A promise that resolves to the transaction response.
|
5560
5638
|
*/
|
5561
5639
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
@@ -5596,7 +5674,7 @@ var Account = class extends AbstractAccount {
|
|
5596
5674
|
*
|
5597
5675
|
* @param recipient - Address of the recipient on the base chain.
|
5598
5676
|
* @param amount - Amount of base asset.
|
5599
|
-
* @param txParams - The
|
5677
|
+
* @param txParams - The transaction parameters (optional).
|
5600
5678
|
* @returns A promise that resolves to the transaction response.
|
5601
5679
|
*/
|
5602
5680
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
@@ -5626,7 +5704,14 @@ var Account = class extends AbstractAccount {
|
|
5626
5704
|
await this.fund(request, txCost);
|
5627
5705
|
return this.sendTransaction(request);
|
5628
5706
|
}
|
5629
|
-
/**
|
5707
|
+
/**
|
5708
|
+
* Sign a message from the account via the connector.
|
5709
|
+
*
|
5710
|
+
* @param message - the message to sign.
|
5711
|
+
* @returns a promise that resolves to the signature.
|
5712
|
+
*
|
5713
|
+
* @hidden
|
5714
|
+
*/
|
5630
5715
|
async signMessage(message) {
|
5631
5716
|
if (!this._connector) {
|
5632
5717
|
throw new FuelError15(ErrorCode15.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
@@ -5634,7 +5719,7 @@ var Account = class extends AbstractAccount {
|
|
5634
5719
|
return this._connector.signMessage(this.address.toString(), message);
|
5635
5720
|
}
|
5636
5721
|
/**
|
5637
|
-
* Signs a transaction
|
5722
|
+
* Signs a transaction from the account via the connector..
|
5638
5723
|
*
|
5639
5724
|
* @param transactionRequestLike - The transaction request to sign.
|
5640
5725
|
* @returns A promise that resolves to the signature of the transaction.
|
@@ -5652,6 +5737,7 @@ var Account = class extends AbstractAccount {
|
|
5652
5737
|
* Sends a transaction to the network.
|
5653
5738
|
*
|
5654
5739
|
* @param transactionRequestLike - The transaction request to be sent.
|
5740
|
+
* @param sendTransactionParams - The provider send transaction parameters (optional).
|
5655
5741
|
* @returns A promise that resolves to the transaction response.
|
5656
5742
|
*/
|
5657
5743
|
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
@@ -5673,6 +5759,7 @@ var Account = class extends AbstractAccount {
|
|
5673
5759
|
* Simulates a transaction.
|
5674
5760
|
*
|
5675
5761
|
* @param transactionRequestLike - The transaction request to be simulated.
|
5762
|
+
* @param estimateTxParams - The estimate transaction params (optional).
|
5676
5763
|
* @returns A promise that resolves to the call result.
|
5677
5764
|
*/
|
5678
5765
|
async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
@@ -6018,6 +6105,8 @@ var BaseWalletUnlocked = class extends Account {
|
|
6018
6105
|
* Populates the witness signature for a transaction and sends it to the network using `provider.sendTransaction`.
|
6019
6106
|
*
|
6020
6107
|
* @param transactionRequestLike - The transaction request to send.
|
6108
|
+
* @param estimateTxDependencies - Whether to estimate the transaction dependencies.
|
6109
|
+
* @param awaitExecution - Whether to wait for the transaction to be executed.
|
6021
6110
|
* @returns A promise that resolves to the TransactionResponse object.
|
6022
6111
|
*/
|
6023
6112
|
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
|
@@ -6049,6 +6138,12 @@ var BaseWalletUnlocked = class extends Account {
|
|
6049
6138
|
}
|
6050
6139
|
);
|
6051
6140
|
}
|
6141
|
+
/**
|
6142
|
+
* Encrypts an unlocked wallet with a password.
|
6143
|
+
*
|
6144
|
+
* @param password - the password to encrypt the wallet with.
|
6145
|
+
* @returns - the encrypted wallet.
|
6146
|
+
*/
|
6052
6147
|
async encrypt(password) {
|
6053
6148
|
return encryptKeystoreWallet(this.privateKey, this.address, password);
|
6054
6149
|
}
|