From dfd5d547e90d2d5f3eca6769584d510cf519cc4a Mon Sep 17 00:00:00 2001 From: Rob Moore Date: Wed, 8 Nov 2023 01:56:03 +0800 Subject: [PATCH 1/6] test: Ensure that all transactions in a transaction group with ABI transaction args are signed --- src/types/app-client.spec.ts | 39 +++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/types/app-client.spec.ts b/src/types/app-client.spec.ts index d974a366..091d155a 100644 --- a/src/types/app-client.spec.ts +++ b/src/types/app-client.spec.ts @@ -1,5 +1,14 @@ import { describe, test } from '@jest/globals' -import algosdk, { ABIUintType, Account, Algodv2, Indexer, OnApplicationComplete, TransactionType, getApplicationAddress } from 'algosdk' +import algosdk, { + ABIUintType, + Account, + Algodv2, + Indexer, + OnApplicationComplete, + TransactionSigner, + TransactionType, + getApplicationAddress, +} from 'algosdk' import invariant from 'tiny-invariant' import * as algokit from '..' import { getTestingAppContract } from '../../tests/example-contracts/testing-app/contract' @@ -519,6 +528,34 @@ describe('application-client', () => { expect(returnValue?.returnValue).toBe(`Sent ${txn.transaction.amount}. test`) }) + test('Sign all transactions in group with abi call with transaction arg', async () => { + const { algod, indexer, testAccount } = localnet.context + const txn = await algokit.transferAlgos( + { + from: testAccount, + to: testAccount.addr, + amount: algokit.microAlgos(Math.ceil(Math.random() * 10000)), + skipSending: true, + }, + algod, + ) + const { client } = await deploy(testAccount, algod, indexer) + + let indexes: number[] = [] + const signer: TransactionSigner = (group, indxs) => { + indexes = indxs + return algokit.getSenderTransactionSigner(testAccount)(group, indexes) + } + + await client.call({ + method: 'call_abi_txn', + methodArgs: [txn.transaction, 'test'], + sender: { addr: testAccount.addr, signer }, + }) + + expect(indexes).toEqual([0, 1]) + }) + test('Construct transaction with abi encoding including foreign references not in signature', async () => { const { algod, indexer, testAccount } = localnet.context const { client } = await deploy(testAccount, algod, indexer) From caf9cedee4b591018222c0cb19c47e90ee2f5dea Mon Sep 17 00:00:00 2001 From: Rob Moore Date: Wed, 8 Nov 2023 02:29:51 +0800 Subject: [PATCH 2/6] feat: Added the ability to specify a rekey for app call transactions --- src/app.spec.ts | 29 ++++++++++++++++++++++++++++ src/app.ts | 8 ++++---- src/types/app-client.spec.ts | 37 ++++++++++++++++++++++++++++++++++++ src/types/app.ts | 5 +++++ 4 files changed, 75 insertions(+), 4 deletions(-) diff --git a/src/app.spec.ts b/src/app.spec.ts index 251b96f9..c6865d08 100644 --- a/src/app.spec.ts +++ b/src/app.spec.ts @@ -31,4 +31,33 @@ describe('app', () => { expect(app.confirmation).toBeTruthy() expect(app.confirmation?.applicationIndex).toBe(app.appId) }) + + test('createApp with rekey performs rekey', async () => { + const { algod, testAccount } = localnet.context + const rekeyTo = algokit.randomAccount() + const contract = await getTestingAppContract() + await algokit.createApp( + { + approvalProgram: contract.approvalProgram.replace('TMPL_UPDATABLE', '0').replace('TMPL_DELETABLE', '0').replace('TMPL_VALUE', '1'), + clearStateProgram: contract.clearStateProgram, + schema: contract.stateSchema, + from: testAccount, + args: { + rekeyTo: rekeyTo, + }, + }, + algod, + ) + + // If the rekey didn't work this will throw + const rekeyedAccount = algokit.rekeyedAccount(rekeyTo, testAccount.addr) + await algokit.transferAlgos( + { + amount: (0).algos(), + from: rekeyedAccount, + to: testAccount, + }, + algod, + ) + }) }) diff --git a/src/app.ts b/src/app.ts index f0277226..db6ada48 100644 --- a/src/app.ts +++ b/src/app.ts @@ -152,7 +152,7 @@ export async function createApp( from: getSenderAddress(from), note: encodeTransactionNote(note), ...getAppArgsForTransaction(args), - rekeyTo: undefined, + rekeyTo: args?.rekeyTo ? (typeof args.rekeyTo === 'string' ? args.rekeyTo : getSenderAddress(args.rekeyTo)) : undefined, }) const { confirmation } = await sendTransaction({ transaction, from, sendParams }, algod) @@ -239,7 +239,7 @@ export async function updateApp( from: getSenderAddress(from), note: encodeTransactionNote(note), ...getAppArgsForTransaction(args), - rekeyTo: undefined, + rekeyTo: args?.rekeyTo ? (typeof args.rekeyTo === 'string' ? args.rekeyTo : getSenderAddress(args.rekeyTo)) : undefined, }) const result = await sendTransaction({ transaction, from, sendParams }, algod) @@ -343,7 +343,7 @@ export async function callApp(call: AppCallParams, algod: Algodv2): Promise { expect(call.return.returnValue).toBe('Hello, test') }) + test('Call app with rekey', async () => { + const { algod, testAccount } = localnet.context + const rekeyTo = algokit.randomAccount() + const client = algokit.getAppClient( + { + resolveBy: 'id', + app: appSpec, + sender: testAccount, + id: 0, + }, + algod, + ) + await client.create({ + deployTimeParams: { + UPDATABLE: 0, + DELETABLE: 0, + VALUE: 1, + }, + }) + await client.optIn({ + method: 'opt_in', + methodArgs: [], + rekeyTo, + }) + + // If the rekey didn't work this will throw + const rekeyedAccount = algokit.rekeyedAccount(rekeyTo, testAccount.addr) + await algokit.transferAlgos( + { + amount: (0).algos(), + from: rekeyedAccount, + to: testAccount, + }, + algod, + ) + }) + test('Create app with abi', async () => { const { algod, testAccount } = localnet.context const client = algokit.getAppClient( diff --git a/src/types/app.ts b/src/types/app.ts index d6d9e7c3..2c39105c 100644 --- a/src/types/app.ts +++ b/src/types/app.ts @@ -76,6 +76,11 @@ export interface CoreAppCallArgs { apps?: number[] /** IDs of any assets to load into the foreignAssets array */ assets?: number[] + /** Optional account / account address that should be authorised to transact on behalf of the from account the app call is sent from after this transaction. + * + * **Note:** Use with extreme caution and review the [official rekey guidance](https://developer.algorand.org/docs/get-details/accounts/rekey/) first. + */ + rekeyTo?: SendTransactionFrom | string } /** From 5ce7b9263325c2fc1138689f79a3a2a6125823a2 Mon Sep 17 00:00:00 2001 From: Rob Moore Date: Wed, 8 Nov 2023 02:49:33 +0800 Subject: [PATCH 3/6] feat: Updated `assetBulkOptIn` and `assetBulkOptOut` to conform to algokit utils standards and added `assetOptIn` and `assetOptOut` methods BREAKING CHANGE: Renamed `optIn` to `assetBulkOptIn` and `optOut` to `assetBulkOptOut` and changed their signatures for consistency with the rest of AlgoKit Utils feat: Added assetOptIn and assetOptOut methods --- src/asset.spec.ts | 131 +++++++------ src/asset.ts | 282 ++++++++++++++++++++-------- src/index.ts | 2 +- src/testing/{asset.ts => _asset.ts} | 16 +- src/transaction.ts | 2 + src/transfer.spec.ts | 51 +++-- src/transfer.ts | 10 +- src/types/asset.ts | 43 +++++ 8 files changed, 348 insertions(+), 189 deletions(-) rename src/testing/{asset.ts => _asset.ts} (69%) create mode 100644 src/types/asset.ts diff --git a/src/asset.spec.ts b/src/asset.spec.ts index 8639d445..3f5f92bb 100644 --- a/src/asset.spec.ts +++ b/src/asset.spec.ts @@ -1,105 +1,88 @@ import { describe, test } from '@jest/globals' -import algosdk from 'algosdk' import * as algokit from './' -import { algos, microAlgos } from './amount' -import { optIn, optOut } from './asset' import { algorandFixture } from './testing' -import { ensureFunds, generateTestAsset } from './testing/asset' -import { ensureFunded } from './transfer' +import { generateTestAsset } from './testing/_asset' describe('asset', () => { const localnet = algorandFixture() beforeEach(localnet.beforeEach, 100_000) test('OptIn an asset to an account succeed', async () => { - const { algod, testAccount, kmd } = localnet.context + const { algod, testAccount, generateAccount } = localnet.context const dummyAssetId = await generateTestAsset(algod, testAccount, 1) const dummyAssetIds = [dummyAssetId] - const secondAccount = algosdk.generateAccount() + const secondAccount = await generateAccount({ initialFunds: (1).algos() }) const secondAccountInfo = await algod.accountInformation(secondAccount.addr).do() expect(secondAccountInfo['total-assets-opted-in']).toBe(0) - await ensureFunds(algod, secondAccount, kmd) - await optIn(algod, secondAccount, dummyAssetIds) + await algokit.assetBulkOptIn({ account: secondAccount, assetIds: dummyAssetIds }, algod) const testAccountInfoAfterOptIn = await algod.accountInformation(secondAccount.addr).do() expect(testAccountInfoAfterOptIn['total-assets-opted-in']).toBe(1) }) test('OptIn assets to an account second attempt failed ', async () => { - const { algod, testAccount, kmd } = localnet.context + const { algod, testAccount, generateAccount } = localnet.context const dummyAssetId = await generateTestAsset(algod, testAccount, 0) const dummyAssetId2 = await generateTestAsset(algod, testAccount, 0) const dummyAssetIds = [dummyAssetId, dummyAssetId2] - const secondAccount = algosdk.generateAccount() + const secondAccount = await generateAccount({ initialFunds: (1).algos() }) - await ensureFunds(algod, secondAccount, kmd) - await optIn(algod, secondAccount, dummyAssetIds) + await algokit.assetBulkOptIn({ account: secondAccount, assetIds: dummyAssetIds }, algod) const secondAccountInfo = await algod.accountInformation(secondAccount.addr).do() expect(secondAccountInfo['total-assets-opted-in']).toBe(2) // await optIn(algod, secondAccount, dummyAssetIds) - await expect(optIn(algod, secondAccount, [dummyAssetId])).rejects.toThrow( - `Assets ${dummyAssetId} cannot be opted in. Ensure that they are valid and that the account has not previously opted into them.`, + await expect(algokit.assetBulkOptIn({ account: secondAccount, assetIds: [dummyAssetId] }, algod)).rejects.toThrow( + `Asset ${dummyAssetId} cannot be opted in. Ensure that they are valid and that the account has not previously opted into them.`, ) }, 10e6) test('OptIn two batches of asset to an account succeed', async () => { - const { algod, testAccount, kmd } = localnet.context + const { algod, testAccount, generateAccount } = localnet.context const dummyAssetIds: number[] = [] - const secondAccount = algosdk.generateAccount() + const secondAccount = await generateAccount({ initialFunds: (3).algos() }) for (let i = 0; i < 20; i++) { const dummyAssetId = await generateTestAsset(algod, testAccount, 0) dummyAssetIds.push(dummyAssetId) } - await ensureFunded( - { - accountToFund: secondAccount, - minSpendingBalance: microAlgos(1), - minFundingIncrement: algos(3), - }, - algod, - kmd, - ) - await optIn(algod, secondAccount, dummyAssetIds) + await algokit.assetBulkOptIn({ account: secondAccount, assetIds: dummyAssetIds }, algod) const secondAccountInfo = await algod.accountInformation(secondAccount.addr).do() expect(secondAccountInfo['total-assets-opted-in']).toBe(20) }, 10e6) test('OptOut of an asset to an account succeed', async () => { - const { algod, testAccount, kmd } = localnet.context + const { algod, testAccount, generateAccount } = localnet.context const dummyAssetId = await generateTestAsset(algod, testAccount, 0) const dummyAssetId2 = await generateTestAsset(algod, testAccount, 0) const dummyAssetIds = [dummyAssetId, dummyAssetId2] - const secondAccount = algosdk.generateAccount() + const secondAccount = await generateAccount({ initialFunds: (1).algos() }) - await ensureFunds(algod, secondAccount, kmd) - await optIn(algod, secondAccount, dummyAssetIds) + await algokit.assetBulkOptIn({ account: secondAccount, assetIds: dummyAssetIds }, algod) const secondAccountInfo = await algod.accountInformation(secondAccount.addr).do() expect(secondAccountInfo['total-assets-opted-in']).toBe(2) - await optOut(algod, secondAccount, dummyAssetIds) + await algokit.assetBulkOptOut({ account: secondAccount, assetIds: dummyAssetIds }, algod) const secondAccountInfoAfterOptOut = await algod.accountInformation(secondAccount.addr).do() expect(secondAccountInfoAfterOptOut['total-assets-opted-in']).toBe(0) }) - test('OptOut of an not opt-in asset to an account failed ', async () => { - const { algod, testAccount, kmd } = localnet.context + test('OptOut of an not opt-in asset to an account failed', async () => { + const { algod, testAccount, generateAccount } = localnet.context const dummyAssetId = await generateTestAsset(algod, testAccount, 0) const dummyAssetIds = [dummyAssetId, 1234567, -132] - const secondAccount = algosdk.generateAccount() + const secondAccount = await generateAccount({ initialFunds: (1).algos() }) - await ensureFunds(algod, secondAccount, kmd) - await optIn(algod, secondAccount, [dummyAssetId]) + await algokit.assetBulkOptIn({ account: secondAccount, assetIds: [dummyAssetId] }, algod) const secondAccountInfo = await algod.accountInformation(secondAccount.addr).do() expect(secondAccountInfo['total-assets-opted-in']).toBe(1) - await expect(optOut(algod, secondAccount, dummyAssetIds)).rejects.toThrow( + await expect(algokit.assetBulkOptOut({ account: secondAccount, assetIds: dummyAssetIds }, algod)).rejects.toThrow( 'Assets 1234567, -132 cannot be opted out. Ensure that they are valid and that the account has previously opted into them and holds zero balance.', ) @@ -107,15 +90,14 @@ describe('asset', () => { expect(secondAccountInfoAfterFailedOptOut['total-assets-opted-in']).toBe(1) }) - test('OptOut of an non-zero balance asset to an account failed ', async () => { - const { algod, testAccount, kmd } = localnet.context + test('Bulk OptOut of an non-zero balance asset to an account failed ', async () => { + const { algod, testAccount, generateAccount } = localnet.context const dummyAssetId = await generateTestAsset(algod, testAccount, 0) const dummyAssetId2 = await generateTestAsset(algod, testAccount, 0) const dummyAssetIds = [dummyAssetId, dummyAssetId2] - const secondAccount = algosdk.generateAccount() + const secondAccount = await generateAccount({ initialFunds: (1).algos() }) - await ensureFunds(algod, secondAccount, kmd) - await optIn(algod, secondAccount, dummyAssetIds) + await algokit.assetBulkOptIn({ account: secondAccount, assetIds: dummyAssetIds }, algod) const secondAccountInfo = await algod.accountInformation(secondAccount.addr).do() expect(secondAccountInfo['total-assets-opted-in']).toBe(2) @@ -131,36 +113,69 @@ describe('asset', () => { algod, ) - await expect(optOut(algod, secondAccount, dummyAssetIds)).rejects.toThrow( - `Assets ${dummyAssetId} cannot be opted out. Ensure that they are valid and that the account has previously opted into them and holds zero balance.`, + await expect(algokit.assetBulkOptOut({ account: secondAccount, assetIds: dummyAssetIds }, algod)).rejects.toThrow( + `Asset ${dummyAssetId} cannot be opted out. Ensure that they are valid and that the account has previously opted into them and holds zero balance.`, ) const secondAccountInfoAfterFailedOptOut = await algod.accountInformation(secondAccount.addr).do() expect(secondAccountInfoAfterFailedOptOut['total-assets-opted-in']).toBe(2) }) + test('OptIn and OptOut of a single asset ', async () => { + const { algod, testAccount, generateAccount } = localnet.context + const dummyAssetId = await generateTestAsset(algod, testAccount, 0) + const secondAccount = await generateAccount({ initialFunds: (1).algos() }) + + await algokit.assetOptIn({ account: secondAccount, assetId: dummyAssetId }, algod) + + const secondAccountInfo = await algod.accountInformation(secondAccount.addr).do() + expect(secondAccountInfo['total-assets-opted-in']).toBe(1) + + await algokit.assetOptOut({ account: secondAccount, assetId: dummyAssetId }, algod) + + const secondAccountInfoAfterOptOut = await algod.accountInformation(secondAccount.addr).do() + expect(secondAccountInfoAfterOptOut['total-assets-opted-in']).toBe(0) + }) + + test('OptOut of non-zero balance single asset to an account fails by default', async () => { + const { algod, testAccount, generateAccount } = localnet.context + const dummyAssetId = await generateTestAsset(algod, testAccount, 0) + const secondAccount = await generateAccount({ initialFunds: (1).algos() }) + + await algokit.assetOptIn({ account: secondAccount, assetId: dummyAssetId }, algod) + + await algokit.transferAsset( + { + from: testAccount, + to: secondAccount.addr, + assetId: dummyAssetId, + amount: 5, + note: `Transfer 5 assets with id ${dummyAssetId}`, + }, + algod, + ) + + await expect(algokit.assetOptOut({ account: secondAccount, assetId: dummyAssetId }, algod)).rejects.toThrow( + `Asset ${dummyAssetId} cannot be opted out. Ensure that they are valid and that the account has previously opted into them and holds zero balance.`, + ) + + const secondAccountInfoAfterFailedOptOut = await algod.accountInformation(secondAccount.addr).do() + expect(secondAccountInfoAfterFailedOptOut['total-assets-opted-in']).toBe(1) + }) + test('OptOut of two batches of asset to an account succeed', async () => { - const { algod, testAccount, kmd } = localnet.context + const { algod, testAccount, generateAccount } = localnet.context const dummyAssetIds: number[] = [] - const secondAccount = algosdk.generateAccount() + const secondAccount = await generateAccount({ initialFunds: (3).algos() }) for (let i = 0; i < 20; i++) { const dummyAssetId = await generateTestAsset(algod, testAccount, 0) dummyAssetIds.push(dummyAssetId) } - await ensureFunded( - { - accountToFund: secondAccount, - minSpendingBalance: microAlgos(1), - minFundingIncrement: algos(3), - }, - algod, - kmd, - ) - await optIn(algod, secondAccount, dummyAssetIds) + await algokit.assetBulkOptIn({ account: secondAccount, assetIds: dummyAssetIds }, algod) const secondAccountInfo = await algod.accountInformation(secondAccount.addr).do() expect(secondAccountInfo['total-assets-opted-in']).toBe(20) - await optOut(algod, secondAccount, dummyAssetIds) + await algokit.assetBulkOptOut({ account: secondAccount, assetIds: dummyAssetIds }, algod) const secondAccountInfoAfterOptOut = await algod.accountInformation(secondAccount.addr).do() expect(secondAccountInfoAfterOptOut['total-assets-opted-in']).toBe(0) diff --git a/src/asset.ts b/src/asset.ts index 90131e9b..a955b746 100644 --- a/src/asset.ts +++ b/src/asset.ts @@ -1,8 +1,16 @@ -import algosdk, { Account, Algodv2 } from 'algosdk' -import { Config, sendGroupOfTransactions } from '.' -import { TransactionGroupToSend, TransactionToSign } from './types/transaction' - -const MaxTxGroupSize = 16 +import algosdk, { Algodv2 } from 'algosdk' +import { + Config, + MAX_TRANSACTION_GROUP_SIZE, + encodeLease, + encodeTransactionNote, + getSenderAddress, + getTransactionParams, + sendGroupOfTransactions, + sendTransaction, +} from '.' +import { AssetBulkOptInOutParams, AssetOptInParams, AssetOptOutParams } from './types/asset' +import { SendTransactionFrom, SendTransactionResult, TransactionGroupToSend, TransactionToSign } from './types/transaction' enum ValidationType { OptIn, @@ -13,36 +21,29 @@ function* chunks(arr: T[], n: number): Generator { for (let i = 0; i < arr.length; i += n) yield arr.slice(i, i + n) } -async function ensureAccountIsValid(client: algosdk.Algodv2, account: algosdk.Account) { - try { - await client.accountInformation(account.addr).do() - } catch (error) { - throw new Error(`Account address ${account.addr} does not exist`) - } -} - async function ensureAssetBalanceConditions( - client: algosdk.Algodv2, - account: algosdk.Account, + account: SendTransactionFrom, assetIds: number[], validationType: ValidationType, + algod: algosdk.Algodv2, ) { - const accountInfo = await client.accountInformation(account.addr).do() + const accountAddress = getSenderAddress(account) + const accountInfo = await algod.accountInformation(accountAddress).do() const assetPromises = assetIds.map(async (assetId) => { if (validationType === ValidationType.OptIn) { if (accountInfo.assets.find((a: Record) => a['asset-id'] === assetId)) { - Config.logger.debug(`Account ${account.addr} has already opted-in to asset ${assetId}`) + Config.logger.debug(`Account ${accountAddress} has already opted-in to asset ${assetId}`) return assetId } } else if (validationType === ValidationType.OptOut) { try { - const accountAssetInfo = await client.accountAssetInformation(account.addr, assetId).do() + const accountAssetInfo = await algod.accountAssetInformation(accountAddress, assetId).do() if (accountAssetInfo['asset-holding']['amount'] !== 0) { Config.logger.debug(`Asset ${assetId} is not with zero balance`) return assetId } } catch (e) { - Config.logger.debug(`Account ${account.addr} does not have asset ${assetId}`) + Config.logger.debug(`Account ${accountAddress} does not have asset ${assetId}`) return assetId } } @@ -51,65 +52,168 @@ async function ensureAssetBalanceConditions( const invalidAssets = (await Promise.all(assetPromises)).filter((assetId) => assetId !== null) if (invalidAssets.length > 0) { - let errorMsg = '' + let errorMessage = '' if (validationType === ValidationType.OptIn) { - errorMsg = `Assets ${invalidAssets.join( + errorMessage = `Asset${invalidAssets.length === 1 ? '' : 's'} ${invalidAssets.join( ', ', )} cannot be opted in. Ensure that they are valid and that the account has not previously opted into them.` } else if (validationType === ValidationType.OptOut) { - errorMsg = `Assets ${invalidAssets.join( + errorMessage = `Asset${invalidAssets.length === 1 ? '' : 's'} ${invalidAssets.join( ', ', )} cannot be opted out. Ensure that they are valid and that the account has previously opted into them and holds zero balance.` } - throw new Error(errorMsg) + throw new Error(errorMessage) + } +} + +/** + * Opt-in an account to an asset. + * @param optIn The opt-in definition + * @param algod An algod client + * @returns The transaction object and optionally the confirmation if it was sent to the chain (`skipSending` is `false` or unset) + * + * @example Usage example + * ```typescript + * await algokit.assetOptIn({ account, assetId }, algod) + * ``` + */ +export async function assetOptIn(optIn: AssetOptInParams, algod: Algodv2): Promise { + const { account, assetId, note, transactionParams, lease, ...sendParams } = optIn + + const transaction = algosdk.makeAssetTransferTxnWithSuggestedParamsFromObject({ + from: getSenderAddress(account), + to: getSenderAddress(account), + assetIndex: assetId, + amount: 0, + rekeyTo: undefined, + revocationTarget: undefined, + closeRemainderTo: undefined, + suggestedParams: await getTransactionParams(transactionParams, algod), + note: encodeTransactionNote(note), + }) + + const encodedLease = encodeLease(lease) + if (encodedLease) { + transaction.addLease(encodedLease) + } + + if (!sendParams.skipSending) { + Config.getLogger(sendParams.suppressLog).debug(`Opted-in ${getSenderAddress(account)} to asset ${assetId}`) + } + + return sendTransaction({ transaction, from: account, sendParams }, algod) +} + +/** + * Opt-out an account from an asset. + * @param optOut The opt-in definition + * @param algod An algod client + * @returns The transaction object and optionally the confirmation if it was sent to the chain (`skipSending` is `false` or unset) + * + * @example Usage example + * ```typescript + * await algokit.assetOptOut({ account, assetId, assetCreatorAddress }, algod) + * ``` + */ +export async function assetOptOut(optOut: AssetOptOutParams, algod: Algodv2): Promise { + const { + account, + assetId, + note, + transactionParams, + lease, + assetCreatorAddress: _assetCreatorAddress, + ensureZeroBalance, + ...sendParams + } = optOut + + if (ensureZeroBalance === undefined || ensureZeroBalance) { + await ensureAssetBalanceConditions(account, [assetId], ValidationType.OptOut, algod) } + + const assetCreatorAddress = _assetCreatorAddress ?? (await algod.getAssetByID(assetId).do()).params.creator + + const transaction = algosdk.makeAssetTransferTxnWithSuggestedParamsFromObject({ + from: getSenderAddress(account), + to: getSenderAddress(account), + assetIndex: assetId, + amount: 0, + rekeyTo: undefined, + revocationTarget: undefined, + closeRemainderTo: assetCreatorAddress, + suggestedParams: await getTransactionParams(transactionParams, algod), + note: encodeTransactionNote(note), + }) + + const encodedLease = encodeLease(lease) + if (encodedLease) { + transaction.addLease(encodedLease) + } + + if (!sendParams.skipSending) { + Config.getLogger(sendParams.suppressLog).debug(`Opted-out ${getSenderAddress(account)} from asset ${assetId}`) + } + + return sendTransaction({ transaction, from: account, sendParams }, algod) } /** * Opt in to a list of assets on the Algorand blockchain. * - * @param client - An instance of the Algodv2 class from the `algosdk` library. - * @param account - An instance of the Account class from the `algosdk` library representing the account that wants to opt in to the assets. - * @param assetIds - An array of asset IDs that the account wants to opt in to. + * @param optIn - The bulk opt-in request. + * @param algod - An instance of the Algodv2 class from the `algosdk` library. * @returns 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. + * @example `algokit.bulkOptIn({ account: account, assetIds: [12345, 67890] }, algod)` */ -export async function optIn(client: Algodv2, account: Account, assetIds: number[]) { +export async function assetBulkOptIn(optIn: AssetBulkOptInOutParams, algod: Algodv2) { + const { account, assetIds, validateBalances, transactionParams, note, maxFee, suppressLog } = optIn const result: Record = {} - await ensureAccountIsValid(client, account) - await ensureAssetBalanceConditions(client, account, assetIds, ValidationType.OptIn) - const assets = await Promise.all(assetIds.map((aid) => client.getAssetByID(aid).do())) - const suggestedParams = await client.getTransactionParams().do() + if (validateBalances === undefined || validateBalances) { + await ensureAssetBalanceConditions(account, assetIds, ValidationType.OptIn, algod) + } - for (const assetGroup of chunks(assets, MaxTxGroupSize)) { + const suggestedParams = await getTransactionParams(transactionParams, algod) + + for (const assetGroup of chunks(assetIds, MAX_TRANSACTION_GROUP_SIZE)) { try { - const transactionToSign: TransactionToSign[] = assetGroup.flatMap((asset) => [ - { - transaction: algosdk.makeAssetTransferTxnWithSuggestedParamsFromObject({ - from: account.addr, - to: account.addr, - assetIndex: asset.index, - amount: 0, - rekeyTo: undefined, - revocationTarget: undefined, - closeRemainderTo: undefined, - suggestedParams, - }), + const transactionsToSign: TransactionToSign[] = await Promise.all( + assetGroup.map(async (assetId) => ({ + transaction: ( + await assetOptIn( + { + account, + assetId, + transactionParams: suggestedParams, + note, + maxFee, + skipSending: true, + suppressLog: true, + }, + algod, + ) + ).transaction, signer: account, - }, - ]) + })), + ) const txnGrp: TransactionGroupToSend = { - transactions: transactionToSign, + transactions: transactionsToSign, signer: account, + sendParams: { + suppressLog: true, + }, } - const sendGroupOfTransactionsResult = await sendGroupOfTransactions(txnGrp, client) - assetGroup.map((asset, index) => { - result[asset.index] = sendGroupOfTransactionsResult.txIds[index] + const sendGroupOfTransactionsResult = await sendGroupOfTransactions(txnGrp, algod) + assetGroup.map((assetId, index) => { + result[assetId] = sendGroupOfTransactionsResult.txIds[index] - Config.logger.info( - `Successfully opted in of asset ${asset.index} with transaction ID ${sendGroupOfTransactionsResult.txIds[index]}, - grouped under ${sendGroupOfTransactionsResult.groupId} round ${sendGroupOfTransactionsResult.confirmations}.`, + Config.getLogger(suppressLog).info( + `Successfully opted in ${getSenderAddress(account)} for asset ${assetId} with transaction ID ${ + sendGroupOfTransactionsResult.txIds[index] + }, + grouped under ${sendGroupOfTransactionsResult.groupId} round ${sendGroupOfTransactionsResult.confirmations?.[0] + ?.confirmedRound}.`, ) }) } catch (e) { @@ -122,49 +226,63 @@ export async function optIn(client: Algodv2, account: Account, assetIds: number[ /** * Opt out of multiple assets in Algorand blockchain. * - * @param {Algodv2} client - An instance of the Algodv2 client used to interact with the Algorand blockchain. - * @param {Account} account - The Algorand account that wants to opt out of the assets. - * @param {number[]} assetIds - An array of asset IDs representing the assets to opt out of. - * @returns {Promise>} - A record object containing asset IDs as keys and their corresponding transaction IDs as values. + * @param optOut The bulk opt-out request. + * @param algod - An instance of the Algodv2 client used to interact with the Algorand blockchain. + * @returns A record object containing asset IDs as keys and their corresponding transaction IDs as values. + * @throws If there is an error during the opt-out process. + * @example `algokit.bulkOptOut({ account: account, assetIds: [12345, 67890] }, algod)` */ -export async function optOut(client: Algodv2, account: Account, assetIds: number[]): Promise> { +export async function assetBulkOptOut(optOut: AssetBulkOptInOutParams, algod: Algodv2): Promise> { + const { account, validateBalances, transactionParams, note, assetIds, maxFee, suppressLog } = optOut const result: Record = {} - // Verify assets - await ensureAccountIsValid(client, account) - await ensureAssetBalanceConditions(client, account, assetIds, ValidationType.OptOut) + if (validateBalances === undefined || validateBalances) { + await ensureAssetBalanceConditions(account, assetIds, ValidationType.OptOut, algod) + } + + const suggestedParams = await getTransactionParams(transactionParams, algod) - const assets = await Promise.all(assetIds.map((aid) => client.getAssetByID(aid).do())) - const suggestedParams = await client.getTransactionParams().do() + const assetDetails = await Promise.all(assetIds.map((assetId) => algod.getAssetByID(assetId).do())) - for (const assetGroup of chunks(assets, MaxTxGroupSize)) { + for (const assetGroup of chunks(assetDetails, MAX_TRANSACTION_GROUP_SIZE)) { try { - const transactionToSign: TransactionToSign[] = assetGroup.flatMap((asset) => [ - { - transaction: algosdk.makeAssetTransferTxnWithSuggestedParamsFromObject({ - assetIndex: asset.index, - amount: 0, - from: account.addr, - to: account.addr, - rekeyTo: undefined, - revocationTarget: undefined, - suggestedParams, - closeRemainderTo: asset.params.creator, - }), + const transactionToSign: TransactionToSign[] = await Promise.all( + assetGroup.map(async (asset) => ({ + transaction: ( + await assetOptOut( + { + account, + assetId: asset.index, + assetCreatorAddress: asset.params.creator, + transactionParams: suggestedParams, + note, + maxFee, + skipSending: true, + suppressLog: true, + }, + algod, + ) + ).transaction, signer: account, - }, - ]) + })), + ) const txnGrp: TransactionGroupToSend = { transactions: transactionToSign, signer: account, + sendParams: { + suppressLog: true, + }, } - const sendGroupOfTransactionsResult = await sendGroupOfTransactions(txnGrp, client) + const sendGroupOfTransactionsResult = await sendGroupOfTransactions(txnGrp, algod) assetGroup.map((asset, index) => { result[asset.index] = sendGroupOfTransactionsResult.txIds[index] - Config.logger.info( - `Successfully opted out of asset ${asset.index} with transaction ID ${sendGroupOfTransactionsResult.txIds[index]}, - grouped under ${sendGroupOfTransactionsResult.groupId} round ${sendGroupOfTransactionsResult.confirmations}.`, + Config.getLogger(suppressLog).info( + `Successfully opted out ${getSenderAddress(account)} from asset ${asset.index} with transaction ID ${ + sendGroupOfTransactionsResult.txIds[index] + }, + grouped under ${sendGroupOfTransactionsResult.groupId} round ${sendGroupOfTransactionsResult.confirmations?.[0] + ?.confirmedRound}.`, ) }) } catch (e) { diff --git a/src/index.ts b/src/index.ts index 7aa7bccc..122d0a8a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,7 @@ export * from './amount' export * from './app' export * from './app-client' export * from './app-deploy' -export { optIn, optOut } from './asset' +export * from './asset' export * from './dispenser-client' export * from './indexer-lookup' export * from './localnet' diff --git a/src/testing/asset.ts b/src/testing/_asset.ts similarity index 69% rename from src/testing/asset.ts rename to src/testing/_asset.ts index 09cd6809..aae8336b 100644 --- a/src/testing/asset.ts +++ b/src/testing/_asset.ts @@ -1,6 +1,4 @@ -import { Account, Algodv2, Kmd, makeAssetCreateTxnWithSuggestedParamsFromObject } from 'algosdk' -import { algos, microAlgos } from '../amount' -import { ensureFunded } from '../transfer' +import { Account, Algodv2, makeAssetCreateTxnWithSuggestedParamsFromObject } from 'algosdk' export async function generateTestAsset(client: Algodv2, sender: Account, total?: number) { total = !total ? Math.floor(Math.random() * 100) + 20 : total @@ -35,15 +33,3 @@ export async function generateTestAsset(client: Algodv2, sender: Account, total? return assetId } - -export async function ensureFunds(algod: Algodv2, account: Account, kmd: Kmd) { - await ensureFunded( - { - accountToFund: account, - minSpendingBalance: microAlgos(1), - minFundingIncrement: algos(1), - }, - algod, - kmd, - ) -} diff --git a/src/transaction.ts b/src/transaction.ts index 8e847e4f..1b17cb16 100644 --- a/src/transaction.ts +++ b/src/transaction.ts @@ -24,6 +24,8 @@ import { } from './types/transaction' import { toNumber } from './util' +export const MAX_TRANSACTION_GROUP_SIZE = 16 + /** Encodes a transaction note into a byte array ready to be included in an Algorand transaction. * * @param note The transaction note diff --git a/src/transfer.spec.ts b/src/transfer.spec.ts index 3042ca68..3a04c7fd 100644 --- a/src/transfer.spec.ts +++ b/src/transfer.spec.ts @@ -2,9 +2,8 @@ import { describe, test } from '@jest/globals' import algosdk, { TransactionType } from 'algosdk' import invariant from 'tiny-invariant' import * as algokit from './' -import { optIn } from './asset' import { algorandFixture } from './testing' -import { ensureFunds, generateTestAsset } from './testing/asset' +import { generateTestAsset } from './testing/_asset' describe('transfer', () => { const localnet = algorandFixture() @@ -72,12 +71,11 @@ describe('transfer', () => { }, 10e6) test('Transfer ASA, sender is not opted in', async () => { - const { algod, testAccount, kmd } = localnet.context + const { algod, testAccount, generateAccount } = localnet.context const dummyAssetId = await generateTestAsset(algod, testAccount, 100) - const secondAccount = algosdk.generateAccount() + const secondAccount = await generateAccount({ initialFunds: (1).algos() }) - await ensureFunds(algod, secondAccount, kmd) - await optIn(algod, secondAccount, [dummyAssetId]) + await algokit.assetOptIn({ account: secondAccount, assetId: dummyAssetId }, algod) try { await algokit.transferAsset( @@ -97,12 +95,11 @@ describe('transfer', () => { }, 10e6) test('Transfer ASA, asset doesnt exist', async () => { - const { algod, testAccount, kmd } = localnet.context + const { algod, testAccount, generateAccount } = localnet.context const dummyAssetId = await generateTestAsset(algod, testAccount, 100) - const secondAccount = algosdk.generateAccount() + const secondAccount = await generateAccount({ initialFunds: (1).algos() }) - await ensureFunds(algod, secondAccount, kmd) - await optIn(algod, secondAccount, [dummyAssetId]) + await algokit.assetOptIn({ account: secondAccount, assetId: dummyAssetId }, algod) try { await algokit.transferAsset( @@ -122,12 +119,11 @@ describe('transfer', () => { }, 10e6) test('Transfer ASA, without sending', async () => { - const { algod, testAccount, kmd } = localnet.context + const { algod, testAccount, generateAccount } = localnet.context const dummyAssetId = await generateTestAsset(algod, testAccount, 100) - const secondAccount = algosdk.generateAccount() + const secondAccount = await generateAccount({ initialFunds: (1).algos() }) - await ensureFunds(algod, secondAccount, kmd) - await optIn(algod, secondAccount, [dummyAssetId]) + await algokit.assetOptIn({ account: secondAccount, assetId: dummyAssetId }, algod) const response = await algokit.transferAsset( { @@ -146,12 +142,11 @@ describe('transfer', () => { }, 10e6) test('Transfer ASA, asset is transfered to another account', async () => { - const { algod, testAccount, kmd } = localnet.context + const { algod, testAccount, generateAccount } = localnet.context const dummyAssetId = await generateTestAsset(algod, testAccount, 100) - const secondAccount = algosdk.generateAccount() + const secondAccount = await generateAccount({ initialFunds: (1).algos() }) - await ensureFunds(algod, secondAccount, kmd) - await optIn(algod, secondAccount, [dummyAssetId]) + await algokit.assetOptIn({ account: secondAccount, assetId: dummyAssetId }, algod) await algokit.transferAsset( { @@ -172,16 +167,14 @@ describe('transfer', () => { }, 10e6) test('Transfer ASA, asset is transfered to another account from revocationTarget', async () => { - const { algod, testAccount, kmd } = localnet.context + const { algod, testAccount, generateAccount } = localnet.context const dummyAssetId = await generateTestAsset(algod, testAccount, 100) - const secondAccount = algosdk.generateAccount() - const clawbackAccount = algosdk.generateAccount() + const secondAccount = await generateAccount({ initialFunds: (1).algos() }) + const clawbackAccount = await generateAccount({ initialFunds: (1).algos() }) - await ensureFunds(algod, secondAccount, kmd) - await optIn(algod, secondAccount, [dummyAssetId]) + await algokit.assetOptIn({ account: secondAccount, assetId: dummyAssetId }, algod) - await ensureFunds(algod, clawbackAccount, kmd) - await optIn(algod, clawbackAccount, [dummyAssetId]) + await algokit.assetOptIn({ account: clawbackAccount, assetId: dummyAssetId }, algod) await algokit.transferAsset( { @@ -221,7 +214,7 @@ describe('transfer', () => { test('ensureFunded is sent and waited for with correct amount for new account', async () => { const { algod, kmd, testAccount } = localnet.context - const secondAccount = algosdk.generateAccount() + const secondAccount = algokit.randomAccount() const result = await algokit.ensureFunded( { @@ -252,8 +245,8 @@ describe('transfer', () => { }) test('ensureFunded respects minimum funding increment', async () => { - const { algod, testAccount, kmd } = localnet.context - const secondAccount = algosdk.generateAccount() + const { algod, testAccount, kmd, generateAccount } = localnet.context + const secondAccount = await generateAccount({ initialFunds: (1).algos() }) await algokit.ensureFunded( { @@ -272,7 +265,7 @@ describe('transfer', () => { test('ensureFunded uses dispenser account by default', async () => { const { algod, kmd } = localnet.context - const secondAccount = algosdk.generateAccount() + const secondAccount = algokit.randomAccount() const dispenser = await algokit.getDispenserAccount(algod, kmd) const result = await algokit.ensureFunded( diff --git a/src/transfer.ts b/src/transfer.ts index 08b403df..f68c89a7 100644 --- a/src/transfer.ts +++ b/src/transfer.ts @@ -133,9 +133,9 @@ export async function ensureFunded( if (fundAmount !== null) { if ((await isTestNet(algod)) && fundingSource instanceof TestNetDispenserApiClient) { - return fundUsingDispenserApi(fundingSource, addressToFund, fundAmount) as Promise + return await fundUsingDispenserApi(fundingSource, addressToFund, fundAmount) } else { - return fundUsingTransfer({ + return await fundUsingTransfer({ algod, addressToFund, funding, @@ -144,7 +144,7 @@ export async function ensureFunded( sendParams, note, kmd, - }) as Promise + }) } } @@ -178,7 +178,9 @@ export async function transferAsset(transfer: TransferAssetParams, algod: Algodv if (!sendParams.skipSending) { Config.getLogger(sendParams.suppressLog).debug( - `Transferring ASA (${assetId}) of amount ${amount} from ${getSenderAddress(from)} to ${to}`, + `Transferring ASA (${assetId}) of amount ${amount} from ${getSenderAddress(from)} to ${ + typeof to === 'string' ? to : getSenderAddress(to) + }`, ) } diff --git a/src/types/asset.ts b/src/types/asset.ts new file mode 100644 index 00000000..ff466386 --- /dev/null +++ b/src/types/asset.ts @@ -0,0 +1,43 @@ +import { SuggestedParams } from 'algosdk' +import { AlgoAmount } from './amount' +import { SendTransactionFrom, SendTransactionParams, TransactionNote } from './transaction' + +/** Parameters for `assetOptIn` call. */ +export interface AssetOptInParams extends SendTransactionParams { + /** The account to opt in/out for */ + account: SendTransactionFrom + /** The ID of the assets to opt in for / out of */ + assetId: number + /** Optional transaction parameters */ + transactionParams?: SuggestedParams + /** The (optional) transaction note */ + note?: TransactionNote + /** An (optional) [transaction lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to apply */ + lease?: string | Uint8Array +} + +/** Parameters for `assetOptOut` call. */ +export interface AssetOptOutParams extends AssetOptInParams { + /** The address of the creator account for the asset; if unspecified then it looks it up using algod */ + assetCreatorAddress?: string + /** Whether or not to validate the account has a zero-balance before issuing the opt-out; default = true */ + ensureZeroBalance?: boolean +} + +/** Parameters for `assetBulkOptIn` / `assetBulkOptOut` call. */ +export interface AssetBulkOptInOutParams { + /** The account to opt in/out for */ + account: SendTransactionFrom + /** The IDs of the assets to opt in for / out of */ + assetIds: number[] + /** Whether or not to validate the opt-in/out is valid before issuing transactions; default = true */ + validateBalances?: boolean + /** Optional transaction parameters */ + transactionParams?: SuggestedParams + /** The (optional) transaction note */ + note?: TransactionNote + /** The maximum fee that you are happy to pay per transaction (default: unbounded) - if this is set it's possible the transaction could get rejected during network congestion */ + maxFee?: AlgoAmount + /** Whether to suppress log messages from transaction send, default: do not suppress */ + suppressLog?: boolean +} From b371f42e6e9d17d4d5138d5f4f3365f33a10510f Mon Sep 17 00:00:00 2001 From: Rob Moore Date: Wed, 8 Nov 2023 02:51:04 +0800 Subject: [PATCH 4/6] feat: Added algokit.rekeyAccount function --- src/transfer.spec.ts | 40 ++++++++++++++++++++++++++++++++++++++++ src/transfer.ts | 38 +++++++++++++++++++++++++++++++++++++- src/types/transfer.ts | 12 ++++++++++++ 3 files changed, 89 insertions(+), 1 deletion(-) diff --git a/src/transfer.spec.ts b/src/transfer.spec.ts index 3a04c7fd..e6e834a7 100644 --- a/src/transfer.spec.ts +++ b/src/transfer.spec.ts @@ -339,3 +339,43 @@ describe('transfer', () => { ).rejects.toThrowErrorMatchingInlineSnapshot('"dummy_error"') }) }) + +describe('rekey', () => { + const localnet = algorandFixture() + const env = process.env + + beforeEach(async () => { + jest.resetModules() + process.env = { ...env } + await localnet.beforeEach() + }, 10_000) + + afterEach(() => { + process.env = env + }) + + test('Rekey works', async () => { + const { algod, testAccount } = localnet.context + const secondAccount = algosdk.generateAccount() + const rekeyedAccount = algokit.rekeyedAccount(secondAccount, testAccount.addr) + + await algokit.rekeyAccount( + { + from: testAccount, + rekeyTo: secondAccount, + note: 'Rekey', + }, + algod, + ) + + // This will throw if the rekey wasn't successful + await algokit.transferAlgos( + { + amount: (1).microAlgos(), + from: rekeyedAccount, + to: testAccount.addr, + }, + algod, + ) + }) +}) diff --git a/src/transfer.ts b/src/transfer.ts index f68c89a7..21754d7e 100644 --- a/src/transfer.ts +++ b/src/transfer.ts @@ -5,7 +5,7 @@ import { encodeTransactionNote, getSenderAddress, getTransactionParams, sendTran import { AlgoAmount } from './types/amount' import { TestNetDispenserApiClient } from './types/dispenser-client' import { SendTransactionResult, TransactionNote } from './types/transaction' -import { AlgoTransferParams, EnsureFundedParams, EnsureFundedReturnType, TransferAssetParams } from './types/transfer' +import { AlgoRekeyParams, AlgoTransferParams, EnsureFundedParams, EnsureFundedReturnType, TransferAssetParams } from './types/transfer' import { calculateFundAmount } from './util' async function fundUsingDispenserApi( @@ -186,3 +186,39 @@ export async function transferAsset(transfer: TransferAssetParams, algod: Algodv return sendTransaction({ transaction, from, sendParams }, algod) } + +/** + * Rekey an account to a new address. + * + * **Note:** Please be careful with this function and be sure to read the [official rekey guidance](https://developer.algorand.org/docs/get-details/accounts/rekey/). + * + * @param rekey The rekey definition + * @param algod An algod client + * @returns The transaction object and optionally the confirmation if it was sent to the chain (`skipSending` is `false` or unset) + * + * @example Usage example + * ```typescript + * await algokit.rekeyAccount({ from, rekeyTo }, algod) + * ``` + */ +export async function rekeyAccount(rekey: AlgoRekeyParams, algod: Algodv2): Promise { + const { from, rekeyTo, note, transactionParams, ...sendParams } = rekey + + const transaction = algosdk.makePaymentTxnWithSuggestedParamsFromObject({ + from: getSenderAddress(from), + to: getSenderAddress(from), + rekeyTo: typeof rekeyTo === 'string' ? rekeyTo : getSenderAddress(rekeyTo), + amount: 0, + note: encodeTransactionNote(note), + suggestedParams: await getTransactionParams(transactionParams, algod), + closeRemainderTo: undefined, + }) + + if (!sendParams.skipSending) { + Config.getLogger(sendParams.suppressLog).debug( + `Rekeying ${getSenderAddress(from)} to ${typeof rekeyTo === 'string' ? rekeyTo : getSenderAddress(rekeyTo)}`, + ) + } + + return sendTransaction({ transaction, from, sendParams }, algod) +} diff --git a/src/types/transfer.ts b/src/types/transfer.ts index 9a251584..4153defe 100644 --- a/src/types/transfer.ts +++ b/src/types/transfer.ts @@ -17,6 +17,18 @@ export interface AlgoTransferParams extends SendTransactionParams { note?: TransactionNote } +/** Parameters for `rekeyAccount` call. */ +export interface AlgoRekeyParams extends SendTransactionParams { + /** The account that will be rekeyed */ + from: SendTransactionFrom + /** The account / account address that will have the private key that is authorised to transact on behalf of the from account from now on */ + rekeyTo: SendTransactionFrom | string + /** Optional transaction parameters */ + transactionParams?: SuggestedParams + /** The (optional) transaction note */ + note?: TransactionNote +} + /** Parameters for `ensureFunded` call. */ export interface EnsureFundedParams extends SendTransactionParams { /** The account to fund */ From e7d606339046fb6ac335bb5c4d06bb1762178531 Mon Sep 17 00:00:00 2001 From: Rob Moore Date: Wed, 8 Nov 2023 02:51:24 +0800 Subject: [PATCH 5/6] feat: Added lease support to all transfer functions and added convenient lease encoding --- src/app.ts | 5 +-- src/asset.ts | 4 +-- src/transaction.ts | 36 +++++++++++++++++++ src/transfer.spec.ts | 84 +++++++++++++++++++++++++++++++++++++++++++ src/transfer.ts | 24 ++++++++++--- src/types/transfer.ts | 8 +++++ 6 files changed, 153 insertions(+), 8 deletions(-) diff --git a/src/app.ts b/src/app.ts index db6ada48..f78ea711 100644 --- a/src/app.ts +++ b/src/app.ts @@ -15,6 +15,7 @@ import { Buffer } from 'buffer' import { Config } from './' import { controlFees, + encodeLease, encodeTransactionNote, getAtomicTransactionComposerTransactions, getSenderAddress, @@ -576,7 +577,7 @@ export function getAppArgsForTransaction(args?: RawAppCallArgs) { boxes: args.boxes?.map(getBoxReference), foreignApps: args?.apps, foreignAssets: args?.assets, - lease: typeof args?.lease === 'string' ? encoder.encode(args?.lease) : args?.lease, + lease: encodeLease(args?.lease), } } @@ -614,7 +615,7 @@ export async function getAppArgsForABICall(args: ABIAppCallArgs, from: SendTrans sender: getSenderAddress(from), signer: signer, boxes: args.boxes?.map(getBoxReference), - lease: typeof args.lease === 'string' ? encoder.encode(args.lease) : args.lease, + lease: encodeLease(args.lease), appForeignApps: args.apps, appForeignAssets: args.assets, appAccounts: args.accounts?.map(_getAccountAddress), diff --git a/src/asset.ts b/src/asset.ts index a955b746..46e07c61 100644 --- a/src/asset.ts +++ b/src/asset.ts @@ -164,7 +164,7 @@ export async function assetOptOut(optOut: AssetOptOutParams, algod: Algodv2): Pr * @param algod - An instance of the Algodv2 class from the `algosdk` library. * @returns 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. - * @example `algokit.bulkOptIn({ account: account, assetIds: [12345, 67890] }, algod)` + * @example algokit.bulkOptIn({ account: account, assetIds: [12345, 67890] }, algod) */ export async function assetBulkOptIn(optIn: AssetBulkOptInOutParams, algod: Algodv2) { const { account, assetIds, validateBalances, transactionParams, note, maxFee, suppressLog } = optIn @@ -230,7 +230,7 @@ export async function assetBulkOptIn(optIn: AssetBulkOptInOutParams, algod: Algo * @param algod - An instance of the Algodv2 client used to interact with the Algorand blockchain. * @returns A record object containing asset IDs as keys and their corresponding transaction IDs as values. * @throws If there is an error during the opt-out process. - * @example `algokit.bulkOptOut({ account: account, assetIds: [12345, 67890] }, algod)` + * @example algokit.bulkOptOut({ account: account, assetIds: [12345, 67890] }, algod) */ export async function assetBulkOptOut(optOut: AssetBulkOptInOutParams, algod: Algodv2): Promise> { const { account, validateBalances, transactionParams, note, assetIds, maxFee, suppressLog } = optOut diff --git a/src/transaction.ts b/src/transaction.ts index 1b17cb16..1094c8b2 100644 --- a/src/transaction.ts +++ b/src/transaction.ts @@ -54,6 +54,42 @@ export function encodeTransactionNote(note?: TransactionNote): Uint8Array | unde } } +/** Encodes a transaction lease into a 32-byte array ready to be included in an Algorand transaction. + * + * @param lease The transaction lease as a string or binary array or null/undefined if there is no lease + * @returns the transaction lease ready for inclusion in a transaction or `undefined` if there is no lease + * @throws if the length of the data is > 32 bytes or empty + * @example algokit.encodeLease('UNIQUE_ID') + * @example algokit.encodeLease(new Uint8Array([1, 2, 3])) + */ +export function encodeLease(lease?: string | Uint8Array): Uint8Array | undefined { + if (lease == null || typeof lease === 'undefined') { + return undefined + } else if (typeof lease === 'object' && lease.constructor === Uint8Array) { + if (lease.length === 0 || lease.length > 32) { + throw new Error( + `Received invalid lease; expected something with length between 1 and 32, but received bytes with length ${lease.length}`, + ) + } + if (lease.length === 32) return lease + const lease32 = new Uint8Array(32) + lease32.set(lease, 0) + return lease32 + } else if (typeof lease === 'string') { + if (lease.length === 0 || lease.length > 32) { + throw new Error( + `Received invalid lease; expected something with length between 1 and 32, but received '${lease}' with length ${lease.length}`, + ) + } + const encoder = new TextEncoder() + const lease32 = new Uint8Array(32) + lease32.set(encoder.encode(lease), 0) + return lease32 + } else { + throw new Error(`Unknown lease type received of ${typeof lease}`) + } +} + /** * Returns the public address of the given transaction sender. * @param sender A transaction sender diff --git a/src/transfer.spec.ts b/src/transfer.spec.ts index e6e834a7..7710b624 100644 --- a/src/transfer.spec.ts +++ b/src/transfer.spec.ts @@ -48,7 +48,91 @@ describe('transfer', () => { expect(accountInfo['amount']).toBe(5_000_000) }) + test('Transfer Algo respects string lease', async () => { + const { algod, testAccount } = localnet.context + const secondAccount = algosdk.generateAccount() + + await algokit.transferAlgos( + { + from: testAccount, + to: secondAccount.addr, + amount: algokit.algos(1), + lease: 'test', + }, + algod, + ) + + await expect( + algokit.transferAlgos( + { + from: testAccount, + to: secondAccount.addr, + amount: algokit.algos(1), + lease: 'test', + }, + algod, + ), + ).rejects.toThrow(/overlapping lease/) + }) + + test('Transfer Algo respects byte array lease', async () => { + const { algod, testAccount } = localnet.context + const secondAccount = algosdk.generateAccount() + + await algokit.transferAlgos( + { + from: testAccount, + to: secondAccount.addr, + amount: algokit.algos(1), + lease: new Uint8Array([1, 2, 3, 4]), + }, + algod, + ) + + await expect( + algokit.transferAlgos( + { + from: testAccount, + to: secondAccount.addr, + amount: algokit.algos(1), + lease: new Uint8Array([1, 2, 3, 4]), + }, + algod, + ), + ).rejects.toThrow(/overlapping lease/) + }) + test('Transfer ASA, receiver is not opted in', async () => { + const { algod, testAccount, generateAccount } = localnet.context + const dummyAssetId = await generateTestAsset(algod, testAccount, 100) + const secondAccount = await generateAccount({ initialFunds: (1).algos() }) + await algokit.assetOptIn({ account: secondAccount, assetId: dummyAssetId }, algod) + await algokit.transferAsset( + { + from: testAccount, + to: secondAccount.addr, + assetId: dummyAssetId, + amount: 1, + lease: 'test', + }, + algod, + ) + + await expect( + algokit.transferAsset( + { + from: testAccount, + to: secondAccount.addr, + assetId: dummyAssetId, + amount: 1, + lease: 'test', + }, + algod, + ), + ).rejects.toThrow(/overlapping lease/) + }, 10e6) + + test('Transfer ASA respects lease', async () => { const { algod, testAccount } = localnet.context const dummyAssetId = await generateTestAsset(algod, testAccount, 100) const secondAccount = algosdk.generateAccount() diff --git a/src/transfer.ts b/src/transfer.ts index 21754d7e..f83830c8 100644 --- a/src/transfer.ts +++ b/src/transfer.ts @@ -1,7 +1,7 @@ import algosdk, { Algodv2, Kmd } from 'algosdk' import { Config, getDispenserAccount, microAlgos } from './' import { isTestNet } from './network-client' -import { encodeTransactionNote, getSenderAddress, getTransactionParams, sendTransaction } from './transaction' +import { encodeLease, encodeTransactionNote, getSenderAddress, getTransactionParams, sendTransaction } from './transaction' import { AlgoAmount } from './types/amount' import { TestNetDispenserApiClient } from './types/dispenser-client' import { SendTransactionResult, TransactionNote } from './types/transaction' @@ -57,6 +57,7 @@ async function fundUsingTransfer({ note: note ?? 'Funding account to meet minimum requirement', amount: amount, transactionParams: transactionParams, + lease: funding.lease, ...sendParams, }, algod, @@ -80,7 +81,7 @@ async function fundUsingTransfer({ * ``` */ export async function transferAlgos(transfer: AlgoTransferParams, algod: Algodv2): Promise { - const { from, to, amount, note, transactionParams, ...sendParams } = transfer + const { from, to, amount, note, transactionParams, lease, ...sendParams } = transfer const transaction = algosdk.makePaymentTxnWithSuggestedParamsFromObject({ from: getSenderAddress(from), @@ -92,6 +93,11 @@ export async function transferAlgos(transfer: AlgoTransferParams, algod: Algodv2 rekeyTo: undefined, }) + const encodedLease = encodeLease(lease) + if (encodedLease) { + transaction.addLease(encodedLease) + } + if (!sendParams.skipSending) { Config.getLogger(sendParams.suppressLog).debug(`Transferring ${amount.microAlgos}µALGOs from ${getSenderAddress(from)} to ${to}`) } @@ -163,7 +169,7 @@ export async function ensureFunded( * ``` */ export async function transferAsset(transfer: TransferAssetParams, algod: Algodv2): Promise { - const { from, to, assetId, amount, transactionParams, clawbackFrom, note, ...sendParams } = transfer + const { from, to, assetId, amount, transactionParams, clawbackFrom, note, lease, ...sendParams } = transfer const transaction = algosdk.makeAssetTransferTxnWithSuggestedParamsFromObject({ from: getSenderAddress(from), to: typeof to === 'string' ? to : getSenderAddress(to), @@ -176,6 +182,11 @@ export async function transferAsset(transfer: TransferAssetParams, algod: Algodv rekeyTo: undefined, }) + const encodedLease = encodeLease(lease) + if (encodedLease) { + transaction.addLease(encodedLease) + } + if (!sendParams.skipSending) { Config.getLogger(sendParams.suppressLog).debug( `Transferring ASA (${assetId}) of amount ${amount} from ${getSenderAddress(from)} to ${ @@ -202,7 +213,7 @@ export async function transferAsset(transfer: TransferAssetParams, algod: Algodv * ``` */ export async function rekeyAccount(rekey: AlgoRekeyParams, algod: Algodv2): Promise { - const { from, rekeyTo, note, transactionParams, ...sendParams } = rekey + const { from, rekeyTo, note, transactionParams, lease, ...sendParams } = rekey const transaction = algosdk.makePaymentTxnWithSuggestedParamsFromObject({ from: getSenderAddress(from), @@ -214,6 +225,11 @@ export async function rekeyAccount(rekey: AlgoRekeyParams, algod: Algodv2): Prom closeRemainderTo: undefined, }) + const encodedLease = encodeLease(lease) + if (encodedLease) { + transaction.addLease(encodedLease) + } + if (!sendParams.skipSending) { Config.getLogger(sendParams.suppressLog).debug( `Rekeying ${getSenderAddress(from)} to ${typeof rekeyTo === 'string' ? rekeyTo : getSenderAddress(rekeyTo)}`, diff --git a/src/types/transfer.ts b/src/types/transfer.ts index 4153defe..6df14abb 100644 --- a/src/types/transfer.ts +++ b/src/types/transfer.ts @@ -15,6 +15,8 @@ export interface AlgoTransferParams extends SendTransactionParams { transactionParams?: SuggestedParams /** The (optional) transaction note */ note?: TransactionNote + /** An (optional) [transaction lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to apply */ + lease?: string | Uint8Array } /** Parameters for `rekeyAccount` call. */ @@ -27,6 +29,8 @@ export interface AlgoRekeyParams extends SendTransactionParams { transactionParams?: SuggestedParams /** The (optional) transaction note */ note?: TransactionNote + /** An (optional) [transaction lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to apply */ + lease?: string | Uint8Array } /** Parameters for `ensureFunded` call. */ @@ -43,6 +47,8 @@ export interface EnsureFundedParams extends SendTransactionParams { transactionParams?: SuggestedParams /** The (optional) transaction note, default: "Funding account to meet minimum requirement" */ note?: TransactionNote + /** An (optional) [transaction lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to apply */ + lease?: string | Uint8Array } /** Parameters for `transferAsset` call. */ @@ -61,6 +67,8 @@ export interface TransferAssetParams extends SendTransactionParams { clawbackFrom?: SendTransactionFrom | string /** The (optional) transaction note */ note?: TransactionNote + /** An (optional) [transaction lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to apply */ + lease?: string | Uint8Array } export interface EnsureFundedReturnType { From 1fee7cf7333342c18c3d1103f8af95724c875555 Mon Sep 17 00:00:00 2001 From: Rob Moore Date: Thu, 9 Nov 2023 19:32:19 +0800 Subject: [PATCH 6/6] docs: Documentation updates for latest features --- docs/capabilities/account.md | 28 ++ docs/capabilities/app.md | 2 + docs/capabilities/asset.md | 96 ++++- docs/capabilities/transfer.md | 3 + docs/code/README.md | 1 + docs/code/enums/types_app.OnSchemaBreak.md | 6 +- docs/code/enums/types_app.OnUpdate.md | 8 +- .../interfaces/types_app.AppCallParams.md | 12 +- .../types_app.AppCallTransactionResult.md | 2 +- ...ypes_app.AppCallTransactionResultOfType.md | 2 +- .../types_app.AppCompilationResult.md | 4 +- .../interfaces/types_app.AppDeployMetadata.md | 8 +- .../types_app.AppDeploymentParams.md | 28 +- docs/code/interfaces/types_app.AppLookup.md | 4 +- docs/code/interfaces/types_app.AppMetadata.md | 16 +- .../interfaces/types_app.AppStorageSchema.md | 10 +- docs/code/interfaces/types_app.BoxName.md | 6 +- .../types_app.BoxValueRequestParams.md | 6 +- .../types_app.BoxValuesRequestParams.md | 6 +- .../code/interfaces/types_app.CompiledTeal.md | 10 +- .../interfaces/types_app.CoreAppCallArgs.md | 15 + .../interfaces/types_app.CreateAppParams.md | 16 +- .../interfaces/types_app.RawAppCallArgs.md | 23 +- .../interfaces/types_app.UpdateAppParams.md | 14 +- .../types_app_client.AppClientCallABIArgs.md | 21 +- .../types_app_client.AppClientCallRawArgs.md | 23 +- .../types_asset.AssetBulkOptInOutParams.md | 103 +++++ .../types_asset.AssetOptInParams.md | 205 ++++++++++ .../types_asset.AssetOptOutParams.md | 249 ++++++++++++ ...types_transaction.SendTransactionParams.md | 4 + .../types_transfer.AlgoRekeyParams.md | 203 ++++++++++ .../types_transfer.AlgoTransferParams.md | 13 + .../types_transfer.EnsureFundedParams.md | 25 +- .../types_transfer.EnsureFundedReturnType.md | 4 +- .../types_transfer.TransferAssetParams.md | 27 +- docs/code/modules/index.md | 353 +++++++++++++----- docs/code/modules/types_app.md | 10 +- docs/code/modules/types_asset.md | 11 + docs/code/modules/types_transfer.md | 1 + src/app.ts | 1 - src/transaction.ts | 2 +- 41 files changed, 1376 insertions(+), 205 deletions(-) create mode 100644 docs/code/interfaces/types_asset.AssetBulkOptInOutParams.md create mode 100644 docs/code/interfaces/types_asset.AssetOptInParams.md create mode 100644 docs/code/interfaces/types_asset.AssetOptOutParams.md create mode 100644 docs/code/interfaces/types_transfer.AlgoRekeyParams.md create mode 100644 docs/code/modules/types_asset.md diff --git a/docs/capabilities/account.md b/docs/capabilities/account.md index 06123c8d..fd454dda 100644 --- a/docs/capabilities/account.md +++ b/docs/capabilities/account.md @@ -38,3 +38,31 @@ In order to get the accounts you can use the underlying algosdk methods where re ### Dispenser - [`algokit.getDispenserAccount(algod, kmd?)`](../code/modules/index.md#getdispenseraccount) - Returns an account that can act as a dispenser to fund other accounts either via Kmd (when targeting LocalNet) or by convention from environment variable via `process.env.DISPENSER_MNEMONIC` (and optionally `process.env.DISPENSER_SENDER` if rekeyed) + +## Rekey account + +One of the unique features of Algorand is the ability to change the private key that can authorise transactions for an account. This is called [rekeying](https://developer.algorand.org/docs/get-details/accounts/rekey/). + +You can issue a transaction to rekey an account by using the `algokit.rekeyAccount(rekey, algod)` function. The `rekey` parameter is an [`AlgoRekeyParams`](../code/interfaces/types_transfer.AlgoRekeyParams.md) object with the following properties: + +- All properties in [`SendTransactionParams`](./transaction.md#sendtransactionparams) +- `from: SendTransactionFrom` - The account that will be rekeyed +- `rekeyTo: SendTransactionFrom | string` - The address of the account that will be used to authorise transactions for the rekeyed account going forward +- `transactionParams?: SuggestedParams` - The optional [transaction parameters](./transaction.md#transaction-params) +- `note?: TransactionNote` - The [transaction note](./transaction.md#transaction-notes) +- `lease?: string | Uint8Array`: A [lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to assign to the transaction to enforce a mutually exclusive transaction (useful to prevent double-posting and other scenarios) + +```typescript +// Example +await algokit.rekeyAccount( + { + from: account, + rekeyTo: newAccount, + // Optionally specify transactionParams, note, lease and transaction sending parameters + }, + algod, +) + +const rekeyedAccount = algokit.rekeyedAccount(newAccount, account.addr) +// rekeyedAccount can be used to sign transactions on behalf of account... +``` diff --git a/docs/capabilities/app.md b/docs/capabilities/app.md index eb58bb25..9c7cc463 100644 --- a/docs/capabilities/app.md +++ b/docs/capabilities/app.md @@ -18,6 +18,7 @@ This [type](../code/modules/types_app.md#appcallargs) is a union of two types: ` - `apps: number[]`: The ID of any apps to load to the [foreign apps array](https://developer.algorand.org/docs/get-details/dapps/smart-contracts/apps/#reference-arrays) - `assets: number[]`: The ID of any assets to load to the [foreign assets array](https://developer.algorand.org/docs/get-details/dapps/smart-contracts/apps/#reference-arrays) - `lease: string | Uint8Array`: A [lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to assign to the transaction to enforce a mutually exclusive transaction (useful to prevent double-posting and other scenarios) +- `rekeyTo: string | SendTransactionFrom`: An account or account address that should be authorised to transact on behalf of the account the app call is sent from after the app transaction is processed; **note:** use with extreme caution and review the [official rekey guidance](https://developer.algorand.org/docs/get-details/accounts/rekey/) first ### `ABIAppCallArgs` @@ -38,6 +39,7 @@ This [type](../code/modules/types_app.md#appcallargs) is a union of two types: ` - `Promise` - which allows you to use an AlgoKit Utils method call that [returns a transaction](transaction.md#sendtransactionresult) without needing to await the call and extract the transaction, if you do this be sure to use `skipWaiting: true` when specifying the [sending parameters](transaction.md#sendtransactionparams) so you get the transaction without sending it to the network - `boxes: (BoxReference | BoxIdentifier | algosdk.BoxReference)[]` - Any [boxes](#referencing-boxes) to load to the [boxes array](https://developer.algorand.org/docs/get-details/dapps/smart-contracts/apps/#reference-arrays) - `lease: string | Uint8Array`: A [lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to assign to the transaction to enforce a mutually exclusive transaction (useful to prevent double-posting and other scenarios) +- `rekeyTo: string | SendTransactionFrom`: An account or account address that should be authorised to transact on behalf of the account the app call is sent from after the app transaction is processed; **note:** use with extreme caution and review the [official rekey guidance](https://developer.algorand.org/docs/get-details/accounts/rekey/) first ### Utility methods diff --git a/docs/capabilities/asset.md b/docs/capabilities/asset.md index 828856fe..97347a11 100644 --- a/docs/capabilities/asset.md +++ b/docs/capabilities/asset.md @@ -3,14 +3,98 @@ 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` +## Transfer + +### `transferAsset` + +The key function to facilitate asset transfers is `transferAsset(transfer, algod)`, which returns a [`SendTransactionResult`](./transaction.md#sendtransactionresult) and takes a [`TransferAssetParams`](../code/interfaces/types_transfer.TransferAssetParams.md): + +- All properties in [`SendTransactionParams`](./transaction.md#sendtransactionparams) +- `from: SendTransactionFrom` - The account that will send the asset +- `to: SendTransactionFrom | string` - The account / account address that will receive the asset +- `assetId: number` - The asset id that will be transfered +- `amount: number | bigint` - The amount to send in the smallest divisible unit +- `transactionParams?: SuggestedParams` - The optional [transaction parameters](./transaction.md#transaction-params) +- `clawbackFrom: SendTransactionFrom | string` - An optional address of a target account from which to perform a clawback operation. Please note, in such cases senderAccount must be equal to clawback field on ASA metadata. +- `note?: TransactionNote` - The [transaction note](./transaction.md#transaction-notes) +- `lease?: string | Uint8Array`: A [lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to assign to the transaction to enforce a mutually exclusive transaction (useful to prevent double-posting and other scenarios) + +## Opt-in/out 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). + +When opting-out you generally want to be careful to ensure you have a zero-balance otherwise you will forfeit the balance you do have. By default, AlgoKit Utils protects you from making this mistake by checking you have a zero-balance before issuing the opt-out transaction. You can turn this check off if you want to avoid the extra calls to Algorand and are confident in what you are doing. + +AlgoKit Utils gives you functions that allow you to do opt-ins in bulk or as a single operation. The bulk operations give you less control over the sending semantics as they automatically send the transactions to Algorand in the most optimal way using transaction groups. + +### `assetOptIn` + +To opt-in an account to a single asset you can use the [`algokit.assetOptIn(optIn, algod)`](../code/modules/index.md#assetoptin) function. The `optIn` argument is an object [containing](../code/interfaces/types_asset.AssetOptInParams.md): + +- All properties in [`SendTransactionParams`](./transaction.md#sendtransactionparams) +- `account: SendTransactionFrom` - The account that will opt-in to the asset +- `assetId: number` - The asset id that will be opted-in to +- `transactionParams: SuggestedParams` - The optional [transaction parameters](./transaction.md#transaction-params) +- `note: TransactionNote` - The optional [transaction note](./transaction.md#transaction-notes) +- `lease: string | Uint8Array`: A [lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to assign to the transaction to enforce a mutually exclusive transaction (useful to prevent double-posting and other scenarios) + +```typescript +// Example +await algokit.assetOptIn({ + account: account, + assetId: 12345, + // Can optionally also specify transactionParams, note, lease and other send params +}) +``` + +### `assetOptOut` + +To opt-out an account from a single asset you can use the [`algokit.assetOptOut(optOut, algod)`](../code/modules/index.md#assetoptout) function. The `optOut` argument is an object [containing](../code/interfaces/types_asset.AssetOptOutParams.md): + +- All properties from [`assetOptIn`](#assetoptin) +- `assetCreatorAddress: string` - The address of the creator account for the asset; if unspecified then it looks it up using algod +- `ensureZeroBalance: boolean` - Whether or not to validate the account has a zero-balance before issuing the opt-out; defaults to true + +```typescript +// Example +await algokit.assetOptOut({ + account: account, + assetId: 12345, + assetCreatorAddress: creator, + // Can optionally also specify ensureZeroBalance, transactionParams, note, lease and other send params +}) +``` + +### `assetBulkOptIn` + +The [`assetBulkOptIn`](../code/modules/index.md#assetbulkoptin) function facilitates the opt-in process for an account to multiple assets, allowing the account to receive and hold those assets. + +```typescript +// Example +await algokit.assetBulkOptIn( + { + account: account, + assetIds: [12354, 673453], + // Can optionally also specify validateBalances, transactionParams, note + }, + algod, +) +``` + +### `assetBulkOptOut` -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. +The `assetBulkOptOut` function manages the opt-out process for a number of assets, 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. +```typescript +// Example +await algokit.assetBulkOptOut( + { + account: account, + assetIds: [12354, 673453], + // Can optionally also specify validateBalances, transactionParams, note + }, + algod, +) +``` diff --git a/docs/capabilities/transfer.md b/docs/capabilities/transfer.md index bd3be8fc..a1ce2922 100644 --- a/docs/capabilities/transfer.md +++ b/docs/capabilities/transfer.md @@ -14,6 +14,7 @@ The key function to facilitate Algo transfers is `algokit.transferAlgos(transfer - `amount: AlgoAmount` - The [amount](./amount.md) of ALGOs to send - `transactionParams?: SuggestedParams` - The optional [transaction parameters](./transaction.md#transaction-params) - `note?: TransactionNote` - The [transaction note](./transaction.md#transaction-notes) +- `lease?: string | Uint8Array`: A [lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to assign to the transaction to enforce a mutually exclusive transaction (useful to prevent double-posting and other scenarios) ## `ensureFunded` @@ -26,6 +27,7 @@ The `ensureFunded` function automatically funds an account to maintain a minimum - `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) +- `lease?: string | Uint8Array`: A [lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to assign to the transaction to enforce a mutually exclusive transaction (useful to prevent double-posting and other scenarios) 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. @@ -41,6 +43,7 @@ The key function to facilitate asset transfers is `transferAsset(transfer, algod - `transactionParams?: SuggestedParams` - The optional [transaction parameters](./transaction.md#transaction-params) - `clawbackFrom: SendTransactionFrom | string` - An optional address of a target account from which to perform a clawback operation. Please note, in such cases senderAccount must be equal to clawback field on ASA metadata. - `note?: TransactionNote` - The [transaction note](./transaction.md#transaction-notes) +- `lease?: string | Uint8Array`: A [lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to assign to the transaction to enforce a mutually exclusive transaction (useful to prevent double-posting and other scenarios) ## Dispenser diff --git a/docs/code/README.md b/docs/code/README.md index bee54a1a..e715758f 100644 --- a/docs/code/README.md +++ b/docs/code/README.md @@ -16,6 +16,7 @@ - [types/app-client](modules/types_app_client.md) - [types/app-client.spec](modules/types_app_client_spec.md) - [types/app-spec](modules/types_app_spec.md) +- [types/asset](modules/types_asset.md) - [types/config](modules/types_config.md) - [types/dispenser-client](modules/types_dispenser_client.md) - [types/dispenser-client.spec](modules/types_dispenser_client_spec.md) diff --git a/docs/code/enums/types_app.OnSchemaBreak.md b/docs/code/enums/types_app.OnSchemaBreak.md index b1240776..d7639887 100644 --- a/docs/code/enums/types_app.OnSchemaBreak.md +++ b/docs/code/enums/types_app.OnSchemaBreak.md @@ -24,7 +24,7 @@ Create a new app #### Defined in -[src/types/app.ts:283](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L283) +[src/types/app.ts:288](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L288) ___ @@ -36,7 +36,7 @@ Fail the deployment #### Defined in -[src/types/app.ts:279](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L279) +[src/types/app.ts:284](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L284) ___ @@ -48,4 +48,4 @@ Delete the app and create a new one in its place #### Defined in -[src/types/app.ts:281](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L281) +[src/types/app.ts:286](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L286) diff --git a/docs/code/enums/types_app.OnUpdate.md b/docs/code/enums/types_app.OnUpdate.md index 5e69c7a4..7331be79 100644 --- a/docs/code/enums/types_app.OnUpdate.md +++ b/docs/code/enums/types_app.OnUpdate.md @@ -25,7 +25,7 @@ Create a new app #### Defined in -[src/types/app.ts:273](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L273) +[src/types/app.ts:278](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L278) ___ @@ -37,7 +37,7 @@ Fail the deployment #### Defined in -[src/types/app.ts:267](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L267) +[src/types/app.ts:272](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L272) ___ @@ -49,7 +49,7 @@ Delete the app and create a new one in its place #### Defined in -[src/types/app.ts:271](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L271) +[src/types/app.ts:276](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L276) ___ @@ -61,4 +61,4 @@ Update the app #### Defined in -[src/types/app.ts:269](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L269) +[src/types/app.ts:274](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L274) diff --git a/docs/code/interfaces/types_app.AppCallParams.md b/docs/code/interfaces/types_app.AppCallParams.md index fbebfe5a..cfb4fd38 100644 --- a/docs/code/interfaces/types_app.AppCallParams.md +++ b/docs/code/interfaces/types_app.AppCallParams.md @@ -40,7 +40,7 @@ The id of the app to call #### Defined in -[src/types/app.ts:162](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L162) +[src/types/app.ts:167](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L167) ___ @@ -52,7 +52,7 @@ The arguments passed in to the app call #### Defined in -[src/types/app.ts:172](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L172) +[src/types/app.ts:177](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L177) ___ @@ -80,7 +80,7 @@ The type of call, everything except create (see `createApp`) and update (see `up #### Defined in -[src/types/app.ts:164](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L164) +[src/types/app.ts:169](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L169) ___ @@ -108,7 +108,7 @@ The account to make the call from #### Defined in -[src/types/app.ts:166](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L166) +[src/types/app.ts:171](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L171) ___ @@ -152,7 +152,7 @@ The (optional) transaction note #### Defined in -[src/types/app.ts:170](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L170) +[src/types/app.ts:175](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L175) ___ @@ -213,4 +213,4 @@ Optional transaction parameters #### Defined in -[src/types/app.ts:168](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L168) +[src/types/app.ts:173](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L173) diff --git a/docs/code/interfaces/types_app.AppCallTransactionResult.md b/docs/code/interfaces/types_app.AppCallTransactionResult.md index 651bfce5..8c42c0c6 100644 --- a/docs/code/interfaces/types_app.AppCallTransactionResult.md +++ b/docs/code/interfaces/types_app.AppCallTransactionResult.md @@ -69,7 +69,7 @@ If an ABI method was called the processed return value #### Defined in -[src/types/app.ts:205](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L205) +[src/types/app.ts:210](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L210) ___ diff --git a/docs/code/interfaces/types_app.AppCallTransactionResultOfType.md b/docs/code/interfaces/types_app.AppCallTransactionResultOfType.md index 605e882c..6c9e6e04 100644 --- a/docs/code/interfaces/types_app.AppCallTransactionResultOfType.md +++ b/docs/code/interfaces/types_app.AppCallTransactionResultOfType.md @@ -75,7 +75,7 @@ If an ABI method was called the processed return value #### Defined in -[src/types/app.ts:205](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L205) +[src/types/app.ts:210](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L210) ___ diff --git a/docs/code/interfaces/types_app.AppCompilationResult.md b/docs/code/interfaces/types_app.AppCompilationResult.md index d56efadd..2114b416 100644 --- a/docs/code/interfaces/types_app.AppCompilationResult.md +++ b/docs/code/interfaces/types_app.AppCompilationResult.md @@ -23,7 +23,7 @@ The compilation result of approval #### Defined in -[src/types/app.ts:312](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L312) +[src/types/app.ts:317](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L317) ___ @@ -35,4 +35,4 @@ The compilation result of clear #### Defined in -[src/types/app.ts:314](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L314) +[src/types/app.ts:319](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L319) diff --git a/docs/code/interfaces/types_app.AppDeployMetadata.md b/docs/code/interfaces/types_app.AppDeployMetadata.md index 3f72e88a..5aa7b7fb 100644 --- a/docs/code/interfaces/types_app.AppDeployMetadata.md +++ b/docs/code/interfaces/types_app.AppDeployMetadata.md @@ -31,7 +31,7 @@ Whether or not the app is deletable / permanent / unspecified #### Defined in -[src/types/app.ts:230](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L230) +[src/types/app.ts:235](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L235) ___ @@ -43,7 +43,7 @@ The unique name identifier of the app within the creator account #### Defined in -[src/types/app.ts:226](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L226) +[src/types/app.ts:231](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L231) ___ @@ -55,7 +55,7 @@ Whether or not the app is updatable / immutable / unspecified #### Defined in -[src/types/app.ts:232](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L232) +[src/types/app.ts:237](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L237) ___ @@ -67,4 +67,4 @@ The version of app that is / will be deployed #### Defined in -[src/types/app.ts:228](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L228) +[src/types/app.ts:233](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L233) diff --git a/docs/code/interfaces/types_app.AppDeploymentParams.md b/docs/code/interfaces/types_app.AppDeploymentParams.md index 3d2d2fc5..c2316630 100644 --- a/docs/code/interfaces/types_app.AppDeploymentParams.md +++ b/docs/code/interfaces/types_app.AppDeploymentParams.md @@ -49,7 +49,7 @@ Omit.approvalProgram #### Defined in -[src/types/app.ts:121](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L121) +[src/types/app.ts:126](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L126) ___ @@ -65,7 +65,7 @@ Omit.clearStateProgram #### Defined in -[src/types/app.ts:123](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L123) +[src/types/app.ts:128](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L128) ___ @@ -77,7 +77,7 @@ Any args to pass to any create transaction that is issued as part of deployment #### Defined in -[src/types/app.ts:300](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L300) +[src/types/app.ts:305](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L305) ___ @@ -89,7 +89,7 @@ Override the on-completion action for the create call; defaults to NoOp #### Defined in -[src/types/app.ts:302](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L302) +[src/types/app.ts:307](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L307) ___ @@ -101,7 +101,7 @@ Any args to pass to any delete transaction that is issued as part of deployment #### Defined in -[src/types/app.ts:306](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L306) +[src/types/app.ts:311](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L311) ___ @@ -113,7 +113,7 @@ Any deploy-time parameters to replace in the TEAL code #### Defined in -[src/types/app.ts:292](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L292) +[src/types/app.ts:297](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L297) ___ @@ -125,7 +125,7 @@ Optional cached value of the existing apps for the given creator #### Defined in -[src/types/app.ts:298](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L298) +[src/types/app.ts:303](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L303) ___ @@ -157,7 +157,7 @@ Omit.from #### Defined in -[src/types/app.ts:119](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L119) +[src/types/app.ts:124](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L124) ___ @@ -201,7 +201,7 @@ The deployment metadata #### Defined in -[src/types/app.ts:290](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L290) +[src/types/app.ts:295](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L295) ___ @@ -213,7 +213,7 @@ What action to perform if a schema break is detected #### Defined in -[src/types/app.ts:294](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L294) +[src/types/app.ts:299](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L299) ___ @@ -225,7 +225,7 @@ What action to perform if a TEAL update is detected #### Defined in -[src/types/app.ts:296](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L296) +[src/types/app.ts:301](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L301) ___ @@ -241,7 +241,7 @@ Omit.schema #### Defined in -[src/types/app.ts:135](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L135) +[src/types/app.ts:140](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L140) ___ @@ -273,7 +273,7 @@ Omit.transactionParams #### Defined in -[src/types/app.ts:125](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L125) +[src/types/app.ts:130](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L130) ___ @@ -285,4 +285,4 @@ Any args to pass to any update transaction that is issued as part of deployment #### Defined in -[src/types/app.ts:304](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L304) +[src/types/app.ts:309](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L309) diff --git a/docs/code/interfaces/types_app.AppLookup.md b/docs/code/interfaces/types_app.AppLookup.md index ad3537a2..85e64d88 100644 --- a/docs/code/interfaces/types_app.AppLookup.md +++ b/docs/code/interfaces/types_app.AppLookup.md @@ -21,7 +21,7 @@ A lookup of name -> Algorand app for a creator #### Defined in -[src/types/app.ts:250](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L250) +[src/types/app.ts:255](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L255) ___ @@ -31,4 +31,4 @@ ___ #### Defined in -[src/types/app.ts:249](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L249) +[src/types/app.ts:254](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L254) diff --git a/docs/code/interfaces/types_app.AppMetadata.md b/docs/code/interfaces/types_app.AppMetadata.md index 5c73bb6c..aa47c672 100644 --- a/docs/code/interfaces/types_app.AppMetadata.md +++ b/docs/code/interfaces/types_app.AppMetadata.md @@ -71,7 +71,7 @@ The metadata when the app was created #### Defined in -[src/types/app.ts:242](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L242) +[src/types/app.ts:247](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L247) ___ @@ -83,7 +83,7 @@ The round the app was created #### Defined in -[src/types/app.ts:238](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L238) +[src/types/app.ts:243](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L243) ___ @@ -99,7 +99,7 @@ Whether or not the app is deletable / permanent / unspecified #### Defined in -[src/types/app.ts:230](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L230) +[src/types/app.ts:235](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L235) ___ @@ -111,7 +111,7 @@ Whether or not the app is deleted #### Defined in -[src/types/app.ts:244](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L244) +[src/types/app.ts:249](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L249) ___ @@ -127,7 +127,7 @@ The unique name identifier of the app within the creator account #### Defined in -[src/types/app.ts:226](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L226) +[src/types/app.ts:231](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L231) ___ @@ -143,7 +143,7 @@ Whether or not the app is updatable / immutable / unspecified #### Defined in -[src/types/app.ts:232](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L232) +[src/types/app.ts:237](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L237) ___ @@ -155,7 +155,7 @@ The last round that the app was updated #### Defined in -[src/types/app.ts:240](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L240) +[src/types/app.ts:245](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L245) ___ @@ -171,4 +171,4 @@ The version of app that is / will be deployed #### Defined in -[src/types/app.ts:228](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L228) +[src/types/app.ts:233](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L233) diff --git a/docs/code/interfaces/types_app.AppStorageSchema.md b/docs/code/interfaces/types_app.AppStorageSchema.md index 80980b35..b280f70e 100644 --- a/docs/code/interfaces/types_app.AppStorageSchema.md +++ b/docs/code/interfaces/types_app.AppStorageSchema.md @@ -26,7 +26,7 @@ Any extra pages that are needed for the smart contract; if left blank then the r #### Defined in -[src/types/app.ts:186](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L186) +[src/types/app.ts:191](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L191) ___ @@ -38,7 +38,7 @@ Restricts number of byte slices in global state #### Defined in -[src/types/app.ts:184](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L184) +[src/types/app.ts:189](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L189) ___ @@ -50,7 +50,7 @@ Restricts number of ints in global state #### Defined in -[src/types/app.ts:182](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L182) +[src/types/app.ts:187](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L187) ___ @@ -62,7 +62,7 @@ Restricts number of byte slices in per-user local state #### Defined in -[src/types/app.ts:180](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L180) +[src/types/app.ts:185](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L185) ___ @@ -74,4 +74,4 @@ Restricts number of ints in per-user local state #### Defined in -[src/types/app.ts:178](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L178) +[src/types/app.ts:183](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L183) diff --git a/docs/code/interfaces/types_app.BoxName.md b/docs/code/interfaces/types_app.BoxName.md index b63f8b60..8dbee357 100644 --- a/docs/code/interfaces/types_app.BoxName.md +++ b/docs/code/interfaces/types_app.BoxName.md @@ -24,7 +24,7 @@ Name in UTF-8 #### Defined in -[src/types/app.ts:337](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L337) +[src/types/app.ts:342](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L342) ___ @@ -36,7 +36,7 @@ Name in Base64 #### Defined in -[src/types/app.ts:341](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L341) +[src/types/app.ts:346](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L346) ___ @@ -48,4 +48,4 @@ Name in binary bytes #### Defined in -[src/types/app.ts:339](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L339) +[src/types/app.ts:344](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L344) diff --git a/docs/code/interfaces/types_app.BoxValueRequestParams.md b/docs/code/interfaces/types_app.BoxValueRequestParams.md index 9108013e..cbc10e73 100644 --- a/docs/code/interfaces/types_app.BoxValueRequestParams.md +++ b/docs/code/interfaces/types_app.BoxValueRequestParams.md @@ -24,7 +24,7 @@ The ID of the app return box names for #### Defined in -[src/types/app.ts:349](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L349) +[src/types/app.ts:354](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L354) ___ @@ -36,7 +36,7 @@ The name of the box to return either as a string, binary array or `BoxName` #### Defined in -[src/types/app.ts:351](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L351) +[src/types/app.ts:356](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L356) ___ @@ -48,4 +48,4 @@ The ABI type to decode the value using #### Defined in -[src/types/app.ts:353](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L353) +[src/types/app.ts:358](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L358) diff --git a/docs/code/interfaces/types_app.BoxValuesRequestParams.md b/docs/code/interfaces/types_app.BoxValuesRequestParams.md index be8baef0..ad27419f 100644 --- a/docs/code/interfaces/types_app.BoxValuesRequestParams.md +++ b/docs/code/interfaces/types_app.BoxValuesRequestParams.md @@ -24,7 +24,7 @@ The ID of the app return box names for #### Defined in -[src/types/app.ts:361](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L361) +[src/types/app.ts:366](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L366) ___ @@ -36,7 +36,7 @@ The names of the boxes to return either as a string, binary array or BoxName` #### Defined in -[src/types/app.ts:363](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L363) +[src/types/app.ts:368](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L368) ___ @@ -48,4 +48,4 @@ The ABI type to decode the value using #### Defined in -[src/types/app.ts:365](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L365) +[src/types/app.ts:370](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L370) diff --git a/docs/code/interfaces/types_app.CompiledTeal.md b/docs/code/interfaces/types_app.CompiledTeal.md index e9785a2f..c553a01b 100644 --- a/docs/code/interfaces/types_app.CompiledTeal.md +++ b/docs/code/interfaces/types_app.CompiledTeal.md @@ -26,7 +26,7 @@ The compiled code #### Defined in -[src/types/app.ts:194](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L194) +[src/types/app.ts:199](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L199) ___ @@ -38,7 +38,7 @@ The base64 encoded code as a byte array #### Defined in -[src/types/app.ts:198](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L198) +[src/types/app.ts:203](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L203) ___ @@ -50,7 +50,7 @@ The has returned by the compiler #### Defined in -[src/types/app.ts:196](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L196) +[src/types/app.ts:201](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L201) ___ @@ -62,7 +62,7 @@ Source map from the compilation #### Defined in -[src/types/app.ts:200](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L200) +[src/types/app.ts:205](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L205) ___ @@ -74,4 +74,4 @@ Original TEAL code #### Defined in -[src/types/app.ts:192](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L192) +[src/types/app.ts:197](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L197) diff --git a/docs/code/interfaces/types_app.CoreAppCallArgs.md b/docs/code/interfaces/types_app.CoreAppCallArgs.md index 715e2c62..3f524ed0 100644 --- a/docs/code/interfaces/types_app.CoreAppCallArgs.md +++ b/docs/code/interfaces/types_app.CoreAppCallArgs.md @@ -21,6 +21,7 @@ Common app call arguments for ABI and non-ABI (raw) calls - [assets](types_app.CoreAppCallArgs.md#assets) - [boxes](types_app.CoreAppCallArgs.md#boxes) - [lease](types_app.CoreAppCallArgs.md#lease) +- [rekeyTo](types_app.CoreAppCallArgs.md#rekeyto) ## Properties @@ -81,3 +82,17 @@ The optional lease for the transaction #### Defined in [src/types/app.ts:70](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L70) + +___ + +### rekeyTo + +• `Optional` **rekeyTo**: `string` \| [`SendTransactionFrom`](../modules/types_transaction.md#sendtransactionfrom) + +Optional account / account address that should be authorised to transact on behalf of the from account the app call is sent from after this transaction. + +**Note:** Use with extreme caution and review the [official rekey guidance](https://developer.algorand.org/docs/get-details/accounts/rekey/) first. + +#### Defined in + +[src/types/app.ts:83](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L83) diff --git a/docs/code/interfaces/types_app.CreateAppParams.md b/docs/code/interfaces/types_app.CreateAppParams.md index e083453f..a01fdd9c 100644 --- a/docs/code/interfaces/types_app.CreateAppParams.md +++ b/docs/code/interfaces/types_app.CreateAppParams.md @@ -46,7 +46,7 @@ CreateOrUpdateAppParams.approvalProgram #### Defined in -[src/types/app.ts:121](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L121) +[src/types/app.ts:126](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L126) ___ @@ -62,7 +62,7 @@ CreateOrUpdateAppParams.args #### Defined in -[src/types/app.ts:129](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L129) +[src/types/app.ts:134](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L134) ___ @@ -94,7 +94,7 @@ CreateOrUpdateAppParams.clearStateProgram #### Defined in -[src/types/app.ts:123](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L123) +[src/types/app.ts:128](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L128) ___ @@ -126,7 +126,7 @@ CreateOrUpdateAppParams.from #### Defined in -[src/types/app.ts:119](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L119) +[src/types/app.ts:124](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L124) ___ @@ -174,7 +174,7 @@ CreateOrUpdateAppParams.note #### Defined in -[src/types/app.ts:127](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L127) +[src/types/app.ts:132](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L132) ___ @@ -186,7 +186,7 @@ Override the on-completion action for the create call; defaults to NoOp #### Defined in -[src/types/app.ts:137](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L137) +[src/types/app.ts:142](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L142) ___ @@ -198,7 +198,7 @@ The storage schema to request for the created app #### Defined in -[src/types/app.ts:135](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L135) +[src/types/app.ts:140](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L140) ___ @@ -263,4 +263,4 @@ CreateOrUpdateAppParams.transactionParams #### Defined in -[src/types/app.ts:125](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L125) +[src/types/app.ts:130](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L130) diff --git a/docs/code/interfaces/types_app.RawAppCallArgs.md b/docs/code/interfaces/types_app.RawAppCallArgs.md index 00edc12d..0cc6037c 100644 --- a/docs/code/interfaces/types_app.RawAppCallArgs.md +++ b/docs/code/interfaces/types_app.RawAppCallArgs.md @@ -25,6 +25,7 @@ App call args with non-ABI (raw) values (minus some processing like encoding str - [boxes](types_app.RawAppCallArgs.md#boxes) - [lease](types_app.RawAppCallArgs.md#lease) - [method](types_app.RawAppCallArgs.md#method) +- [rekeyTo](types_app.RawAppCallArgs.md#rekeyto) ## Properties @@ -52,7 +53,7 @@ Any application arguments to pass through #### Defined in -[src/types/app.ts:86](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L86) +[src/types/app.ts:91](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L91) ___ @@ -128,4 +129,22 @@ Property to aid intellisense #### Defined in -[src/types/app.ts:88](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L88) +[src/types/app.ts:93](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L93) + +___ + +### rekeyTo + +• `Optional` **rekeyTo**: `string` \| [`SendTransactionFrom`](../modules/types_transaction.md#sendtransactionfrom) + +Optional account / account address that should be authorised to transact on behalf of the from account the app call is sent from after this transaction. + +**Note:** Use with extreme caution and review the [official rekey guidance](https://developer.algorand.org/docs/get-details/accounts/rekey/) first. + +#### Inherited from + +[CoreAppCallArgs](types_app.CoreAppCallArgs.md).[rekeyTo](types_app.CoreAppCallArgs.md#rekeyto) + +#### Defined in + +[src/types/app.ts:83](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L83) diff --git a/docs/code/interfaces/types_app.UpdateAppParams.md b/docs/code/interfaces/types_app.UpdateAppParams.md index 488a3906..70a95090 100644 --- a/docs/code/interfaces/types_app.UpdateAppParams.md +++ b/docs/code/interfaces/types_app.UpdateAppParams.md @@ -41,7 +41,7 @@ The id of the app to update #### Defined in -[src/types/app.ts:143](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L143) +[src/types/app.ts:148](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L148) ___ @@ -57,7 +57,7 @@ CreateOrUpdateAppParams.approvalProgram #### Defined in -[src/types/app.ts:121](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L121) +[src/types/app.ts:126](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L126) ___ @@ -73,7 +73,7 @@ CreateOrUpdateAppParams.args #### Defined in -[src/types/app.ts:129](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L129) +[src/types/app.ts:134](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L134) ___ @@ -105,7 +105,7 @@ CreateOrUpdateAppParams.clearStateProgram #### Defined in -[src/types/app.ts:123](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L123) +[src/types/app.ts:128](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L128) ___ @@ -137,7 +137,7 @@ CreateOrUpdateAppParams.from #### Defined in -[src/types/app.ts:119](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L119) +[src/types/app.ts:124](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L124) ___ @@ -185,7 +185,7 @@ CreateOrUpdateAppParams.note #### Defined in -[src/types/app.ts:127](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L127) +[src/types/app.ts:132](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L132) ___ @@ -250,4 +250,4 @@ CreateOrUpdateAppParams.transactionParams #### Defined in -[src/types/app.ts:125](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L125) +[src/types/app.ts:130](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L130) diff --git a/docs/code/interfaces/types_app_client.AppClientCallABIArgs.md b/docs/code/interfaces/types_app_client.AppClientCallABIArgs.md index ad0e3816..fd49a424 100644 --- a/docs/code/interfaces/types_app_client.AppClientCallABIArgs.md +++ b/docs/code/interfaces/types_app_client.AppClientCallABIArgs.md @@ -21,6 +21,7 @@ - [lease](types_app_client.AppClientCallABIArgs.md#lease) - [method](types_app_client.AppClientCallABIArgs.md#method) - [methodArgs](types_app_client.AppClientCallABIArgs.md#methodargs) +- [rekeyTo](types_app_client.AppClientCallABIArgs.md#rekeyto) ## Properties @@ -128,4 +129,22 @@ Omit.methodArgs #### Defined in -[src/types/app.ts:107](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L107) +[src/types/app.ts:112](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L112) + +___ + +### rekeyTo + +• `Optional` **rekeyTo**: `string` \| [`SendTransactionFrom`](../modules/types_transaction.md#sendtransactionfrom) + +Optional account / account address that should be authorised to transact on behalf of the from account the app call is sent from after this transaction. + +**Note:** Use with extreme caution and review the [official rekey guidance](https://developer.algorand.org/docs/get-details/accounts/rekey/) first. + +#### Inherited from + +Omit.rekeyTo + +#### Defined in + +[src/types/app.ts:83](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L83) diff --git a/docs/code/interfaces/types_app_client.AppClientCallRawArgs.md b/docs/code/interfaces/types_app_client.AppClientCallRawArgs.md index e2988c48..66e6a74b 100644 --- a/docs/code/interfaces/types_app_client.AppClientCallRawArgs.md +++ b/docs/code/interfaces/types_app_client.AppClientCallRawArgs.md @@ -23,6 +23,7 @@ App call args with non-ABI (raw) values (minus some processing like encoding str - [boxes](types_app_client.AppClientCallRawArgs.md#boxes) - [lease](types_app_client.AppClientCallRawArgs.md#lease) - [method](types_app_client.AppClientCallRawArgs.md#method) +- [rekeyTo](types_app_client.AppClientCallRawArgs.md#rekeyto) ## Properties @@ -54,7 +55,7 @@ Any application arguments to pass through #### Defined in -[src/types/app.ts:86](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L86) +[src/types/app.ts:91](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L91) ___ @@ -134,4 +135,22 @@ Property to aid intellisense #### Defined in -[src/types/app.ts:88](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L88) +[src/types/app.ts:93](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L93) + +___ + +### rekeyTo + +• `Optional` **rekeyTo**: `string` \| [`SendTransactionFrom`](../modules/types_transaction.md#sendtransactionfrom) + +Optional account / account address that should be authorised to transact on behalf of the from account the app call is sent from after this transaction. + +**Note:** Use with extreme caution and review the [official rekey guidance](https://developer.algorand.org/docs/get-details/accounts/rekey/) first. + +#### Inherited from + +[RawAppCallArgs](types_app.RawAppCallArgs.md).[rekeyTo](types_app.RawAppCallArgs.md#rekeyto) + +#### Defined in + +[src/types/app.ts:83](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L83) diff --git a/docs/code/interfaces/types_asset.AssetBulkOptInOutParams.md b/docs/code/interfaces/types_asset.AssetBulkOptInOutParams.md new file mode 100644 index 00000000..34a93bf7 --- /dev/null +++ b/docs/code/interfaces/types_asset.AssetBulkOptInOutParams.md @@ -0,0 +1,103 @@ +[@algorandfoundation/algokit-utils](../README.md) / [types/asset](../modules/types_asset.md) / AssetBulkOptInOutParams + +# Interface: AssetBulkOptInOutParams + +[types/asset](../modules/types_asset.md).AssetBulkOptInOutParams + +Parameters for `assetBulkOptIn` / `assetBulkOptOut` call. + +## Table of contents + +### Properties + +- [account](types_asset.AssetBulkOptInOutParams.md#account) +- [assetIds](types_asset.AssetBulkOptInOutParams.md#assetids) +- [maxFee](types_asset.AssetBulkOptInOutParams.md#maxfee) +- [note](types_asset.AssetBulkOptInOutParams.md#note) +- [suppressLog](types_asset.AssetBulkOptInOutParams.md#suppresslog) +- [transactionParams](types_asset.AssetBulkOptInOutParams.md#transactionparams) +- [validateBalances](types_asset.AssetBulkOptInOutParams.md#validatebalances) + +## Properties + +### account + +• **account**: [`SendTransactionFrom`](../modules/types_transaction.md#sendtransactionfrom) + +The account to opt in/out for + +#### Defined in + +[src/types/asset.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L30) + +___ + +### assetIds + +• **assetIds**: `number`[] + +The IDs of the assets to opt in for / out of + +#### Defined in + +[src/types/asset.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L32) + +___ + +### maxFee + +• `Optional` **maxFee**: [`AlgoAmount`](../classes/types_amount.AlgoAmount.md) + +The maximum fee that you are happy to pay per transaction (default: unbounded) - if this is set it's possible the transaction could get rejected during network congestion + +#### Defined in + +[src/types/asset.ts:40](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L40) + +___ + +### note + +• `Optional` **note**: [`TransactionNote`](../modules/types_transaction.md#transactionnote) + +The (optional) transaction note + +#### Defined in + +[src/types/asset.ts:38](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L38) + +___ + +### suppressLog + +• `Optional` **suppressLog**: `boolean` + +Whether to suppress log messages from transaction send, default: do not suppress + +#### Defined in + +[src/types/asset.ts:42](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L42) + +___ + +### transactionParams + +• `Optional` **transactionParams**: `SuggestedParams` + +Optional transaction parameters + +#### Defined in + +[src/types/asset.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L36) + +___ + +### validateBalances + +• `Optional` **validateBalances**: `boolean` + +Whether or not to validate the opt-in/out is valid before issuing transactions; default = true + +#### Defined in + +[src/types/asset.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L34) diff --git a/docs/code/interfaces/types_asset.AssetOptInParams.md b/docs/code/interfaces/types_asset.AssetOptInParams.md new file mode 100644 index 00000000..3870a7ec --- /dev/null +++ b/docs/code/interfaces/types_asset.AssetOptInParams.md @@ -0,0 +1,205 @@ +[@algorandfoundation/algokit-utils](../README.md) / [types/asset](../modules/types_asset.md) / AssetOptInParams + +# Interface: AssetOptInParams + +[types/asset](../modules/types_asset.md).AssetOptInParams + +Parameters for `assetOptIn` call. + +## Hierarchy + +- [`SendTransactionParams`](types_transaction.SendTransactionParams.md) + + ↳ **`AssetOptInParams`** + + ↳↳ [`AssetOptOutParams`](types_asset.AssetOptOutParams.md) + +## Table of contents + +### Properties + +- [account](types_asset.AssetOptInParams.md#account) +- [assetId](types_asset.AssetOptInParams.md#assetid) +- [atc](types_asset.AssetOptInParams.md#atc) +- [fee](types_asset.AssetOptInParams.md#fee) +- [lease](types_asset.AssetOptInParams.md#lease) +- [maxFee](types_asset.AssetOptInParams.md#maxfee) +- [maxRoundsToWaitForConfirmation](types_asset.AssetOptInParams.md#maxroundstowaitforconfirmation) +- [note](types_asset.AssetOptInParams.md#note) +- [skipSending](types_asset.AssetOptInParams.md#skipsending) +- [skipWaiting](types_asset.AssetOptInParams.md#skipwaiting) +- [suppressLog](types_asset.AssetOptInParams.md#suppresslog) +- [transactionParams](types_asset.AssetOptInParams.md#transactionparams) + +## Properties + +### account + +• **account**: [`SendTransactionFrom`](../modules/types_transaction.md#sendtransactionfrom) + +The account to opt in/out for + +#### Defined in + +[src/types/asset.ts:8](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L8) + +___ + +### assetId + +• **assetId**: `number` + +The ID of the assets to opt in for / out of + +#### Defined in + +[src/types/asset.ts:10](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L10) + +___ + +### atc + +• `Optional` **atc**: `AtomicTransactionComposer` + +An optional `AtomicTransactionComposer` to add the transaction to, if specified then `skipSending: undefined` has the same effect as `skipSending: true` + +#### Inherited from + +[SendTransactionParams](types_transaction.SendTransactionParams.md).[atc](types_transaction.SendTransactionParams.md#atc) + +#### Defined in + +[src/types/transaction.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L30) + +___ + +### 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 + +[src/types/transaction.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L34) + +___ + +### lease + +• `Optional` **lease**: `string` \| `Uint8Array` + +An (optional) [transaction lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to apply + +#### Defined in + +[src/types/asset.ts:16](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L16) + +___ + +### 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 + +[src/types/transaction.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L36) + +___ + +### 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 + +[src/types/transaction.ts:38](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L38) + +___ + +### note + +• `Optional` **note**: [`TransactionNote`](../modules/types_transaction.md#transactionnote) + +The (optional) transaction note + +#### Defined in + +[src/types/asset.ts:14](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L14) + +___ + +### skipSending + +• `Optional` **skipSending**: `boolean` + +Whether to skip signing and sending the transaction to the chain (default: transaction signed and sent to chain, unless `atc` specified) +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 + +[src/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 + +[src/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 + +[src/types/transaction.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L32) + +___ + +### transactionParams + +• `Optional` **transactionParams**: `SuggestedParams` + +Optional transaction parameters + +#### Defined in + +[src/types/asset.ts:12](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L12) diff --git a/docs/code/interfaces/types_asset.AssetOptOutParams.md b/docs/code/interfaces/types_asset.AssetOptOutParams.md new file mode 100644 index 00000000..3a2a53ab --- /dev/null +++ b/docs/code/interfaces/types_asset.AssetOptOutParams.md @@ -0,0 +1,249 @@ +[@algorandfoundation/algokit-utils](../README.md) / [types/asset](../modules/types_asset.md) / AssetOptOutParams + +# Interface: AssetOptOutParams + +[types/asset](../modules/types_asset.md).AssetOptOutParams + +Parameters for `assetOptOut` call. + +## Hierarchy + +- [`AssetOptInParams`](types_asset.AssetOptInParams.md) + + ↳ **`AssetOptOutParams`** + +## Table of contents + +### Properties + +- [account](types_asset.AssetOptOutParams.md#account) +- [assetCreatorAddress](types_asset.AssetOptOutParams.md#assetcreatoraddress) +- [assetId](types_asset.AssetOptOutParams.md#assetid) +- [atc](types_asset.AssetOptOutParams.md#atc) +- [ensureZeroBalance](types_asset.AssetOptOutParams.md#ensurezerobalance) +- [fee](types_asset.AssetOptOutParams.md#fee) +- [lease](types_asset.AssetOptOutParams.md#lease) +- [maxFee](types_asset.AssetOptOutParams.md#maxfee) +- [maxRoundsToWaitForConfirmation](types_asset.AssetOptOutParams.md#maxroundstowaitforconfirmation) +- [note](types_asset.AssetOptOutParams.md#note) +- [skipSending](types_asset.AssetOptOutParams.md#skipsending) +- [skipWaiting](types_asset.AssetOptOutParams.md#skipwaiting) +- [suppressLog](types_asset.AssetOptOutParams.md#suppresslog) +- [transactionParams](types_asset.AssetOptOutParams.md#transactionparams) + +## Properties + +### account + +• **account**: [`SendTransactionFrom`](../modules/types_transaction.md#sendtransactionfrom) + +The account to opt in/out for + +#### Inherited from + +[AssetOptInParams](types_asset.AssetOptInParams.md).[account](types_asset.AssetOptInParams.md#account) + +#### Defined in + +[src/types/asset.ts:8](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L8) + +___ + +### assetCreatorAddress + +• `Optional` **assetCreatorAddress**: `string` + +The address of the creator account for the asset; if unspecified then it looks it up using algod + +#### Defined in + +[src/types/asset.ts:22](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L22) + +___ + +### assetId + +• **assetId**: `number` + +The ID of the assets to opt in for / out of + +#### Inherited from + +[AssetOptInParams](types_asset.AssetOptInParams.md).[assetId](types_asset.AssetOptInParams.md#assetid) + +#### Defined in + +[src/types/asset.ts:10](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L10) + +___ + +### atc + +• `Optional` **atc**: `AtomicTransactionComposer` + +An optional `AtomicTransactionComposer` to add the transaction to, if specified then `skipSending: undefined` has the same effect as `skipSending: true` + +#### Inherited from + +[AssetOptInParams](types_asset.AssetOptInParams.md).[atc](types_asset.AssetOptInParams.md#atc) + +#### Defined in + +[src/types/transaction.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L30) + +___ + +### ensureZeroBalance + +• `Optional` **ensureZeroBalance**: `boolean` + +Whether or not to validate the account has a zero-balance before issuing the opt-out; default = true + +#### Defined in + +[src/types/asset.ts:24](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L24) + +___ + +### 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 + +[AssetOptInParams](types_asset.AssetOptInParams.md).[fee](types_asset.AssetOptInParams.md#fee) + +#### Defined in + +[src/types/transaction.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L34) + +___ + +### lease + +• `Optional` **lease**: `string` \| `Uint8Array` + +An (optional) [transaction lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to apply + +#### Inherited from + +[AssetOptInParams](types_asset.AssetOptInParams.md).[lease](types_asset.AssetOptInParams.md#lease) + +#### Defined in + +[src/types/asset.ts:16](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L16) + +___ + +### 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 + +[AssetOptInParams](types_asset.AssetOptInParams.md).[maxFee](types_asset.AssetOptInParams.md#maxfee) + +#### Defined in + +[src/types/transaction.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L36) + +___ + +### 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 + +[AssetOptInParams](types_asset.AssetOptInParams.md).[maxRoundsToWaitForConfirmation](types_asset.AssetOptInParams.md#maxroundstowaitforconfirmation) + +#### Defined in + +[src/types/transaction.ts:38](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L38) + +___ + +### note + +• `Optional` **note**: [`TransactionNote`](../modules/types_transaction.md#transactionnote) + +The (optional) transaction note + +#### Inherited from + +[AssetOptInParams](types_asset.AssetOptInParams.md).[note](types_asset.AssetOptInParams.md#note) + +#### Defined in + +[src/types/asset.ts:14](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L14) + +___ + +### skipSending + +• `Optional` **skipSending**: `boolean` + +Whether to skip signing and sending the transaction to the chain (default: transaction signed and sent to chain, unless `atc` specified) +and instead just return the raw transaction, e.g. so you can add it to a group of transactions + +#### Inherited from + +[AssetOptInParams](types_asset.AssetOptInParams.md).[skipSending](types_asset.AssetOptInParams.md#skipsending) + +#### Defined in + +[src/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 + +[AssetOptInParams](types_asset.AssetOptInParams.md).[skipWaiting](types_asset.AssetOptInParams.md#skipwaiting) + +#### Defined in + +[src/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 + +[AssetOptInParams](types_asset.AssetOptInParams.md).[suppressLog](types_asset.AssetOptInParams.md#suppresslog) + +#### Defined in + +[src/types/transaction.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L32) + +___ + +### transactionParams + +• `Optional` **transactionParams**: `SuggestedParams` + +Optional transaction parameters + +#### Inherited from + +[AssetOptInParams](types_asset.AssetOptInParams.md).[transactionParams](types_asset.AssetOptInParams.md#transactionparams) + +#### Defined in + +[src/types/asset.ts:12](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/asset.ts#L12) diff --git a/docs/code/interfaces/types_transaction.SendTransactionParams.md b/docs/code/interfaces/types_transaction.SendTransactionParams.md index ad6f3ef9..32f1c464 100644 --- a/docs/code/interfaces/types_transaction.SendTransactionParams.md +++ b/docs/code/interfaces/types_transaction.SendTransactionParams.md @@ -12,8 +12,12 @@ The sending configuration for a transaction ↳ [`AppCallParams`](types_app.AppCallParams.md) + ↳ [`AssetOptInParams`](types_asset.AssetOptInParams.md) + ↳ [`AlgoTransferParams`](types_transfer.AlgoTransferParams.md) + ↳ [`AlgoRekeyParams`](types_transfer.AlgoRekeyParams.md) + ↳ [`EnsureFundedParams`](types_transfer.EnsureFundedParams.md) ↳ [`TransferAssetParams`](types_transfer.TransferAssetParams.md) diff --git a/docs/code/interfaces/types_transfer.AlgoRekeyParams.md b/docs/code/interfaces/types_transfer.AlgoRekeyParams.md new file mode 100644 index 00000000..0253de5d --- /dev/null +++ b/docs/code/interfaces/types_transfer.AlgoRekeyParams.md @@ -0,0 +1,203 @@ +[@algorandfoundation/algokit-utils](../README.md) / [types/transfer](../modules/types_transfer.md) / AlgoRekeyParams + +# Interface: AlgoRekeyParams + +[types/transfer](../modules/types_transfer.md).AlgoRekeyParams + +Parameters for `rekeyAccount` call. + +## Hierarchy + +- [`SendTransactionParams`](types_transaction.SendTransactionParams.md) + + ↳ **`AlgoRekeyParams`** + +## Table of contents + +### Properties + +- [atc](types_transfer.AlgoRekeyParams.md#atc) +- [fee](types_transfer.AlgoRekeyParams.md#fee) +- [from](types_transfer.AlgoRekeyParams.md#from) +- [lease](types_transfer.AlgoRekeyParams.md#lease) +- [maxFee](types_transfer.AlgoRekeyParams.md#maxfee) +- [maxRoundsToWaitForConfirmation](types_transfer.AlgoRekeyParams.md#maxroundstowaitforconfirmation) +- [note](types_transfer.AlgoRekeyParams.md#note) +- [rekeyTo](types_transfer.AlgoRekeyParams.md#rekeyto) +- [skipSending](types_transfer.AlgoRekeyParams.md#skipsending) +- [skipWaiting](types_transfer.AlgoRekeyParams.md#skipwaiting) +- [suppressLog](types_transfer.AlgoRekeyParams.md#suppresslog) +- [transactionParams](types_transfer.AlgoRekeyParams.md#transactionparams) + +## Properties + +### atc + +• `Optional` **atc**: `AtomicTransactionComposer` + +An optional `AtomicTransactionComposer` to add the transaction to, if specified then `skipSending: undefined` has the same effect as `skipSending: true` + +#### Inherited from + +[SendTransactionParams](types_transaction.SendTransactionParams.md).[atc](types_transaction.SendTransactionParams.md#atc) + +#### Defined in + +[src/types/transaction.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L30) + +___ + +### 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 + +[src/types/transaction.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L34) + +___ + +### from + +• **from**: [`SendTransactionFrom`](../modules/types_transaction.md#sendtransactionfrom) + +The account that will be rekeyed + +#### Defined in + +[src/types/transfer.ts:25](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L25) + +___ + +### lease + +• `Optional` **lease**: `string` \| `Uint8Array` + +An (optional) [transaction lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to apply + +#### Defined in + +[src/types/transfer.ts:33](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L33) + +___ + +### 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 + +[src/types/transaction.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L36) + +___ + +### 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 + +[src/types/transaction.ts:38](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L38) + +___ + +### note + +• `Optional` **note**: [`TransactionNote`](../modules/types_transaction.md#transactionnote) + +The (optional) transaction note + +#### Defined in + +[src/types/transfer.ts:31](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L31) + +___ + +### rekeyTo + +• **rekeyTo**: `string` \| [`SendTransactionFrom`](../modules/types_transaction.md#sendtransactionfrom) + +The account / account address that will have the private key that is authorised to transact on behalf of the from account from now on + +#### Defined in + +[src/types/transfer.ts:27](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L27) + +___ + +### skipSending + +• `Optional` **skipSending**: `boolean` + +Whether to skip signing and sending the transaction to the chain (default: transaction signed and sent to chain, unless `atc` specified) +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 + +[src/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 + +[src/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 + +[src/types/transaction.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L32) + +___ + +### transactionParams + +• `Optional` **transactionParams**: `SuggestedParams` + +Optional transaction parameters + +#### Defined in + +[src/types/transfer.ts:29](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L29) diff --git a/docs/code/interfaces/types_transfer.AlgoTransferParams.md b/docs/code/interfaces/types_transfer.AlgoTransferParams.md index 1a9f60ca..1d80a865 100644 --- a/docs/code/interfaces/types_transfer.AlgoTransferParams.md +++ b/docs/code/interfaces/types_transfer.AlgoTransferParams.md @@ -20,6 +20,7 @@ Parameters for `transferAlgos` call. - [atc](types_transfer.AlgoTransferParams.md#atc) - [fee](types_transfer.AlgoTransferParams.md#fee) - [from](types_transfer.AlgoTransferParams.md#from) +- [lease](types_transfer.AlgoTransferParams.md#lease) - [maxFee](types_transfer.AlgoTransferParams.md#maxfee) - [maxRoundsToWaitForConfirmation](types_transfer.AlgoTransferParams.md#maxroundstowaitforconfirmation) - [note](types_transfer.AlgoTransferParams.md#note) @@ -87,6 +88,18 @@ The account that will send the ALGOs ___ +### lease + +• `Optional` **lease**: `string` \| `Uint8Array` + +An (optional) [transaction lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to apply + +#### Defined in + +[src/types/transfer.ts:19](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L19) + +___ + ### maxFee • `Optional` **maxFee**: [`AlgoAmount`](../classes/types_amount.AlgoAmount.md) diff --git a/docs/code/interfaces/types_transfer.EnsureFundedParams.md b/docs/code/interfaces/types_transfer.EnsureFundedParams.md index 581f877e..25a59ef5 100644 --- a/docs/code/interfaces/types_transfer.EnsureFundedParams.md +++ b/docs/code/interfaces/types_transfer.EnsureFundedParams.md @@ -20,6 +20,7 @@ Parameters for `ensureFunded` call. - [atc](types_transfer.EnsureFundedParams.md#atc) - [fee](types_transfer.EnsureFundedParams.md#fee) - [fundingSource](types_transfer.EnsureFundedParams.md#fundingsource) +- [lease](types_transfer.EnsureFundedParams.md#lease) - [maxFee](types_transfer.EnsureFundedParams.md#maxfee) - [maxRoundsToWaitForConfirmation](types_transfer.EnsureFundedParams.md#maxroundstowaitforconfirmation) - [minFundingIncrement](types_transfer.EnsureFundedParams.md#minfundingincrement) @@ -40,7 +41,7 @@ The account to fund #### Defined in -[src/types/transfer.ts:23](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L23) +[src/types/transfer.ts:39](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L39) ___ @@ -84,7 +85,19 @@ The account to use as a funding source, will default to using the dispenser acco #### Defined in -[src/types/transfer.ts:25](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L25) +[src/types/transfer.ts:41](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L41) + +___ + +### lease + +• `Optional` **lease**: `string` \| `Uint8Array` + +An (optional) [transaction lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to apply + +#### Defined in + +[src/types/transfer.ts:51](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L51) ___ @@ -128,7 +141,7 @@ When issuing a funding amount, the minimum amount to transfer (avoids many small #### Defined in -[src/types/transfer.ts:29](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L29) +[src/types/transfer.ts:45](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L45) ___ @@ -140,7 +153,7 @@ The minimum balance of ALGOs that the account should have available to spend (i. #### Defined in -[src/types/transfer.ts:27](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L27) +[src/types/transfer.ts:43](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L43) ___ @@ -152,7 +165,7 @@ The (optional) transaction note, default: "Funding account to meet minimum requi #### Defined in -[src/types/transfer.ts:33](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L33) +[src/types/transfer.ts:49](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L49) ___ @@ -213,4 +226,4 @@ Optional transaction parameters #### Defined in -[src/types/transfer.ts:31](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L31) +[src/types/transfer.ts:47](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L47) diff --git a/docs/code/interfaces/types_transfer.EnsureFundedReturnType.md b/docs/code/interfaces/types_transfer.EnsureFundedReturnType.md index c5f14ecd..ed444620 100644 --- a/docs/code/interfaces/types_transfer.EnsureFundedReturnType.md +++ b/docs/code/interfaces/types_transfer.EnsureFundedReturnType.md @@ -21,7 +21,7 @@ The response if the transaction was sent and waited for #### Defined in -[src/types/transfer.ts:58](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L58) +[src/types/transfer.ts:78](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L78) ___ @@ -33,4 +33,4 @@ The transaction #### Defined in -[src/types/transfer.ts:56](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L56) +[src/types/transfer.ts:76](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L76) diff --git a/docs/code/interfaces/types_transfer.TransferAssetParams.md b/docs/code/interfaces/types_transfer.TransferAssetParams.md index ab5c0735..743b14cf 100644 --- a/docs/code/interfaces/types_transfer.TransferAssetParams.md +++ b/docs/code/interfaces/types_transfer.TransferAssetParams.md @@ -22,6 +22,7 @@ Parameters for `transferAsset` call. - [clawbackFrom](types_transfer.TransferAssetParams.md#clawbackfrom) - [fee](types_transfer.TransferAssetParams.md#fee) - [from](types_transfer.TransferAssetParams.md#from) +- [lease](types_transfer.TransferAssetParams.md#lease) - [maxFee](types_transfer.TransferAssetParams.md#maxfee) - [maxRoundsToWaitForConfirmation](types_transfer.TransferAssetParams.md#maxroundstowaitforconfirmation) - [note](types_transfer.TransferAssetParams.md#note) @@ -41,7 +42,7 @@ The amount to send as the smallest divisible unit value #### Defined in -[src/types/transfer.ts:45](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L45) +[src/types/transfer.ts:63](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L63) ___ @@ -53,7 +54,7 @@ The asset id that will be transfered #### Defined in -[src/types/transfer.ts:43](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L43) +[src/types/transfer.ts:61](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L61) ___ @@ -81,7 +82,7 @@ An address of a target account from which to perform a clawback operation. Pleas #### Defined in -[src/types/transfer.ts:49](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L49) +[src/types/transfer.ts:67](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L67) ___ @@ -109,7 +110,19 @@ The account that will send the asset #### Defined in -[src/types/transfer.ts:39](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L39) +[src/types/transfer.ts:57](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L57) + +___ + +### lease + +• `Optional` **lease**: `string` \| `Uint8Array` + +An (optional) [transaction lease](https://developer.algorand.org/articles/leased-transactions-securing-advanced-smart-contract-design/) to apply + +#### Defined in + +[src/types/transfer.ts:71](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L71) ___ @@ -153,7 +166,7 @@ The (optional) transaction note #### Defined in -[src/types/transfer.ts:51](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L51) +[src/types/transfer.ts:69](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L69) ___ @@ -214,7 +227,7 @@ The account / account address that will receive the asset #### Defined in -[src/types/transfer.ts:41](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L41) +[src/types/transfer.ts:59](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L59) ___ @@ -226,4 +239,4 @@ Optional transaction parameters #### Defined in -[src/types/transfer.ts:47](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L47) +[src/types/transfer.ts:65](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transfer.ts#L65) diff --git a/docs/code/modules/index.md b/docs/code/modules/index.md index c56d6f18..89dd6fb4 100644 --- a/docs/code/modules/index.md +++ b/docs/code/modules/index.md @@ -7,10 +7,15 @@ ### Variables - [Config](index.md#config) +- [MAX\_TRANSACTION\_GROUP\_SIZE](index.md#max_transaction_group_size) ### Functions - [algos](index.md#algos) +- [assetBulkOptIn](index.md#assetbulkoptin) +- [assetBulkOptOut](index.md#assetbulkoptout) +- [assetOptIn](index.md#assetoptin) +- [assetOptOut](index.md#assetoptout) - [callApp](index.md#callapp) - [capTransactionFee](index.md#captransactionfee) - [compileTeal](index.md#compileteal) @@ -18,6 +23,7 @@ - [createApp](index.md#createapp) - [decodeAppState](index.md#decodeappstate) - [deployApp](index.md#deployapp) +- [encodeLease](index.md#encodelease) - [encodeTransactionNote](index.md#encodetransactionnote) - [ensureFunded](index.md#ensurefunded) - [executePaginatedRequest](index.md#executepaginatedrequest) @@ -73,13 +79,12 @@ - [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) - [performTemplateSubstitutionAndCompile](index.md#performtemplatesubstitutionandcompile) - [randomAccount](index.md#randomaccount) +- [rekeyAccount](index.md#rekeyaccount) - [rekeyedAccount](index.md#rekeyedaccount) - [replaceDeployTimeControlParams](index.md#replacedeploytimecontrolparams) - [searchTransactions](index.md#searchtransactions) @@ -107,6 +112,16 @@ The AlgoKit config. To update it use the configure method. [src/index.ts:17](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/index.ts#L17) +___ + +### MAX\_TRANSACTION\_GROUP\_SIZE + +• `Const` **MAX\_TRANSACTION\_GROUP\_SIZE**: ``16`` + +#### Defined in + +[src/transaction.ts:27](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L27) + ## Functions ### algos @@ -131,6 +146,140 @@ Returns an amount of Algos using AlgoAmount ___ +### assetBulkOptIn + +▸ **assetBulkOptIn**(`optIn`, `algod`): `Promise`<`Record`<`number`, `string`\>\> + +Opt in to a list of assets on the Algorand blockchain. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `optIn` | [`AssetBulkOptInOutParams`](../interfaces/types_asset.AssetBulkOptInOutParams.md) | The bulk opt-in request. | +| `algod` | `default` | An instance of the Algodv2 class from the `algosdk` library. | + +#### 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. + +**`Example`** + +```ts +algokit.bulkOptIn({ account: account, assetIds: [12345, 67890] }, algod) +``` + +#### Defined in + +[src/asset.ts:169](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/asset.ts#L169) + +___ + +### assetBulkOptOut + +▸ **assetBulkOptOut**(`optOut`, `algod`): `Promise`<`Record`<`number`, `string`\>\> + +Opt out of multiple assets in Algorand blockchain. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `optOut` | [`AssetBulkOptInOutParams`](../interfaces/types_asset.AssetBulkOptInOutParams.md) | The bulk opt-out request. | +| `algod` | `default` | An instance of the Algodv2 client used to interact with the Algorand blockchain. | + +#### Returns + +`Promise`<`Record`<`number`, `string`\>\> + +A record object containing asset IDs as keys and their corresponding transaction IDs as values. + +**`Throws`** + +If there is an error during the opt-out process. + +**`Example`** + +```ts +algokit.bulkOptOut({ account: account, assetIds: [12345, 67890] }, algod) +``` + +#### Defined in + +[src/asset.ts:235](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/asset.ts#L235) + +___ + +### assetOptIn + +▸ **assetOptIn**(`optIn`, `algod`): `Promise`<[`SendTransactionResult`](../interfaces/types_transaction.SendTransactionResult.md)\> + +Opt-in an account to an asset. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `optIn` | [`AssetOptInParams`](../interfaces/types_asset.AssetOptInParams.md) | The opt-in definition | +| `algod` | `default` | An algod client | + +#### Returns + +`Promise`<[`SendTransactionResult`](../interfaces/types_transaction.SendTransactionResult.md)\> + +The transaction object and optionally the confirmation if it was sent to the chain (`skipSending` is `false` or unset) + +**`Example`** + +Usage example +```typescript +await algokit.assetOptIn({ account, assetId }, algod) +``` + +#### Defined in + +[src/asset.ts:80](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/asset.ts#L80) + +___ + +### assetOptOut + +▸ **assetOptOut**(`optOut`, `algod`): `Promise`<[`SendTransactionResult`](../interfaces/types_transaction.SendTransactionResult.md)\> + +Opt-out an account from an asset. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `optOut` | [`AssetOptOutParams`](../interfaces/types_asset.AssetOptOutParams.md) | The opt-in definition | +| `algod` | `default` | An algod client | + +#### Returns + +`Promise`<[`SendTransactionResult`](../interfaces/types_transaction.SendTransactionResult.md)\> + +The transaction object and optionally the confirmation if it was sent to the chain (`skipSending` is `false` or unset) + +**`Example`** + +Usage example +```typescript +await algokit.assetOptOut({ account, assetId, assetCreatorAddress }, algod) +``` + +#### Defined in + +[src/asset.ts:118](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/asset.ts#L118) + +___ + ### callApp ▸ **callApp**(`call`, `algod`): `Promise`<[`AppCallTransactionResult`](../interfaces/types_app.AppCallTransactionResult.md)\> @@ -152,7 +301,7 @@ The result of the call #### Defined in -[src/app.ts:305](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L305) +[src/app.ts:306](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L306) ___ @@ -177,7 +326,7 @@ the estimated rate. #### Defined in -[src/transaction.ts:426](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L426) +[src/transaction.ts:464](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L464) ___ @@ -233,7 +382,7 @@ Allows for control of fees on a `Transaction` or `SuggestedParams` object #### Defined in -[src/transaction.ts:449](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L449) +[src/transaction.ts:487](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L487) ___ @@ -258,7 +407,7 @@ The details of the created app, or the transaction to create it if `skipSending` #### Defined in -[src/app.ts:56](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L56) +[src/app.ts:57](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L57) ___ @@ -283,7 +432,7 @@ An object keyeed by the UTF-8 representation of the key with various parsings of #### Defined in -[src/app.ts:522](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L522) +[src/app.ts:523](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L523) ___ @@ -321,6 +470,46 @@ The app reference of the new/existing app ___ +### encodeLease + +▸ **encodeLease**(`lease?`): `Uint8Array` \| `undefined` + +Encodes a transaction lease into a 32-byte array ready to be included in an Algorand transaction. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `lease?` | `string` \| `Uint8Array` | The transaction lease as a string or binary array or null/undefined if there is no lease | + +#### Returns + +`Uint8Array` \| `undefined` + +the transaction lease ready for inclusion in a transaction or `undefined` if there is no lease + +**`Throws`** + +if the length of the data is > 32 bytes or empty + +**`Example`** + +```ts +algokit.encodeLease('UNIQUE_ID') +``` + +**`Example`** + +```ts +algokit.encodeLease(new Uint8Array([1, 2, 3])) +``` + +#### Defined in + +[src/transaction.ts:65](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L65) + +___ + ### encodeTransactionNote ▸ **encodeTransactionNote**(`note?`): `Uint8Array` \| `undefined` @@ -348,7 +537,7 @@ the transaction note ready for inclusion in a transaction #### Defined in -[src/transaction.ts:39](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L39) +[src/transaction.ts:41](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L41) ___ @@ -383,7 +572,7 @@ https://developer.algorand.org/docs/get-details/accounts/#minimum-balance #### Defined in -[src/transfer.ts:114](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transfer.ts#L114) +[src/transfer.ts:120](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transfer.ts#L120) ___ @@ -460,7 +649,7 @@ The return value for the method call #### Defined in -[src/app.ts:386](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L386) +[src/app.ts:387](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L387) ___ @@ -827,7 +1016,7 @@ ___ ### getAppArgsForABICall -▸ **getAppArgsForABICall**(`args`, `from`): `Promise`<{ `appAccounts`: `undefined` \| `string`[] ; `appForeignApps`: `undefined` \| `number`[] = args.apps; `appForeignAssets`: `undefined` \| `number`[] = args.assets; `boxes`: `undefined` \| `BoxReference`[] ; `lease`: `undefined` \| `Uint8Array` ; `method`: `ABIMethod` ; `methodArgs`: (`string` \| `number` \| `bigint` \| `boolean` \| `Uint8Array` \| `ABIValue`[] \| `TransactionWithSigner`)[] = methodArgs; `rekeyTo`: `undefined` = undefined; `sender`: `string` ; `signer`: `TransactionSigner` = signer }\> +▸ **getAppArgsForABICall**(`args`, `from`): `Promise`<{ `appAccounts`: `undefined` \| `string`[] ; `appForeignApps`: `undefined` \| `number`[] = args.apps; `appForeignAssets`: `undefined` \| `number`[] = args.assets; `boxes`: `undefined` \| `BoxReference`[] ; `lease`: `undefined` \| `Uint8Array` ; `method`: `ABIMethod` ; `methodArgs`: (`string` \| `number` \| `bigint` \| `boolean` \| `Uint8Array` \| `ABIValue`[] \| `TransactionWithSigner`)[] = methodArgs; `rekeyTo`: `undefined` \| `string` ; `sender`: `string` ; `signer`: `TransactionSigner` = signer }\> Returns the app args ready to load onto an ABI method call in `AtomicTransactionComposer` @@ -840,13 +1029,13 @@ Returns the app args ready to load onto an ABI method call in `AtomicTransaction #### Returns -`Promise`<{ `appAccounts`: `undefined` \| `string`[] ; `appForeignApps`: `undefined` \| `number`[] = args.apps; `appForeignAssets`: `undefined` \| `number`[] = args.assets; `boxes`: `undefined` \| `BoxReference`[] ; `lease`: `undefined` \| `Uint8Array` ; `method`: `ABIMethod` ; `methodArgs`: (`string` \| `number` \| `bigint` \| `boolean` \| `Uint8Array` \| `ABIValue`[] \| `TransactionWithSigner`)[] = methodArgs; `rekeyTo`: `undefined` = undefined; `sender`: `string` ; `signer`: `TransactionSigner` = signer }\> +`Promise`<{ `appAccounts`: `undefined` \| `string`[] ; `appForeignApps`: `undefined` \| `number`[] = args.apps; `appForeignAssets`: `undefined` \| `number`[] = args.assets; `boxes`: `undefined` \| `BoxReference`[] ; `lease`: `undefined` \| `Uint8Array` ; `method`: `ABIMethod` ; `methodArgs`: (`string` \| `number` \| `bigint` \| `boolean` \| `Uint8Array` \| `ABIValue`[] \| `TransactionWithSigner`)[] = methodArgs; `rekeyTo`: `undefined` \| `string` ; `sender`: `string` ; `signer`: `TransactionSigner` = signer }\> The parameters ready to pass into `addMethodCall` within AtomicTransactionComposer #### Defined in -[src/app.ts:589](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L589) +[src/app.ts:590](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L590) ___ @@ -870,7 +1059,7 @@ The args ready to load into a `Transaction` #### Defined in -[src/app.ts:569](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L569) +[src/app.ts:570](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L570) ___ @@ -895,7 +1084,7 @@ The current box names #### Defined in -[src/app.ts:458](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L458) +[src/app.ts:459](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L459) ___ @@ -921,7 +1110,7 @@ The current box value as a byte array #### Defined in -[src/app.ts:476](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L476) +[src/app.ts:477](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L477) ___ @@ -946,7 +1135,7 @@ The current box value as an ABI value #### Defined in -[src/app.ts:499](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L499) +[src/app.ts:500](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L500) ___ @@ -972,7 +1161,7 @@ The current box values as a byte array in the same order as the passed in box na #### Defined in -[src/app.ts:489](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L489) +[src/app.ts:490](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L490) ___ @@ -997,7 +1186,7 @@ The current box values as an ABI value in the same order as the passed in box na #### Defined in -[src/app.ts:511](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L511) +[src/app.ts:512](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L512) ___ @@ -1204,7 +1393,7 @@ The current global state #### Defined in -[src/app.ts:422](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L422) +[src/app.ts:423](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L423) ___ @@ -1230,7 +1419,7 @@ The current local state for the given (app, account) combination #### Defined in -[src/app.ts:439](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L439) +[src/app.ts:440](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L440) ___ @@ -1258,7 +1447,7 @@ The `algosdk.OnApplicationComplete` #### Defined in -[src/app.ts:275](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L275) +[src/app.ts:276](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L276) ___ @@ -1282,7 +1471,7 @@ The array of transactions with signers #### Defined in -[src/transaction.ts:481](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L481) +[src/transaction.ts:519](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L519) ___ @@ -1531,7 +1720,7 @@ The public address #### Defined in -[src/transaction.ts:60](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L60) +[src/transaction.ts:98](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L98) ___ @@ -1556,7 +1745,7 @@ A transaction signer #### Defined in -[src/transaction.ts:70](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L70) +[src/transaction.ts:108](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L108) ___ @@ -1617,7 +1806,7 @@ The suggested transaction parameters #### Defined in -[src/transaction.ts:472](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L472) +[src/transaction.ts:510](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L510) ___ @@ -1643,7 +1832,7 @@ A TransactionWithSigner object. #### Defined in -[src/transaction.ts:83](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L83) +[src/transaction.ts:121](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L121) ___ @@ -1932,62 +2121,6 @@ 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`\> @@ -2010,7 +2143,7 @@ The dryrun result #### Defined in -[src/transaction.ts:278](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L278) +[src/transaction.ts:316](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L316) ___ @@ -2035,7 +2168,7 @@ The simulation result, which includes various details about how the transactions #### Defined in -[src/transaction.ts:293](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L293) +[src/transaction.ts:331](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L331) ___ @@ -2113,6 +2246,40 @@ This is a wrapper around algosdk.generateAccount to provide a more friendly/obvi ___ +### rekeyAccount + +▸ **rekeyAccount**(`rekey`, `algod`): `Promise`<[`SendTransactionResult`](../interfaces/types_transaction.SendTransactionResult.md)\> + +Rekey an account to a new address. + +**Note:** Please be careful with this function and be sure to read the [official rekey guidance](https://developer.algorand.org/docs/get-details/accounts/rekey/). + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `rekey` | [`AlgoRekeyParams`](../interfaces/types_transfer.AlgoRekeyParams.md) | The rekey definition | +| `algod` | `default` | An algod client | + +#### Returns + +`Promise`<[`SendTransactionResult`](../interfaces/types_transaction.SendTransactionResult.md)\> + +The transaction object and optionally the confirmation if it was sent to the chain (`skipSending` is `false` or unset) + +**`Example`** + +Usage example +```typescript +await algokit.rekeyAccount({ from, rekeyTo }, algod) +``` + +#### Defined in + +[src/transfer.ts:215](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transfer.ts#L215) + +___ + ### rekeyedAccount ▸ **rekeyedAccount**(`signer`, `sender`): [`SigningAccount`](../classes/types_account.SigningAccount.md) @@ -2218,7 +2385,7 @@ An object with transaction IDs, transactions, group transaction ID (`groupTransa #### Defined in -[src/transaction.ts:190](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L190) +[src/transaction.ts:228](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L228) ___ @@ -2243,7 +2410,7 @@ An object with transaction IDs, transactions, group transaction ID (`groupTransa #### Defined in -[src/transaction.ts:324](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L324) +[src/transaction.ts:362](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L362) ___ @@ -2271,7 +2438,7 @@ An object with transaction (`transaction`) and (if `skipWaiting` is `false` or ` #### Defined in -[src/transaction.ts:146](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L146) +[src/transaction.ts:184](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L184) ___ @@ -2296,7 +2463,7 @@ The signed transaction as a `Uint8Array` #### Defined in -[src/transaction.ts:126](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L126) +[src/transaction.ts:164](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L164) ___ @@ -2399,7 +2566,7 @@ await algokit.transferAlgos({ from, to, amount: algokit.algos(1) }, algod) #### Defined in -[src/transfer.ts:82](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transfer.ts#L82) +[src/transfer.ts:83](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transfer.ts#L83) ___ @@ -2431,7 +2598,7 @@ await algokit.transferAsset({ from, to, assetId, amount }, algod) #### Defined in -[src/transfer.ts:165](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transfer.ts#L165) +[src/transfer.ts:171](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transfer.ts#L171) ___ @@ -2456,7 +2623,7 @@ The transaction send result and the compilation result #### Defined in -[src/app.ts:188](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L188) +[src/app.ts:189](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L189) ___ @@ -2487,4 +2654,4 @@ Throws an error if the transaction is not confirmed or rejected in the next `tim #### Defined in -[src/transaction.ts:369](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L369) +[src/transaction.ts:407](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L407) diff --git a/docs/code/modules/types_app.md b/docs/code/modules/types_app.md index c58afc12..039e448a 100644 --- a/docs/code/modules/types_app.md +++ b/docs/code/modules/types_app.md @@ -60,7 +60,7 @@ An argument for an ABI method, either a primitive value, or a transaction with o #### Defined in -[src/types/app.ts:92](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L92) +[src/types/app.ts:97](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L97) ___ @@ -72,7 +72,7 @@ App call args for an ABI call #### Defined in -[src/types/app.ts:103](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L103) +[src/types/app.ts:108](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L108) ___ @@ -84,7 +84,7 @@ The return value of an ABI method call #### Defined in -[src/types/app.ts:213](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L213) +[src/types/app.ts:218](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L218) ___ @@ -98,7 +98,7 @@ Arguments to pass to an app call either: #### Defined in -[src/types/app.ts:114](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L114) +[src/types/app.ts:119](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L119) ___ @@ -119,7 +119,7 @@ Equivalent of `algosdk.OnApplicationComplete`, but as a more convenient string e #### Defined in -[src/types/app.ts:157](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L157) +[src/types/app.ts:162](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L162) ___ diff --git a/docs/code/modules/types_asset.md b/docs/code/modules/types_asset.md new file mode 100644 index 00000000..5e379b3a --- /dev/null +++ b/docs/code/modules/types_asset.md @@ -0,0 +1,11 @@ +[@algorandfoundation/algokit-utils](../README.md) / types/asset + +# Module: types/asset + +## Table of contents + +### Interfaces + +- [AssetBulkOptInOutParams](../interfaces/types_asset.AssetBulkOptInOutParams.md) +- [AssetOptInParams](../interfaces/types_asset.AssetOptInParams.md) +- [AssetOptOutParams](../interfaces/types_asset.AssetOptOutParams.md) diff --git a/docs/code/modules/types_transfer.md b/docs/code/modules/types_transfer.md index f96d2c1a..c68345fb 100644 --- a/docs/code/modules/types_transfer.md +++ b/docs/code/modules/types_transfer.md @@ -6,6 +6,7 @@ ### Interfaces +- [AlgoRekeyParams](../interfaces/types_transfer.AlgoRekeyParams.md) - [AlgoTransferParams](../interfaces/types_transfer.AlgoTransferParams.md) - [EnsureFundedParams](../interfaces/types_transfer.EnsureFundedParams.md) - [EnsureFundedReturnType](../interfaces/types_transfer.EnsureFundedReturnType.md) diff --git a/src/app.ts b/src/app.ts index f78ea711..f6380094 100644 --- a/src/app.ts +++ b/src/app.ts @@ -588,7 +588,6 @@ export function getAppArgsForTransaction(args?: RawAppCallArgs) { * @returns The parameters ready to pass into `addMethodCall` within AtomicTransactionComposer */ export async function getAppArgsForABICall(args: ABIAppCallArgs, from: SendTransactionFrom) { - const encoder = new TextEncoder() const signer = getSenderTransactionSigner(from) const methodArgs = await Promise.all( ('methodArgs' in args ? args.methodArgs : args)?.map(async (a, index) => { diff --git a/src/transaction.ts b/src/transaction.ts index 1094c8b2..1b29f1ca 100644 --- a/src/transaction.ts +++ b/src/transaction.ts @@ -63,7 +63,7 @@ export function encodeTransactionNote(note?: TransactionNote): Uint8Array | unde * @example algokit.encodeLease(new Uint8Array([1, 2, 3])) */ export function encodeLease(lease?: string | Uint8Array): Uint8Array | undefined { - if (lease == null || typeof lease === 'undefined') { + if (lease === null || typeof lease === 'undefined') { return undefined } else if (typeof lease === 'object' && lease.constructor === Uint8Array) { if (lease.length === 0 || lease.length > 32) {