@algorandfoundation/algokit-utils 9.0.1 → 9.0.2-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.mjs","sources":["../../src/transaction/transaction.ts"],"sourcesContent":["import algosdk, { Address, ApplicationTransactionFields, TransactionBoxReference, TransactionType, stringifyJSON } from 'algosdk'\nimport { Buffer } from 'buffer'\nimport { Config } from '../config'\nimport { AlgoAmount } from '../types/amount'\nimport { ABIReturn } from '../types/app'\nimport { EventType } from '../types/lifecycle-events'\nimport {\n AdditionalAtomicTransactionComposerContext,\n AtomicTransactionComposerToSend,\n SendAtomicTransactionComposerResults,\n SendParams,\n SendTransactionFrom,\n SendTransactionParams,\n SendTransactionResult,\n TransactionGroupToSend,\n TransactionNote,\n TransactionToSign,\n} from '../types/transaction'\nimport { asJson, toNumber } from '../util'\nimport { performAtomicTransactionComposerSimulate } from './perform-atomic-transaction-composer-simulate'\nimport Algodv2 = algosdk.Algodv2\nimport AtomicTransactionComposer = algosdk.AtomicTransactionComposer\nimport modelsv2 = algosdk.modelsv2\nimport SuggestedParams = algosdk.SuggestedParams\nimport Transaction = algosdk.Transaction\nimport TransactionSigner = algosdk.TransactionSigner\nimport TransactionWithSigner = algosdk.TransactionWithSigner\nimport ABIValue = algosdk.ABIValue\nimport ABIType = algosdk.ABIType\n\nexport const MAX_TRANSACTION_GROUP_SIZE = 16\nexport const MAX_APP_CALL_FOREIGN_REFERENCES = 8\nexport const MAX_APP_CALL_ACCOUNT_REFERENCES = 4\n\n/**\n * @deprecated Convert your data to a `string` or `Uint8Array`, if using ARC-2 use `TransactionComposer.arc2Note`.\n *\n * Encodes a transaction note into a byte array ready to be included in an Algorand transaction.\n *\n * @param note The transaction note\n * @returns the transaction note ready for inclusion in a transaction\n *\n * Case on the value of `data` this either be:\n * * `null` | `undefined`: `undefined`\n * * `string`: The string value\n * * Uint8Array: passthrough\n * * Arc2TransactionNote object: ARC-0002 compatible transaction note\n * * Else: The object/value converted into a JSON string representation\n */\nexport function encodeTransactionNote(note?: TransactionNote): Uint8Array | undefined {\n if (note == null || typeof note === 'undefined') {\n return undefined\n } else if (typeof note === 'object' && note.constructor === Uint8Array) {\n return note\n } else if (typeof note === 'object' && 'dAppName' in note) {\n const arc2Payload = `${note.dAppName}:${note.format}${typeof note.data === 'string' ? note.data : asJson(note.data)}`\n const encoder = new TextEncoder()\n return encoder.encode(arc2Payload)\n } else {\n const n = typeof note === 'string' ? note : asJson(note)\n const encoder = new TextEncoder()\n return encoder.encode(n)\n }\n}\n\n/** Encodes a transaction lease into a 32-byte array ready to be included in an Algorand transaction.\n *\n * @param lease The transaction lease as a string or binary array or null/undefined if there is no lease\n * @returns the transaction lease ready for inclusion in a transaction or `undefined` if there is no lease\n * @throws if the length of the data is > 32 bytes or empty\n * @example algokit.encodeLease('UNIQUE_ID')\n * @example algokit.encodeLease(new Uint8Array([1, 2, 3]))\n */\nexport function encodeLease(lease?: string | Uint8Array): Uint8Array | undefined {\n if (lease === null || typeof lease === 'undefined') {\n return undefined\n } else if (typeof lease === 'object' && lease.constructor === Uint8Array) {\n if (lease.length === 0 || lease.length > 32) {\n throw new Error(\n `Received invalid lease; expected something with length between 1 and 32, but received bytes with length ${lease.length}`,\n )\n }\n if (lease.length === 32) return lease\n const lease32 = new Uint8Array(32)\n lease32.set(lease, 0)\n return lease32\n } else if (typeof lease === 'string') {\n if (lease.length === 0 || lease.length > 32) {\n throw new Error(\n `Received invalid lease; expected something with length between 1 and 32, but received '${lease}' with length ${lease.length}`,\n )\n }\n const encoder = new TextEncoder()\n const lease32 = new Uint8Array(32)\n lease32.set(encoder.encode(lease), 0)\n return lease32\n } else {\n throw new Error(`Unknown lease type received of ${typeof lease}`)\n }\n}\n\n/**\n * @deprecated Use `algorand.client` to interact with accounts, and use `.addr` to get the address\n * and/or move from using `SendTransactionFrom` to `TransactionSignerAccount` and use `.addr` instead.\n *\n * Returns the public address of the given transaction sender.\n * @param sender A transaction sender\n * @returns The public address\n */\nexport const getSenderAddress = function (sender: string | SendTransactionFrom): string {\n return typeof sender === 'string' ? sender : 'addr' in sender ? sender.addr.toString() : sender.address().toString()\n}\n\n/**\n * @deprecated Use `AlgorandClient` / `TransactionComposer` to construct transactions instead or\n * construct an `algosdk.TransactionWithSigner` manually instead.\n *\n * Given a transaction in a variety of supported formats, returns a TransactionWithSigner object ready to be passed to an\n * AtomicTransactionComposer's addTransaction method.\n * @param transaction One of: A TransactionWithSigner object (returned as is), a TransactionToSign object (signer is obtained from the\n * signer property), a Transaction object (signer is extracted from the defaultSender parameter), an async SendTransactionResult returned by\n * one of algokit utils' helpers (signer is obtained from the defaultSender parameter)\n * @param defaultSender The default sender to be used to obtain a signer where the object provided to the transaction parameter does not\n * include a signer.\n * @returns A TransactionWithSigner object.\n */\nexport const getTransactionWithSigner = async (\n transaction: TransactionWithSigner | TransactionToSign | Transaction | Promise<SendTransactionResult>,\n defaultSender?: SendTransactionFrom,\n): Promise<TransactionWithSigner> => {\n if ('txn' in transaction) return transaction\n if (defaultSender === undefined)\n throw new Error('Default sender must be provided when passing in a transaction object that does not contain its own signer')\n return transaction instanceof Promise\n ? {\n txn: (await transaction).transaction,\n signer: getSenderTransactionSigner(defaultSender),\n }\n : 'transaction' in transaction\n ? {\n txn: transaction.transaction,\n signer: getSenderTransactionSigner(transaction.signer),\n }\n : {\n txn: transaction,\n signer: getSenderTransactionSigner(defaultSender),\n }\n}\n\nconst memoize = <T = unknown, R = unknown>(fn: (val: T) => R) => {\n const cache = new Map()\n const cached = function (this: unknown, val: T) {\n return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val)\n }\n cached.cache = cache\n return cached as (val: T) => R\n}\n\n/**\n * @deprecated Use `TransactionSignerAccount` instead of `SendTransactionFrom` or use\n * `algosdk.makeBasicAccountTransactionSigner` / `algosdk.makeLogicSigAccountTransactionSigner`.\n *\n * Returns a `TransactionSigner` for the given transaction sender.\n * This function has memoization, so will return the same transaction signer for a given sender.\n * @param sender A transaction sender\n * @returns A transaction signer\n */\nexport const getSenderTransactionSigner = memoize(function (sender: SendTransactionFrom): TransactionSigner {\n return 'signer' in sender\n ? sender.signer\n : 'lsig' in sender\n ? algosdk.makeLogicSigAccountTransactionSigner(sender)\n : algosdk.makeBasicAccountTransactionSigner(sender)\n})\n\n/**\n * @deprecated Use `AlgorandClient` / `TransactionComposer` to sign transactions\n * or use the relevant underlying `account.signTxn` / `algosdk.signLogicSigTransactionObject`\n * / `multiSigAccount.sign` / `TransactionSigner` methods directly.\n *\n * Signs a single transaction by the given signer.\n * @param transaction The transaction to sign\n * @param signer The signer to sign\n * @returns The signed transaction as a `Uint8Array`\n */\nexport const signTransaction = async (transaction: Transaction, signer: SendTransactionFrom) => {\n return 'sk' in signer\n ? transaction.signTxn(signer.sk)\n : 'lsig' in signer\n ? algosdk.signLogicSigTransactionObject(transaction, signer).blob\n : 'sign' in signer\n ? signer.sign(transaction)\n : (await signer.signer([transaction], [0]))[0]\n}\n\n/**\n * @deprecated Use `AlgorandClient` / `TransactionComposer` to send transactions.\n *\n * Prepares a transaction for sending and then (if instructed) signs and sends the given transaction to the chain.\n *\n * @param send The details for the transaction to prepare/send, including:\n * * `transaction`: The unsigned transaction\n * * `from`: The account to sign the transaction with: either an account with private key loaded or a logic signature account\n * * `config`: The sending configuration for this transaction\n * @param algod An algod client\n *\n * @returns An object with transaction (`transaction`) and (if `skipWaiting` is `false` or `undefined`) confirmation (`confirmation`)\n */\nexport const sendTransaction = async function (\n send: {\n transaction: Transaction\n from: SendTransactionFrom\n sendParams?: SendTransactionParams\n },\n algod: Algodv2,\n): Promise<SendTransactionResult> {\n const { transaction, from, sendParams } = send\n const { skipSending, skipWaiting, fee, maxFee, suppressLog, maxRoundsToWaitForConfirmation, atc } = sendParams ?? {}\n\n controlFees(transaction, { fee, maxFee })\n\n if (atc) {\n atc.addTransaction({ txn: transaction, signer: getSenderTransactionSigner(from) })\n return { transaction }\n }\n\n if (skipSending) {\n return { transaction }\n }\n\n let txnToSend = transaction\n\n const populateAppCallResources = sendParams?.populateAppCallResources ?? Config.populateAppCallResources\n\n // Populate resources if the transaction is an appcall and populateAppCallResources wasn't explicitly set to false\n if (txnToSend.type === algosdk.TransactionType.appl && populateAppCallResources) {\n const newAtc = new AtomicTransactionComposer()\n newAtc.addTransaction({ txn: txnToSend, signer: getSenderTransactionSigner(from) })\n const atc = await prepareGroupForSending(newAtc, algod, { ...sendParams, populateAppCallResources })\n txnToSend = atc.buildGroup()[0].txn\n }\n\n const signedTransaction = await signTransaction(txnToSend, from)\n\n await algod.sendRawTransaction(signedTransaction).do()\n\n Config.getLogger(suppressLog).verbose(`Sent transaction ID ${txnToSend.txID()} ${txnToSend.type} from ${getSenderAddress(from)}`)\n\n let confirmation: modelsv2.PendingTransactionResponse | undefined = undefined\n if (!skipWaiting) {\n confirmation = await waitForConfirmation(txnToSend.txID(), maxRoundsToWaitForConfirmation ?? 5, algod)\n }\n\n return { transaction: txnToSend, confirmation }\n}\n\n/**\n * Get the execution info of a transaction group for the given ATC\n * The function uses the simulate endpoint and depending on the sendParams can return the following:\n * - The unnamed resources accessed by the group\n * - The unnamed resources accessed by each transaction in the group\n * - The required fee delta for each transaction in the group. A positive value indicates a fee deficit, a negative value indicates a surplus.\n *\n * @param atc The ATC containing the txn group\n * @param algod The algod client to use for the simulation\n * @param sendParams The send params for the transaction group\n * @param additionalAtcContext Additional ATC context used to determine how best to alter transactions in the group\n * @returns The execution info for the group\n */\nasync function getGroupExecutionInfo(\n atc: algosdk.AtomicTransactionComposer,\n algod: algosdk.Algodv2,\n sendParams: SendParams,\n additionalAtcContext?: AdditionalAtomicTransactionComposerContext,\n) {\n const simulateRequest = new algosdk.modelsv2.SimulateRequest({\n txnGroups: [],\n allowUnnamedResources: true,\n allowEmptySignatures: true,\n fixSigners: true,\n })\n\n const nullSigner = algosdk.makeEmptyTransactionSigner()\n\n const emptySignerAtc = atc.clone()\n\n const appCallIndexesWithoutMaxFees: number[] = []\n emptySignerAtc['transactions'].forEach((t: algosdk.TransactionWithSigner, i: number) => {\n t.signer = nullSigner\n\n if (sendParams.coverAppCallInnerTransactionFees && t.txn.type === TransactionType.appl) {\n if (!additionalAtcContext?.suggestedParams) {\n throw Error(`Please provide additionalAtcContext.suggestedParams when coverAppCallInnerTransactionFees is enabled`)\n }\n\n const maxFee = additionalAtcContext?.maxFees?.get(i)?.microAlgo\n if (maxFee === undefined) {\n appCallIndexesWithoutMaxFees.push(i)\n } else {\n t.txn.fee = maxFee\n }\n }\n })\n\n if (sendParams.coverAppCallInnerTransactionFees && appCallIndexesWithoutMaxFees.length > 0) {\n throw Error(\n `Please provide a maxFee for each app call transaction when coverAppCallInnerTransactionFees is enabled. Required for transaction ${appCallIndexesWithoutMaxFees.join(', ')}`,\n )\n }\n\n const perByteTxnFee = BigInt(additionalAtcContext?.suggestedParams.fee ?? 0n)\n const minTxnFee = BigInt(additionalAtcContext?.suggestedParams.minFee ?? 1000n)\n\n const result = await emptySignerAtc.simulate(algod, simulateRequest)\n\n const groupResponse = result.simulateResponse.txnGroups[0]\n\n if (groupResponse.failureMessage) {\n if (sendParams.coverAppCallInnerTransactionFees && groupResponse.failureMessage.match(/fee too small/)) {\n throw Error(`Fees were too small to resolve execution info via simulate. You may need to increase an app call transaction maxFee.`)\n }\n\n throw Error(`Error resolving execution info via simulate in transaction ${groupResponse.failedAt}: ${groupResponse.failureMessage}`)\n }\n\n return {\n groupUnnamedResourcesAccessed: sendParams.populateAppCallResources ? groupResponse.unnamedResourcesAccessed : undefined,\n txns: groupResponse.txnResults.map((txn, i) => {\n const originalTxn = atc['transactions'][i].txn as algosdk.Transaction\n\n let requiredFeeDelta = 0n\n if (sendParams.coverAppCallInnerTransactionFees) {\n // Min fee calc is lifted from algosdk https://github.com/algorand/js-algorand-sdk/blob/6973ff583b243ddb0632e91f4c0383021430a789/src/transaction.ts#L710\n // 75 is the number of bytes added to a txn after signing it\n const parentPerByteFee = perByteTxnFee * BigInt(originalTxn.toByte().length + 75)\n const parentMinFee = parentPerByteFee < minTxnFee ? minTxnFee : parentPerByteFee\n const parentFeeDelta = parentMinFee - originalTxn.fee\n if (originalTxn.type === TransactionType.appl) {\n const calculateInnerFeeDelta = (itxns: algosdk.modelsv2.PendingTransactionResponse[], acc: bigint = 0n): bigint => {\n // Surplus inner transaction fees do not pool up to the parent transaction.\n // Additionally surplus inner transaction fees only pool from sibling transactions that are sent prior to a given inner transaction, hence why we iterate in reverse order.\n return itxns.reverse().reduce((acc, itxn) => {\n const currentFeeDelta =\n (itxn.innerTxns && itxn.innerTxns.length > 0 ? calculateInnerFeeDelta(itxn.innerTxns, acc) : acc) +\n (minTxnFee - itxn.txn.txn.fee) // Inner transactions don't require per byte fees\n return currentFeeDelta < 0n ? 0n : currentFeeDelta\n }, acc)\n }\n\n const innerFeeDelta = calculateInnerFeeDelta(txn.txnResult.innerTxns ?? [])\n requiredFeeDelta = innerFeeDelta + parentFeeDelta\n } else {\n requiredFeeDelta = parentFeeDelta\n }\n }\n\n return {\n unnamedResourcesAccessed: sendParams.populateAppCallResources ? txn.unnamedResourcesAccessed : undefined,\n requiredFeeDelta,\n }\n }),\n }\n}\n\n/**\n * Take an existing Atomic Transaction Composer and return a new one with the required\n * app call resources populated into it\n *\n * @param algod The algod client to use for the simulation\n * @param atc The ATC containing the txn group\n * @returns A new ATC with the resources populated into the transactions\n *\n * @privateRemarks\n *\n * This entire function will eventually be implemented in simulate upstream in algod. The simulate endpoint will return\n * an array of refference arrays for each transaction, so this eventually will eventually just call simulate and set the\n * reference arrays in the transactions to the reference arrays returned by simulate.\n *\n * See https://github.com/algorand/go-algorand/pull/5684\n *\n */\nexport async function populateAppCallResources(atc: algosdk.AtomicTransactionComposer, algod: algosdk.Algodv2) {\n return await prepareGroupForSending(atc, algod, { populateAppCallResources: true })\n}\n\n/**\n * Take an existing Atomic Transaction Composer and return a new one with changes applied to the transactions\n * based on the supplied sendParams to prepare it for sending.\n * Please note, that before calling `.execute()` on the returned ATC, you must call `.buildGroup()`.\n *\n * @param algod The algod client to use for the simulation\n * @param atc The ATC containing the txn group\n * @param sendParams The send params for the transaction group\n * @param additionalAtcContext Additional ATC context used to determine how best to change the transactions in the group\n * @returns A new ATC with the changes applied\n *\n * @privateRemarks\n * Parts of this function will eventually be implemented in algod. Namely:\n * - Simulate will return information on how to populate reference arrays, see https://github.com/algorand/go-algorand/pull/6015\n */\nexport async function prepareGroupForSending(\n atc: algosdk.AtomicTransactionComposer,\n algod: algosdk.Algodv2,\n sendParams: SendParams,\n additionalAtcContext?: AdditionalAtomicTransactionComposerContext,\n) {\n const executionInfo = await getGroupExecutionInfo(atc, algod, sendParams, additionalAtcContext)\n const group = atc.buildGroup()\n\n const [_, additionalTransactionFees] = sendParams.coverAppCallInnerTransactionFees\n ? executionInfo.txns\n .map((txn, i) => {\n const groupIndex = i\n const txnInGroup = group[groupIndex].txn\n const maxFee = additionalAtcContext?.maxFees?.get(i)?.microAlgo\n const immutableFee = maxFee !== undefined && maxFee === txnInGroup.fee\n // Because we don't alter non app call transaction, they take priority\n const priorityMultiplier =\n txn.requiredFeeDelta > 0n && (immutableFee || txnInGroup.type !== algosdk.TransactionType.appl) ? 1_000n : 1n\n\n return {\n ...txn,\n groupIndex,\n // Measures the priority level of covering the transaction fee using the surplus group fees. The higher the number, the higher the priority.\n surplusFeePriorityLevel: txn.requiredFeeDelta > 0n ? txn.requiredFeeDelta * priorityMultiplier : -1n,\n }\n })\n .sort((a, b) => {\n return a.surplusFeePriorityLevel > b.surplusFeePriorityLevel ? -1 : a.surplusFeePriorityLevel < b.surplusFeePriorityLevel ? 1 : 0\n })\n .reduce(\n (acc, { groupIndex, requiredFeeDelta }) => {\n if (requiredFeeDelta > 0n) {\n // There is a fee deficit on the transaction\n let surplusGroupFees = acc[0]\n const additionalTransactionFees = acc[1]\n const additionalFeeDelta = requiredFeeDelta - surplusGroupFees\n if (additionalFeeDelta <= 0n) {\n // The surplus group fees fully cover the required fee delta\n surplusGroupFees = -additionalFeeDelta\n } else {\n // The surplus group fees do not fully cover the required fee delta, use what is available\n additionalTransactionFees.set(groupIndex, additionalFeeDelta)\n surplusGroupFees = 0n\n }\n return [surplusGroupFees, additionalTransactionFees] as const\n }\n return acc\n },\n [\n executionInfo.txns.reduce((acc, { requiredFeeDelta }) => {\n if (requiredFeeDelta < 0n) {\n return acc + -requiredFeeDelta\n }\n return acc\n }, 0n),\n new Map<number, bigint>(),\n ] as const,\n )\n : [0n, new Map<number, bigint>()]\n\n executionInfo.txns.forEach(({ unnamedResourcesAccessed: r }, i) => {\n // Populate Transaction App Call Resources\n if (sendParams.populateAppCallResources && r !== undefined && group[i].txn.type === TransactionType.appl) {\n if (r.boxes || r.extraBoxRefs) throw Error('Unexpected boxes at the transaction level')\n if (r.appLocals) throw Error('Unexpected app local at the transaction level')\n if (r.assetHoldings)\n throw Error('Unexpected asset holding at the transaction level')\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(group[i].txn as any)['applicationCall'] = {\n ...group[i].txn.applicationCall,\n accounts: [...(group[i].txn?.applicationCall?.accounts ?? []), ...(r.accounts ?? [])],\n foreignApps: [...(group[i].txn?.applicationCall?.foreignApps ?? []), ...(r.apps ?? [])],\n foreignAssets: [...(group[i].txn?.applicationCall?.foreignAssets ?? []), ...(r.assets ?? [])],\n boxes: [...(group[i].txn?.applicationCall?.boxes ?? []), ...(r.boxes ?? [])],\n } satisfies Partial<ApplicationTransactionFields>\n\n const accounts = group[i].txn.applicationCall?.accounts?.length ?? 0\n if (accounts > MAX_APP_CALL_ACCOUNT_REFERENCES)\n throw Error(`Account reference limit of ${MAX_APP_CALL_ACCOUNT_REFERENCES} exceeded in transaction ${i}`)\n const assets = group[i].txn.applicationCall?.foreignAssets?.length ?? 0\n const apps = group[i].txn.applicationCall?.foreignApps?.length ?? 0\n const boxes = group[i].txn.applicationCall?.boxes?.length ?? 0\n if (accounts + assets + apps + boxes > MAX_APP_CALL_FOREIGN_REFERENCES) {\n throw Error(`Resource reference limit of ${MAX_APP_CALL_FOREIGN_REFERENCES} exceeded in transaction ${i}`)\n }\n }\n\n // Cover App Call Inner Transaction Fees\n if (sendParams.coverAppCallInnerTransactionFees) {\n const additionalTransactionFee = additionalTransactionFees.get(i)\n\n if (additionalTransactionFee !== undefined) {\n if (group[i].txn.type !== algosdk.TransactionType.appl) {\n throw Error(`An additional fee of ${additionalTransactionFee} µALGO is required for non app call transaction ${i}`)\n }\n const transactionFee = group[i].txn.fee + additionalTransactionFee\n const maxFee = additionalAtcContext?.maxFees?.get(i)?.microAlgo\n if (maxFee === undefined || transactionFee > maxFee) {\n throw Error(\n `Calculated transaction fee ${transactionFee} µALGO is greater than max of ${maxFee ?? 'undefined'} for transaction ${i}`,\n )\n }\n group[i].txn.fee = transactionFee\n }\n }\n })\n\n // Populate Group App Call Resources\n if (sendParams.populateAppCallResources) {\n const populateGroupResource = (\n txns: algosdk.TransactionWithSigner[],\n reference:\n | string\n | algosdk.modelsv2.BoxReference\n | algosdk.modelsv2.ApplicationLocalReference\n | algosdk.modelsv2.AssetHoldingReference\n | bigint\n | number\n | Address,\n type: 'account' | 'assetHolding' | 'appLocal' | 'app' | 'box' | 'asset',\n ): void => {\n const isApplBelowLimit = (t: algosdk.TransactionWithSigner) => {\n if (t.txn.type !== algosdk.TransactionType.appl) return false\n\n const accounts = t.txn.applicationCall?.accounts?.length ?? 0\n const assets = t.txn.applicationCall?.foreignAssets?.length ?? 0\n const apps = t.txn.applicationCall?.foreignApps?.length ?? 0\n const boxes = t.txn.applicationCall?.boxes?.length ?? 0\n\n return accounts + assets + apps + boxes < MAX_APP_CALL_FOREIGN_REFERENCES\n }\n\n // If this is a asset holding or app local, first try to find a transaction that already has the account available\n if (type === 'assetHolding' || type === 'appLocal') {\n const { account } = reference as algosdk.modelsv2.ApplicationLocalReference | algosdk.modelsv2.AssetHoldingReference\n\n let txnIndex = txns.findIndex((t) => {\n if (!isApplBelowLimit(t)) return false\n\n return (\n // account is in the foreign accounts array\n t.txn.applicationCall?.accounts?.map((a) => a.toString()).includes(account.toString()) ||\n // account is available as an app account\n t.txn.applicationCall?.foreignApps?.map((a) => algosdk.getApplicationAddress(a).toString()).includes(account.toString()) ||\n // account is available since it's in one of the fields\n Object.values(t.txn).some((f) =>\n stringifyJSON(f, (_, v) => (v instanceof Address ? v.toString() : v))?.includes(account.toString()),\n )\n )\n })\n\n if (txnIndex > -1) {\n if (type === 'assetHolding') {\n const { asset } = reference as algosdk.modelsv2.AssetHoldingReference\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n foreignAssets: [...(txns[txnIndex].txn?.applicationCall?.foreignAssets ?? []), ...[asset]],\n } satisfies Partial<ApplicationTransactionFields>\n } else {\n const { app } = reference as algosdk.modelsv2.ApplicationLocalReference\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n foreignApps: [...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []), ...[app]],\n } satisfies Partial<ApplicationTransactionFields>\n }\n return\n }\n\n // Now try to find a txn that already has that app or asset available\n txnIndex = txns.findIndex((t) => {\n if (!isApplBelowLimit(t)) return false\n\n // check if there is space in the accounts array\n if ((t.txn.applicationCall?.accounts?.length ?? 0) >= MAX_APP_CALL_ACCOUNT_REFERENCES) return false\n\n if (type === 'assetHolding') {\n const { asset } = reference as algosdk.modelsv2.AssetHoldingReference\n return t.txn.applicationCall?.foreignAssets?.includes(asset)\n } else {\n const { app } = reference as algosdk.modelsv2.ApplicationLocalReference\n return t.txn.applicationCall?.foreignApps?.includes(app) || t.txn.applicationCall?.appIndex === app\n }\n })\n\n if (txnIndex > -1) {\n const { account } = reference as algosdk.modelsv2.AssetHoldingReference | algosdk.modelsv2.ApplicationLocalReference\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[account]],\n } satisfies Partial<ApplicationTransactionFields>\n\n return\n }\n }\n\n // If this is a box, first try to find a transaction that already has the app available\n if (type === 'box') {\n const { app, name } = reference as algosdk.modelsv2.BoxReference\n\n const txnIndex = txns.findIndex((t) => {\n if (!isApplBelowLimit(t)) return false\n\n // If the app is in the foreign array OR the app being called, then we know it's available\n return t.txn.applicationCall?.foreignApps?.includes(app) || t.txn.applicationCall?.appIndex === app\n })\n\n if (txnIndex > -1) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n boxes: [...(txns[txnIndex].txn?.applicationCall?.boxes ?? []), ...[{ appIndex: app, name } satisfies TransactionBoxReference]],\n } satisfies Partial<ApplicationTransactionFields>\n\n return\n }\n }\n\n // Find the txn index to put the reference(s)\n const txnIndex = txns.findIndex((t) => {\n if (t.txn.type !== algosdk.TransactionType.appl) return false\n\n const accounts = t.txn.applicationCall?.accounts?.length ?? 0\n if (type === 'account') return accounts < MAX_APP_CALL_ACCOUNT_REFERENCES\n\n const assets = t.txn.applicationCall?.foreignAssets?.length ?? 0\n const apps = t.txn.applicationCall?.foreignApps?.length ?? 0\n const boxes = t.txn.applicationCall?.boxes?.length ?? 0\n\n // If we're adding local state or asset holding, we need space for the acocunt and the other reference\n if (type === 'assetHolding' || type === 'appLocal') {\n return accounts + assets + apps + boxes < MAX_APP_CALL_FOREIGN_REFERENCES - 1 && accounts < MAX_APP_CALL_ACCOUNT_REFERENCES\n }\n\n // If we're adding a box, we need space for both the box ref and the app ref\n if (type === 'box' && BigInt((reference as algosdk.modelsv2.BoxReference).app) !== BigInt(0)) {\n return accounts + assets + apps + boxes < MAX_APP_CALL_FOREIGN_REFERENCES - 1\n }\n\n return accounts + assets + apps + boxes < MAX_APP_CALL_FOREIGN_REFERENCES\n })\n\n if (txnIndex === -1) {\n throw Error('No more transactions below reference limit. Add another app call to the group.')\n }\n\n if (type === 'account') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[reference as Address]],\n } satisfies Partial<ApplicationTransactionFields>\n } else if (type === 'app') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n foreignApps: [\n ...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []),\n ...[typeof reference === 'bigint' ? reference : BigInt(reference as number)],\n ],\n } satisfies Partial<ApplicationTransactionFields>\n } else if (type === 'box') {\n const { app, name } = reference as algosdk.modelsv2.BoxReference\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n boxes: [...(txns[txnIndex].txn?.applicationCall?.boxes ?? []), ...[{ appIndex: app, name } satisfies TransactionBoxReference]],\n } satisfies Partial<ApplicationTransactionFields>\n\n if (app.toString() !== '0') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n foreignApps: [...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []), ...[app]],\n } satisfies Partial<ApplicationTransactionFields>\n }\n } else if (type === 'assetHolding') {\n const { asset, account } = reference as algosdk.modelsv2.AssetHoldingReference\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n foreignAssets: [...(txns[txnIndex].txn?.applicationCall?.foreignAssets ?? []), ...[asset]],\n accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[account]],\n } satisfies Partial<ApplicationTransactionFields>\n } else if (type === 'appLocal') {\n const { app, account } = reference as algosdk.modelsv2.ApplicationLocalReference\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n foreignApps: [...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []), ...[app]],\n accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[account]],\n } satisfies Partial<ApplicationTransactionFields>\n } else if (type === 'asset') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n foreignAssets: [\n ...(txns[txnIndex].txn?.applicationCall?.foreignAssets ?? []),\n ...[typeof reference === 'bigint' ? reference : BigInt(reference as number)],\n ],\n } satisfies Partial<ApplicationTransactionFields>\n }\n }\n\n const g = executionInfo.groupUnnamedResourcesAccessed\n\n if (g) {\n // Do cross-reference resources first because they are the most restrictive in terms\n // of which transactions can be used\n g.appLocals?.forEach((a) => {\n populateGroupResource(group, a, 'appLocal')\n\n // Remove resources from the group if we're adding them here\n g.accounts = g.accounts?.filter((acc) => acc !== a.account)\n g.apps = g.apps?.filter((app) => BigInt(app) !== BigInt(a.app))\n })\n\n g.assetHoldings?.forEach((a) => {\n populateGroupResource(group, a, 'assetHolding')\n\n // Remove resources from the group if we're adding them here\n g.accounts = g.accounts?.filter((acc) => acc !== a.account)\n g.assets = g.assets?.filter((asset) => BigInt(asset) !== BigInt(a.asset))\n })\n\n // Do accounts next because the account limit is 4\n g.accounts?.forEach((a) => {\n populateGroupResource(group, a, 'account')\n })\n\n g.boxes?.forEach((b) => {\n populateGroupResource(group, b, 'box')\n\n // Remove apps as resource from the group if we're adding it here\n g.apps = g.apps?.filter((app) => BigInt(app) !== BigInt(b.app))\n })\n\n g.assets?.forEach((a) => {\n populateGroupResource(group, a, 'asset')\n })\n\n g.apps?.forEach((a) => {\n populateGroupResource(group, a, 'app')\n })\n\n if (g.extraBoxRefs) {\n for (let i = 0; i < g.extraBoxRefs; i += 1) {\n const ref = new algosdk.modelsv2.BoxReference({ app: 0, name: new Uint8Array(0) })\n populateGroupResource(group, ref, 'box')\n }\n }\n }\n }\n\n const newAtc = new algosdk.AtomicTransactionComposer()\n\n group.forEach((t) => {\n t.txn.group = undefined\n newAtc.addTransaction(t)\n })\n\n newAtc['methodCalls'] = atc['methodCalls']\n return newAtc\n}\n\n/**\n * Signs and sends transactions that have been collected by an `AtomicTransactionComposer`.\n * @param atcSend The parameters controlling the send, including `atc` The `AtomicTransactionComposer` and params to control send behaviour\n * @param algod An algod client\n * @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`)\n */\nexport const sendAtomicTransactionComposer = async function (atcSend: AtomicTransactionComposerToSend, algod: Algodv2) {\n const { atc: givenAtc, sendParams, additionalAtcContext, ...executeParams } = atcSend\n\n let atc: AtomicTransactionComposer\n\n atc = givenAtc\n try {\n const transactionsWithSigner = atc.buildGroup()\n\n // If populateAppCallResources is true OR if populateAppCallResources is undefined and there are app calls, then populate resources\n const populateAppCallResources =\n executeParams?.populateAppCallResources ?? sendParams?.populateAppCallResources ?? Config.populateAppCallResources\n const coverAppCallInnerTransactionFees = executeParams?.coverAppCallInnerTransactionFees\n\n if (\n (populateAppCallResources || coverAppCallInnerTransactionFees) &&\n transactionsWithSigner.map((t) => t.txn.type).includes(algosdk.TransactionType.appl)\n ) {\n atc = await prepareGroupForSending(\n givenAtc,\n algod,\n { ...executeParams, populateAppCallResources, coverAppCallInnerTransactionFees },\n additionalAtcContext,\n )\n }\n\n // atc.buildGroup() is needed to ensure that any changes made by prepareGroupForSending are reflected and the group id is set\n const transactionsToSend = atc.buildGroup().map((t) => {\n return t.txn\n })\n let groupId: string | undefined = undefined\n if (transactionsToSend.length > 1) {\n groupId = transactionsToSend[0].group ? Buffer.from(transactionsToSend[0].group).toString('base64') : ''\n Config.getLogger(executeParams?.suppressLog ?? sendParams?.suppressLog).verbose(\n `Sending group of ${transactionsToSend.length} transactions (${groupId})`,\n {\n transactionsToSend,\n },\n )\n\n Config.getLogger(executeParams?.suppressLog ?? sendParams?.suppressLog).debug(\n `Transaction IDs (${groupId})`,\n transactionsToSend.map((t) => t.txID()),\n )\n }\n\n if (Config.debug && Config.traceAll) {\n // Emit the simulate response for use with AlgoKit AVM debugger\n const simulateResponse = await performAtomicTransactionComposerSimulate(atc, algod)\n await Config.events.emitAsync(EventType.TxnGroupSimulated, {\n simulateResponse,\n })\n }\n const result = await atc.execute(\n algod,\n executeParams?.maxRoundsToWaitForConfirmation ?? sendParams?.maxRoundsToWaitForConfirmation ?? 5,\n )\n\n if (transactionsToSend.length > 1) {\n Config.getLogger(executeParams?.suppressLog ?? sendParams?.suppressLog).verbose(\n `Group transaction (${groupId}) sent with ${transactionsToSend.length} transactions`,\n )\n } else {\n Config.getLogger(executeParams?.suppressLog ?? sendParams?.suppressLog).verbose(\n `Sent transaction ID ${transactionsToSend[0].txID()} ${transactionsToSend[0].type} from ${transactionsToSend[0].sender.toString()}`,\n )\n }\n\n let confirmations: modelsv2.PendingTransactionResponse[] | undefined = undefined\n if (!sendParams?.skipWaiting) {\n confirmations = await Promise.all(transactionsToSend.map(async (t) => await algod.pendingTransactionInformation(t.txID()).do()))\n }\n\n return {\n groupId,\n confirmations,\n txIds: transactionsToSend.map((t) => t.txID()),\n transactions: transactionsToSend,\n returns: result.methodResults.map(getABIReturnValue),\n } as SendAtomicTransactionComposerResults\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n // Create a new error object so the stack trace is correct (algosdk throws an error with a more limited stack trace)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const err = new Error(typeof e === 'object' ? e?.message : 'Received error executing Atomic Transaction Composer') as any as any\n err.cause = e\n if (typeof e === 'object') {\n // Remove headers as it doesn't have anything useful.\n delete e.response?.headers\n err.response = e.response\n // body property very noisy\n if (e.response && 'body' in e.response) delete err.response.body\n err.name = e.name\n }\n\n if (Config.debug && typeof e === 'object') {\n err.traces = []\n Config.getLogger(executeParams?.suppressLog ?? sendParams?.suppressLog).error(\n 'Received error executing Atomic Transaction Composer and debug flag enabled; attempting simulation to get more information',\n err,\n )\n const simulate = await performAtomicTransactionComposerSimulate(atc, algod)\n if (Config.debug && !Config.traceAll) {\n // Emit the event only if traceAll: false, as it should have already been emitted above\n await Config.events.emitAsync(EventType.TxnGroupSimulated, {\n simulateResponse: simulate,\n })\n }\n\n if (simulate && simulate.txnGroups[0].failedAt) {\n for (const txn of simulate.txnGroups[0].txnResults) {\n err.traces.push({\n trace: txn.execTrace?.toEncodingData(),\n appBudget: txn.appBudgetConsumed,\n logicSigBudget: txn.logicSigBudgetConsumed,\n logs: txn.txnResult.logs,\n message: simulate.txnGroups[0].failureMessage,\n })\n }\n }\n } else {\n Config.getLogger(executeParams?.suppressLog ?? sendParams?.suppressLog).error(\n 'Received error executing Atomic Transaction Composer, for more information enable the debug flag',\n err,\n )\n }\n throw err\n }\n}\n\nconst convertABIDecodedBigIntToNumber = (value: ABIValue, type: ABIType): ABIValue => {\n if (typeof value === 'bigint') {\n if (type instanceof algosdk.ABIUintType) {\n return type.bitSize < 53 ? Number(value) : value\n } else {\n return value\n }\n } else if (Array.isArray(value) && (type instanceof algosdk.ABIArrayStaticType || type instanceof algosdk.ABIArrayDynamicType)) {\n return value.map((v) => convertABIDecodedBigIntToNumber(v, type.childType))\n } else if (Array.isArray(value) && type instanceof algosdk.ABITupleType) {\n return value.map((v, i) => convertABIDecodedBigIntToNumber(v, type.childTypes[i]))\n } else {\n return value\n }\n}\n\n/**\n * Takes an algosdk `ABIResult` and converts it to an `ABIReturn`.\n * Converts `bigint`'s for Uint's < 64 to `number` for easier use.\n * @param result The `ABIReturn`\n */\nexport function getABIReturnValue(result: algosdk.ABIResult): ABIReturn {\n if (result.decodeError) {\n return {\n decodeError: result.decodeError,\n }\n }\n\n return {\n method: result.method,\n rawReturnValue: result.rawReturnValue,\n decodeError: undefined,\n returnValue:\n result.returnValue !== undefined && result.method.returns.type !== 'void'\n ? convertABIDecodedBigIntToNumber(result.returnValue, result.method.returns.type)\n : result.returnValue!,\n }\n}\n\n/**\n * @deprecated Use `TransactionComposer` (`algorand.newGroup()`) or `AtomicTransactionComposer` to construct and send group transactions instead.\n *\n * Signs and sends a group of [up to 16](https://dev.algorand.co/concepts/transactions/atomic-txn-groups/#create-transactions) transactions to the chain\n *\n * @param groupSend The group details to send, with:\n * * `transactions`: The array of transactions to send along with their signing account\n * * `sendParams`: The parameters to dictate how the group is sent\n * @param algod An algod client\n * @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`)\n */\nexport const sendGroupOfTransactions = async function (groupSend: TransactionGroupToSend, algod: Algodv2) {\n const { transactions, signer, sendParams } = groupSend\n\n const defaultTransactionSigner = signer ? getSenderTransactionSigner(signer) : undefined\n\n const transactionsWithSigner = await Promise.all(\n transactions.map(async (t) => {\n if ('signer' in t)\n return {\n txn: t.transaction,\n signer: getSenderTransactionSigner(t.signer),\n sender: t.signer,\n }\n\n const txn = 'then' in t ? (await t).transaction : t\n if (!signer) {\n throw new Error(`Attempt to send transaction ${txn.txID()} as part of a group transaction, but no signer parameter was provided.`)\n }\n\n return {\n txn,\n signer: defaultTransactionSigner!,\n sender: signer,\n }\n }),\n )\n\n const atc = new AtomicTransactionComposer()\n transactionsWithSigner.forEach((txn) => atc.addTransaction(txn))\n\n return (await sendAtomicTransactionComposer({ atc, sendParams }, algod)) as Omit<SendAtomicTransactionComposerResults, 'returns'>\n}\n\n/**\n * Wait until the transaction is confirmed or rejected, or until `timeout`\n * number of rounds have passed.\n *\n * @param algod An algod client\n * @param transactionId The transaction ID to wait for\n * @param maxRoundsToWait Maximum number of rounds to wait\n *\n * @return Pending transaction information\n * @throws Throws an error if the transaction is not confirmed or rejected in the next `timeout` rounds\n */\nexport const waitForConfirmation = async function (\n transactionId: string,\n maxRoundsToWait: number | bigint,\n algod: Algodv2,\n): Promise<modelsv2.PendingTransactionResponse> {\n if (maxRoundsToWait < 0) {\n throw new Error(`Invalid timeout, received ${maxRoundsToWait}, expected > 0`)\n }\n\n // Get current round\n const status = await algod.status().do()\n if (status === undefined) {\n throw new Error('Unable to get node status')\n }\n\n // Loop for up to `timeout` rounds looking for a confirmed transaction\n const startRound = BigInt(status.lastRound) + 1n\n let currentRound = startRound\n while (currentRound < startRound + BigInt(maxRoundsToWait)) {\n try {\n const pendingInfo = await algod.pendingTransactionInformation(transactionId).do()\n\n if (pendingInfo !== undefined) {\n const confirmedRound = pendingInfo.confirmedRound\n if (confirmedRound && confirmedRound > 0) {\n return pendingInfo\n } else {\n const poolError = pendingInfo.poolError\n if (poolError != null && poolError.length > 0) {\n // If there was a pool error, then the transaction has been rejected!\n throw new Error(`Transaction ${transactionId} was rejected; pool error: ${poolError}`)\n }\n }\n }\n } catch (e: unknown) {\n if ((e as Error).name === 'URLTokenBaseHTTPError') {\n currentRound++\n continue\n }\n }\n\n await algod.statusAfterBlock(toNumber(currentRound)).do()\n currentRound++\n }\n\n throw new Error(`Transaction ${transactionId} not confirmed after ${maxRoundsToWait} rounds`)\n}\n\n/**\n * @deprecated Use `TransactionComposer` and the `maxFee` field in the transaction params instead.\n *\n * Limit the acceptable fee to a defined amount of µAlgo.\n * This also sets the transaction to be flatFee to ensure the transaction only succeeds at\n * the estimated rate.\n * @param transaction The transaction to cap or suggested params object about to be used to create a transaction\n * @param maxAcceptableFee The maximum acceptable fee to pay\n */\nexport function capTransactionFee(transaction: algosdk.Transaction | SuggestedParams, maxAcceptableFee: AlgoAmount) {\n // If a flat fee hasn't already been defined\n if (!('flatFee' in transaction) || !transaction.flatFee) {\n // Once a transaction has been constructed by algosdk, transaction.fee indicates what the total transaction fee\n // Will be based on the current suggested fee-per-byte value.\n if (transaction.fee > maxAcceptableFee.microAlgo) {\n throw new Error(\n `Cancelled transaction due to high network congestion fees. Algorand suggested fees would cause this transaction to cost ${transaction.fee} µALGO. Cap for this transaction is ${maxAcceptableFee.microAlgo} µALGO.`,\n )\n } else if (transaction.fee > 1_000_000) {\n Config.logger.warn(`Algorand network congestion fees are in effect. This transaction will incur a fee of ${transaction.fee} µALGO.`)\n }\n\n // Now set the flat on the transaction. Otherwise the network may increase the fee above our cap and perform the transaction.\n if ('flatFee' in transaction) {\n transaction.flatFee = true\n }\n }\n}\n\n/**\n * @deprecated Use `TransactionComposer` and the `maxFee` and `staticFee` fields in the transaction params instead.\n *\n * Allows for control of fees on a `Transaction` or `SuggestedParams` object\n * @param transaction The transaction or suggested params\n * @param feeControl The fee control parameters\n */\nexport function controlFees<T extends SuggestedParams | Transaction>(\n transaction: T,\n feeControl: { fee?: AlgoAmount; maxFee?: AlgoAmount },\n) {\n const { fee, maxFee } = feeControl\n if (fee) {\n transaction.fee = Number(fee.microAlgo)\n if ('flatFee' in transaction) {\n transaction.flatFee = true\n }\n }\n\n if (maxFee !== undefined) {\n capTransactionFee(transaction, maxFee)\n }\n\n return transaction\n}\n\n/**\n * @deprecated Use `suggestedParams ? { ...suggestedParams } : await algod.getTransactionParams().do()` instead\n *\n * Returns suggested transaction parameters from algod unless some are already provided.\n * @param params Optionally provide parameters to use\n * @param algod Algod algod\n * @returns The suggested transaction parameters\n */\nexport async function getTransactionParams(params: SuggestedParams | undefined, algod: Algodv2): Promise<SuggestedParams> {\n if (params) {\n return { ...params }\n }\n const p = await algod.getTransactionParams().do()\n return {\n fee: p.fee,\n firstValid: p.firstValid,\n lastValid: p.lastValid,\n genesisID: p.genesisID,\n genesisHash: p.genesisHash,\n minFee: p.minFee,\n }\n}\n\n/**\n * @deprecated Use `atc.clone().buildGroup()` instead.\n *\n * Returns the array of transactions currently present in the given `AtomicTransactionComposer`\n * @param atc The atomic transaction composer\n * @returns The array of transactions with signers\n */\nexport function getAtomicT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GAAG;QACV,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,SAAS,EAAE,CAAC,CAAC,SAAS;QACtB,SAAS,EAAE,CAAC,CAAC,SAAS;QACtB,WAAW,EAAE,CAAC,CAAC,WAAW;QAC1B,MAAM,EAAE,CAAC,CAAC,MAAM;KACjB;AACH;AAEA;;;;;;AAMG;AACG,SAAU,wCAAwC,CAAC,GAA8B,EAAA;AACrF,IAAA,IAAI;AACF,QAAA,OAAO,GAAG,CAAC,KAAK,EAAE,CAAC,UAAU,EAAE;;AAC/B,IAAA,MAAM;AACN,QAAA,OAAO,EAAE;;AAEb;;;;"}
1
+ {"version":3,"file":"transaction.mjs","sources":["../../src/transaction/transaction.ts"],"sourcesContent":["import algosdk, { Address, ApplicationTransactionFields, TransactionBoxReference, TransactionType, stringifyJSON } from 'algosdk'\nimport { Buffer } from 'buffer'\nimport { Config } from '../config'\nimport { AlgoAmount } from '../types/amount'\nimport { ABIReturn } from '../types/app'\nimport { EventType } from '../types/lifecycle-events'\nimport {\n AdditionalAtomicTransactionComposerContext,\n AtomicTransactionComposerToSend,\n SendAtomicTransactionComposerResults,\n SendParams,\n SendTransactionFrom,\n SendTransactionParams,\n SendTransactionResult,\n TransactionGroupToSend,\n TransactionNote,\n TransactionToSign,\n} from '../types/transaction'\nimport { asJson, toNumber } from '../util'\nimport { performAtomicTransactionComposerSimulate } from './perform-atomic-transaction-composer-simulate'\nimport Algodv2 = algosdk.Algodv2\nimport AtomicTransactionComposer = algosdk.AtomicTransactionComposer\nimport modelsv2 = algosdk.modelsv2\nimport SuggestedParams = algosdk.SuggestedParams\nimport Transaction = algosdk.Transaction\nimport TransactionSigner = algosdk.TransactionSigner\nimport TransactionWithSigner = algosdk.TransactionWithSigner\nimport ABIValue = algosdk.ABIValue\nimport ABIType = algosdk.ABIType\n\nexport const MAX_TRANSACTION_GROUP_SIZE = 16\nexport const MAX_APP_CALL_FOREIGN_REFERENCES = 8\nexport const MAX_APP_CALL_ACCOUNT_REFERENCES = 4\n\n/**\n * @deprecated Convert your data to a `string` or `Uint8Array`, if using ARC-2 use `TransactionComposer.arc2Note`.\n *\n * Encodes a transaction note into a byte array ready to be included in an Algorand transaction.\n *\n * @param note The transaction note\n * @returns the transaction note ready for inclusion in a transaction\n *\n * Case on the value of `data` this either be:\n * * `null` | `undefined`: `undefined`\n * * `string`: The string value\n * * Uint8Array: passthrough\n * * Arc2TransactionNote object: ARC-0002 compatible transaction note\n * * Else: The object/value converted into a JSON string representation\n */\nexport function encodeTransactionNote(note?: TransactionNote): Uint8Array | undefined {\n if (note == null || typeof note === 'undefined') {\n return undefined\n } else if (typeof note === 'object' && note.constructor === Uint8Array) {\n return note\n } else if (typeof note === 'object' && 'dAppName' in note) {\n const arc2Payload = `${note.dAppName}:${note.format}${typeof note.data === 'string' ? note.data : asJson(note.data)}`\n const encoder = new TextEncoder()\n return encoder.encode(arc2Payload)\n } else {\n const n = typeof note === 'string' ? note : asJson(note)\n const encoder = new TextEncoder()\n return encoder.encode(n)\n }\n}\n\n/** Encodes a transaction lease into a 32-byte array ready to be included in an Algorand transaction.\n *\n * @param lease The transaction lease as a string or binary array or null/undefined if there is no lease\n * @returns the transaction lease ready for inclusion in a transaction or `undefined` if there is no lease\n * @throws if the length of the data is > 32 bytes or empty\n * @example algokit.encodeLease('UNIQUE_ID')\n * @example algokit.encodeLease(new Uint8Array([1, 2, 3]))\n */\nexport function encodeLease(lease?: string | Uint8Array): Uint8Array | undefined {\n if (lease === null || typeof lease === 'undefined') {\n return undefined\n } else if (typeof lease === 'object' && lease.constructor === Uint8Array) {\n if (lease.length === 0 || lease.length > 32) {\n throw new Error(\n `Received invalid lease; expected something with length between 1 and 32, but received bytes with length ${lease.length}`,\n )\n }\n if (lease.length === 32) return lease\n const lease32 = new Uint8Array(32)\n lease32.set(lease, 0)\n return lease32\n } else if (typeof lease === 'string') {\n if (lease.length === 0 || lease.length > 32) {\n throw new Error(\n `Received invalid lease; expected something with length between 1 and 32, but received '${lease}' with length ${lease.length}`,\n )\n }\n const encoder = new TextEncoder()\n const lease32 = new Uint8Array(32)\n lease32.set(encoder.encode(lease), 0)\n return lease32\n } else {\n throw new Error(`Unknown lease type received of ${typeof lease}`)\n }\n}\n\n/**\n * @deprecated Use `algorand.client` to interact with accounts, and use `.addr` to get the address\n * and/or move from using `SendTransactionFrom` to `TransactionSignerAccount` and use `.addr` instead.\n *\n * Returns the public address of the given transaction sender.\n * @param sender A transaction sender\n * @returns The public address\n */\nexport const getSenderAddress = function (sender: string | SendTransactionFrom): string {\n return typeof sender === 'string' ? sender : 'addr' in sender ? sender.addr.toString() : sender.address().toString()\n}\n\n/**\n * @deprecated Use `AlgorandClient` / `TransactionComposer` to construct transactions instead or\n * construct an `algosdk.TransactionWithSigner` manually instead.\n *\n * Given a transaction in a variety of supported formats, returns a TransactionWithSigner object ready to be passed to an\n * AtomicTransactionComposer's addTransaction method.\n * @param transaction One of: A TransactionWithSigner object (returned as is), a TransactionToSign object (signer is obtained from the\n * signer property), a Transaction object (signer is extracted from the defaultSender parameter), an async SendTransactionResult returned by\n * one of algokit utils' helpers (signer is obtained from the defaultSender parameter)\n * @param defaultSender The default sender to be used to obtain a signer where the object provided to the transaction parameter does not\n * include a signer.\n * @returns A TransactionWithSigner object.\n */\nexport const getTransactionWithSigner = async (\n transaction: TransactionWithSigner | TransactionToSign | Transaction | Promise<SendTransactionResult>,\n defaultSender?: SendTransactionFrom,\n): Promise<TransactionWithSigner> => {\n if ('txn' in transaction) return transaction\n if (defaultSender === undefined)\n throw new Error('Default sender must be provided when passing in a transaction object that does not contain its own signer')\n return transaction instanceof Promise\n ? {\n txn: (await transaction).transaction,\n signer: getSenderTransactionSigner(defaultSender),\n }\n : 'transaction' in transaction\n ? {\n txn: transaction.transaction,\n signer: getSenderTransactionSigner(transaction.signer),\n }\n : {\n txn: transaction,\n signer: getSenderTransactionSigner(defaultSender),\n }\n}\n\nconst memoize = <T = unknown, R = unknown>(fn: (val: T) => R) => {\n const cache = new Map()\n const cached = function (this: unknown, val: T) {\n return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val)\n }\n cached.cache = cache\n return cached as (val: T) => R\n}\n\n/**\n * @deprecated Use `TransactionSignerAccount` instead of `SendTransactionFrom` or use\n * `algosdk.makeBasicAccountTransactionSigner` / `algosdk.makeLogicSigAccountTransactionSigner`.\n *\n * Returns a `TransactionSigner` for the given transaction sender.\n * This function has memoization, so will return the same transaction signer for a given sender.\n * @param sender A transaction sender\n * @returns A transaction signer\n */\nexport const getSenderTransactionSigner = memoize(function (sender: SendTransactionFrom): TransactionSigner {\n return 'signer' in sender\n ? sender.signer\n : 'lsig' in sender\n ? algosdk.makeLogicSigAccountTransactionSigner(sender)\n : algosdk.makeBasicAccountTransactionSigner(sender)\n})\n\n/**\n * @deprecated Use `AlgorandClient` / `TransactionComposer` to sign transactions\n * or use the relevant underlying `account.signTxn` / `algosdk.signLogicSigTransactionObject`\n * / `multiSigAccount.sign` / `TransactionSigner` methods directly.\n *\n * Signs a single transaction by the given signer.\n * @param transaction The transaction to sign\n * @param signer The signer to sign\n * @returns The signed transaction as a `Uint8Array`\n */\nexport const signTransaction = async (transaction: Transaction, signer: SendTransactionFrom) => {\n return 'sk' in signer\n ? transaction.signTxn(signer.sk)\n : 'lsig' in signer\n ? algosdk.signLogicSigTransactionObject(transaction, signer).blob\n : 'sign' in signer\n ? signer.sign(transaction)\n : (await signer.signer([transaction], [0]))[0]\n}\n\n/**\n * @deprecated Use `AlgorandClient` / `TransactionComposer` to send transactions.\n *\n * Prepares a transaction for sending and then (if instructed) signs and sends the given transaction to the chain.\n *\n * @param send The details for the transaction to prepare/send, including:\n * * `transaction`: The unsigned transaction\n * * `from`: The account to sign the transaction with: either an account with private key loaded or a logic signature account\n * * `config`: The sending configuration for this transaction\n * @param algod An algod client\n *\n * @returns An object with transaction (`transaction`) and (if `skipWaiting` is `false` or `undefined`) confirmation (`confirmation`)\n */\nexport const sendTransaction = async function (\n send: {\n transaction: Transaction\n from: SendTransactionFrom\n sendParams?: SendTransactionParams\n },\n algod: Algodv2,\n): Promise<SendTransactionResult> {\n const { transaction, from, sendParams } = send\n const { skipSending, skipWaiting, fee, maxFee, suppressLog, maxRoundsToWaitForConfirmation, atc } = sendParams ?? {}\n\n controlFees(transaction, { fee, maxFee })\n\n if (atc) {\n atc.addTransaction({ txn: transaction, signer: getSenderTransactionSigner(from) })\n return { transaction }\n }\n\n if (skipSending) {\n return { transaction }\n }\n\n let txnToSend = transaction\n\n const populateAppCallResources = sendParams?.populateAppCallResources ?? Config.populateAppCallResources\n\n // Populate resources if the transaction is an appcall and populateAppCallResources wasn't explicitly set to false\n if (txnToSend.type === algosdk.TransactionType.appl && populateAppCallResources) {\n const newAtc = new AtomicTransactionComposer()\n newAtc.addTransaction({ txn: txnToSend, signer: getSenderTransactionSigner(from) })\n const atc = await prepareGroupForSending(newAtc, algod, { ...sendParams, populateAppCallResources })\n txnToSend = atc.buildGroup()[0].txn\n }\n\n const signedTransaction = await signTransaction(txnToSend, from)\n\n await algod.sendRawTransaction(signedTransaction).do()\n\n Config.getLogger(suppressLog).verbose(`Sent transaction ID ${txnToSend.txID()} ${txnToSend.type} from ${getSenderAddress(from)}`)\n\n let confirmation: modelsv2.PendingTransactionResponse | undefined = undefined\n if (!skipWaiting) {\n confirmation = await waitForConfirmation(txnToSend.txID(), maxRoundsToWaitForConfirmation ?? 5, algod)\n }\n\n return { transaction: txnToSend, confirmation }\n}\n\n/**\n * Get the execution info of a transaction group for the given ATC\n * The function uses the simulate endpoint and depending on the sendParams can return the following:\n * - The unnamed resources accessed by the group\n * - The unnamed resources accessed by each transaction in the group\n * - The required fee delta for each transaction in the group. A positive value indicates a fee deficit, a negative value indicates a surplus.\n *\n * @param atc The ATC containing the txn group\n * @param algod The algod client to use for the simulation\n * @param sendParams The send params for the transaction group\n * @param additionalAtcContext Additional ATC context used to determine how best to alter transactions in the group\n * @returns The execution info for the group\n */\nasync function getGroupExecutionInfo(\n atc: algosdk.AtomicTransactionComposer,\n algod: algosdk.Algodv2,\n sendParams: SendParams,\n additionalAtcContext?: AdditionalAtomicTransactionComposerContext,\n) {\n const simulateRequest = new algosdk.modelsv2.SimulateRequest({\n txnGroups: [],\n allowUnnamedResources: true,\n allowEmptySignatures: true,\n fixSigners: true,\n })\n\n const nullSigner = algosdk.makeEmptyTransactionSigner()\n\n const emptySignerAtc = atc.clone()\n\n const appCallIndexesWithoutMaxFees: number[] = []\n emptySignerAtc['transactions'].forEach((t: algosdk.TransactionWithSigner, i: number) => {\n t.signer = nullSigner\n\n if (sendParams.coverAppCallInnerTransactionFees && t.txn.type === TransactionType.appl) {\n if (!additionalAtcContext?.suggestedParams) {\n throw Error(`Please provide additionalAtcContext.suggestedParams when coverAppCallInnerTransactionFees is enabled`)\n }\n\n const maxFee = additionalAtcContext?.maxFees?.get(i)?.microAlgo\n if (maxFee === undefined) {\n appCallIndexesWithoutMaxFees.push(i)\n } else {\n t.txn.fee = maxFee\n }\n }\n })\n\n if (sendParams.coverAppCallInnerTransactionFees && appCallIndexesWithoutMaxFees.length > 0) {\n throw Error(\n `Please provide a maxFee for each app call transaction when coverAppCallInnerTransactionFees is enabled. Required for transaction ${appCallIndexesWithoutMaxFees.join(', ')}`,\n )\n }\n\n const perByteTxnFee = BigInt(additionalAtcContext?.suggestedParams.fee ?? 0n)\n const minTxnFee = BigInt(additionalAtcContext?.suggestedParams.minFee ?? 1000n)\n\n const result = await emptySignerAtc.simulate(algod, simulateRequest)\n\n const groupResponse = result.simulateResponse.txnGroups[0]\n\n if (groupResponse.failureMessage) {\n if (sendParams.coverAppCallInnerTransactionFees && groupResponse.failureMessage.match(/fee too small/)) {\n throw Error(`Fees were too small to resolve execution info via simulate. You may need to increase an app call transaction maxFee.`)\n }\n\n throw Error(`Error resolving execution info via simulate in transaction ${groupResponse.failedAt}: ${groupResponse.failureMessage}`)\n }\n\n return {\n groupUnnamedResourcesAccessed: sendParams.populateAppCallResources ? groupResponse.unnamedResourcesAccessed : undefined,\n txns: groupResponse.txnResults.map((txn, i) => {\n const originalTxn = atc['transactions'][i].txn as algosdk.Transaction\n\n let requiredFeeDelta = 0n\n if (sendParams.coverAppCallInnerTransactionFees) {\n // Min fee calc is lifted from algosdk https://github.com/algorand/js-algorand-sdk/blob/6973ff583b243ddb0632e91f4c0383021430a789/src/transaction.ts#L710\n // 75 is the number of bytes added to a txn after signing it\n const parentPerByteFee = perByteTxnFee * BigInt(originalTxn.toByte().length + 75)\n const parentMinFee = parentPerByteFee < minTxnFee ? minTxnFee : parentPerByteFee\n const parentFeeDelta = parentMinFee - originalTxn.fee\n if (originalTxn.type === TransactionType.appl) {\n const calculateInnerFeeDelta = (itxns: algosdk.modelsv2.PendingTransactionResponse[], acc: bigint = 0n): bigint => {\n // Surplus inner transaction fees do not pool up to the parent transaction.\n // Additionally surplus inner transaction fees only pool from sibling transactions that are sent prior to a given inner transaction, hence why we iterate in reverse order.\n return itxns.reverse().reduce((acc, itxn) => {\n const currentFeeDelta =\n (itxn.innerTxns && itxn.innerTxns.length > 0 ? calculateInnerFeeDelta(itxn.innerTxns, acc) : acc) +\n (minTxnFee - itxn.txn.txn.fee) // Inner transactions don't require per byte fees\n return currentFeeDelta < 0n ? 0n : currentFeeDelta\n }, acc)\n }\n\n const innerFeeDelta = calculateInnerFeeDelta(txn.txnResult.innerTxns ?? [])\n requiredFeeDelta = innerFeeDelta + parentFeeDelta\n } else {\n requiredFeeDelta = parentFeeDelta\n }\n }\n\n return {\n unnamedResourcesAccessed: sendParams.populateAppCallResources ? txn.unnamedResourcesAccessed : undefined,\n requiredFeeDelta,\n }\n }),\n }\n}\n\n/**\n * Take an existing Atomic Transaction Composer and return a new one with the required\n * app call resources populated into it\n *\n * @param algod The algod client to use for the simulation\n * @param atc The ATC containing the txn group\n * @returns A new ATC with the resources populated into the transactions\n *\n * @privateRemarks\n *\n * This entire function will eventually be implemented in simulate upstream in algod. The simulate endpoint will return\n * an array of refference arrays for each transaction, so this eventually will eventually just call simulate and set the\n * reference arrays in the transactions to the reference arrays returned by simulate.\n *\n * See https://github.com/algorand/go-algorand/pull/5684\n *\n */\nexport async function populateAppCallResources(atc: algosdk.AtomicTransactionComposer, algod: algosdk.Algodv2) {\n return await prepareGroupForSending(atc, algod, { populateAppCallResources: true })\n}\n\n/**\n * Take an existing Atomic Transaction Composer and return a new one with changes applied to the transactions\n * based on the supplied sendParams to prepare it for sending.\n * Please note, that before calling `.execute()` on the returned ATC, you must call `.buildGroup()`.\n *\n * @param algod The algod client to use for the simulation\n * @param atc The ATC containing the txn group\n * @param sendParams The send params for the transaction group\n * @param additionalAtcContext Additional ATC context used to determine how best to change the transactions in the group\n * @returns A new ATC with the changes applied\n *\n * @privateRemarks\n * Parts of this function will eventually be implemented in algod. Namely:\n * - Simulate will return information on how to populate reference arrays, see https://github.com/algorand/go-algorand/pull/6015\n */\nexport async function prepareGroupForSending(\n atc: algosdk.AtomicTransactionComposer,\n algod: algosdk.Algodv2,\n sendParams: SendParams,\n additionalAtcContext?: AdditionalAtomicTransactionComposerContext,\n) {\n const executionInfo = await getGroupExecutionInfo(atc, algod, sendParams, additionalAtcContext)\n const group = atc.buildGroup()\n\n const [_, additionalTransactionFees] = sendParams.coverAppCallInnerTransactionFees\n ? executionInfo.txns\n .map((txn, i) => {\n const groupIndex = i\n const txnInGroup = group[groupIndex].txn\n const maxFee = additionalAtcContext?.maxFees?.get(i)?.microAlgo\n const immutableFee = maxFee !== undefined && maxFee === txnInGroup.fee\n // Because we don't alter non app call transaction, they take priority\n const priorityMultiplier =\n txn.requiredFeeDelta > 0n && (immutableFee || txnInGroup.type !== algosdk.TransactionType.appl) ? 1_000n : 1n\n\n return {\n ...txn,\n groupIndex,\n // Measures the priority level of covering the transaction fee using the surplus group fees. The higher the number, the higher the priority.\n surplusFeePriorityLevel: txn.requiredFeeDelta > 0n ? txn.requiredFeeDelta * priorityMultiplier : -1n,\n }\n })\n .sort((a, b) => {\n return a.surplusFeePriorityLevel > b.surplusFeePriorityLevel ? -1 : a.surplusFeePriorityLevel < b.surplusFeePriorityLevel ? 1 : 0\n })\n .reduce(\n (acc, { groupIndex, requiredFeeDelta }) => {\n if (requiredFeeDelta > 0n) {\n // There is a fee deficit on the transaction\n let surplusGroupFees = acc[0]\n const additionalTransactionFees = acc[1]\n const additionalFeeDelta = requiredFeeDelta - surplusGroupFees\n if (additionalFeeDelta <= 0n) {\n // The surplus group fees fully cover the required fee delta\n surplusGroupFees = -additionalFeeDelta\n } else {\n // The surplus group fees do not fully cover the required fee delta, use what is available\n additionalTransactionFees.set(groupIndex, additionalFeeDelta)\n surplusGroupFees = 0n\n }\n return [surplusGroupFees, additionalTransactionFees] as const\n }\n return acc\n },\n [\n executionInfo.txns.reduce((acc, { requiredFeeDelta }) => {\n if (requiredFeeDelta < 0n) {\n return acc + -requiredFeeDelta\n }\n return acc\n }, 0n),\n new Map<number, bigint>(),\n ] as const,\n )\n : [0n, new Map<number, bigint>()]\n\n executionInfo.txns.forEach(({ unnamedResourcesAccessed: r }, i) => {\n // Populate Transaction App Call Resources\n if (sendParams.populateAppCallResources && r !== undefined && group[i].txn.type === TransactionType.appl) {\n if (r.boxes || r.extraBoxRefs) throw Error('Unexpected boxes at the transaction level')\n if (r.appLocals) throw Error('Unexpected app local at the transaction level')\n if (r.assetHoldings)\n throw Error('Unexpected asset holding at the transaction level')\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(group[i].txn as any)['applicationCall'] = {\n ...group[i].txn.applicationCall,\n accounts: [...(group[i].txn?.applicationCall?.accounts ?? []), ...(r.accounts ?? [])],\n foreignApps: [...(group[i].txn?.applicationCall?.foreignApps ?? []), ...(r.apps ?? [])],\n foreignAssets: [...(group[i].txn?.applicationCall?.foreignAssets ?? []), ...(r.assets ?? [])],\n boxes: [...(group[i].txn?.applicationCall?.boxes ?? []), ...(r.boxes ?? [])],\n } satisfies Partial<ApplicationTransactionFields>\n\n const accounts = group[i].txn.applicationCall?.accounts?.length ?? 0\n if (accounts > MAX_APP_CALL_ACCOUNT_REFERENCES)\n throw Error(`Account reference limit of ${MAX_APP_CALL_ACCOUNT_REFERENCES} exceeded in transaction ${i}`)\n const assets = group[i].txn.applicationCall?.foreignAssets?.length ?? 0\n const apps = group[i].txn.applicationCall?.foreignApps?.length ?? 0\n const boxes = group[i].txn.applicationCall?.boxes?.length ?? 0\n if (accounts + assets + apps + boxes > MAX_APP_CALL_FOREIGN_REFERENCES) {\n throw Error(`Resource reference limit of ${MAX_APP_CALL_FOREIGN_REFERENCES} exceeded in transaction ${i}`)\n }\n }\n\n // Cover App Call Inner Transaction Fees\n if (sendParams.coverAppCallInnerTransactionFees) {\n const additionalTransactionFee = additionalTransactionFees.get(i)\n\n if (additionalTransactionFee !== undefined) {\n if (group[i].txn.type !== algosdk.TransactionType.appl) {\n throw Error(`An additional fee of ${additionalTransactionFee} µALGO is required for non app call transaction ${i}`)\n }\n const transactionFee = group[i].txn.fee + additionalTransactionFee\n const maxFee = additionalAtcContext?.maxFees?.get(i)?.microAlgo\n if (maxFee === undefined || transactionFee > maxFee) {\n throw Error(\n `Calculated transaction fee ${transactionFee} µALGO is greater than max of ${maxFee ?? 'undefined'} for transaction ${i}`,\n )\n }\n group[i].txn.fee = transactionFee\n }\n }\n })\n\n // Populate Group App Call Resources\n if (sendParams.populateAppCallResources) {\n const populateGroupResource = (\n txns: algosdk.TransactionWithSigner[],\n reference:\n | string\n | algosdk.modelsv2.BoxReference\n | algosdk.modelsv2.ApplicationLocalReference\n | algosdk.modelsv2.AssetHoldingReference\n | bigint\n | number\n | Address,\n type: 'account' | 'assetHolding' | 'appLocal' | 'app' | 'box' | 'asset',\n ): void => {\n const isApplBelowLimit = (t: algosdk.TransactionWithSigner) => {\n if (t.txn.type !== algosdk.TransactionType.appl) return false\n\n const accounts = t.txn.applicationCall?.accounts?.length ?? 0\n const assets = t.txn.applicationCall?.foreignAssets?.length ?? 0\n const apps = t.txn.applicationCall?.foreignApps?.length ?? 0\n const boxes = t.txn.applicationCall?.boxes?.length ?? 0\n\n return accounts + assets + apps + boxes < MAX_APP_CALL_FOREIGN_REFERENCES\n }\n\n // If this is a asset holding or app local, first try to find a transaction that already has the account available\n if (type === 'assetHolding' || type === 'appLocal') {\n const { account } = reference as algosdk.modelsv2.ApplicationLocalReference | algosdk.modelsv2.AssetHoldingReference\n\n let txnIndex = txns.findIndex((t) => {\n if (!isApplBelowLimit(t)) return false\n\n return (\n // account is in the foreign accounts array\n t.txn.applicationCall?.accounts?.map((a) => a.toString()).includes(account.toString()) ||\n // account is available as an app account\n t.txn.applicationCall?.foreignApps?.map((a) => algosdk.getApplicationAddress(a).toString()).includes(account.toString()) ||\n // account is available since it's in one of the fields\n Object.values(t.txn).some((f) =>\n stringifyJSON(f, (_, v) => (v instanceof Address ? v.toString() : v))?.includes(account.toString()),\n )\n )\n })\n\n if (txnIndex > -1) {\n if (type === 'assetHolding') {\n const { asset } = reference as algosdk.modelsv2.AssetHoldingReference\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n foreignAssets: [...(txns[txnIndex].txn?.applicationCall?.foreignAssets ?? []), ...[asset]],\n } satisfies Partial<ApplicationTransactionFields>\n } else {\n const { app } = reference as algosdk.modelsv2.ApplicationLocalReference\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n foreignApps: [...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []), ...[app]],\n } satisfies Partial<ApplicationTransactionFields>\n }\n return\n }\n\n // Now try to find a txn that already has that app or asset available\n txnIndex = txns.findIndex((t) => {\n if (!isApplBelowLimit(t)) return false\n\n // check if there is space in the accounts array\n if ((t.txn.applicationCall?.accounts?.length ?? 0) >= MAX_APP_CALL_ACCOUNT_REFERENCES) return false\n\n if (type === 'assetHolding') {\n const { asset } = reference as algosdk.modelsv2.AssetHoldingReference\n return t.txn.applicationCall?.foreignAssets?.includes(asset)\n } else {\n const { app } = reference as algosdk.modelsv2.ApplicationLocalReference\n return t.txn.applicationCall?.foreignApps?.includes(app) || t.txn.applicationCall?.appIndex === app\n }\n })\n\n if (txnIndex > -1) {\n const { account } = reference as algosdk.modelsv2.AssetHoldingReference | algosdk.modelsv2.ApplicationLocalReference\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[account]],\n } satisfies Partial<ApplicationTransactionFields>\n\n return\n }\n }\n\n // If this is a box, first try to find a transaction that already has the app available\n if (type === 'box') {\n const { app, name } = reference as algosdk.modelsv2.BoxReference\n\n const txnIndex = txns.findIndex((t) => {\n if (!isApplBelowLimit(t)) return false\n\n // If the app is in the foreign array OR the app being called, then we know it's available\n return t.txn.applicationCall?.foreignApps?.includes(app) || t.txn.applicationCall?.appIndex === app\n })\n\n if (txnIndex > -1) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n boxes: [...(txns[txnIndex].txn?.applicationCall?.boxes ?? []), ...[{ appIndex: app, name } satisfies TransactionBoxReference]],\n } satisfies Partial<ApplicationTransactionFields>\n\n return\n }\n }\n\n // Find the txn index to put the reference(s)\n const txnIndex = txns.findIndex((t) => {\n if (t.txn.type !== algosdk.TransactionType.appl) return false\n\n const accounts = t.txn.applicationCall?.accounts?.length ?? 0\n if (type === 'account') return accounts < MAX_APP_CALL_ACCOUNT_REFERENCES\n\n const assets = t.txn.applicationCall?.foreignAssets?.length ?? 0\n const apps = t.txn.applicationCall?.foreignApps?.length ?? 0\n const boxes = t.txn.applicationCall?.boxes?.length ?? 0\n\n // If we're adding local state or asset holding, we need space for the acocunt and the other reference\n if (type === 'assetHolding' || type === 'appLocal') {\n return accounts + assets + apps + boxes < MAX_APP_CALL_FOREIGN_REFERENCES - 1 && accounts < MAX_APP_CALL_ACCOUNT_REFERENCES\n }\n\n // If we're adding a box, we need space for both the box ref and the app ref\n if (type === 'box' && BigInt((reference as algosdk.modelsv2.BoxReference).app) !== BigInt(0)) {\n return accounts + assets + apps + boxes < MAX_APP_CALL_FOREIGN_REFERENCES - 1\n }\n\n return accounts + assets + apps + boxes < MAX_APP_CALL_FOREIGN_REFERENCES\n })\n\n if (txnIndex === -1) {\n throw Error('No more transactions below reference limit. Add another app call to the group.')\n }\n\n if (type === 'account') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[reference as Address]],\n } satisfies Partial<ApplicationTransactionFields>\n } else if (type === 'app') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n foreignApps: [\n ...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []),\n ...[typeof reference === 'bigint' ? reference : BigInt(reference as number)],\n ],\n } satisfies Partial<ApplicationTransactionFields>\n } else if (type === 'box') {\n const { app, name } = reference as algosdk.modelsv2.BoxReference\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n boxes: [...(txns[txnIndex].txn?.applicationCall?.boxes ?? []), ...[{ appIndex: app, name } satisfies TransactionBoxReference]],\n } satisfies Partial<ApplicationTransactionFields>\n\n if (app.toString() !== '0') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n foreignApps: [...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []), ...[app]],\n } satisfies Partial<ApplicationTransactionFields>\n }\n } else if (type === 'assetHolding') {\n const { asset, account } = reference as algosdk.modelsv2.AssetHoldingReference\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n foreignAssets: [...(txns[txnIndex].txn?.applicationCall?.foreignAssets ?? []), ...[asset]],\n accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[account]],\n } satisfies Partial<ApplicationTransactionFields>\n } else if (type === 'appLocal') {\n const { app, account } = reference as algosdk.modelsv2.ApplicationLocalReference\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n foreignApps: [...(txns[txnIndex].txn?.applicationCall?.foreignApps ?? []), ...[app]],\n accounts: [...(txns[txnIndex].txn?.applicationCall?.accounts ?? []), ...[account]],\n } satisfies Partial<ApplicationTransactionFields>\n } else if (type === 'asset') {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(txns[txnIndex].txn as any)['applicationCall'] = {\n ...txns[txnIndex].txn.applicationCall,\n foreignAssets: [\n ...(txns[txnIndex].txn?.applicationCall?.foreignAssets ?? []),\n ...[typeof reference === 'bigint' ? reference : BigInt(reference as number)],\n ],\n } satisfies Partial<ApplicationTransactionFields>\n }\n }\n\n const g = executionInfo.groupUnnamedResourcesAccessed\n\n if (g) {\n // Do cross-reference resources first because they are the most restrictive in terms\n // of which transactions can be used\n g.appLocals?.forEach((a) => {\n populateGroupResource(group, a, 'appLocal')\n\n // Remove resources from the group if we're adding them here\n g.accounts = g.accounts?.filter((acc) => acc !== a.account)\n g.apps = g.apps?.filter((app) => BigInt(app) !== BigInt(a.app))\n })\n\n g.assetHoldings?.forEach((a) => {\n populateGroupResource(group, a, 'assetHolding')\n\n // Remove resources from the group if we're adding them here\n g.accounts = g.accounts?.filter((acc) => acc !== a.account)\n g.assets = g.assets?.filter((asset) => BigInt(asset) !== BigInt(a.asset))\n })\n\n // Do accounts next because the account limit is 4\n g.accounts?.forEach((a) => {\n populateGroupResource(group, a, 'account')\n })\n\n g.boxes?.forEach((b) => {\n populateGroupResource(group, b, 'box')\n\n // Remove apps as resource from the group if we're adding it here\n g.apps = g.apps?.filter((app) => BigInt(app) !== BigInt(b.app))\n })\n\n g.assets?.forEach((a) => {\n populateGroupResource(group, a, 'asset')\n })\n\n g.apps?.forEach((a) => {\n populateGroupResource(group, a, 'app')\n })\n\n if (g.extraBoxRefs) {\n for (let i = 0; i < g.extraBoxRefs; i += 1) {\n const ref = new algosdk.modelsv2.BoxReference({ app: 0, name: new Uint8Array(0) })\n populateGroupResource(group, ref, 'box')\n }\n }\n }\n }\n\n const newAtc = new algosdk.AtomicTransactionComposer()\n\n group.forEach((t) => {\n t.txn.group = undefined\n newAtc.addTransaction(t)\n })\n\n newAtc['methodCalls'] = atc['methodCalls']\n return newAtc\n}\n\n/**\n * Signs and sends transactions that have been collected by an `AtomicTransactionComposer`.\n * @param atcSend The parameters controlling the send, including `atc` The `AtomicTransactionComposer` and params to control send behaviour\n * @param algod An algod client\n * @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`)\n */\nexport const sendAtomicTransactionComposer = async function (atcSend: AtomicTransactionComposerToSend, algod: Algodv2) {\n const { atc: givenAtc, sendParams, additionalAtcContext, ...executeParams } = atcSend\n\n let atc: AtomicTransactionComposer\n\n atc = givenAtc\n try {\n const transactionsWithSigner = atc.buildGroup()\n\n // If populateAppCallResources is true OR if populateAppCallResources is undefined and there are app calls, then populate resources\n const populateAppCallResources =\n executeParams?.populateAppCallResources ?? sendParams?.populateAppCallResources ?? Config.populateAppCallResources\n const coverAppCallInnerTransactionFees = executeParams?.coverAppCallInnerTransactionFees\n\n if (\n (populateAppCallResources || coverAppCallInnerTransactionFees) &&\n transactionsWithSigner.map((t) => t.txn.type).includes(algosdk.TransactionType.appl)\n ) {\n atc = await prepareGroupForSending(\n givenAtc,\n algod,\n { ...executeParams, populateAppCallResources, coverAppCallInnerTransactionFees },\n additionalAtcContext,\n )\n }\n\n // atc.buildGroup() is needed to ensure that any changes made by prepareGroupForSending are reflected and the group id is set\n const transactionsToSend = atc.buildGroup().map((t) => {\n return t.txn\n })\n let groupId: string | undefined = undefined\n if (transactionsToSend.length > 1) {\n groupId = transactionsToSend[0].group ? Buffer.from(transactionsToSend[0].group).toString('base64') : ''\n Config.getLogger(executeParams?.suppressLog ?? sendParams?.suppressLog).verbose(\n `Sending group of ${transactionsToSend.length} transactions (${groupId})`,\n {\n transactionsToSend,\n },\n )\n\n Config.getLogger(executeParams?.suppressLog ?? sendParams?.suppressLog).debug(\n `Transaction IDs (${groupId})`,\n transactionsToSend.map((t) => t.txID()),\n )\n }\n\n if (Config.debug && Config.traceAll) {\n // Emit the simulate response for use with AlgoKit AVM debugger\n const simulateResponse = await performAtomicTransactionComposerSimulate(atc, algod)\n await Config.events.emitAsync(EventType.TxnGroupSimulated, {\n simulateResponse,\n })\n }\n const result = await atc.execute(\n algod,\n executeParams?.maxRoundsToWaitForConfirmation ?? sendParams?.maxRoundsToWaitForConfirmation ?? 5,\n )\n\n if (transactionsToSend.length > 1) {\n Config.getLogger(executeParams?.suppressLog ?? sendParams?.suppressLog).verbose(\n `Group transaction (${groupId}) sent with ${transactionsToSend.length} transactions`,\n )\n } else {\n Config.getLogger(executeParams?.suppressLog ?? sendParams?.suppressLog).verbose(\n `Sent transaction ID ${transactionsToSend[0].txID()} ${transactionsToSend[0].type} from ${transactionsToSend[0].sender.toString()}`,\n )\n }\n\n let confirmations: modelsv2.PendingTransactionResponse[] | undefined = undefined\n if (!sendParams?.skipWaiting) {\n confirmations = await Promise.all(transactionsToSend.map(async (t) => await algod.pendingTransactionInformation(t.txID()).do()))\n }\n\n return {\n groupId,\n confirmations,\n txIds: transactionsToSend.map((t) => t.txID()),\n transactions: transactionsToSend,\n returns: result.methodResults.map(getABIReturnValue),\n } as SendAtomicTransactionComposerResults\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n // Create a new error object so the stack trace is correct (algosdk throws an error with a more limited stack trace)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const err = new Error(typeof e === 'object' ? e?.message : 'Received error executing Atomic Transaction Composer') as any as any\n err.cause = e\n if (typeof e === 'object') {\n // Remove headers as it doesn't have anything useful.\n delete e.response?.headers\n err.response = e.response\n // body property very noisy\n if (e.response && 'body' in e.response) delete err.response.body\n err.name = e.name\n }\n\n if (Config.debug && typeof e === 'object') {\n err.traces = []\n Config.getLogger(executeParams?.suppressLog ?? sendParams?.suppressLog).error(\n 'Received error executing Atomic Transaction Composer and debug flag enabled; attempting simulation to get more information',\n err,\n )\n const simulate = await performAtomicTransactionComposerSimulate(atc, algod)\n if (Config.debug && !Config.traceAll) {\n // Emit the event only if traceAll: false, as it should have already been emitted above\n await Config.events.emitAsync(EventType.TxnGroupSimulated, {\n simulateResponse: simulate,\n })\n }\n\n if (simulate && simulate.txnGroups[0].failedAt) {\n for (const txn of simulate.txnGroups[0].txnResults) {\n err.traces.push({\n trace: txn.execTrace?.toEncodingData(),\n appBudget: txn.appBudgetConsumed,\n logicSigBudget: txn.logicSigBudgetConsumed,\n logs: txn.txnResult.logs,\n message: simulate.txnGroups[0].failureMessage,\n })\n }\n }\n } else {\n Config.getLogger(executeParams?.suppressLog ?? sendParams?.suppressLog).error(\n 'Received error executing Atomic Transaction Composer, for more information enable the debug flag',\n err,\n )\n }\n throw err\n }\n}\n\nconst convertABIDecodedBigIntToNumber = (value: ABIValue, type: ABIType): ABIValue => {\n if (typeof value === 'bigint') {\n if (type instanceof algosdk.ABIUintType) {\n return type.bitSize < 53 ? Number(value) : value\n } else {\n return value\n }\n } else if (Array.isArray(value) && (type instanceof algosdk.ABIArrayStaticType || type instanceof algosdk.ABIArrayDynamicType)) {\n return value.map((v) => convertABIDecodedBigIntToNumber(v, type.childType))\n } else if (Array.isArray(value) && type instanceof algosdk.ABITupleType) {\n return value.map((v, i) => convertABIDecodedBigIntToNumber(v, type.childTypes[i]))\n } else {\n return value\n }\n}\n\n/**\n * Takes an algosdk `ABIResult` and converts it to an `ABIReturn`.\n * Converts `bigint`'s for Uint's < 64 to `number` for easier use.\n * @param result The `ABIReturn`\n */\nexport function getABIReturnValue(result: algosdk.ABIResult): ABIReturn {\n if (result.decodeError) {\n return {\n decodeError: result.decodeError,\n }\n }\n\n return {\n method: result.method,\n rawReturnValue: result.rawReturnValue,\n decodeError: undefined,\n returnValue:\n result.returnValue !== undefined && result.method.returns.type !== 'void'\n ? convertABIDecodedBigIntToNumber(result.returnValue, result.method.returns.type)\n : result.returnValue!,\n }\n}\n\n/**\n * @deprecated Use `TransactionComposer` (`algorand.newGroup()`) or `AtomicTransactionComposer` to construct and send group transactions instead.\n *\n * Signs and sends a group of [up to 16](https://dev.algorand.co/concepts/transactions/atomic-txn-groups/#create-transactions) transactions to the chain\n *\n * @param groupSend The group details to send, with:\n * * `transactions`: The array of transactions to send along with their signing account\n * * `sendParams`: The parameters to dictate how the group is sent\n * @param algod An algod client\n * @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`)\n */\nexport const sendGroupOfTransactions = async function (groupSend: TransactionGroupToSend, algod: Algodv2) {\n const { transactions, signer, sendParams } = groupSend\n\n const defaultTransactionSigner = signer ? getSenderTransactionSigner(signer) : undefined\n\n const transactionsWithSigner = await Promise.all(\n transactions.map(async (t) => {\n if ('signer' in t)\n return {\n txn: t.transaction,\n signer: getSenderTransactionSigner(t.signer),\n sender: t.signer,\n }\n\n const txn = 'then' in t ? (await t).transaction : t\n if (!signer) {\n throw new Error(`Attempt to send transaction ${txn.txID()} as part of a group transaction, but no signer parameter was provided.`)\n }\n\n return {\n txn,\n signer: defaultTransactionSigner!,\n sender: signer,\n }\n }),\n )\n\n const atc = new AtomicTransactionComposer()\n transactionsWithSigner.forEach((txn) => atc.addTransaction(txn))\n\n return (await sendAtomicTransactionComposer({ atc, sendParams }, algod)) as Omit<SendAtomicTransactionComposerResults, 'returns'>\n}\n\n/**\n * Wait until the transaction is confirmed or rejected, or until `timeout`\n * number of rounds have passed.\n *\n * @param algod An algod client\n * @param transactionId The transaction ID to wait for\n * @param maxRoundsToWait Maximum number of rounds to wait\n *\n * @return Pending transaction information\n * @throws Throws an error if the transaction is not confirmed or rejected in the next `timeout` rounds\n */\nexport const waitForConfirmation = async function (\n transactionId: string,\n maxRoundsToWait: number | bigint,\n algod: Algodv2,\n): Promise<modelsv2.PendingTransactionResponse> {\n if (maxRoundsToWait < 0) {\n throw new Error(`Invalid timeout, received ${maxRoundsToWait}, expected > 0`)\n }\n\n // Get current round\n const status = await algod.status().do()\n if (status === undefined) {\n throw new Error('Unable to get node status')\n }\n\n // Loop for up to `timeout` rounds looking for a confirmed transaction\n const startRound = BigInt(status.lastRound) + 1n\n let currentRound = startRound\n while (currentRound < startRound + BigInt(maxRoundsToWait)) {\n try {\n const pendingInfo = await algod.pendingTransactionInformation(transactionId).do()\n\n if (pendingInfo !== undefined) {\n const confirmedRound = pendingInfo.confirmedRound\n if (confirmedRound && confirmedRound > 0) {\n return pendingInfo\n } else {\n const poolError = pendingInfo.poolError\n if (poolError != null && poolError.length > 0) {\n // If there was a pool error, then the transaction has been rejected!\n throw new Error(`Transaction ${transactionId} was rejected; pool error: ${poolError}`)\n }\n }\n }\n } catch (e: unknown) {\n if ((e as Error).name === 'URLTokenBaseHTTPError') {\n currentRound++\n continue\n }\n }\n\n await algod.statusAfterBlock(toNumber(currentRound)).do()\n currentRound++\n }\n\n throw new Error(`Transaction ${transactionId} not confirmed after ${maxRoundsToWait} rounds`)\n}\n\n/**\n * @deprecated Use `TransactionComposer` and the `maxFee` field in the transaction params instead.\n *\n * Limit the acceptable fee to a defined amount of µAlgo.\n * This also sets the transaction to be flatFee to ensure the transaction only succeeds at\n * the estimated rate.\n * @param transaction The transaction to cap or suggested params object about to be used to create a transaction\n * @param maxAcceptableFee The maximum acceptable fee to pay\n */\nexport function capTransactionFee(transaction: algosdk.Transaction | SuggestedParams, maxAcceptableFee: AlgoAmount) {\n // If a flat fee hasn't already been defined\n if (!('flatFee' in transaction) || !transaction.flatFee) {\n // Once a transaction has been constructed by algosdk, transaction.fee indicates what the total transaction fee\n // Will be based on the current suggested fee-per-byte value.\n if (transaction.fee > maxAcceptableFee.microAlgo) {\n throw new Error(\n `Cancelled transaction due to high network congestion fees. Algorand suggested fees would cause this transaction to cost ${transaction.fee} µALGO. Cap for this transaction is ${maxAcceptableFee.microAlgo} µALGO.`,\n )\n } else if (transaction.fee > 1_000_000) {\n Config.logger.warn(`Algorand network congestion fees are in effect. This transaction will incur a fee of ${transaction.fee} µALGO.`)\n }\n\n // Now set the flat on the transaction. Otherwise the network may increase the fee above our cap and perform the transaction.\n if ('flatFee' in transaction) {\n transaction.flatFee = true\n }\n }\n}\n\n/**\n * @deprecated Use `TransactionComposer` and the `maxFee` and `staticFee` fields in the transaction params instead.\n *\n * Allows for control of fees on a `Transaction` or `SuggestedParams` object\n * @param transaction The transaction or suggested params\n * @param feeControl The fee control parameters\n */\nexport function controlFees<T extends SuggestedParams | Transaction>(\n transaction: T,\n feeControl: { fee?: AlgoAmount; maxFee?: AlgoAmount },\n) {\n const { fee, maxFee } = feeControl\n if (fee) {\n transaction.fee = Number(fee.microAlgo)\n if ('flatFee' in transaction) {\n transaction.flatFee = true\n }\n }\n\n if (maxFee !== undefined) {\n capTransactionFee(transaction, maxFee)\n }\n\n return transaction\n}\n\n/**\n * @deprecated Use `suggestedParams ? { ...suggestedParams } : await algod.getTransactionParams().do()` instead\n *\n * Returns suggested transaction parameters from algod unless some are already provided.\n * @param params Optionally provide parameters to use\n * @param algod Algod algod\n * @returns The suggested transaction parameters\n */\nexport async function getTransactionParams(params: SuggestedParams | undefined, algod: Algodv2): Promise<SuggestedParams> {\n if (params) {\n return { ...params }\n }\n const p = await algod.getTransactionParams().do()\n return {\n fee: p.fee,\n firstValid: p.firstValid,\n lastValid: p.lastValid,\n genesisID: p.genesisID,\n genesisHash: p.genesisHash,\n minFee: p.minFee,\n }\n}\n\n/**\n * @deprecated Use `atc.clone().buildGroup()` instead.\n *\n * Returns the array of transactions currently present in the given `AtomicTransactionComposer`\n * @param atc The atomic transaction composer\n * @returns The array of transactions with signers\n */\nexport function getAtomicTransactionComposerTransactions(atc: AtomicTransactionComposer) {\n try {\n return atc.clone().buildGroup()\n } catch {\n return []\n }\n}\n"],"names":[],"mappings":";;;;;;;AAqBA,IAAO,yBAAyB,GAAG,OAAO,CAAC,yBAAyB;AAS7D,MAAM,0BAA0B,GAAG;AACnC,MAAM,+BAA+B,GAAG;AACxC,MAAM,+BAA+B,GAAG;AAE/C;;;;;;;;;;;;;;AAcG;AACG,SAAU,qBAAqB,CAAC,IAAsB,EAAA;IAC1D,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE;AAC/C,QAAA,OAAO,SAAS;;SACX,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,WAAW,KAAK,UAAU,EAAE;AACtE,QAAA,OAAO,IAAI;;SACN,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,UAAU,IAAI,IAAI,EAAE;AACzD,QAAA,MAAM,WAAW,GAAG,CAAG,EAAA,IAAI,CAAC,QAAQ,CAAA,CAAA,EAAI,IAAI,CAAC,MAAM,CAAA,EAAG,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,GAAG,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;AACrH,QAAA,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE;AACjC,QAAA,OAAO,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC;;SAC7B;AACL,QAAA,MAAM,CAAC,GAAG,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC,IAAI,CA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AoB,CAAC,MAAmC,EAAE,KAAc,EAAA;IAC5F,IAAI,MAAM,EAAE;AACV,QAAA,OAAO,EAAE,GAAG,MAAM,EAAE;;IAEtB,MAAM,CAAC,GAAG,MAAM,KAAK,CAAC,oBAAoB,EAAE,CAAC,EAAE,EAAE;IACjD,OAAO;QACL,GAAG,EAAE,CAAC,CAAC,GAAG;QACV,UAAU,EAAE,CAAC,CAAC,UAAU;QACxB,SAAS,EAAE,CAAC,CAAC,SAAS;QACtB,SAAS,EAAE,CAAC,CAAC,SAAS;QACtB,WAAW,EAAE,CAAC,CAAC,WAAW;QAC1B,MAAM,EAAE,CAAC,CAAC,MAAM;KACjB;AACH;AAEA;;;;;;AAMG;AACG,SAAU,wCAAwC,CAAC,GAA8B,EAAA;AACrF,IAAA,IAAI;AACF,QAAA,OAAO,GAAG,CAAC,KAAK,EAAE,CAAC,UAAU,EAAE;;AAC/B,IAAA,MAAM;AACN,QAAA,OAAO,EAAE;;AAEb;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { legacySendTransactionBridge } from '../transaction/legacy-bridge.mjs';
2
- import { getSenderAddress, encodeTransactionNote } from '../transaction/transaction.mjs';
2
+ import { encodeTransactionNote, getSenderAddress } from '../transaction/transaction.mjs';
3
3
 
4
4
  /**
5
5
  * @deprecated Use `algorand.send.payment()` / `algorand.createTransaction.payment()` instead
@@ -1 +1 @@
1
- {"version":3,"file":"account-manager.js","sources":["../../src/types/account-manager.ts"],"sourcesContent":["import algosdk, { Address } from 'algosdk'\nimport { Config } from '../config'\nimport { calculateFundAmount, memoize } from '../util'\nimport { AccountInformation, DISPENSER_ACCOUNT, MultisigAccount, SigningAccount, TransactionSignerAccount } from './account'\nimport { AlgoAmount } from './amount'\nimport { ClientManager } from './client-manager'\nimport { CommonTransactionParams, TransactionComposer } from './composer'\nimport { TestNetDispenserApiClient } from './dispenser-client'\nimport { KmdAccountManager } from './kmd-account-manager'\nimport { SendParams, SendSingleTransactionResult } from './transaction'\nimport LogicSigAccount = algosdk.LogicSigAccount\nimport Account = algosdk.Account\nimport TransactionSigner = algosdk.TransactionSigner\n\nconst address = (address: string | Address) => (typeof address === 'string' ? Address.fromString(address) : address)\n\n/** Result from performing an ensureFunded call. */\nexport interface EnsureFundedResult {\n /** The transaction ID of the transaction that funded the account. */\n transactionId: string\n /** The amount that was sent to the account. */\n amountFunded: AlgoAmount\n}\n\n/**\n * Returns a `TransactionSigner` for the given account that can sign a transaction.\n * This function has memoization, so will return the same transaction signer for a given account.\n * @param account An account that can sign a transaction\n * @returns A transaction signer\n * @example\n * ```typescript\n * const signer = getAccountTransactionSigner(account)\n * ```\n */\nexport const getAccountTransactionSigner = memoize(function (\n account: TransactionSignerAccount | Account | SigningAccount | LogicSigAccount | MultisigAccount,\n): TransactionSigner {\n return 'signer' in account\n ? account.signer\n : 'lsig' in account\n ? algosdk.makeLogicSigAccountTransactionSigner(account)\n : algosdk.makeBasicAccountTransactionSigner(account)\n})\n\n/** Creates and keeps track of signing accounts that can sign transactions for a sending address. */\nexport class AccountManager {\n private _clientManager: ClientManager\n private _kmdAccountManager: KmdAccountManager\n private _accounts: { [address: string]: TransactionSignerAccount } = {}\n private _defaultSigner?: algosdk.TransactionSigner\n\n /**\n * Create a new account manager.\n * @param clientManager The ClientManager client to use for algod and kmd clients\n * @example Create a new account manager\n * ```typescript\n * const accountManager = new AccountManager(clientManager)\n * ```\n */\n constructor(clientManager: ClientManager) {\n this._clientManager = clientManager\n this._kmdAccountManager = new KmdAccountManager(clientManager)\n }\n\n private _getComposer(getSuggestedParams?: () => Promise<algosdk.SuggestedParams>) {\n return new TransactionComposer({\n algod: this._clientManager.algod,\n getSigner: this.getSigner.bind(this),\n getSuggestedParams: getSuggestedParams ?? (() => this._clientManager.algod.getTransactionParams().do()),\n })\n }\n\n /**\n * KMD account manager that allows you to easily get and create accounts using KMD.\n * @returns The `KmdAccountManager` instance.\n * @example\n * ```typescript\n * const kmdManager = accountManager.kmd;\n * ```\n */\n public get kmd() {\n return this._kmdAccountManager\n }\n\n /**\n * Sets the default signer to use if no other signer is specified.\n *\n * If this isn't set an a transaction needs signing for a given sender\n * then an error will be thrown from `getSigner` / `getAccount`.\n * @param signer The signer to use, either a `TransactionSigner` or a `TransactionSignerAccount`\n * @example\n * ```typescript\n * const signer = accountManager.random() // Can be anything that returns a `algosdk.TransactionSigner` or `TransactionSignerAccount`\n * accountManager.setDefaultSigner(signer)\n *\n * // When signing a transaction, if there is no signer registered for the sender then the default signer will be used\n * const signer = accountManager.getSigner(\"SENDERADDRESS\")\n * ```\n * @returns The `AccountManager` so method calls can be chained\n */\n public setDefaultSigner(signer: algosdk.TransactionSigner | TransactionSignerAccount): AccountManager {\n this._defaultSigner = 'signer' in signer ? signer.signer : signer\n return this\n }\n\n /**\n * Records the given account (that can sign) against the address of the provided account for later\n * retrieval and returns a `TransactionSignerAccount` along with the original account in an `account` property.\n */\n\n private signerAccount<T extends TransactionSignerAccount | Account | SigningAccount | LogicSigAccount | MultisigAccount>(\n account: T,\n ): Address &\n TransactionSignerAccount & {\n /* The underlying account that specified this address. */ account: T\n } {\n const signer = getAccountTransactionSigner(account)\n const acc: TransactionSignerAccount = {\n addr: 'addr' in account ? account.addr : account.address(),\n signer: signer,\n }\n this._accounts[acc.addr.toString()] = acc\n\n const addressWithAccount = Address.fromString(acc.addr.toString()) as Address & TransactionSignerAccount & { account: T }\n addressWithAccount.account = account\n addressWithAccount.addr = acc.addr\n addressWithAccount.signer = signer\n return addressWithAccount\n }\n\n /**\n * Tracks the given account for later signing.\n *\n * Note: If you are generating accounts via the various methods on `AccountManager`\n * (like `random`, `fromMnemonic`, `logicsig`, etc.) then they automatically get tracked.\n * @param account The account to register, which can be a `TransactionSignerAccount` or\n * a `algosdk.Account`, `algosdk.LogicSigAccount`, `SigningAccount` or `MultisigAccount`\n * @example\n * ```typescript\n * const accountManager = new AccountManager(clientManager)\n * .setSignerFromAccount(algosdk.generateAccount())\n * .setSignerFromAccount(new algosdk.LogicSigAccount(program, args))\n * .setSignerFromAccount(new SigningAccount(mnemonic, sender))\n * .setSignerFromAccount(new MultisigAccount({version: 1, threshold: 1, addrs: [\"ADDRESS1...\", \"ADDRESS2...\"]}, [account1, account2]))\n * .setSignerFromAccount({addr: \"SENDERADDRESS\", signer: transactionSigner})\n * ```\n * @returns The `AccountManager` instance for method chaining\n */\n public setSignerFromAccount(account: TransactionSignerAccount | Account | LogicSigAccount | SigningAccount | MultisigAccount) {\n this.signerAccount(account)\n return this\n }\n\n /**\n * Tracks the given `algosdk.TransactionSigner` against the given sender address for later signing.\n * @param sender The sender address to use this signer for\n * @param signer The `algosdk.TransactionSigner` to sign transactions with for the given sender\n * @example\n * ```typescript\n * const accountManager = new AccountManager(clientManager)\n * .setSigner(\"SENDERADDRESS\", transactionSigner)\n * ```\n * @returns The `AccountManager` instance for method chaining\n */\n public setSigner(sender: string | Address, signer: algosdk.TransactionSigner) {\n this._accounts[address(sender).toString()] = { addr: address(sender), signer }\n return this\n }\n\n /**\n * Takes all registered signers from the given `AccountManager` and adds them to this `AccountManager`.\n *\n * This is useful for situations where you have multiple contexts you are building accounts in such as unit tests.\n * @param anotherAccountManager Another account manager with signers registered\n * @param overwriteExisting Whether or not to overwrite any signers that have the same sender address with the ones in the other account manager or not (default: true)\n * @returns The `AccountManager` instance for method chaining\n * @example\n * ```typescript\n * accountManager2.setSigners(accountManager1);\n * ```\n */\n public setSigners(anotherAccountManager: AccountManager, overwriteExisting = true) {\n this._accounts = overwriteExisting\n ? { ...this._accounts, ...anotherAccountManager._accounts }\n : { ...anotherAccountManager._accounts, ...this._accounts }\n return this\n }\n\n /**\n * Returns the `TransactionSigner` for the given sender address, ready to sign a transaction for that sender.\n *\n * If no signer has been registered for that address then the default signer is used if registered and\n * if not then an error is thrown.\n *\n * @param sender The sender address\n * @example\n * ```typescript\n * const signer = accountManager.getSigner(\"SENDERADDRESS\")\n * ```\n * @returns The `TransactionSigner` or throws an error if not found and no default signer is set\n */\n public getSigner(sender: string | Address): algosdk.TransactionSigner {\n const signer = this._accounts[address(sender).toString()]?.signer ?? this._defaultSigner\n if (!signer) throw new Error(`No signer found for address ${sender}`)\n return signer\n }\n\n /**\n * Returns the `TransactionSignerAccount` for the given sender address.\n *\n * If no signer has been registered for that address then an error is thrown.\n * @param sender The sender address\n * @example\n * ```typescript\n * const sender = accountManager.random()\n * // ...\n * // Returns the `TransactionSignerAccount` for `sender` that has previously been registered\n * const account = accountManager.getAccount(sender)\n * ```\n * @returns The `TransactionSignerAccount` or throws an error if not found\n */\n public getAccount(sender: string | Address): TransactionSignerAccount {\n const account = this._accounts[address(sender).toString()]\n if (!account) throw new Error(`No signer found for address ${sender}`)\n return account\n }\n\n /**\n * Returns the given sender account's current status, balance and spendable amounts.\n *\n * [Response data schema details](https://dev.algorand.co/reference/rest-apis/algod/#accountinformation)\n * @example\n * ```typescript\n * const address = \"XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA\";\n * const accountInfo = await accountManager.getInformation(address);\n * ```\n *\n * @param sender The account / address to look up\n * @returns The account information\n */\n public async getInformation(sender: string | Address): Promise<AccountInformation> {\n const {\n round,\n lastHeartbeat = undefined,\n lastProposed = undefined,\n address,\n ...account\n } = await this._clientManager.algod.accountInformation(sender).do()\n\n return {\n ...account,\n // None of the Number types can practically overflow 2^53\n address: Address.fromString(address),\n balance: AlgoAmount.MicroAlgo(Number(account.amount)),\n amountWithoutPendingRewards: AlgoAmount.MicroAlgo(Number(account.amountWithoutPendingRewards)),\n minBalance: AlgoAmount.MicroAlgo(Number(account.minBalance)),\n pendingRewards: AlgoAmount.MicroAlgo(Number(account.pendingRewards)),\n rewards: AlgoAmount.MicroAlgo(Number(account.rewards)),\n validAsOfRound: BigInt(round),\n totalAppsOptedIn: Number(account.totalAppsOptedIn),\n totalAssetsOptedIn: Number(account.totalAssetsOptedIn),\n totalCreatedApps: Number(account.totalCreatedApps),\n totalCreatedAssets: Number(account.totalCreatedAssets),\n appsTotalExtraPages: account.appsTotalExtraPages !== undefined ? Number(account.appsTotalExtraPages) : undefined,\n rewardBase: account.rewardBase !== undefined ? Number(account.rewardBase) : undefined,\n totalBoxBytes: account.totalBoxBytes !== undefined ? Number(account.totalBoxBytes) : undefined,\n totalBoxes: account.totalBoxes !== undefined ? Number(account.totalBoxes) : undefined,\n lastHeartbeatRound: lastHeartbeat !== undefined ? BigInt(lastHeartbeat) : undefined,\n lastProposedRound: lastProposed !== undefined ? BigInt(lastProposed) : undefined,\n }\n }\n\n /**\n * Tracks and returns an Algorand account with secret key loaded (i.e. that can sign transactions) by taking the mnemonic secret.\n *\n * @example\n * ```typescript\n * const account = accountManager.fromMnemonic(\"mnemonic secret ...\")\n * const rekeyedAccount = accountManager.fromMnemonic(\"mnemonic secret ...\", \"SENDERADDRESS...\")\n * ```\n * @param mnemonicSecret The mnemonic secret representing the private key of an account; **Note: Be careful how the mnemonic is handled**,\n * never commit it into source control and ideally load it from the environment (ideally via a secret storage service) rather than the file system.\n * @param sender The optional sender address to use this signer for (aka a rekeyed account)\n * @returns The account\n */\n public fromMnemonic(mnemonicSecret: string, sender?: string | Address) {\n const account = algosdk.mnemonicToSecretKey(mnemonicSecret)\n return this.signerAccount(new SigningAccount(account, sender))\n }\n\n /**\n * Tracks and returns an Algorand account that is a rekeyed version of the given account to a new sender.\n *\n * @example\n * ```typescript\n * const account = accountManager.fromMnemonic(\"mnemonic secret ...\")\n * const rekeyedAccount = accountManager.rekeyed(account, \"SENDERADDRESS...\")\n * ```\n * @param account The account to use as the signer for this new rekeyed account\n * @param sender The sender address to use as the new sender\n * @returns The account\n */\n public rekeyed(sender: string | Address, account: TransactionSignerAccount) {\n return this.signerAccount({ addr: address(sender), signer: account.signer })\n }\n\n /**\n * Tracks and returns an Algorand account with private key loaded by convention from environment variables based on the given name identifier.\n *\n * Note: This function expects to run in a Node.js environment.\n *\n * ## Convention:\n * * **Non-LocalNet:** will load process.env['\\{NAME\\}_MNEMONIC'] as a mnemonic secret; **Note: Be careful how the mnemonic is handled**,\n * never commit it into source control and ideally load it via a secret storage service rather than the file system.\n * If process.env['\\{NAME\\}_SENDER'] is defined then it will use that for the sender address (i.e. to support rekeyed accounts)\n * * **LocalNet:** will load the account from a KMD wallet called \\{NAME\\} and if that wallet doesn't exist it will create it and fund the account for you\n *\n * This allows you to write code that will work seamlessly in production and local development (LocalNet) without manual config locally (including when you reset the LocalNet).\n *\n * @example Default\n *\n * If you have a mnemonic secret loaded into `process.env.MY_ACCOUNT_MNEMONIC` then you can call the following to get that private key loaded into an account object:\n * ```typescript\n * const account = await accountManager.fromEnvironment('MY_ACCOUNT')\n * ```\n *\n * If that code runs against LocalNet then a wallet called `MY_ACCOUNT` will automatically be created with an account that is automatically funded with 1000 (default) ALGO from the default LocalNet dispenser.\n * If not running against LocalNet then it will use proces.env.MY_ACCOUNT_MNEMONIC as the private key and (if present) process.env.MY_ACCOUNT_SENDER as the sender address.\n *\n * @param name The name identifier of the account\n * @param fundWith The optional amount to fund the account with when it gets created (when targeting LocalNet), if not specified then 1000 ALGO will be funded from the dispenser account\n * @returns The account\n */\n public async fromEnvironment(name: string, fundWith?: AlgoAmount) {\n if (!process || !process.env) {\n throw new Error('Attempt to get account with private key from a non Node.js context; this is not supported!')\n }\n\n const accountMnemonic = process.env[`${name.toUpperCase()}_MNEMONIC`]\n const sender = process.env[`${name.toUpperCase()}_SENDER`]\n\n if (accountMnemonic) {\n const signer = algosdk.mnemonicToSecretKey(accountMnemonic)\n return this.signerAccount(new SigningAccount(signer, sender))\n }\n\n if (await this._clientManager.isLocalNet()) {\n const account = await this._kmdAccountManager.getOrCreateWalletAccount(name, fundWith)\n return this.signerAccount(account.account)\n }\n\n throw new Error(`Missing environment variable ${name.toUpperCase()}_MNEMONIC when looking for account ${name}`)\n }\n\n /**\n * Tracks and returns an Algorand account with private key loaded from the given KMD wallet (identified by name).\n *\n * @param name The name of the wallet to retrieve an account from\n * @param predicate An optional filter to use to find the account (otherwise it will return a random account from the wallet)\n * @param sender The optional sender address to use this signer for (aka a rekeyed account)\n * @example Get default funded account in a LocalNet\n *\n * ```typescript\n * const defaultDispenserAccount = await accountManager.fromKmd('unencrypted-default-wallet',\n * a => a.status !== 'Offline' && a.amount > 1_000_000_000\n * )\n * ```\n * @returns The account\n */\n public async fromKmd(\n name: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n predicate?: (account: Record<string, any>) => boolean,\n sender?: string | Address,\n ) {\n const account = await this._kmdAccountManager.getWalletAccount(name, predicate, sender)\n if (!account) throw new Error(`Unable to find KMD account ${name}${predicate ? ' with predicate' : ''}`)\n return this.signerAccount(account.account)\n }\n\n /**\n * Tracks and returns an account that supports partial or full multisig signing.\n *\n * @example\n * ```typescript\n * const account = accountManager.multisig({version: 1, threshold: 1, addrs: [\"ADDRESS1...\", \"ADDRESS2...\"]},\n * [(await accountManager.fromEnvironment('ACCOUNT1')).account])\n * ```\n * @param multisigParams The parameters that define the multisig account\n * @param signingAccounts The signers that are currently present\n * @returns A multisig account wrapper\n */\n public multisig(multisigParams: algosdk.MultisigMetadata, signingAccounts: (algosdk.Account | SigningAccount)[]) {\n return this.signerAccount(new MultisigAccount(multisigParams, signingAccounts))\n }\n\n /**\n * Tracks and returns an account that represents a logic signature.\n *\n * @example\n * ```typescript\n * const account = accountManager.logicsig(program, [new Uint8Array(3, ...)])\n * ```\n * @param program The bytes that make up the compiled logic signature\n * @param args The (binary) arguments to pass into the logic signature\n * @returns A logic signature account wrapper\n */\n public logicsig(program: Uint8Array, args?: Array<Uint8Array>) {\n return this.signerAccount(new LogicSigAccount(program, args))\n }\n\n /**\n * Tracks and returns a new, random Algorand account with secret key loaded.\n *\n * @example\n * ```typescript\n * const account = accountManager.random()\n * ```\n * @returns The account\n */\n public random() {\n return this.signerAccount(algosdk.generateAccount())\n }\n\n /**\n * Returns an account (with private key loaded) that can act as a dispenser from\n * environment variables, or against default LocalNet if no environment variables present.\n *\n * Note: requires a Node.js environment to execute.\n *\n * If present, it will load the account mnemonic stored in process.env.DISPENSER_MNEMONIC and optionally\n * process.env.DISPENSER_SENDER if it's a rekeyed account.\n *\n * @example\n * ```typescript\n * const account = await accountManager.dispenserFromEnvironment()\n * ```\n *\n * @returns The account\n */\n public async dispenserFromEnvironment() {\n if (!process || !process.env) {\n throw new Error('Attempt to get dispenser from environment from a non Node.js context; this is not supported!')\n }\n\n return process.env[`${DISPENSER_ACCOUNT.toUpperCase()}_MNEMONIC`]\n ? await this.fromEnvironment(DISPENSER_ACCOUNT)\n : await this.localNetDispenser()\n }\n\n /**\n * Returns an Algorand account with private key loaded for the default LocalNet dispenser account (that can be used to fund other accounts).\n *\n * @example\n * ```typescript\n * const account = await accountManager.localNetDispenser()\n * ```\n * @returns The account\n */\n public async localNetDispenser() {\n const dispenser = await this._kmdAccountManager.getLocalNetDispenserAccount()\n return this.signerAccount(dispenser.account)\n }\n\n /**\n * Rekey an account to a new address.\n *\n * **Note:** Please be careful with this function and be sure to read the [official rekey guidance](https://dev.algorand.co/concepts/accounts/rekeying).\n *\n * @param account The account to rekey\n * @param rekeyTo The account address or signing account of the account that will be used to authorise transactions for the rekeyed account going forward.\n * If a signing account is provided that will now be tracked as the signer for `account` in this `AccountManager`\n * @param options Any parameters to control the transaction or execution of the transaction\n *\n * @example Basic example (with string addresses)\n * ```typescript\n * await accountManager.rekeyAccount({account: \"ACCOUNTADDRESS\", rekeyTo: \"NEWADDRESS\"})\n * ```\n * @example Basic example (with signer accounts)\n * ```typescript\n * await accountManager.rekeyAccount({account: account1, rekeyTo: newSignerAccount})\n * ```\n * @example Advanced example\n * ```typescript\n * await accountManager.rekeyAccount({\n * account: \"ACCOUNTADDRESS\",\n * rekeyTo: \"NEWADDRESS\",\n * lease: 'lease',\n * note: 'note',\n * firstValidRound: 1000n,\n * validityWindow: 10,\n * extraFee: (1000).microAlgo(),\n * staticFee: (1000).microAlgo(),\n * // Max fee doesn't make sense with extraFee AND staticFee\n * // already specified, but here for completeness\n * maxFee: (3000).microAlgo(),\n * maxRoundsToWaitForConfirmation: 5,\n * suppressLog: true,\n * })\n * ```\n * @returns The result of the transaction and the transaction that was sent\n */\n async rekeyAccount(\n account: string | Address,\n rekeyTo: string | Address | TransactionSignerAccount,\n options?: Omit<CommonTransactionParams, 'sender'> & SendParams,\n ): Promise<SendSingleTransactionResult> {\n const result = await this._getComposer()\n .addPayment({\n ...options,\n sender: address(account),\n receiver: address(account),\n amount: AlgoAmount.MicroAlgo(0),\n rekeyTo: address(typeof rekeyTo === 'object' && 'addr' in rekeyTo ? rekeyTo.addr : rekeyTo),\n })\n .send(options)\n\n // If the rekey is a signing account set it as the signer for this account\n if (typeof rekeyTo === 'object' && 'addr' in rekeyTo) {\n this.rekeyed(account, rekeyTo)\n }\n\n Config.getLogger(options?.suppressLog).info(`Rekeyed ${account} to ${rekeyTo} via transaction ${result.txIds.at(-1)}`)\n\n return { ...result, transaction: result.transactions.at(-1)!, confirmation: result.confirmations.at(-1)! }\n }\n\n private async _getEnsureFundedAmount(sender: Address, minSpendingBalance: AlgoAmount, minFundingIncrement?: AlgoAmount) {\n const accountInfo = await this.getInformation(sender)\n const currentSpendingBalance = accountInfo.balance.microAlgo - accountInfo.minBalance.microAlgo\n\n const amountFunded = calculateFundAmount(minSpendingBalance.microAlgo, currentSpendingBalance, minFundingIncrement?.microAlgo ?? 0n)\n\n return amountFunded === null ? undefined : AlgoAmount.MicroAlgo(amountFunded)\n }\n\n /**\n * Funds a given account using a dispenser account as a funding source such that\n * the given account has a certain amount of Algo free to spend (accounting for\n * Algo locked in minimum balance requirement).\n *\n * https://dev.algorand.co/concepts/smart-contracts/costs-constraints#mbr\n *\n * @param accountToFund The account to fund\n * @param dispenserAccount The account to use as a dispenser funding source\n * @param minSpendingBalance The minimum balance of Algo that the account should have available to spend (i.e. on top of minimum balance requirement)\n * @param options Optional parameters to control the funding increment, transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * await accountManager.ensureFunded(\"ACCOUNTADDRESS\", \"DISPENSERADDRESS\", algokit.algo(1))\n * // With configuration\n * await accountManager.ensureFunded(\"ACCOUNTADDRESS\", \"DISPENSERADDRESS\", algokit.algo(1),\n * { minFundingIncrement: algokit.algo(2), fee: (1000).microAlgo(), suppressLog: true }\n * )\n * ```\n * @returns\n * - The result of executing the dispensing transaction and the `amountFunded` if funds were needed.\n * - `undefined` if no funds were needed.\n */\n async ensureFunded(\n accountToFund: string | Address,\n dispenserAccount: string | Address,\n minSpendingBalance: AlgoAmount,\n options?: {\n minFundingIncrement?: AlgoAmount\n } & SendParams &\n Omit<CommonTransactionParams, 'sender'>,\n ): Promise<(SendSingleTransactionResult & EnsureFundedResult) | undefined> {\n const addressToFund = address(accountToFund)\n\n const amountFunded = await this._getEnsureFundedAmount(addressToFund, minSpendingBalance, options?.minFundingIncrement)\n if (!amountFunded) return undefined\n\n const result = await this._getComposer()\n .addPayment({\n ...options,\n sender: address(dispenserAccount),\n receiver: addressToFund,\n amount: amountFunded,\n })\n .send(options)\n\n return {\n ...result,\n transaction: result.transactions[0],\n confirmation: result.confirmations[0],\n transactionId: result.txIds[0],\n amountFunded: amountFunded,\n }\n }\n\n /**\n * Funds a given account using a dispenser account retrieved from the environment,\n * per the `dispenserFromEnvironment` method, as a funding source such that\n * the given account has a certain amount of Algo free to spend (accounting for\n * Algo locked in minimum balance requirement).\n *\n * **Note:** requires a Node.js environment to execute.\n *\n * The dispenser account is retrieved from the account mnemonic stored in\n * process.env.DISPENSER_MNEMONIC and optionally process.env.DISPENSER_SENDER\n * if it's a rekeyed account, or against default LocalNet if no environment variables present.\n *\n * https://dev.algorand.co/concepts/smart-contracts/costs-constraints#mbr\n *\n * @param accountToFund The account to fund\n * @param minSpendingBalance The minimum balance of Algo that the account should have available to spend (i.e. on top of minimum balance requirement)\n * @param options Optional parameters to control the funding increment, transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * await accountManager.ensureFundedFromEnvironment(\"ACCOUNTADDRESS\", algokit.algo(1))\n * // With configuration\n * await accountManager.ensureFundedFromEnvironment(\"ACCOUNTADDRESS\", algokit.algo(1),\n * { minFundingIncrement: algokit.algo(2), fee: (1000).microAlgo(), suppressLog: true }\n * )\n * ```\n * @returns\n * - The result of executing the dispensing transaction and the `amountFunded` if funds were needed.\n * - `undefined` if no funds were needed.\n */\n async ensureFundedFromEnvironment(\n accountToFund: string | Address,\n minSpendingBalance: AlgoAmount,\n options?: {\n minFundingIncrement?: AlgoAmount\n } & SendParams &\n Omit<CommonTransactionParams, 'sender'>,\n ): Promise<(SendSingleTransactionResult & EnsureFundedResult) | undefined> {\n const addressToFund = address(accountToFund)\n const dispenserAccount = await this.dispenserFromEnvironment()\n\n const amountFunded = await this._getEnsureFundedAmount(addressToFund, minSpendingBalance, options?.minFundingIncrement)\n if (!amountFunded) return undefined\n\n const result = await this._getComposer()\n .addPayment({\n ...options,\n sender: dispenserAccount,\n receiver: addressToFund,\n amount: amountFunded,\n })\n .send(options)\n\n return {\n ...result,\n transaction: result.transactions[0],\n confirmation: result.confirmations[0],\n transactionId: result.txIds[0],\n amountFunded: amountFunded,\n }\n }\n\n /**\n * Funds a given account using the TestNet Dispenser API as a funding source such that\n * the account has a certain amount of Algo free to spend (accounting for Algo locked\n * in minimum balance requirement).\n *\n * https://dev.algorand.co/concepts/smart-contracts/costs-constraints#mbr\n *\n * @param accountToFund The account to fund\n * @param dispenserClient The TestNet dispenser funding client\n * @param minSpendingBalance The minimum balance of Algo that the account should have available to spend (i.e. on top of minimum balance requirement)\n * @param options Optional parameters to control the funding increment, transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * await accountManager.ensureFundedFromTestNetDispenserApi(\"ACCOUNTADDRESS\", algorand.client.getTestNetDispenserFromEnvironment(), algokit.algo(1))\n * // With configuration\n * await accountManager.ensureFundedFromTestNetDispenserApi(\"ACCOUNTADDRESS\", algorand.client.getTestNetDispenserFromEnvironment(), algokit.algo(1),\n * { minFundingIncrement: algokit.algo(2) }\n * )\n * ```\n * @returns\n * - The result of executing the dispensing transaction and the `amountFunded` if funds were needed.\n * - `undefined` if no funds were needed.\n */\n async ensureFundedFromTestNetDispenserApi(\n accountToFund: string | Address,\n dispenserClient: TestNetDispenserApiClient,\n minSpendingBalance: AlgoAmount,\n options?: {\n minFundingIncrement?: AlgoAmount\n },\n ): Promise<EnsureFundedResult | undefined> {\n if (!(await this._clientManager.isTestNet())) {\n throw new Error('Attempt to fund using TestNet dispenser API on non TestNet network.')\n }\n\n const addressToFund = address(accountToFund)\n\n const amountFunded = await this._getEnsureFundedAmount(addressToFund, minSpendingBalance, options?.minFundingIncrement)\n if (!amountFunded) return undefined\n\n const result = await dispenserClient.fund(addressToFund, amountFunded.microAlgo)\n return {\n amountFunded: AlgoAmount.MicroAlgo(result.amount),\n transactionId: result.txId,\n }\n }\n}\n"],"names":["Address","memoize","KmdAccountManager","TransactionComposer","AlgoAmount","SigningAccount","MultisigAccount","DISPENSER_ACCOUNT","Config","calculateFundAmount"],"mappings":";;;;;;;;;;AAUA,IAAO,eAAe,GAAG,OAAO,CAAC,eAAe;AAIhD,MAAM,OAAO,GAAG,CAAC,OAAyB,MAAM,OAAO,OAAO,KAAK,QAAQ,GAAGA,eAAO,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAUpH;;;;;;;;;AASG;AACU,MAAA,2BAA2B,GAAGC,YAAO,CAAC,UACjD,OAAgG,EAAA;IAEhG,OAAO,QAAQ,IAAI;UACf,OAAO,CAAC;UACR,MAAM,IAAI;AACV,cAAE,OAAO,CAAC,oCAAoC,CAAC,OAAO;AACtD,cAAE,OAAO,CAAC,iCAAiC,CAAC,OAAO,CAAC;AAC1D,CAAC;AAED;MACa,cAAc,CAAA;AAMzB;;;;;;;AAOG;AACH,IAAA,WAAA,CAAY,aAA4B,EAAA;QAXhC,IAAS,CAAA,SAAA,GAAoD,EAAE;AAYrE,QAAA,IAAI,CAAC,cAAc,GAAG,aAAa;QACnC,IAAI,CAAC,k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a,EAAE,MAAM,CAAC,IAAI;SAC3B;;AAEJ;;;;;"}
1
+ {"version":3,"file":"account-manager.js","sources":["../../src/types/account-manager.ts"],"sourcesContent":["import algosdk, { Address } from 'algosdk'\nimport { Config } from '../config'\nimport { calculateFundAmount, memoize } from '../util'\nimport { AccountInformation, DISPENSER_ACCOUNT, MultisigAccount, SigningAccount, TransactionSignerAccount } from './account'\nimport { AlgoAmount } from './amount'\nimport { ClientManager } from './client-manager'\nimport { CommonTransactionParams, TransactionComposer } from './composer'\nimport { TestNetDispenserApiClient } from './dispenser-client'\nimport { KmdAccountManager } from './kmd-account-manager'\nimport { SendParams, SendSingleTransactionResult } from './transaction'\nimport LogicSigAccount = algosdk.LogicSigAccount\nimport Account = algosdk.Account\nimport TransactionSigner = algosdk.TransactionSigner\n\nconst address = (address: string | Address) => (typeof address === 'string' ? Address.fromString(address) : address)\n\n/** Result from performing an ensureFunded call. */\nexport interface EnsureFundedResult {\n /** The transaction ID of the transaction that funded the account. */\n transactionId: string\n /** The amount that was sent to the account. */\n amountFunded: AlgoAmount\n}\n\n/**\n * Returns a `TransactionSigner` for the given account that can sign a transaction.\n * This function has memoization, so will return the same transaction signer for a given account.\n * @param account An account that can sign a transaction\n * @returns A transaction signer\n * @example\n * ```typescript\n * const signer = getAccountTransactionSigner(account)\n * ```\n */\nexport const getAccountTransactionSigner = memoize(function (\n account: TransactionSignerAccount | Account | SigningAccount | LogicSigAccount | MultisigAccount,\n): TransactionSigner {\n return 'signer' in account\n ? account.signer\n : 'lsig' in account\n ? algosdk.makeLogicSigAccountTransactionSigner(account)\n : algosdk.makeBasicAccountTransactionSigner(account)\n})\n\n/** Creates and keeps track of signing accounts that can sign transactions for a sending address. */\nexport class AccountManager {\n private _clientManager: ClientManager\n private _kmdAccountManager: KmdAccountManager\n private _accounts: { [address: string]: TransactionSignerAccount } = {}\n private _defaultSigner?: algosdk.TransactionSigner\n\n /**\n * Create a new account manager.\n * @param clientManager The ClientManager client to use for algod and kmd clients\n * @example Create a new account manager\n * ```typescript\n * const accountManager = new AccountManager(clientManager)\n * ```\n */\n constructor(clientManager: ClientManager) {\n this._clientManager = clientManager\n this._kmdAccountManager = new KmdAccountManager(clientManager)\n }\n\n private _getComposer(getSuggestedParams?: () => Promise<algosdk.SuggestedParams>) {\n return new TransactionComposer({\n algod: this._clientManager.algod,\n getSigner: this.getSigner.bind(this),\n getSuggestedParams: getSuggestedParams ?? (() => this._clientManager.algod.getTransactionParams().do()),\n })\n }\n\n /**\n * KMD account manager that allows you to easily get and create accounts using KMD.\n * @returns The `KmdAccountManager` instance.\n * @example\n * ```typescript\n * const kmdManager = accountManager.kmd;\n * ```\n */\n public get kmd() {\n return this._kmdAccountManager\n }\n\n /**\n * Sets the default signer to use if no other signer is specified.\n *\n * If this isn't set an a transaction needs signing for a given sender\n * then an error will be thrown from `getSigner` / `getAccount`.\n * @param signer The signer to use, either a `TransactionSigner` or a `TransactionSignerAccount`\n * @example\n * ```typescript\n * const signer = accountManager.random() // Can be anything that returns a `algosdk.TransactionSigner` or `TransactionSignerAccount`\n * accountManager.setDefaultSigner(signer)\n *\n * // When signing a transaction, if there is no signer registered for the sender then the default signer will be used\n * const signer = accountManager.getSigner(\"SENDERADDRESS\")\n * ```\n * @returns The `AccountManager` so method calls can be chained\n */\n public setDefaultSigner(signer: algosdk.TransactionSigner | TransactionSignerAccount): AccountManager {\n this._defaultSigner = 'signer' in signer ? signer.signer : signer\n return this\n }\n\n /**\n * Records the given account (that can sign) against the address of the provided account for later\n * retrieval and returns a `TransactionSignerAccount` along with the original account in an `account` property.\n */\n\n private signerAccount<T extends TransactionSignerAccount | Account | SigningAccount | LogicSigAccount | MultisigAccount>(\n account: T,\n ): Address &\n TransactionSignerAccount & {\n /* The underlying account that specified this address. */ account: T\n } {\n const signer = getAccountTransactionSigner(account)\n const acc: TransactionSignerAccount = {\n addr: 'addr' in account ? account.addr : account.address(),\n signer: signer,\n }\n this._accounts[acc.addr.toString()] = acc\n\n const addressWithAccount = Address.fromString(acc.addr.toString()) as Address & TransactionSignerAccount & { account: T }\n addressWithAccount.account = account\n addressWithAccount.addr = acc.addr\n addressWithAccount.signer = signer\n return addressWithAccount\n }\n\n /**\n * Tracks the given account for later signing.\n *\n * Note: If you are generating accounts via the various methods on `AccountManager`\n * (like `random`, `fromMnemonic`, `logicsig`, etc.) then they automatically get tracked.\n * @param account The account to register, which can be a `TransactionSignerAccount` or\n * a `algosdk.Account`, `algosdk.LogicSigAccount`, `SigningAccount` or `MultisigAccount`\n * @example\n * ```typescript\n * const accountManager = new AccountManager(clientManager)\n * .setSignerFromAccount(algosdk.generateAccount())\n * .setSignerFromAccount(new algosdk.LogicSigAccount(program, args))\n * .setSignerFromAccount(new SigningAccount(mnemonic, sender))\n * .setSignerFromAccount(new MultisigAccount({version: 1, threshold: 1, addrs: [\"ADDRESS1...\", \"ADDRESS2...\"]}, [account1, account2]))\n * .setSignerFromAccount({addr: \"SENDERADDRESS\", signer: transactionSigner})\n * ```\n * @returns The `AccountManager` instance for method chaining\n */\n public setSignerFromAccount(account: TransactionSignerAccount | Account | LogicSigAccount | SigningAccount | MultisigAccount) {\n this.signerAccount(account)\n return this\n }\n\n /**\n * Tracks the given `algosdk.TransactionSigner` against the given sender address for later signing.\n * @param sender The sender address to use this signer for\n * @param signer The `algosdk.TransactionSigner` to sign transactions with for the given sender\n * @example\n * ```typescript\n * const accountManager = new AccountManager(clientManager)\n * .setSigner(\"SENDERADDRESS\", transactionSigner)\n * ```\n * @returns The `AccountManager` instance for method chaining\n */\n public setSigner(sender: string | Address, signer: algosdk.TransactionSigner) {\n this._accounts[address(sender).toString()] = { addr: address(sender), signer }\n return this\n }\n\n /**\n * Takes all registered signers from the given `AccountManager` and adds them to this `AccountManager`.\n *\n * This is useful for situations where you have multiple contexts you are building accounts in such as unit tests.\n * @param anotherAccountManager Another account manager with signers registered\n * @param overwriteExisting Whether or not to overwrite any signers that have the same sender address with the ones in the other account manager or not (default: true)\n * @returns The `AccountManager` instance for method chaining\n * @example\n * ```typescript\n * accountManager2.setSigners(accountManager1);\n * ```\n */\n public setSigners(anotherAccountManager: AccountManager, overwriteExisting = true) {\n this._accounts = overwriteExisting\n ? { ...this._accounts, ...anotherAccountManager._accounts }\n : { ...anotherAccountManager._accounts, ...this._accounts }\n return this\n }\n\n /**\n * Returns the `TransactionSigner` for the given sender address, ready to sign a transaction for that sender.\n *\n * If no signer has been registered for that address then the default signer is used if registered and\n * if not then an error is thrown.\n *\n * @param sender The sender address\n * @example\n * ```typescript\n * const signer = accountManager.getSigner(\"SENDERADDRESS\")\n * ```\n * @returns The `TransactionSigner` or throws an error if not found and no default signer is set\n */\n public getSigner(sender: string | Address): algosdk.TransactionSigner {\n const signer = this._accounts[address(sender).toString()]?.signer ?? this._defaultSigner\n if (!signer) throw new Error(`No signer found for address ${sender}`)\n return signer\n }\n\n /**\n * Returns the `TransactionSignerAccount` for the given sender address.\n *\n * If no signer has been registered for that address then an error is thrown.\n * @param sender The sender address\n * @example\n * ```typescript\n * const sender = accountManager.random()\n * // ...\n * // Returns the `TransactionSignerAccount` for `sender` that has previously been registered\n * const account = accountManager.getAccount(sender)\n * ```\n * @returns The `TransactionSignerAccount` or throws an error if not found\n */\n public getAccount(sender: string | Address): TransactionSignerAccount {\n const account = this._accounts[address(sender).toString()]\n if (!account) throw new Error(`No signer found for address ${sender}`)\n return account\n }\n\n /**\n * Returns the given sender account's current status, balance and spendable amounts.\n *\n * [Response data schema details](https://dev.algorand.co/reference/rest-apis/algod/#accountinformation)\n * @example\n * ```typescript\n * const address = \"XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA\";\n * const accountInfo = await accountManager.getInformation(address);\n * ```\n *\n * @param sender The account / address to look up\n * @returns The account information\n */\n public async getInformation(sender: string | Address): Promise<AccountInformation> {\n const {\n round,\n lastHeartbeat = undefined,\n lastProposed = undefined,\n address,\n ...account\n } = await this._clientManager.algod.accountInformation(sender).do()\n\n return {\n ...account,\n // None of the Number types can practically overflow 2^53\n address: Address.fromString(address),\n balance: AlgoAmount.MicroAlgo(Number(account.amount)),\n amountWithoutPendingRewards: AlgoAmount.MicroAlgo(Number(account.amountWithoutPendingRewards)),\n minBalance: AlgoAmount.MicroAlgo(Number(account.minBalance)),\n pendingRewards: AlgoAmount.MicroAlgo(Number(account.pendingRewards)),\n rewards: AlgoAmount.MicroAlgo(Number(account.rewards)),\n validAsOfRound: BigInt(round),\n totalAppsOptedIn: Number(account.totalAppsOptedIn),\n totalAssetsOptedIn: Number(account.totalAssetsOptedIn),\n totalCreatedApps: Number(account.totalCreatedApps),\n totalCreatedAssets: Number(account.totalCreatedAssets),\n appsTotalExtraPages: account.appsTotalExtraPages !== undefined ? Number(account.appsTotalExtraPages) : undefined,\n rewardBase: account.rewardBase !== undefined ? Number(account.rewardBase) : undefined,\n totalBoxBytes: account.totalBoxBytes !== undefined ? Number(account.totalBoxBytes) : undefined,\n totalBoxes: account.totalBoxes !== undefined ? Number(account.totalBoxes) : undefined,\n lastHeartbeatRound: lastHeartbeat !== undefined ? BigInt(lastHeartbeat) : undefined,\n lastProposedRound: lastProposed !== undefined ? BigInt(lastProposed) : undefined,\n }\n }\n\n /**\n * Tracks and returns an Algorand account with secret key loaded (i.e. that can sign transactions) by taking the mnemonic secret.\n *\n * @example\n * ```typescript\n * const account = accountManager.fromMnemonic(\"mnemonic secret ...\")\n * const rekeyedAccount = accountManager.fromMnemonic(\"mnemonic secret ...\", \"SENDERADDRESS...\")\n * ```\n * @param mnemonicSecret The mnemonic secret representing the private key of an account; **Note: Be careful how the mnemonic is handled**,\n * never commit it into source control and ideally load it from the environment (ideally via a secret storage service) rather than the file system.\n * @param sender The optional sender address to use this signer for (aka a rekeyed account)\n * @returns The account\n */\n public fromMnemonic(mnemonicSecret: string, sender?: string | Address) {\n const account = algosdk.mnemonicToSecretKey(mnemonicSecret)\n return this.signerAccount(new SigningAccount(account, sender))\n }\n\n /**\n * Tracks and returns an Algorand account that is a rekeyed version of the given account to a new sender.\n *\n * @example\n * ```typescript\n * const account = accountManager.fromMnemonic(\"mnemonic secret ...\")\n * const rekeyedAccount = accountManager.rekeyed(account, \"SENDERADDRESS...\")\n * ```\n * @param account The account to use as the signer for this new rekeyed account\n * @param sender The sender address to use as the new sender\n * @returns The account\n */\n public rekeyed(sender: string | Address, account: TransactionSignerAccount) {\n return this.signerAccount({ addr: address(sender), signer: account.signer })\n }\n\n /**\n * Tracks and returns an Algorand account with private key loaded by convention from environment variables based on the given name identifier.\n *\n * Note: This function expects to run in a Node.js environment.\n *\n * ## Convention:\n * * **Non-LocalNet:** will load process.env['\\{NAME\\}_MNEMONIC'] as a mnemonic secret; **Note: Be careful how the mnemonic is handled**,\n * never commit it into source control and ideally load it via a secret storage service rather than the file system.\n * If process.env['\\{NAME\\}_SENDER'] is defined then it will use that for the sender address (i.e. to support rekeyed accounts)\n * * **LocalNet:** will load the account from a KMD wallet called \\{NAME\\} and if that wallet doesn't exist it will create it and fund the account for you\n *\n * This allows you to write code that will work seamlessly in production and local development (LocalNet) without manual config locally (including when you reset the LocalNet).\n *\n * @example Default\n *\n * If you have a mnemonic secret loaded into `process.env.MY_ACCOUNT_MNEMONIC` then you can call the following to get that private key loaded into an account object:\n * ```typescript\n * const account = await accountManager.fromEnvironment('MY_ACCOUNT')\n * ```\n *\n * If that code runs against LocalNet then a wallet called `MY_ACCOUNT` will automatically be created with an account that is automatically funded with 1000 (default) ALGO from the default LocalNet dispenser.\n * If not running against LocalNet then it will use proces.env.MY_ACCOUNT_MNEMONIC as the private key and (if present) process.env.MY_ACCOUNT_SENDER as the sender address.\n *\n * @param name The name identifier of the account\n * @param fundWith The optional amount to fund the account with when it gets created (when targeting LocalNet), if not specified then 1000 ALGO will be funded from the dispenser account\n * @returns The account\n */\n public async fromEnvironment(name: string, fundWith?: AlgoAmount) {\n if (!process || !process.env) {\n throw new Error('Attempt to get account with private key from a non Node.js context; this is not supported!')\n }\n\n const accountMnemonic = process.env[`${name.toUpperCase()}_MNEMONIC`]\n const sender = process.env[`${name.toUpperCase()}_SENDER`]\n\n if (accountMnemonic) {\n const signer = algosdk.mnemonicToSecretKey(accountMnemonic)\n return this.signerAccount(new SigningAccount(signer, sender))\n }\n\n if (await this._clientManager.isLocalNet()) {\n const account = await this._kmdAccountManager.getOrCreateWalletAccount(name, fundWith)\n return this.signerAccount(account.account)\n }\n\n throw new Error(`Missing environment variable ${name.toUpperCase()}_MNEMONIC when looking for account ${name}`)\n }\n\n /**\n * Tracks and returns an Algorand account with private key loaded from the given KMD wallet (identified by name).\n *\n * @param name The name of the wallet to retrieve an account from\n * @param predicate An optional filter to use to find the account (otherwise it will return a random account from the wallet)\n * @param sender The optional sender address to use this signer for (aka a rekeyed account)\n * @example Get default funded account in a LocalNet\n *\n * ```typescript\n * const defaultDispenserAccount = await accountManager.fromKmd('unencrypted-default-wallet',\n * a => a.status !== 'Offline' && a.amount > 1_000_000_000\n * )\n * ```\n * @returns The account\n */\n public async fromKmd(\n name: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n predicate?: (account: Record<string, any>) => boolean,\n sender?: string | Address,\n ) {\n const account = await this._kmdAccountManager.getWalletAccount(name, predicate, sender)\n if (!account) throw new Error(`Unable to find KMD account ${name}${predicate ? ' with predicate' : ''}`)\n return this.signerAccount(account.account)\n }\n\n /**\n * Tracks and returns an account that supports partial or full multisig signing.\n *\n * @example\n * ```typescript\n * const account = accountManager.multisig({version: 1, threshold: 1, addrs: [\"ADDRESS1...\", \"ADDRESS2...\"]},\n * [(await accountManager.fromEnvironment('ACCOUNT1')).account])\n * ```\n * @param multisigParams The parameters that define the multisig account\n * @param signingAccounts The signers that are currently present\n * @returns A multisig account wrapper\n */\n public multisig(multisigParams: algosdk.MultisigMetadata, signingAccounts: (algosdk.Account | SigningAccount)[]) {\n return this.signerAccount(new MultisigAccount(multisigParams, signingAccounts))\n }\n\n /**\n * Tracks and returns an account that represents a logic signature.\n *\n * @example\n * ```typescript\n * const account = accountManager.logicsig(program, [new Uint8Array(3, ...)])\n * ```\n * @param program The bytes that make up the compiled logic signature\n * @param args The (binary) arguments to pass into the logic signature\n * @returns A logic signature account wrapper\n */\n public logicsig(program: Uint8Array, args?: Array<Uint8Array>) {\n return this.signerAccount(new LogicSigAccount(program, args))\n }\n\n /**\n * Tracks and returns a new, random Algorand account with secret key loaded.\n *\n * @example\n * ```typescript\n * const account = accountManager.random()\n * ```\n * @returns The account\n */\n public random() {\n return this.signerAccount(algosdk.generateAccount())\n }\n\n /**\n * Returns an account (with private key loaded) that can act as a dispenser from\n * environment variables, or against default LocalNet if no environment variables present.\n *\n * Note: requires a Node.js environment to execute.\n *\n * If present, it will load the account mnemonic stored in process.env.DISPENSER_MNEMONIC and optionally\n * process.env.DISPENSER_SENDER if it's a rekeyed account.\n *\n * @example\n * ```typescript\n * const account = await accountManager.dispenserFromEnvironment()\n * ```\n *\n * @returns The account\n */\n public async dispenserFromEnvironment() {\n if (!process || !process.env) {\n throw new Error('Attempt to get dispenser from environment from a non Node.js context; this is not supported!')\n }\n\n return process.env[`${DISPENSER_ACCOUNT.toUpperCase()}_MNEMONIC`]\n ? await this.fromEnvironment(DISPENSER_ACCOUNT)\n : await this.localNetDispenser()\n }\n\n /**\n * Returns an Algorand account with private key loaded for the default LocalNet dispenser account (that can be used to fund other accounts).\n *\n * @example\n * ```typescript\n * const account = await accountManager.localNetDispenser()\n * ```\n * @returns The account\n */\n public async localNetDispenser() {\n const dispenser = await this._kmdAccountManager.getLocalNetDispenserAccount()\n return this.signerAccount(dispenser.account)\n }\n\n /**\n * Rekey an account to a new address.\n *\n * **Note:** Please be careful with this function and be sure to read the [official rekey guidance](https://dev.algorand.co/concepts/accounts/rekeying).\n *\n * @param account The account to rekey\n * @param rekeyTo The account address or signing account of the account that will be used to authorise transactions for the rekeyed account going forward.\n * If a signing account is provided that will now be tracked as the signer for `account` in this `AccountManager`\n * @param options Any parameters to control the transaction or execution of the transaction\n *\n * @example Basic example (with string addresses)\n * ```typescript\n * await accountManager.rekeyAccount({account: \"ACCOUNTADDRESS\", rekeyTo: \"NEWADDRESS\"})\n * ```\n * @example Basic example (with signer accounts)\n * ```typescript\n * await accountManager.rekeyAccount({account: account1, rekeyTo: newSignerAccount})\n * ```\n * @example Advanced example\n * ```typescript\n * await accountManager.rekeyAccount({\n * account: \"ACCOUNTADDRESS\",\n * rekeyTo: \"NEWADDRESS\",\n * lease: 'lease',\n * note: 'note',\n * firstValidRound: 1000n,\n * validityWindow: 10,\n * extraFee: (1000).microAlgo(),\n * staticFee: (1000).microAlgo(),\n * // Max fee doesn't make sense with extraFee AND staticFee\n * // already specified, but here for completeness\n * maxFee: (3000).microAlgo(),\n * maxRoundsToWaitForConfirmation: 5,\n * suppressLog: true,\n * })\n * ```\n * @returns The result of the transaction and the transaction that was sent\n */\n async rekeyAccount(\n account: string | Address,\n rekeyTo: string | Address | TransactionSignerAccount,\n options?: Omit<CommonTransactionParams, 'sender'> & SendParams,\n ): Promise<SendSingleTransactionResult> {\n const result = await this._getComposer()\n .addPayment({\n ...options,\n sender: address(account),\n receiver: address(account),\n amount: AlgoAmount.MicroAlgo(0),\n rekeyTo: address(typeof rekeyTo === 'object' && 'addr' in rekeyTo ? rekeyTo.addr : rekeyTo),\n })\n .send(options)\n\n // If the rekey is a signing account set it as the signer for this account\n if (typeof rekeyTo === 'object' && 'addr' in rekeyTo) {\n this.rekeyed(account, rekeyTo)\n }\n\n Config.getLogger(options?.suppressLog).info(`Rekeyed ${account} to ${rekeyTo} via transaction ${result.txIds.at(-1)}`)\n\n return { ...result, transaction: result.transactions.at(-1)!, confirmation: result.confirmations.at(-1)! }\n }\n\n private async _getEnsureFundedAmount(sender: Address, minSpendingBalance: AlgoAmount, minFundingIncrement?: AlgoAmount) {\n const accountInfo = await this.getInformation(sender)\n const currentSpendingBalance = accountInfo.balance.microAlgo - accountInfo.minBalance.microAlgo\n\n const amountFunded = calculateFundAmount(minSpendingBalance.microAlgo, currentSpendingBalance, minFundingIncrement?.microAlgo ?? 0n)\n\n return amountFunded === null ? undefined : AlgoAmount.MicroAlgo(amountFunded)\n }\n\n /**\n * Funds a given account using a dispenser account as a funding source such that\n * the given account has a certain amount of Algo free to spend (accounting for\n * Algo locked in minimum balance requirement).\n *\n * https://dev.algorand.co/concepts/smart-contracts/costs-constraints#mbr\n *\n * @param accountToFund The account to fund\n * @param dispenserAccount The account to use as a dispenser funding source\n * @param minSpendingBalance The minimum balance of Algo that the account should have available to spend (i.e. on top of minimum balance requirement)\n * @param options Optional parameters to control the funding increment, transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * await accountManager.ensureFunded(\"ACCOUNTADDRESS\", \"DISPENSERADDRESS\", algokit.algo(1))\n * // With configuration\n * await accountManager.ensureFunded(\"ACCOUNTADDRESS\", \"DISPENSERADDRESS\", algokit.algo(1),\n * { minFundingIncrement: algokit.algo(2), fee: (1000).microAlgo(), suppressLog: true }\n * )\n * ```\n * @returns\n * - The result of executing the dispensing transaction and the `amountFunded` if funds were needed.\n * - `undefined` if no funds were needed.\n */\n async ensureFunded(\n accountToFund: string | Address,\n dispenserAccount: string | Address,\n minSpendingBalance: AlgoAmount,\n options?: {\n minFundingIncrement?: AlgoAmount\n } & SendParams &\n Omit<CommonTransactionParams, 'sender'>,\n ): Promise<(SendSingleTransactionResult & EnsureFundedResult) | undefined> {\n const addressToFund = address(accountToFund)\n\n const amountFunded = await this._getEnsureFundedAmount(addressToFund, minSpendingBalance, options?.minFundingIncrement)\n if (!amountFunded) return undefined\n\n const result = await this._getComposer()\n .addPayment({\n ...options,\n sender: address(dispenserAccount),\n receiver: addressToFund,\n amount: amountFunded,\n })\n .send(options)\n\n return {\n ...result,\n transaction: result.transactions[0],\n confirmation: result.confirmations[0],\n transactionId: result.txIds[0],\n amountFunded: amountFunded,\n }\n }\n\n /**\n * Funds a given account using a dispenser account retrieved from the environment,\n * per the `dispenserFromEnvironment` method, as a funding source such that\n * the given account has a certain amount of Algo free to spend (accounting for\n * Algo locked in minimum balance requirement).\n *\n * **Note:** requires a Node.js environment to execute.\n *\n * The dispenser account is retrieved from the account mnemonic stored in\n * process.env.DISPENSER_MNEMONIC and optionally process.env.DISPENSER_SENDER\n * if it's a rekeyed account, or against default LocalNet if no environment variables present.\n *\n * https://dev.algorand.co/concepts/smart-contracts/costs-constraints#mbr\n *\n * @param accountToFund The account to fund\n * @param minSpendingBalance The minimum balance of Algo that the account should have available to spend (i.e. on top of minimum balance requirement)\n * @param options Optional parameters to control the funding increment, transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * await accountManager.ensureFundedFromEnvironment(\"ACCOUNTADDRESS\", algokit.algo(1))\n * // With configuration\n * await accountManager.ensureFundedFromEnvironment(\"ACCOUNTADDRESS\", algokit.algo(1),\n * { minFundingIncrement: algokit.algo(2), fee: (1000).microAlgo(), suppressLog: true }\n * )\n * ```\n * @returns\n * - The result of executing the dispensing transaction and the `amountFunded` if funds were needed.\n * - `undefined` if no funds were needed.\n */\n async ensureFundedFromEnvironment(\n accountToFund: string | Address,\n minSpendingBalance: AlgoAmount,\n options?: {\n minFundingIncrement?: AlgoAmount\n } & SendParams &\n Omit<CommonTransactionParams, 'sender'>,\n ): Promise<(SendSingleTransactionResult & EnsureFundedResult) | undefined> {\n const addressToFund = address(accountToFund)\n const dispenserAccount = await this.dispenserFromEnvironment()\n\n const amountFunded = await this._getEnsureFundedAmount(addressToFund, minSpendingBalance, options?.minFundingIncrement)\n if (!amountFunded) return undefined\n\n const result = await this._getComposer()\n .addPayment({\n ...options,\n sender: dispenserAccount,\n receiver: addressToFund,\n amount: amountFunded,\n })\n .send(options)\n\n return {\n ...result,\n transaction: result.transactions[0],\n confirmation: result.confirmations[0],\n transactionId: result.txIds[0],\n amountFunded: amountFunded,\n }\n }\n\n /**\n * Funds a given account using the TestNet Dispenser API as a funding source such that\n * the account has a certain amount of Algo free to spend (accounting for Algo locked\n * in minimum balance requirement).\n *\n * https://dev.algorand.co/concepts/smart-contracts/costs-constraints#mbr\n *\n * @param accountToFund The account to fund\n * @param dispenserClient The TestNet dispenser funding client\n * @param minSpendingBalance The minimum balance of Algo that the account should have available to spend (i.e. on top of minimum balance requirement)\n * @param options Optional parameters to control the funding increment, transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * await accountManager.ensureFundedFromTestNetDispenserApi(\"ACCOUNTADDRESS\", algorand.client.getTestNetDispenserFromEnvironment(), algokit.algo(1))\n * // With configuration\n * await accountManager.ensureFundedFromTestNetDispenserApi(\"ACCOUNTADDRESS\", algorand.client.getTestNetDispenserFromEnvironment(), algokit.algo(1),\n * { minFundingIncrement: algokit.algo(2) }\n * )\n * ```\n * @returns\n * - The result of executing the dispensing transaction and the `amountFunded` if funds were needed.\n * - `undefined` if no funds were needed.\n */\n async ensureFundedFromTestNetDispenserApi(\n accountToFund: string | Address,\n dispenserClient: TestNetDispenserApiClient,\n minSpendingBalance: AlgoAmount,\n options?: {\n minFundingIncrement?: AlgoAmount\n },\n ): Promise<EnsureFundedResult | undefined> {\n if (!(await this._clientManager.isTestNet())) {\n throw new Error('Attempt to fund using TestNet dispenser API on non TestNet network.')\n }\n\n const addressToFund = address(accountToFund)\n\n const amountFunded = await this._getEnsureFundedAmount(addressToFund, minSpendingBalance, options?.minFundingIncrement)\n if (!amountFunded) return undefined\n\n const result = await dispenserClient.fund(addressToFund, amountFunded.microAlgo)\n return {\n amountFunded: AlgoAmount.MicroAlgo(result.amount),\n transactionId: result.txId,\n }\n }\n}\n"],"names":["Address","memoize","KmdAccountManager","TransactionComposer","AlgoAmount","SigningAccount","MultisigAccount","DISPENSER_ACCOUNT","Config","calculateFundAmount"],"mappings":";;;;;;;;;;AAUA,IAAO,eAAe,GAAG,OAAO,CAAC,eAAe;AAIhD,MAAM,OAAO,GAAG,CAAC,OAAyB,MAAM,OAAO,OAAO,KAAK,QAAQ,GAAGA,eAAO,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,OAAO,C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