Skip to content

Commit

Permalink
chore: renaming class (#145)
Browse files Browse the repository at this point in the history
* chore: renaming class

* chore: fixing tests
  • Loading branch information
aorumbayev authored Oct 5, 2023
1 parent 6f27c74 commit 03d3212
Show file tree
Hide file tree
Showing 17 changed files with 161 additions and 152 deletions.
4 changes: 2 additions & 2 deletions docs/capabilities/dispenser-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ If both methods are used, the constructor argument takes precedence.
import * as algokit from '@algorandfoundation/algokit-utils'

// Using constructor argument
const client = algokit.getDispenserApiTestnetClient({ authToken: 'your_auth_token' })
const client = algokit.getTestNetDispenserApiClient({ authToken: 'your_auth_token' })

// Using environment variable
process.env['ALGOKIT_DISPENSER_ACCESS_TOKEN'] = 'your_auth_token'
const client = algokit.getDispenserApiTestnetClient()
const client = algokit.getTestNetDispenserApiClient()
```

## Funding an Account
Expand Down
4 changes: 2 additions & 2 deletions docs/capabilities/transfer.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ The `ensureFunded` function automatically funds an account to maintain a minimum

- All properties in [`SendTransactionParams`](./transaction.md#sendtransactionparams)
- `accountToFund: SendTransactionFrom | string` - The account that is to be funded
- `fundingSource?: SendTransactionFrom | DispenserApiTestnetClient` - The account that is the source of funds or a dispenser API client. If not specified, it will use the [dispenser](./account.md#dispenser)
- `fundingSource?: SendTransactionFrom | TestNetDispenserApiClient` - The account that is the source of funds or a dispenser API client. If not specified, it will use the [dispenser](./account.md#dispenser)
- `minSpendingBalance: AlgoAmount` - The minimum balance of ALGOs that the account should have available to spend (i.e., on top of the minimum balance requirement)
- `minFundingIncrement?: AlgoAmount` - When issuing a funding amount, the minimum amount to transfer. This avoids many small transfers if this function gets called often on an active account
- `transactionParams?: SuggestedParams` - The optional [transaction parameters](./transaction.md#transaction-params)
- `note?: TransactionNote` - The [transaction note](./transaction.md#transaction-notes)

The function calls Algod to find the current balance and minimum balance requirement, calculates the difference between those two numbers, and checks to see if it's more than the `minSpendingBalance`. If so, it will send the difference, or the `minFundingIncrement` if that is specified. If the `fundingSource` is an instance of `DispenserApiTestnetClient`, the function will use the dispenser API to fund the account. Refer to [algokit-cli documentation](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/dispenser.md#ci-access-token) for details on obtaining an access token for AlgoKit TestNet Dispenser API.
The function calls Algod to find the current balance and minimum balance requirement, calculates the difference between those two numbers, and checks to see if it's more than the `minSpendingBalance`. If so, it will send the difference, or the `minFundingIncrement` if that is specified. If the `fundingSource` is an instance of `TestNetDispenserApiClient`, the function will use the dispenser API to fund the account. Refer to [algokit-cli documentation](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/features/dispenser.md#ci-access-token) for details on obtaining an access token for AlgoKit TestNet Dispenser API.

## `transferAsset`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[@algorandfoundation/algokit-utils](../README.md) / [types/dispenser-client](../modules/types_dispenser_client.md) / DispenserApiTestnetClient
[@algorandfoundation/algokit-utils](../README.md) / [types/dispenser-client](../modules/types_dispenser_client.md) / TestNetDispenserApiClient

# Class: DispenserApiTestnetClient
# Class: TestNetDispenserApiClient

[types/dispenser-client](../modules/types_dispenser_client.md).DispenserApiTestnetClient
[types/dispenser-client](../modules/types_dispenser_client.md).TestNetDispenserApiClient

`DispenserApiTestnetClient` is a class that provides methods to interact with the [Algorand TestNet Dispenser API](https://github.com/algorandfoundation/algokit/blob/main/docs/testnet_api.md).
`TestNetDispenserApiClient` is a class that provides methods to interact with the [Algorand TestNet Dispenser API](https://github.com/algorandfoundation/algokit/blob/main/docs/testnet_api.md).
It allows you to fund an address with Algos, refund a transaction, and get the funding limit for the Algo asset.

The class requires an authentication token and a request timeout to be initialized. The authentication token can be provided
Expand All @@ -27,7 +27,7 @@ limit - Sends a request to the dispenser API to get the funding limit for the Al
**`Example`**

```typescript
const client = new DispenserApiTestnetClient({ authToken: 'your_auth_token', requestTimeout: 30 });
const client = new TestNetDispenserApiClient({ authToken: 'your_auth_token', requestTimeout: 30 });
const fundResponse = await client.fund('your_address', 100);
const limitResponse = await client.getLimit();
await client.refund('your_transaction_id');
Expand All @@ -41,40 +41,40 @@ If neither the environment variable 'ALGOKIT_DISPENSER_ACCESS_TOKEN' nor the aut

### Constructors

- [constructor](types_dispenser_client.DispenserApiTestnetClient.md#constructor)
- [constructor](types_dispenser_client.TestNetDispenserApiClient.md#constructor)

### Properties

- [\_authToken](types_dispenser_client.DispenserApiTestnetClient.md#_authtoken)
- [\_requestTimeout](types_dispenser_client.DispenserApiTestnetClient.md#_requesttimeout)
- [\_authToken](types_dispenser_client.TestNetDispenserApiClient.md#_authtoken)
- [\_requestTimeout](types_dispenser_client.TestNetDispenserApiClient.md#_requesttimeout)

### Accessors

- [authToken](types_dispenser_client.DispenserApiTestnetClient.md#authtoken)
- [requestTimeout](types_dispenser_client.DispenserApiTestnetClient.md#requesttimeout)
- [authToken](types_dispenser_client.TestNetDispenserApiClient.md#authtoken)
- [requestTimeout](types_dispenser_client.TestNetDispenserApiClient.md#requesttimeout)

### Methods

- [fund](types_dispenser_client.DispenserApiTestnetClient.md#fund)
- [getLimit](types_dispenser_client.DispenserApiTestnetClient.md#getlimit)
- [processDispenserRequest](types_dispenser_client.DispenserApiTestnetClient.md#processdispenserrequest)
- [refund](types_dispenser_client.DispenserApiTestnetClient.md#refund)
- [fund](types_dispenser_client.TestNetDispenserApiClient.md#fund)
- [getLimit](types_dispenser_client.TestNetDispenserApiClient.md#getlimit)
- [processDispenserRequest](types_dispenser_client.TestNetDispenserApiClient.md#processdispenserrequest)
- [refund](types_dispenser_client.TestNetDispenserApiClient.md#refund)

## Constructors

### constructor

**new DispenserApiTestnetClient**(`params`)
**new TestNetDispenserApiClient**(`params`)

#### Parameters

| Name | Type |
| :------ | :------ |
| `params` | ``null`` \| [`DispenserApiTestnetClientParams`](../interfaces/types_dispenser_client.DispenserApiTestnetClientParams.md) |
| `params` | ``null`` \| [`TestNetDispenserApiClientParams`](../interfaces/types_dispenser_client.TestNetDispenserApiClientParams.md) |

#### Defined in

[src/types/dispenser-client.ts:61](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L61)
[src/types/dispenser-client.ts:63](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L63)

## Properties

Expand All @@ -84,7 +84,7 @@ If neither the environment variable 'ALGOKIT_DISPENSER_ACCESS_TOKEN' nor the aut

#### Defined in

[src/types/dispenser-client.ts:58](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L58)
[src/types/dispenser-client.ts:60](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L60)

___

Expand All @@ -94,7 +94,7 @@ ___

#### Defined in

[src/types/dispenser-client.ts:59](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L59)
[src/types/dispenser-client.ts:61](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L61)

## Accessors

Expand All @@ -110,7 +110,7 @@ The authentication token used for API requests.

#### Defined in

[src/types/dispenser-client.ts:77](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L77)
[src/types/dispenser-client.ts:79](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L79)

___

Expand All @@ -126,7 +126,7 @@ The timeout for API requests, in seconds.

#### Defined in

[src/types/dispenser-client.ts:81](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L81)
[src/types/dispenser-client.ts:83](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L83)

## Methods

Expand All @@ -151,7 +151,7 @@ DispenserFundResponse: An object containing the transaction ID and funded amount

#### Defined in

[src/types/dispenser-client.ts:142](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L142)
[src/types/dispenser-client.ts:144](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L144)

___

Expand All @@ -169,7 +169,7 @@ DispenserLimitResponse: An object containing the funding limit amount.

#### Defined in

[src/types/dispenser-client.ts:168](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L168)
[src/types/dispenser-client.ts:170](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L170)

___

Expand All @@ -196,7 +196,7 @@ The API response.

#### Defined in

[src/types/dispenser-client.ts:95](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L95)
[src/types/dispenser-client.ts:97](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L97)

___

Expand All @@ -218,4 +218,4 @@ Sends a refund request to the dispenser API for the specified refundTxnId.

#### Defined in

[src/types/dispenser-client.ts:159](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L159)
[src/types/dispenser-client.ts:161](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L161)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#### Defined in

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

___

Expand All @@ -29,4 +29,4 @@ ___

#### Defined in

[src/types/dispenser-client.ts:18](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L18)
[src/types/dispenser-client.ts:20](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L20)
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@

#### Defined in

[src/types/dispenser-client.ts:23](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L23)
[src/types/dispenser-client.ts:25](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L25)
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[@algorandfoundation/algokit-utils](../README.md) / [types/dispenser-client](../modules/types_dispenser_client.md) / TestNetDispenserApiClientParams

# Interface: TestNetDispenserApiClientParams

[types/dispenser-client](../modules/types_dispenser_client.md).TestNetDispenserApiClientParams

## Table of contents

### Properties

- [authToken](types_dispenser_client.TestNetDispenserApiClientParams.md#authtoken)
- [requestTimeout](types_dispenser_client.TestNetDispenserApiClientParams.md#requesttimeout)

## Properties

### authToken

**authToken**: `string`

#### Defined in

[src/types/dispenser-client.ts:29](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L29)

___

### requestTimeout

**requestTimeout**: ``null`` \| `number`

#### Defined in

[src/types/dispenser-client.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/dispenser-client.ts#L30)
2 changes: 1 addition & 1 deletion docs/code/interfaces/types_transfer.EnsureFundedParams.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ ___

### fundingSource

`Optional` **fundingSource**: [`SendTransactionFrom`](../modules/types_transaction.md#sendtransactionfrom) \| [`DispenserApiTestnetClient`](../classes/types_dispenser_client.DispenserApiTestnetClient.md)
`Optional` **fundingSource**: [`SendTransactionFrom`](../modules/types_transaction.md#sendtransactionfrom) \| [`TestNetDispenserApiClient`](../classes/types_dispenser_client.TestNetDispenserApiClient.md)

The account to use as a funding source, will default to using the dispenser account returned by `algokit.getDispenserAccount`

Expand Down
74 changes: 37 additions & 37 deletions docs/code/modules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@
- [getCreatorAppsByName](index.md#getcreatorappsbyname)
- [getDefaultLocalNetConfig](index.md#getdefaultlocalnetconfig)
- [getDispenserAccount](index.md#getdispenseraccount)
- [getDispenserApiTestnetClient](index.md#getdispenserapitestnetclient)
- [getIndexerConfigFromEnvironment](index.md#getindexerconfigfromenvironment)
- [getKmdWalletAccount](index.md#getkmdwalletaccount)
- [getLocalNetDispenserAccount](index.md#getlocalnetdispenseraccount)
- [getOrCreateKmdWalletAccount](index.md#getorcreatekmdwalletaccount)
- [getSenderAddress](index.md#getsenderaddress)
- [getSenderTransactionSigner](index.md#getsendertransactionsigner)
- [getTestNetDispenserApiClient](index.md#gettestnetdispenserapiclient)
- [getTransactionParams](index.md#gettransactionparams)
- [getTransactionWithSigner](index.md#gettransactionwithsigner)
- [isLocalNet](index.md#islocalnet)
Expand Down Expand Up @@ -1399,42 +1399,6 @@ If running on LocalNet then it will return the default dispenser account automat

___

### getDispenserApiTestnetClient

▸ **getDispenserApiTestnetClient**(`params?`): [`DispenserApiTestnetClient`](../classes/types_dispenser_client.DispenserApiTestnetClient.md)

Create a new DispenserApiTestnetClient instance.
Refer to [docs](https://github.com/algorandfoundation/algokit/blob/main/docs/testnet_api.md) on guidance to obtain an access token.

#### Parameters

| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `params` | ``null`` \| [`DispenserApiTestnetClientParams`](../interfaces/types_dispenser_client.DispenserApiTestnetClientParams.md) | `null` | An object containing parameters for the DispenserApiTestnetClient class. Or null if you want the client to load the access token from the environment variable `ALGOKIT_DISPENSER_ACCESS_TOKEN`. |

#### Returns

[`DispenserApiTestnetClient`](../classes/types_dispenser_client.DispenserApiTestnetClient.md)

An instance of the DispenserApiTestnetClient class.

**`Example`**

```ts
const client = algokit.getDispenserApiTestnetClient(
{
authToken: 'your_auth_token',
requestTimeout: 15,
}
)
```

#### Defined in

[src/dispenser-client.ts:19](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/dispenser-client.ts#L19)

___

### getIndexerConfigFromEnvironment

▸ **getIndexerConfigFromEnvironment**(): [`AlgoClientConfig`](../interfaces/types_network_client.AlgoClientConfig.md)
Expand Down Expand Up @@ -1594,6 +1558,42 @@ A transaction signer

___

### getTestNetDispenserApiClient

▸ **getTestNetDispenserApiClient**(`params?`): [`TestNetDispenserApiClient`](../classes/types_dispenser_client.TestNetDispenserApiClient.md)

Create a new TestNetDispenserApiClient instance.
Refer to [docs](https://github.com/algorandfoundation/algokit/blob/main/docs/testnet_api.md) on guidance to obtain an access token.

#### Parameters

| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `params` | ``null`` \| [`TestNetDispenserApiClientParams`](../interfaces/types_dispenser_client.TestNetDispenserApiClientParams.md) | `null` | An object containing parameters for the TestNetDispenserApiClient class. Or null if you want the client to load the access token from the environment variable `ALGOKIT_DISPENSER_ACCESS_TOKEN`. |

#### Returns

[`TestNetDispenserApiClient`](../classes/types_dispenser_client.TestNetDispenserApiClient.md)

An instance of the TestNetDispenserApiClient class.

**`Example`**

```ts
const client = algokit.getTestNetDispenserApiClient(
{
authToken: 'your_auth_token',
requestTimeout: 15,
}
)
```

#### Defined in

[src/dispenser-client.ts:19](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/dispenser-client.ts#L19)

___

### getTransactionParams

▸ **getTransactionParams**(`params`, `algod`): `Promise`<`SuggestedParamsWithMinFee` \| { `fee`: `number` ; `firstRound`: `number` ; `flatFee?`: `boolean` ; `genesisHash`: `string` ; `genesisID`: `string` ; `lastRound`: `number` }\>
Expand Down
4 changes: 2 additions & 2 deletions docs/code/modules/types_dispenser_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

### Classes

- [DispenserApiTestnetClient](../classes/types_dispenser_client.DispenserApiTestnetClient.md)
- [TestNetDispenserApiClient](../classes/types_dispenser_client.TestNetDispenserApiClient.md)

### Interfaces

- [DispenserApiTestnetClientParams](../interfaces/types_dispenser_client.DispenserApiTestnetClientParams.md)
- [DispenserFundResponse](../interfaces/types_dispenser_client.DispenserFundResponse.md)
- [DispenserLimitResponse](../interfaces/types_dispenser_client.DispenserLimitResponse.md)
- [TestNetDispenserApiClientParams](../interfaces/types_dispenser_client.TestNetDispenserApiClientParams.md)
Loading

0 comments on commit 03d3212

Please sign in to comment.