Skip to content

Commit

Permalink
chore: cleanup typedoc for Account and Wallet (#2276)
Browse files Browse the repository at this point in the history
* chore: typedoc cleanup for wallet and account

* chore: changeset

* chore: linting

* chore: spelling

Co-authored-by: Chad Nehemiah <chad.nehemiah94@gmail.com>

* chore: add optional params

* docs: update doc

Co-authored-by: Peter Smith <peter@blueoceancomputing.co.uk>

* chore: typedoc cleanup wallet account (#2353)

docs: better align typedocs

* docs: update typedoc

Co-authored-by: Sérgio Torres <30977845+Torres-ssf@users.noreply.github.com>

* chore: remove redundant doc

---------

Co-authored-by: Anderson Arboleya <anderson@arboleya.me>
Co-authored-by: Chad Nehemiah <chad.nehemiah94@gmail.com>
Co-authored-by: Peter Smith <peter@blueoceancomputing.co.uk>
Co-authored-by: Sérgio Torres <30977845+Torres-ssf@users.noreply.github.com>
  • Loading branch information
5 people authored May 23, 2024
1 parent ceef79a commit 395eb2c
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 88 deletions.
2 changes: 2 additions & 0 deletions .changeset/friendly-carpets-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
58 changes: 28 additions & 30 deletions packages/account/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,17 @@ export class Account extends AbstractAccount {
*/
protected _provider?: Provider;

/**
* The connector for use with external wallets
*/
protected _connector?: FuelConnector;

/**
* Creates a new Account instance.
*
* @param address - The address of the account.
* @param provider - A Provider instance (optional).
* @param connector - A FuelConnector instance (optional).
*/
constructor(address: string | AbstractAddress, provider?: Provider, connector?: FuelConnector) {
super();
Expand Down Expand Up @@ -123,12 +127,12 @@ export class Account extends AbstractAccount {
/**
* Retrieves resources satisfying the spend query for the account.
*
* @param quantities - IDs of coins to exclude.
* @param excludedIds - IDs of resources to be excluded from the query.
* @param quantities - Quantities of resources to be obtained.
* @param excludedIds - IDs of resources to be excluded from the query (optional).
* @returns A promise that resolves to an array of Resources.
*/
async getResourcesToSpend(
quantities: CoinQuantityLike[] /** IDs of coins to exclude */,
quantities: CoinQuantityLike[],
excludedIds?: ExcludeResourcesOption
): Promise<Resource[]> {
return this.provider.getResourcesToSpend(this.address, quantities, excludedIds);
Expand All @@ -137,7 +141,7 @@ export class Account extends AbstractAccount {
/**
* Retrieves coins owned by the account.
*
* @param assetId - The asset ID of the coins to retrieve.
* @param assetId - The asset ID of the coins to retrieve (optional).
* @returns A promise that resolves to an array of Coins.
*/
async getCoins(assetId?: BytesLike): Promise<Coin[]> {
Expand Down Expand Up @@ -206,7 +210,7 @@ export class Account extends AbstractAccount {
/**
* Retrieves the balance of the account for the given asset.
*
* @param assetId - The asset ID to check the balance for.
* @param assetId - The asset ID to check the balance for (optional).
* @returns A promise that resolves to the balance amount.
*/
async getBalance(assetId?: BytesLike): Promise<BN> {
Expand Down Expand Up @@ -255,7 +259,7 @@ export class Account extends AbstractAccount {
* @typeParam T - The type of the TransactionRequest.
* @param request - The transaction request to fund.
* @param params - The estimated transaction parameters.
* @returns The funded transaction request.
* @returns A promise that resolves to the funded transaction request.
*/
async fund<T extends TransactionRequest>(request: T, params: EstimatedTxParams): Promise<T> {
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
Expand Down Expand Up @@ -370,18 +374,14 @@ export class Account extends AbstractAccount {
*
* @param destination - The address of the destination.
* @param amount - The amount of coins to transfer.
* @param assetId - The asset ID of the coins to transfer.
* @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
* @param assetId - The asset ID of the coins to transfer (optional).
* @param txParams - The transaction parameters (optional).
* @returns A promise that resolves to the prepared transaction request.
*/
async createTransfer(
/** Address of the destination */
destination: string | AbstractAddress,
/** Amount of coins */
amount: BigNumberish,
/** Asset ID of coins */
assetId?: BytesLike,
/** Tx Params */
txParams: TxParamsType = {}
): Promise<TransactionRequest> {
let request = new ScriptTransactionRequest(txParams);
Expand All @@ -395,18 +395,14 @@ export class Account extends AbstractAccount {
*
* @param destination - The address of the destination.
* @param amount - The amount of coins to transfer.
* @param assetId - The asset ID of the coins to transfer.
* @param txParams - The transaction parameters (gasLimit, maturity).
* @param assetId - The asset ID of the coins to transfer (optional).
* @param txParams - The transaction parameters (optional).
* @returns A promise that resolves to the transaction response.
*/
async transfer(
/** Address of the destination */
destination: string | AbstractAddress,
/** Amount of coins */
amount: BigNumberish,
/** Asset ID of coins */
assetId?: BytesLike,
/** Tx Params */
txParams: TxParamsType = {}
): Promise<TransactionResponse> {
const request = await this.createTransfer(destination, amount, assetId, txParams);
Expand Down Expand Up @@ -472,18 +468,14 @@ export class Account extends AbstractAccount {
*
* @param contractId - The address of the contract.
* @param amount - The amount of coins to transfer.
* @param assetId - The asset ID of the coins to transfer.
* @param txParams - The optional transaction parameters.
* @param assetId - The asset ID of the coins to transfer (optional).
* @param txParams - The transaction parameters (optional).
* @returns A promise that resolves to the transaction response.
*/
async transferToContract(
/** Contract address */
contractId: string | AbstractAddress,
/** Amount of coins */
amount: BigNumberish,
/** Asset ID of coins */
assetId?: BytesLike,
/** Tx Params */
txParams: TxParamsType = {}
): Promise<TransactionResponse> {
if (bn(amount).lte(0)) {
Expand Down Expand Up @@ -531,15 +523,12 @@ export class Account extends AbstractAccount {
*
* @param recipient - Address of the recipient on the base chain.
* @param amount - Amount of base asset.
* @param txParams - The optional transaction parameters.
* @param txParams - The transaction parameters (optional).
* @returns A promise that resolves to the transaction response.
*/
async withdrawToBaseLayer(
/** Address of the recipient on the base chain */
recipient: string | AbstractAddress,
/** Amount of base asset */
amount: BigNumberish,
/** Tx Params */
txParams: TxParamsType = {}
): Promise<TransactionResponse> {
const recipientAddress = Address.fromAddressOrString(recipient);
Expand Down Expand Up @@ -576,7 +565,14 @@ export class Account extends AbstractAccount {
return this.sendTransaction(request);
}

/** @hidden * */
/**
* Sign a message from the account via the connector.
*
* @param message - the message to sign.
* @returns a promise that resolves to the signature.
*
* @hidden
*/
async signMessage(message: string): Promise<string> {
if (!this._connector) {
throw new FuelError(ErrorCode.MISSING_CONNECTOR, 'A connector is required to sign messages.');
Expand All @@ -585,7 +581,7 @@ export class Account extends AbstractAccount {
}

/**
* Signs a transaction with the wallet's private key.
* Signs a transaction from the account via the connector..
*
* @param transactionRequestLike - The transaction request to sign.
* @returns A promise that resolves to the signature of the transaction.
Expand All @@ -604,6 +600,7 @@ export class Account extends AbstractAccount {
* Sends a transaction to the network.
*
* @param transactionRequestLike - The transaction request to be sent.
* @param sendTransactionParams - The provider send transaction parameters (optional).
* @returns A promise that resolves to the transaction response.
*/
async sendTransaction(
Expand All @@ -629,6 +626,7 @@ export class Account extends AbstractAccount {
* Simulates a transaction.
*
* @param transactionRequestLike - The transaction request to be simulated.
* @param estimateTxParams - The estimate transaction params (optional).
* @returns A promise that resolves to the call result.
*/
async simulateTransaction(
Expand Down
Loading

0 comments on commit 395eb2c

Please sign in to comment.