@algorandfoundation/algokit-utils 10.0.0-alpha.31 → 10.0.0-alpha.32
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.
- package/account-manager.d.ts +448 -0
- package/account-manager.js +623 -0
- package/account-manager.js.map +1 -0
- package/account-manager.mjs +620 -0
- package/account-manager.mjs.map +1 -0
- package/account.d.ts +156 -0
- package/account.js +10 -0
- package/account.js.map +1 -0
- package/account.mjs +9 -0
- package/account.mjs.map +1 -0
- package/algorand-client-transaction-creator.d.ts +1103 -0
- package/algorand-client-transaction-creator.js +735 -0
- package/algorand-client-transaction-creator.js.map +1 -0
- package/algorand-client-transaction-creator.mjs +734 -0
- package/algorand-client-transaction-creator.mjs.map +1 -0
- package/algorand-client-transaction-sender.d.ts +1317 -0
- package/algorand-client-transaction-sender.js +933 -0
- package/algorand-client-transaction-sender.js.map +1 -0
- package/algorand-client-transaction-sender.mjs +932 -0
- package/algorand-client-transaction-sender.mjs.map +1 -0
- package/algorand-client.d.ts +246 -0
- package/algorand-client.js +325 -0
- package/algorand-client.js.map +1 -0
- package/algorand-client.mjs +325 -0
- package/algorand-client.mjs.map +1 -0
- package/amount.d.ts +46 -3
- package/amount.js +92 -13
- package/amount.js.map +1 -1
- package/amount.mjs +80 -3
- package/amount.mjs.map +1 -1
- package/app-client.d.ts +2130 -0
- package/app-client.js +909 -0
- package/app-client.js.map +1 -0
- package/app-client.mjs +908 -0
- package/app-client.mjs.map +1 -0
- package/app-deployer.d.ts +166 -0
- package/app-deployer.js +353 -0
- package/app-deployer.js.map +1 -0
- package/app-deployer.mjs +353 -0
- package/app-deployer.mjs.map +1 -0
- package/app-factory.d.ts +965 -0
- package/app-factory.js +448 -0
- package/app-factory.js.map +1 -0
- package/app-factory.mjs +448 -0
- package/app-factory.mjs.map +1 -0
- package/app-manager.d.ts +323 -0
- package/app-manager.js +468 -0
- package/app-manager.js.map +1 -0
- package/app-manager.mjs +468 -0
- package/app-manager.mjs.map +1 -0
- package/app-spec.d.ts +203 -0
- package/app-spec.js +137 -0
- package/app-spec.js.map +1 -0
- package/app-spec.mjs +137 -0
- package/app-spec.mjs.map +1 -0
- package/app.d.ts +257 -0
- package/app.js +49 -0
- package/app.js.map +1 -0
- package/app.mjs +42 -0
- package/app.mjs.map +1 -0
- package/asset-manager.d.ts +212 -0
- package/asset-manager.js +166 -0
- package/asset-manager.js.map +1 -0
- package/asset-manager.mjs +166 -0
- package/asset-manager.mjs.map +1 -0
- package/async-event-emitter.d.ts +16 -0
- package/async-event-emitter.js +38 -0
- package/async-event-emitter.js.map +1 -0
- package/async-event-emitter.mjs +37 -0
- package/async-event-emitter.mjs.map +1 -0
- package/client-manager.d.ts +475 -0
- package/client-manager.js +616 -0
- package/client-manager.js.map +1 -0
- package/client-manager.mjs +616 -0
- package/client-manager.mjs.map +1 -0
- package/composer.d.ts +947 -0
- package/composer.js +1584 -0
- package/composer.js.map +1 -0
- package/composer.mjs +1583 -0
- package/composer.mjs.map +1 -0
- package/config.d.ts +1 -1
- package/config.js +2 -2
- package/config.js.map +1 -1
- package/config.mjs +1 -1
- package/config.mjs.map +1 -1
- package/debugging.d.ts +47 -0
- package/debugging.js +20 -0
- package/debugging.js.map +1 -0
- package/debugging.mjs +15 -0
- package/debugging.mjs.map +1 -0
- package/dispenser-client.d.ts +90 -0
- package/dispenser-client.js +127 -0
- package/dispenser-client.js.map +1 -0
- package/dispenser-client.mjs +127 -0
- package/dispenser-client.mjs.map +1 -0
- package/expand.d.ts +2 -0
- package/expand.js +0 -0
- package/expand.mjs +0 -0
- package/index.d.ts +6 -5
- package/index.js +4 -3
- package/index.mjs +5 -5
- package/indexer-client/indexer-lookup.d.ts +1 -1
- package/indexer-client/indexer-lookup.js.map +1 -1
- package/indexer-client/indexer-lookup.mjs.map +1 -1
- package/indexer.d.ts +40 -0
- package/indexer.js +38 -0
- package/indexer.js.map +1 -0
- package/indexer.mjs +35 -0
- package/indexer.mjs.map +1 -0
- package/instance-of.d.ts +8 -0
- package/kmd-account-manager.d.ts +74 -0
- package/kmd-account-manager.js +167 -0
- package/kmd-account-manager.js.map +1 -0
- package/kmd-account-manager.mjs +165 -0
- package/kmd-account-manager.mjs.map +1 -0
- package/lifecycle-events.d.ts +14 -0
- package/lifecycle-events.js +11 -0
- package/lifecycle-events.js.map +1 -0
- package/lifecycle-events.mjs +10 -0
- package/lifecycle-events.mjs.map +1 -0
- package/logging.d.ts +13 -0
- package/logging.js +47 -0
- package/logging.js.map +1 -0
- package/logging.mjs +42 -0
- package/logging.mjs.map +1 -0
- package/logic-error.d.ts +39 -0
- package/logic-error.js +54 -0
- package/logic-error.js.map +1 -0
- package/logic-error.mjs +53 -0
- package/logic-error.mjs.map +1 -0
- package/network-client.d.ts +43 -0
- package/network-client.js +14 -0
- package/network-client.js.map +1 -0
- package/network-client.mjs +13 -0
- package/network-client.mjs.map +1 -0
- package/package.json +11 -1
- package/testing/account.d.ts +2 -2
- package/testing/account.js +1 -1
- package/testing/account.js.map +1 -1
- package/testing/account.mjs +1 -1
- package/testing/account.mjs.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
- package/testing/fixtures/algorand-fixture.d.ts +2 -2
- package/testing/fixtures/algorand-fixture.js +2 -2
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +2 -2
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/testing/index.d.ts +2 -1
- package/testing/test-logger.d.ts +1 -1
- package/testing/test-logger.js.map +1 -1
- package/testing/test-logger.mjs.map +1 -1
- package/testing/types.d.ts +156 -0
- package/transaction/index.d.ts +4 -0
- package/transaction/index.js +9 -0
- package/transaction/index.mjs +4 -0
- package/transaction/perform-transaction-composer-simulate.d.ts +1 -1
- package/transaction/perform-transaction-composer-simulate.js.map +1 -1
- package/transaction/perform-transaction-composer-simulate.mjs.map +1 -1
- package/transaction/transaction.d.ts +2 -2
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs.map +1 -1
- package/transaction/types.d.ts +133 -0
- package/transactions/app-call.d.ts +1 -1
- package/transactions/app-call.js +1 -1
- package/transactions/app-call.js.map +1 -1
- package/transactions/app-call.mjs +1 -1
- package/transactions/app-call.mjs.map +1 -1
- package/transactions/common.d.ts +1 -1
- package/transactions/common.js.map +1 -1
- package/transactions/common.mjs.map +1 -1
- package/transactions/method-call.d.ts +1 -1
- package/transactions/method-call.js +1 -1
- package/transactions/method-call.js.map +1 -1
- package/transactions/method-call.mjs +1 -1
- package/transactions/method-call.mjs.map +1 -1
- package/transactions/payment.d.ts +1 -1
- package/transactions/payment.js.map +1 -1
- package/transactions/payment.mjs.map +1 -1
- package/types/account-manager.d.ts +11 -442
- package/types/account-manager.js +5 -616
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +5 -614
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +8 -150
- package/types/account.js +3 -4
- package/types/account.js.map +1 -1
- package/types/account.mjs +4 -4
- package/types/account.mjs.map +1 -1
- package/types/algorand-client-transaction-creator.d.ts +5 -1098
- package/types/algorand-client-transaction-creator.js +3 -729
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +4 -729
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +5 -1312
- package/types/algorand-client-transaction-sender.js +3 -927
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +3 -926
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +5 -241
- package/types/algorand-client.js +3 -319
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +3 -319
- package/types/algorand-client.mjs.map +1 -1
- package/types/amount.d.ts +6 -45
- package/types/amount.js +3 -79
- package/types/amount.js.map +1 -1
- package/types/amount.mjs +4 -79
- package/types/amount.mjs.map +1 -1
- package/types/app-client.d.ts +75 -2125
- package/types/app-client.js +3 -903
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +3 -902
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +21 -161
- package/types/app-deployer.js +3 -347
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs +3 -347
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +21 -960
- package/types/app-factory.js +3 -442
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +3 -442
- package/types/app-factory.mjs.map +1 -1
- package/types/app-manager.d.ts +15 -318
- package/types/app-manager.js +3 -462
- package/types/app-manager.js.map +1 -1
- package/types/app-manager.mjs +3 -462
- package/types/app-manager.mjs.map +1 -1
- package/types/app-spec.d.ts +39 -198
- package/types/app-spec.js +3 -131
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +3 -131
- package/types/app-spec.mjs.map +1 -1
- package/types/app.d.ts +62 -247
- package/types/app.js +15 -37
- package/types/app.js.map +1 -1
- package/types/app.mjs +16 -37
- package/types/app.mjs.map +1 -1
- package/types/asset-manager.d.ts +9 -207
- package/types/asset-manager.js +3 -160
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +3 -160
- package/types/asset-manager.mjs.map +1 -1
- package/types/async-event-emitter.d.ts +7 -11
- package/types/async-event-emitter.js +3 -32
- package/types/async-event-emitter.js.map +1 -1
- package/types/async-event-emitter.mjs +4 -32
- package/types/async-event-emitter.mjs.map +1 -1
- package/types/client-manager.d.ts +27 -470
- package/types/client-manager.js +3 -610
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +3 -610
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +79 -943
- package/types/composer.js +3 -1578
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +3 -1577
- package/types/composer.mjs.map +1 -1
- package/types/config.d.ts +7 -52
- package/types/config.js +3 -74
- package/types/config.js.map +1 -1
- package/types/config.mjs +3 -74
- package/types/config.mjs.map +1 -1
- package/types/debugging.d.ts +12 -37
- package/types/debugging.js +11 -10
- package/types/debugging.js.map +1 -1
- package/types/debugging.mjs +12 -10
- package/types/debugging.mjs.map +1 -1
- package/types/dispenser-client.d.ts +11 -85
- package/types/dispenser-client.js +3 -121
- package/types/dispenser-client.js.map +1 -1
- package/types/dispenser-client.mjs +3 -121
- package/types/dispenser-client.mjs.map +1 -1
- package/types/expand.d.ts +8 -2
- package/types/indexer.d.ts +16 -36
- package/types/indexer.js +7 -30
- package/types/indexer.js.map +1 -1
- package/types/indexer.mjs +8 -30
- package/types/indexer.mjs.map +1 -1
- package/types/instance-of.d.ts +4 -4
- package/types/kmd-account-manager.d.ts +5 -69
- package/types/kmd-account-manager.js +3 -161
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +3 -159
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/lifecycle-events.d.ts +7 -9
- package/types/lifecycle-events.js +3 -5
- package/types/lifecycle-events.js.map +1 -1
- package/types/lifecycle-events.mjs +4 -5
- package/types/lifecycle-events.mjs.map +1 -1
- package/types/logging.d.ts +14 -9
- package/types/logging.js +11 -37
- package/types/logging.js.map +1 -1
- package/types/logging.mjs +12 -37
- package/types/logging.mjs.map +1 -1
- package/types/logic-error.d.ts +8 -35
- package/types/logic-error.js +3 -48
- package/types/logic-error.js.map +1 -1
- package/types/logic-error.mjs +4 -48
- package/types/logic-error.mjs.map +1 -1
- package/types/network-client.d.ts +10 -39
- package/types/network-client.js +3 -8
- package/types/network-client.js.map +1 -1
- package/types/network-client.mjs +4 -8
- package/types/network-client.mjs.map +1 -1
- package/types/testing.d.ts +13 -151
- package/types/transaction.d.ts +33 -128
- package/updatable-config.d.ts +57 -0
- package/updatable-config.js +80 -0
- package/updatable-config.js.map +1 -0
- package/updatable-config.mjs +80 -0
- package/updatable-config.mjs.map +1 -0
- package/util.js +1 -1
- package/util.js.map +1 -1
- package/util.mjs +1 -1
- package/util.mjs.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method-call.mjs","names":["addr: Address","encodedArgs: Uint8Array[]"],"sources":["../../src/transactions/method-call.ts"],"sourcesContent":["import {\n ABIMethod,\n ABITupleType,\n ABIType,\n ABIUintType,\n ABIValue,\n argTypeIsReference,\n argTypeIsTransaction,\n} from '@algorandfoundation/algokit-abi'\nimport { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Address, Expand, getAddress } from '@algorandfoundation/algokit-common'\nimport { OnApplicationComplete, Transaction, TransactionSigner, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { TransactionWithSigner } from '../transaction'\nimport { AlgoAmount } from '../types/amount'\nimport { AppManager } from '../types/app-manager'\nimport { calculateExtraProgramPages } from '../util'\nimport { AppCreateParams, AppDeleteParams, AppMethodCallParams, AppUpdateParams } from './app-call'\nimport { buildTransactionCommonData } from './common'\n\nconst ARGS_TUPLE_PACKING_THRESHOLD = 15 // ARC-4 allows 15 ABI args (slots 1-15) before tuple packing is needed\n\n/** Parameters to define an ABI method call create transaction. */\nexport type AppCreateMethodCall = Expand<AppMethodCall<AppCreateParams>>\n/** Parameters to define an ABI method call update transaction. */\nexport type AppUpdateMethodCall = Expand<AppMethodCall<AppUpdateParams>>\n/** Parameters to define an ABI method call delete transaction. */\nexport type AppDeleteMethodCall = Expand<AppMethodCall<AppDeleteParams>>\n/** Parameters to define an ABI method call transaction. */\nexport type AppCallMethodCall = Expand<AppMethodCall<AppMethodCallParams>>\n\nexport type ProcessedAppCreateMethodCall = Expand<\n Omit<AppCreateMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\nexport type ProcessedAppUpdateMethodCall = Expand<\n Omit<AppUpdateMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\nexport type ProcessedAppCallMethodCall = Expand<\n Omit<AppCallMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\n/** Types that can be used to define a transaction argument for an ABI call transaction. */\nexport type AppMethodCallTransactionArgument =\n // The following should match the partial `args` types from `AppMethodCall<T>` below\n | TransactionWithSigner\n | Transaction\n | Promise<Transaction>\n | AppMethodCall<AppCreateParams>\n | AppMethodCall<AppUpdateParams>\n | AppMethodCall<AppMethodCallParams>\n\n/** Parameters to define an ABI method call. */\nexport type AppMethodCall<T> = Expand<Omit<T, 'args'>> & {\n /** The ABI method to call */\n method: ABIMethod\n /** Arguments to the ABI method, either:\n * * An ABI value\n * * A transaction with explicit signer\n * * A transaction (where the signer will be automatically assigned)\n * * An unawaited transaction (e.g. from algorand.createTransaction.{transactionType}())\n * * Another method call (via method call params object)\n * * undefined (this represents a placeholder transaction argument that is fulfilled by another method call argument)\n */\n args?: (\n | ABIValue\n // The following should match the above `AppMethodCallTransactionArgument` type above\n | TransactionWithSigner\n | Transaction\n | Promise<Transaction>\n | AppMethodCall<AppCreateParams>\n | AppMethodCall<AppUpdateParams>\n | AppMethodCall<AppMethodCallParams>\n | undefined\n )[]\n}\n\ntype AppMethodCallArgs = AppMethodCall<unknown>['args']\ntype AppMethodCallArg = NonNullable<AppMethodCallArgs>[number]\n\nexport type AsyncTransactionParams = {\n txn: Promise<Transaction>\n signer?: TransactionSigner\n maxFee?: AlgoAmount\n}\n\nexport type TransactionParams = {\n txn: Transaction\n signer?: TransactionSigner\n maxFee?: AlgoAmount\n}\n\ntype ExtractedMethodCallTransactionArg =\n | { data: TransactionParams; type: 'txn' }\n | {\n data: AsyncTransactionParams\n type: 'asyncTxn'\n }\n | { data: ProcessedAppCallMethodCall | ProcessedAppCreateMethodCall | ProcessedAppUpdateMethodCall; type: 'methodCall' }\n\nexport function extractComposerTransactionsFromAppMethodCallParams(\n params: AppCallMethodCall | AppCreateMethodCall | AppUpdateMethodCall | AppDeleteMethodCall,\n parentSigner?: TransactionSigner,\n): ExtractedMethodCallTransactionArg[] {\n const composerTransactions = new Array<ExtractedMethodCallTransactionArg>()\n const methodCallArgs = params.args\n if (!methodCallArgs) return []\n\n // Extract signer from params, falling back to parentSigner\n const currentSigner = params.signer ? ('signer' in params.signer ? params.signer.signer : params.signer) : parentSigner\n\n for (let i = 0; i < methodCallArgs.length; i++) {\n const arg = methodCallArgs[i]\n\n if (arg === undefined) {\n // is a transaction or default value placeholder, do nothing\n continue\n }\n if (isAbiValue(arg)) {\n // if is ABI value, also ignore\n continue\n }\n\n if (isTransactionWithSignerArg(arg)) {\n composerTransactions.push({\n data: {\n txn: arg.txn,\n signer: arg.signer,\n },\n type: 'txn',\n })\n\n continue\n }\n if (isAppCallMethodCallArg(arg)) {\n // Recursively extract nested method call transactions, passing the nested call itself and current signer as parent\n const nestedComposerTransactions = extractComposerTransactionsFromAppMethodCallParams(arg, currentSigner)\n composerTransactions.push(...nestedComposerTransactions)\n composerTransactions.push({\n data: {\n ...arg,\n signer: arg.signer ?? currentSigner,\n args: processAppMethodCallArgs(arg.args),\n },\n type: 'methodCall',\n } satisfies ExtractedMethodCallTransactionArg)\n\n continue\n }\n if (arg instanceof Promise) {\n composerTransactions.push({\n data: {\n txn: arg,\n signer: currentSigner,\n },\n type: 'asyncTxn',\n })\n continue\n }\n\n composerTransactions.push({\n data: {\n txn: Promise.resolve(arg),\n signer: currentSigner,\n },\n type: 'asyncTxn',\n })\n }\n\n return composerTransactions\n}\n\nexport function processAppMethodCallArgs(args: AppMethodCallArg[] | undefined): (ABIValue | undefined)[] | undefined {\n if (args === undefined) return undefined\n\n return args.map((arg) => {\n if (arg === undefined) {\n // Handle explicit placeholders (either transaction or default value)\n return undefined\n } else if (!isAbiValue(arg)) {\n // If the arg is not an ABIValue, it's must be a transaction, set to undefined\n // transaction arguments should be flattened out and added into the composer during the add process\n return undefined\n }\n return arg\n })\n}\n\nfunction isTransactionWithSignerArg(arg: AppMethodCallArg): arg is TransactionWithSigner {\n return typeof arg === 'object' && arg !== undefined && 'txn' in arg && 'signer' in arg\n}\n\nfunction isAppCallMethodCallArg(\n arg: AppMethodCallArg,\n): arg is AppMethodCall<AppCreateParams> | AppMethodCall<AppUpdateParams> | AppMethodCall<AppMethodCallParams> {\n return typeof arg === 'object' && arg !== undefined && 'method' in arg\n}\n\nconst isAbiValue = (x: unknown): x is ABIValue => {\n if (Array.isArray(x)) return x.length == 0 || x.every(isAbiValue)\n\n // If x is a POJO literal\n if (Object.getPrototypeOf(x) === Object.getPrototypeOf({})) {\n return Object.values(x as object).every(isAbiValue)\n }\n\n return (\n typeof x === 'bigint' ||\n typeof x === 'boolean' ||\n typeof x === 'number' ||\n typeof x === 'string' ||\n x instanceof Uint8Array ||\n x instanceof Address\n )\n}\n\n/**\n * Prepares method arguments for ABI encoding by building reference arrays and\n * replacing reference-type arguments (account, asset, application) with their indices.\n */\nfunction prepareArgsForEncoding(\n sender: Address,\n appId: bigint,\n method: ABIMethod,\n methodArgs: (ABIValue | undefined)[],\n accountReferences?: Address[],\n appReferences?: bigint[],\n assetReferences?: bigint[],\n): { accountReferences: Address[]; appReferences: bigint[]; assetReferences: bigint[]; updatedArgs: (ABIValue | undefined)[] } {\n const accounts = [...(accountReferences ?? [])]\n const assets = [...(assetReferences ?? [])]\n const apps = [...(appReferences ?? [])]\n\n const updatedArgs = methodArgs.map((arg, i) => {\n const argType = method.args[i].type\n if (!argTypeIsReference(argType)) {\n return arg\n }\n switch (argType) {\n case 'account': {\n let addr: Address\n if (typeof arg === 'string') {\n addr = getAddress(arg)\n } else if (arg instanceof Uint8Array) {\n addr = new Address(arg)\n } else {\n throw new Error('Invalid value for account')\n }\n\n if (sender.equals(addr)) {\n return 0\n }\n\n const existing = accounts.findIndex((a) => a.equals(addr)) + 1\n if (existing) return existing\n\n accounts.push(addr)\n return accounts.length\n }\n case 'asset': {\n if (typeof arg !== 'bigint') {\n throw new Error('Invalid value for asset')\n }\n\n const existing = assets.findIndex((a) => a === arg)\n if (existing === -1) {\n assets.push(arg)\n return assets.length - 1\n }\n\n return existing\n }\n case 'application': {\n if (typeof arg !== 'bigint') {\n throw new Error('Invalid value for application')\n }\n\n if (arg === appId) return 0\n\n const existing = apps.findIndex((a) => a === arg) + 1\n if (existing) return existing\n\n apps.push(arg)\n return apps.length\n }\n }\n })\n\n return { accountReferences: accounts, appReferences: apps, assetReferences: assets, updatedArgs }\n}\n\n/**\n * Encode ABI method arguments with tuple packing support\n * Ports the logic from the Rust encode_method_arguments function\n */\nfunction encodeMethodArguments(method: ABIMethod, args: (ABIValue | undefined)[]): Uint8Array[] {\n const encodedArgs = new Array<Uint8Array>()\n\n // Insert method selector at the front\n encodedArgs.push(method.getSelector())\n\n // Get ABI types for non-transaction arguments\n const abiTypes = new Array<ABIType>()\n const abiValues = new Array<ABIValue>()\n\n // Process each method argument\n for (let i = 0; i < method.args.length; i++) {\n const methodArg = method.args[i]\n const argValue = args[i]\n\n if (argTypeIsTransaction(methodArg.type)) {\n // Transaction arguments are not ABI encoded - they're handled separately\n } else if (argTypeIsReference(methodArg.type)) {\n // Reference types are encoded as uint8 indexes\n const referenceType = methodArg.type\n if (typeof argValue === 'number') {\n abiTypes.push(new ABIUintType(8))\n abiValues.push(argValue)\n } else {\n throw new Error(`Invalid reference value for ${referenceType}: ${argValue}`)\n }\n } else if (argValue !== undefined) {\n // Regular ABI value\n abiTypes.push(methodArg.type)\n // it's safe to cast to ABIValue here because the abiType must be ABIValue\n abiValues.push(argValue as ABIValue)\n }\n\n // Skip undefined values (transaction placeholders)\n }\n\n if (abiValues.length !== abiTypes.length) {\n throw new Error('Mismatch in length of non-transaction arguments')\n }\n\n // Apply ARC-4 tuple packing for methods with more than 15 ABI arguments\n // Algorand allows 16 app args total; slot 0 is the method selector, leaving 15 for ABI args\n if (abiTypes.length > ARGS_TUPLE_PACKING_THRESHOLD) {\n encodedArgs.push(...encodeArgsWithTuplePacking(abiTypes, abiValues))\n } else {\n encodedArgs.push(...encodeArgsIndividually(abiTypes, abiValues))\n }\n\n return encodedArgs\n}\n\n/**\n * Encode individual ABI values\n */\nfunction encodeArgsIndividually(abiTypes: ABIType[], abiValues: ABIValue[]): Uint8Array[] {\n const encodedArgs: Uint8Array[] = []\n\n for (let i = 0; i < abiTypes.length; i++) {\n const abiType = abiTypes[i]\n const abiValue = abiValues[i]\n const encoded = abiType.encode(abiValue)\n encodedArgs.push(encoded)\n }\n\n return encodedArgs\n}\n\n/**\n * Encode ABI values with tuple packing for methods with many arguments\n */\nfunction encodeArgsWithTuplePacking(abiTypes: ABIType[], abiValues: ABIValue[]): Uint8Array[] {\n const encodedArgs: Uint8Array[] = []\n\n // When packing is needed (> 15 args), we split at 14 to leave one slot for the packed tuple\n // This gives us: 1 (selector) + 14 (individual) + 1 (packed tuple) = 16 total app args\n const splitAt = ARGS_TUPLE_PACKING_THRESHOLD - 1\n const firstAbiTypes = abiTypes.slice(0, splitAt)\n const firstAbiValues = abiValues.slice(0, splitAt)\n encodedArgs.push(...encodeArgsIndividually(firstAbiTypes, firstAbiValues))\n\n // Pack remaining arguments into a tuple\n const remainingAbiTypes = abiTypes.slice(splitAt)\n const remainingAbiValues = abiValues.slice(splitAt)\n\n if (remainingAbiTypes.length > 0) {\n const tupleType = new ABITupleType(remainingAbiTypes)\n const tupleValue = remainingAbiValues\n const tupleEncoded = tupleType.encode(tupleValue)\n encodedArgs.push(tupleEncoded)\n }\n\n return encodedArgs\n}\n\n/**\n * Builds encoded ABI method arguments and resolves reference arrays\n */\nfunction buildMethodCallArgsAndReferences(params: {\n sender: Address\n appId: bigint\n method: ABIMethod\n args: (ABIValue | undefined)[]\n accountReferences?: Address[]\n appReferences?: bigint[]\n assetReferences?: bigint[]\n}): { args: Uint8Array[]; accountReferences: Address[]; appReferences: bigint[]; assetReferences: bigint[] } {\n const { accountReferences, appReferences, assetReferences, updatedArgs } = prepareArgsForEncoding(\n params.sender,\n params.appId,\n params.method,\n params.args ?? [],\n params.accountReferences,\n params.appReferences,\n params.assetReferences,\n )\n\n const encodedArgs = encodeMethodArguments(params.method, updatedArgs)\n\n return {\n args: encodedArgs,\n accountReferences,\n appReferences,\n assetReferences,\n }\n}\n\nexport const buildAppCreateMethodCall = async (\n params: ProcessedAppCreateMethodCall,\n appManager: AppManager,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const approvalProgram =\n typeof params.approvalProgram === 'string'\n ? (await appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes\n : params.approvalProgram\n const clearStateProgram =\n typeof params.clearStateProgram === 'string'\n ? (await appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes\n : params.clearStateProgram\n const globalStateSchema =\n params.schema?.globalByteSlices !== undefined || params.schema?.globalInts !== undefined\n ? {\n numByteSlices: params.schema?.globalByteSlices ?? 0,\n numUints: params.schema?.globalInts ?? 0,\n }\n : undefined\n const localStateSchema =\n params.schema?.localByteSlices !== undefined || params.schema?.localInts !== undefined\n ? {\n numByteSlices: params.schema?.localByteSlices ?? 0,\n numUints: params.schema?.localInts ?? 0,\n }\n : undefined\n const extraProgramPages =\n params.extraProgramPages !== undefined ? params.extraProgramPages : calculateExtraProgramPages(approvalProgram!, clearStateProgram!)\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const argsAndReferences = buildMethodCallArgsAndReferences({\n sender: commonData.sender,\n appId: 0n,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n })\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: 0n,\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n globalStateSchema: globalStateSchema,\n localStateSchema: localStateSchema,\n extraProgramPages: extraProgramPages,\n args: argsAndReferences.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: argsAndReferences.accountReferences,\n appReferences: argsAndReferences.appReferences,\n assetReferences: argsAndReferences.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n\nexport const buildAppUpdateMethodCall = async (\n params: ProcessedAppUpdateMethodCall,\n appManager: AppManager,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const approvalProgram =\n typeof params.approvalProgram === 'string'\n ? (await appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes\n : params.approvalProgram\n const clearStateProgram =\n typeof params.clearStateProgram === 'string'\n ? (await appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes\n : params.clearStateProgram\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const argsAndReferences = buildMethodCallArgsAndReferences({\n sender: commonData.sender,\n appId: params.appId,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n })\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: params.appId,\n onComplete: OnApplicationComplete.UpdateApplication,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n args: argsAndReferences.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: argsAndReferences.accountReferences,\n appReferences: argsAndReferences.appReferences,\n assetReferences: argsAndReferences.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n\nexport const buildAppCallMethodCall = async (\n params: ProcessedAppCallMethodCall,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const argsAndReferences = buildMethodCallArgsAndReferences({\n sender: commonData.sender,\n appId: params.appId,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n })\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: params.appId,\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n args: argsAndReferences.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: argsAndReferences.accountReferences,\n appReferences: argsAndReferences.appReferences,\n assetReferences: argsAndReferences.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n"],"mappings":";;;;;;;;;;;AAmBA,MAAM,+BAA+B;AAuFrC,SAAgB,mDACd,QACA,cACqC;CACrC,MAAM,uBAAuB,IAAI,OAA0C;CAC3E,MAAM,iBAAiB,OAAO;AAC9B,KAAI,CAAC,eAAgB,QAAO,EAAE;CAG9B,MAAM,gBAAgB,OAAO,SAAU,YAAY,OAAO,SAAS,OAAO,OAAO,SAAS,OAAO,SAAU;AAE3G,MAAK,IAAI,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;EAC9C,MAAM,MAAM,eAAe;AAE3B,MAAI,QAAQ,OAEV;AAEF,MAAI,WAAW,IAAI,CAEjB;AAGF,MAAI,2BAA2B,IAAI,EAAE;AACnC,wBAAqB,KAAK;IACxB,MAAM;KACJ,KAAK,IAAI;KACT,QAAQ,IAAI;KACb;IACD,MAAM;IACP,CAAC;AAEF;;AAEF,MAAI,uBAAuB,IAAI,EAAE;GAE/B,MAAM,6BAA6B,mDAAmD,KAAK,cAAc;AACzG,wBAAqB,KAAK,GAAG,2BAA2B;AACxD,wBAAqB,K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AAe,OAAO,eAAe,IAAI,WAAW,gBAAgB;IACrE;GACL,eAAe,OAAO;GACvB;EACF,CAAC;;AAGJ,MAAa,yBAAyB,OACpC,QACA,iBACA,0BACyB;CACzB,MAAM,aAAa,2BAA2B,QAAQ,iBAAiB,sBAAsB;CAC7F,MAAM,oBAAoB,OAAO,mBAAmB,KAAK,MAAM,WAAW,EAAE,CAAC;CAC7E,MAAM,oBAAoB,iCAAiC;EACzD,QAAQ,WAAW;EACnB,OAAO,OAAO;EACd,QAAQ,OAAO;EACf,MAAM,OAAO,QAAQ,EAAE;EACJ;EACnB,eAAe,OAAO;EACtB,iBAAiB,OAAO;EACzB,CAAC;CAGF,MAAM,sBAAsB,OAAO,oBAAoB,OAAO,iBAAiB,SAAS;AAExF,QAAO,IAAI,YAAY;EACrB,GAAG;EACH,MAAM,gBAAgB;EACtB,SAAS;GACP,OAAO,OAAO;GACd,YAAY,OAAO,cAAc,sBAAsB;GACvD,MAAM,kBAAkB;GACxB,GAAI,sBACA,EAAE,kBAAkB,OAAO,kBAAkB,GAC7C;IACE,mBAAmB,kBAAkB;IACrC,eAAe,kBAAkB;IACjC,iBAAiB,kBAAkB;IACnC,eAAe,OAAO,eAAe,IAAI,WAAW,gBAAgB;IACrE;GACL,eAAe,OAAO;GACvB;EACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"method-call.mjs","names":["addr: Address","encodedArgs: Uint8Array[]"],"sources":["../../src/transactions/method-call.ts"],"sourcesContent":["import {\n ABIMethod,\n ABITupleType,\n ABIType,\n ABIUintType,\n ABIValue,\n argTypeIsReference,\n argTypeIsTransaction,\n} from '@algorandfoundation/algokit-abi'\nimport { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Address, Expand, getAddress } from '@algorandfoundation/algokit-common'\nimport { OnApplicationComplete, Transaction, TransactionSigner, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { AlgoAmount } from '../amount'\nimport { AppManager } from '../app-manager'\nimport { TransactionWithSigner } from '../transaction'\nimport { calculateExtraProgramPages } from '../util'\nimport { AppCreateParams, AppDeleteParams, AppMethodCallParams, AppUpdateParams } from './app-call'\nimport { buildTransactionCommonData } from './common'\n\nconst ARGS_TUPLE_PACKING_THRESHOLD = 15 // ARC-4 allows 15 ABI args (slots 1-15) before tuple packing is needed\n\n/** Parameters to define an ABI method call create transaction. */\nexport type AppCreateMethodCall = Expand<AppMethodCall<AppCreateParams>>\n/** Parameters to define an ABI method call update transaction. */\nexport type AppUpdateMethodCall = Expand<AppMethodCall<AppUpdateParams>>\n/** Parameters to define an ABI method call delete transaction. */\nexport type AppDeleteMethodCall = Expand<AppMethodCall<AppDeleteParams>>\n/** Parameters to define an ABI method call transaction. */\nexport type AppCallMethodCall = Expand<AppMethodCall<AppMethodCallParams>>\n\nexport type ProcessedAppCreateMethodCall = Expand<\n Omit<AppCreateMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\nexport type ProcessedAppUpdateMethodCall = Expand<\n Omit<AppUpdateMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\nexport type ProcessedAppCallMethodCall = Expand<\n Omit<AppCallMethodCall, 'args'> & {\n args?: (ABIValue | undefined)[]\n }\n>\n\n/** Types that can be used to define a transaction argument for an ABI call transaction. */\nexport type AppMethodCallTransactionArgument =\n // The following should match the partial `args` types from `AppMethodCall<T>` below\n | TransactionWithSigner\n | Transaction\n | Promise<Transaction>\n | AppMethodCall<AppCreateParams>\n | AppMethodCall<AppUpdateParams>\n | AppMethodCall<AppMethodCallParams>\n\n/** Parameters to define an ABI method call. */\nexport type AppMethodCall<T> = Expand<Omit<T, 'args'>> & {\n /** The ABI method to call */\n method: ABIMethod\n /** Arguments to the ABI method, either:\n * * An ABI value\n * * A transaction with explicit signer\n * * A transaction (where the signer will be automatically assigned)\n * * An unawaited transaction (e.g. from algorand.createTransaction.{transactionType}())\n * * Another method call (via method call params object)\n * * undefined (this represents a placeholder transaction argument that is fulfilled by another method call argument)\n */\n args?: (\n | ABIValue\n // The following should match the above `AppMethodCallTransactionArgument` type above\n | TransactionWithSigner\n | Transaction\n | Promise<Transaction>\n | AppMethodCall<AppCreateParams>\n | AppMethodCall<AppUpdateParams>\n | AppMethodCall<AppMethodCallParams>\n | undefined\n )[]\n}\n\ntype AppMethodCallArgs = AppMethodCall<unknown>['args']\ntype AppMethodCallArg = NonNullable<AppMethodCallArgs>[number]\n\nexport type AsyncTransactionParams = {\n txn: Promise<Transaction>\n signer?: TransactionSigner\n maxFee?: AlgoAmount\n}\n\nexport type TransactionParams = {\n txn: Transaction\n signer?: TransactionSigner\n maxFee?: AlgoAmount\n}\n\ntype ExtractedMethodCallTransactionArg =\n | { data: TransactionParams; type: 'txn' }\n | {\n data: AsyncTransactionParams\n type: 'asyncTxn'\n }\n | { data: ProcessedAppCallMethodCall | ProcessedAppCreateMethodCall | ProcessedAppUpdateMethodCall; type: 'methodCall' }\n\nexport function extractComposerTransactionsFromAppMethodCallParams(\n params: AppCallMethodCall | AppCreateMethodCall | AppUpdateMethodCall | AppDeleteMethodCall,\n parentSigner?: TransactionSigner,\n): ExtractedMethodCallTransactionArg[] {\n const composerTransactions = new Array<ExtractedMethodCallTransactionArg>()\n const methodCallArgs = params.args\n if (!methodCallArgs) return []\n\n // Extract signer from params, falling back to parentSigner\n const currentSigner = params.signer ? ('signer' in params.signer ? params.signer.signer : params.signer) : parentSigner\n\n for (let i = 0; i < methodCallArgs.length; i++) {\n const arg = methodCallArgs[i]\n\n if (arg === undefined) {\n // is a transaction or default value placeholder, do nothing\n continue\n }\n if (isAbiValue(arg)) {\n // if is ABI value, also ignore\n continue\n }\n\n if (isTransactionWithSignerArg(arg)) {\n composerTransactions.push({\n data: {\n txn: arg.txn,\n signer: arg.signer,\n },\n type: 'txn',\n })\n\n continue\n }\n if (isAppCallMethodCallArg(arg)) {\n // Recursively extract nested method call transactions, passing the nested call itself and current signer as parent\n const nestedComposerTransactions = extractComposerTransactionsFromAppMethodCallParams(arg, currentSigner)\n composerTransactions.push(...nestedComposerTransactions)\n composerTransactions.push({\n data: {\n ...arg,\n signer: arg.signer ?? currentSigner,\n args: processAppMethodCallArgs(arg.args),\n },\n type: 'methodCall',\n } satisfies ExtractedMethodCallTransactionArg)\n\n continue\n }\n if (arg instanceof Promise) {\n composerTransactions.push({\n data: {\n txn: arg,\n signer: currentSigner,\n },\n type: 'asyncTxn',\n })\n continue\n }\n\n composerTransactions.push({\n data: {\n txn: Promise.resolve(arg),\n signer: currentSigner,\n },\n type: 'asyncTxn',\n })\n }\n\n return composerTransactions\n}\n\nexport function processAppMethodCallArgs(args: AppMethodCallArg[] | undefined): (ABIValue | undefined)[] | undefined {\n if (args === undefined) return undefined\n\n return args.map((arg) => {\n if (arg === undefined) {\n // Handle explicit placeholders (either transaction or default value)\n return undefined\n } else if (!isAbiValue(arg)) {\n // If the arg is not an ABIValue, it's must be a transaction, set to undefined\n // transaction arguments should be flattened out and added into the composer during the add process\n return undefined\n }\n return arg\n })\n}\n\nfunction isTransactionWithSignerArg(arg: AppMethodCallArg): arg is TransactionWithSigner {\n return typeof arg === 'object' && arg !== undefined && 'txn' in arg && 'signer' in arg\n}\n\nfunction isAppCallMethodCallArg(\n arg: AppMethodCallArg,\n): arg is AppMethodCall<AppCreateParams> | AppMethodCall<AppUpdateParams> | AppMethodCall<AppMethodCallParams> {\n return typeof arg === 'object' && arg !== undefined && 'method' in arg\n}\n\nconst isAbiValue = (x: unknown): x is ABIValue => {\n if (Array.isArray(x)) return x.length == 0 || x.every(isAbiValue)\n\n // If x is a POJO literal\n if (Object.getPrototypeOf(x) === Object.getPrototypeOf({})) {\n return Object.values(x as object).every(isAbiValue)\n }\n\n return (\n typeof x === 'bigint' ||\n typeof x === 'boolean' ||\n typeof x === 'number' ||\n typeof x === 'string' ||\n x instanceof Uint8Array ||\n x instanceof Address\n )\n}\n\n/**\n * Prepares method arguments for ABI encoding by building reference arrays and\n * replacing reference-type arguments (account, asset, application) with their indices.\n */\nfunction prepareArgsForEncoding(\n sender: Address,\n appId: bigint,\n method: ABIMethod,\n methodArgs: (ABIValue | undefined)[],\n accountReferences?: Address[],\n appReferences?: bigint[],\n assetReferences?: bigint[],\n): { accountReferences: Address[]; appReferences: bigint[]; assetReferences: bigint[]; updatedArgs: (ABIValue | undefined)[] } {\n const accounts = [...(accountReferences ?? [])]\n const assets = [...(assetReferences ?? [])]\n const apps = [...(appReferences ?? [])]\n\n const updatedArgs = methodArgs.map((arg, i) => {\n const argType = method.args[i].type\n if (!argTypeIsReference(argType)) {\n return arg\n }\n switch (argType) {\n case 'account': {\n let addr: Address\n if (typeof arg === 'string') {\n addr = getAddress(arg)\n } else if (arg instanceof Uint8Array) {\n addr = new Address(arg)\n } else {\n throw new Error('Invalid value for account')\n }\n\n if (sender.equals(addr)) {\n return 0\n }\n\n const existing = accounts.findIndex((a) => a.equals(addr)) + 1\n if (existing) return existing\n\n accounts.push(addr)\n return accounts.length\n }\n case 'asset': {\n if (typeof arg !== 'bigint') {\n throw new Error('Invalid value for asset')\n }\n\n const existing = assets.findIndex((a) => a === arg)\n if (existing === -1) {\n assets.push(arg)\n return assets.length - 1\n }\n\n return existing\n }\n case 'application': {\n if (typeof arg !== 'bigint') {\n throw new Error('Invalid value for application')\n }\n\n if (arg === appId) return 0\n\n const existing = apps.findIndex((a) => a === arg) + 1\n if (existing) return existing\n\n apps.push(arg)\n return apps.length\n }\n }\n })\n\n return { accountReferences: accounts, appReferences: apps, assetReferences: assets, updatedArgs }\n}\n\n/**\n * Encode ABI method arguments with tuple packing support\n * Ports the logic from the Rust encode_method_arguments function\n */\nfunction encodeMethodArguments(method: ABIMethod, args: (ABIValue | undefined)[]): Uint8Array[] {\n const encodedArgs = new Array<Uint8Array>()\n\n // Insert method selector at the front\n encodedArgs.push(method.getSelector())\n\n // Get ABI types for non-transaction arguments\n const abiTypes = new Array<ABIType>()\n const abiValues = new Array<ABIValue>()\n\n // Process each method argument\n for (let i = 0; i < method.args.length; i++) {\n const methodArg = method.args[i]\n const argValue = args[i]\n\n if (argTypeIsTransaction(methodArg.type)) {\n // Transaction arguments are not ABI encoded - they're handled separately\n } else if (argTypeIsReference(methodArg.type)) {\n // Reference types are encoded as uint8 indexes\n const referenceType = methodArg.type\n if (typeof argValue === 'number') {\n abiTypes.push(new ABIUintType(8))\n abiValues.push(argValue)\n } else {\n throw new Error(`Invalid reference value for ${referenceType}: ${argValue}`)\n }\n } else if (argValue !== undefined) {\n // Regular ABI value\n abiTypes.push(methodArg.type)\n // it's safe to cast to ABIValue here because the abiType must be ABIValue\n abiValues.push(argValue as ABIValue)\n }\n\n // Skip undefined values (transaction placeholders)\n }\n\n if (abiValues.length !== abiTypes.length) {\n throw new Error('Mismatch in length of non-transaction arguments')\n }\n\n // Apply ARC-4 tuple packing for methods with more than 15 ABI arguments\n // Algorand allows 16 app args total; slot 0 is the method selector, leaving 15 for ABI args\n if (abiTypes.length > ARGS_TUPLE_PACKING_THRESHOLD) {\n encodedArgs.push(...encodeArgsWithTuplePacking(abiTypes, abiValues))\n } else {\n encodedArgs.push(...encodeArgsIndividually(abiTypes, abiValues))\n }\n\n return encodedArgs\n}\n\n/**\n * Encode individual ABI values\n */\nfunction encodeArgsIndividually(abiTypes: ABIType[], abiValues: ABIValue[]): Uint8Array[] {\n const encodedArgs: Uint8Array[] = []\n\n for (let i = 0; i < abiTypes.length; i++) {\n const abiType = abiTypes[i]\n const abiValue = abiValues[i]\n const encoded = abiType.encode(abiValue)\n encodedArgs.push(encoded)\n }\n\n return encodedArgs\n}\n\n/**\n * Encode ABI values with tuple packing for methods with many arguments\n */\nfunction encodeArgsWithTuplePacking(abiTypes: ABIType[], abiValues: ABIValue[]): Uint8Array[] {\n const encodedArgs: Uint8Array[] = []\n\n // When packing is needed (> 15 args), we split at 14 to leave one slot for the packed tuple\n // This gives us: 1 (selector) + 14 (individual) + 1 (packed tuple) = 16 total app args\n const splitAt = ARGS_TUPLE_PACKING_THRESHOLD - 1\n const firstAbiTypes = abiTypes.slice(0, splitAt)\n const firstAbiValues = abiValues.slice(0, splitAt)\n encodedArgs.push(...encodeArgsIndividually(firstAbiTypes, firstAbiValues))\n\n // Pack remaining arguments into a tuple\n const remainingAbiTypes = abiTypes.slice(splitAt)\n const remainingAbiValues = abiValues.slice(splitAt)\n\n if (remainingAbiTypes.length > 0) {\n const tupleType = new ABITupleType(remainingAbiTypes)\n const tupleValue = remainingAbiValues\n const tupleEncoded = tupleType.encode(tupleValue)\n encodedArgs.push(tupleEncoded)\n }\n\n return encodedArgs\n}\n\n/**\n * Builds encoded ABI method arguments and resolves reference arrays\n */\nfunction buildMethodCallArgsAndReferences(params: {\n sender: Address\n appId: bigint\n method: ABIMethod\n args: (ABIValue | undefined)[]\n accountReferences?: Address[]\n appReferences?: bigint[]\n assetReferences?: bigint[]\n}): { args: Uint8Array[]; accountReferences: Address[]; appReferences: bigint[]; assetReferences: bigint[] } {\n const { accountReferences, appReferences, assetReferences, updatedArgs } = prepareArgsForEncoding(\n params.sender,\n params.appId,\n params.method,\n params.args ?? [],\n params.accountReferences,\n params.appReferences,\n params.assetReferences,\n )\n\n const encodedArgs = encodeMethodArguments(params.method, updatedArgs)\n\n return {\n args: encodedArgs,\n accountReferences,\n appReferences,\n assetReferences,\n }\n}\n\nexport const buildAppCreateMethodCall = async (\n params: ProcessedAppCreateMethodCall,\n appManager: AppManager,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const approvalProgram =\n typeof params.approvalProgram === 'string'\n ? (await appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes\n : params.approvalProgram\n const clearStateProgram =\n typeof params.clearStateProgram === 'string'\n ? (await appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes\n : params.clearStateProgram\n const globalStateSchema =\n params.schema?.globalByteSlices !== undefined || params.schema?.globalInts !== undefined\n ? {\n numByteSlices: params.schema?.globalByteSlices ?? 0,\n numUints: params.schema?.globalInts ?? 0,\n }\n : undefined\n const localStateSchema =\n params.schema?.localByteSlices !== undefined || params.schema?.localInts !== undefined\n ? {\n numByteSlices: params.schema?.localByteSlices ?? 0,\n numUints: params.schema?.localInts ?? 0,\n }\n : undefined\n const extraProgramPages =\n params.extraProgramPages !== undefined ? params.extraProgramPages : calculateExtraProgramPages(approvalProgram!, clearStateProgram!)\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const argsAndReferences = buildMethodCallArgsAndReferences({\n sender: commonData.sender,\n appId: 0n,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n })\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: 0n,\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n globalStateSchema: globalStateSchema,\n localStateSchema: localStateSchema,\n extraProgramPages: extraProgramPages,\n args: argsAndReferences.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: argsAndReferences.accountReferences,\n appReferences: argsAndReferences.appReferences,\n assetReferences: argsAndReferences.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n\nexport const buildAppUpdateMethodCall = async (\n params: ProcessedAppUpdateMethodCall,\n appManager: AppManager,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const approvalProgram =\n typeof params.approvalProgram === 'string'\n ? (await appManager.compileTeal(params.approvalProgram)).compiledBase64ToBytes\n : params.approvalProgram\n const clearStateProgram =\n typeof params.clearStateProgram === 'string'\n ? (await appManager.compileTeal(params.clearStateProgram)).compiledBase64ToBytes\n : params.clearStateProgram\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const argsAndReferences = buildMethodCallArgsAndReferences({\n sender: commonData.sender,\n appId: params.appId,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n })\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: params.appId,\n onComplete: OnApplicationComplete.UpdateApplication,\n approvalProgram: approvalProgram,\n clearStateProgram: clearStateProgram,\n args: argsAndReferences.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: argsAndReferences.accountReferences,\n appReferences: argsAndReferences.appReferences,\n assetReferences: argsAndReferences.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n\nexport const buildAppCallMethodCall = async (\n params: ProcessedAppCallMethodCall,\n suggestedParams: SuggestedParams,\n defaultValidityWindow: bigint,\n): Promise<Transaction> => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n const accountReferences = params.accountReferences?.map((a) => getAddress(a))\n const argsAndReferences = buildMethodCallArgsAndReferences({\n sender: commonData.sender,\n appId: params.appId,\n method: params.method,\n args: params.args ?? [],\n accountReferences: accountReferences,\n appReferences: params.appReferences,\n assetReferences: params.assetReferences,\n })\n\n // If accessReferences is provided, we should not pass legacy foreign arrays\n const hasAccessReferences = params.accessReferences && params.accessReferences.length > 0\n\n return new Transaction({\n ...commonData,\n type: TransactionType.AppCall,\n appCall: {\n appId: params.appId,\n onComplete: params.onComplete ?? OnApplicationComplete.NoOp,\n args: argsAndReferences.args,\n ...(hasAccessReferences\n ? { accessReferences: params.accessReferences }\n : {\n accountReferences: argsAndReferences.accountReferences,\n appReferences: argsAndReferences.appReferences,\n assetReferences: argsAndReferences.assetReferences,\n boxReferences: params.boxReferences?.map(AppManager.getBoxReference),\n }),\n rejectVersion: params.rejectVersion,\n },\n })\n}\n"],"mappings":";;;;;;;;;;;AAmBA,MAAM,+BAA+B;AAuFrC,SAAgB,mDACd,QACA,cACqC;CACrC,MAAM,uBAAuB,IAAI,OAA0C;CAC3E,MAAM,iBAAiB,OAAO;AAC9B,KAAI,CAAC,eAAgB,QAAO,EAAE;CAG9B,MAAM,gBAAgB,OAAO,SAAU,YAAY,OAAO,SAAS,OAAO,OAAO,SAAS,OAAO,SAAU;AAE3G,MAAK,IAAI,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;EAC9C,MAAM,MAAM,eAAe;AAE3B,MAAI,QAAQ,OAEV;AAEF,MAAI,WAAW,IAAI,CAEjB;AAGF,MAAI,2BAA2B,IAAI,EAAE;AACnC,wBAAqB,KAAK;IACxB,MAAM;KACJ,KAAK,IAAI;KACT,QAAQ,IAAI;KACb;IACD,MAAM;IACP,CAAC;AAEF;;AAEF,MAAI,uBAAuB,IAAI,EAAE;GAE/B,MAAM,6BAA6B,mDAAmD,KAAK,cAAc;AACzG,wBAAqB,KAAK,GAAG,2BAA2B;AACxD,wBAAqB,KAAK;IACxB,MAAM;KACJ,GAAG;KACH,QAAQ,IAAI,UAAU;KACtB,MAAM,yBAAyB,IAAI,KAAK;KACzC;IACD,MAAM;IACP,CAA6C;AAE9C;;AAEF,MAAI,eAAe,SAAS;AAC1B,wBAAqB,KAAK;IACxB,MAAM;KACJ,KAAK;KACL,QAAQ;KACT;IACD,MAAM;IACP,CAAC;AACF;;AAGF,uBAAqB,KAAK;GACxB,MAAM;IACJ,KAAK,QAAQ,QAAQ,IAAI;IACzB,QAAQ;IACT;GACD,MAAM;GACP,CAAC;;AAGJ,QAAO;;AAGT,SAAgB,yBAAyB,MAA4E;AACnH,KAAI,SAAS,OAAW,QAAO;AAE/B,QAAO,KAAK,KAAK,QAAQ;AACvB,MAAI,QAAQ,OAEV;WACS,CAAC,WAAW,IAA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rB,GAAG;EACH,MAAM,gBAAgB;EACtB,SAAS;GACP,OAAO,OAAO;GACd,YAAY,OAAO,cAAc,sBAAsB;GACvD,MAAM,kBAAkB;GACxB,GAAI,sBACA,EAAE,kBAAkB,OAAO,kBAAkB,GAC7C;IACE,mBAAmB,kBAAkB;IACrC,eAAe,kBAAkB;IACjC,iBAAiB,kBAAkB;IACnC,eAAe,OAAO,eAAe,IAAI,WAAW,gBAAgB;IACrE;GACL,eAAe,OAAO;GACvB;EACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment.js","names":["Transaction","buildTransactionCommonData","TransactionType","getAddress","getOptionalAddress"],"sources":["../../src/transactions/payment.ts"],"sourcesContent":["import { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { ReadableAddress, getAddress, getOptionalAddress } from '@algorandfoundation/algokit-common'\nimport { Transaction, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { AlgoAmount } from '../
|
|
1
|
+
{"version":3,"file":"payment.js","names":["Transaction","buildTransactionCommonData","TransactionType","getAddress","getOptionalAddress"],"sources":["../../src/transactions/payment.ts"],"sourcesContent":["import { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { ReadableAddress, getAddress, getOptionalAddress } from '@algorandfoundation/algokit-common'\nimport { Transaction, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { AlgoAmount } from '../amount'\nimport { CommonTransactionParams, buildTransactionCommonData } from './common'\n\n/** Parameters to define a payment transaction. */\nexport type PaymentParams = CommonTransactionParams & {\n /** The address of the account that will receive the Algo */\n receiver: ReadableAddress\n /** Amount to send */\n amount: AlgoAmount\n /** If given, close the sender account and send the remaining balance to this address\n *\n * *Warning:* Be careful with this parameter as it can lead to loss of funds if not used correctly.\n */\n closeRemainderTo?: ReadableAddress\n}\n\nexport const buildPayment = (params: PaymentParams, suggestedParams: SuggestedParams, defaultValidityWindow: bigint): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n return new Transaction({\n ...commonData,\n type: TransactionType.Payment,\n payment: {\n receiver: getAddress(params.receiver),\n amount: params.amount.microAlgos,\n closeRemainderTo: getOptionalAddress(params.closeRemainderTo),\n },\n })\n}\n"],"mappings":";;;;;;AAmBA,MAAa,gBAAgB,QAAuB,iBAAkC,0BAA+C;AAEnI,QAAO,IAAIA,gCAAY;EACrB,GAFiBC,0CAA2B,QAAQ,iBAAiB,sBAAsB;EAG3F,MAAMC,yCAAgB;EACtB,SAAS;GACP,UAAUC,2BAAW,OAAO,SAAS;GACrC,QAAQ,OAAO,OAAO;GACtB,kBAAkBC,mCAAmB,OAAO,iBAAiB;GAC9D;EACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment.mjs","names":[],"sources":["../../src/transactions/payment.ts"],"sourcesContent":["import { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { ReadableAddress, getAddress, getOptionalAddress } from '@algorandfoundation/algokit-common'\nimport { Transaction, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { AlgoAmount } from '../
|
|
1
|
+
{"version":3,"file":"payment.mjs","names":[],"sources":["../../src/transactions/payment.ts"],"sourcesContent":["import { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { ReadableAddress, getAddress, getOptionalAddress } from '@algorandfoundation/algokit-common'\nimport { Transaction, TransactionType } from '@algorandfoundation/algokit-transact'\nimport { AlgoAmount } from '../amount'\nimport { CommonTransactionParams, buildTransactionCommonData } from './common'\n\n/** Parameters to define a payment transaction. */\nexport type PaymentParams = CommonTransactionParams & {\n /** The address of the account that will receive the Algo */\n receiver: ReadableAddress\n /** Amount to send */\n amount: AlgoAmount\n /** If given, close the sender account and send the remaining balance to this address\n *\n * *Warning:* Be careful with this parameter as it can lead to loss of funds if not used correctly.\n */\n closeRemainderTo?: ReadableAddress\n}\n\nexport const buildPayment = (params: PaymentParams, suggestedParams: SuggestedParams, defaultValidityWindow: bigint): Transaction => {\n const commonData = buildTransactionCommonData(params, suggestedParams, defaultValidityWindow)\n return new Transaction({\n ...commonData,\n type: TransactionType.Payment,\n payment: {\n receiver: getAddress(params.receiver),\n amount: params.amount.microAlgos,\n closeRemainderTo: getOptionalAddress(params.closeRemainderTo),\n },\n })\n}\n"],"mappings":";;;;;;AAmBA,MAAa,gBAAgB,QAAuB,iBAAkC,0BAA+C;AAEnI,QAAO,IAAI,YAAY;EACrB,GAFiB,2BAA2B,QAAQ,iBAAiB,sBAAsB;EAG3F,MAAM,gBAAgB;EACtB,SAAS;GACP,UAAU,WAAW,OAAO,SAAS;GACrC,QAAQ,OAAO,OAAO;GACtB,kBAAkB,mBAAmB,OAAO,iBAAiB;GAC9D;EACF,CAAC"}
|
|
@@ -1,448 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { AlgoAmount } from "./amount.js";
|
|
6
|
-
import { CommonTransactionParams } from "../transactions/common.js";
|
|
7
|
-
import { SendParams, SendSingleTransactionResult } from "./transaction.js";
|
|
8
|
-
import { AccountInformation } from "./account.js";
|
|
9
|
-
import { TestNetDispenserApiClient } from "./dispenser-client.js";
|
|
10
|
-
import { ClientManager } from "./client-manager.js";
|
|
11
|
-
import { KmdAccountManager } from "./kmd-account-manager.js";
|
|
1
|
+
import { MultisigAccount } from "../packages/transact/src/multisig.js";
|
|
2
|
+
import { LogicSigAccount } from "../packages/transact/src/logicsig.js";
|
|
3
|
+
import { AddressWithTransactionSigner, TransactionSigner } from "../packages/transact/src/signer.js";
|
|
4
|
+
import { AccountManager as AccountManager$1, EnsureFundedResult as EnsureFundedResult$1 } from "../account-manager.js";
|
|
12
5
|
|
|
13
6
|
//#region src/types/account-manager.d.ts
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Returns a `TransactionSigner` for the given account that can sign a transaction.
|
|
23
|
-
* This function has memoization, so will return the same transaction signer for a given account.
|
|
24
|
-
* @param account An account that can sign a transaction
|
|
25
|
-
* @returns A transaction signer
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* const signer = getAccountTransactionSigner(account)
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
7
|
+
/** @deprecated Import from `@algorandfoundation/algokit-utils/account-manager` instead */
|
|
8
|
+
declare const AccountManager: typeof AccountManager$1;
|
|
9
|
+
/** @deprecated Import from `@algorandfoundation/algokit-utils/account-manager` instead */
|
|
10
|
+
type AccountManager = AccountManager$1;
|
|
11
|
+
/** @deprecated Import from `@algorandfoundation/algokit-utils/account-manager` instead */
|
|
12
|
+
type EnsureFundedResult = EnsureFundedResult$1;
|
|
13
|
+
/** @deprecated Import from `@algorandfoundation/algokit-utils/account-manager` instead */
|
|
31
14
|
declare const getAccountTransactionSigner: (val: AddressWithTransactionSigner | LogicSigAccount | MultisigAccount) => TransactionSigner;
|
|
32
|
-
/** Creates and keeps track of signing accounts that can sign transactions for a sending address. */
|
|
33
|
-
declare class AccountManager {
|
|
34
|
-
private _clientManager;
|
|
35
|
-
private _kmdAccountManager;
|
|
36
|
-
private _accounts;
|
|
37
|
-
private _defaultSigner?;
|
|
38
|
-
/**
|
|
39
|
-
* Create a new account manager.
|
|
40
|
-
* @param clientManager The ClientManager client to use for algod and kmd clients
|
|
41
|
-
* @example Create a new account manager
|
|
42
|
-
* ```typescript
|
|
43
|
-
* const accountManager = new AccountManager(clientManager)
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
constructor(clientManager: ClientManager);
|
|
47
|
-
private _getComposer;
|
|
48
|
-
/**
|
|
49
|
-
* KMD account manager that allows you to easily get and create accounts using KMD.
|
|
50
|
-
* @returns The `KmdAccountManager` instance.
|
|
51
|
-
* @example
|
|
52
|
-
* ```typescript
|
|
53
|
-
* const kmdManager = accountManager.kmd;
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
get kmd(): KmdAccountManager;
|
|
57
|
-
/**
|
|
58
|
-
* Sets the default signer to use if no other signer is specified.
|
|
59
|
-
*
|
|
60
|
-
* If this isn't set an a transaction needs signing for a given sender
|
|
61
|
-
* then an error will be thrown from `getSigner` / `getAccount`.
|
|
62
|
-
* @param signer The signer to use, either a `TransactionSigner` or a `AddressWithSigner`
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* const signer = accountManager.random() // Can be anything that returns a `TransactionSigner` or `AddressWithSigner`
|
|
66
|
-
* accountManager.setDefaultSigner(signer)
|
|
67
|
-
*
|
|
68
|
-
* // When signing a transaction, if there is no signer registered for the sender then the default signer will be used
|
|
69
|
-
* const signer = accountManager.getSigner("SENDERADDRESS")
|
|
70
|
-
* ```
|
|
71
|
-
* @returns The `AccountManager` so method calls can be chained
|
|
72
|
-
*/
|
|
73
|
-
setDefaultSigner(signer: TransactionSigner | AddressWithTransactionSigner): AccountManager;
|
|
74
|
-
/**
|
|
75
|
-
* Records the given account (that can sign) against the address of the provided account for later
|
|
76
|
-
* retrieval and returns a `AddressWithTransactionSigner` along with the original account in an `account` property.
|
|
77
|
-
*/
|
|
78
|
-
private signerAccount;
|
|
79
|
-
/**
|
|
80
|
-
* Tracks the given account for later signing.
|
|
81
|
-
*
|
|
82
|
-
* Note: If you are generating accounts via the various methods on `AccountManager`
|
|
83
|
-
* (like `random`, `fromMnemonic`, `logicsig`, etc.) then they automatically get tracked.
|
|
84
|
-
* @param account The account to register, which can be a `AddressWithSigner` or
|
|
85
|
-
* a `algosdk.Account`, `algosdk.LogicSigAccount`, `SigningAccount` or `MultisigAccount`
|
|
86
|
-
* @example
|
|
87
|
-
* ```typescript
|
|
88
|
-
* const accountManager = new AccountManager(clientManager)
|
|
89
|
-
* .setSignerFromAccount(algosdk.generateAccount())
|
|
90
|
-
* .setSignerFromAccount(new algosdk.LogicSigAccount(program, args))
|
|
91
|
-
* .setSignerFromAccount(new SigningAccount(mnemonic, sender))
|
|
92
|
-
* .setSignerFromAccount(new MultisigAccount({version: 1, threshold: 1, addrs: ["ADDRESS1...", "ADDRESS2..."]}, [account1, account2]))
|
|
93
|
-
* .setSignerFromAccount({addr: "SENDERADDRESS", signer: transactionSigner})
|
|
94
|
-
* ```
|
|
95
|
-
* @returns The `AccountManager` instance for method chaining
|
|
96
|
-
*/
|
|
97
|
-
setSignerFromAccount(account: AddressWithTransactionSigner | LogicSigAccount | MultisigAccount): this;
|
|
98
|
-
/**
|
|
99
|
-
* Tracks the given `TransactionSigner` against the given sender address for later signing.
|
|
100
|
-
* @param sender The sender address to use this signer for
|
|
101
|
-
* @param signer The `TransactionSigner` to sign transactions with for the given sender
|
|
102
|
-
* @example
|
|
103
|
-
* ```typescript
|
|
104
|
-
* const accountManager = new AccountManager(clientManager)
|
|
105
|
-
* .setSigner("SENDERADDRESS", transactionSigner)
|
|
106
|
-
* ```
|
|
107
|
-
* @returns The `AccountManager` instance for method chaining
|
|
108
|
-
*/
|
|
109
|
-
setSigner(sender: string | Address, signer: TransactionSigner): this;
|
|
110
|
-
/**
|
|
111
|
-
* Takes all registered signers from the given `AccountManager` and adds them to this `AccountManager`.
|
|
112
|
-
*
|
|
113
|
-
* This is useful for situations where you have multiple contexts you are building accounts in such as unit tests.
|
|
114
|
-
* @param anotherAccountManager Another account manager with signers registered
|
|
115
|
-
* @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)
|
|
116
|
-
* @returns The `AccountManager` instance for method chaining
|
|
117
|
-
* @example
|
|
118
|
-
* ```typescript
|
|
119
|
-
* accountManager2.setSigners(accountManager1);
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
setSigners(anotherAccountManager: AccountManager, overwriteExisting?: boolean): this;
|
|
123
|
-
/**
|
|
124
|
-
* Returns the `TransactionSigner` for the given sender address, ready to sign a transaction for that sender.
|
|
125
|
-
*
|
|
126
|
-
* If no signer has been registered for that address then the default signer is used if registered and
|
|
127
|
-
* if not then an error is thrown.
|
|
128
|
-
*
|
|
129
|
-
* @param sender The sender address
|
|
130
|
-
* @example
|
|
131
|
-
* ```typescript
|
|
132
|
-
* const signer = accountManager.getSigner("SENDERADDRESS")
|
|
133
|
-
* ```
|
|
134
|
-
* @returns The `TransactionSigner` or throws an error if not found and no default signer is set
|
|
135
|
-
*/
|
|
136
|
-
getSigner(sender: ReadableAddress): TransactionSigner;
|
|
137
|
-
/**
|
|
138
|
-
* Returns the `AddressWithSigner` for the given sender address.
|
|
139
|
-
*
|
|
140
|
-
* If no signer has been registered for that address then an error is thrown.
|
|
141
|
-
* @param sender The sender address
|
|
142
|
-
* @example
|
|
143
|
-
* ```typescript
|
|
144
|
-
* const sender = accountManager.random()
|
|
145
|
-
* // ...
|
|
146
|
-
* // Returns the `AddressWithSigner` for `sender` that has previously been registered
|
|
147
|
-
* const account = accountManager.getAccount(sender)
|
|
148
|
-
* ```
|
|
149
|
-
* @returns The `AddressWithSigner` or throws an error if not found
|
|
150
|
-
*/
|
|
151
|
-
getAccount(sender: ReadableAddress): AddressWithTransactionSigner;
|
|
152
|
-
/**
|
|
153
|
-
* Returns the given sender account's current status, balance and spendable amounts.
|
|
154
|
-
*
|
|
155
|
-
* [Response data schema details](https://dev.algorand.co/reference/rest-apis/algod/#accountinformation)
|
|
156
|
-
* @example
|
|
157
|
-
* ```typescript
|
|
158
|
-
* const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
|
|
159
|
-
* const accountInfo = await accountManager.getInformation(address);
|
|
160
|
-
* ```
|
|
161
|
-
*
|
|
162
|
-
* @param sender The account / address to look up
|
|
163
|
-
* @returns The account information
|
|
164
|
-
*/
|
|
165
|
-
getInformation(sender: ReadableAddress): Promise<AccountInformation>;
|
|
166
|
-
/**
|
|
167
|
-
* Tracks and returns an Algorand account with secret key loaded (i.e. that can sign transactions) by taking the mnemonic secret.
|
|
168
|
-
*
|
|
169
|
-
* @example
|
|
170
|
-
* ```typescript
|
|
171
|
-
* const account = accountManager.fromMnemonic("mnemonic secret ...")
|
|
172
|
-
* const rekeyedAccount = accountManager.fromMnemonic("mnemonic secret ...", "SENDERADDRESS...")
|
|
173
|
-
* ```
|
|
174
|
-
* @param mnemonicSecret The mnemonic secret representing the private key of an account; **Note: Be careful how the mnemonic is handled**,
|
|
175
|
-
* never commit it into source control and ideally load it from the environment (ideally via a secret storage service) rather than the file system.
|
|
176
|
-
* @param sender The optional sender address to use this signer for (aka a rekeyed account)
|
|
177
|
-
* @returns The account
|
|
178
|
-
*/
|
|
179
|
-
fromMnemonic(mnemonicSecret: string, sender?: string | Address): AddressWithTransactionSigner;
|
|
180
|
-
/**
|
|
181
|
-
* Tracks and returns an Algorand account that is a rekeyed version of the given account to a new sender.
|
|
182
|
-
*
|
|
183
|
-
* @example
|
|
184
|
-
* ```typescript
|
|
185
|
-
* const account = accountManager.fromMnemonic("mnemonic secret ...")
|
|
186
|
-
* const rekeyedAccount = accountManager.rekeyed(account, "SENDERADDRESS...")
|
|
187
|
-
* ```
|
|
188
|
-
* @param account The account to use as the signer for this new rekeyed account
|
|
189
|
-
* @param sender The sender address to use as the new sender
|
|
190
|
-
* @returns The account
|
|
191
|
-
*/
|
|
192
|
-
rekeyed(sender: string | Address, account: AddressWithTransactionSigner): Address & AddressWithTransactionSigner & {
|
|
193
|
-
account: {
|
|
194
|
-
addr: Address;
|
|
195
|
-
signer: TransactionSigner;
|
|
196
|
-
};
|
|
197
|
-
};
|
|
198
|
-
/**
|
|
199
|
-
* Tracks and returns an Algorand account with private key loaded by convention from environment variables based on the given name identifier.
|
|
200
|
-
*
|
|
201
|
-
* Note: This function expects to run in a Node.js environment.
|
|
202
|
-
*
|
|
203
|
-
* ## Convention:
|
|
204
|
-
* * **Non-LocalNet:** will load process.env['\{NAME\}_MNEMONIC'] as a mnemonic secret; **Note: Be careful how the mnemonic is handled**,
|
|
205
|
-
* never commit it into source control and ideally load it via a secret storage service rather than the file system.
|
|
206
|
-
* If process.env['\{NAME\}_SENDER'] is defined then it will use that for the sender address (i.e. to support rekeyed accounts)
|
|
207
|
-
* * **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
|
|
208
|
-
*
|
|
209
|
-
* 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).
|
|
210
|
-
*
|
|
211
|
-
* @example Default
|
|
212
|
-
*
|
|
213
|
-
* 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:
|
|
214
|
-
* ```typescript
|
|
215
|
-
* const account = await accountManager.fromEnvironment('MY_ACCOUNT')
|
|
216
|
-
* ```
|
|
217
|
-
*
|
|
218
|
-
* 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.
|
|
219
|
-
* 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.
|
|
220
|
-
*
|
|
221
|
-
* @param name The name identifier of the account
|
|
222
|
-
* @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
|
|
223
|
-
* @returns The account
|
|
224
|
-
*/
|
|
225
|
-
fromEnvironment(name: string, fundWith?: AlgoAmount): Promise<AddressWithTransactionSigner>;
|
|
226
|
-
/**
|
|
227
|
-
* Tracks and returns an Algorand account with private key loaded from the given KMD wallet (identified by name).
|
|
228
|
-
*
|
|
229
|
-
* @param name The name of the wallet to retrieve an account from
|
|
230
|
-
* @param predicate An optional filter to use to find the account (otherwise it will return a random account from the wallet)
|
|
231
|
-
* @param sender The optional sender address to use this signer for (aka a rekeyed account)
|
|
232
|
-
* @example Get default funded account in a LocalNet
|
|
233
|
-
*
|
|
234
|
-
* ```typescript
|
|
235
|
-
* const defaultDispenserAccount = await accountManager.fromKmd('unencrypted-default-wallet',
|
|
236
|
-
* a => a.status !== 'Offline' && a.amount > 1_000_000_000
|
|
237
|
-
* )
|
|
238
|
-
* ```
|
|
239
|
-
* @returns The account
|
|
240
|
-
*/
|
|
241
|
-
fromKmd(name: string, predicate?: (account: Record<string, any>) => boolean, sender?: string | Address): Promise<Address & AddressWithTransactionSigner & {
|
|
242
|
-
account: AddressWithTransactionSigner;
|
|
243
|
-
}>;
|
|
244
|
-
/**
|
|
245
|
-
* Tracks and returns an account that supports partial or full multisig signing.
|
|
246
|
-
*
|
|
247
|
-
* @example
|
|
248
|
-
* ```typescript
|
|
249
|
-
* const account = accountManager.multisig({version: 1, threshold: 1, addrs: ["ADDRESS1...", "ADDRESS2..."]},
|
|
250
|
-
* [(await accountManager.fromEnvironment('ACCOUNT1')).account])
|
|
251
|
-
* ```
|
|
252
|
-
* @param multisigParams The parameters that define the multisig account
|
|
253
|
-
* @param subSigners The signers that are currently present
|
|
254
|
-
* @returns A multisig account wrapper
|
|
255
|
-
*/
|
|
256
|
-
multisig(multisigParams: MultisigMetadata, subSigners: AddressWithSigners[]): Address & AddressWithTransactionSigner & {
|
|
257
|
-
account: MultisigAccount;
|
|
258
|
-
};
|
|
259
|
-
/**
|
|
260
|
-
* Tracks and returns an account that represents a logic signature.
|
|
261
|
-
*
|
|
262
|
-
* @example
|
|
263
|
-
* ```typescript
|
|
264
|
-
* const account = accountManager.logicsig(program, [new Uint8Array(3, ...)])
|
|
265
|
-
* ```
|
|
266
|
-
* @param program The bytes that make up the compiled logic signature
|
|
267
|
-
* @param args The (binary) arguments to pass into the logic signature
|
|
268
|
-
* @returns A logic signature account wrapper
|
|
269
|
-
*/
|
|
270
|
-
logicsig(program: Uint8Array, args?: Array<Uint8Array>): Address & AddressWithTransactionSigner & {
|
|
271
|
-
account: LogicSigAccount;
|
|
272
|
-
};
|
|
273
|
-
/**
|
|
274
|
-
* Tracks and returns a new, random Algorand account with secret key loaded.
|
|
275
|
-
*
|
|
276
|
-
* @example
|
|
277
|
-
* ```typescript
|
|
278
|
-
* const account = accountManager.random()
|
|
279
|
-
* ```
|
|
280
|
-
* @returns The account
|
|
281
|
-
*/
|
|
282
|
-
random(): Address & {
|
|
283
|
-
addr: Readonly<Address>;
|
|
284
|
-
signer: TransactionSigner;
|
|
285
|
-
lsigSigner: DelegatedLsigSigner;
|
|
286
|
-
programDataSigner: ProgramDataSigner;
|
|
287
|
-
mxBytesSigner: MxBytesSigner;
|
|
288
|
-
};
|
|
289
|
-
/**
|
|
290
|
-
* Returns an account (with private key loaded) that can act as a dispenser from
|
|
291
|
-
* environment variables, or against default LocalNet if no environment variables present.
|
|
292
|
-
*
|
|
293
|
-
* Note: requires a Node.js environment to execute.
|
|
294
|
-
*
|
|
295
|
-
* If present, it will load the account mnemonic stored in process.env.DISPENSER_MNEMONIC and optionally
|
|
296
|
-
* process.env.DISPENSER_SENDER if it's a rekeyed account.
|
|
297
|
-
*
|
|
298
|
-
* @example
|
|
299
|
-
* ```typescript
|
|
300
|
-
* const account = await accountManager.dispenserFromEnvironment()
|
|
301
|
-
* ```
|
|
302
|
-
*
|
|
303
|
-
* @returns The account
|
|
304
|
-
*/
|
|
305
|
-
dispenserFromEnvironment(): Promise<AddressWithTransactionSigner>;
|
|
306
|
-
/**
|
|
307
|
-
* Returns an Algorand account with private key loaded for the default LocalNet dispenser account (that can be used to fund other accounts).
|
|
308
|
-
*
|
|
309
|
-
* @example
|
|
310
|
-
* ```typescript
|
|
311
|
-
* const account = await accountManager.localNetDispenser()
|
|
312
|
-
* ```
|
|
313
|
-
* @returns The account
|
|
314
|
-
*/
|
|
315
|
-
localNetDispenser(): Promise<Address & AddressWithTransactionSigner & {
|
|
316
|
-
account: AddressWithTransactionSigner;
|
|
317
|
-
}>;
|
|
318
|
-
/**
|
|
319
|
-
* Rekey an account to a new address.
|
|
320
|
-
*
|
|
321
|
-
* **Note:** Please be careful with this function and be sure to read the [official rekey guidance](https://dev.algorand.co/concepts/accounts/rekeying).
|
|
322
|
-
*
|
|
323
|
-
* @param account The account to rekey
|
|
324
|
-
* @param rekeyTo The account address or signing account of the account that will be used to authorise transactions for the rekeyed account going forward.
|
|
325
|
-
* If a signing account is provided that will now be tracked as the signer for `account` in this `AccountManager`
|
|
326
|
-
* @param options Any parameters to control the transaction or execution of the transaction
|
|
327
|
-
*
|
|
328
|
-
* @example Basic example (with string addresses)
|
|
329
|
-
* ```typescript
|
|
330
|
-
* await accountManager.rekeyAccount({account: "ACCOUNTADDRESS", rekeyTo: "NEWADDRESS"})
|
|
331
|
-
* ```
|
|
332
|
-
* @example Basic example (with signer accounts)
|
|
333
|
-
* ```typescript
|
|
334
|
-
* await accountManager.rekeyAccount({account: account1, rekeyTo: newSignerAccount})
|
|
335
|
-
* ```
|
|
336
|
-
* @example Advanced example
|
|
337
|
-
* ```typescript
|
|
338
|
-
* await accountManager.rekeyAccount({
|
|
339
|
-
* account: "ACCOUNTADDRESS",
|
|
340
|
-
* rekeyTo: "NEWADDRESS",
|
|
341
|
-
* lease: 'lease',
|
|
342
|
-
* note: 'note',
|
|
343
|
-
* firstValidRound: 1000n,
|
|
344
|
-
* validityWindow: 10,
|
|
345
|
-
* extraFee: (1000).microAlgo(),
|
|
346
|
-
* staticFee: (1000).microAlgo(),
|
|
347
|
-
* // Max fee doesn't make sense with extraFee AND staticFee
|
|
348
|
-
* // already specified, but here for completeness
|
|
349
|
-
* maxFee: (3000).microAlgo(),
|
|
350
|
-
* maxRoundsToWaitForConfirmation: 5,
|
|
351
|
-
* suppressLog: true,
|
|
352
|
-
* })
|
|
353
|
-
* ```
|
|
354
|
-
* @returns The result of the transaction and the transaction that was sent
|
|
355
|
-
*/
|
|
356
|
-
rekeyAccount(account: string | Address, rekeyTo: string | Address | AddressWithTransactionSigner, options?: Omit<CommonTransactionParams, 'sender'> & SendParams): Promise<SendSingleTransactionResult>;
|
|
357
|
-
private _getEnsureFundedAmount;
|
|
358
|
-
/**
|
|
359
|
-
* Funds a given account using a dispenser account as a funding source such that
|
|
360
|
-
* the given account has a certain amount of Algo free to spend (accounting for
|
|
361
|
-
* Algo locked in minimum balance requirement).
|
|
362
|
-
*
|
|
363
|
-
* https://dev.algorand.co/concepts/smart-contracts/costs-constraints#mbr
|
|
364
|
-
*
|
|
365
|
-
* @param accountToFund The account to fund
|
|
366
|
-
* @param dispenserAccount The account to use as a dispenser funding source
|
|
367
|
-
* @param minSpendingBalance The minimum balance of Algo that the account should have available to spend (i.e. on top of minimum balance requirement)
|
|
368
|
-
* @param options Optional parameters to control the funding increment, transaction or execution of the transaction
|
|
369
|
-
* @example Example using AlgorandClient
|
|
370
|
-
* ```typescript
|
|
371
|
-
* // Basic example
|
|
372
|
-
* await accountManager.ensureFunded("ACCOUNTADDRESS", "DISPENSERADDRESS", algokit.algo(1))
|
|
373
|
-
* // With configuration
|
|
374
|
-
* await accountManager.ensureFunded("ACCOUNTADDRESS", "DISPENSERADDRESS", algokit.algo(1),
|
|
375
|
-
* { minFundingIncrement: algokit.algo(2), fee: (1000).microAlgo(), suppressLog: true }
|
|
376
|
-
* )
|
|
377
|
-
* ```
|
|
378
|
-
* @returns
|
|
379
|
-
* - The result of executing the dispensing transaction and the `amountFunded` if funds were needed.
|
|
380
|
-
* - `undefined` if no funds were needed.
|
|
381
|
-
*/
|
|
382
|
-
ensureFunded(accountToFund: string | Address, dispenserAccount: string | Address, minSpendingBalance: AlgoAmount, options?: {
|
|
383
|
-
minFundingIncrement?: AlgoAmount;
|
|
384
|
-
} & SendParams & Omit<CommonTransactionParams, 'sender'>): Promise<(SendSingleTransactionResult & EnsureFundedResult) | undefined>;
|
|
385
|
-
/**
|
|
386
|
-
* Funds a given account using a dispenser account retrieved from the environment,
|
|
387
|
-
* per the `dispenserFromEnvironment` method, as a funding source such that
|
|
388
|
-
* the given account has a certain amount of Algo free to spend (accounting for
|
|
389
|
-
* Algo locked in minimum balance requirement).
|
|
390
|
-
*
|
|
391
|
-
* **Note:** requires a Node.js environment to execute.
|
|
392
|
-
*
|
|
393
|
-
* The dispenser account is retrieved from the account mnemonic stored in
|
|
394
|
-
* process.env.DISPENSER_MNEMONIC and optionally process.env.DISPENSER_SENDER
|
|
395
|
-
* if it's a rekeyed account, or against default LocalNet if no environment variables present.
|
|
396
|
-
*
|
|
397
|
-
* https://dev.algorand.co/concepts/smart-contracts/costs-constraints#mbr
|
|
398
|
-
*
|
|
399
|
-
* @param accountToFund The account to fund
|
|
400
|
-
* @param minSpendingBalance The minimum balance of Algo that the account should have available to spend (i.e. on top of minimum balance requirement)
|
|
401
|
-
* @param options Optional parameters to control the funding increment, transaction or execution of the transaction
|
|
402
|
-
* @example Example using AlgorandClient
|
|
403
|
-
* ```typescript
|
|
404
|
-
* // Basic example
|
|
405
|
-
* await accountManager.ensureFundedFromEnvironment("ACCOUNTADDRESS", algokit.algo(1))
|
|
406
|
-
* // With configuration
|
|
407
|
-
* await accountManager.ensureFundedFromEnvironment("ACCOUNTADDRESS", algokit.algo(1),
|
|
408
|
-
* { minFundingIncrement: algokit.algo(2), fee: (1000).microAlgo(), suppressLog: true }
|
|
409
|
-
* )
|
|
410
|
-
* ```
|
|
411
|
-
* @returns
|
|
412
|
-
* - The result of executing the dispensing transaction and the `amountFunded` if funds were needed.
|
|
413
|
-
* - `undefined` if no funds were needed.
|
|
414
|
-
*/
|
|
415
|
-
ensureFundedFromEnvironment(accountToFund: string | Address, minSpendingBalance: AlgoAmount, options?: {
|
|
416
|
-
minFundingIncrement?: AlgoAmount;
|
|
417
|
-
} & SendParams & Omit<CommonTransactionParams, 'sender'>): Promise<(SendSingleTransactionResult & EnsureFundedResult) | undefined>;
|
|
418
|
-
/**
|
|
419
|
-
* Funds a given account using the TestNet Dispenser API as a funding source such that
|
|
420
|
-
* the account has a certain amount of Algo free to spend (accounting for Algo locked
|
|
421
|
-
* in minimum balance requirement).
|
|
422
|
-
*
|
|
423
|
-
* https://dev.algorand.co/concepts/smart-contracts/costs-constraints#mbr
|
|
424
|
-
*
|
|
425
|
-
* @param accountToFund The account to fund
|
|
426
|
-
* @param dispenserClient The TestNet dispenser funding client
|
|
427
|
-
* @param minSpendingBalance The minimum balance of Algo that the account should have available to spend (i.e. on top of minimum balance requirement)
|
|
428
|
-
* @param options Optional parameters to control the funding increment, transaction or execution of the transaction
|
|
429
|
-
* @example Example using AlgorandClient
|
|
430
|
-
* ```typescript
|
|
431
|
-
* // Basic example
|
|
432
|
-
* await accountManager.ensureFundedFromTestNetDispenserApi("ACCOUNTADDRESS", algorand.client.getTestNetDispenserFromEnvironment(), algokit.algo(1))
|
|
433
|
-
* // With configuration
|
|
434
|
-
* await accountManager.ensureFundedFromTestNetDispenserApi("ACCOUNTADDRESS", algorand.client.getTestNetDispenserFromEnvironment(), algokit.algo(1),
|
|
435
|
-
* { minFundingIncrement: algokit.algo(2) }
|
|
436
|
-
* )
|
|
437
|
-
* ```
|
|
438
|
-
* @returns
|
|
439
|
-
* - The result of executing the dispensing transaction and the `amountFunded` if funds were needed.
|
|
440
|
-
* - `undefined` if no funds were needed.
|
|
441
|
-
*/
|
|
442
|
-
ensureFundedFromTestNetDispenserApi(accountToFund: string | Address, dispenserClient: TestNetDispenserApiClient, minSpendingBalance: AlgoAmount, options?: {
|
|
443
|
-
minFundingIncrement?: AlgoAmount;
|
|
444
|
-
}): Promise<EnsureFundedResult | undefined>;
|
|
445
|
-
}
|
|
446
15
|
//#endregion
|
|
447
16
|
export { AccountManager, EnsureFundedResult, getAccountTransactionSigner };
|
|
448
17
|
//# sourceMappingURL=account-manager.d.ts.map
|