Skip to content

Commit

Permalink
feat(transfer): Added ensureFunded method
Browse files Browse the repository at this point in the history
  • Loading branch information
robdmoore committed Mar 22, 2023
1 parent d16704f commit fff8c87
Show file tree
Hide file tree
Showing 10 changed files with 399 additions and 10 deletions.
34 changes: 32 additions & 2 deletions docs/code/classes/types_amount.AlgoAmount.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Wrapper class to ensure safe, explicit conversion between µAlgos, Algos and num

### Methods

- [toString](types_amount.AlgoAmount.md#tostring)
- [valueOf](types_amount.AlgoAmount.md#valueof)
- [Algos](types_amount.AlgoAmount.md#algos-1)
- [MicroAlgos](types_amount.AlgoAmount.md#microalgos-1)

Expand Down Expand Up @@ -86,6 +88,34 @@ Return the amount as a number in µAlgos

## Methods

### toString

**toString**(): `string`

#### Returns

`string`

#### Defined in

[types/amount.ts:21](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L21)

___

### valueOf

**valueOf**(): `number`

#### Returns

`number`

#### Defined in

[types/amount.ts:25](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L25)

___

### Algos

`Static` **Algos**(`amount`): [`AlgoAmount`](types_amount.AlgoAmount.md)
Expand All @@ -108,7 +138,7 @@ object representing the given number of Algos

#### Defined in

[types/amount.ts:22](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L22)
[types/amount.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L30)

___

Expand All @@ -134,4 +164,4 @@ object representing the given number of µAlgos

#### Defined in

[types/amount.ts:27](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L27)
[types/amount.ts:35](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/amount.ts#L35)
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ The sending configuration for a transaction

[`AlgoTransferParams`](types_transfer.AlgoTransferParams.md)

[`EnsureFundedParams`](types_transfer.EnsureFundedParams.md)

## Table of contents

### Properties
Expand Down
16 changes: 10 additions & 6 deletions docs/code/interfaces/types_transfer.AlgoTransferParams.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

[types/transfer](../modules/types_transfer.md).AlgoTransferParams

The sending configuration for a transaction
Parameters for

**`See`**

transferAlgos call.

## Hierarchy

Expand Down Expand Up @@ -38,7 +42,7 @@ The amount to send

#### Defined in

[types/transfer.ts:11](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L11)
[types/transfer.ts:12](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L12)

___

Expand Down Expand Up @@ -66,7 +70,7 @@ The account (with private key loaded) that will send the µALGOs

#### Defined in

[types/transfer.ts:7](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L7)
[types/transfer.ts:8](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L8)

___

Expand Down Expand Up @@ -110,7 +114,7 @@ The (optional) transaction note

#### Defined in

[types/transfer.ts:15](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L15)
[types/transfer.ts:16](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L16)

___

Expand Down Expand Up @@ -171,7 +175,7 @@ The account address that will receive the ALGOs

#### Defined in

[types/transfer.ts:9](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L9)
[types/transfer.ts:10](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L10)

___

Expand All @@ -183,4 +187,4 @@ Optional transaction parameters

#### Defined in

[types/transfer.ts:13](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L13)
[types/transfer.ts:14](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L14)
203 changes: 203 additions & 0 deletions docs/code/interfaces/types_transfer.EnsureFundedParams.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
[@algorandfoundation/algokit-utils](../README.md) / [types/transfer](../modules/types_transfer.md) / EnsureFundedParams

# Interface: EnsureFundedParams

[types/transfer](../modules/types_transfer.md).EnsureFundedParams

Parameters for

**`See`**

ensureFunded call.

## Hierarchy

- [`SendTransactionParams`](types_transaction.SendTransactionParams.md)

**`EnsureFundedParams`**

## Table of contents

### Properties

- [accountToFund](types_transfer.EnsureFundedParams.md#accounttofund)
- [fee](types_transfer.EnsureFundedParams.md#fee)
- [fundingSource](types_transfer.EnsureFundedParams.md#fundingsource)
- [maxFee](types_transfer.EnsureFundedParams.md#maxfee)
- [maxRoundsToWaitForConfirmation](types_transfer.EnsureFundedParams.md#maxroundstowaitforconfirmation)
- [minFundingIncrement](types_transfer.EnsureFundedParams.md#minfundingincrement)
- [minSpendingBalance](types_transfer.EnsureFundedParams.md#minspendingbalance)
- [note](types_transfer.EnsureFundedParams.md#note)
- [skipSending](types_transfer.EnsureFundedParams.md#skipsending)
- [skipWaiting](types_transfer.EnsureFundedParams.md#skipwaiting)
- [suppressLog](types_transfer.EnsureFundedParams.md#suppresslog)
- [transactionParams](types_transfer.EnsureFundedParams.md#transactionparams)

## Properties

### accountToFund

**accountToFund**: `string` \| [`SendTransactionFrom`](../modules/types_transaction.md#sendtransactionfrom)

The account to fund

#### Defined in

[types/transfer.ts:22](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L22)

___

### fee

`Optional` **fee**: [`AlgoAmount`](../classes/types_amount.AlgoAmount.md)

The flat fee you want to pay, useful for covering extra fees in a transaction group or app call

#### Inherited from

[SendTransactionParams](types_transaction.SendTransactionParams.md).[fee](types_transaction.SendTransactionParams.md#fee)

#### Defined in

[types/transaction.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L32)

___

### fundingSource

**fundingSource**: [`SendTransactionFrom`](../modules/types_transaction.md#sendtransactionfrom)

The account to use as a funding source

#### Defined in

[types/transfer.ts:24](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L24)

___

### maxFee

`Optional` **maxFee**: [`AlgoAmount`](../classes/types_amount.AlgoAmount.md)

The maximum fee that you are happy to pay (default: unbounded) - if this is set it's possible the transaction could get rejected during network congestion

#### Inherited from

[SendTransactionParams](types_transaction.SendTransactionParams.md).[maxFee](types_transaction.SendTransactionParams.md#maxfee)

#### Defined in

[types/transaction.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L34)

___

### maxRoundsToWaitForConfirmation

`Optional` **maxRoundsToWaitForConfirmation**: `number`

The maximum number of rounds to wait for confirmation, only applies if `skipWaiting` is `undefined` or `false`, default: wait up to 5 rounds

#### Inherited from

[SendTransactionParams](types_transaction.SendTransactionParams.md).[maxRoundsToWaitForConfirmation](types_transaction.SendTransactionParams.md#maxroundstowaitforconfirmation)

#### Defined in

[types/transaction.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L36)

___

### minFundingIncrement

`Optional` **minFundingIncrement**: [`AlgoAmount`](../classes/types_amount.AlgoAmount.md)

When issuing a funding amount, the minimum amount to transfer (avoids many small transfers if this gets called often on an active account)

#### Defined in

[types/transfer.ts:28](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L28)

___

### minSpendingBalance

**minSpendingBalance**: [`AlgoAmount`](../classes/types_amount.AlgoAmount.md)

The minimum balance of ALGOs that the account should have available to spend (i.e. on top of minimum balance requirement)

#### Defined in

[types/transfer.ts:26](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L26)

___

### note

`Optional` **note**: [`TransactionNote`](../modules/types_transaction.md#transactionnote)

The (optional) transaction note, default: "Funding account to meet minimum requirement"

#### Defined in

[types/transfer.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L32)

___

### skipSending

`Optional` **skipSending**: `boolean`

Whether to skip signing and sending the transaction to the chain (default: transaction signed and sent to chain)
(and instead just return the raw transaction, e.g. so you can add it to a group of transactions)

#### Inherited from

[SendTransactionParams](types_transaction.SendTransactionParams.md).[skipSending](types_transaction.SendTransactionParams.md#skipsending)

#### Defined in

[types/transaction.ts:26](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L26)

___

### skipWaiting

`Optional` **skipWaiting**: `boolean`

Whether to skip waiting for the submitted transaction (only relevant if `skipSending` is `false` or unset)

#### Inherited from

[SendTransactionParams](types_transaction.SendTransactionParams.md).[skipWaiting](types_transaction.SendTransactionParams.md#skipwaiting)

#### Defined in

[types/transaction.ts:28](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L28)

___

### suppressLog

`Optional` **suppressLog**: `boolean`

Whether to suppress log messages from transaction send, default: do not suppress

#### Inherited from

[SendTransactionParams](types_transaction.SendTransactionParams.md).[suppressLog](types_transaction.SendTransactionParams.md#suppresslog)

#### Defined in

[types/transaction.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L30)

___

### transactionParams

`Optional` **transactionParams**: `SuggestedParams`

Optional transaction parameters

#### Defined in

[types/transfer.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L30)
30 changes: 30 additions & 0 deletions docs/code/modules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- [createApp](index.md#createapp)
- [deployApp](index.md#deployapp)
- [encodeTransactionNote](index.md#encodetransactionnote)
- [ensureFunded](index.md#ensurefunded)
- [executePaginatedRequest](index.md#executepaginatedrequest)
- [getABIReturn](index.md#getabireturn)
- [getAccount](index.md#getaccount)
Expand Down Expand Up @@ -268,6 +269,35 @@ the transaction note ready for inclusion in a transaction

___

### ensureFunded

**ensureFunded**(`funding`, `client`): `Promise`<[`SendTransactionResult`](../interfaces/types_transaction.SendTransactionResult.md) \| `undefined`\>

Funds a given account using a funding source such that it has a certain amount of algos free to spend (accounting for ALGOs locked in minimum balance requirement).

**`See`**

https://developer.algorand.org/docs/get-details/accounts/#minimum-balance

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `funding` | [`EnsureFundedParams`](../interfaces/types_transfer.EnsureFundedParams.md) | The funding configuration |
| `client` | `default` | An algod client |

#### Returns

`Promise`<[`SendTransactionResult`](../interfaces/types_transaction.SendTransactionResult.md) \| `undefined`\>

undefined if nothing was needed or the transaction send result

#### Defined in

[transfer.ts:42](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transfer.ts#L42)

___

### executePaginatedRequest

**executePaginatedRequest**<`TResult`, `TRequest`\>(`extractItems`, `buildRequest`): `Promise`<`TResult`[]\>
Expand Down
1 change: 1 addition & 0 deletions docs/code/modules/types_transfer.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
### Interfaces

- [AlgoTransferParams](../interfaces/types_transfer.AlgoTransferParams.md)
- [EnsureFundedParams](../interfaces/types_transfer.EnsureFundedParams.md)
Loading

0 comments on commit fff8c87

Please sign in to comment.