Skip to content

Commit

Permalink
feat: task opt in and opt out (#148)
Browse files Browse the repository at this point in the history
* feat: adding opt in

* feat: adding initial stage of opt out

* fix: fixing opt out and opt in

* test: added test and fixing other tests

* fix: fix a test

* fix: fixing exceeded timeout for test

* docs: added initial document

* fix: pr reviews

* test: fix a test

* feat: adding multiple opt in

* docs: changing docs for multiple opt in

* fix: fix  transfer tests

* fix: edit the settings

* docs: adding docs based on pr reviews

* fix: fix export for opt in and out

* docs: update generated docs

* refactor: refactoring based on pr review

* docs: updating generated docs

* chore: fixing audit error

* fix: removing redundant functions

* docs: updating generated docs
  • Loading branch information
negar-abbasi authored Oct 18, 2023
1 parent 98622e7 commit 0c6f5c1
Show file tree
Hide file tree
Showing 8 changed files with 557 additions and 76 deletions.
16 changes: 16 additions & 0 deletions docs/capabilities/asset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Assets

The asset management functions include opting in and out of assets, which are fundamental to asset interaction in a blockchain environment.
To see some usage examples check out the [automated tests](../../src/asset.spec.ts).

## `optIn`

Before an account can receive a specific asset, it must `opt-in` to receive it. An opt-in transaction places an asset holding of 0 into the account and increases its minimum balance by [100,000 microAlgos](https://developer.algorand.org/docs/get-details/asa/#assets-overview).
The `optIn` function facilitates the opt-in process for an account to multiple assets, allowing the account to receive and hold those assets.

## `optOut`

An account can opt out of an asset at any time. This means that the account will no longer hold the asset, and the account will no longer be able to receive the asset. The account also recovers the Minimum Balance Requirement for the asset (100,000 microAlgos)
The `optOut` function manages the opt-out process, permitting the account to discontinue holding a group of assets.

> **Note**:It's essential to note that an account can only opt-out of an asset if its balance of that asset is zero.
60 changes: 59 additions & 1 deletion docs/code/modules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
- [mnemonicAccount](index.md#mnemonicaccount)
- [mnemonicAccountFromEnvironment](index.md#mnemonicaccountfromenvironment)
- [multisigAccount](index.md#multisigaccount)
- [optIn](index.md#optin)
- [optOut](index.md#optout)
- [performAtomicTransactionComposerDryrun](index.md#performatomictransactioncomposerdryrun)
- [performAtomicTransactionComposerSimulate](index.md#performatomictransactioncomposersimulate)
- [performTemplateSubstitution](index.md#performtemplatesubstitution)
Expand Down Expand Up @@ -103,7 +105,7 @@ The AlgoKit config. To update it use the configure method.

#### Defined in

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

## Functions

Expand Down Expand Up @@ -1930,6 +1932,62 @@ A multisig account wrapper

___

### optIn

▸ **optIn**(`client`, `account`, `assetIds`): `Promise`<`Record`<`number`, `string`\>\>

Opt in to a list of assets on the Algorand blockchain.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `client` | `default` | An instance of the Algodv2 class from the `algosdk` library. |
| `account` | `default` | An instance of the Account class from the `algosdk` library representing the account that wants to opt in to the assets. |
| `assetIds` | `number`[] | An array of asset IDs that the account wants to opt in to. |

#### Returns

`Promise`<`Record`<`number`, `string`\>\>

A record object where the keys are the asset IDs and the values are the corresponding transaction IDs for successful opt-ins.

**`Throws`**

If there is an error during the opt-in process.

#### Defined in

[src/asset.ts:77](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/asset.ts#L77)

___

### optOut

▸ **optOut**(`client`, `account`, `assetIds`): `Promise`<`Record`<`number`, `string`\>\>

Opt out of multiple assets in Algorand blockchain.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `client` | `default` | An instance of the Algodv2 client used to interact with the Algorand blockchain. |
| `account` | `default` | The Algorand account that wants to opt out of the assets. |
| `assetIds` | `number`[] | An array of asset IDs representing the assets to opt out of. |

#### Returns

`Promise`<`Record`<`number`, `string`\>\>

- A record object containing asset IDs as keys and their corresponding transaction IDs as values.

#### Defined in

[src/asset.ts:130](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/asset.ts#L130)

___

### performAtomicTransactionComposerDryrun

▸ **performAtomicTransactionComposerDryrun**(`atc`, `algod`): `Promise`<`DryrunResult`\>
Expand Down
164 changes: 118 additions & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0c6f5c1

Please sign in to comment.