Skip to content

Commit

Permalink
Merge main into release
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Jul 12, 2023
2 parents d71c670 + 0eb2c5f commit b3fbb28
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 128 deletions.
66 changes: 66 additions & 0 deletions docs/code/interfaces/types_account.AccountConfig.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[@algorandfoundation/algokit-utils](../README.md) / [types/account](../modules/types_account.md) / AccountConfig

# Interface: AccountConfig

[types/account](../modules/types_account.md).AccountConfig

Config for an account config

## Table of contents

### Properties

- [accountMnemonic](types_account.AccountConfig.md#accountmnemonic)
- [accountName](types_account.AccountConfig.md#accountname)
- [senderAddress](types_account.AccountConfig.md#senderaddress)
- [senderMnemonic](types_account.AccountConfig.md#sendermnemonic)

## Properties

### accountMnemonic

**accountMnemonic**: `string`

Mnemonic for an account

#### Defined in

[src/types/account.ts:116](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L116)

___

### accountName

**accountName**: `string`

Account name used to retrieve config

#### Defined in

[src/types/account.ts:120](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L120)

___

### senderAddress

`Optional` **senderAddress**: `string`

Address of a rekeyed account

#### Defined in

[src/types/account.ts:118](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L118)

___

### senderMnemonic

`Optional` **senderMnemonic**: `string`

**`Deprecated`**

Renamed to senderAddress in 2.3.1

#### Defined in

[src/types/account.ts:123](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L123)
34 changes: 0 additions & 34 deletions docs/code/interfaces/types_network_client.AccountConfig.md

This file was deleted.

59 changes: 29 additions & 30 deletions docs/code/modules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ ___

**`Deprecated`**

use getAccount(account: { name: string; fundWith?: AlgoAmount } | string, algod: Algodv2, env: AlgoClientConfig, kmdClient?: Kmd) instead
use getAccount(account: { config: AccountConfig; fundWith?: AlgoAmount }, algod: Algodv2, kmdClient?: Kmd) instead

Returns an Algorand account with private key loaded by convention based on the given name identifier.

Expand Down Expand Up @@ -484,7 +484,7 @@ If that code runs against LocalNet then a wallet called `ACCOUNT` will automatic

| Name | Type | Description |
| :------ | :------ | :------ |
| `account` | `string` \| { `fundWith?`: [`AlgoAmount`](../classes/types_amount.AlgoAmount.md) ; `name`: `string` } | The details of the account to get, wither the name identifier (string) or an object with: * `name`: The name identifier of the account * `fundWith`: The amount to fund the account with it it gets created (when targeting LocalNet), if not specified then 1000 Algos will be funded from the dispenser account |
| `account` | `string` \| { `fundWith?`: [`AlgoAmount`](../classes/types_amount.AlgoAmount.md) ; `name`: `string` } | The details of the account to get, either the name identifier (string) or an object with: * `name`: The name identifier of the account * `fundWith`: The amount to fund the account with when it gets created (when targeting LocalNet), if not specified then 1000 Algos will be funded from the dispenser account |
| `algod` | `default` | An algod client |
| `kmdClient?` | `default` | An optional KMD client to use to create an account (when targeting LocalNet), if not specified then a default KMD client will be loaded from environment variables |

Expand All @@ -496,9 +496,9 @@ The requested account with private key loaded from the environment variables or

#### Defined in

[src/account.ts:93](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/account.ts#L93)
[src/account.ts:92](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/account.ts#L92)

**getAccount**(`account`, `algod`, `kmdClient`): `Promise`<`Account` \| [`SigningAccount`](../classes/types_account.SigningAccount.md)\>
**getAccount**(`account`, `algod`, `kmdClient?`): `Promise`<`Account` \| [`SigningAccount`](../classes/types_account.SigningAccount.md)\>

Returns an Algorand account with private key loaded by convention based on the given name identifier.

Expand All @@ -510,7 +510,7 @@ Default

If you have a mnemonic secret loaded into `process.env.ACCOUNT_MNEMONIC` then you can call the following to get that private key loaded into an account object:
```typescript
const account = await getAccount('ACCOUNT', algod, undefined, getAccountConfigFromEnvironment(accountName))
const account = await getAccount({config: getAccountConfigFromEnvironment('ACCOUNT')}, algod)
```

If that code runs against LocalNet then a wallet called `ACCOUNT` will automatically be created with an account that is automatically funded with 1000 (default) ALGOs from the default LocalNet dispenser.
Expand All @@ -519,12 +519,11 @@ If that code runs against LocalNet then a wallet called `ACCOUNT` will automatic

| Name | Type | Description |
| :------ | :------ | :------ |
| `account` | `Object` | The details of the account to get, wither the name identifier (string) or an object with: * `name`: The name identifier of the account * `fundWith`: The amount to fund the account with it it gets created (when targeting LocalNet), if not specified then 1000 Algos will be funded from the dispenser account |
| `account.config` | [`AccountConfig`](../interfaces/types_network_client.AccountConfig.md) | - |
| `account` | `Object` | The details of the account to get, an object with: * `config`: Account configuration. To get from environment use getAccountConfigFromEnvironment(accountName) * `fundWith`: The amount to fund the account with when it gets created (when targeting LocalNet), if not specified then 1000 Algos will be funded from the dispenser account |
| `account.config` | [`AccountConfig`](../interfaces/types_account.AccountConfig.md) | - |
| `account.fundWith?` | [`AlgoAmount`](../classes/types_amount.AlgoAmount.md) | - |
| `account.name` | `string` | - |
| `algod` | `default` | An algod client |
| `kmdClient` | `undefined` \| `default` | An optional KMD client to use to create an account (when targeting LocalNet), if not specified then a default KMD client will be loaded from environment variables |
| `kmdClient?` | `default` | An optional KMD client to use to create an account (when targeting LocalNet), if not specified then a default KMD client will be loaded from environment variables |

#### Returns

Expand All @@ -534,7 +533,7 @@ The requested account with private key loaded from the environment variables or

#### Defined in

[src/account.ts:121](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/account.ts#L121)
[src/account.ts:119](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/account.ts#L119)

___

Expand All @@ -556,7 +555,7 @@ Returns the string address of an Algorand account from a base64 encoded version

#### Defined in

[src/account.ts:208](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/account.ts#L208)
[src/account.ts:212](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/account.ts#L212)

___

Expand All @@ -578,20 +577,20 @@ Returns an account's address as a byte array

#### Defined in

[src/account.ts:200](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/account.ts#L200)
[src/account.ts:204](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/account.ts#L204)

___

### getAccountConfigFromEnvironment

**getAccountConfigFromEnvironment**(`accountName`): [`AccountConfig`](../interfaces/types_network_client.AccountConfig.md)
**getAccountConfigFromEnvironment**(`accountName`): [`AccountConfig`](../interfaces/types_account.AccountConfig.md)

Returns the Account configuration from enviroment variables
Returns the Account configuration from environment variables

**`Example`**

```ts
enviroment variables
environment variables
{accountName}_MNEMONIC
{accountName}_SENDER
```
Expand All @@ -604,11 +603,11 @@ enviroment variables

#### Returns

[`AccountConfig`](../interfaces/types_network_client.AccountConfig.md)
[`AccountConfig`](../interfaces/types_account.AccountConfig.md)

#### Defined in

[src/network-client.ts:88](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/network-client.ts#L88)
[src/account.ts:239](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/account.ts#L239)

___

Expand Down Expand Up @@ -665,7 +664,7 @@ Custom (e.g. default LocalNet, although we recommend loading this into a .env an

#### Defined in

[src/network-client.ts:146](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/network-client.ts#L146)
[src/network-client.ts:126](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/network-client.ts#L126)

___

Expand Down Expand Up @@ -722,7 +721,7 @@ Custom (e.g. default LocalNet, although we recommend loading this into a .env an

#### Defined in

[src/network-client.ts:179](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/network-client.ts#L179)
[src/network-client.ts:159](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/network-client.ts#L159)

___

Expand Down Expand Up @@ -762,7 +761,7 @@ Custom (e.g. default LocalNet, although we recommend loading this into a .env an

#### Defined in

[src/network-client.ts:202](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/network-client.ts#L202)
[src/network-client.ts:182](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/network-client.ts#L182)

___

Expand Down Expand Up @@ -1243,7 +1242,7 @@ Returns the Algorand configuration to point to the default LocalNet

#### Defined in

[src/network-client.ts:103](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/network-client.ts#L103)
[src/network-client.ts:83](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/network-client.ts#L83)

___

Expand All @@ -1269,7 +1268,7 @@ If running on LocalNet then it will return the default dispenser account automat

#### Defined in

[src/account.ts:220](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/account.ts#L220)
[src/account.ts:224](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/account.ts#L224)

___

Expand Down Expand Up @@ -1365,7 +1364,7 @@ If this is used via `getAccount`, then you can even use the same code that runs

| Name | Type | Description |
| :------ | :------ | :------ |
| `walletAccount` | `Object` | The wallet details with: * `name`: The name of the wallet to retrieve / create * `fundWith`: The number of Algos to fund the account with it it gets created, if not specified then 1000 Algos will be funded from the dispenser account |
| `walletAccount` | `Object` | The wallet details with: * `name`: The name of the wallet to retrieve / create * `fundWith`: The number of Algos to fund the account with when it gets created, if not specified then 1000 Algos will be funded from the dispenser account |
| `walletAccount.fundWith?` | [`AlgoAmount`](../classes/types_amount.AlgoAmount.md) | - |
| `walletAccount.name` | `string` | - |
| `algod` | `default` | An algod client |
Expand Down Expand Up @@ -1521,7 +1520,7 @@ ___

#### Defined in

[src/network-client.ts:213](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/network-client.ts#L213)
[src/network-client.ts:193](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/network-client.ts#L193)

___

Expand Down Expand Up @@ -1568,7 +1567,7 @@ ___

#### Defined in

[src/network-client.ts:209](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/network-client.ts#L209)
[src/network-client.ts:189](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/network-client.ts#L189)

___

Expand Down Expand Up @@ -1691,7 +1690,7 @@ This is a wrapper around algosdk.mnemonicToSecretKey to provide a more friendly/

#### Defined in

[src/account.ts:48](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/account.ts#L48)
[src/account.ts:47](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/account.ts#L47)

___

Expand All @@ -1716,7 +1715,7 @@ A multisig account wrapper

#### Defined in

[src/account.ts:17](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/account.ts#L17)
[src/account.ts:16](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/account.ts#L16)

___

Expand Down Expand Up @@ -1816,7 +1815,7 @@ This is a wrapper around algosdk.generateAccount to provide a more friendly/obvi

#### Defined in

[src/account.ts:58](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/account.ts#L58)
[src/account.ts:57](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/account.ts#L57)

___

Expand All @@ -1841,7 +1840,7 @@ The SigningAccount wrapper

#### Defined in

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

___

Expand Down Expand Up @@ -2074,7 +2073,7 @@ The SigningAccount wrapper

#### Defined in

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

___

Expand Down
3 changes: 0 additions & 3 deletions docs/code/modules/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ ___

**algorandFixture**(`fixtureConfig?`): [`AlgorandFixture`](../interfaces/types_testing.AlgorandFixture.md)

**`Deprecated`**

use algorandFixture(fixtureConfig: AlgorandFixtureConfig | undefined, config: AlgoConfig) instead
Creates a test fixture for automated testing against Algorand.
By default it tests against an environment variable specified client
if the standard environment variables are specified, otherwise against
Expand Down
1 change: 1 addition & 0 deletions docs/code/modules/types_account.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

### Interfaces

- [AccountConfig](../interfaces/types_account.AccountConfig.md)
- [TransactionSignerAccount](../interfaces/types_account.TransactionSignerAccount.md)

### Variables
Expand Down
1 change: 0 additions & 1 deletion docs/code/modules/types_network_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@

### Interfaces

- [AccountConfig](../interfaces/types_network_client.AccountConfig.md)
- [AlgoClientConfig](../interfaces/types_network_client.AlgoClientConfig.md)
- [AlgoConfig](../interfaces/types_network_client.AlgoConfig.md)
16 changes: 13 additions & 3 deletions src/account.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ describe('account', () => {

test('New account is retrieved and funded', async () => {
const { algod, kmd } = localnet.context
const config = algokit.getAccountConfigFromEnvironment(uuid())

const account = await algokit.getAccount(uuid(), algod, kmd)
const account = await algokit.getAccount({ config }, algod, kmd)
const accountInfo = await algod.accountInformation(account.addr).do()

expect(accountInfo['amount']).toBeGreaterThan(0)
Expand All @@ -20,12 +21,21 @@ describe('account', () => {
test('Same account is subsequently retrieved', async () => {
const { algod, kmd } = localnet.context
const name = uuid()
const config = algokit.getAccountConfigFromEnvironment(name)

const account = await algokit.getAccount(name, algod, kmd)
const account2 = await algokit.getAccount(name, algod, kmd)
const account = await algokit.getAccount({ config }, algod, kmd)
const account2 = await algokit.getAccount({ config }, algod, kmd)

expect(account).not.toBe(account2)
expect(account.addr).toBe(account2.addr)
expect(account.sk).toEqual(account2.sk)
}, 10_000)

test('Deprecated signature still works', async () => {
const { algod, kmd } = localnet.context
const account = await algokit.getAccount(uuid(), algod, kmd)
const accountInfo = await algod.accountInformation(account.addr).do()

expect(accountInfo['amount']).toBeGreaterThan(0)
}, 10_000)
})
Loading

0 comments on commit b3fbb28

Please sign in to comment.