@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.js
CHANGED
@@ -2839,6 +2839,13 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2839
2839
|
}
|
2840
2840
|
return this.outputs.length - 1;
|
2841
2841
|
}
|
2842
|
+
/**
|
2843
|
+
* Calculates the maximum gas for the transaction.
|
2844
|
+
*
|
2845
|
+
* @param chainInfo - The chain information.
|
2846
|
+
* @param minGas - The minimum gas.
|
2847
|
+
* @returns the maximum gas.
|
2848
|
+
*/
|
2842
2849
|
calculateMaxGas(chainInfo, minGas) {
|
2843
2850
|
const { consensusParameters } = chainInfo;
|
2844
2851
|
const {
|
@@ -4002,7 +4009,6 @@ var _Provider = class {
|
|
4002
4009
|
* Constructor to initialize a Provider.
|
4003
4010
|
*
|
4004
4011
|
* @param url - GraphQL endpoint of the Fuel node
|
4005
|
-
* @param chainInfo - Chain info of the Fuel node
|
4006
4012
|
* @param options - Additional options for the provider
|
4007
4013
|
* @hidden
|
4008
4014
|
*/
|
@@ -4025,10 +4031,14 @@ var _Provider = class {
|
|
4025
4031
|
this.operations = this.createOperations();
|
4026
4032
|
this.cache = options.cacheUtxo ? new MemoryCache(options.cacheUtxo) : void 0;
|
4027
4033
|
}
|
4034
|
+
/** @hidden */
|
4028
4035
|
static clearChainAndNodeCaches() {
|
4029
4036
|
_Provider.nodeInfoCache = {};
|
4030
4037
|
_Provider.chainInfoCache = {};
|
4031
4038
|
}
|
4039
|
+
/**
|
4040
|
+
* @hidden
|
4041
|
+
*/
|
4032
4042
|
static getFetchFn(options) {
|
4033
4043
|
const { retryOptions, timeout } = options;
|
4034
4044
|
return autoRetryFetch(async (...args) => {
|
@@ -4044,8 +4054,11 @@ var _Provider = class {
|
|
4044
4054
|
}
|
4045
4055
|
/**
|
4046
4056
|
* Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
|
4057
|
+
*
|
4047
4058
|
* @param url - GraphQL endpoint of the Fuel node
|
4048
4059
|
* @param options - Additional options for the provider
|
4060
|
+
*
|
4061
|
+
* @returns A promise that resolves to a Provider instance.
|
4049
4062
|
*/
|
4050
4063
|
static async create(url, options = {}) {
|
4051
4064
|
const provider = new _Provider(url, options);
|
@@ -4054,6 +4067,8 @@ var _Provider = class {
|
|
4054
4067
|
}
|
4055
4068
|
/**
|
4056
4069
|
* Returns the cached chainInfo for the current URL.
|
4070
|
+
*
|
4071
|
+
* @returns the chain information configuration.
|
4057
4072
|
*/
|
4058
4073
|
getChain() {
|
4059
4074
|
const chain = _Provider.chainInfoCache[this.url];
|
@@ -4067,6 +4082,8 @@ var _Provider = class {
|
|
4067
4082
|
}
|
4068
4083
|
/**
|
4069
4084
|
* Returns the cached nodeInfo for the current URL.
|
4085
|
+
*
|
4086
|
+
* @returns the node information configuration.
|
4070
4087
|
*/
|
4071
4088
|
getNode() {
|
4072
4089
|
const node = _Provider.nodeInfoCache[this.url];
|
@@ -4098,6 +4115,9 @@ var _Provider = class {
|
|
4098
4115
|
}
|
4099
4116
|
/**
|
4100
4117
|
* Updates the URL for the provider and fetches the consensus parameters for the new URL, if needed.
|
4118
|
+
*
|
4119
|
+
* @param url - The URL to connect to.
|
4120
|
+
* @param options - Additional options for the provider.
|
4101
4121
|
*/
|
4102
4122
|
async connect(url, options) {
|
4103
4123
|
this.url = url;
|
@@ -4106,9 +4126,9 @@ var _Provider = class {
|
|
4106
4126
|
await this.fetchChainAndNodeInfo();
|
4107
4127
|
}
|
4108
4128
|
/**
|
4109
|
-
*
|
4129
|
+
* Return the chain and node information.
|
4110
4130
|
*
|
4111
|
-
* @returns
|
4131
|
+
* @returns A promise that resolves to the Chain and NodeInfo.
|
4112
4132
|
*/
|
4113
4133
|
async fetchChainAndNodeInfo() {
|
4114
4134
|
const chain = await this.fetchChain();
|
@@ -4119,6 +4139,9 @@ var _Provider = class {
|
|
4119
4139
|
nodeInfo
|
4120
4140
|
};
|
4121
4141
|
}
|
4142
|
+
/**
|
4143
|
+
* @hidden
|
4144
|
+
*/
|
4122
4145
|
static ensureClientVersionIsSupported(nodeInfo) {
|
4123
4146
|
const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
|
4124
4147
|
if (!isMajorSupported || !isMinorSupported) {
|
@@ -4134,6 +4157,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4134
4157
|
* Create GraphQL client and set operations.
|
4135
4158
|
*
|
4136
4159
|
* @returns The operation SDK object
|
4160
|
+
* @hidden
|
4137
4161
|
*/
|
4138
4162
|
createOperations() {
|
4139
4163
|
const fetchFn = _Provider.getFetchFn(this.options);
|
@@ -4178,18 +4202,18 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4178
4202
|
return nodeVersion;
|
4179
4203
|
}
|
4180
4204
|
/**
|
4181
|
-
* Returns the block number.
|
4205
|
+
* Returns the latest block number.
|
4182
4206
|
*
|
4183
|
-
* @returns A promise that resolves to the block number
|
4207
|
+
* @returns A promise that resolves to the latest block number.
|
4184
4208
|
*/
|
4185
4209
|
async getBlockNumber() {
|
4186
4210
|
const { chain } = await this.operations.getChain();
|
4187
4211
|
return (0, import_math17.bn)(chain.latestBlock.height, 10);
|
4188
4212
|
}
|
4189
4213
|
/**
|
4190
|
-
* Returns the
|
4191
|
-
*
|
4192
|
-
* @returns
|
4214
|
+
* Returns the node information for the current provider network.
|
4215
|
+
*
|
4216
|
+
* @returns a promise that resolves to the node information.
|
4193
4217
|
*/
|
4194
4218
|
async fetchNode() {
|
4195
4219
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
@@ -4204,9 +4228,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4204
4228
|
return processedNodeInfo;
|
4205
4229
|
}
|
4206
4230
|
/**
|
4207
|
-
*
|
4208
|
-
*
|
4209
|
-
* @returns
|
4231
|
+
* Returns the chain information for the current provider network.
|
4232
|
+
*
|
4233
|
+
* @returns a promise that resolves to the chain information.
|
4210
4234
|
*/
|
4211
4235
|
async fetchChain() {
|
4212
4236
|
const { chain } = await this.operations.getChain();
|
@@ -4215,8 +4239,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4215
4239
|
return processedChain;
|
4216
4240
|
}
|
4217
4241
|
/**
|
4218
|
-
* Returns the chain ID
|
4219
|
-
*
|
4242
|
+
* Returns the chain ID for the current provider network.
|
4243
|
+
*
|
4244
|
+
* @returns A promise that resolves to the chain ID number.
|
4220
4245
|
*/
|
4221
4246
|
getChainId() {
|
4222
4247
|
const {
|
@@ -4225,9 +4250,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4225
4250
|
return chainId.toNumber();
|
4226
4251
|
}
|
4227
4252
|
/**
|
4228
|
-
* Returns the base asset ID for the current provider network
|
4253
|
+
* Returns the base asset ID for the current provider network.
|
4229
4254
|
*
|
4230
|
-
* @returns the base asset ID
|
4255
|
+
* @returns the base asset ID.
|
4231
4256
|
*/
|
4232
4257
|
getBaseAssetId() {
|
4233
4258
|
const {
|
@@ -4242,6 +4267,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4242
4267
|
* the transaction will be mutated and those dependencies will be added.
|
4243
4268
|
*
|
4244
4269
|
* @param transactionRequestLike - The transaction request object.
|
4270
|
+
* @param sendTransactionParams - The provider send transaction parameters (optional).
|
4245
4271
|
* @returns A promise that resolves to the transaction response object.
|
4246
4272
|
*/
|
4247
4273
|
// #region Provider-sendTransaction
|
@@ -4286,7 +4312,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4286
4312
|
* the transaction will be mutated and those dependencies will be added.
|
4287
4313
|
*
|
4288
4314
|
* @param transactionRequestLike - The transaction request object.
|
4289
|
-
* @param
|
4315
|
+
* @param sendTransactionParams - The provider call parameters (optional).
|
4290
4316
|
* @returns A promise that resolves to the call result object.
|
4291
4317
|
*/
|
4292
4318
|
async call(transactionRequestLike, { utxoValidation, estimateTxDependencies = true } = {}) {
|
@@ -4306,6 +4332,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4306
4332
|
/**
|
4307
4333
|
* Verifies whether enough gas is available to complete transaction.
|
4308
4334
|
*
|
4335
|
+
* @template T - The type of the transaction request object.
|
4336
|
+
*
|
4309
4337
|
* @param transactionRequest - The transaction request object.
|
4310
4338
|
* @returns A promise that resolves to the estimated transaction request object.
|
4311
4339
|
*/
|
@@ -4340,9 +4368,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4340
4368
|
* If there are missing variable outputs,
|
4341
4369
|
* `addVariableOutputs` is called on the transaction.
|
4342
4370
|
*
|
4343
|
-
*
|
4344
4371
|
* @param transactionRequest - The transaction request object.
|
4345
|
-
* @returns A promise.
|
4372
|
+
* @returns A promise that resolves to the estimate transaction dependencies.
|
4346
4373
|
*/
|
4347
4374
|
async estimateTxDependencies(transactionRequest) {
|
4348
4375
|
if (transactionRequest.type === import_transactions20.TransactionType.Create) {
|
@@ -4455,6 +4482,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4455
4482
|
}
|
4456
4483
|
return results;
|
4457
4484
|
}
|
4485
|
+
/**
|
4486
|
+
* Dry runs multiple transactions.
|
4487
|
+
*
|
4488
|
+
* @param transactionRequests - Array of transaction request objects.
|
4489
|
+
* @param sendTransactionParams - The provider call parameters (optional).
|
4490
|
+
*
|
4491
|
+
* @returns A promise that resolves to an array of results for each transaction call.
|
4492
|
+
*/
|
4458
4493
|
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
4459
4494
|
if (estimateTxDependencies) {
|
4460
4495
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
@@ -4525,6 +4560,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4525
4560
|
* the transaction will be mutated and those dependencies will be added
|
4526
4561
|
*
|
4527
4562
|
* @param transactionRequestLike - The transaction request object.
|
4563
|
+
* @param estimateTxParams - The estimate transaction params (optional).
|
4528
4564
|
* @returns A promise that resolves to the call result object.
|
4529
4565
|
*/
|
4530
4566
|
async simulate(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
@@ -4549,14 +4585,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4549
4585
|
* to set gasLimit and also reserve balance amounts
|
4550
4586
|
* on the the transaction.
|
4551
4587
|
*
|
4552
|
-
* @privateRemarks
|
4553
|
-
* The tolerance is add on top of the gasUsed calculated
|
4554
|
-
* from the node, this create a safe margin costs like
|
4555
|
-
* change states on transfer that don't occur on the dryRun
|
4556
|
-
* transaction. The default value is 0.2 or 20%
|
4557
|
-
*
|
4558
4588
|
* @param transactionRequestLike - The transaction request object.
|
4559
|
-
* @param
|
4589
|
+
* @param transactionCostParams - The transaction cost parameters (optional).
|
4590
|
+
*
|
4560
4591
|
* @returns A promise that resolves to the transaction cost object.
|
4561
4592
|
*/
|
4562
4593
|
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
@@ -4624,6 +4655,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4624
4655
|
updateMaxFee
|
4625
4656
|
};
|
4626
4657
|
}
|
4658
|
+
/**
|
4659
|
+
* Get the required quantities and associated resources for a transaction.
|
4660
|
+
*
|
4661
|
+
* @param owner - address to add resources from.
|
4662
|
+
* @param transactionRequestLike - transaction request to populate resources for.
|
4663
|
+
* @param quantitiesToContract - quantities for the contract (optional).
|
4664
|
+
*
|
4665
|
+
* @returns a promise resolving to the required quantities for the transaction.
|
4666
|
+
*/
|
4627
4667
|
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
4628
4668
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4629
4669
|
const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
|
@@ -4645,6 +4685,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4645
4685
|
}
|
4646
4686
|
/**
|
4647
4687
|
* Returns coins for the given owner.
|
4688
|
+
*
|
4689
|
+
* @param owner - The address to get coins for.
|
4690
|
+
* @param assetId - The asset ID of coins to get (optional).
|
4691
|
+
* @param paginationArgs - Pagination arguments (optional).
|
4692
|
+
*
|
4693
|
+
* @returns A promise that resolves to the coins.
|
4648
4694
|
*/
|
4649
4695
|
async getCoins(owner, assetId, paginationArgs) {
|
4650
4696
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
@@ -4667,8 +4713,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4667
4713
|
* Returns resources for the given owner satisfying the spend query.
|
4668
4714
|
*
|
4669
4715
|
* @param owner - The address to get resources for.
|
4670
|
-
* @param quantities - The quantities to get.
|
4671
|
-
* @param excludedIds - IDs of excluded resources from the selection.
|
4716
|
+
* @param quantities - The coin quantities to get.
|
4717
|
+
* @param excludedIds - IDs of excluded resources from the selection (optional).
|
4672
4718
|
* @returns A promise that resolves to the resources.
|
4673
4719
|
*/
|
4674
4720
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
@@ -4723,7 +4769,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4723
4769
|
* Returns block matching the given ID or height.
|
4724
4770
|
*
|
4725
4771
|
* @param idOrHeight - ID or height of the block.
|
4726
|
-
* @returns A promise that resolves to the block.
|
4772
|
+
* @returns A promise that resolves to the block or null.
|
4727
4773
|
*/
|
4728
4774
|
async getBlock(idOrHeight) {
|
4729
4775
|
let variables;
|
@@ -4853,7 +4899,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4853
4899
|
* Returns balances for the given owner.
|
4854
4900
|
*
|
4855
4901
|
* @param owner - The address to get coins for.
|
4856
|
-
* @param paginationArgs - Pagination arguments.
|
4902
|
+
* @param paginationArgs - Pagination arguments (optional).
|
4857
4903
|
* @returns A promise that resolves to the balances.
|
4858
4904
|
*/
|
4859
4905
|
async getBalances(owner, paginationArgs) {
|
@@ -4872,7 +4918,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4872
4918
|
* Returns message for the given address.
|
4873
4919
|
*
|
4874
4920
|
* @param address - The address to get message from.
|
4875
|
-
* @param paginationArgs - Pagination arguments.
|
4921
|
+
* @param paginationArgs - Pagination arguments (optional).
|
4876
4922
|
* @returns A promise that resolves to the messages.
|
4877
4923
|
*/
|
4878
4924
|
async getMessages(address, paginationArgs) {
|
@@ -4903,8 +4949,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4903
4949
|
*
|
4904
4950
|
* @param transactionId - The transaction to get message from.
|
4905
4951
|
* @param messageId - The message id from MessageOut receipt.
|
4906
|
-
* @param commitBlockId - The commit block id.
|
4907
|
-
* @param commitBlockHeight - The commit block height.
|
4952
|
+
* @param commitBlockId - The commit block id (optional).
|
4953
|
+
* @param commitBlockHeight - The commit block height (optional).
|
4908
4954
|
* @returns A promise that resolves to the message proof.
|
4909
4955
|
*/
|
4910
4956
|
async getMessageProof(transactionId, nonce, commitBlockId, commitBlockHeight) {
|
@@ -4992,10 +5038,21 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4992
5038
|
data
|
4993
5039
|
};
|
4994
5040
|
}
|
5041
|
+
/**
|
5042
|
+
* Get the latest gas price from the node.
|
5043
|
+
*
|
5044
|
+
* @returns A promise that resolves to the latest gas price.
|
5045
|
+
*/
|
4995
5046
|
async getLatestGasPrice() {
|
4996
5047
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4997
5048
|
return (0, import_math17.bn)(latestGasPrice.gasPrice);
|
4998
5049
|
}
|
5050
|
+
/**
|
5051
|
+
* Returns the estimate gas price for the given block horizon.
|
5052
|
+
*
|
5053
|
+
* @param blockHorizon - The block horizon to estimate gas price for.
|
5054
|
+
* @returns A promise that resolves to the estimated gas price.
|
5055
|
+
*/
|
4999
5056
|
async estimateGasPrice(blockHorizon) {
|
5000
5057
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
5001
5058
|
blockHorizon: String(blockHorizon)
|
@@ -5015,8 +5072,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5015
5072
|
/**
|
5016
5073
|
* Lets you produce blocks with custom timestamps and the block number of the last block produced.
|
5017
5074
|
*
|
5018
|
-
* @param amount - The amount of blocks to produce
|
5019
|
-
* @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block
|
5075
|
+
* @param amount - The amount of blocks to produce.
|
5076
|
+
* @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block (optional).
|
5020
5077
|
* @returns A promise that resolves to the block number of the last produced block.
|
5021
5078
|
*/
|
5022
5079
|
async produceBlocks(amount, startTime) {
|
@@ -5026,6 +5083,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5026
5083
|
});
|
5027
5084
|
return (0, import_math17.bn)(latestBlockHeight);
|
5028
5085
|
}
|
5086
|
+
/**
|
5087
|
+
* Get the transaction response for the given transaction ID.
|
5088
|
+
*
|
5089
|
+
* @param transactionId - The transaction ID to get the response for.
|
5090
|
+
* @returns A promise that resolves to the transaction response.
|
5091
|
+
*/
|
5029
5092
|
// eslint-disable-next-line @typescript-eslint/require-await
|
5030
5093
|
async getTransactionResponse(transactionId) {
|
5031
5094
|
return new TransactionResponse(transactionId, this);
|
@@ -5034,7 +5097,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5034
5097
|
* Returns Message for given nonce.
|
5035
5098
|
*
|
5036
5099
|
* @param nonce - The nonce of the message to retrieve.
|
5037
|
-
* @returns A promise that resolves to the Message object.
|
5100
|
+
* @returns A promise that resolves to the Message object or null.
|
5038
5101
|
*/
|
5039
5102
|
async getMessageByNonce(nonce) {
|
5040
5103
|
const { message } = await this.operations.getMessageByNonce({ nonce });
|
@@ -5043,6 +5106,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5043
5106
|
}
|
5044
5107
|
return message;
|
5045
5108
|
}
|
5109
|
+
/**
|
5110
|
+
* Get the relayed transaction for the given transaction ID.
|
5111
|
+
*
|
5112
|
+
* @param relayedTransactionId - The relayed transaction ID to get the response for.
|
5113
|
+
* @returns A promise that resolves to the relayed transaction.
|
5114
|
+
*/
|
5046
5115
|
async getRelayedTransactionStatus(relayedTransactionId) {
|
5047
5116
|
const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
|
5048
5117
|
relayedTransactionId
|
@@ -5052,6 +5121,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5052
5121
|
}
|
5053
5122
|
return relayedTransactionStatus;
|
5054
5123
|
}
|
5124
|
+
/**
|
5125
|
+
* @hidden
|
5126
|
+
*/
|
5055
5127
|
extractDryRunError(transactionRequest, receipts, dryRunStatus) {
|
5056
5128
|
const status = dryRunStatus;
|
5057
5129
|
let logs = [];
|
@@ -5081,7 +5153,9 @@ cacheInputs_fn = function(inputs) {
|
|
5081
5153
|
}
|
5082
5154
|
});
|
5083
5155
|
};
|
5156
|
+
/** @hidden */
|
5084
5157
|
__publicField(Provider, "chainInfoCache", {});
|
5158
|
+
/** @hidden */
|
5085
5159
|
__publicField(Provider, "nodeInfoCache", {});
|
5086
5160
|
|
5087
5161
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
@@ -5377,12 +5451,16 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5377
5451
|
* The provider used to interact with the network.
|
5378
5452
|
*/
|
5379
5453
|
_provider;
|
5454
|
+
/**
|
5455
|
+
* The connector for use with external wallets
|
5456
|
+
*/
|
5380
5457
|
_connector;
|
5381
5458
|
/**
|
5382
5459
|
* Creates a new Account instance.
|
5383
5460
|
*
|
5384
5461
|
* @param address - The address of the account.
|
5385
5462
|
* @param provider - A Provider instance (optional).
|
5463
|
+
* @param connector - A FuelConnector instance (optional).
|
5386
5464
|
*/
|
5387
5465
|
constructor(address, provider, connector) {
|
5388
5466
|
super();
|
@@ -5424,8 +5502,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5424
5502
|
/**
|
5425
5503
|
* Retrieves resources satisfying the spend query for the account.
|
5426
5504
|
*
|
5427
|
-
* @param quantities -
|
5428
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
5505
|
+
* @param quantities - Quantities of resources to be obtained.
|
5506
|
+
* @param excludedIds - IDs of resources to be excluded from the query (optional).
|
5429
5507
|
* @returns A promise that resolves to an array of Resources.
|
5430
5508
|
*/
|
5431
5509
|
async getResourcesToSpend(quantities, excludedIds) {
|
@@ -5434,7 +5512,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5434
5512
|
/**
|
5435
5513
|
* Retrieves coins owned by the account.
|
5436
5514
|
*
|
5437
|
-
* @param assetId - The asset ID of the coins to retrieve.
|
5515
|
+
* @param assetId - The asset ID of the coins to retrieve (optional).
|
5438
5516
|
* @returns A promise that resolves to an array of Coins.
|
5439
5517
|
*/
|
5440
5518
|
async getCoins(assetId) {
|
@@ -5487,7 +5565,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5487
5565
|
/**
|
5488
5566
|
* Retrieves the balance of the account for the given asset.
|
5489
5567
|
*
|
5490
|
-
* @param assetId - The asset ID to check the balance for.
|
5568
|
+
* @param assetId - The asset ID to check the balance for (optional).
|
5491
5569
|
* @returns A promise that resolves to the balance amount.
|
5492
5570
|
*/
|
5493
5571
|
async getBalance(assetId) {
|
@@ -5527,7 +5605,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5527
5605
|
* @typeParam T - The type of the TransactionRequest.
|
5528
5606
|
* @param request - The transaction request to fund.
|
5529
5607
|
* @param params - The estimated transaction parameters.
|
5530
|
-
* @returns
|
5608
|
+
* @returns A promise that resolves to the funded transaction request.
|
5531
5609
|
*/
|
5532
5610
|
async fund(request, params) {
|
5533
5611
|
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
|
@@ -5620,8 +5698,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5620
5698
|
*
|
5621
5699
|
* @param destination - The address of the destination.
|
5622
5700
|
* @param amount - The amount of coins to transfer.
|
5623
|
-
* @param assetId - The asset ID of the coins to transfer.
|
5624
|
-
* @param txParams - The transaction parameters (
|
5701
|
+
* @param assetId - The asset ID of the coins to transfer (optional).
|
5702
|
+
* @param txParams - The transaction parameters (optional).
|
5625
5703
|
* @returns A promise that resolves to the prepared transaction request.
|
5626
5704
|
*/
|
5627
5705
|
async createTransfer(destination, amount, assetId, txParams = {}) {
|
@@ -5635,8 +5713,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5635
5713
|
*
|
5636
5714
|
* @param destination - The address of the destination.
|
5637
5715
|
* @param amount - The amount of coins to transfer.
|
5638
|
-
* @param assetId - The asset ID of the coins to transfer.
|
5639
|
-
* @param txParams - The transaction parameters (
|
5716
|
+
* @param assetId - The asset ID of the coins to transfer (optional).
|
5717
|
+
* @param txParams - The transaction parameters (optional).
|
5640
5718
|
* @returns A promise that resolves to the transaction response.
|
5641
5719
|
*/
|
5642
5720
|
async transfer(destination, amount, assetId, txParams = {}) {
|
@@ -5696,8 +5774,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5696
5774
|
*
|
5697
5775
|
* @param contractId - The address of the contract.
|
5698
5776
|
* @param amount - The amount of coins to transfer.
|
5699
|
-
* @param assetId - The asset ID of the coins to transfer.
|
5700
|
-
* @param txParams - The
|
5777
|
+
* @param assetId - The asset ID of the coins to transfer (optional).
|
5778
|
+
* @param txParams - The transaction parameters (optional).
|
5701
5779
|
* @returns A promise that resolves to the transaction response.
|
5702
5780
|
*/
|
5703
5781
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
@@ -5738,7 +5816,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5738
5816
|
*
|
5739
5817
|
* @param recipient - Address of the recipient on the base chain.
|
5740
5818
|
* @param amount - Amount of base asset.
|
5741
|
-
* @param txParams - The
|
5819
|
+
* @param txParams - The transaction parameters (optional).
|
5742
5820
|
* @returns A promise that resolves to the transaction response.
|
5743
5821
|
*/
|
5744
5822
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
@@ -5768,7 +5846,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5768
5846
|
await this.fund(request, txCost);
|
5769
5847
|
return this.sendTransaction(request);
|
5770
5848
|
}
|
5771
|
-
/**
|
5849
|
+
/**
|
5850
|
+
* Sign a message from the account via the connector.
|
5851
|
+
*
|
5852
|
+
* @param message - the message to sign.
|
5853
|
+
* @returns a promise that resolves to the signature.
|
5854
|
+
*
|
5855
|
+
* @hidden
|
5856
|
+
*/
|
5772
5857
|
async signMessage(message) {
|
5773
5858
|
if (!this._connector) {
|
5774
5859
|
throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
@@ -5776,7 +5861,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5776
5861
|
return this._connector.signMessage(this.address.toString(), message);
|
5777
5862
|
}
|
5778
5863
|
/**
|
5779
|
-
* Signs a transaction
|
5864
|
+
* Signs a transaction from the account via the connector..
|
5780
5865
|
*
|
5781
5866
|
* @param transactionRequestLike - The transaction request to sign.
|
5782
5867
|
* @returns A promise that resolves to the signature of the transaction.
|
@@ -5794,6 +5879,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5794
5879
|
* Sends a transaction to the network.
|
5795
5880
|
*
|
5796
5881
|
* @param transactionRequestLike - The transaction request to be sent.
|
5882
|
+
* @param sendTransactionParams - The provider send transaction parameters (optional).
|
5797
5883
|
* @returns A promise that resolves to the transaction response.
|
5798
5884
|
*/
|
5799
5885
|
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
|
@@ -5815,6 +5901,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5815
5901
|
* Simulates a transaction.
|
5816
5902
|
*
|
5817
5903
|
* @param transactionRequestLike - The transaction request to be simulated.
|
5904
|
+
* @param estimateTxParams - The estimate transaction params (optional).
|
5818
5905
|
* @returns A promise that resolves to the call result.
|
5819
5906
|
*/
|
5820
5907
|
async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
|
@@ -6152,6 +6239,8 @@ var BaseWalletUnlocked = class extends Account {
|
|
6152
6239
|
* Populates the witness signature for a transaction and sends it to the network using `provider.sendTransaction`.
|
6153
6240
|
*
|
6154
6241
|
* @param transactionRequestLike - The transaction request to send.
|
6242
|
+
* @param estimateTxDependencies - Whether to estimate the transaction dependencies.
|
6243
|
+
* @param awaitExecution - Whether to wait for the transaction to be executed.
|
6155
6244
|
* @returns A promise that resolves to the TransactionResponse object.
|
6156
6245
|
*/
|
6157
6246
|
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
|
@@ -6183,6 +6272,12 @@ var BaseWalletUnlocked = class extends Account {
|
|
6183
6272
|
}
|
6184
6273
|
);
|
6185
6274
|
}
|
6275
|
+
/**
|
6276
|
+
* Encrypts an unlocked wallet with a password.
|
6277
|
+
*
|
6278
|
+
* @param password - the password to encrypt the wallet with.
|
6279
|
+
* @returns - the encrypted wallet.
|
6280
|
+
*/
|
6186
6281
|
async encrypt(password) {
|
6187
6282
|
return encryptKeystoreWallet(this.privateKey, this.address, password);
|
6188
6283
|
}
|