From 363c8c85412e25bc64458d167abcdc9a80e15f9e Mon Sep 17 00:00:00 2001 From: Rob Moore Date: Wed, 29 Mar 2023 12:57:41 +0800 Subject: [PATCH 1/5] docs: Replacing sandbox with LocalNet --- docs/code/modules/index.md | 14 +++++++------- src/account.ts | 4 ++-- src/localnet.ts | 4 ++-- src/network-client.ts | 10 +++++----- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/code/modules/index.md b/docs/code/modules/index.md index ff59b6f3..5626975f 100644 --- a/docs/code/modules/index.md +++ b/docs/code/modules/index.md @@ -508,7 +508,7 @@ AlgoNode (mainnet) **`Example`** -Custom (e.g. default local sandbox, although we recommend loading this into a .env and using the Default option instead) +Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead) ```typescript const algod = getAlgoClient({server: 'http://localhost', port: '4001', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}) await algod.healthCheck().do() @@ -565,7 +565,7 @@ AlgoNode (mainnet) **`Example`** -Custom (e.g. default local sandbox, although we recommend loading this into a .env and using the Default option instead) +Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead) ```typescript const indexer = getAlgoIndexerClient({server: 'http://localhost', port: '8980', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}) await indexer.makeHealthCheck().do() @@ -593,7 +593,7 @@ ___ Returns a KMD SDK client that automatically retries on idempotent calls -KMD client allows you to export private keys, which is useful to get the default account in a sandbox network. +KMD client allows you to export private keys, which is useful to get the default account in a LocalNet network. **`Example`** @@ -606,7 +606,7 @@ Default (load from environment variables) **`Example`** -Custom (e.g. default local sandbox, although we recommend loading this into a .env and using the Default option instead) +Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead) ```typescript const kmd = getAlgoKmdClient({server: 'http://localhost', port: '4002', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}) ``` @@ -1017,7 +1017,7 @@ ___ Returns an account (with private key loaded) that can act as a dispenser -If running on Sandbox then it will return the default dispenser account automatically, +If running on LocalNet then it will return the default dispenser account automatically, otherwise it will load the account mnemonic stored in process.env.DISPENSER_MNEMONIC **`See`** @@ -1128,9 +1128,9 @@ ___ Gets an account with private key loaded from a KMD wallet of the given name, or alternatively creates one with funds in it via a KMD wallet of the given name. -This is useful to get idempotent accounts from a local sandbox without having to specify the private key (which will change when resetting the sandbox). +This is useful to get idempotent accounts from LocalNet without having to specify the private key (which will change when resetting the LocalNet). -This significantly speeds up local dev time and improves experience since you can write code that *just works* first go without manual config in a fresh sandbox. +This significantly speeds up local dev time and improves experience since you can write code that *just works* first go without manual config in a fresh LocalNet. If this is used via diff --git a/src/account.ts b/src/account.ts index e369ac6d..ac1c86f8 100644 --- a/src/account.ts +++ b/src/account.ts @@ -145,14 +145,14 @@ export function getAccountAddressAsString(addressEncodedInB64: string): string { /** Returns an account (with private key loaded) that can act as a dispenser * - * If running on Sandbox then it will return the default dispenser account automatically, + * If running on LocalNet then it will return the default dispenser account automatically, * otherwise it will load the account mnemonic stored in process.env.DISPENSER_MNEMONIC @see {getAccount} * * @param algod An algod client * @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient} */ export async function getDispenserAccount(algod: Algodv2, kmd?: Kmd) { - // If we are running against a sandbox we can use the default account within it, otherwise use an automation account specified via environment variables and ensure it's populated with ALGOs + // If we are running against LocalNet we can use the default account within it, otherwise use an automation account specified via environment variables and ensure it's populated with ALGOs const canFundFromDefaultAccount = await isLocalNet(algod) return canFundFromDefaultAccount ? await getLocalNetDispenserAccount(algod, kmd) : await getAccount(DISPENSER_ACCOUNT, algod) } diff --git a/src/localnet.ts b/src/localnet.ts index 4c3b6aee..2f7f70aa 100644 --- a/src/localnet.ts +++ b/src/localnet.ts @@ -15,9 +15,9 @@ export async function isLocalNet(algod: Algodv2): Promise { /** * Gets an account with private key loaded from a KMD wallet of the given name, or alternatively creates one with funds in it via a KMD wallet of the given name. * - * This is useful to get idempotent accounts from a local sandbox without having to specify the private key (which will change when resetting the sandbox). + * This is useful to get idempotent accounts from LocalNet without having to specify the private key (which will change when resetting the LocalNet). * - * This significantly speeds up local dev time and improves experience since you can write code that *just works* first go without manual config in a fresh sandbox. + * This significantly speeds up local dev time and improves experience since you can write code that *just works* first go without manual config in a fresh LocalNet. * * If this is used via @see {getAccount}, then you can even use the same code that runs on production without changes for local development! * diff --git a/src/network-client.ts b/src/network-client.ts index 6d4674ad..b262ed6f 100644 --- a/src/network-client.ts +++ b/src/network-client.ts @@ -90,7 +90,7 @@ function getAlgoTokenHeader(server: string, token?: string | TokenHeader, defaul * const algod = getAlgoClient(getAlgoNodeConfig('mainnet', 'algod')) * await algod.healthCheck().do() * ``` - * @example Custom (e.g. default local sandbox, although we recommend loading this into a .env and using the Default option instead) + * @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead) * ```typescript * const algod = getAlgoClient({server: 'http://localhost', port: '4001', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}) * await algod.healthCheck().do() @@ -123,7 +123,7 @@ export function getAlgoClient(config?: AlgoClientConfig): Algodv2 { * const indexer = getAlgoIndexerClient(getAlgoNodeConfig('mainnet', 'indexer')) * await indexer.makeHealthCheck().do() * ``` - * @example Custom (e.g. default local sandbox, although we recommend loading this into a .env and using the Default option instead) + * @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead) * ```typescript * const indexer = getAlgoIndexerClient({server: 'http://localhost', port: '8980', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}) * await indexer.makeHealthCheck().do() @@ -138,7 +138,7 @@ export function getAlgoIndexerClient(config?: AlgoClientConfig): Indexer { /** * Returns a KMD SDK client that automatically retries on idempotent calls * - * KMD client allows you to export private keys, which is useful to get the default account in a sandbox network. + * KMD client allows you to export private keys, which is useful to get the default account in a LocalNet network. * * @param config The config if you want to override the default (getting config from process.env) * @example Default (load from environment variables) @@ -147,14 +147,14 @@ export function getAlgoIndexerClient(config?: AlgoClientConfig): Indexer { * // Uses process.env.ALGOD_SERVER, process.env.KMD_PORT (or if not specified: port 4002) and process.env.ALGOD_TOKEN * const kmd = getAlgoKmdClient() * ``` - * @example Custom (e.g. default local sandbox, although we recommend loading this into a .env and using the Default option instead) + * @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead) * ```typescript * const kmd = getAlgoKmdClient({server: 'http://localhost', port: '4002', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}) * ``` */ export function getAlgoKmdClient(config?: AlgoClientConfig): Kmd { const { token, server } = config ?? getAlgodConfigFromEnvironment() - // We can only use Kmd on the Sandbox otherwise it's not exposed so this makes some assumptions + // We can only use Kmd on the LocalNet otherwise it's not exposed so this makes some assumptions // (e.g. same token and server as algod and port 4002 by default) return new Kmd(token as string, server, process?.env?.KMD_PORT ?? '4002') } From 36334b18ac6f528099b893ca171245df821c22c6 Mon Sep 17 00:00:00 2001 From: Rob Moore Date: Wed, 5 Apr 2023 18:59:31 +0800 Subject: [PATCH 2/5] feat(transaction): Added ability to pass an atomic transaction composer in to any transaction feat(account): Added ability to retrieve TransactionSigner from MultisigAccount and SigningAccount fix(transaction): Using atomic transaction composer for sendGroupOfTransactions to simplify code Note: Technically there is a breaking change in SigningAccount.signer, but I don't believe anyone would be using that property at this stage, so not marking as a major version bump. --- src/transaction.ts | 132 +++++++++++++++++---------------------- src/types/account.ts | 17 ++++- src/types/transaction.ts | 10 +-- 3 files changed, 78 insertions(+), 81 deletions(-) diff --git a/src/transaction.ts b/src/transaction.ts index 960d6e3a..02e3ebe5 100644 --- a/src/transaction.ts +++ b/src/transaction.ts @@ -1,7 +1,6 @@ -import algosdk, { Algodv2, SuggestedParams, Transaction } from 'algosdk' +import algosdk, { Algodv2, AtomicTransactionComposer, SuggestedParams, Transaction, TransactionSigner } from 'algosdk' import { Buffer } from 'buffer' import { Config } from './' -import { TransactionSignerAccount } from './types/account' import { PendingTransactionResponse } from './types/algod' import { AlgoAmount } from './types/amount' import { @@ -49,6 +48,29 @@ export const getSenderAddress = function (sender: SendTransactionFrom) { return 'addr' in sender ? sender.addr : sender.address() } +const memoize = (fn: (val: T) => R) => { + const cache = new Map() + const cached = function (this: unknown, val: T) { + return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val) + } + cached.cache = cache + return cached as (val: T) => R +} + +/** + * Returns a @see TransactionSigner for the given transaction sender. + * This function has memoization, so will return the same transaction signer for a given sender. + * @param sender A transaction sender + * @returns A transaction signer + */ +export const getSenderTransactionSigner = memoize(function (sender: SendTransactionFrom): TransactionSigner { + return 'signer' in sender + ? sender.signer + : 'lsig' in sender + ? algosdk.makeLogicSigAccountTransactionSigner(sender) + : algosdk.makeBasicAccountTransactionSigner(sender) +}) + /** Signs and sends the given transaction to the chain * * @param send The details for the transaction to send, including: @@ -68,7 +90,7 @@ export const sendTransaction = async function ( algod: Algodv2, ): Promise { const { transaction, from, sendParams } = send - const { skipSending, skipWaiting, fee, maxFee, suppressLog, maxRoundsToWaitForConfirmation } = sendParams ?? {} + const { skipSending, skipWaiting, fee, maxFee, suppressLog, maxRoundsToWaitForConfirmation, atc } = sendParams ?? {} if (fee) { transaction.fee = fee.microAlgos @@ -79,6 +101,11 @@ export const sendTransaction = async function ( capTransactionFee(transaction, maxFee) } + if (atc) { + atc.addTransaction({ txn: transaction, signer: getSenderTransactionSigner(from) }) + return { transaction } + } + if (skipSending) { return { transaction } } @@ -88,9 +115,9 @@ export const sendTransaction = async function ( ? transaction.signTxn(from.sk) : 'lsig' in from ? algosdk.signLogicSigTransactionObject(transaction, from).blob - : 'signer' in from - ? (await from.signer([transaction], [0]))[0] - : from.sign(transaction) + : 'sign' in from + ? from.sign(transaction) + : (await from.signer([transaction], [0]))[0] await algod.sendRawTransaction(signedTransaction).do() Config.getLogger(suppressLog).info(`Sent transaction ID ${transaction.txID()} ${transaction.type} from ${getSenderAddress(from)}`) @@ -103,12 +130,6 @@ export const sendTransaction = async function ( return { transaction, confirmation } } -const groupBy = (array: T[], predicate: (value: T, id: number, array: T[]) => string) => - array.reduce((acc, value, id, array) => { - ;(acc[predicate(value, id, array)] ||= []).push(value) - return acc - }, {} as { [key: string]: T[] }) - /** * Signs and sends a group of [up to 16](https://developer.algorand.org/docs/get-details/atomic_transfers/#create-transactions) transactions to the chain * @@ -121,84 +142,47 @@ const groupBy = (array: T[], predicate: (value: T, id: number, array: T[]) => export const sendGroupOfTransactions = async function (groupSend: TransactionGroupToSend, algod: Algodv2) { const { transactions, signer, sendParams } = groupSend + const defaultTransactionSigner = signer ? getSenderTransactionSigner(signer) : undefined + const transactionsWithSigner = await Promise.all( transactions.map(async (t) => { - if ('signer' in t) return t + if ('signer' in t) + return { + txn: t.transaction, + signer: getSenderTransactionSigner(t.signer), + sender: t.signer, + } const txn = 'then' in t ? (await t).transaction : t if (!signer) { - throw new Error(`Attempt to send transaction ${txn.txID()} as part of a group transaction, but no signer was provided.`) + throw new Error(`Attempt to send transaction ${txn.txID()} as part of a group transaction, but no signer parameter was provided.`) } return { - transaction: txn, - signer: signer, + txn, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + signer: defaultTransactionSigner!, + sender: signer, } }), ) + + const atc = new AtomicTransactionComposer() + transactionsWithSigner.forEach((txn) => atc.addTransaction(txn)) + const signedTransactions = await atc.gatherSignatures() + const transactionsToSend = transactionsWithSigner.map((t) => { - return t.transaction + return t.txn }) - - const group = algosdk.assignGroupID(transactionsToSend) // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const groupId = Buffer.from(group[0].group!).toString('base64') - - Config.getLogger(sendParams?.suppressLog).info(`Sending group of transactions (${groupId})`, { transactionsToSend }) - - // Sign transactions either using TransactionSigners, or not - let signedTransactions: Uint8Array[] - if (transactionsWithSigner.find((t) => 'signer' in t.signer)) { - // Validate all or nothing for transaction signers - if (transactionsWithSigner.find((t) => !('signer' in t.signer))) { - throw new Error( - "When issuing a group transaction the signers should either all be TransactionSignerAccount's or all not. " + - 'Received at least one TransactionSignerAccount, but not all of them so failing the send.', - ) - } - - // Group transaction signers by signer - const groupedBySigner = groupBy( - transactionsWithSigner.map((t, i) => ({ - signer: t.signer as TransactionSignerAccount, - id: i, - })), - (t) => t.signer.addr, - ) - - // Perform the signature, grouped by signer - const signed = ( - await Promise.all( - Object.values(groupedBySigner).map(async (signature) => { - const indexes = signature.map((s) => s.id) - const signed = await signature[0].signer.signer(group, indexes) - return signed.map((txn, i) => ({ - txn, - id: indexes[i], - })) - }), - ) - ).flatMap((a) => a) - - // Extract the signed transactions in order - signedTransactions = signed.sort((s1, s2) => s1.id - s2.id).map((s) => s.txn) - } else { - signedTransactions = group.map((groupedTransaction, id) => { - const signer = transactionsWithSigner[id].signer - return 'sk' in signer - ? groupedTransaction.signTxn(signer.sk) - : 'lsig' in signer - ? algosdk.signLogicSigTransactionObject(groupedTransaction, signer).blob - : 'sign' in signer - ? signer.sign(groupedTransaction) - : // This bit will never happen because above if statement - new Uint8Array() - }) - } + const groupId = Buffer.from(transactionsToSend[0].group!).toString('base64') + Config.getLogger(sendParams?.suppressLog).info(`Sending group of ${transactionsToSend.length} transactions (${groupId})`, { + transactionsToSend, + }) Config.getLogger(sendParams?.suppressLog).debug( - `Signer IDs (${groupId})`, - transactionsWithSigner.map((t) => getSenderAddress(t.signer)), + `Sender Addresses (${groupId})`, + transactionsWithSigner.map((t) => getSenderAddress(t.sender)), ) Config.getLogger(sendParams?.suppressLog).debug( diff --git a/src/types/account.ts b/src/types/account.ts index a77a6c1d..3987aba9 100644 --- a/src/types/account.ts +++ b/src/types/account.ts @@ -10,6 +10,7 @@ export class MultisigAccount { _params: algosdk.MultisigMetadata _signingAccounts: (algosdk.Account | SigningAccount)[] _addr: string + _signer: TransactionSigner /** The parameters for the multisig account */ get params(): Readonly { @@ -26,10 +27,18 @@ export class MultisigAccount { return this._addr } + get signer(): TransactionSigner { + return this._signer + } + constructor(multisigParams: MultisigMetadata, signingAccounts: (Account | SigningAccount)[]) { this._params = multisigParams this._signingAccounts = signingAccounts this._addr = algosdk.multisigAddress(multisigParams) + this._signer = algosdk.makeMultiSigAccountTransactionSigner( + multisigParams, + signingAccounts.map((a) => a.sk), + ) } /** @@ -54,6 +63,7 @@ export class MultisigAccount { /** Account wrapper that supports a rekeyed account */ export class SigningAccount implements Account { private _account: Account + private _signer: TransactionSigner private _sender: string /** @@ -71,10 +81,10 @@ export class SigningAccount implements Account { } /** - * Algorand account of the underlying signing account + * Transaction signer for the underlying signing account */ - get signer(): Account { - return this._account + get signer(): TransactionSigner { + return this._signer } /** @@ -90,6 +100,7 @@ export class SigningAccount implements Account { constructor(account: Account, sender: string | undefined) { this._account = account this._sender = sender ?? account.addr + this._signer = algosdk.makeBasicAccountTransactionSigner(account) } } diff --git a/src/types/transaction.ts b/src/types/transaction.ts index 804818b1..8a49066a 100644 --- a/src/types/transaction.ts +++ b/src/types/transaction.ts @@ -1,4 +1,4 @@ -import { Account, LogicSigAccount, Transaction } from 'algosdk' +import { Account, AtomicTransactionComposer, LogicSigAccount, Transaction } from 'algosdk' import { MultisigAccount, SigningAccount, TransactionSignerAccount } from './account' import { PendingTransactionResponse } from './algod' import { AlgoAmount } from './amount' @@ -26,6 +26,8 @@ export interface SendTransactionParams { skipSending?: boolean /** Whether to skip waiting for the submitted transaction (only relevant if `skipSending` is `false` or unset) */ skipWaiting?: boolean + /** An optional @see AtomicTransactionComposer to add the transaction to, if specified then has the same effect as `skipSending: true` */ + atc?: AtomicTransactionComposer /** Whether to suppress log messages from transaction send, default: do not suppress */ suppressLog?: boolean /** The flat fee you want to pay, useful for covering extra fees in a transaction group or app call */ @@ -65,10 +67,10 @@ export interface TransactionToSign { */ export interface TransactionGroupToSend { /** Any parameters to control the semantics of the send to the network */ - sendParams?: Omit, 'skipSending'> + sendParams?: Omit /** The list of transactions to send, which can either be a raw transaction (in which case `signer` is required), - * the async result of an AlgoKit utils method that returns a @see SendTransactionResult (saves unwrapping the promise, be sure to pass `skipSending: true`, `signer` is required) - * or the transaction with its signer + * the async result of an AlgoKit utils method that returns a @see SendTransactionResult (saves unwrapping the promise, be sure to pass `skipSending: true`, `signer` is also required) + * or the transaction with its signer (`signer` is ignored) **/ transactions: (TransactionToSign | Transaction | Promise)[] /** Optional signer to pass in, required if at least one transaction provided is just the transaction, ignored otherwise */ From 856db796d8d23081c4f2e7d3ddc6d9d922e6852d Mon Sep 17 00:00:00 2001 From: Rob Moore Date: Wed, 5 Apr 2023 19:25:52 +0800 Subject: [PATCH 3/5] refactor(app): Replacing custom abi return parsing code with ATC static call --- src/app.ts | 51 +++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/src/app.ts b/src/app.ts index f29e4073..5c284aa3 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,5 +1,6 @@ import algosdk, { ABIMethod, + ABIResult, ABIValue, Algodv2, AtomicTransactionComposer, @@ -14,7 +15,6 @@ import { encodeTransactionNote, getSenderAddress, getTransactionParams, sendTran import { ApplicationResponse, EvalDelta, PendingTransactionResponse, TealValue } from './types/algod' import { ABIReturn, - ABI_RETURN_PREFIX, AppCallArgs, AppCallParams, AppCallTransactionResult, @@ -171,32 +171,31 @@ export async function callApp(call: AppCallParams, algod: Algodv2): Promise Date: Thu, 6 Apr 2023 00:19:25 +0800 Subject: [PATCH 4/5] feat(app): Incorporated ABI and ATC properly into create/update/call app test(application-client): Improved test coverage of application client and added test contract fix(application-client): Resolved incorrect on complete actions from some app client methods --- src/__snapshots__/deploy-app.spec.ts.snap | 20 +- src/app.ts | 361 ++++++++++++------ src/deploy-app.ts | 74 ++-- src/transaction.ts | 158 +++++--- src/types/app.ts | 8 +- src/types/application-client.spec.ts | 300 ++++++++++++++- src/types/application-client.ts | 6 +- src/types/transaction.ts | 26 +- .../testing-app/application.json | 53 ++- .../testing-app/approval.teal | 270 ++++++++++--- .../testing-app/contract.json | 36 ++ .../example-contracts/testing-app/contract.py | 127 ++++++ 12 files changed, 1168 insertions(+), 271 deletions(-) create mode 100644 tests/example-contracts/testing-app/contract.py diff --git a/src/__snapshots__/deploy-app.spec.ts.snap b/src/__snapshots__/deploy-app.spec.ts.snap index 80de3d50..725d4545 100644 --- a/src/__snapshots__/deploy-app.spec.ts.snap +++ b/src/__snapshots__/deploy-app.spec.ts.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`deploy-app Deploy failure for replacement of permanent, updated app 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 4668 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 6770 bytes of teal code and 39 bytes of teal code INFO: Existing app test found by creator ACCOUNT_1, with app id APP_1 and version 1.0. INFO: Detected a TEAL update in app APP_1 for creator ACCOUNT_1 WARN: App is not deletable and onUpdate=ReplaceApp, will attempt to create new app and delete old app, delete will most likely fail @@ -10,26 +10,26 @@ WARN: Deleting existing test app with id APP_1 from ACCOUNT_1 account." `; exports[`deploy-app Deploy failure for replacement of schema broken app fails if onSchemaBreak = Fail 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 4668 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 6770 bytes of teal code and 39 bytes of teal code INFO: Existing app test found by creator ACCOUNT_1, with app id APP_1 and version 1.0. WARN: Detected a breaking app schema change in app APP_1: | [{"from":{"global":{"num-byte-slice":2,"num-uint":3},"local":{"num-byte-slice":2,"num-uint":2}},"to":{"global":{"num-byte-slice":3,"num-uint":3},"local":{"num-byte-slice":2,"num-uint":2}}}]" `; exports[`deploy-app Deploy failure for updated app fails if onupdate = Fail 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 4668 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 6770 bytes of teal code and 39 bytes of teal code INFO: Existing app test found by creator ACCOUNT_1, with app id APP_1 and version 1.0. INFO: Detected a TEAL update in app APP_1 for creator ACCOUNT_1" `; exports[`deploy-app Deploy new app 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 4668 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 6770 bytes of teal code and 39 bytes of teal code INFO: App test not found in apps created by ACCOUNT_1; deploying app with version 1.0. INFO: Sent transaction ID TXID_1 appl from ACCOUNT_1 DEBUG: Created app APP_1 from creator ACCOUNT_1" `; exports[`deploy-app Deploy replacement of deletable schema broken app 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 4668 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 6770 bytes of teal code and 39 bytes of teal code INFO: Existing app test found by creator ACCOUNT_1, with app id APP_1 and version 1.0. WARN: Detected a breaking app schema change in app APP_1: | [{"from":{"global":{"num-byte-slice":2,"num-uint":3},"local":{"num-byte-slice":2,"num-uint":2}},"to":{"global":{"num-byte-slice":3,"num-uint":3},"local":{"num-byte-slice":2,"num-uint":2}}}] INFO: App is deletable and onSchemaBreak=ReplaceApp, will attempt to create new app and delete old app @@ -39,7 +39,7 @@ WARN: Sent transactions TXID_2 to create app with id APP_2 and TXID_3 to delete `; exports[`deploy-app Deploy replacement to deletable, updated app 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 4668 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 6770 bytes of teal code and 39 bytes of teal code INFO: Existing app test found by creator ACCOUNT_1, with app id APP_1 and version 1.0. INFO: Detected a TEAL update in app APP_1 for creator ACCOUNT_1 WARN: App is deletable and onUpdate=ReplaceApp, creating new app and deleting old app... @@ -49,7 +49,7 @@ WARN: Sent transactions TXID_2 to create app with id APP_2 and TXID_3 to delete `; exports[`deploy-app Deploy replacement to schema broken, permanent app fails 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 4668 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 6770 bytes of teal code and 39 bytes of teal code INFO: Existing app test found by creator ACCOUNT_1, with app id APP_1 and version 1.0. WARN: Detected a breaking app schema change in app APP_1: | [{"from":{"global":{"num-byte-slice":2,"num-uint":3},"local":{"num-byte-slice":2,"num-uint":2}},"to":{"global":{"num-byte-slice":3,"num-uint":3},"local":{"num-byte-slice":2,"num-uint":2}}}] INFO: App is not deletable but onSchemaBreak=ReplaceApp, will attempt to delete app, delete will most likely fail @@ -58,7 +58,7 @@ WARN: Deleting existing test app with id APP_1 from ACCOUNT_1 account." `; exports[`deploy-app Deploy update to immutable updated app fails 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 4668 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 6770 bytes of teal code and 39 bytes of teal code INFO: Existing app test found by creator ACCOUNT_1, with app id APP_1 and version 1.0. INFO: Detected a TEAL update in app APP_1 for creator ACCOUNT_1 WARN: App is not updatable but onUpdate=UpdateApp, will attempt to update app, update will most likely fail @@ -67,7 +67,7 @@ DEBUG: Updating app APP_1" `; exports[`deploy-app Deploy update to updatable updated app 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 4668 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 6770 bytes of teal code and 39 bytes of teal code INFO: Existing app test found by creator ACCOUNT_1, with app id APP_1 and version 1.0. INFO: Detected a TEAL update in app APP_1 for creator ACCOUNT_1 INFO: App is updatable and onUpdate=UpdateApp, updating app... @@ -77,7 +77,7 @@ INFO: Sent transaction ID TXID_2 appl from ACCOUNT_1" `; exports[`deploy-app Do nothing if deploying app with no changes 1`] = ` -"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 4668 bytes of teal code and 39 bytes of teal code +"INFO: Idempotently deploying app "test" from creator ACCOUNT_1 using 6770 bytes of teal code and 39 bytes of teal code INFO: Existing app test found by creator ACCOUNT_1, with app id APP_1 and version 1.0. DEBUG: No detected changes in app, nothing to do." `; diff --git a/src/app.ts b/src/app.ts index 5c284aa3..d67c6d86 100644 --- a/src/app.ts +++ b/src/app.ts @@ -4,16 +4,25 @@ import algosdk, { ABIValue, Algodv2, AtomicTransactionComposer, - makeBasicAccountTransactionSigner, OnApplicationComplete, SourceMap, Transaction, } from 'algosdk' import { Buffer } from 'buffer' import { Config } from './' -import { encodeTransactionNote, getSenderAddress, getTransactionParams, sendTransaction } from './transaction' +import { + controlFees, + encodeTransactionNote, + getAtomicTransactionComposerTransactions, + getSenderAddress, + getSenderTransactionSigner, + getTransactionParams, + sendAtomicTransactionComposer, + sendTransaction, +} from './transaction' import { ApplicationResponse, EvalDelta, PendingTransactionResponse, TealValue } from './types/algod' import { + ABIAppCallArgs, ABIReturn, AppCallArgs, AppCallParams, @@ -27,9 +36,10 @@ import { BoxValuesRequestParams, CompiledTeal, CreateAppParams, + RawAppCallArgs, UpdateAppParams, } from './types/app' -import { SendTransactionFrom } from './types/transaction' +import { SendTransactionFrom, SendTransactionParams } from './types/transaction' /** * Creates a smart contract app, returns the details of the created app. @@ -48,40 +58,108 @@ export async function createApp( const compiledClear = typeof clear === 'string' ? await compileTeal(clear, algod) : undefined const clearProgram = compiledClear ? compiledClear.compiledBase64ToBytes : clear - const transaction = algosdk.makeApplicationCreateTxnFromObject({ - approvalProgram: approvalProgram as Uint8Array, - clearProgram: clearProgram as Uint8Array, - numLocalInts: schema.localInts, - numLocalByteSlices: schema.localByteSlices, - numGlobalInts: schema.globalInts, - numGlobalByteSlices: schema.globalByteSlices, - extraPages: schema.extraPages ?? Math.floor((approvalProgram.length + clearProgram.length) / APP_PAGE_MAX_SIZE), - onComplete: algosdk.OnApplicationComplete.NoOpOC, - suggestedParams: await getTransactionParams(transactionParams, algod), - from: getSenderAddress(from), - note: encodeTransactionNote(note), - ...getAppArgsForTransaction(args), - rekeyTo: undefined, - }) - - const { confirmation } = await sendTransaction({ transaction, from, sendParams }, algod) - if (confirmation) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const appId = confirmation['application-index']! + if (args && 'method' in args) { + const atc = attachATC(sendParams) + + const before = getAtomicTransactionComposerTransactions(atc) + + atc.addMethodCall({ + appID: 0, + approvalProgram: approvalProgram as Uint8Array, + clearProgram: clearProgram as Uint8Array, + numLocalInts: schema.localInts, + numLocalByteSlices: schema.localByteSlices, + numGlobalInts: schema.globalInts, + numGlobalByteSlices: schema.globalByteSlices, + extraPages: schema.extraPages ?? Math.floor((approvalProgram.length + clearProgram.length) / APP_PAGE_MAX_SIZE), + onComplete: algosdk.OnApplicationComplete.NoOpOC, + suggestedParams: controlFees(await getTransactionParams(transactionParams, algod), sendParams), + note: encodeTransactionNote(note), + ...getAppArgsForABICall(args, from), + }) - Config.getLogger(sendParams.suppressLog).debug(`Created app ${appId} from creator ${getSenderAddress(from)}`) + if (sendParams.skipSending) { + const after = atc.clone().buildGroup() + return { + transaction: after[after.length - 1].txn, + transactions: after.slice(before.length).map((t) => t.txn), + appId: 0, + appAddress: '', + compiledApproval, + compiledClear, + } + } - return { - transaction, - confirmation, - appId, - appAddress: algosdk.getApplicationAddress(appId), - return: getABIReturn(args, confirmation), - compiledApproval, - compiledClear, + const result = await sendAtomicTransactionComposer({ atc, sendParams }, algod) + const confirmation = result.confirmations ? result.confirmations[result.confirmations?.length - 1] : undefined + if (confirmation) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const appId = confirmation['application-index']! + + Config.getLogger(sendParams.suppressLog).debug(`Created app ${appId} from creator ${getSenderAddress(from)}`) + + return { + transactions: result.transactions, + confirmations: result.confirmations, + return: confirmation ? getABIReturn(args, confirmation) : undefined, + transaction: result.transactions[result.transactions.length - 1], + confirmation: confirmation, + appId, + appAddress: algosdk.getApplicationAddress(appId), + compiledApproval, + compiledClear, + } + } else { + return { + transactions: result.transactions, + confirmations: result.confirmations, + return: confirmation ? getABIReturn(args, confirmation) : undefined, + transaction: result.transactions[result.transactions.length - 1], + confirmation: confirmation, + appId: 0, + appAddress: '', + compiledApproval, + compiledClear, + } } } else { - return { transaction, appId: 0, appAddress: '', compiledApproval, compiledClear } + const transaction = algosdk.makeApplicationCreateTxnFromObject({ + approvalProgram: approvalProgram as Uint8Array, + clearProgram: clearProgram as Uint8Array, + numLocalInts: schema.localInts, + numLocalByteSlices: schema.localByteSlices, + numGlobalInts: schema.globalInts, + numGlobalByteSlices: schema.globalByteSlices, + extraPages: schema.extraPages ?? Math.floor((approvalProgram.length + clearProgram.length) / APP_PAGE_MAX_SIZE), + onComplete: algosdk.OnApplicationComplete.NoOpOC, + suggestedParams: await getTransactionParams(transactionParams, algod), + from: getSenderAddress(from), + note: encodeTransactionNote(note), + ...getAppArgsForTransaction(args), + rekeyTo: undefined, + }) + + const { confirmation } = await sendTransaction({ transaction, from, sendParams }, algod) + if (confirmation) { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const appId = confirmation['application-index']! + + Config.getLogger(sendParams.suppressLog).debug(`Created app ${appId} from creator ${getSenderAddress(from)}`) + + return { + transaction, + transactions: [transaction], + confirmation, + confirmations: confirmation ? [confirmation] : undefined, + appId, + appAddress: algosdk.getApplicationAddress(appId), + return: getABIReturn(args, confirmation), + compiledApproval, + compiledClear, + } + } else { + return { transaction, transactions: [transaction], appId: 0, appAddress: '', compiledApproval, compiledClear } + } } } @@ -102,27 +180,71 @@ export async function updateApp( const compiledClear = typeof clear === 'string' ? await compileTeal(clear, algod) : undefined const clearProgram = compiledClear ? compiledClear.compiledBase64ToBytes : clear - const transaction = algosdk.makeApplicationUpdateTxnFromObject({ - appIndex: appId, - approvalProgram: approvalProgram as Uint8Array, - clearProgram: clearProgram as Uint8Array, - suggestedParams: await getTransactionParams(transactionParams, algod), - from: getSenderAddress(from), - note: encodeTransactionNote(note), - ...getAppArgsForTransaction(args), - rekeyTo: undefined, - }) - Config.getLogger(sendParams.suppressLog).debug(`Updating app ${appId}`) - const result = await sendTransaction({ transaction, from, sendParams }, algod) + if (args && 'method' in args) { + const atc = attachATC(sendParams) - return { - ...result, - return: getABIReturn(args, result.confirmation), - compiledApproval, - compiledClear, + const before = getAtomicTransactionComposerTransactions(atc) + + atc.addMethodCall({ + appID: appId, + onComplete: OnApplicationComplete.UpdateApplicationOC, + approvalProgram: approvalProgram as Uint8Array, + clearProgram: clearProgram as Uint8Array, + suggestedParams: controlFees(await getTransactionParams(transactionParams, algod), sendParams), + note: encodeTransactionNote(note), + ...getAppArgsForABICall(args, from), + }) + + if (sendParams.skipSending) { + const after = atc.clone().buildGroup() + return { + transaction: after[after.length - 1].txn, + transactions: after.slice(before.length).map((t) => t.txn), + } + } + + const result = await sendAtomicTransactionComposer({ atc, sendParams }, algod) + const confirmation = result.confirmations ? result.confirmations[result.confirmations?.length - 1] : undefined + return { + transactions: result.transactions, + confirmations: result.confirmations, + return: confirmation ? getABIReturn(args, confirmation) : undefined, + transaction: result.transactions[result.transactions.length - 1], + confirmation: confirmation, + } + } else { + const transaction = algosdk.makeApplicationUpdateTxnFromObject({ + appIndex: appId, + approvalProgram: approvalProgram as Uint8Array, + clearProgram: clearProgram as Uint8Array, + suggestedParams: await getTransactionParams(transactionParams, algod), + from: getSenderAddress(from), + note: encodeTransactionNote(note), + ...getAppArgsForTransaction(args), + rekeyTo: undefined, + }) + + const result = await sendTransaction({ transaction, from, sendParams }, algod) + + return { + ...result, + transactions: [result.transaction], + confirmations: result.confirmation ? [result.confirmation] : undefined, + return: getABIReturn(args, result.confirmation), + compiledApproval, + compiledClear, + } + } +} + +function attachATC(sendParams: SendTransactionParams) { + if (sendParams.atc) { + sendParams.skipSending = true } + sendParams.atc = sendParams.atc ?? new AtomicTransactionComposer() + return sendParams.atc } /** @@ -134,6 +256,47 @@ export async function updateApp( export async function callApp(call: AppCallParams, algod: Algodv2): Promise { const { appId, callType, from, args, note, transactionParams, ...sendParams } = call + if (args && 'method' in args) { + const atc = attachATC(sendParams) + + const before = getAtomicTransactionComposerTransactions(atc) + + atc.addMethodCall({ + appID: appId, + suggestedParams: controlFees(await getTransactionParams(transactionParams, algod), sendParams), + note: encodeTransactionNote(note), + onComplete: + callType === 'normal' + ? OnApplicationComplete.NoOpOC + : callType === 'clearstate' + ? OnApplicationComplete.ClearStateOC + : callType === 'closeout' + ? OnApplicationComplete.CloseOutOC + : callType === 'delete' + ? OnApplicationComplete.DeleteApplicationOC + : OnApplicationComplete.OptInOC, + ...getAppArgsForABICall(args, from), + }) + + if (sendParams.skipSending) { + const after = atc.clone().buildGroup() + return { + transaction: after[after.length - 1].txn, + transactions: after.slice(before.length).map((t) => t.txn), + } + } + + const result = await sendAtomicTransactionComposer({ atc, sendParams }, algod) + const confirmation = result.confirmations ? result.confirmations[result.confirmations?.length - 1] : undefined + return { + transactions: result.transactions, + confirmations: result.confirmations, + return: confirmation ? getABIReturn(args, confirmation) : undefined, + transaction: result.transactions[result.transactions.length - 1], + confirmation: confirmation, + } + } + const appCallParams = { appIndex: appId, from: getSenderAddress(from), @@ -166,6 +329,8 @@ export async function callApp(call: AppCallParams, algod: Algodv2): Promise { - if (typeof a !== 'object') { - return a - } - // Handle the various forms of transactions to wrangle them for ATC - return 'txn' in a - ? a - : 'transaction' in a - ? { txn: a.transaction, signer: dummySigner } - : 'txID' in a - ? { txn: a, signer: dummySigner } - : a - }) - - const dummyOnComplete = OnApplicationComplete.NoOpOC - dummyAtc.addMethodCall({ - method: 'txnCount' in args.method ? args.method : new ABIMethod(args.method), - methodArgs, - // Rest are dummy values - appID: dummyAppId, - sender: dummyAccount.addr, - signer: dummySigner, - suggestedParams: dummyParams, - onComplete: dummyOnComplete, - }) - const txns = dummyAtc.buildGroup() - const txn = txns[txns.length - 1] - actualArgs = { - accounts: txn.txn.appAccounts, - appArgs: txn.txn.appArgs, - apps: txn.txn.appForeignApps, - assets: txn.txn.appForeignAssets, - boxes: args.boxes?.map((b) => (typeof b === 'object' && 'appId' in b ? b : { appId: 0, name: b })), - lease: args.lease, - } - } else { - actualArgs = args + const encoder = new TextEncoder() + return { + accounts: args?.accounts?.map((a) => (typeof a === 'string' ? a : algosdk.encodeAddress(a.publicKey))), + appArgs: args?.appArgs?.map((a) => (typeof a === 'string' ? encoder.encode(a) : a)), + boxes: args?.boxes + ?.map((b) => (typeof b === 'object' && 'appId' in b ? b : { appId: 0, name: b })) + ?.map( + (ref) => + ({ + appIndex: ref.appId, + name: typeof ref.name === 'string' ? encoder.encode(ref.name) : ref.name, + } as algosdk.BoxReference), + ), + foreignApps: args?.apps, + foreignAssets: args?.assets, + lease: typeof args?.lease === 'string' ? encoder.encode(args?.lease) : args?.lease, } +} +/** Returns the app args ready to load onto an ABI method call in @see AtomicTransactionComposer */ +export function getAppArgsForABICall(args: ABIAppCallArgs, from: SendTransactionFrom) { const encoder = new TextEncoder() + const signer = getSenderTransactionSigner(from) + const methodArgs = args.args?.map((a) => { + if (typeof a !== 'object') { + return a + } + // Handle the various forms of transactions to wrangle them for ATC + return 'txn' in a ? a : 'transaction' in a ? { txn: a.transaction, signer } : 'txID' in a ? { txn: a, signer } : a + }) return { - accounts: actualArgs?.accounts?.map((a) => (typeof a === 'string' ? a : algosdk.encodeAddress(a.publicKey))), - appArgs: actualArgs?.appArgs?.map((a) => (typeof a === 'string' ? encoder.encode(a) : a)), - boxes: actualArgs?.boxes + method: 'txnCount' in args.method ? args.method : new ABIMethod(args.method), + sender: getSenderAddress(from), + signer: signer, + boxes: args.boxes ?.map((b) => (typeof b === 'object' && 'appId' in b ? b : { appId: 0, name: b })) ?.map( (ref) => @@ -415,9 +554,9 @@ export function getAppArgsForTransaction(args?: AppCallArgs) { name: typeof ref.name === 'string' ? encoder.encode(ref.name) : ref.name, } as algosdk.BoxReference), ), - foreignApps: actualArgs?.apps, - foreignAssets: actualArgs?.assets, - lease: typeof actualArgs?.lease === 'string' ? encoder.encode(actualArgs?.lease) : actualArgs?.lease, + lease: typeof args.lease === 'string' ? encoder.encode(args.lease) : args.lease, + methodArgs: methodArgs, + rekeyTo: undefined, } } diff --git a/src/deploy-app.ts b/src/deploy-app.ts index bed30954..5a396d67 100644 --- a/src/deploy-app.ts +++ b/src/deploy-app.ts @@ -1,10 +1,11 @@ -import { Algodv2, getApplicationAddress, Indexer, TransactionType } from 'algosdk' +import { Algodv2, AtomicTransactionComposer, getApplicationAddress, Indexer, TransactionType } from 'algosdk' import { Config } from './' import { callApp, compileTeal, createApp, getAppByIndex, updateApp } from './app' import { lookupAccountCreatedApplicationByAddress, searchTransactions } from './indexer-lookup' -import { getSenderAddress, sendGroupOfTransactions } from './transaction' +import { getSenderAddress, sendAtomicTransactionComposer } from './transaction' import { ApplicationStateSchema } from './types/algod' import { + ABIReturn, AppCompilationResult, AppDeploymentParams, AppDeployMetadata, @@ -18,7 +19,7 @@ import { TealTemplateParams, UPDATABLE_TEMPLATE_NAME, } from './types/app' -import { ConfirmedTransactionResult, SendTransactionFrom } from './types/transaction' +import { ConfirmedTransactionResult, ConfirmedTransactionResults, SendTransactionFrom } from './types/transaction' /** * Idempotently deploy (create, update/delete if changed) an app against the given name via the given creator account, including deploy-time template placeholder substitutions. @@ -42,8 +43,14 @@ export async function deployApp( ): Promise< Partial & ( - | (ConfirmedTransactionResult & AppMetadata & { operationPerformed: 'create' | 'update' }) - | (ConfirmedTransactionResult & AppMetadata & { deleteResult: ConfirmedTransactionResult; operationPerformed: 'replace' }) + | (ConfirmedTransactionResults & AppMetadata & { return?: ABIReturn; operationPerformed: 'create' | 'update' }) + | (ConfirmedTransactionResults & + AppMetadata & { + return?: ABIReturn + deleteReturn?: ABIReturn + deleteResult: ConfirmedTransactionResult + operationPerformed: 'replace' + }) | (AppMetadata & { operationPerformed: 'nothing' }) ) > { @@ -91,14 +98,16 @@ export async function deployApp( const apps = existingDeployments ?? (await getCreatorAppsByName(appParams.from, indexer!)) const create = async ( - skipSending?: boolean, - ): Promise & ConfirmedTransactionResult & AppMetadata & { operationPerformed: 'create' }> => { + atc?: AtomicTransactionComposer, + ): Promise< + Partial & ConfirmedTransactionResults & AppMetadata & { return?: ABIReturn; operationPerformed: 'create' } + > => { const result = await createApp( { ...appParams, args: createArgs, note: getAppDeploymentTransactionNote(metadata), - skipSending: skipSending ?? false, + atc, skipWaiting: false, }, algod, @@ -106,8 +115,12 @@ export async function deployApp( return { transaction: result.transaction, + transactions: result.transactions, // eslint-disable-next-line @typescript-eslint/no-non-null-assertion confirmation: result.confirmation!, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + confirmations: result.confirmations!, + return: result.return, appId: result.appId, appAddress: result.appAddress, createdMetadata: metadata, @@ -163,16 +176,24 @@ export async function deployApp( const replace = async (): Promise< Partial & - ConfirmedTransactionResult & - AppMetadata & { deleteResult: ConfirmedTransactionResult; operationPerformed: 'replace' } + ConfirmedTransactionResults & + AppMetadata & { + return?: ABIReturn + deleteReturn?: ABIReturn + deleteResult: ConfirmedTransactionResult + operationPerformed: 'replace' + } > => { + const atc = new AtomicTransactionComposer() + // Create Config.getLogger(appParams.suppressLog).info( `Deploying a new ${metadata.name} app for ${getSenderAddress(appParams.from)}; deploying app with version ${metadata.version}.`, ) - const { transaction: createTransaction } = await create(true) + const { transaction: createTransaction } = await create(atc) + const createTransactions = atc.clone().buildGroup() // Delete @@ -189,23 +210,15 @@ export async function deployApp( transactionParams: appParams.transactionParams, suppressLog: appParams.suppressLog, skipSending: true, + atc, }, algod, ) // Ensure create and delete happen atomically - const { confirmations } = await sendGroupOfTransactions( + const { transactions, confirmations, returns } = await sendAtomicTransactionComposer( { - transactions: [ - { - transaction: createTransaction, - signer: appParams.from, - }, - { - transaction: deleteTransaction, - signer: appParams.from, - }, - ], + atc, sendParams: { maxRoundsToWaitForConfirmation: appParams.maxRoundsToWaitForConfirmation, skipWaiting: false, @@ -216,9 +229,9 @@ export async function deployApp( ) // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const createConfirmation = confirmations![0] + const createConfirmation = confirmations![createTransactions.length - 1] // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const deleteConfirmation = confirmations![1] + const deleteConfirmation = confirmations![confirmations!.length - 1] // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const newAppIndex = createConfirmation['application-index']! @@ -230,8 +243,13 @@ export async function deployApp( return { transaction: createTransaction, + transactions: transactions, // eslint-disable-next-line @typescript-eslint/no-non-null-assertion confirmation: createConfirmation!, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + confirmations: confirmations!, + return: returns[0], + deleteReturn: returns[1], appId: newAppIndex, appAddress: getApplicationAddress(newAppIndex), createdMetadata: metadata, @@ -244,12 +262,12 @@ export async function deployApp( compiledApproval, compiledClear, } as Partial & - ConfirmedTransactionResult & + ConfirmedTransactionResults & AppMetadata & { deleteResult: ConfirmedTransactionResult; operationPerformed: 'replace' } } const update = async (): Promise< - Partial & ConfirmedTransactionResult & AppMetadata & { operationPerformed: 'update' } + Partial & ConfirmedTransactionResults & AppMetadata & { return?: ABIReturn; operationPerformed: 'update' } > => { Config.getLogger(appParams.suppressLog).info( `Updating existing ${metadata.name} app for ${getSenderAddress(appParams.from)} to version ${metadata.version}.`, @@ -273,8 +291,12 @@ export async function deployApp( return { transaction: result.transaction, + transactions: result.transactions, // eslint-disable-next-line @typescript-eslint/no-non-null-assertion confirmation: result.confirmation!, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + confirmations: result.confirmations!, + return: result.return, appId: existingApp.appId, appAddress: existingApp.appAddress, createdMetadata: existingApp.createdMetadata, diff --git a/src/transaction.ts b/src/transaction.ts index 02e3ebe5..95ec4096 100644 --- a/src/transaction.ts +++ b/src/transaction.ts @@ -3,7 +3,9 @@ import { Buffer } from 'buffer' import { Config } from './' import { PendingTransactionResponse } from './types/algod' import { AlgoAmount } from './types/amount' +import { ABIReturn } from './types/app' import { + AtomicTransactionComposerToSend, SendTransactionFrom, SendTransactionParams, SendTransactionResult, @@ -71,15 +73,15 @@ export const getSenderTransactionSigner = memoize(function (sender: SendTransact : algosdk.makeBasicAccountTransactionSigner(sender) }) -/** Signs and sends the given transaction to the chain +/** Prepares a transaction for sending and then (if instructed) signs and sends the given transaction to the chain. * - * @param send The details for the transaction to send, including: + * @param send The details for the transaction to prepare/send, including: * * `transaction`: The unsigned transaction * * `from`: The account to sign the transaction with: either an account with private key loaded or a logic signature account * * `config`: The sending configuration for this transaction * @param algod An algod client * - * @returns An object with transaction (`transaction`) and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`) + * @returns An object with transaction (`transaction`) and (if `skipWaiting` is `false` or `undefined`) confirmation (`confirmation`) */ export const sendTransaction = async function ( send: { @@ -92,14 +94,7 @@ export const sendTransaction = async function ( const { transaction, from, sendParams } = send const { skipSending, skipWaiting, fee, maxFee, suppressLog, maxRoundsToWaitForConfirmation, atc } = sendParams ?? {} - if (fee) { - transaction.fee = fee.microAlgos - transaction.flatFee = true - } - - if (maxFee !== undefined) { - capTransactionFee(transaction, maxFee) - } + controlFees(transaction, { fee, maxFee }) if (atc) { atc.addTransaction({ txn: transaction, signer: getSenderTransactionSigner(from) }) @@ -118,6 +113,7 @@ export const sendTransaction = async function ( : 'sign' in from ? from.sign(transaction) : (await from.signer([transaction], [0]))[0] + await algod.sendRawTransaction(signedTransaction).do() Config.getLogger(suppressLog).info(`Sent transaction ID ${transaction.txID()} ${transaction.type} from ${getSenderAddress(from)}`) @@ -130,6 +126,65 @@ export const sendTransaction = async function ( return { transaction, confirmation } } +/** + * Signs and sends transactions that have been collected by an @see AtomicTransactionComposer. + * @param atcSend The parameters controlling the send, including: + * * `atc` The @see AtomicTransactionComposer + * * `sendParams` The parameters to control the send behaviour + * @param algod An algod client + * @returns An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`) + */ +export const sendAtomicTransactionComposer = async function (atcSend: AtomicTransactionComposerToSend, algod: Algodv2) { + const { atc, sendParams } = atcSend + + const transactionsWithSigner = atc.buildGroup() + + const transactionsToSend = transactionsWithSigner.map((t) => { + return t.txn + }) + let groupId: string | undefined = undefined + if (transactionsToSend.length === 1) { + Config.getLogger(sendParams?.suppressLog).info(`Sending transaction ${transactionsToSend[0].txID()}`) + } else { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + groupId = transactionsToSend[0].group ? Buffer.from(transactionsToSend[0].group).toString('base64') : '' + Config.getLogger(sendParams?.suppressLog).info(`Sending group of ${transactionsToSend.length} transactions (${groupId})`, { + transactionsToSend, + }) + + Config.getLogger(sendParams?.suppressLog).debug( + `Transaction IDs (${groupId})`, + transactionsToSend.map((t) => t.txID()), + ) + } + + const result = await atc.execute(algod, sendParams?.maxRoundsToWaitForConfirmation ?? 5) + + Config.getLogger(sendParams?.suppressLog).info(`Group transaction (${groupId}) sent with ${transactionsToSend.length} transactions`) + + let confirmations: PendingTransactionResponse[] | undefined = undefined + if (!sendParams?.skipWaiting) { + confirmations = await Promise.all( + transactionsToSend.map(async (t) => (await algod.pendingTransactionInformation(t.txID()).do()) as PendingTransactionResponse), + ) + } + + return { + groupId, + confirmations, + txIds: transactionsToSend.map((t) => t.txID()), + transactions: transactionsToSend, + returns: result.methodResults.map( + (r) => + ({ + decodeError: r.decodeError, + returnValue: r.returnValue, + rawReturnValue: r.rawReturnValue, + } as ABIReturn), + ), + } +} + /** * Signs and sends a group of [up to 16](https://developer.algorand.org/docs/get-details/atomic_transfers/#create-transactions) transactions to the chain * @@ -137,7 +192,7 @@ export const sendTransaction = async function ( * * `transactions`: The array of transactions to send along with their signing account * * `sendParams`: The parameters to dictate how the group is sent * @param algod An algod client - * @returns An object with group transaction ID (`groupTransactionId`) and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`) + * @returns An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`) */ export const sendGroupOfTransactions = async function (groupSend: TransactionGroupToSend, algod: Algodv2) { const { transactions, signer, sendParams } = groupSend @@ -169,44 +224,8 @@ export const sendGroupOfTransactions = async function (groupSend: TransactionGro const atc = new AtomicTransactionComposer() transactionsWithSigner.forEach((txn) => atc.addTransaction(txn)) - const signedTransactions = await atc.gatherSignatures() - - const transactionsToSend = transactionsWithSigner.map((t) => { - return t.txn - }) - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const groupId = Buffer.from(transactionsToSend[0].group!).toString('base64') - Config.getLogger(sendParams?.suppressLog).info(`Sending group of ${transactionsToSend.length} transactions (${groupId})`, { - transactionsToSend, - }) - - Config.getLogger(sendParams?.suppressLog).debug( - `Sender Addresses (${groupId})`, - transactionsWithSigner.map((t) => getSenderAddress(t.sender)), - ) - - Config.getLogger(sendParams?.suppressLog).debug( - `Transaction IDs (${groupId})`, - transactionsToSend.map((t) => t.txID()), - ) - - // https://developer.algorand.org/docs/rest-apis/algod/v2/#post-v2transactions - await algod.sendRawTransaction(signedTransactions).do() - - Config.getLogger(sendParams?.suppressLog).info(`Group transaction (${groupId}) sent with ${transactionsToSend.length} transactions`) - let confirmations: PendingTransactionResponse[] | undefined = undefined - if (!sendParams?.skipWaiting) { - confirmations = await Promise.all( - transactionsToSend.map(async (t) => await waitForConfirmation(t.txID(), sendParams?.maxRoundsToWaitForConfirmation ?? 5, algod)), - ) - } - - return { - groupId, - confirmations, - txIds: transactionsToSend.map((t) => t.txID()), - } + return await sendAtomicTransactionComposer({ atc, sendParams }, algod) } /** @@ -264,10 +283,10 @@ export const waitForConfirmation = async function ( * Limit the acceptable fee to a defined amount of µALGOs. * This also sets the transaction to be flatFee to ensure the transaction only succeeds at * the estimated rate. - * @param transaction The transaction to cap + * @param transaction The transaction to cap or suggested params object about to be used to create a transaction * @param maxAcceptableFee The maximum acceptable fee to pay */ -export function capTransactionFee(transaction: algosdk.Transaction, maxAcceptableFee: AlgoAmount) { +export function capTransactionFee(transaction: algosdk.Transaction | SuggestedParams, maxAcceptableFee: AlgoAmount) { // If a flat fee hasn't already been defined if (!transaction.flatFee) { // Once a transaction has been constructed by algosdk, transaction.fee indicates what the total transaction fee @@ -285,6 +304,28 @@ export function capTransactionFee(transaction: algosdk.Transaction, maxAcceptabl } } +/** + * Allows for control of fees on a @see Transaction or @see SuggestedParams object + * @param transaction The transaction or suggested params + * @param feeControl The fee control parameters + */ +export function controlFees( + transaction: T, + feeControl: { fee?: AlgoAmount; maxFee?: AlgoAmount }, +) { + const { fee, maxFee } = feeControl + if (fee) { + transaction.fee = fee.microAlgos + transaction.flatFee = true + } + + if (maxFee !== undefined) { + capTransactionFee(transaction, maxFee) + } + + return transaction +} + /** * Returns suggested transaction parameters from algod unless some are already provided. * @param params Optionally provide parameters to use @@ -292,5 +333,18 @@ export function capTransactionFee(transaction: algosdk.Transaction, maxAcceptabl * @returns The suggested transaction parameters */ export async function getTransactionParams(params: SuggestedParams | undefined, algod: Algodv2) { - return params ?? (await algod.getTransactionParams().do()) + return params ? { ...params } : await algod.getTransactionParams().do() +} + +/** + * Returns the array of transactions currently present in the given @see AtomicTransactionComposer + * @param atc The atomic transaction composer + * @returns The array of transactions with signers + */ +export function getAtomicTransactionComposerTransactions(atc: AtomicTransactionComposer) { + try { + return atc.clone().buildGroup() + } catch { + return [] + } } diff --git a/src/types/app.ts b/src/types/app.ts index affc2fc0..02353519 100644 --- a/src/types/app.ts +++ b/src/types/app.ts @@ -1,4 +1,5 @@ import { ABIArgument, ABIMethod, ABIMethodParams, ABIType, ABIValue, Address, SourceMap, SuggestedParams, Transaction } from 'algosdk' +import { PendingTransactionResponse } from './algod' import { SendTransactionFrom, SendTransactionParams, SendTransactionResult, TransactionNote, TransactionToSign } from './transaction' /** The name of the TEAL template variable for deploy-time immutability control */ @@ -109,6 +110,7 @@ export interface UpdateAppParams extends CreateOrUpdateAppParams { appId: number } +/** Parameters representing a call to an app. */ export interface AppCallParams extends SendTransactionParams { /** The id of the app to call */ appId: number @@ -154,6 +156,10 @@ export interface CompiledTeal { /** Result from calling an app */ export interface AppCallTransactionResult extends SendTransactionResult { + /** All transactions sent as part of the app call (i.e. multiple if an ABI call is made which includes transaction arguments) */ + transactions: Transaction[] + /** The responses if the transactions are sent and waited for */ + confirmations?: PendingTransactionResponse[] /** If an ABI method was called the processed return value */ return?: ABIReturn } @@ -229,7 +235,7 @@ export enum OnSchemaBreak { } /** The parameters to deploy an app */ -export interface AppDeploymentParams extends Omit { +export interface AppDeploymentParams extends Omit { /** The deployment metadata */ metadata: AppDeployMetadata /** Any deploy-time parameters to replace in the TEAL code */ diff --git a/src/types/application-client.spec.ts b/src/types/application-client.spec.ts index f1da4a3f..00576d2a 100644 --- a/src/types/application-client.spec.ts +++ b/src/types/application-client.spec.ts @@ -1,5 +1,5 @@ import { describe, test } from '@jest/globals' -import algosdk, { ABIMethod, ABIStringType, ABIUintType, Account, Algodv2, getApplicationAddress, Indexer, TransactionType } from 'algosdk' +import algosdk, { ABIUintType, Account, Algodv2, getApplicationAddress, Indexer, OnApplicationComplete, TransactionType } from 'algosdk' import invariant from 'tiny-invariant' import * as algokit from '../' import { getTestingAppContract } from '../../tests/example-contracts/testing-app/contract' @@ -60,7 +60,7 @@ describe('application-client', () => { expect(app.confirmation?.['application-index']).toBe(app.appId) }) - test('Deploy app', async () => { + test('Deploy app - create', async () => { const { algod, indexer, testAccount } = localnet.context const client = algokit.getApplicationClient( @@ -86,6 +86,195 @@ describe('application-client', () => { expect(app.confirmation?.['application-index']).toBe(app.appId) }) + test('Deploy app - create (abi)', async () => { + const { algod, indexer, testAccount } = localnet.context + + const client = algokit.getApplicationClient( + { + app: appSpec, + sender: testAccount, + creatorAddress: testAccount.addr, + indexer, + }, + algod, + ) + + const app = await client.deploy({ + version: '1.0', + deployTimeParams: { + VALUE: 1, + }, + createArgs: { + method: 'create_abi', + methodArgs: ['arg_io'], + }, + }) + + invariant(app.operationPerformed === 'create') + expect(app.appId).toBeGreaterThan(0) + expect(app.appAddress).toBe(getApplicationAddress(app.appId)) + expect(app.confirmation?.['application-index']).toBe(app.appId) + expect(app.return?.returnValue).toBe('arg_io') + }) + + test('Deploy app - update', async () => { + const { algod, indexer, testAccount } = localnet.context + const client = algokit.getApplicationClient( + { + app: appSpec, + sender: testAccount, + creatorAddress: testAccount.addr, + indexer, + }, + algod, + ) + const createdApp = await client.deploy({ + version: '1.0', + deployTimeParams: { + VALUE: 1, + }, + allowUpdate: true, + }) + const app = await client.deploy({ + version: '1.0', + deployTimeParams: { + VALUE: 2, + }, + onUpdate: 'update', + }) + + invariant(app.operationPerformed === 'update') + expect(app.appId).toBe(createdApp.appId) + expect(app.appAddress).toBe(createdApp.appAddress) + invariant(app.confirmation) + expect(app.createdRound).toBe(createdApp.createdRound) + expect(app.updatedRound).not.toBe(app.createdRound) + expect(app.updatedRound).toBe(app.confirmation['confirmed-round']) + }) + + test('Deploy app - update (abi)', async () => { + const { algod, indexer, testAccount } = localnet.context + const client = algokit.getApplicationClient( + { + app: appSpec, + sender: testAccount, + creatorAddress: testAccount.addr, + indexer, + }, + algod, + ) + const createdApp = await client.deploy({ + version: '1.0', + deployTimeParams: { + VALUE: 1, + }, + allowUpdate: true, + }) + const app = await client.deploy({ + version: '1.0', + deployTimeParams: { + VALUE: 2, + }, + onUpdate: 'update', + updateArgs: { + method: 'update_abi', + methodArgs: ['arg_io'], + }, + }) + + invariant(app.operationPerformed === 'update') + expect(app.appId).toBe(createdApp.appId) + expect(app.appAddress).toBe(createdApp.appAddress) + invariant(app.confirmation) + expect(app.createdRound).toBe(createdApp.createdRound) + expect(app.updatedRound).not.toBe(app.createdRound) + expect(app.updatedRound).toBe(app.confirmation['confirmed-round']) + expect(app.transaction.appOnComplete).toBe(OnApplicationComplete.UpdateApplicationOC) + expect(app.return?.returnValue).toBe('arg_io') + }) + + test('Deploy app - replace', async () => { + const { algod, indexer, testAccount } = localnet.context + const client = algokit.getApplicationClient( + { + app: appSpec, + sender: testAccount, + creatorAddress: testAccount.addr, + indexer, + }, + algod, + ) + const createdApp = await client.deploy({ + version: '1.0', + deployTimeParams: { + VALUE: 1, + }, + allowDelete: true, + }) + const app = await client.deploy({ + version: '1.0', + deployTimeParams: { + VALUE: 2, + }, + onUpdate: 'replace', + }) + + invariant(app.operationPerformed === 'replace') + expect(app.appId).toBeGreaterThan(createdApp.appId) + expect(app.appAddress).toBe(algosdk.getApplicationAddress(app.appId)) + invariant(app.confirmation) + invariant(app.deleteResult) + invariant(app.deleteResult.confirmation) + expect(app.deleteResult.transaction.appIndex).toBe(createdApp.appId) + expect(app.deleteResult.transaction.appOnComplete).toBe(OnApplicationComplete.DeleteApplicationOC) + }) + + test('Deploy app - replace (abi)', async () => { + const { algod, indexer, testAccount } = localnet.context + const client = algokit.getApplicationClient( + { + app: appSpec, + sender: testAccount, + creatorAddress: testAccount.addr, + indexer, + }, + algod, + ) + const createdApp = await client.deploy({ + version: '1.0', + deployTimeParams: { + VALUE: 1, + }, + allowDelete: true, + }) + const app = await client.deploy({ + version: '1.0', + deployTimeParams: { + VALUE: 2, + }, + onUpdate: 'replace', + createArgs: { + method: 'create_abi', + methodArgs: ['arg_io'], + }, + deleteArgs: { + method: 'delete_abi', + methodArgs: ['arg2_io'], + }, + }) + + invariant(app.operationPerformed === 'replace') + expect(app.appId).toBeGreaterThan(createdApp.appId) + expect(app.appAddress).toBe(algosdk.getApplicationAddress(app.appId)) + invariant(app.confirmation) + invariant(app.deleteResult) + invariant(app.deleteResult.confirmation) + expect(app.deleteResult.transaction.appIndex).toBe(createdApp.appId) + expect(app.deleteResult.transaction.appOnComplete).toBe(OnApplicationComplete.DeleteApplicationOC) + expect(app.return?.returnValue).toBe('arg_io') + expect(app.deleteReturn?.returnValue).toBe('arg2_io') + }) + test('Create then call app', async () => { const { algod, testAccount } = localnet.context const client = algokit.getApplicationClient( @@ -114,6 +303,90 @@ describe('application-client', () => { expect(call.return.returnValue).toBe('Hello, test') }) + test('Create app with abi', async () => { + const { algod, testAccount } = localnet.context + const client = algokit.getApplicationClient( + { + app: appSpec, + sender: testAccount, + id: 0, + }, + algod, + ) + + const call = await client.create({ + deployTimeParams: { + UPDATABLE: 0, + DELETABLE: 0, + VALUE: 1, + }, + method: 'create_abi', + methodArgs: ['string_io'], + }) + + invariant(call.return) + expect(call.return.decodeError).toBeUndefined() + expect(call.return.returnValue).toBe('string_io') + }) + + test('Update app with abi', async () => { + const { algod, testAccount } = localnet.context + const client = algokit.getApplicationClient( + { + app: appSpec, + sender: testAccount, + id: 0, + }, + algod, + ) + const deployTimeParams = { + UPDATABLE: 1, + DELETABLE: 0, + VALUE: 1, + } + await client.create({ + deployTimeParams, + }) + + const call = await client.update({ + method: 'update_abi', + methodArgs: ['string_io'], + deployTimeParams, + }) + + invariant(call.return) + expect(call.return.decodeError).toBeUndefined() + expect(call.return.returnValue).toBe('string_io') + }) + + test('Delete app with abi', async () => { + const { algod, testAccount } = localnet.context + const client = algokit.getApplicationClient( + { + app: appSpec, + sender: testAccount, + id: 0, + }, + algod, + ) + await client.create({ + deployTimeParams: { + UPDATABLE: 0, + DELETABLE: 1, + VALUE: 1, + }, + }) + + const call = await client.delete({ + method: 'delete_abi', + methodArgs: ['string_io'], + }) + + invariant(call.return) + expect(call.return.decodeError).toBeUndefined() + expect(call.return.returnValue).toBe('string_io') + }) + test('Construct transaction with boxes', async () => { const { algod, indexer, testAccount } = localnet.context const { client } = await deploy(testAccount, algod, indexer) @@ -134,23 +407,24 @@ describe('application-client', () => { { from: testAccount, to: testAccount.addr, - amount: algokit.microAlgos(1), + amount: algokit.microAlgos(Math.ceil(Math.random() * 10000)), skipSending: true, }, algod, ) const { client } = await deploy(testAccount, algod, indexer) - const call = await client.call({ + const result = await client.call({ method: 'call_abi_txn', methodArgs: { args: [txn.transaction, 'test'] }, - sendParams: { skipSending: true }, }) + invariant(result.confirmations) + invariant(result.confirmations[1]) + expect(result.transactions.length).toBe(2) // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const methodSelector = new ABIMethod(client.getABIMethodParams('call_abi_txn')!).getSelector() - const methodArg = new ABIStringType().encode('test') - expect(call.transaction.appArgs).toEqual([methodSelector, methodArg]) + const returnValue = algokit.getABIReturn({ method: client.getABIMethod('call_abi_txn')!, args: [] }, result.confirmations[1]) + expect(returnValue?.returnValue).toBe(`Sent ${txn.transaction.amount}. test`) }) test('Display nice error messages when there is a logic error', async () => { @@ -164,18 +438,18 @@ describe('application-client', () => { }) invariant(false) } catch (e: any) { - expect(e.toString()).toMatchInlineSnapshot(`"Error: assert failed pc=607. at:315"`) + expect(e.toString()).toMatchInlineSnapshot(`"Error: assert failed pc=783. at:416"`) expect(e.stack).toMatchInlineSnapshot(` - " - // error - error_5: + "// error + error_6: proto 0 0 intc_0 // 0 + // Deliberate error assert <--- Error retsub // create - create_6:" + create_7:" `) } }) diff --git a/src/types/application-client.ts b/src/types/application-client.ts index c603de5c..01635af5 100644 --- a/src/types/application-client.ts +++ b/src/types/application-client.ts @@ -432,15 +432,15 @@ export class ApplicationClient { } async closeOut(call: AppClientCallParams) { - return await this._call(call, 'optin') + return await this._call(call, 'closeout') } async clearState(call: AppClientCallParams) { - return await this._call(call, 'optin') + return await this._call(call, 'clearstate') } async delete(call: AppClientCallParams) { - return await this._call(call, 'optin') + return await this._call(call, 'delete') } private async _call(call: AppClientCallParams, callType: 'optin' | 'closeout' | 'clearstate' | 'delete' | 'normal') { diff --git a/src/types/transaction.ts b/src/types/transaction.ts index 8a49066a..f136c494 100644 --- a/src/types/transaction.ts +++ b/src/types/transaction.ts @@ -21,12 +21,12 @@ export type Arc2TransactionNote = /** The sending configuration for a transaction */ export interface SendTransactionParams { - /** Whether to skip signing and sending the transaction to the chain (default: transaction signed and sent to chain) + /** 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) */ skipSending?: boolean /** Whether to skip waiting for the submitted transaction (only relevant if `skipSending` is `false` or unset) */ skipWaiting?: boolean - /** An optional @see AtomicTransactionComposer to add the transaction to, if specified then has the same effect as `skipSending: true` */ + /** An optional @see AtomicTransactionComposer to add the transaction to, if specified then `skipSending: undefined` has the same effect as `skipSending: true` */ atc?: AtomicTransactionComposer /** Whether to suppress log messages from transaction send, default: do not suppress */ suppressLog?: boolean @@ -48,8 +48,18 @@ export interface SendTransactionResult { /** The result of sending and confirming a transaction */ export interface ConfirmedTransactionResult extends SendTransactionResult { - /** The response if the transaction was sent and waited for */ + /** The response from sending and waiting for the transaction */ + confirmation: PendingTransactionResponse +} + +/** The result of sending and confirming one or more transactions, but where there is a primary transaction of interest */ +export interface ConfirmedTransactionResults extends SendTransactionResult { + /** The transactions */ + transactions: Transaction[] + /** The response from sending and waiting for the primary transaction */ confirmation: PendingTransactionResponse + /** The response from sending and waiting for the transactions */ + confirmations: PendingTransactionResponse[] } export type SendTransactionFrom = Account | SigningAccount | LogicSigAccount | MultisigAccount | TransactionSignerAccount @@ -67,7 +77,7 @@ export interface TransactionToSign { */ export interface TransactionGroupToSend { /** Any parameters to control the semantics of the send to the network */ - sendParams?: Omit + sendParams?: Omit /** The list of transactions to send, which can either be a raw transaction (in which case `signer` is required), * the async result of an AlgoKit utils method that returns a @see SendTransactionResult (saves unwrapping the promise, be sure to pass `skipSending: true`, `signer` is also required) * or the transaction with its signer (`signer` is ignored) @@ -76,3 +86,11 @@ export interface TransactionGroupToSend { /** Optional signer to pass in, required if at least one transaction provided is just the transaction, ignored otherwise */ signer?: SendTransactionFrom } + +/** An @see AtomicTransactionComposer with transactions to send. */ +export interface AtomicTransactionComposerToSend { + /** The @see AtomicTransactionComposer with transactions loaded to send */ + atc: AtomicTransactionComposer + /** Any parameters to control the semantics of the send to the network */ + sendParams?: Omit +} diff --git a/tests/example-contracts/testing-app/application.json b/tests/example-contracts/testing-app/application.json index 71360e7a..a086b09c 100644 --- a/tests/example-contracts/testing-app/application.json +++ b/tests/example-contracts/testing-app/application.json @@ -33,6 +33,21 @@ "no_op": "CALL" } }, + "create_abi(string)string": { + "call_config": { + "no_op": "CREATE" + } + }, + "update_abi(string)string": { + "call_config": { + "update_application": "CALL" + } + }, + "delete_abi(string)string": { + "call_config": { + "delete_application": "CALL" + } + }, "opt_in()void": { "call_config": { "opt_in": "CALL" @@ -40,7 +55,7 @@ } }, "source": { - "approval": "I3ByYWdtYSB2ZXJzaW9uIDgKaW50Y2Jsb2NrIDAgMQpieXRlY2Jsb2NrIDB4MTUxZjdjNzUgMHgKdHhuIE51bUFwcEFyZ3MKaW50Y18wIC8vIDAKPT0KYm56IG1haW5fbDE2CnR4bmEgQXBwbGljYXRpb25BcmdzIDAKcHVzaGJ5dGVzIDB4ZjE3ZTgwYTUgLy8gImNhbGxfYWJpKHN0cmluZylzdHJpbmciCj09CmJueiBtYWluX2wxNQp0eG5hIEFwcGxpY2F0aW9uQXJncyAwCnB1c2hieXRlcyAweDBhOTJhODFlIC8vICJjYWxsX2FiaV90eG4ocGF5LHN0cmluZylzdHJpbmciCj09CmJueiBtYWluX2wxNAp0eG5hIEFwcGxpY2F0aW9uQXJncyAwCnB1c2hieXRlcyAweGE0Y2Y4ZGVhIC8vICJzZXRfZ2xvYmFsKHVpbnQ2NCx1aW50NjQsc3RyaW5nLGJ5dGVbNF0pdm9pZCIKPT0KYm56IG1haW5fbDEzCnR4bmEgQXBwbGljYXRpb25BcmdzIDAKcHVzaGJ5dGVzIDB4Y2VjMjgzNGEgLy8gInNldF9sb2NhbCh1aW50NjQsdWludDY0LHN0cmluZyxieXRlWzRdKXZvaWQiCj09CmJueiBtYWluX2wxMgp0eG5hIEFwcGxpY2F0aW9uQXJncyAwCnB1c2hieXRlcyAweGE0YjRhMjMwIC8vICJzZXRfYm94KGJ5dGVbNF0sc3RyaW5nKXZvaWQiCj09CmJueiBtYWluX2wxMQp0eG5hIEFwcGxpY2F0aW9uQXJncyAwCnB1c2hieXRlcyAweDQ0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XNzZXJ0CmludGMgNSAvLyBUTVBMX0RFTEVUQUJMRQovLyBDaGVjayBhcHAgaXMgZGVsZXRhYmxlCmFzc2VydApyZXRzdWIKCi8vIGRlbGV0ZV9hYmkKZGVsZXRlYWJpXzEyOgpwcm90byAxIDEKYnl0ZWNfMCAvLyAiIgp0eG4gU2VuZGVyCmdsb2JhbCBDcmVhdG9yQWRkcmVzcwo9PQovLyB1bmF1dGhvcml6ZWQKYXNzZXJ0CmludGMgNSAvLyBUTVBMX0RFTEVUQUJMRQovLyBDaGVjayBhcHAgaXMgZGVsZXRhYmxlCmFzc2VydApmcmFtZV9kaWcgLTEKZXh0cmFjdCAyIDAKZnJhbWVfYnVyeSAwCmZyYW1lX2RpZyAwCmxlbgppdG9iCmV4dHJhY3QgNiAwCmZyYW1lX2RpZyAwCmNvbmNhdApmcmFtZV9idXJ5IDAKcmV0c3ViCgovLyBvcHRfaW4Kb3B0aW5fMTM6CnByb3RvIDAgMAppbnRjXzEgLy8gMQpyZXR1cm4=", "clear": "I3ByYWdtYSB2ZXJzaW9uIDgKcHVzaGludCAwIC8vIDAKcmV0dXJu" }, "state": { @@ -212,6 +227,42 @@ "type": "void" } }, + { + "name": "create_abi", + "args": [ + { + "type": "string", + "name": "input" + } + ], + "returns": { + "type": "string" + } + }, + { + "name": "update_abi", + "args": [ + { + "type": "string", + "name": "input" + } + ], + "returns": { + "type": "string" + } + }, + { + "name": "delete_abi", + "args": [ + { + "type": "string", + "name": "input" + } + ], + "returns": { + "type": "string" + } + }, { "name": "opt_in", "args": [], diff --git a/tests/example-contracts/testing-app/approval.teal b/tests/example-contracts/testing-app/approval.teal index c489c9bb..b88a31fa 100644 --- a/tests/example-contracts/testing-app/approval.teal +++ b/tests/example-contracts/testing-app/approval.teal @@ -1,40 +1,52 @@ #pragma version 8 -intcblock 0 1 -bytecblock 0x151f7c75 0x +intcblock 0 1 10 5 TMPL_UPDATABLE TMPL_DELETABLE +bytecblock 0x 0x151f7c75 txn NumAppArgs intc_0 // 0 == -bnz main_l16 +bnz main_l22 txna ApplicationArgs 0 pushbytes 0xf17e80a5 // "call_abi(string)string" == -bnz main_l15 +bnz main_l21 txna ApplicationArgs 0 pushbytes 0x0a92a81e // "call_abi_txn(pay,string)string" == -bnz main_l14 +bnz main_l20 txna ApplicationArgs 0 pushbytes 0xa4cf8dea // "set_global(uint64,uint64,string,byte[4])void" == -bnz main_l13 +bnz main_l19 txna ApplicationArgs 0 pushbytes 0xcec2834a // "set_local(uint64,uint64,string,byte[4])void" == -bnz main_l12 +bnz main_l18 txna ApplicationArgs 0 pushbytes 0xa4b4a230 // "set_box(byte[4],string)void" == -bnz main_l11 +bnz main_l17 txna ApplicationArgs 0 pushbytes 0x44d0da0d // "error()void" == -bnz main_l10 +bnz main_l16 +txna ApplicationArgs 0 +pushbytes 0x9d523040 // "create_abi(string)string" +== +bnz main_l15 +txna ApplicationArgs 0 +pushbytes 0x3ca5ceb7 // "update_abi(string)string" +== +bnz main_l14 +txna ApplicationArgs 0 +pushbytes 0x271b4ee9 // "delete_abi(string)string" +== +bnz main_l13 txna ApplicationArgs 0 pushbytes 0x30c6d58a // "opt_in()void" == -bnz main_l9 +bnz main_l12 err -main_l9: +main_l12: txn OnCompletion intc_1 // OptIn == @@ -43,10 +55,64 @@ intc_0 // 0 != && assert -callsub optin_9 +callsub optin_13 +intc_1 // 1 +return +main_l13: +txn OnCompletion +intc_3 // DeleteApplication +== +txn ApplicationID +intc_0 // 0 +!= +&& +assert +txna ApplicationArgs 1 +callsub deleteabi_12 +store 16 +bytec_1 // 0x151f7c75 +load 16 +concat +log +intc_1 // 1 +return +main_l14: +txn OnCompletion +pushint 4 // UpdateApplication +== +txn ApplicationID +intc_0 // 0 +!= +&& +assert +txna ApplicationArgs 1 +callsub updateabi_10 +store 15 +bytec_1 // 0x151f7c75 +load 15 +concat +log intc_1 // 1 return -main_l10: +main_l15: +txn OnCompletion +intc_0 // NoOp +== +txn ApplicationID +intc_0 // 0 +== +&& +assert +txna ApplicationArgs 1 +callsub createabi_8 +store 14 +bytec_1 // 0x151f7c75 +load 14 +concat +log +intc_1 // 1 +return +main_l16: txn OnCompletion intc_0 // NoOp == @@ -55,10 +121,10 @@ intc_0 // 0 != && assert -callsub error_5 +callsub error_6 intc_1 // 1 return -main_l11: +main_l17: txn OnCompletion intc_0 // NoOp == @@ -73,10 +139,10 @@ txna ApplicationArgs 2 store 13 load 12 load 13 -callsub setbox_4 +callsub setbox_5 intc_1 // 1 return -main_l12: +main_l18: txn OnCompletion intc_0 // NoOp == @@ -99,10 +165,10 @@ load 8 load 9 load 10 load 11 -callsub setlocal_3 +callsub setlocal_4 intc_1 // 1 return -main_l13: +main_l19: txn OnCompletion intc_0 // NoOp == @@ -125,10 +191,10 @@ load 4 load 5 load 6 load 7 -callsub setglobal_2 +callsub setglobal_3 intc_1 // 1 return -main_l14: +main_l20: txn OnCompletion intc_0 // NoOp == @@ -150,15 +216,15 @@ intc_1 // pay assert load 1 load 2 -callsub callabitxn_1 +callsub callabitxn_2 store 3 -bytec_0 // 0x151f7c75 +bytec_1 // 0x151f7c75 load 3 concat log intc_1 // 1 return -main_l15: +main_l21: txn OnCompletion intc_0 // NoOp == @@ -170,55 +236,55 @@ assert txna ApplicationArgs 1 callsub callabi_0 store 0 -bytec_0 // 0x151f7c75 +bytec_1 // 0x151f7c75 load 0 concat log intc_1 // 1 return -main_l16: +main_l22: txn OnCompletion intc_0 // NoOp == -bnz main_l22 +bnz main_l28 txn OnCompletion pushint 4 // UpdateApplication == -bnz main_l21 +bnz main_l27 txn OnCompletion -pushint 5 // DeleteApplication +intc_3 // DeleteApplication == -bnz main_l20 +bnz main_l26 err -main_l20: +main_l26: txn ApplicationID intc_0 // 0 != assert -callsub delete_8 +callsub delete_11 intc_1 // 1 return -main_l21: +main_l27: txn ApplicationID intc_0 // 0 != assert -callsub update_7 +callsub update_9 intc_1 // 1 return -main_l22: +main_l28: txn ApplicationID intc_0 // 0 == assert -callsub create_6 +callsub create_7 intc_1 // 1 return // call_abi callabi_0: proto 1 1 -bytec_1 // "" +bytec_0 // "" pushbytes 0x48656c6c6f2c20 // "Hello, " frame_dig -1 extract 2 0 @@ -233,14 +299,48 @@ concat frame_bury 0 retsub +// itoa +itoa_1: +proto 1 1 +frame_dig -1 +intc_0 // 0 +== +bnz itoa_1_l5 +frame_dig -1 +intc_2 // 10 +/ +intc_0 // 0 +> +bnz itoa_1_l4 +bytec_0 // "" +itoa_1_l3: +pushbytes 0x30313233343536373839 // "0123456789" +frame_dig -1 +intc_2 // 10 +% +intc_1 // 1 +extract3 +concat +b itoa_1_l6 +itoa_1_l4: +frame_dig -1 +intc_2 // 10 +/ +callsub itoa_1 +b itoa_1_l3 +itoa_1_l5: +pushbytes 0x30 // "0" +itoa_1_l6: +retsub + // call_abi_txn -callabitxn_1: +callabitxn_2: proto 2 1 -bytec_1 // "" +bytec_0 // "" pushbytes 0x53656e7420 // "Sent " frame_dig -2 gtxns Amount -itob +callsub itoa_1 concat pushbytes 0x2e20 // ". " concat @@ -258,7 +358,7 @@ frame_bury 0 retsub // set_global -setglobal_2: +setglobal_3: proto 4 0 pushbytes 0x696e7431 // "int1" frame_dig -4 @@ -276,7 +376,7 @@ app_global_put retsub // set_local -setlocal_3: +setlocal_4: proto 4 0 txn Sender pushbytes 0x6c6f63616c5f696e7431 // "local_int1" @@ -298,7 +398,7 @@ app_local_put retsub // set_box -setbox_4: +setbox_5: proto 2 0 frame_dig -2 box_del @@ -310,14 +410,15 @@ box_put retsub // error -error_5: +error_6: proto 0 0 intc_0 // 0 +// Deliberate error assert retsub // create -create_6: +create_7: proto 0 0 txn Sender global CreatorAddress @@ -329,34 +430,103 @@ pushint TMPL_VALUE // TMPL_VALUE app_global_put retsub +// create_abi +createabi_8: +proto 1 1 +bytec_0 // "" +txn Sender +global CreatorAddress +== +// unauthorized +assert +frame_dig -1 +extract 2 0 +frame_bury 0 +frame_dig 0 +len +itob +extract 6 0 +frame_dig 0 +concat +frame_bury 0 +retsub + // update -update_7: +update_9: proto 0 0 txn Sender global CreatorAddress == // unauthorized assert -pushint TMPL_UPDATABLE // TMPL_UPDATABLE +intc 4 // TMPL_UPDATABLE // Check app is updatable assert retsub +// update_abi +updateabi_10: +proto 1 1 +bytec_0 // "" +txn Sender +global CreatorAddress +== +// unauthorized +assert +intc 4 // TMPL_UPDATABLE +// Check app is updatable +assert +frame_dig -1 +extract 2 0 +frame_bury 0 +frame_dig 0 +len +itob +extract 6 0 +frame_dig 0 +concat +frame_bury 0 +retsub + // delete -delete_8: +delete_11: proto 0 0 txn Sender global CreatorAddress == // unauthorized assert -pushint TMPL_DELETABLE // TMPL_DELETABLE +intc 5 // TMPL_DELETABLE +// Check app is deletable +assert +retsub + +// delete_abi +deleteabi_12: +proto 1 1 +bytec_0 // "" +txn Sender +global CreatorAddress +== +// unauthorized +assert +intc 5 // TMPL_DELETABLE // Check app is deletable assert +frame_dig -1 +extract 2 0 +frame_bury 0 +frame_dig 0 +len +itob +extract 6 0 +frame_dig 0 +concat +frame_bury 0 retsub // opt_in -optin_9: +optin_13: proto 0 0 intc_1 // 1 return \ No newline at end of file diff --git a/tests/example-contracts/testing-app/contract.json b/tests/example-contracts/testing-app/contract.json index 02f90baf..9499cc5a 100644 --- a/tests/example-contracts/testing-app/contract.json +++ b/tests/example-contracts/testing-app/contract.json @@ -100,6 +100,42 @@ "type": "void" } }, + { + "name": "create_abi", + "args": [ + { + "type": "string", + "name": "input" + } + ], + "returns": { + "type": "string" + } + }, + { + "name": "update_abi", + "args": [ + { + "type": "string", + "name": "input" + } + ], + "returns": { + "type": "string" + } + }, + { + "name": "delete_abi", + "args": [ + { + "type": "string", + "name": "input" + } + ], + "returns": { + "type": "string" + } + }, { "name": "opt_in", "args": [], diff --git a/tests/example-contracts/testing-app/contract.py b/tests/example-contracts/testing-app/contract.py new file mode 100644 index 00000000..b4ecfa5d --- /dev/null +++ b/tests/example-contracts/testing-app/contract.py @@ -0,0 +1,127 @@ +import beaker +from beaker.lib.storage import BoxMapping +import pyteal as pt +from typing import Literal + +UPDATABLE_TEMPLATE_NAME = "TMPL_UPDATABLE" +DELETABLE_TEMPLATE_NAME = "TMPL_DELETABLE" + + +class BareCallAppState: + value = beaker.GlobalStateValue(stack_type=pt.TealType.uint64) + bytes1 = beaker.GlobalStateValue(stack_type=pt.TealType.bytes) + bytes2 = beaker.GlobalStateValue(stack_type=pt.TealType.bytes) + int1 = beaker.GlobalStateValue(stack_type=pt.TealType.uint64) + int2 = beaker.GlobalStateValue(stack_type=pt.TealType.uint64) + local_bytes1 = beaker.LocalStateValue(stack_type=pt.TealType.bytes) + local_bytes2 = beaker.LocalStateValue(stack_type=pt.TealType.bytes) + local_int1 = beaker.LocalStateValue(stack_type=pt.TealType.uint64) + local_int2 = beaker.LocalStateValue(stack_type=pt.TealType.uint64) + box = BoxMapping(pt.abi.StaticBytes[Literal[4]], pt.abi.String) + + +app = beaker.Application("TestingApp", state=BareCallAppState) + + +@app.external(read_only=True) +def call_abi(value: pt.abi.String, *, output: pt.abi.String) -> pt.Expr: + return output.set(pt.Concat(pt.Bytes("Hello, "), value.get())) + + +# https://github.com/algorand/pyteal-utils/blob/main/pytealutils/strings/string.py#L63 +@pt.Subroutine(pt.TealType.bytes) +def itoa(i: pt.Expr) -> pt.Expr: + """itoa converts an integer to the ascii byte string it represents""" + return pt.If( + i == pt.Int(0), + pt.Bytes("0"), + pt.Concat( + pt.If(i / pt.Int(10) > pt.Int(0), itoa(i / pt.Int(10)), pt.Bytes("")), + pt.Extract(pt.Bytes("0123456789"), i % pt.Int(10), pt.Int(1)), + ), + ) + + +@app.external(read_only=True) +def call_abi_txn(txn: pt.abi.PaymentTransaction, value: pt.abi.String, *, output: pt.abi.String) -> pt.Expr: + return output.set( + pt.Concat( + pt.Bytes("Sent "), + itoa(txn.get().amount()), + pt.Bytes(". "), + value.get(), + ) + ) + + +@app.external() +def set_global( + int1: pt.abi.Uint64, int2: pt.abi.Uint64, bytes1: pt.abi.String, bytes2: pt.abi.StaticBytes[Literal[4]] +) -> pt.Expr: + return pt.Seq( + app.state.int1.set(int1.get()), + app.state.int2.set(int2.get()), + app.state.bytes1.set(bytes1.get()), + app.state.bytes2.set(bytes2.get()), + ) + + +@app.external() +def set_local( + int1: pt.abi.Uint64, int2: pt.abi.Uint64, bytes1: pt.abi.String, bytes2: pt.abi.StaticBytes[Literal[4]] +) -> pt.Expr: + return pt.Seq( + app.state.local_int1.set(int1.get()), + app.state.local_int2.set(int2.get()), + app.state.local_bytes1.set(bytes1.get()), + app.state.local_bytes2.set(bytes2.get()), + ) + + +@app.external() +def set_box(name: pt.abi.StaticBytes[Literal[4]], value: pt.abi.String) -> pt.Expr: + return app.state.box[name.get()].set(value.get()) + + +@app.external(read_only=True) +def error() -> pt.Expr: + return pt.Assert(pt.Int(0), comment="Deliberate error") + + +@app.create(authorize=beaker.Authorize.only_creator(), bare=True) +def create() -> pt.Expr: + return app.state.value.set(pt.Tmpl.Int("TMPL_VALUE")) + + +@app.create(authorize=beaker.Authorize.only_creator()) +def create_abi(input: pt.abi.String, *, output: pt.abi.String) -> pt.Expr: + return output.set(input.get()) + + +@app.update(authorize=beaker.Authorize.only_creator(), bare=True) +def update() -> pt.Expr: + return pt.Assert(pt.Tmpl.Int(UPDATABLE_TEMPLATE_NAME), comment="Check app is updatable") + + +@app.update(authorize=beaker.Authorize.only_creator()) +def update_abi(input: pt.abi.String, *, output: pt.abi.String) -> pt.Expr: + return pt.Seq( + pt.Assert(pt.Tmpl.Int(UPDATABLE_TEMPLATE_NAME), comment="Check app is updatable"), output.set(input.get()) + ) + + +@app.delete(authorize=beaker.Authorize.only_creator(), bare=True) +def delete() -> pt.Expr: + return pt.Assert(pt.Tmpl.Int(DELETABLE_TEMPLATE_NAME), comment="Check app is deletable") + + +@app.delete(authorize=beaker.Authorize.only_creator()) +def delete_abi(input: pt.abi.String, *, output: pt.abi.String) -> pt.Expr: + return pt.Seq( + pt.Assert(pt.Tmpl.Int(DELETABLE_TEMPLATE_NAME), comment="Check app is deletable"), output.set(input.get()) + ) + + +@app.opt_in +def opt_in() -> pt.Expr: + return pt.Approve() From d74779931248d5b03f7824572b80f5646b3741d3 Mon Sep 17 00:00:00 2001 From: Rob Moore Date: Thu, 6 Apr 2023 11:25:01 +0800 Subject: [PATCH 5/5] docs: Updated docs with latest changes --- .../classes/types_account.MultisigAccount.md | 36 ++- .../classes/types_account.SigningAccount.md | 31 ++- ...es_application_client.ApplicationClient.md | 4 +- docs/code/enums/types_app.OnSchemaBreak.md | 4 +- docs/code/enums/types_app.OnUpdate.md | 6 +- .../types_account.TransactionSignerAccount.md | 4 +- .../interfaces/types_app.ABIAppCallArgs.md | 8 +- .../interfaces/types_app.AppCallParams.md | 45 +++- .../types_app.AppCallTransactionResult.md | 32 ++- .../types_app.AppCompilationResult.md | 4 +- .../interfaces/types_app.AppDeployMetadata.md | 8 +- .../types_app.AppDeploymentParams.md | 36 +-- docs/code/interfaces/types_app.AppLookup.md | 4 +- docs/code/interfaces/types_app.AppMetadata.md | 20 +- .../code/interfaces/types_app.AppReference.md | 4 +- .../interfaces/types_app.AppStorageSchema.md | 10 +- docs/code/interfaces/types_app.BoxName.md | 6 +- .../code/interfaces/types_app.BoxReference.md | 4 +- .../types_app.BoxValueRequestParams.md | 6 +- .../types_app.BoxValuesRequestParams.md | 6 +- .../code/interfaces/types_app.CompiledTeal.md | 10 +- .../interfaces/types_app.CreateAppParams.md | 45 +++- .../interfaces/types_app.RawAppCallArgs.md | 12 +- .../interfaces/types_app.UpdateAppParams.md | 45 +++- ...saction.AtomicTransactionComposerToSend.md | 46 ++++ ..._transaction.ConfirmedTransactionResult.md | 6 +- ...transaction.ConfirmedTransactionResults.md | 78 ++++++ ...types_transaction.SendTransactionParams.md | 27 +- ...types_transaction.SendTransactionResult.md | 6 +- ...ypes_transaction.TransactionGroupToSend.md | 12 +- .../types_transaction.TransactionToSign.md | 4 +- .../types_transfer.AlgoTransferParams.md | 31 ++- .../types_transfer.EnsureFundedParams.md | 31 ++- docs/code/modules/index.md | 248 +++++++++++++++--- docs/code/modules/types_app.md | 16 +- docs/code/modules/types_transaction.md | 4 +- 36 files changed, 689 insertions(+), 210 deletions(-) create mode 100644 docs/code/interfaces/types_transaction.AtomicTransactionComposerToSend.md create mode 100644 docs/code/interfaces/types_transaction.ConfirmedTransactionResults.md diff --git a/docs/code/classes/types_account.MultisigAccount.md b/docs/code/classes/types_account.MultisigAccount.md index 06415aeb..4e8ba62c 100644 --- a/docs/code/classes/types_account.MultisigAccount.md +++ b/docs/code/classes/types_account.MultisigAccount.md @@ -16,12 +16,14 @@ Account wrapper that supports partial or full multisig signing. - [\_addr](types_account.MultisigAccount.md#_addr) - [\_params](types_account.MultisigAccount.md#_params) +- [\_signer](types_account.MultisigAccount.md#_signer) - [\_signingAccounts](types_account.MultisigAccount.md#_signingaccounts) ### Accessors - [addr](types_account.MultisigAccount.md#addr) - [params](types_account.MultisigAccount.md#params) +- [signer](types_account.MultisigAccount.md#signer) - [signingAccounts](types_account.MultisigAccount.md#signingaccounts) ### Methods @@ -43,7 +45,7 @@ Account wrapper that supports partial or full multisig signing. #### Defined in -[src/types/account.ts:29](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L29) +[src/types/account.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L34) ## Properties @@ -67,6 +69,16 @@ ___ ___ +### \_signer + +• **\_signer**: `TransactionSigner` + +#### Defined in + +[src/types/account.ts:13](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L13) + +___ + ### \_signingAccounts • **\_signingAccounts**: (`default` \| [`SigningAccount`](types_account.SigningAccount.md))[] @@ -89,7 +101,7 @@ The address of the multisig account #### Defined in -[src/types/account.ts:25](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L25) +[src/types/account.ts:26](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L26) ___ @@ -105,7 +117,21 @@ The parameters for the multisig account #### Defined in -[src/types/account.ts:15](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L15) +[src/types/account.ts:16](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L16) + +___ + +### signer + +• `get` **signer**(): `TransactionSigner` + +#### Returns + +`TransactionSigner` + +#### Defined in + +[src/types/account.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L30) ___ @@ -121,7 +147,7 @@ readonly (`default` \| [`SigningAccount`](types_account.SigningAccount.md))[] #### Defined in -[src/types/account.ts:20](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L20) +[src/types/account.ts:21](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L21) ## Methods @@ -145,4 +171,4 @@ The transaction signed by the present signers #### Defined in -[src/types/account.ts:40](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L40) +[src/types/account.ts:49](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L49) diff --git a/docs/code/classes/types_account.SigningAccount.md b/docs/code/classes/types_account.SigningAccount.md index bc0776c8..13f90552 100644 --- a/docs/code/classes/types_account.SigningAccount.md +++ b/docs/code/classes/types_account.SigningAccount.md @@ -20,6 +20,7 @@ Account wrapper that supports a rekeyed account - [\_account](types_account.SigningAccount.md#_account) - [\_sender](types_account.SigningAccount.md#_sender) +- [\_signer](types_account.SigningAccount.md#_signer) ### Accessors @@ -43,7 +44,7 @@ Account wrapper that supports a rekeyed account #### Defined in -[src/types/account.ts:90](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L90) +[src/types/account.ts:100](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L100) ## Properties @@ -53,7 +54,7 @@ Account wrapper that supports a rekeyed account #### Defined in -[src/types/account.ts:56](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L56) +[src/types/account.ts:65](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L65) ___ @@ -63,7 +64,17 @@ ___ #### Defined in -[src/types/account.ts:57](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L57) +[src/types/account.ts:67](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L67) + +___ + +### \_signer + +• `Private` **\_signer**: `TransactionSigner` + +#### Defined in + +[src/types/account.ts:66](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L66) ## Accessors @@ -83,7 +94,7 @@ Account.addr #### Defined in -[src/types/account.ts:62](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L62) +[src/types/account.ts:72](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L72) ___ @@ -99,23 +110,23 @@ Algorand account of the sender address and signer private key #### Defined in -[src/types/account.ts:83](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L83) +[src/types/account.ts:93](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L93) ___ ### signer -• `get` **signer**(): `default` +• `get` **signer**(): `TransactionSigner` -Algorand account of the underlying signing account +Transaction signer for the underlying signing account #### Returns -`default` +`TransactionSigner` #### Defined in -[src/types/account.ts:76](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L76) +[src/types/account.ts:86](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L86) ___ @@ -135,4 +146,4 @@ Account.sk #### Defined in -[src/types/account.ts:69](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L69) +[src/types/account.ts:79](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L79) diff --git a/docs/code/classes/types_application_client.ApplicationClient.md b/docs/code/classes/types_application_client.ApplicationClient.md index 2d228ebb..72f4d418 100644 --- a/docs/code/classes/types_application_client.ApplicationClient.md +++ b/docs/code/classes/types_application_client.ApplicationClient.md @@ -314,7 +314,7 @@ ___ ### deploy -▸ **deploy**(`deploy?`): `Promise`<`Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"update"`` \| ``"create"`` } \| `Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `deleteResult`: [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) ; `operationPerformed`: ``"replace"`` } \| `Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"nothing"`` }\> +▸ **deploy**(`deploy?`): `Promise`<`Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`ConfirmedTransactionResults`](../interfaces/types_transaction.ConfirmedTransactionResults.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"update"`` \| ``"create"`` ; `return?`: [`ABIReturn`](../modules/types_app.md#abireturn) } \| `Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`ConfirmedTransactionResults`](../interfaces/types_transaction.ConfirmedTransactionResults.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `deleteResult`: [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) ; `deleteReturn?`: [`ABIReturn`](../modules/types_app.md#abireturn) ; `operationPerformed`: ``"replace"`` ; `return?`: [`ABIReturn`](../modules/types_app.md#abireturn) } \| `Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"nothing"`` }\> Idempotently deploy (create, update/delete if changed) an app against the given name via the given creator account, including deploy-time template placeholder substitutions. @@ -336,7 +336,7 @@ https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-de #### Returns -`Promise`<`Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"update"`` \| ``"create"`` } \| `Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `deleteResult`: [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) ; `operationPerformed`: ``"replace"`` } \| `Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"nothing"`` }\> +`Promise`<`Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`ConfirmedTransactionResults`](../interfaces/types_transaction.ConfirmedTransactionResults.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"update"`` \| ``"create"`` ; `return?`: [`ABIReturn`](../modules/types_app.md#abireturn) } \| `Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`ConfirmedTransactionResults`](../interfaces/types_transaction.ConfirmedTransactionResults.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `deleteResult`: [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) ; `deleteReturn?`: [`ABIReturn`](../modules/types_app.md#abireturn) ; `operationPerformed`: ``"replace"`` ; `return?`: [`ABIReturn`](../modules/types_app.md#abireturn) } \| `Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"nothing"`` }\> The metadata and transaction result(s) of the deployment, or just the metadata if it didn't need to issue transactions diff --git a/docs/code/enums/types_app.OnSchemaBreak.md b/docs/code/enums/types_app.OnSchemaBreak.md index 3555297e..62c009a3 100644 --- a/docs/code/enums/types_app.OnSchemaBreak.md +++ b/docs/code/enums/types_app.OnSchemaBreak.md @@ -23,7 +23,7 @@ Fail the deployment #### 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:232](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L232) ___ @@ -35,4 +35,4 @@ Delete the app and create a new one in its place #### 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:234](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L234) diff --git a/docs/code/enums/types_app.OnUpdate.md b/docs/code/enums/types_app.OnUpdate.md index 91a67b8b..c1e5dbb0 100644 --- a/docs/code/enums/types_app.OnUpdate.md +++ b/docs/code/enums/types_app.OnUpdate.md @@ -24,7 +24,7 @@ Fail the deployment #### Defined in -[src/types/app.ts:216](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L216) +[src/types/app.ts:222](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L222) ___ @@ -36,7 +36,7 @@ Delete the app and create a new one in its place #### Defined in -[src/types/app.ts:220](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L220) +[src/types/app.ts:226](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L226) ___ @@ -48,4 +48,4 @@ Update the app #### Defined in -[src/types/app.ts:218](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L218) +[src/types/app.ts:224](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L224) diff --git a/docs/code/interfaces/types_account.TransactionSignerAccount.md b/docs/code/interfaces/types_account.TransactionSignerAccount.md index 276aa098..cfc67c60 100644 --- a/docs/code/interfaces/types_account.TransactionSignerAccount.md +++ b/docs/code/interfaces/types_account.TransactionSignerAccount.md @@ -25,7 +25,7 @@ that also has the sender address. #### Defined in -[src/types/account.ts:98](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L98) +[src/types/account.ts:109](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L109) ___ @@ -35,4 +35,4 @@ ___ #### Defined in -[src/types/account.ts:99](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L99) +[src/types/account.ts:110](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/account.ts#L110) diff --git a/docs/code/interfaces/types_app.ABIAppCallArgs.md b/docs/code/interfaces/types_app.ABIAppCallArgs.md index aa8f942e..f5fd8378 100644 --- a/docs/code/interfaces/types_app.ABIAppCallArgs.md +++ b/docs/code/interfaces/types_app.ABIAppCallArgs.md @@ -25,7 +25,7 @@ The ABI args to pass in #### Defined in -[src/types/app.ts:71](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L71) +[src/types/app.ts:72](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L72) ___ @@ -37,7 +37,7 @@ Any box references to load either as the box name (if for the current app) or th #### Defined in -[src/types/app.ts:75](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L75) +[src/types/app.ts:76](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L76) ___ @@ -49,7 +49,7 @@ The optional lease for the transaction #### Defined in -[src/types/app.ts:73](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L73) +[src/types/app.ts:74](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L74) ___ @@ -63,4 +63,4 @@ The ABI method to call, either: #### Defined in -[src/types/app.ts:69](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L69) +[src/types/app.ts:70](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L70) diff --git a/docs/code/interfaces/types_app.AppCallParams.md b/docs/code/interfaces/types_app.AppCallParams.md index f0c47cdf..c8b9d653 100644 --- a/docs/code/interfaces/types_app.AppCallParams.md +++ b/docs/code/interfaces/types_app.AppCallParams.md @@ -4,7 +4,7 @@ [types/app](../modules/types_app.md).AppCallParams -The sending configuration for a transaction +Parameters representing a call to an app. ## Hierarchy @@ -18,6 +18,7 @@ The sending configuration for a transaction - [appId](types_app.AppCallParams.md#appid) - [args](types_app.AppCallParams.md#args) +- [atc](types_app.AppCallParams.md#atc) - [callType](types_app.AppCallParams.md#calltype) - [fee](types_app.AppCallParams.md#fee) - [from](types_app.AppCallParams.md#from) @@ -39,7 +40,7 @@ The id of the app to call #### 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:116](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L116) ___ @@ -51,7 +52,27 @@ The arguments passed in to the app call #### Defined in -[src/types/app.ts:124](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L124) +[src/types/app.ts:126](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L126) + +___ + +### atc + +• `Optional` **atc**: `AtomicTransactionComposer` + +An optional + +**`See`** + +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) ___ @@ -63,7 +84,7 @@ The type of call, everything except create (@see createApp ) and update (@see up #### Defined in -[src/types/app.ts:116](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L116) +[src/types/app.ts:118](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L118) ___ @@ -79,7 +100,7 @@ The flat fee you want to pay, useful for covering extra fees in a transaction gr #### Defined in -[src/types/transaction.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L32) +[src/types/transaction.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L34) ___ @@ -91,7 +112,7 @@ The account to make the call from #### Defined in -[src/types/app.ts:118](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L118) +[src/types/app.ts:120](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L120) ___ @@ -107,7 +128,7 @@ The maximum fee that you are happy to pay (default: unbounded) - if this is set #### Defined in -[src/types/transaction.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L34) +[src/types/transaction.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L36) ___ @@ -123,7 +144,7 @@ The maximum number of rounds to wait for confirmation, only applies if `skipWait #### Defined in -[src/types/transaction.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L36) +[src/types/transaction.ts:38](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L38) ___ @@ -135,7 +156,7 @@ The (optional) transaction note #### Defined in -[src/types/app.ts:122](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L122) +[src/types/app.ts:124](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L124) ___ @@ -143,7 +164,7 @@ ___ • `Optional` **skipSending**: `boolean` -Whether to skip signing and sending the transaction to the chain (default: transaction signed and sent to chain) +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 @@ -184,7 +205,7 @@ Whether to suppress log messages from transaction send, default: do not suppress #### Defined in -[src/types/transaction.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L30) +[src/types/transaction.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L32) ___ @@ -196,4 +217,4 @@ Optional transaction parameters #### Defined in -[src/types/app.ts:120](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L120) +[src/types/app.ts:122](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L122) diff --git a/docs/code/interfaces/types_app.AppCallTransactionResult.md b/docs/code/interfaces/types_app.AppCallTransactionResult.md index 889ecd68..2b6a3867 100644 --- a/docs/code/interfaces/types_app.AppCallTransactionResult.md +++ b/docs/code/interfaces/types_app.AppCallTransactionResult.md @@ -17,8 +17,10 @@ Result from calling an app ### Properties - [confirmation](types_app.AppCallTransactionResult.md#confirmation) +- [confirmations](types_app.AppCallTransactionResult.md#confirmations) - [return](types_app.AppCallTransactionResult.md#return) - [transaction](types_app.AppCallTransactionResult.md#transaction) +- [transactions](types_app.AppCallTransactionResult.md#transactions) ## Properties @@ -34,7 +36,19 @@ The response if the transaction was sent and waited for #### Defined in -[src/types/transaction.ts:44](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L44) +[src/types/transaction.ts:46](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L46) + +___ + +### confirmations + +• `Optional` **confirmations**: [`PendingTransactionResponse`](types_algod.PendingTransactionResponse.md)[] + +The responses if the transactions are sent and waited for + +#### Defined in + +[src/types/app.ts:162](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L162) ___ @@ -46,7 +60,7 @@ If an ABI method was called the processed return value #### Defined in -[src/types/app.ts:158](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L158) +[src/types/app.ts:164](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L164) ___ @@ -62,4 +76,16 @@ The transaction #### Defined in -[src/types/transaction.ts:42](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L42) +[src/types/transaction.ts:44](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L44) + +___ + +### transactions + +• **transactions**: `Transaction`[] + +All transactions sent as part of the app call (i.e. multiple if an ABI call is made which includes transaction arguments) + +#### Defined in + +[src/types/app.ts:160](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L160) diff --git a/docs/code/interfaces/types_app.AppCompilationResult.md b/docs/code/interfaces/types_app.AppCompilationResult.md index 02203a47..7e805ac0 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:254](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L254) +[src/types/app.ts:260](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L260) ___ @@ -35,4 +35,4 @@ The compilation result of clear #### Defined in -[src/types/app.ts:256](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L256) +[src/types/app.ts:262](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L262) diff --git a/docs/code/interfaces/types_app.AppDeployMetadata.md b/docs/code/interfaces/types_app.AppDeployMetadata.md index d2b37466..4e0ca0ed 100644 --- a/docs/code/interfaces/types_app.AppDeployMetadata.md +++ b/docs/code/interfaces/types_app.AppDeployMetadata.md @@ -35,7 +35,7 @@ Whether or not the app is deletable / permanent / unspecified #### Defined in -[src/types/app.ts:179](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L179) +[src/types/app.ts:185](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L185) ___ @@ -47,7 +47,7 @@ The unique name identifier of the app within the creator account #### Defined in -[src/types/app.ts:175](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L175) +[src/types/app.ts:181](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L181) ___ @@ -59,7 +59,7 @@ Whether or not the app is updatable / immutable / unspecified #### Defined in -[src/types/app.ts:181](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L181) +[src/types/app.ts:187](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L187) ___ @@ -71,4 +71,4 @@ The version of app that is / will be deployed #### Defined in -[src/types/app.ts:177](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L177) +[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.AppDeploymentParams.md b/docs/code/interfaces/types_app.AppDeploymentParams.md index e5a5c038..f4b68a40 100644 --- a/docs/code/interfaces/types_app.AppDeploymentParams.md +++ b/docs/code/interfaces/types_app.AppDeploymentParams.md @@ -8,7 +8,7 @@ The parameters to deploy an app ## Hierarchy -- `Omit`<[`CreateAppParams`](types_app.CreateAppParams.md), ``"args"`` \| ``"note"`` \| ``"skipSending"`` \| ``"skipWaiting"``\> +- `Omit`<[`CreateAppParams`](types_app.CreateAppParams.md), ``"args"`` \| ``"note"`` \| ``"skipSending"`` \| ``"skipWaiting"`` \| ``"atc"``\> ↳ **`AppDeploymentParams`** @@ -48,7 +48,7 @@ Omit.approvalProgram #### Defined in -[src/types/app.ts:89](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L89) +[src/types/app.ts:90](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L90) ___ @@ -64,7 +64,7 @@ Omit.clearStateProgram #### Defined in -[src/types/app.ts:91](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L91) +[src/types/app.ts:92](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L92) ___ @@ -76,7 +76,7 @@ Any args to pass to any create transaction that is issued as part of deployment #### 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:250](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L250) ___ @@ -88,7 +88,7 @@ Any args to pass to any delete transaction that is issued as part of deployment #### Defined in -[src/types/app.ts:248](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L248) +[src/types/app.ts:254](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L254) ___ @@ -100,7 +100,7 @@ Any deploy-time parameters to replace in the TEAL code #### Defined in -[src/types/app.ts:236](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L236) +[src/types/app.ts:242](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L242) ___ @@ -112,7 +112,7 @@ Optional cached value of the existing apps for the given creator #### 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:248](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L248) ___ @@ -128,7 +128,7 @@ Omit.fee #### Defined in -[src/types/transaction.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L32) +[src/types/transaction.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L34) ___ @@ -144,7 +144,7 @@ Omit.from #### Defined in -[src/types/app.ts:87](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L87) +[src/types/app.ts:88](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L88) ___ @@ -160,7 +160,7 @@ Omit.maxFee #### Defined in -[src/types/transaction.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L34) +[src/types/transaction.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L36) ___ @@ -176,7 +176,7 @@ Omit.maxRoundsToWaitForConfirmation #### Defined in -[src/types/transaction.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L36) +[src/types/transaction.ts:38](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L38) ___ @@ -188,7 +188,7 @@ The deployment metadata #### Defined in -[src/types/app.ts:234](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L234) +[src/types/app.ts:240](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L240) ___ @@ -200,7 +200,7 @@ What action to perform if a schema break is detected #### 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:244](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L244) ___ @@ -212,7 +212,7 @@ What action to perform if a TEAL update is detected #### 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:246](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L246) ___ @@ -228,7 +228,7 @@ Omit.schema #### 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:104](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L104) ___ @@ -244,7 +244,7 @@ Omit.suppressLog #### Defined in -[src/types/transaction.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L30) +[src/types/transaction.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L32) ___ @@ -260,7 +260,7 @@ Omit.transactionParams #### Defined in -[src/types/app.ts:93](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L93) +[src/types/app.ts:94](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L94) ___ @@ -272,4 +272,4 @@ Any args to pass to any update transaction that is issued as part of deployment #### Defined in -[src/types/app.ts:246](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L246) +[src/types/app.ts:252](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L252) diff --git a/docs/code/interfaces/types_app.AppLookup.md b/docs/code/interfaces/types_app.AppLookup.md index 19828dd9..434437ff 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:199](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L199) +[src/types/app.ts:205](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L205) ___ @@ -31,4 +31,4 @@ ___ #### 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:204](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L204) diff --git a/docs/code/interfaces/types_app.AppMetadata.md b/docs/code/interfaces/types_app.AppMetadata.md index a24aff97..bc5fd32f 100644 --- a/docs/code/interfaces/types_app.AppMetadata.md +++ b/docs/code/interfaces/types_app.AppMetadata.md @@ -43,7 +43,7 @@ The Algorand address of the account associated with the app #### Defined in -[src/types/app.ts:24](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L24) +[src/types/app.ts:25](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L25) ___ @@ -59,7 +59,7 @@ The id of the app #### Defined in -[src/types/app.ts:22](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L22) +[src/types/app.ts:23](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L23) ___ @@ -71,7 +71,7 @@ The metadata when the app was created #### Defined in -[src/types/app.ts:191](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L191) +[src/types/app.ts:197](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L197) ___ @@ -83,7 +83,7 @@ The round the app was created #### Defined in -[src/types/app.ts:187](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L187) +[src/types/app.ts:193](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L193) ___ @@ -99,7 +99,7 @@ Whether or not the app is deletable / permanent / unspecified #### Defined in -[src/types/app.ts:179](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L179) +[src/types/app.ts:185](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L185) ___ @@ -111,7 +111,7 @@ Whether or not the app is deleted #### Defined in -[src/types/app.ts:193](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L193) +[src/types/app.ts:199](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L199) ___ @@ -127,7 +127,7 @@ The unique name identifier of the app within the creator account #### Defined in -[src/types/app.ts:175](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L175) +[src/types/app.ts:181](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L181) ___ @@ -143,7 +143,7 @@ Whether or not the app is updatable / immutable / unspecified #### Defined in -[src/types/app.ts:181](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L181) +[src/types/app.ts:187](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L187) ___ @@ -155,7 +155,7 @@ The last round that the app was updated #### Defined in -[src/types/app.ts:189](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L189) +[src/types/app.ts:195](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L195) ___ @@ -171,4 +171,4 @@ The version of app that is / will be deployed #### Defined in -[src/types/app.ts:177](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L177) +[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.AppReference.md b/docs/code/interfaces/types_app.AppReference.md index 960bfebe..a88e43f7 100644 --- a/docs/code/interfaces/types_app.AppReference.md +++ b/docs/code/interfaces/types_app.AppReference.md @@ -29,7 +29,7 @@ The Algorand address of the account associated with the app #### Defined in -[src/types/app.ts:24](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L24) +[src/types/app.ts:25](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L25) ___ @@ -41,4 +41,4 @@ The id of the app #### Defined in -[src/types/app.ts:22](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L22) +[src/types/app.ts:23](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L23) diff --git a/docs/code/interfaces/types_app.AppStorageSchema.md b/docs/code/interfaces/types_app.AppStorageSchema.md index 944b3433..16748d49 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:138](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L138) +[src/types/app.ts:140](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L140) ___ @@ -38,7 +38,7 @@ Restricts number of byte slices in global state #### Defined in -[src/types/app.ts:136](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L136) +[src/types/app.ts:138](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L138) ___ @@ -50,7 +50,7 @@ Restricts number of ints in global state #### Defined in -[src/types/app.ts:134](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L134) +[src/types/app.ts:136](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L136) ___ @@ -62,7 +62,7 @@ Restricts number of byte slices in per-user local state #### Defined in -[src/types/app.ts:132](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L132) +[src/types/app.ts:134](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L134) ___ @@ -74,4 +74,4 @@ Restricts number of ints in per-user local state #### Defined in -[src/types/app.ts:130](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L130) +[src/types/app.ts:132](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L132) diff --git a/docs/code/interfaces/types_app.BoxName.md b/docs/code/interfaces/types_app.BoxName.md index b012c6f0..28da842f 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:279](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L279) +[src/types/app.ts:285](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L285) ___ @@ -36,7 +36,7 @@ Name in Base64 #### 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:289](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L289) ___ @@ -48,4 +48,4 @@ Name in binary bytes #### 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:287](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L287) diff --git a/docs/code/interfaces/types_app.BoxReference.md b/docs/code/interfaces/types_app.BoxReference.md index d7879cf4..91bce961 100644 --- a/docs/code/interfaces/types_app.BoxReference.md +++ b/docs/code/interfaces/types_app.BoxReference.md @@ -23,7 +23,7 @@ A unique application id #### Defined in -[src/types/app.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L34) +[src/types/app.ts:35](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L35) ___ @@ -35,4 +35,4 @@ Name of box to reference #### Defined in -[src/types/app.ts:38](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L38) +[src/types/app.ts:39](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L39) diff --git a/docs/code/interfaces/types_app.BoxValueRequestParams.md b/docs/code/interfaces/types_app.BoxValueRequestParams.md index b8b8effb..22459bc3 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:291](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L291) +[src/types/app.ts:297](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L297) ___ @@ -40,7 +40,7 @@ BoxName #### Defined in -[src/types/app.ts:293](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L293) +[src/types/app.ts:299](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L299) ___ @@ -52,4 +52,4 @@ The ABI type to decode the value using #### Defined in -[src/types/app.ts:295](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L295) +[src/types/app.ts:301](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L301) diff --git a/docs/code/interfaces/types_app.BoxValuesRequestParams.md b/docs/code/interfaces/types_app.BoxValuesRequestParams.md index 3d5b40fd..84691d9d 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:303](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L303) +[src/types/app.ts:309](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L309) ___ @@ -40,7 +40,7 @@ BoxName #### Defined in -[src/types/app.ts:305](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L305) +[src/types/app.ts:311](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L311) ___ @@ -52,4 +52,4 @@ The ABI type to decode the value using #### Defined in -[src/types/app.ts:307](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L307) +[src/types/app.ts:313](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L313) diff --git a/docs/code/interfaces/types_app.CompiledTeal.md b/docs/code/interfaces/types_app.CompiledTeal.md index 2dc67335..d9512d44 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:146](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L146) +[src/types/app.ts:148](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L148) ___ @@ -38,7 +38,7 @@ The base64 encoded code as a byte array #### Defined in -[src/types/app.ts:150](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L150) +[src/types/app.ts:152](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L152) ___ @@ -50,7 +50,7 @@ The has returned by the compiler #### Defined in -[src/types/app.ts:148](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L148) +[src/types/app.ts:150](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L150) ___ @@ -62,7 +62,7 @@ Source map from the compilation #### Defined in -[src/types/app.ts:152](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L152) +[src/types/app.ts:154](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L154) ___ @@ -74,4 +74,4 @@ Original TEAL code #### Defined in -[src/types/app.ts:144](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L144) +[src/types/app.ts:146](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L146) diff --git a/docs/code/interfaces/types_app.CreateAppParams.md b/docs/code/interfaces/types_app.CreateAppParams.md index c35ab963..91371ab3 100644 --- a/docs/code/interfaces/types_app.CreateAppParams.md +++ b/docs/code/interfaces/types_app.CreateAppParams.md @@ -18,6 +18,7 @@ Parameters that are passed in when creating an app. - [approvalProgram](types_app.CreateAppParams.md#approvalprogram) - [args](types_app.CreateAppParams.md#args) +- [atc](types_app.CreateAppParams.md#atc) - [clearStateProgram](types_app.CreateAppParams.md#clearstateprogram) - [fee](types_app.CreateAppParams.md#fee) - [from](types_app.CreateAppParams.md#from) @@ -44,7 +45,7 @@ CreateOrUpdateAppParams.approvalProgram #### Defined in -[src/types/app.ts:89](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L89) +[src/types/app.ts:90](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L90) ___ @@ -60,7 +61,27 @@ CreateOrUpdateAppParams.args #### Defined in -[src/types/app.ts:97](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L97) +[src/types/app.ts:98](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L98) + +___ + +### atc + +• `Optional` **atc**: `AtomicTransactionComposer` + +An optional + +**`See`** + +AtomicTransactionComposer to add the transaction to, if specified then `skipSending: undefined` has the same effect as `skipSending: true` + +#### Inherited from + +CreateOrUpdateAppParams.atc + +#### Defined in + +[src/types/transaction.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L30) ___ @@ -76,7 +97,7 @@ CreateOrUpdateAppParams.clearStateProgram #### Defined in -[src/types/app.ts:91](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L91) +[src/types/app.ts:92](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L92) ___ @@ -92,7 +113,7 @@ CreateOrUpdateAppParams.fee #### Defined in -[src/types/transaction.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L32) +[src/types/transaction.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L34) ___ @@ -108,7 +129,7 @@ CreateOrUpdateAppParams.from #### Defined in -[src/types/app.ts:87](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L87) +[src/types/app.ts:88](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L88) ___ @@ -124,7 +145,7 @@ CreateOrUpdateAppParams.maxFee #### Defined in -[src/types/transaction.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L34) +[src/types/transaction.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L36) ___ @@ -140,7 +161,7 @@ CreateOrUpdateAppParams.maxRoundsToWaitForConfirmation #### Defined in -[src/types/transaction.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L36) +[src/types/transaction.ts:38](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L38) ___ @@ -156,7 +177,7 @@ CreateOrUpdateAppParams.note #### Defined in -[src/types/app.ts:95](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L95) +[src/types/app.ts:96](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L96) ___ @@ -168,7 +189,7 @@ The storage schema to request for the created app #### 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:104](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L104) ___ @@ -176,7 +197,7 @@ ___ • `Optional` **skipSending**: `boolean` -Whether to skip signing and sending the transaction to the chain (default: transaction signed and sent to chain) +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 @@ -217,7 +238,7 @@ CreateOrUpdateAppParams.suppressLog #### Defined in -[src/types/transaction.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L30) +[src/types/transaction.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L32) ___ @@ -233,4 +254,4 @@ CreateOrUpdateAppParams.transactionParams #### Defined in -[src/types/app.ts:93](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L93) +[src/types/app.ts:94](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L94) diff --git a/docs/code/interfaces/types_app.RawAppCallArgs.md b/docs/code/interfaces/types_app.RawAppCallArgs.md index a1ed9d49..b9027b38 100644 --- a/docs/code/interfaces/types_app.RawAppCallArgs.md +++ b/docs/code/interfaces/types_app.RawAppCallArgs.md @@ -27,7 +27,7 @@ The address of any accounts to load in #### Defined in -[src/types/app.ts:46](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L46) +[src/types/app.ts:47](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L47) ___ @@ -39,7 +39,7 @@ Any application arguments to pass through #### Defined in -[src/types/app.ts:48](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L48) +[src/types/app.ts:49](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L49) ___ @@ -51,7 +51,7 @@ IDs of any apps to load into the foreignApps array #### Defined in -[src/types/app.ts:52](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L52) +[src/types/app.ts:53](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L53) ___ @@ -63,7 +63,7 @@ IDs of any assets to load into the foreignAssets array #### Defined in -[src/types/app.ts:54](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L54) +[src/types/app.ts:55](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L55) ___ @@ -75,7 +75,7 @@ Any box references to load #### Defined in -[src/types/app.ts:50](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L50) +[src/types/app.ts:51](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L51) ___ @@ -87,4 +87,4 @@ The optional lease for the transaction #### Defined in -[src/types/app.ts:56](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L56) +[src/types/app.ts:57](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L57) diff --git a/docs/code/interfaces/types_app.UpdateAppParams.md b/docs/code/interfaces/types_app.UpdateAppParams.md index ba11dac1..96f5a9db 100644 --- a/docs/code/interfaces/types_app.UpdateAppParams.md +++ b/docs/code/interfaces/types_app.UpdateAppParams.md @@ -19,6 +19,7 @@ Parameters that are passed in when updating an app. - [appId](types_app.UpdateAppParams.md#appid) - [approvalProgram](types_app.UpdateAppParams.md#approvalprogram) - [args](types_app.UpdateAppParams.md#args) +- [atc](types_app.UpdateAppParams.md#atc) - [clearStateProgram](types_app.UpdateAppParams.md#clearstateprogram) - [fee](types_app.UpdateAppParams.md#fee) - [from](types_app.UpdateAppParams.md#from) @@ -40,7 +41,7 @@ The id of the app to update #### Defined in -[src/types/app.ts:109](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L109) +[src/types/app.ts:110](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L110) ___ @@ -56,7 +57,7 @@ CreateOrUpdateAppParams.approvalProgram #### Defined in -[src/types/app.ts:89](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L89) +[src/types/app.ts:90](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L90) ___ @@ -72,7 +73,27 @@ CreateOrUpdateAppParams.args #### Defined in -[src/types/app.ts:97](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L97) +[src/types/app.ts:98](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L98) + +___ + +### atc + +• `Optional` **atc**: `AtomicTransactionComposer` + +An optional + +**`See`** + +AtomicTransactionComposer to add the transaction to, if specified then `skipSending: undefined` has the same effect as `skipSending: true` + +#### Inherited from + +CreateOrUpdateAppParams.atc + +#### Defined in + +[src/types/transaction.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L30) ___ @@ -88,7 +109,7 @@ CreateOrUpdateAppParams.clearStateProgram #### Defined in -[src/types/app.ts:91](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L91) +[src/types/app.ts:92](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L92) ___ @@ -104,7 +125,7 @@ CreateOrUpdateAppParams.fee #### Defined in -[src/types/transaction.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L32) +[src/types/transaction.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L34) ___ @@ -120,7 +141,7 @@ CreateOrUpdateAppParams.from #### Defined in -[src/types/app.ts:87](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L87) +[src/types/app.ts:88](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L88) ___ @@ -136,7 +157,7 @@ CreateOrUpdateAppParams.maxFee #### Defined in -[src/types/transaction.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L34) +[src/types/transaction.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L36) ___ @@ -152,7 +173,7 @@ CreateOrUpdateAppParams.maxRoundsToWaitForConfirmation #### Defined in -[src/types/transaction.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L36) +[src/types/transaction.ts:38](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L38) ___ @@ -168,7 +189,7 @@ CreateOrUpdateAppParams.note #### Defined in -[src/types/app.ts:95](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L95) +[src/types/app.ts:96](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L96) ___ @@ -176,7 +197,7 @@ ___ • `Optional` **skipSending**: `boolean` -Whether to skip signing and sending the transaction to the chain (default: transaction signed and sent to chain) +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 @@ -217,7 +238,7 @@ CreateOrUpdateAppParams.suppressLog #### Defined in -[src/types/transaction.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L30) +[src/types/transaction.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L32) ___ @@ -233,4 +254,4 @@ CreateOrUpdateAppParams.transactionParams #### Defined in -[src/types/app.ts:93](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L93) +[src/types/app.ts:94](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L94) diff --git a/docs/code/interfaces/types_transaction.AtomicTransactionComposerToSend.md b/docs/code/interfaces/types_transaction.AtomicTransactionComposerToSend.md new file mode 100644 index 00000000..92b7d37b --- /dev/null +++ b/docs/code/interfaces/types_transaction.AtomicTransactionComposerToSend.md @@ -0,0 +1,46 @@ +[@algorandfoundation/algokit-utils](../README.md) / [types/transaction](../modules/types_transaction.md) / AtomicTransactionComposerToSend + +# Interface: AtomicTransactionComposerToSend + +[types/transaction](../modules/types_transaction.md).AtomicTransactionComposerToSend + +An + +**`See`** + +AtomicTransactionComposer with transactions to send. + +## Table of contents + +### Properties + +- [atc](types_transaction.AtomicTransactionComposerToSend.md#atc) +- [sendParams](types_transaction.AtomicTransactionComposerToSend.md#sendparams) + +## Properties + +### atc + +• **atc**: `AtomicTransactionComposer` + +The + +**`See`** + +AtomicTransactionComposer with transactions loaded to send + +#### Defined in + +[src/types/transaction.ts:93](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L93) + +___ + +### sendParams + +• `Optional` **sendParams**: `Omit`<[`SendTransactionParams`](types_transaction.SendTransactionParams.md), ``"fee"`` \| ``"maxFee"`` \| ``"skipSending"`` \| ``"atc"``\> + +Any parameters to control the semantics of the send to the network + +#### Defined in + +[src/types/transaction.ts:95](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L95) diff --git a/docs/code/interfaces/types_transaction.ConfirmedTransactionResult.md b/docs/code/interfaces/types_transaction.ConfirmedTransactionResult.md index feb12e1a..4b20acfb 100644 --- a/docs/code/interfaces/types_transaction.ConfirmedTransactionResult.md +++ b/docs/code/interfaces/types_transaction.ConfirmedTransactionResult.md @@ -25,7 +25,7 @@ The result of sending and confirming a transaction • **confirmation**: [`PendingTransactionResponse`](types_algod.PendingTransactionResponse.md) -The response if the transaction was sent and waited for +The response from sending and waiting for the transaction #### Overrides @@ -33,7 +33,7 @@ The response if the transaction was sent and waited for #### Defined in -[src/types/transaction.ts:50](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L50) +[src/types/transaction.ts:52](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L52) ___ @@ -49,4 +49,4 @@ The transaction #### Defined in -[src/types/transaction.ts:42](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L42) +[src/types/transaction.ts:44](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L44) diff --git a/docs/code/interfaces/types_transaction.ConfirmedTransactionResults.md b/docs/code/interfaces/types_transaction.ConfirmedTransactionResults.md new file mode 100644 index 00000000..9a1ff214 --- /dev/null +++ b/docs/code/interfaces/types_transaction.ConfirmedTransactionResults.md @@ -0,0 +1,78 @@ +[@algorandfoundation/algokit-utils](../README.md) / [types/transaction](../modules/types_transaction.md) / ConfirmedTransactionResults + +# Interface: ConfirmedTransactionResults + +[types/transaction](../modules/types_transaction.md).ConfirmedTransactionResults + +The result of sending and confirming one or more transactions, but where there is a primary transaction of interest + +## Hierarchy + +- [`SendTransactionResult`](types_transaction.SendTransactionResult.md) + + ↳ **`ConfirmedTransactionResults`** + +## Table of contents + +### Properties + +- [confirmation](types_transaction.ConfirmedTransactionResults.md#confirmation) +- [confirmations](types_transaction.ConfirmedTransactionResults.md#confirmations) +- [transaction](types_transaction.ConfirmedTransactionResults.md#transaction) +- [transactions](types_transaction.ConfirmedTransactionResults.md#transactions) + +## Properties + +### confirmation + +• **confirmation**: [`PendingTransactionResponse`](types_algod.PendingTransactionResponse.md) + +The response from sending and waiting for the primary transaction + +#### Overrides + +[SendTransactionResult](types_transaction.SendTransactionResult.md).[confirmation](types_transaction.SendTransactionResult.md#confirmation) + +#### Defined in + +[src/types/transaction.ts:60](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L60) + +___ + +### confirmations + +• **confirmations**: [`PendingTransactionResponse`](types_algod.PendingTransactionResponse.md)[] + +The response from sending and waiting for the transactions + +#### Defined in + +[src/types/transaction.ts:62](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L62) + +___ + +### transaction + +• **transaction**: `Transaction` + +The transaction + +#### Inherited from + +[SendTransactionResult](types_transaction.SendTransactionResult.md).[transaction](types_transaction.SendTransactionResult.md#transaction) + +#### Defined in + +[src/types/transaction.ts:44](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L44) + +___ + +### transactions + +• **transactions**: `Transaction`[] + +The transactions + +#### Defined in + +[src/types/transaction.ts:58](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L58) diff --git a/docs/code/interfaces/types_transaction.SendTransactionParams.md b/docs/code/interfaces/types_transaction.SendTransactionParams.md index 734862d6..11a84651 100644 --- a/docs/code/interfaces/types_transaction.SendTransactionParams.md +++ b/docs/code/interfaces/types_transaction.SendTransactionParams.md @@ -20,6 +20,7 @@ The sending configuration for a transaction ### Properties +- [atc](types_transaction.SendTransactionParams.md#atc) - [fee](types_transaction.SendTransactionParams.md#fee) - [maxFee](types_transaction.SendTransactionParams.md#maxfee) - [maxRoundsToWaitForConfirmation](types_transaction.SendTransactionParams.md#maxroundstowaitforconfirmation) @@ -29,6 +30,22 @@ The sending configuration for a transaction ## Properties +### atc + +• `Optional` **atc**: `AtomicTransactionComposer` + +An optional + +**`See`** + +AtomicTransactionComposer to add the transaction to, if specified then `skipSending: undefined` has the same effect as `skipSending: true` + +#### 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) @@ -37,7 +54,7 @@ The flat fee you want to pay, useful for covering extra fees in a transaction gr #### Defined in -[src/types/transaction.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L32) +[src/types/transaction.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L34) ___ @@ -49,7 +66,7 @@ The maximum fee that you are happy to pay (default: unbounded) - if this is set #### Defined in -[src/types/transaction.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L34) +[src/types/transaction.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L36) ___ @@ -61,7 +78,7 @@ The maximum number of rounds to wait for confirmation, only applies if `skipWait #### Defined in -[src/types/transaction.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L36) +[src/types/transaction.ts:38](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L38) ___ @@ -69,7 +86,7 @@ ___ • `Optional` **skipSending**: `boolean` -Whether to skip signing and sending the transaction to the chain (default: transaction signed and sent to chain) +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) #### Defined in @@ -98,4 +115,4 @@ Whether to suppress log messages from transaction send, default: do not suppress #### Defined in -[src/types/transaction.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L30) +[src/types/transaction.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L32) diff --git a/docs/code/interfaces/types_transaction.SendTransactionResult.md b/docs/code/interfaces/types_transaction.SendTransactionResult.md index ed35ffcc..7aba28ed 100644 --- a/docs/code/interfaces/types_transaction.SendTransactionResult.md +++ b/docs/code/interfaces/types_transaction.SendTransactionResult.md @@ -14,6 +14,8 @@ The result of sending a transaction ↳ [`ConfirmedTransactionResult`](types_transaction.ConfirmedTransactionResult.md) + ↳ [`ConfirmedTransactionResults`](types_transaction.ConfirmedTransactionResults.md) + ## Table of contents ### Properties @@ -31,7 +33,7 @@ The response if the transaction was sent and waited for #### Defined in -[src/types/transaction.ts:44](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L44) +[src/types/transaction.ts:46](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L46) ___ @@ -43,4 +45,4 @@ The transaction #### Defined in -[src/types/transaction.ts:42](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L42) +[src/types/transaction.ts:44](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L44) diff --git a/docs/code/interfaces/types_transaction.TransactionGroupToSend.md b/docs/code/interfaces/types_transaction.TransactionGroupToSend.md index ad48882d..e6e449b1 100644 --- a/docs/code/interfaces/types_transaction.TransactionGroupToSend.md +++ b/docs/code/interfaces/types_transaction.TransactionGroupToSend.md @@ -22,13 +22,13 @@ https://developer.algorand.org/docs/get-details/atomic_transfers/ ### sendParams -• `Optional` **sendParams**: `Omit`<`Omit`<[`SendTransactionParams`](types_transaction.SendTransactionParams.md), ``"maxFee"``\>, ``"skipSending"``\> +• `Optional` **sendParams**: `Omit`<[`SendTransactionParams`](types_transaction.SendTransactionParams.md), ``"fee"`` \| ``"maxFee"`` \| ``"skipSending"`` \| ``"atc"``\> Any parameters to control the semantics of the send to the network #### Defined in -[src/types/transaction.ts:68](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L68) +[src/types/transaction.ts:80](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L80) ___ @@ -40,7 +40,7 @@ Optional signer to pass in, required if at least one transaction provided is jus #### Defined in -[src/types/transaction.ts:75](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L75) +[src/types/transaction.ts:87](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L87) ___ @@ -53,9 +53,9 @@ The list of transactions to send, which can either be a raw transaction (in whic **`See`** -SendTransactionResult (saves unwrapping the promise, be sure to pass `skipSending: true`, `signer` is required) - or the transaction with its signer +SendTransactionResult (saves unwrapping the promise, be sure to pass `skipSending: true`, `signer` is also required) + or the transaction with its signer (`signer` is ignored) #### Defined in -[src/types/transaction.ts:73](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L73) +[src/types/transaction.ts:85](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L85) diff --git a/docs/code/interfaces/types_transaction.TransactionToSign.md b/docs/code/interfaces/types_transaction.TransactionToSign.md index 6c4c611b..ff4c3efb 100644 --- a/docs/code/interfaces/types_transaction.TransactionToSign.md +++ b/docs/code/interfaces/types_transaction.TransactionToSign.md @@ -23,7 +23,7 @@ The account to use to sign the transaction, either an account (with private key #### Defined in -[src/types/transaction.ts:60](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L60) +[src/types/transaction.ts:72](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L72) ___ @@ -35,4 +35,4 @@ The unsigned transaction to sign and send #### Defined in -[src/types/transaction.ts:58](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L58) +[src/types/transaction.ts:70](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L70) diff --git a/docs/code/interfaces/types_transfer.AlgoTransferParams.md b/docs/code/interfaces/types_transfer.AlgoTransferParams.md index ef1e946f..7810a79c 100644 --- a/docs/code/interfaces/types_transfer.AlgoTransferParams.md +++ b/docs/code/interfaces/types_transfer.AlgoTransferParams.md @@ -21,6 +21,7 @@ transferAlgos call. ### Properties - [amount](types_transfer.AlgoTransferParams.md#amount) +- [atc](types_transfer.AlgoTransferParams.md#atc) - [fee](types_transfer.AlgoTransferParams.md#fee) - [from](types_transfer.AlgoTransferParams.md#from) - [maxFee](types_transfer.AlgoTransferParams.md#maxfee) @@ -46,6 +47,26 @@ The amount to send ___ +### atc + +• `Optional` **atc**: `AtomicTransactionComposer` + +An optional + +**`See`** + +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) @@ -58,7 +79,7 @@ The flat fee you want to pay, useful for covering extra fees in a transaction gr #### Defined in -[src/types/transaction.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L32) +[src/types/transaction.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L34) ___ @@ -86,7 +107,7 @@ The maximum fee that you are happy to pay (default: unbounded) - if this is set #### Defined in -[src/types/transaction.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L34) +[src/types/transaction.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L36) ___ @@ -102,7 +123,7 @@ The maximum number of rounds to wait for confirmation, only applies if `skipWait #### Defined in -[src/types/transaction.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L36) +[src/types/transaction.ts:38](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L38) ___ @@ -122,7 +143,7 @@ ___ • `Optional` **skipSending**: `boolean` -Whether to skip signing and sending the transaction to the chain (default: transaction signed and sent to chain) +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 @@ -163,7 +184,7 @@ Whether to suppress log messages from transaction send, default: do not suppress #### Defined in -[src/types/transaction.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L30) +[src/types/transaction.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L32) ___ diff --git a/docs/code/interfaces/types_transfer.EnsureFundedParams.md b/docs/code/interfaces/types_transfer.EnsureFundedParams.md index a4e10871..92641fa0 100644 --- a/docs/code/interfaces/types_transfer.EnsureFundedParams.md +++ b/docs/code/interfaces/types_transfer.EnsureFundedParams.md @@ -21,6 +21,7 @@ ensureFunded call. ### Properties - [accountToFund](types_transfer.EnsureFundedParams.md#accounttofund) +- [atc](types_transfer.EnsureFundedParams.md#atc) - [fee](types_transfer.EnsureFundedParams.md#fee) - [fundingSource](types_transfer.EnsureFundedParams.md#fundingsource) - [maxFee](types_transfer.EnsureFundedParams.md#maxfee) @@ -47,6 +48,26 @@ The account to fund ___ +### atc + +• `Optional` **atc**: `AtomicTransactionComposer` + +An optional + +**`See`** + +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) @@ -59,7 +80,7 @@ The flat fee you want to pay, useful for covering extra fees in a transaction gr #### Defined in -[src/types/transaction.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L32) +[src/types/transaction.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L34) ___ @@ -87,7 +108,7 @@ The maximum fee that you are happy to pay (default: unbounded) - if this is set #### Defined in -[src/types/transaction.ts:34](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L34) +[src/types/transaction.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L36) ___ @@ -103,7 +124,7 @@ The maximum number of rounds to wait for confirmation, only applies if `skipWait #### Defined in -[src/types/transaction.ts:36](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L36) +[src/types/transaction.ts:38](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L38) ___ @@ -147,7 +168,7 @@ ___ • `Optional` **skipSending**: `boolean` -Whether to skip signing and sending the transaction to the chain (default: transaction signed and sent to chain) +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 @@ -188,7 +209,7 @@ Whether to suppress log messages from transaction send, default: do not suppress #### Defined in -[src/types/transaction.ts:30](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L30) +[src/types/transaction.ts:32](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L32) ___ diff --git a/docs/code/modules/index.md b/docs/code/modules/index.md index 5626975f..2a6b11e3 100644 --- a/docs/code/modules/index.md +++ b/docs/code/modules/index.md @@ -14,6 +14,7 @@ - [callApp](index.md#callapp) - [capTransactionFee](index.md#captransactionfee) - [compileTeal](index.md#compileteal) +- [controlFees](index.md#controlfees) - [createApp](index.md#createapp) - [decodeAppState](index.md#decodeappstate) - [deployApp](index.md#deployapp) @@ -29,6 +30,7 @@ - [getAlgoKmdClient](index.md#getalgokmdclient) - [getAlgoNodeConfig](index.md#getalgonodeconfig) - [getAlgodConfigFromEnvironment](index.md#getalgodconfigfromenvironment) +- [getAppArgsForABICall](index.md#getappargsforabicall) - [getAppArgsForTransaction](index.md#getappargsfortransaction) - [getAppBoxNames](index.md#getappboxnames) - [getAppBoxValue](index.md#getappboxvalue) @@ -40,6 +42,7 @@ - [getAppGlobalState](index.md#getappglobalstate) - [getAppLocalState](index.md#getapplocalstate) - [getApplicationClient](index.md#getapplicationclient) +- [getAtomicTransactionComposerTransactions](index.md#getatomictransactioncomposertransactions) - [getCreatorAppsByName](index.md#getcreatorappsbyname) - [getDefaultLocalNetConfig](index.md#getdefaultlocalnetconfig) - [getDispenserAccount](index.md#getdispenseraccount) @@ -48,6 +51,7 @@ - [getLocalNetDispenserAccount](index.md#getlocalnetdispenseraccount) - [getOrCreateKmdWalletAccount](index.md#getorcreatekmdwalletaccount) - [getSenderAddress](index.md#getsenderaddress) +- [getSenderTransactionSigner](index.md#getsendertransactionsigner) - [getTransactionParams](index.md#gettransactionparams) - [isLocalNet](index.md#islocalnet) - [isSchemaIsBroken](index.md#isschemaisbroken) @@ -62,6 +66,7 @@ - [rekeyedAccount](index.md#rekeyedaccount) - [replaceDeployTimeControlParams](index.md#replacedeploytimecontrolparams) - [searchTransactions](index.md#searchtransactions) +- [sendAtomicTransactionComposer](index.md#sendatomictransactioncomposer) - [sendGroupOfTransactions](index.md#sendgroupoftransactions) - [sendTransaction](index.md#sendtransaction) - [transactionFees](index.md#transactionfees) @@ -131,7 +136,7 @@ The result of the call #### Defined in -[src/app.ts:134](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L134) +[src/app.ts:256](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L256) ___ @@ -147,7 +152,7 @@ the estimated rate. | Name | Type | Description | | :------ | :------ | :------ | -| `transaction` | `Transaction` | The transaction to cap | +| `transaction` | `Transaction` \| `SuggestedParams` | The transaction to cap or suggested params object about to be used to create a transaction | | `maxAcceptableFee` | [`AlgoAmount`](../classes/types_amount.AlgoAmount.md) | The maximum acceptable fee to pay | #### Returns @@ -156,7 +161,7 @@ the estimated rate. #### Defined in -[src/transaction.ts:286](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L286) +[src/transaction.ts:289](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L289) ___ @@ -181,7 +186,43 @@ The information about the compiled file #### Defined in -[src/app.ts:443](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L443) +[src/app.ts:581](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L581) + +___ + +### controlFees + +▸ **controlFees**<`T`\>(`transaction`, `feeControl`): `T` + +Allows for control of fees on a + +**`See`** + + - Transaction or + - SuggestedParams object + +#### Type parameters + +| Name | Type | +| :------ | :------ | +| `T` | extends `Transaction` \| `SuggestedParams` | + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `transaction` | `T` | The transaction or suggested params | +| `feeControl` | `Object` | The fee control parameters | +| `feeControl.fee?` | [`AlgoAmount`](../classes/types_amount.AlgoAmount.md) | - | +| `feeControl.maxFee?` | [`AlgoAmount`](../classes/types_amount.AlgoAmount.md) | - | + +#### Returns + +`T` + +#### Defined in + +[src/transaction.ts:312](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L312) ___ @@ -206,7 +247,7 @@ The details of the created app, or the transaction to create it if `skipSending` #### Defined in -[src/app.ts:40](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L40) +[src/app.ts:50](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L50) ___ @@ -226,13 +267,13 @@ ___ #### Defined in -[src/app.ts:304](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L304) +[src/app.ts:468](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L468) ___ ### deployApp -▸ **deployApp**(`deployment`, `algod`, `indexer?`): `Promise`<`Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"create"`` \| ``"update"`` } \| [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `deleteResult`: [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) ; `operationPerformed`: ``"replace"`` } \| [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"nothing"`` }\> +▸ **deployApp**(`deployment`, `algod`, `indexer?`): `Promise`<`Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`ConfirmedTransactionResults`](../interfaces/types_transaction.ConfirmedTransactionResults.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"create"`` \| ``"update"`` ; `return?`: [`ABIReturn`](types_app.md#abireturn) } \| [`ConfirmedTransactionResults`](../interfaces/types_transaction.ConfirmedTransactionResults.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `deleteResult`: [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) ; `deleteReturn?`: [`ABIReturn`](types_app.md#abireturn) ; `operationPerformed`: ``"replace"`` ; `return?`: [`ABIReturn`](types_app.md#abireturn) } \| [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"nothing"`` }\> Idempotently deploy (create, update/delete if changed) an app against the given name via the given creator account, including deploy-time template placeholder substitutions. @@ -258,13 +299,13 @@ https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-de #### Returns -`Promise`<`Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"create"`` \| ``"update"`` } \| [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `deleteResult`: [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) ; `operationPerformed`: ``"replace"`` } \| [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"nothing"`` }\> +`Promise`<`Partial`<[`AppCompilationResult`](../interfaces/types_app.AppCompilationResult.md)\> & [`ConfirmedTransactionResults`](../interfaces/types_transaction.ConfirmedTransactionResults.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"create"`` \| ``"update"`` ; `return?`: [`ABIReturn`](types_app.md#abireturn) } \| [`ConfirmedTransactionResults`](../interfaces/types_transaction.ConfirmedTransactionResults.md) & [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `deleteResult`: [`ConfirmedTransactionResult`](../interfaces/types_transaction.ConfirmedTransactionResult.md) ; `deleteReturn?`: [`ABIReturn`](types_app.md#abireturn) ; `operationPerformed`: ``"replace"`` ; `return?`: [`ABIReturn`](types_app.md#abireturn) } \| [`AppMetadata`](../interfaces/types_app.AppMetadata.md) & { `operationPerformed`: ``"nothing"`` }\> The app reference of the new/existing app #### Defined in -[src/deploy-app.ts:38](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/deploy-app.ts#L38) +[src/deploy-app.ts:39](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/deploy-app.ts#L39) ___ @@ -295,7 +336,7 @@ the transaction note ready for inclusion in a transaction #### Defined in -[src/transaction.ts:27](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L27) +[src/transaction.ts:28](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L28) ___ @@ -373,7 +414,7 @@ ___ #### Defined in -[src/app.ts:173](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L173) +[src/app.ts:338](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L338) ___ @@ -666,9 +707,46 @@ Retrieve the algod configuration from environment variables (expects to be calle ___ +### getAppArgsForABICall + +▸ **getAppArgsForABICall**(`args`, `from`): `Object` + +Returns the app args ready to load onto an ABI method call in + +**`See`** + +AtomicTransactionComposer + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `args` | [`ABIAppCallArgs`](../interfaces/types_app.ABIAppCallArgs.md) | +| `from` | [`SendTransactionFrom`](types_transaction.md#sendtransactionfrom) | + +#### Returns + +`Object` + +| Name | Type | +| :------ | :------ | +| `boxes` | `undefined` \| `BoxReference`[] | +| `lease` | `undefined` \| `Uint8Array` | +| `method` | `ABIMethod` | +| `methodArgs` | (`string` \| `number` \| `bigint` \| `boolean` \| `Uint8Array` \| `ABIValue`[] \| `TransactionWithSigner`)[] | +| `rekeyTo` | `undefined` | +| `sender` | `string` | +| `signer` | `TransactionSigner` | + +#### Defined in + +[src/app.ts:534](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L534) + +___ + ### getAppArgsForTransaction -▸ **getAppArgsForTransaction**(`args?`): `undefined` \| { `accounts`: `undefined` \| `string`[] ; `appArgs`: `undefined` \| `Uint8Array`[] ; `boxes`: `undefined` \| `BoxReference`[] ; `foreignApps`: `undefined` \| `number`[] = actualArgs.apps; `foreignAssets`: `undefined` \| `number`[] = actualArgs.assets; `lease`: `undefined` \| `Uint8Array` } +▸ **getAppArgsForTransaction**(`args?`): `undefined` \| { `accounts`: `undefined` \| `string`[] ; `appArgs`: `undefined` \| `Uint8Array`[] ; `boxes`: `undefined` \| `BoxReference`[] ; `foreignApps`: `undefined` \| `number`[] = args.apps; `foreignAssets`: `undefined` \| `number`[] = args.assets; `lease`: `undefined` \| `Uint8Array` } Returns the app args ready to load onto an app @@ -680,15 +758,15 @@ object | Name | Type | | :------ | :------ | -| `args?` | [`AppCallArgs`](types_app.md#appcallargs) | +| `args?` | [`RawAppCallArgs`](../interfaces/types_app.RawAppCallArgs.md) | #### Returns -`undefined` \| { `accounts`: `undefined` \| `string`[] ; `appArgs`: `undefined` \| `Uint8Array`[] ; `boxes`: `undefined` \| `BoxReference`[] ; `foreignApps`: `undefined` \| `number`[] = actualArgs.apps; `foreignAssets`: `undefined` \| `number`[] = actualArgs.assets; `lease`: `undefined` \| `Uint8Array` } +`undefined` \| { `accounts`: `undefined` \| `string`[] ; `appArgs`: `undefined` \| `Uint8Array`[] ; `boxes`: `undefined` \| `BoxReference`[] ; `foreignApps`: `undefined` \| `number`[] = args.apps; `foreignAssets`: `undefined` \| `number`[] = args.assets; `lease`: `undefined` \| `Uint8Array` } #### Defined in -[src/app.ts:347](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L347) +[src/app.ts:511](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L511) ___ @@ -713,7 +791,7 @@ The current box names #### Defined in -[src/app.ts:244](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L244) +[src/app.ts:408](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L408) ___ @@ -743,7 +821,7 @@ The current box value as a byte array #### Defined in -[src/app.ts:262](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L262) +[src/app.ts:426](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L426) ___ @@ -768,7 +846,7 @@ The current box value as an ABI value #### Defined in -[src/app.ts:285](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L285) +[src/app.ts:449](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L449) ___ @@ -798,7 +876,7 @@ The current box values as a byte array in the same order as the passed in box na #### Defined in -[src/app.ts:275](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L275) +[src/app.ts:439](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L439) ___ @@ -823,7 +901,7 @@ The current box values as an ABI value in the same order as the passed in box na #### Defined in -[src/app.ts:297](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L297) +[src/app.ts:461](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L461) ___ @@ -848,7 +926,7 @@ The data about the app #### Defined in -[src/app.ts:432](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L432) +[src/app.ts:570](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L570) ___ @@ -878,7 +956,7 @@ The transaction note as a utf-8 string #### Defined in -[src/deploy-app.ts:484](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/deploy-app.ts#L484) +[src/deploy-app.ts:506](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/deploy-app.ts#L506) ___ @@ -903,7 +981,7 @@ The current global state #### Defined in -[src/app.ts:210](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L210) +[src/app.ts:374](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L374) ___ @@ -929,7 +1007,7 @@ The current local state for the given (app, account) combination #### Defined in -[src/app.ts:227](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L227) +[src/app.ts:391](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L391) ___ @@ -958,6 +1036,34 @@ The application client ___ +### getAtomicTransactionComposerTransactions + +▸ **getAtomicTransactionComposerTransactions**(`atc`): `TransactionWithSigner`[] + +Returns the array of transactions currently present in the given + +**`See`** + +AtomicTransactionComposer + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `atc` | `AtomicTransactionComposer` | The atomic transaction composer | + +#### Returns + +`TransactionWithSigner`[] + +The array of transactions with signers + +#### Defined in + +[src/transaction.ts:344](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L344) + +___ + ### getCreatorAppsByName ▸ **getCreatorAppsByName**(`creatorAccount`, `indexer`): `Promise`<[`AppLookup`](../interfaces/types_app.AppLookup.md)\> @@ -985,7 +1091,7 @@ A name-based lookup of the app information (id, address) #### Defined in -[src/deploy-app.ts:388](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/deploy-app.ts#L388) +[src/deploy-app.ts:410](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/deploy-app.ts#L410) ___ @@ -1182,7 +1288,36 @@ The public address #### Defined in -[src/transaction.ts:48](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L48) +[src/transaction.ts:49](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L49) + +___ + +### getSenderTransactionSigner + +▸ **getSenderTransactionSigner**(`val`): `TransactionSigner` + +Returns a + +**`See`** + +TransactionSigner for the given transaction sender. +This function has memoization, so will return the same transaction signer for a given sender. + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `val` | [`SendTransactionFrom`](types_transaction.md#sendtransactionfrom) | + +#### Returns + +`TransactionSigner` + +A transaction signer + +#### Defined in + +[src/transaction.ts:59](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L59) ___ @@ -1207,7 +1342,7 @@ The suggested transaction parameters #### Defined in -[src/transaction.ts:310](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L310) +[src/transaction.ts:335](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L335) ___ @@ -1256,7 +1391,7 @@ Whether or not there is a breaking change #### Defined in -[src/deploy-app.ts:375](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/deploy-app.ts#L375) +[src/deploy-app.ts:397](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/deploy-app.ts#L397) ___ @@ -1412,7 +1547,7 @@ The TEAL code with replacements #### Defined in -[src/deploy-app.ts:533](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/deploy-app.ts#L533) +[src/deploy-app.ts:555](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/deploy-app.ts#L555) ___ @@ -1441,7 +1576,7 @@ The information about the compiled code #### Defined in -[src/deploy-app.ts:563](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/deploy-app.ts#L563) +[src/deploy-app.ts:585](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/deploy-app.ts#L585) ___ @@ -1520,7 +1655,7 @@ The replaced TEAL code #### Defined in -[src/deploy-app.ts:502](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/deploy-app.ts#L502) +[src/deploy-app.ts:524](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/deploy-app.ts#L524) ___ @@ -1552,9 +1687,40 @@ The search results ___ +### sendAtomicTransactionComposer + +▸ **sendAtomicTransactionComposer**(`atcSend`, `algod`): `Promise`<{ `confirmations`: `undefined` \| [`PendingTransactionResponse`](../interfaces/types_algod.PendingTransactionResponse.md)[] ; `groupId`: `undefined` \| `string` ; `returns`: [`ABIReturn`](types_app.md#abireturn)[] ; `transactions`: `Transaction`[] = transactionsToSend; `txIds`: `string`[] }\> + +Signs and sends transactions that have been collected by an + +**`See`** + + - AtomicTransactionComposer. + - AtomicTransactionComposer + * `sendParams` The parameters to control the send behaviour + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `atcSend` | [`AtomicTransactionComposerToSend`](../interfaces/types_transaction.AtomicTransactionComposerToSend.md) | The parameters controlling the send, including: * `atc` The | +| `algod` | `default` | An algod client | + +#### Returns + +`Promise`<{ `confirmations`: `undefined` \| [`PendingTransactionResponse`](../interfaces/types_algod.PendingTransactionResponse.md)[] ; `groupId`: `undefined` \| `string` ; `returns`: [`ABIReturn`](types_app.md#abireturn)[] ; `transactions`: `Transaction`[] = transactionsToSend; `txIds`: `string`[] }\> + +An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`) + +#### Defined in + +[src/transaction.ts:137](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L137) + +___ + ### sendGroupOfTransactions -▸ **sendGroupOfTransactions**(`groupSend`, `algod`): `Promise`<{ `confirmations`: `undefined` \| [`PendingTransactionResponse`](../interfaces/types_algod.PendingTransactionResponse.md)[] ; `groupId`: `string` ; `txIds`: `string`[] }\> +▸ **sendGroupOfTransactions**(`groupSend`, `algod`): `Promise`<{ `confirmations`: `undefined` \| [`PendingTransactionResponse`](../interfaces/types_algod.PendingTransactionResponse.md)[] ; `groupId`: `undefined` \| `string` ; `returns`: [`ABIReturn`](types_app.md#abireturn)[] ; `transactions`: `Transaction`[] = transactionsToSend; `txIds`: `string`[] }\> Signs and sends a group of [up to 16](https://developer.algorand.org/docs/get-details/atomic_transfers/#create-transactions) transactions to the chain @@ -1567,13 +1733,13 @@ Signs and sends a group of [up to 16](https://developer.algorand.org/docs/get-de #### Returns -`Promise`<{ `confirmations`: `undefined` \| [`PendingTransactionResponse`](../interfaces/types_algod.PendingTransactionResponse.md)[] ; `groupId`: `string` ; `txIds`: `string`[] }\> +`Promise`<{ `confirmations`: `undefined` \| [`PendingTransactionResponse`](../interfaces/types_algod.PendingTransactionResponse.md)[] ; `groupId`: `undefined` \| `string` ; `returns`: [`ABIReturn`](types_app.md#abireturn)[] ; `transactions`: `Transaction`[] = transactionsToSend; `txIds`: `string`[] }\> -An object with group transaction ID (`groupTransactionId`) and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`) +An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`) #### Defined in -[src/transaction.ts:121](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L121) +[src/transaction.ts:197](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L197) ___ @@ -1581,13 +1747,13 @@ ___ ▸ **sendTransaction**(`send`, `algod`): `Promise`<[`SendTransactionResult`](../interfaces/types_transaction.SendTransactionResult.md)\> -Signs and sends the given transaction to the chain +Prepares a transaction for sending and then (if instructed) signs and sends the given transaction to the chain. #### Parameters | Name | Type | Description | | :------ | :------ | :------ | -| `send` | `Object` | The details for the transaction to send, including: * `transaction`: The unsigned transaction * `from`: The account to sign the transaction with: either an account with private key loaded or a logic signature account * `config`: The sending configuration for this transaction | +| `send` | `Object` | The details for the transaction to prepare/send, including: * `transaction`: The unsigned transaction * `from`: The account to sign the transaction with: either an account with private key loaded or a logic signature account * `config`: The sending configuration for this transaction | | `send.from` | [`SendTransactionFrom`](types_transaction.md#sendtransactionfrom) | - | | `send.sendParams?` | [`SendTransactionParams`](../interfaces/types_transaction.SendTransactionParams.md) | - | | `send.transaction` | `Transaction` | - | @@ -1597,11 +1763,11 @@ Signs and sends the given transaction to the chain `Promise`<[`SendTransactionResult`](../interfaces/types_transaction.SendTransactionResult.md)\> -An object with transaction (`transaction`) and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`) +An object with transaction (`transaction`) and (if `skipWaiting` is `false` or `undefined`) confirmation (`confirmation`) #### Defined in -[src/transaction.ts:62](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L62) +[src/transaction.ts:86](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L86) ___ @@ -1706,7 +1872,7 @@ The transaction #### Defined in -[src/app.ts:94](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L94) +[src/app.ts:172](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/app.ts#L172) ___ @@ -1737,4 +1903,4 @@ Pending transaction information #### Defined in -[src/transaction.ts:239](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L239) +[src/transaction.ts:242](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/transaction.ts#L242) diff --git a/docs/code/modules/types_app.md b/docs/code/modules/types_app.md index 9ff8c35b..131d0d37 100644 --- a/docs/code/modules/types_app.md +++ b/docs/code/modules/types_app.md @@ -54,7 +54,7 @@ #### Defined in -[src/types/app.ts:59](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L59) +[src/types/app.ts:60](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L60) ___ @@ -66,7 +66,7 @@ The return value of an ABI method 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:168](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L168) ___ @@ -80,7 +80,7 @@ Arguments to pass to an app call either: #### Defined in -[src/types/app.ts:82](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L82) +[src/types/app.ts:83](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L83) ## Variables @@ -92,7 +92,7 @@ First 4 bytes of SHA-512/256 hash of "return" for retrieving ABI return values #### Defined in -[src/types/app.ts:17](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L17) +[src/types/app.ts:18](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L18) ___ @@ -104,7 +104,7 @@ The app create/update ARC-2 transaction note prefix #### Defined in -[src/types/app.ts:11](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L11) +[src/types/app.ts:12](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L12) ___ @@ -116,7 +116,7 @@ The maximum number of bytes in a single app code page #### Defined in -[src/types/app.ts:14](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L14) +[src/types/app.ts:15](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L15) ___ @@ -128,7 +128,7 @@ The name of the TEAL template variable for deploy-time permanence control #### Defined in -[src/types/app.ts:8](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L8) +[src/types/app.ts:9](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L9) ___ @@ -140,4 +140,4 @@ The name of the TEAL template variable for deploy-time immutability control #### Defined in -[src/types/app.ts:5](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L5) +[src/types/app.ts:6](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/app.ts#L6) diff --git a/docs/code/modules/types_transaction.md b/docs/code/modules/types_transaction.md index 0b0ab446..a0658978 100644 --- a/docs/code/modules/types_transaction.md +++ b/docs/code/modules/types_transaction.md @@ -6,7 +6,9 @@ ### Interfaces +- [AtomicTransactionComposerToSend](../interfaces/types_transaction.AtomicTransactionComposerToSend.md) - [ConfirmedTransactionResult](../interfaces/types_transaction.ConfirmedTransactionResult.md) +- [ConfirmedTransactionResults](../interfaces/types_transaction.ConfirmedTransactionResults.md) - [SendTransactionParams](../interfaces/types_transaction.SendTransactionParams.md) - [SendTransactionResult](../interfaces/types_transaction.SendTransactionResult.md) - [TransactionGroupToSend](../interfaces/types_transaction.TransactionGroupToSend.md) @@ -43,7 +45,7 @@ ___ #### Defined in -[src/types/transaction.ts:53](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L53) +[src/types/transaction.ts:65](https://github.com/algorandfoundation/algokit-utils-ts/blob/main/src/types/transaction.ts#L65) ___