@algorandfoundation/algokit-utils 7.0.0-beta.9 → 8.0.0-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.
Files changed (231) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +21 -3
  3. package/account/account.d.ts +4 -1
  4. package/account/account.js +10 -7
  5. package/account/account.js.map +1 -1
  6. package/account/account.mjs +11 -8
  7. package/account/account.mjs.map +1 -1
  8. package/account/get-account-config-from-environment.js.map +1 -1
  9. package/account/get-account-config-from-environment.mjs.map +1 -1
  10. package/account/get-account.js.map +1 -1
  11. package/account/get-account.mjs.map +1 -1
  12. package/account/get-dispenser-account.d.ts +1 -1
  13. package/account/get-dispenser-account.js.map +1 -1
  14. package/account/get-dispenser-account.mjs.map +1 -1
  15. package/account/mnemonic-account.js.map +1 -1
  16. package/account/mnemonic-account.mjs.map +1 -1
  17. package/amount.d.ts +1 -0
  18. package/amount.js +3 -2
  19. package/amount.js.map +1 -1
  20. package/amount.mjs +3 -3
  21. package/amount.mjs.map +1 -1
  22. package/app-client.d.ts +4 -4
  23. package/app-client.js +4 -4
  24. package/app-client.js.map +1 -1
  25. package/app-client.mjs +4 -4
  26. package/app-client.mjs.map +1 -1
  27. package/app-deploy.js +25 -15
  28. package/app-deploy.js.map +1 -1
  29. package/app-deploy.mjs +27 -17
  30. package/app-deploy.mjs.map +1 -1
  31. package/app.d.ts +2 -2
  32. package/app.js +9 -6
  33. package/app.js.map +1 -1
  34. package/app.mjs +9 -6
  35. package/app.mjs.map +1 -1
  36. package/asset.js.map +1 -1
  37. package/asset.mjs.map +1 -1
  38. package/debugging/debugging.js.map +1 -1
  39. package/debugging/debugging.mjs.map +1 -1
  40. package/dispenser-client.js.map +1 -1
  41. package/dispenser-client.mjs.map +1 -1
  42. package/index.d.ts +1 -0
  43. package/index.js +7 -1
  44. package/index.js.map +1 -1
  45. package/index.mjs +3 -2
  46. package/index.mjs.map +1 -1
  47. package/indexer-lookup.d.ts +10 -8
  48. package/indexer-lookup.js +14 -10
  49. package/indexer-lookup.js.map +1 -1
  50. package/indexer-lookup.mjs +14 -10
  51. package/indexer-lookup.mjs.map +1 -1
  52. package/localnet/get-kmd-wallet-account.js.map +1 -1
  53. package/localnet/get-kmd-wallet-account.mjs.map +1 -1
  54. package/localnet/get-localnet-dispenser-account.js.map +1 -1
  55. package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
  56. package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
  57. package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
  58. package/localnet/is-localnet.js.map +1 -1
  59. package/localnet/is-localnet.mjs.map +1 -1
  60. package/network-client.d.ts +1 -7
  61. package/network-client.js +2 -9
  62. package/network-client.js.map +1 -1
  63. package/network-client.mjs +2 -9
  64. package/network-client.mjs.map +1 -1
  65. package/package.json +5 -5
  66. package/testing/_asset.d.ts +2 -1
  67. package/testing/account.d.ts +4 -3
  68. package/testing/account.js +8 -2
  69. package/testing/account.js.map +1 -1
  70. package/testing/account.mjs +9 -3
  71. package/testing/account.mjs.map +1 -1
  72. package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
  73. package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
  74. package/testing/fixtures/algorand-fixture.js +5 -6
  75. package/testing/fixtures/algorand-fixture.js.map +1 -1
  76. package/testing/fixtures/algorand-fixture.mjs +5 -6
  77. package/testing/fixtures/algorand-fixture.mjs.map +1 -1
  78. package/testing/indexer.js.map +1 -1
  79. package/testing/indexer.mjs.map +1 -1
  80. package/testing/test-logger.js +7 -1
  81. package/testing/test-logger.js.map +1 -1
  82. package/testing/test-logger.mjs +7 -1
  83. package/testing/test-logger.mjs.map +1 -1
  84. package/testing/transaction-logger.js.map +1 -1
  85. package/testing/transaction-logger.mjs.map +1 -1
  86. package/transaction/legacy-bridge.js +2 -2
  87. package/transaction/legacy-bridge.js.map +1 -1
  88. package/transaction/legacy-bridge.mjs +3 -3
  89. package/transaction/legacy-bridge.mjs.map +1 -1
  90. package/transaction/perform-atomic-transaction-composer-simulate.d.ts +4 -1
  91. package/transaction/perform-atomic-transaction-composer-simulate.js +14 -9
  92. package/transaction/perform-atomic-transaction-composer-simulate.js.map +1 -1
  93. package/transaction/perform-atomic-transaction-composer-simulate.mjs +15 -10
  94. package/transaction/perform-atomic-transaction-composer-simulate.mjs.map +1 -1
  95. package/transaction/transaction.d.ts +13 -22
  96. package/transaction/transaction.js +164 -110
  97. package/transaction/transaction.js.map +1 -1
  98. package/transaction/transaction.mjs +163 -109
  99. package/transaction/transaction.mjs.map +1 -1
  100. package/transfer/transfer-algos.js.map +1 -1
  101. package/transfer/transfer-algos.mjs.map +1 -1
  102. package/transfer/transfer.js +3 -1
  103. package/transfer/transfer.js.map +1 -1
  104. package/transfer/transfer.mjs +3 -1
  105. package/transfer/transfer.mjs.map +1 -1
  106. package/types/account-manager.d.ts +20 -20
  107. package/types/account-manager.js +36 -27
  108. package/types/account-manager.js.map +1 -1
  109. package/types/account-manager.mjs +38 -29
  110. package/types/account-manager.mjs.map +1 -1
  111. package/types/account.d.ts +17 -8
  112. package/types/account.js +2 -2
  113. package/types/account.js.map +1 -1
  114. package/types/account.mjs +3 -3
  115. package/types/account.mjs.map +1 -1
  116. package/types/algo-http-client-with-retry.d.ts +1 -2
  117. package/types/algo-http-client-with-retry.js +33 -3
  118. package/types/algo-http-client-with-retry.js.map +1 -1
  119. package/types/algo-http-client-with-retry.mjs +32 -2
  120. package/types/algo-http-client-with-retry.mjs.map +1 -1
  121. package/types/algorand-client-interface.d.ts +2 -2
  122. package/types/algorand-client-transaction-creator.d.ts +16 -14
  123. package/types/algorand-client-transaction-creator.js +3 -1
  124. package/types/algorand-client-transaction-creator.js.map +1 -1
  125. package/types/algorand-client-transaction-creator.mjs +3 -1
  126. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  127. package/types/algorand-client-transaction-sender.d.ts +109 -105
  128. package/types/algorand-client-transaction-sender.js +6 -2
  129. package/types/algorand-client-transaction-sender.js.map +1 -1
  130. package/types/algorand-client-transaction-sender.mjs +6 -2
  131. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  132. package/types/algorand-client.d.ts +6 -7
  133. package/types/algorand-client.js +3 -6
  134. package/types/algorand-client.js.map +1 -1
  135. package/types/algorand-client.mjs +5 -5
  136. package/types/algorand-client.mjs.map +1 -1
  137. package/types/amount.js.map +1 -1
  138. package/types/amount.mjs.map +1 -1
  139. package/types/app-arc56.d.ts +31 -20
  140. package/types/app-arc56.js.map +1 -1
  141. package/types/app-arc56.mjs.map +1 -1
  142. package/types/app-client.d.ts +298 -286
  143. package/types/app-client.js +148 -41
  144. package/types/app-client.js.map +1 -1
  145. package/types/app-client.mjs +147 -40
  146. package/types/app-client.mjs.map +1 -1
  147. package/types/app-deployer.d.ts +4 -4
  148. package/types/app-deployer.js +23 -24
  149. package/types/app-deployer.js.map +1 -1
  150. package/types/app-deployer.mjs +25 -26
  151. package/types/app-deployer.mjs.map +1 -1
  152. package/types/app-factory.d.ts +130 -130
  153. package/types/app-factory.js +4 -5
  154. package/types/app-factory.js.map +1 -1
  155. package/types/app-factory.mjs +5 -6
  156. package/types/app-factory.mjs.map +1 -1
  157. package/types/app-manager.d.ts +5 -5
  158. package/types/app-manager.js +116 -38
  159. package/types/app-manager.js.map +1 -1
  160. package/types/app-manager.mjs +117 -39
  161. package/types/app-manager.mjs.map +1 -1
  162. package/types/app-spec.js +8 -2
  163. package/types/app-spec.js.map +1 -1
  164. package/types/app-spec.mjs +8 -2
  165. package/types/app-spec.mjs.map +1 -1
  166. package/types/app.d.ts +12 -11
  167. package/types/app.js.map +1 -1
  168. package/types/app.mjs.map +1 -1
  169. package/types/asset-manager.d.ts +9 -9
  170. package/types/asset-manager.js +10 -13
  171. package/types/asset-manager.js.map +1 -1
  172. package/types/asset-manager.mjs +10 -13
  173. package/types/asset-manager.mjs.map +1 -1
  174. package/types/async-event-emitter.d.ts +1 -10
  175. package/types/async-event-emitter.js +0 -5
  176. package/types/async-event-emitter.js.map +1 -1
  177. package/types/async-event-emitter.mjs +1 -6
  178. package/types/async-event-emitter.mjs.map +1 -1
  179. package/types/client-manager.d.ts +2 -9
  180. package/types/client-manager.js +11 -21
  181. package/types/client-manager.js.map +1 -1
  182. package/types/client-manager.mjs +11 -21
  183. package/types/client-manager.mjs.map +1 -1
  184. package/types/composer.d.ts +58 -46
  185. package/types/composer.js +154 -105
  186. package/types/composer.js.map +1 -1
  187. package/types/composer.mjs +156 -105
  188. package/types/composer.mjs.map +1 -1
  189. package/types/config.js.map +1 -1
  190. package/types/config.mjs.map +1 -1
  191. package/types/debugging.d.ts +1 -1
  192. package/types/debugging.js +1 -1
  193. package/types/debugging.js.map +1 -1
  194. package/types/debugging.mjs +1 -1
  195. package/types/debugging.mjs.map +1 -1
  196. package/types/dispenser-client.d.ts +2 -1
  197. package/types/dispenser-client.js +5 -1
  198. package/types/dispenser-client.js.map +1 -1
  199. package/types/dispenser-client.mjs +5 -1
  200. package/types/dispenser-client.mjs.map +1 -1
  201. package/types/indexer.d.ts +74 -755
  202. package/types/indexer.js.map +1 -1
  203. package/types/indexer.mjs.map +1 -1
  204. package/types/kmd-account-manager.d.ts +2 -2
  205. package/types/kmd-account-manager.js +1 -1
  206. package/types/kmd-account-manager.js.map +1 -1
  207. package/types/kmd-account-manager.mjs +2 -2
  208. package/types/kmd-account-manager.mjs.map +1 -1
  209. package/types/lifecycle-events.d.ts +10 -0
  210. package/types/lifecycle-events.js +8 -0
  211. package/types/lifecycle-events.js.map +1 -0
  212. package/types/lifecycle-events.mjs +8 -0
  213. package/types/lifecycle-events.mjs.map +1 -0
  214. package/types/logging.js.map +1 -1
  215. package/types/logging.mjs.map +1 -1
  216. package/types/logic-error.d.ts +2 -3
  217. package/types/logic-error.js +3 -3
  218. package/types/logic-error.js.map +1 -1
  219. package/types/logic-error.mjs +3 -3
  220. package/types/logic-error.mjs.map +1 -1
  221. package/types/network-client.d.ts +1 -1
  222. package/types/network-client.js.map +1 -1
  223. package/types/network-client.mjs.map +1 -1
  224. package/types/testing.d.ts +6 -7
  225. package/util.js.map +1 -1
  226. package/util.mjs.map +1 -1
  227. package/types/urlTokenBaseHTTPClient.d.ts +0 -40
  228. package/types/urlTokenBaseHTTPClient.js +0 -153
  229. package/types/urlTokenBaseHTTPClient.js.map +0 -1
  230. package/types/urlTokenBaseHTTPClient.mjs +0 -151
  231. package/types/urlTokenBaseHTTPClient.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"algorand-client.js","sources":["../../src/types/algorand-client.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { MultisigAccount, SigningAccount, TransactionSignerAccount } from './account'\nimport { AccountManager } from './account-manager'\nimport { AlgorandClientInterface } from './algorand-client-interface'\nimport { AlgorandClientTransactionCreator } from './algorand-client-transaction-creator'\nimport { AlgorandClientTransactionSender } from './algorand-client-transaction-sender'\nimport { AppDeployer } from './app-deployer'\nimport { AppManager } from './app-manager'\nimport { AssetManager } from './asset-manager'\nimport { AlgoSdkClients, ClientManager } from './client-manager'\nimport AlgoKitComposer from './composer'\nimport { AlgoConfig } from './network-client'\nimport Account = algosdk.Account\nimport LogicSigAccount = algosdk.LogicSigAccount\n\n/**\n * A client that brokers easy access to Algorand functionality.\n */\nexport class AlgorandClient implements AlgorandClientInterface {\n private _clientManager: ClientManager\n private _accountManager: AccountManager\n private _appManager: AppManager\n private _appDeployer: AppDeployer\n private _assetManager: AssetManager\n private _transactionSender: AlgorandClientTransactionSender\n private _transactionCreator: AlgorandClientTransactionCreator\n\n private _cachedSuggestedParams?: algosdk.SuggestedParams\n private _cachedSuggestedParamsExpiry?: Date\n private _cachedSuggestedParamsTimeout: number = 3_000 // three seconds\n\n private _defaultValidityWindow: number | undefined = undefined\n\n private constructor(config: AlgoConfig | AlgoSdkClients) {\n this._clientManager = new ClientManager(config, this)\n this._accountManager = new AccountManager(this._clientManager)\n this._appManager = new AppManager(this._clientManager.algod)\n this._assetManager = new AssetManager(this._clientManager.algod, () => this.newGroup())\n this._transactionSender = new AlgorandClientTransactionSender(() => this.newGroup(), this._assetManager, this._appManager)\n this._transactionCreator = new AlgorandClientTransactionCreator(() => this.newGroup())\n this._appDeployer = new AppDeployer(this._appManager, this._transactionSender, this._clientManager.indexerIfPresent)\n }\n\n /**\n * Sets the default validity window for transactions.\n * @param validityWindow The number of rounds between the first and last valid rounds\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setDefaultValidityWindow(validityWindow: number) {\n this._defaultValidityWindow = validityWindow\n return this\n }\n\n /**\n * Sets the default signer to use if no other signer is specified.\n * @param signer The signer to use, either a `TransactionSigner` or a `TransactionSignerAccount`\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setDefaultSigner(signer: algosdk.TransactionSigner | TransactionSignerAccount): AlgorandClient {\n this._accountManager.setDefaultSigner(signer)\n return this\n }\n\n /**\n * Tracks the given account (object that encapsulates an address and a signer) for later signing.\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 = AlgorandClient.mainnet()\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 `AlgorandClient` so method calls can be chained\n */\n public setSignerFromAccount(\n account: TransactionSignerAccount | TransactionSignerAccount | Account | LogicSigAccount | SigningAccount | MultisigAccount,\n ) {\n this._accountManager.setSignerFromAccount(account)\n return this\n }\n\n /**\n * Tracks the given signer against the given sender for later signing.\n * @param sender The sender address to use this signer for\n * @param signer The signer to sign transactions with for the given sender\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setSigner(sender: string, signer: algosdk.TransactionSigner) {\n this._accountManager.setSigner(sender, signer)\n return this\n }\n\n /**\n * Sets a cache value to use for suggested transaction params.\n * @param suggestedParams The suggested params to use\n * @param until A date until which to cache, or if not specified then the timeout is used\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setSuggestedParamsCache(suggestedParams: algosdk.SuggestedParams, until?: Date) {\n this._cachedSuggestedParams = suggestedParams\n this._cachedSuggestedParamsExpiry = until ?? new Date(+new Date() + this._cachedSuggestedParamsTimeout)\n return this\n }\n\n /**\n * Sets the timeout for caching suggested params.\n * @param timeout The timeout in milliseconds\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setSuggestedParamsCacheTimeout(timeout: number) {\n this._cachedSuggestedParamsTimeout = timeout\n return this\n }\n\n /** Get suggested params for a transaction (either cached or from algod if the cache is stale or empty) */\n public async getSuggestedParams(): Promise<algosdk.SuggestedParams> {\n if (this._cachedSuggestedParams && (!this._cachedSuggestedParamsExpiry || this._cachedSuggestedParamsExpiry > new Date())) {\n return {\n ...this._cachedSuggestedParams,\n }\n }\n\n this._cachedSuggestedParams = await this._clientManager.algod.getTransactionParams().do()\n this._cachedSuggestedParamsExpiry = new Date(new Date().getTime() + this._cachedSuggestedParamsTimeout)\n\n return {\n ...this._cachedSuggestedParams,\n }\n }\n\n /** Get clients, including algosdk clients and app clients. */\n public get client() {\n return this._clientManager\n }\n\n /** Get or create accounts that can sign transactions. */\n public get account() {\n return this._accountManager\n }\n\n /** Methods for interacting with assets. */\n public get asset() {\n return this._assetManager\n }\n\n /** Methods for interacting with apps. */\n public get app() {\n return this._appManager\n }\n\n /** Methods for deploying apps and managing app deployment metadata. */\n public get appDeployer() {\n return this._appDeployer\n }\n\n /** Start a new `AlgoKitComposer` transaction group */\n public newGroup() {\n return new AlgoKitComposer({\n algod: this.client.algod,\n getSigner: (addr: string) => this.account.getSigner(addr),\n getSuggestedParams: () => this.getSuggestedParams(),\n defaultValidityWindow: this._defaultValidityWindow,\n appManager: this._appManager,\n })\n }\n\n /**\n * Methods for sending a transaction.\n */\n public get send() {\n return this._transactionSender\n }\n\n /**\n * Methods for creating a transaction.\n */\n public get createTransaction() {\n return this._transactionCreator\n }\n\n // Static methods to create an `AlgorandClient`\n\n /**\n * Returns an `AlgorandClient` pointing at default LocalNet ports and API token.\n * @returns The `AlgorandClient`\n */\n public static defaultLocalNet() {\n return new AlgorandClient({\n algodConfig: ClientManager.getDefaultLocalNetConfig('algod'),\n indexerConfig: ClientManager.getDefaultLocalNetConfig('indexer'),\n kmdConfig: ClientManager.getDefaultLocalNetConfig('kmd'),\n })\n }\n\n /**\n * Returns an `AlgorandClient` pointing at TestNet using AlgoNode.\n * @returns The `AlgorandClient`\n */\n public static testNet() {\n return new AlgorandClient({\n algodConfig: ClientManager.getAlgoNodeConfig('testnet', 'algod'),\n indexerConfig: ClientManager.getAlgoNodeConfig('testnet', 'indexer'),\n kmdConfig: undefined,\n })\n }\n\n /**\n * Returns an `AlgorandClient` pointing at MainNet using AlgoNode.\n * @returns The `AlgorandClient`\n */\n public static mainNet() {\n return new AlgorandClient({\n algodConfig: ClientManager.getAlgoNodeConfig('mainnet', 'algod'),\n indexerConfig: ClientManager.getAlgoNodeConfig('mainnet', 'indexer'),\n kmdConfig: undefined,\n })\n }\n\n /**\n * Returns an `AlgorandClient` pointing to the given client(s).\n * @param clients The clients to use\n * @returns The `AlgorandClient`\n */\n public static fromClients(clients: AlgoSdkClients) {\n return new AlgorandClient(clients)\n }\n\n /**\n * Returns an `AlgorandClient` loading the configuration from environment variables.\n *\n * Retrieve configurations from environment variables when defined or get default LocalNet configuration if they aren't defined.\n *\n * Expects to be called from a Node.js environment.\n *\n * If `process.env.ALGOD_SERVER` is defined it will use that along with optional `process.env.ALGOD_PORT` and `process.env.ALGOD_TOKEN`.\n *\n * If `process.env.INDEXER_SERVER` is defined it will use that along with optional `process.env.INDEXER_PORT` and `process.env.INDEXER_TOKEN`.\n *\n * If either aren't defined it will use the default LocalNet config.\n *\n * It will return a KMD configuration that uses `process.env.KMD_PORT` (or port 4002) if `process.env.ALGOD_SERVER` is defined,\n * otherwise it will use the default LocalNet config unless it detects testnet or mainnet.\n * @returns The `AlgorandClient`\n */\n public static fromEnvironment() {\n return new AlgorandClient(ClientManager.getConfigFromEnvironmentOrLocalNet())\n }\n\n /**\n * Returns an `AlgorandClient` from the given config.\n * @param config The config to use\n * @returns The `AlgorandClient`\n */\n public static fromConfig(config: AlgoConfig) {\n return new AlgorandClient(config)\n }\n}\n\nexport default AlgorandClient\n"],"names":["ClientManager","AccountManager","AppManager","AssetManager","AlgorandClientTransactionSender","AlgorandClientTransactionCreator","AppDeployer","AlgoKitComposer"],"mappings":";;;;;;;;;;;;;AAeA;;AAEG;MACU,cAAc,CAAA;AAezB,IAAA,WAAA,CAAoB,MAAmC,EAAA;AAJ/C,QAAA,IAAA,CAAA,6BAA6B,GAAW,IAAK,CAAA;QAE7C,IAAsB,CAAA,sBAAA,GAAuB,SAAS,CAAA;QAG5D,IAAI,CAAC,cAAc,GAAG,IAAIA,iCAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QACrD,IAAI,CAAC,eAAe,GAAG,IAAIC,mCAAc,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;AAC9D,QAAA,IAAI,CAAC,WAAW,GAAG,IAAIC,2BAAU,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;QAC5D,IAAI,CAAC,aAAa,GAAG,IAAIC,+BAAY,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;QACvF,IAAI,CAAC,kBAAkB,GAAG,IAAIC,qEAA+B,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;AAC1H,QAAA,IAAI,CAAC,mBAAmB,GAAG,IAAIC,uEAAgC,CAAC,MAAM,IAAI,CAAC,QAA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C3B,OAAO,IAAI,cAAc,CAACA,iCAAa,CAAC,kCAAkC,EAAE,CAAC,CAAA;KAC9E;AAED;;;;AAIG;IACI,OAAO,UAAU,CAAC,MAAkB,EAAA;AACzC,QAAA,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAA;KAClC;AACF;;;;;"}
1
+ {"version":3,"file":"algorand-client.js","sources":["../../src/types/algorand-client.ts"],"sourcesContent":["import algosdk, { Address } from 'algosdk'\nimport { MultisigAccount, SigningAccount, TransactionSignerAccount } from './account'\nimport { AccountManager } from './account-manager'\nimport { AlgorandClientInterface } from './algorand-client-interface'\nimport { AlgorandClientTransactionCreator } from './algorand-client-transaction-creator'\nimport { AlgorandClientTransactionSender } from './algorand-client-transaction-sender'\nimport { AppDeployer } from './app-deployer'\nimport { AppManager } from './app-manager'\nimport { AssetManager } from './asset-manager'\nimport { AlgoSdkClients, ClientManager } from './client-manager'\nimport { TransactionComposer } from './composer'\nimport { AlgoConfig } from './network-client'\nimport Account = algosdk.Account\nimport LogicSigAccount = algosdk.LogicSigAccount\n\n/**\n * A client that brokers easy access to Algorand functionality.\n */\nexport class AlgorandClient implements AlgorandClientInterface {\n private _clientManager: ClientManager\n private _accountManager: AccountManager\n private _appManager: AppManager\n private _appDeployer: AppDeployer\n private _assetManager: AssetManager\n private _transactionSender: AlgorandClientTransactionSender\n private _transactionCreator: AlgorandClientTransactionCreator\n\n private _cachedSuggestedParams?: algosdk.SuggestedParams\n private _cachedSuggestedParamsExpiry?: Date\n private _cachedSuggestedParamsTimeout: number = 3_000 // three seconds\n\n private _defaultValidityWindow: bigint | undefined = undefined\n\n private constructor(config: AlgoConfig | AlgoSdkClients) {\n this._clientManager = new ClientManager(config, this)\n this._accountManager = new AccountManager(this._clientManager)\n this._appManager = new AppManager(this._clientManager.algod)\n this._assetManager = new AssetManager(this._clientManager.algod, () => this.newGroup())\n this._transactionSender = new AlgorandClientTransactionSender(() => this.newGroup(), this._assetManager, this._appManager)\n this._transactionCreator = new AlgorandClientTransactionCreator(() => this.newGroup())\n this._appDeployer = new AppDeployer(this._appManager, this._transactionSender, this._clientManager.indexerIfPresent)\n }\n\n /**\n * Sets the default validity window for transactions.\n * @param validityWindow The number of rounds between the first and last valid rounds\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setDefaultValidityWindow(validityWindow: number | bigint) {\n this._defaultValidityWindow = BigInt(validityWindow)\n return this\n }\n\n /**\n * Sets the default signer to use if no other signer is specified.\n * @param signer The signer to use, either a `TransactionSigner` or a `TransactionSignerAccount`\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setDefaultSigner(signer: algosdk.TransactionSigner | TransactionSignerAccount): AlgorandClient {\n this._accountManager.setDefaultSigner(signer)\n return this\n }\n\n /**\n * Tracks the given account (object that encapsulates an address and a signer) for later signing.\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 = AlgorandClient.mainnet()\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 `AlgorandClient` so method calls can be chained\n */\n public setSignerFromAccount(\n account: TransactionSignerAccount | TransactionSignerAccount | Account | LogicSigAccount | SigningAccount | MultisigAccount,\n ) {\n this._accountManager.setSignerFromAccount(account)\n return this\n }\n\n /**\n * Tracks the given signer against the given sender for later signing.\n * @param sender The sender address to use this signer for\n * @param signer The signer to sign transactions with for the given sender\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setSigner(sender: string | Address, signer: algosdk.TransactionSigner) {\n this._accountManager.setSigner(sender, signer)\n return this\n }\n\n /**\n * Sets a cache value to use for suggested transaction params.\n * @param suggestedParams The suggested params to use\n * @param until A date until which to cache, or if not specified then the timeout is used\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setSuggestedParamsCache(suggestedParams: algosdk.SuggestedParams, until?: Date) {\n this._cachedSuggestedParams = suggestedParams\n this._cachedSuggestedParamsExpiry = until ?? new Date(+new Date() + this._cachedSuggestedParamsTimeout)\n return this\n }\n\n /**\n * Sets the timeout for caching suggested params.\n * @param timeout The timeout in milliseconds\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setSuggestedParamsCacheTimeout(timeout: number) {\n this._cachedSuggestedParamsTimeout = timeout\n return this\n }\n\n /** Get suggested params for a transaction (either cached or from algod if the cache is stale or empty) */\n public async getSuggestedParams(): Promise<algosdk.SuggestedParams> {\n if (this._cachedSuggestedParams && (!this._cachedSuggestedParamsExpiry || this._cachedSuggestedParamsExpiry > new Date())) {\n return {\n ...this._cachedSuggestedParams,\n }\n }\n\n this._cachedSuggestedParams = await this._clientManager.algod.getTransactionParams().do()\n this._cachedSuggestedParamsExpiry = new Date(new Date().getTime() + this._cachedSuggestedParamsTimeout)\n\n return {\n ...this._cachedSuggestedParams,\n }\n }\n\n /** Get clients, including algosdk clients and app clients. */\n public get client() {\n return this._clientManager\n }\n\n /** Get or create accounts that can sign transactions. */\n public get account() {\n return this._accountManager\n }\n\n /** Methods for interacting with assets. */\n public get asset() {\n return this._assetManager\n }\n\n /** Methods for interacting with apps. */\n public get app() {\n return this._appManager\n }\n\n /** Methods for deploying apps and managing app deployment metadata. */\n public get appDeployer() {\n return this._appDeployer\n }\n\n /** Start a new `TransactionComposer` transaction group */\n public newGroup() {\n return new TransactionComposer({\n algod: this.client.algod,\n getSigner: (addr: string | Address) => this.account.getSigner(addr),\n getSuggestedParams: () => this.getSuggestedParams(),\n defaultValidityWindow: this._defaultValidityWindow,\n appManager: this._appManager,\n })\n }\n\n /**\n * Methods for sending a transaction.\n */\n public get send() {\n return this._transactionSender\n }\n\n /**\n * Methods for creating a transaction.\n */\n public get createTransaction() {\n return this._transactionCreator\n }\n\n // Static methods to create an `AlgorandClient`\n\n /**\n * Returns an `AlgorandClient` pointing at default LocalNet ports and API token.\n * @returns The `AlgorandClient`\n */\n public static defaultLocalNet() {\n return new AlgorandClient({\n algodConfig: ClientManager.getDefaultLocalNetConfig('algod'),\n indexerConfig: ClientManager.getDefaultLocalNetConfig('indexer'),\n kmdConfig: ClientManager.getDefaultLocalNetConfig('kmd'),\n })\n }\n\n /**\n * Returns an `AlgorandClient` pointing at TestNet using AlgoNode.\n * @returns The `AlgorandClient`\n */\n public static testNet() {\n return new AlgorandClient({\n algodConfig: ClientManager.getAlgoNodeConfig('testnet', 'algod'),\n indexerConfig: ClientManager.getAlgoNodeConfig('testnet', 'indexer'),\n kmdConfig: undefined,\n })\n }\n\n /**\n * Returns an `AlgorandClient` pointing at MainNet using AlgoNode.\n * @returns The `AlgorandClient`\n */\n public static mainNet() {\n return new AlgorandClient({\n algodConfig: ClientManager.getAlgoNodeConfig('mainnet', 'algod'),\n indexerConfig: ClientManager.getAlgoNodeConfig('mainnet', 'indexer'),\n kmdConfig: undefined,\n })\n }\n\n /**\n * Returns an `AlgorandClient` pointing to the given client(s).\n * @param clients The clients to use\n * @returns The `AlgorandClient`\n */\n public static fromClients(clients: AlgoSdkClients) {\n return new AlgorandClient(clients)\n }\n\n /**\n * Returns an `AlgorandClient` loading the configuration from environment variables.\n *\n * Retrieve configurations from environment variables when defined or get default LocalNet configuration if they aren't defined.\n *\n * Expects to be called from a Node.js environment.\n *\n * If `process.env.ALGOD_SERVER` is defined it will use that along with optional `process.env.ALGOD_PORT` and `process.env.ALGOD_TOKEN`.\n *\n * If `process.env.INDEXER_SERVER` is defined it will use that along with optional `process.env.INDEXER_PORT` and `process.env.INDEXER_TOKEN`.\n *\n * If either aren't defined it will use the default LocalNet config.\n *\n * It will return a KMD configuration that uses `process.env.KMD_PORT` (or port 4002) if `process.env.ALGOD_SERVER` is defined,\n * otherwise it will use the default LocalNet config unless it detects testnet or mainnet.\n * @returns The `AlgorandClient`\n */\n public static fromEnvironment() {\n return new AlgorandClient(ClientManager.getConfigFromEnvironmentOrLocalNet())\n }\n\n /**\n * Returns an `AlgorandClient` from the given config.\n * @param config The config to use\n * @returns The `AlgorandClient`\n */\n public static fromConfig(config: AlgoConfig) {\n return new AlgorandClient(config)\n }\n}\n"],"names":["ClientManager","AccountManager","AppManager","AssetManager","AlgorandClientTransactionSender","AlgorandClientTransactionCreator","AppDeployer","TransactionComposer"],"mappings":";;;;;;;;;;;AAeA;;AAEG;MACU,cAAc,CAAA;AAezB,IAAA,WAAA,CAAoB,MAAmC,EAAA;AAJ/C,QAAA,IAAA,CAAA,6BAA6B,GAAW,IAAK,CAAA;QAE7C,IAAsB,CAAA,sBAAA,GAAuB,SAAS;QAG5D,IAAI,CAAC,cAAc,GAAG,IAAIA,iCAAa,CAAC,MAAM,EAAE,IAAI,CAAC;QACrD,IAAI,CAAC,eAAe,GAAG,IAAIC,mCAAc,CAAC,IAAI,CAAC,cAAc,CAAC;AAC9D,QAAA,IAAI,CAAC,WAAW,GAAG,IAAIC,2BAAU,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC;QAC5D,IAAI,CAAC,aAAa,GAAG,IAAIC,+BAAY,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACvF,IAAI,CAAC,kBAAkB,GAAG,IAAIC,qEAA+B,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC;AAC1H,QAAA,IAAI,CAAC,mBAAmB,GAAG,IAAIC,uEAAgC,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACtF,IAAI,CAAC,YAAY,GAAG,IAAIC,6BAAW,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,cAAc,CAA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C,OAAO,CAAC;AAC5D,YAAA,aAAa,EAAEA,iCAAa,CAAC,wBAAwB,CAAC,SAAS,CAAC;AAChE,YAAA,SAAS,EAAEA,iCAAa,CAAC,wBAAwB,CAAC,KAAK,CAAC;AACzD,SAAA,CAAC;;AAGJ;;;AAGG;AACI,IAAA,OAAO,OAAO,GAAA;QACnB,OAAO,IAAI,cAAc,CAAC;YACxB,WAAW,EAAEA,iCAAa,CAAC,iBAAiB,CAAC,SAAS,EAAE,OAAO,CAAC;YAChE,aAAa,EAAEA,iCAAa,CAAC,iBAAiB,CAAC,SAAS,EAAE,SAAS,CAAC;AACpE,YAAA,SAAS,EAAE,SAAS;AACrB,SAAA,CAAC;;AAGJ;;;AAGG;AACI,IAAA,OAAO,OAAO,GAAA;QACnB,OAAO,IAAI,cAAc,CAAC;YACxB,WAAW,EAAEA,iCAAa,CAAC,iBAAiB,CAAC,SAAS,EAAE,OAAO,CAAC;YAChE,aAAa,EAAEA,iCAAa,CAAC,iBAAiB,CAAC,SAAS,EAAE,SAAS,CAAC;AACpE,YAAA,SAAS,EAAE,SAAS;AACrB,SAAA,CAAC;;AAGJ;;;;AAIG;IACI,OAAO,WAAW,CAAC,OAAuB,EAAA;AAC/C,QAAA,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC;;AAGpC;;;;;;;;;;;;;;;;AAgBG;AACI,IAAA,OAAO,eAAe,GAAA;QAC3B,OAAO,IAAI,cAAc,CAACA,iCAAa,CAAC,kCAAkC,EAAE,CAAC;;AAG/E;;;;AAIG;IACI,OAAO,UAAU,CAAC,MAAkB,EAAA;AACzC,QAAA,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC;;AAEpC;;;;"}
@@ -5,7 +5,7 @@ import { AppDeployer } from './app-deployer.mjs';
5
5
  import { AppManager } from './app-manager.mjs';
6
6
  import { AssetManager } from './asset-manager.mjs';
7
7
  import { ClientManager } from './client-manager.mjs';
8
- import AlgoKitComposer from './composer.mjs';
8
+ import { TransactionComposer } from './composer.mjs';
9
9
 
10
10
  /**
11
11
  * A client that brokers easy access to Algorand functionality.
@@ -28,7 +28,7 @@ class AlgorandClient {
28
28
  * @returns The `AlgorandClient` so method calls can be chained
29
29
  */
30
30
  setDefaultValidityWindow(validityWindow) {
31
- this._defaultValidityWindow = validityWindow;
31
+ this._defaultValidityWindow = BigInt(validityWindow);
32
32
  return this;
33
33
  }
34
34
  /**
@@ -122,9 +122,9 @@ class AlgorandClient {
122
122
  get appDeployer() {
123
123
  return this._appDeployer;
124
124
  }
125
- /** Start a new `AlgoKitComposer` transaction group */
125
+ /** Start a new `TransactionComposer` transaction group */
126
126
  newGroup() {
127
- return new AlgoKitComposer({
127
+ return new TransactionComposer({
128
128
  algod: this.client.algod,
129
129
  getSigner: (addr) => this.account.getSigner(addr),
130
130
  getSuggestedParams: () => this.getSuggestedParams(),
@@ -216,5 +216,5 @@ class AlgorandClient {
216
216
  }
217
217
  }
218
218
 
219
- export { AlgorandClient, AlgorandClient as default };
219
+ export { AlgorandClient };
220
220
  //# sourceMappingURL=algorand-client.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"algorand-client.mjs","sources":["../../src/types/algorand-client.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { MultisigAccount, SigningAccount, TransactionSignerAccount } from './account'\nimport { AccountManager } from './account-manager'\nimport { AlgorandClientInterface } from './algorand-client-interface'\nimport { AlgorandClientTransactionCreator } from './algorand-client-transaction-creator'\nimport { AlgorandClientTransactionSender } from './algorand-client-transaction-sender'\nimport { AppDeployer } from './app-deployer'\nimport { AppManager } from './app-manager'\nimport { AssetManager } from './asset-manager'\nimport { AlgoSdkClients, ClientManager } from './client-manager'\nimport AlgoKitComposer from './composer'\nimport { AlgoConfig } from './network-client'\nimport Account = algosdk.Account\nimport LogicSigAccount = algosdk.LogicSigAccount\n\n/**\n * A client that brokers easy access to Algorand functionality.\n */\nexport class AlgorandClient implements AlgorandClientInterface {\n private _clientManager: ClientManager\n private _accountManager: AccountManager\n private _appManager: AppManager\n private _appDeployer: AppDeployer\n private _assetManager: AssetManager\n private _transactionSender: AlgorandClientTransactionSender\n private _transactionCreator: AlgorandClientTransactionCreator\n\n private _cachedSuggestedParams?: algosdk.SuggestedParams\n private _cachedSuggestedParamsExpiry?: Date\n private _cachedSuggestedParamsTimeout: number = 3_000 // three seconds\n\n private _defaultValidityWindow: number | undefined = undefined\n\n private constructor(config: AlgoConfig | AlgoSdkClients) {\n this._clientManager = new ClientManager(config, this)\n this._accountManager = new AccountManager(this._clientManager)\n this._appManager = new AppManager(this._clientManager.algod)\n this._assetManager = new AssetManager(this._clientManager.algod, () => this.newGroup())\n this._transactionSender = new AlgorandClientTransactionSender(() => this.newGroup(), this._assetManager, this._appManager)\n this._transactionCreator = new AlgorandClientTransactionCreator(() => this.newGroup())\n this._appDeployer = new AppDeployer(this._appManager, this._transactionSender, this._clientManager.indexerIfPresent)\n }\n\n /**\n * Sets the default validity window for transactions.\n * @param validityWindow The number of rounds between the first and last valid rounds\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setDefaultValidityWindow(validityWindow: number) {\n this._defaultValidityWindow = validityWindow\n return this\n }\n\n /**\n * Sets the default signer to use if no other signer is specified.\n * @param signer The signer to use, either a `TransactionSigner` or a `TransactionSignerAccount`\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setDefaultSigner(signer: algosdk.TransactionSigner | TransactionSignerAccount): AlgorandClient {\n this._accountManager.setDefaultSigner(signer)\n return this\n }\n\n /**\n * Tracks the given account (object that encapsulates an address and a signer) for later signing.\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 = AlgorandClient.mainnet()\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 `AlgorandClient` so method calls can be chained\n */\n public setSignerFromAccount(\n account: TransactionSignerAccount | TransactionSignerAccount | Account | LogicSigAccount | SigningAccount | MultisigAccount,\n ) {\n this._accountManager.setSignerFromAccount(account)\n return this\n }\n\n /**\n * Tracks the given signer against the given sender for later signing.\n * @param sender The sender address to use this signer for\n * @param signer The signer to sign transactions with for the given sender\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setSigner(sender: string, signer: algosdk.TransactionSigner) {\n this._accountManager.setSigner(sender, signer)\n return this\n }\n\n /**\n * Sets a cache value to use for suggested transaction params.\n * @param suggestedParams The suggested params to use\n * @param until A date until which to cache, or if not specified then the timeout is used\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setSuggestedParamsCache(suggestedParams: algosdk.SuggestedParams, until?: Date) {\n this._cachedSuggestedParams = suggestedParams\n this._cachedSuggestedParamsExpiry = until ?? new Date(+new Date() + this._cachedSuggestedParamsTimeout)\n return this\n }\n\n /**\n * Sets the timeout for caching suggested params.\n * @param timeout The timeout in milliseconds\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setSuggestedParamsCacheTimeout(timeout: number) {\n this._cachedSuggestedParamsTimeout = timeout\n return this\n }\n\n /** Get suggested params for a transaction (either cached or from algod if the cache is stale or empty) */\n public async getSuggestedParams(): Promise<algosdk.SuggestedParams> {\n if (this._cachedSuggestedParams && (!this._cachedSuggestedParamsExpiry || this._cachedSuggestedParamsExpiry > new Date())) {\n return {\n ...this._cachedSuggestedParams,\n }\n }\n\n this._cachedSuggestedParams = await this._clientManager.algod.getTransactionParams().do()\n this._cachedSuggestedParamsExpiry = new Date(new Date().getTime() + this._cachedSuggestedParamsTimeout)\n\n return {\n ...this._cachedSuggestedParams,\n }\n }\n\n /** Get clients, including algosdk clients and app clients. */\n public get client() {\n return this._clientManager\n }\n\n /** Get or create accounts that can sign transactions. */\n public get account() {\n return this._accountManager\n }\n\n /** Methods for interacting with assets. */\n public get asset() {\n return this._assetManager\n }\n\n /** Methods for interacting with apps. */\n public get app() {\n return this._appManager\n }\n\n /** Methods for deploying apps and managing app deployment metadata. */\n public get appDeployer() {\n return this._appDeployer\n }\n\n /** Start a new `AlgoKitComposer` transaction group */\n public newGroup() {\n return new AlgoKitComposer({\n algod: this.client.algod,\n getSigner: (addr: string) => this.account.getSigner(addr),\n getSuggestedParams: () => this.getSuggestedParams(),\n defaultValidityWindow: this._defaultValidityWindow,\n appManager: this._appManager,\n })\n }\n\n /**\n * Methods for sending a transaction.\n */\n public get send() {\n return this._transactionSender\n }\n\n /**\n * Methods for creating a transaction.\n */\n public get createTransaction() {\n return this._transactionCreator\n }\n\n // Static methods to create an `AlgorandClient`\n\n /**\n * Returns an `AlgorandClient` pointing at default LocalNet ports and API token.\n * @returns The `AlgorandClient`\n */\n public static defaultLocalNet() {\n return new AlgorandClient({\n algodConfig: ClientManager.getDefaultLocalNetConfig('algod'),\n indexerConfig: ClientManager.getDefaultLocalNetConfig('indexer'),\n kmdConfig: ClientManager.getDefaultLocalNetConfig('kmd'),\n })\n }\n\n /**\n * Returns an `AlgorandClient` pointing at TestNet using AlgoNode.\n * @returns The `AlgorandClient`\n */\n public static testNet() {\n return new AlgorandClient({\n algodConfig: ClientManager.getAlgoNodeConfig('testnet', 'algod'),\n indexerConfig: ClientManager.getAlgoNodeConfig('testnet', 'indexer'),\n kmdConfig: undefined,\n })\n }\n\n /**\n * Returns an `AlgorandClient` pointing at MainNet using AlgoNode.\n * @returns The `AlgorandClient`\n */\n public static mainNet() {\n return new AlgorandClient({\n algodConfig: ClientManager.getAlgoNodeConfig('mainnet', 'algod'),\n indexerConfig: ClientManager.getAlgoNodeConfig('mainnet', 'indexer'),\n kmdConfig: undefined,\n })\n }\n\n /**\n * Returns an `AlgorandClient` pointing to the given client(s).\n * @param clients The clients to use\n * @returns The `AlgorandClient`\n */\n public static fromClients(clients: AlgoSdkClients) {\n return new AlgorandClient(clients)\n }\n\n /**\n * Returns an `AlgorandClient` loading the configuration from environment variables.\n *\n * Retrieve configurations from environment variables when defined or get default LocalNet configuration if they aren't defined.\n *\n * Expects to be called from a Node.js environment.\n *\n * If `process.env.ALGOD_SERVER` is defined it will use that along with optional `process.env.ALGOD_PORT` and `process.env.ALGOD_TOKEN`.\n *\n * If `process.env.INDEXER_SERVER` is defined it will use that along with optional `process.env.INDEXER_PORT` and `process.env.INDEXER_TOKEN`.\n *\n * If either aren't defined it will use the default LocalNet config.\n *\n * It will return a KMD configuration that uses `process.env.KMD_PORT` (or port 4002) if `process.env.ALGOD_SERVER` is defined,\n * otherwise it will use the default LocalNet config unless it detects testnet or mainnet.\n * @returns The `AlgorandClient`\n */\n public static fromEnvironment() {\n return new AlgorandClient(ClientManager.getConfigFromEnvironmentOrLocalNet())\n }\n\n /**\n * Returns an `AlgorandClient` from the given config.\n * @param config The config to use\n * @returns The `AlgorandClient`\n */\n public static fromConfig(config: AlgoConfig) {\n return new AlgorandClient(config)\n }\n}\n\nexport default AlgorandClient\n"],"names":[],"mappings":";;;;;;;;;AAeA;;AAEG;MACU,cAAc,CAAA;AAezB,IAAA,WAAA,CAAoB,MAAmC,EAAA;AAJ/C,QAAA,IAAA,CAAA,6BAA6B,GAAW,IAAK,CAAA;QAE7C,IAAsB,CAAA,sBAAA,GAAuB,SAAS,CAAA;QAG5D,IAAI,CAAC,cAAc,GAAG,IAAI,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QACrD,IAAI,CAAC,eAAe,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;AAC9D,QAAA,IAAI,CAAC,WAAW,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;QAC5D,IAAI,CAAC,aAAa,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,M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E,SAAS,CAAC;AACpE,YAAA,SAAS,EAAE,SAAS;AACrB,SAAA,CAAC,CAAA;KACH;AAED;;;;AAIG;IACI,OAAO,WAAW,CAAC,OAAuB,EAAA;AAC/C,QAAA,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC,CAAA;KACnC;AAED;;;;;;;;;;;;;;;;AAgBG;AACI,IAAA,OAAO,eAAe,GAAA;QAC3B,OAAO,IAAI,cAAc,CAAC,aAAa,CAAC,kCAAkC,EAAE,CAAC,CAAA;KAC9E;AAED;;;;AAIG;IACI,OAAO,UAAU,CAAC,MAAkB,EAAA;AACzC,QAAA,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAA;KAClC;AACF;;;;"}
1
+ {"version":3,"file":"algorand-client.mjs","sources":["../../src/types/algorand-client.ts"],"sourcesContent":["import algosdk, { Address } from 'algosdk'\nimport { MultisigAccount, SigningAccount, TransactionSignerAccount } from './account'\nimport { AccountManager } from './account-manager'\nimport { AlgorandClientInterface } from './algorand-client-interface'\nimport { AlgorandClientTransactionCreator } from './algorand-client-transaction-creator'\nimport { AlgorandClientTransactionSender } from './algorand-client-transaction-sender'\nimport { AppDeployer } from './app-deployer'\nimport { AppManager } from './app-manager'\nimport { AssetManager } from './asset-manager'\nimport { AlgoSdkClients, ClientManager } from './client-manager'\nimport { TransactionComposer } from './composer'\nimport { AlgoConfig } from './network-client'\nimport Account = algosdk.Account\nimport LogicSigAccount = algosdk.LogicSigAccount\n\n/**\n * A client that brokers easy access to Algorand functionality.\n */\nexport class AlgorandClient implements AlgorandClientInterface {\n private _clientManager: ClientManager\n private _accountManager: AccountManager\n private _appManager: AppManager\n private _appDeployer: AppDeployer\n private _assetManager: AssetManager\n private _transactionSender: AlgorandClientTransactionSender\n private _transactionCreator: AlgorandClientTransactionCreator\n\n private _cachedSuggestedParams?: algosdk.SuggestedParams\n private _cachedSuggestedParamsExpiry?: Date\n private _cachedSuggestedParamsTimeout: number = 3_000 // three seconds\n\n private _defaultValidityWindow: bigint | undefined = undefined\n\n private constructor(config: AlgoConfig | AlgoSdkClients) {\n this._clientManager = new ClientManager(config, this)\n this._accountManager = new AccountManager(this._clientManager)\n this._appManager = new AppManager(this._clientManager.algod)\n this._assetManager = new AssetManager(this._clientManager.algod, () => this.newGroup())\n this._transactionSender = new AlgorandClientTransactionSender(() => this.newGroup(), this._assetManager, this._appManager)\n this._transactionCreator = new AlgorandClientTransactionCreator(() => this.newGroup())\n this._appDeployer = new AppDeployer(this._appManager, this._transactionSender, this._clientManager.indexerIfPresent)\n }\n\n /**\n * Sets the default validity window for transactions.\n * @param validityWindow The number of rounds between the first and last valid rounds\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setDefaultValidityWindow(validityWindow: number | bigint) {\n this._defaultValidityWindow = BigInt(validityWindow)\n return this\n }\n\n /**\n * Sets the default signer to use if no other signer is specified.\n * @param signer The signer to use, either a `TransactionSigner` or a `TransactionSignerAccount`\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setDefaultSigner(signer: algosdk.TransactionSigner | TransactionSignerAccount): AlgorandClient {\n this._accountManager.setDefaultSigner(signer)\n return this\n }\n\n /**\n * Tracks the given account (object that encapsulates an address and a signer) for later signing.\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 = AlgorandClient.mainnet()\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 `AlgorandClient` so method calls can be chained\n */\n public setSignerFromAccount(\n account: TransactionSignerAccount | TransactionSignerAccount | Account | LogicSigAccount | SigningAccount | MultisigAccount,\n ) {\n this._accountManager.setSignerFromAccount(account)\n return this\n }\n\n /**\n * Tracks the given signer against the given sender for later signing.\n * @param sender The sender address to use this signer for\n * @param signer The signer to sign transactions with for the given sender\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setSigner(sender: string | Address, signer: algosdk.TransactionSigner) {\n this._accountManager.setSigner(sender, signer)\n return this\n }\n\n /**\n * Sets a cache value to use for suggested transaction params.\n * @param suggestedParams The suggested params to use\n * @param until A date until which to cache, or if not specified then the timeout is used\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setSuggestedParamsCache(suggestedParams: algosdk.SuggestedParams, until?: Date) {\n this._cachedSuggestedParams = suggestedParams\n this._cachedSuggestedParamsExpiry = until ?? new Date(+new Date() + this._cachedSuggestedParamsTimeout)\n return this\n }\n\n /**\n * Sets the timeout for caching suggested params.\n * @param timeout The timeout in milliseconds\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setSuggestedParamsCacheTimeout(timeout: number) {\n this._cachedSuggestedParamsTimeout = timeout\n return this\n }\n\n /** Get suggested params for a transaction (either cached or from algod if the cache is stale or empty) */\n public async getSuggestedParams(): Promise<algosdk.SuggestedParams> {\n if (this._cachedSuggestedParams && (!this._cachedSuggestedParamsExpiry || this._cachedSuggestedParamsExpiry > new Date())) {\n return {\n ...this._cachedSuggestedParams,\n }\n }\n\n this._cachedSuggestedParams = await this._clientManager.algod.getTransactionParams().do()\n this._cachedSuggestedParamsExpiry = new Date(new Date().getTime() + this._cachedSuggestedParamsTimeout)\n\n return {\n ...this._cachedSuggestedParams,\n }\n }\n\n /** Get clients, including algosdk clients and app clients. */\n public get client() {\n return this._clientManager\n }\n\n /** Get or create accounts that can sign transactions. */\n public get account() {\n return this._accountManager\n }\n\n /** Methods for interacting with assets. */\n public get asset() {\n return this._assetManager\n }\n\n /** Methods for interacting with apps. */\n public get app() {\n return this._appManager\n }\n\n /** Methods for deploying apps and managing app deployment metadata. */\n public get appDeployer() {\n return this._appDeployer\n }\n\n /** Start a new `TransactionComposer` transaction group */\n public newGroup() {\n return new TransactionComposer({\n algod: this.client.algod,\n getSigner: (addr: string | Address) => this.account.getSigner(addr),\n getSuggestedParams: () => this.getSuggestedParams(),\n defaultValidityWindow: this._defaultValidityWindow,\n appManager: this._appManager,\n })\n }\n\n /**\n * Methods for sending a transaction.\n */\n public get send() {\n return this._transactionSender\n }\n\n /**\n * Methods for creating a transaction.\n */\n public get createTransaction() {\n return this._transactionCreator\n }\n\n // Static methods to create an `AlgorandClient`\n\n /**\n * Returns an `AlgorandClient` pointing at default LocalNet ports and API token.\n * @returns The `AlgorandClient`\n */\n public static defaultLocalNet() {\n return new AlgorandClient({\n algodConfig: ClientManager.getDefaultLocalNetConfig('algod'),\n indexerConfig: ClientManager.getDefaultLocalNetConfig('indexer'),\n kmdConfig: ClientManager.getDefaultLocalNetConfig('kmd'),\n })\n }\n\n /**\n * Returns an `AlgorandClient` pointing at TestNet using AlgoNode.\n * @returns The `AlgorandClient`\n */\n public static testNet() {\n return new AlgorandClient({\n algodConfig: ClientManager.getAlgoNodeConfig('testnet', 'algod'),\n indexerConfig: ClientManager.getAlgoNodeConfig('testnet', 'indexer'),\n kmdConfig: undefined,\n })\n }\n\n /**\n * Returns an `AlgorandClient` pointing at MainNet using AlgoNode.\n * @returns The `AlgorandClient`\n */\n public static mainNet() {\n return new AlgorandClient({\n algodConfig: ClientManager.getAlgoNodeConfig('mainnet', 'algod'),\n indexerConfig: ClientManager.getAlgoNodeConfig('mainnet', 'indexer'),\n kmdConfig: undefined,\n })\n }\n\n /**\n * Returns an `AlgorandClient` pointing to the given client(s).\n * @param clients The clients to use\n * @returns The `AlgorandClient`\n */\n public static fromClients(clients: AlgoSdkClients) {\n return new AlgorandClient(clients)\n }\n\n /**\n * Returns an `AlgorandClient` loading the configuration from environment variables.\n *\n * Retrieve configurations from environment variables when defined or get default LocalNet configuration if they aren't defined.\n *\n * Expects to be called from a Node.js environment.\n *\n * If `process.env.ALGOD_SERVER` is defined it will use that along with optional `process.env.ALGOD_PORT` and `process.env.ALGOD_TOKEN`.\n *\n * If `process.env.INDEXER_SERVER` is defined it will use that along with optional `process.env.INDEXER_PORT` and `process.env.INDEXER_TOKEN`.\n *\n * If either aren't defined it will use the default LocalNet config.\n *\n * It will return a KMD configuration that uses `process.env.KMD_PORT` (or port 4002) if `process.env.ALGOD_SERVER` is defined,\n * otherwise it will use the default LocalNet config unless it detects testnet or mainnet.\n * @returns The `AlgorandClient`\n */\n public static fromEnvironment() {\n return new AlgorandClient(ClientManager.getConfigFromEnvironmentOrLocalNet())\n }\n\n /**\n * Returns an `AlgorandClient` from the given config.\n * @param config The config to use\n * @returns The `AlgorandClient`\n */\n public static fromConfig(config: AlgoConfig) {\n return new AlgorandClient(config)\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAeA;;AAEG;MACU,cAAc,CAAA;AAezB,IAAA,WAAA,CAAoB,MAAmC,EAAA;AAJ/C,QAAA,IAAA,CAAA,6BAA6B,GAAW,IAAK,CAAA;QAE7C,IAAsB,CAAA,sBAAA,GAAuB,SAAS;QAG5D,IAAI,CAAC,cAAc,GAAG,IAAI,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC;QACrD,IAAI,CAAC,eAAe,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC;AAC9D,QAAA,IAAI,CAAC,WAAW,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC;QAC5D,IAAI,CAAC,aAAa,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACvF,IAAI,CAAC,kBAAkB,GAAG,IAAI,+BAA+B,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC;AAC1H,QAAA,IAAI,CAAC,mBAAmB,GAAG,IAAI,gCAAgC,CAAC,MAAM,IA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sourcesContent":["import algosdk from 'algosdk'\n\n/** Wrapper class to ensure safe, explicit conversion between µAlgo, Algo and numbers */\nexport class AlgoAmount {\n private amountInMicroAlgo: bigint\n\n /** Return the amount as a number in µAlgo */\n get microAlgos() {\n return this.amountInMicroAlgo\n }\n\n /** Return the amount as a number in µAlgo */\n get microAlgo() {\n return this.amountInMicroAlgo\n }\n\n /** Return the amount as a number in Algo */\n get algos() {\n return algosdk.microalgosToAlgos(Number(this.amountInMicroAlgo))\n }\n\n /** Return the amount as a number in Algo */\n get algo() {\n return algosdk.microalgosToAlgos(Number(this.amountInMicroAlgo))\n }\n\n constructor(\n amount: { algos: number | bigint } | { algo: number | bigint } | { microAlgos: number | bigint } | { microAlgo: number | bigint },\n ) {\n this.amountInMicroAlgo =\n 'microAlgos' in amount\n ? BigInt(amount.microAlgos)\n : 'microAlgo' in amount\n ? BigInt(amount.microAlgo)\n : 'algos' in amount\n ? BigInt(algosdk.algosToMicroalgos(Number(amount.algos)))\n : BigInt(algosdk.algosToMicroalgos(Number(amount.algo)))\n }\n\n toString(): string {\n return `${this.microAlgo.toLocaleString('en-US')} µALGO`\n }\n\n /** valueOf allows you to use `AlgoAmount` in comparison operations such as `<` and `>=` etc.,\n * but it's not recommended to use this to convert to a number, it's much safer to explicitly call\n * the algos or microAlgos properties\n */\n valueOf(): number {\n return Number(this.microAlgo)\n }\n\n /** Create a `AlgoAmount` object representing the given number of Algo */\n static Algos(amount: number | bigint) {\n return new AlgoAmount({ algos: amount })\n }\n\n /** Create a `AlgoAmount` object representing the given number of Algo */\n static Algo(amount: number | bigint) {\n return new AlgoAmount({ algos: amount })\n }\n\n /** Create a `AlgoAmount` object representing the given number of µAlgo */\n static MicroAlgos(amount: number | bigint) {\n return new AlgoAmount({ microAlgos: amount })\n }\n\n /** Create a `AlgoAmount` object representing the given number of µAlgo */\n static MicroAlgo(amount: number | bigint) {\n return new AlgoAmount({ microAlgos: amount })\n }\n}\n"],"names":[],"mappings":";;;;AAEA;MACa,U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,MAAuB,EAAA;QACjC,OAAO,IAAI,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;KACzC;;IAGD,OAAO,UAAU,CAAC,MAAuB,EAAA;QACvC,OAAO,IAAI,UAAU,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAA;KAC9C;;IAGD,OAAO,SAAS,CAAC,MAAuB,EAAA;QACtC,OAAO,IAAI,UAAU,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAA;KAC9C;AACF;;;;"}
1
+ {"version":3,"file":"amount.js","sources":["../../src/types/amount.ts"],"sourcesContent":["import algosdk from 'algosdk'\n\n/** Wrapper class to ensure safe, explicit conversion between µAlgo, Algo and numbers */\nexport class AlgoAmount {\n private amountInMicroAlgo: bigint\n\n /** Return the amount as a number in µAlgo */\n get microAlgos() {\n return this.amountInMicroAlgo\n }\n\n /** Return the amount as a number in µAlgo */\n get microAlgo() {\n return this.amountInMicroAlgo\n }\n\n /** Return the amount as a number in Algo */\n get algos() {\n return algosdk.microalgosToAlgos(Number(this.amountInMicroAlgo))\n }\n\n /** Return the amount as a number in Algo */\n get algo() {\n return algosdk.microalgosToAlgos(Number(this.amountInMicroAlgo))\n }\n\n constructor(\n amount: { algos: number | bigint } | { algo: number | bigint } | { microAlgos: number | bigint } | { microAlgo: number | bigint },\n ) {\n this.amountInMicroAlgo =\n 'microAlgos' in amount\n ? BigInt(amount.microAlgos)\n : 'microAlgo' in amount\n ? BigInt(amount.microAlgo)\n : 'algos' in amount\n ? BigInt(algosdk.algosToMicroalgos(Number(amount.algos)))\n : BigInt(algosdk.algosToMicroalgos(Number(amount.algo)))\n }\n\n toString(): string {\n return `${this.microAlgo.toLocaleString('en-US')} µALGO`\n }\n\n /** valueOf allows you to use `AlgoAmount` in comparison operations such as `<` and `>=` etc.,\n * but it's not recommended to use this to convert to a number, it's much safer to explicitly call\n * the algos or microAlgos properties\n */\n valueOf(): number {\n return Number(this.microAlgo)\n }\n\n /** Create a `AlgoAmount` object representing the given number of Algo */\n static Algos(amount: number | bigint) {\n return new AlgoAmount({ algos: amount })\n }\n\n /** Create a `AlgoAmount` object representing the given number of Algo */\n static Algo(amount: number | bigint) {\n return new AlgoAmount({ algos: amount })\n }\n\n /** Create a `AlgoAmount` object representing the given number of µAlgo */\n static MicroAlgos(amount: number | bigint) {\n return new AlgoAmount({ microAlgos: amount })\n }\n\n /** Create a `AlgoAmount` object representing the given number of µAlgo */\n static MicroAlgo(amount: number | bigint) {\n return new AlgoAmount({ microAlgos: amount })\n }\n}\n"],"names":[],"mappings":";;;;AAEA;MACa,UAAU,CAAA;;AAIrB,IAAA,IAAI,UAAU,GAAA;QACZ,OAAO,IAAI,CAAC,iBAAiB;;;AAI/B,IAAA,IAAI,SAAS,GAAA;QACX,OAAO,IAAI,CAAC,iBAAiB;;;AAI/B,IAAA,IAAI,KAAK,GAAA;QACP,OAAO,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;;;AAIlE,IAAA,IAAI,IAAI,GAAA;QACN,OAAO,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;;AAGlE,IAAA,WAAA,CACE,MAAiI,EAAA;AAEjI,QAAA,IAAI,CAAC,iBAAiB;AACpB,YAAA,YAAY,IAAI;AACd,kBAAE,MAAM,CAAC,MAAM,CAAC,UAAU;kBACxB,WAAW,IAAI;AACf,sBAAE,MAAM,CAAC,MAAM,CAAC,SAAS;sBACvB,OAAO,IAAI;AACX,0BAAE,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACxD,0BAAE,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;;IAGlE,QAAQ,GAAA;QACN,OAAO,CAAA,EAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA,MAAA,CAAQ;;AAG1D;;;AAGG;IACH,OAAO,GAAA;AACL,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;;;IAI/B,OAAO,KAAK,CAAC,MAAuB,EAAA;QAClC,OAAO,IAAI,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;;;IAI1C,OAAO,IAAI,CAAC,MAAuB,EAAA;QACjC,OAAO,IAAI,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;;;IAI1C,OAAO,UAAU,CAAC,MAAuB,EAAA;QACvC,OAAO,IAAI,UAAU,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;;;IAI/C,OAAO,SAAS,CAAC,MAAuB,EAAA;QACtC,OAAO,IAAI,UAAU,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;;AAEhD;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"amount.mjs","sources":["../../src/types/amount.ts"],"sourcesContent":["import algosdk from 'algosdk'\n\n/** Wrapper class to ensure safe, explicit conversion between µAlgo, Algo and numbers */\nexport class AlgoAmount {\n private amountInMicroAlgo: bigint\n\n /** Return the amount as a number in µAlgo */\n get microAlgos() {\n return this.amountInMicroAlgo\n }\n\n /** Return the amount as a number in µAlgo */\n get microAlgo() {\n return this.amountInMicroAlgo\n }\n\n /** Return the amount as a number in Algo */\n get algos() {\n return algosdk.microalgosToAlgos(Number(this.amountInMicroAlgo))\n }\n\n /** Return the amount as a number in Algo */\n get algo() {\n return algosdk.microalgosToAlgos(Number(this.amountInMicroAlgo))\n }\n\n constructor(\n amount: { algos: number | bigint } | { algo: number | bigint } | { microAlgos: number | bigint } | { microAlgo: number | bigint },\n ) {\n this.amountInMicroAlgo =\n 'microAlgos' in amount\n ? BigInt(amount.microAlgos)\n : 'microAlgo' in amount\n ? BigInt(amount.microAlgo)\n : 'algos' in amount\n ? BigInt(algosdk.algosToMicroalgos(Number(amount.algos)))\n : BigInt(algosdk.algosToMicroalgos(Number(amount.algo)))\n }\n\n toString(): string {\n return `${this.microAlgo.toLocaleString('en-US')} µALGO`\n }\n\n /** valueOf allows you to use `AlgoAmount` in comparison operations such as `<` and `>=` etc.,\n * but it's not recommended to use this to convert to a number, it's much safer to explicitly call\n * the algos or microAlgos properties\n */\n valueOf(): number {\n return Number(this.microAlgo)\n }\n\n /** Create a `AlgoAmount` object representing the given number of Algo */\n static Algos(amount: number | bigint) {\n return new AlgoAmount({ algos: amount })\n }\n\n /** Create a `AlgoAmount` object representing the given number of Algo */\n static Algo(amount: number | bigint) {\n return new AlgoAmount({ algos: amount })\n }\n\n /** Create a `AlgoAmount` object representing the given number of µAlgo */\n static MicroAlgos(amount: number | bigint) {\n return new AlgoAmount({ microAlgos: amount })\n }\n\n /** Create a `AlgoAmount` object representing the given number of µAlgo */\n static MicroAlgo(amount: number | bigint) {\n return new AlgoAmount({ microAlgos: amount })\n }\n}\n"],"names":[],"mappings":";;AAEA;MACa,UAAU,CAAA;;AAIrB,IAAA,IAAI,UAAU,GAAA;QACZ,OAAO,IAAI,CAAC,iBAAiB,CAAA;KAC9B;;AAGD,IAAA,IAAI,SAAS,GAAA;QACX,OAAO,IAAI,CAAC,iBAAiB,CAAA;KAC9B;;AAGD,IAAA,IAAI,KAAK,GAAA;QACP,OAAO,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAA;KACjE;;AAGD,IAAA,IAAI,IAAI,GAAA;QACN,OAAO,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAA;KACjE;AAED,IAAA,WAAA,CACE,MAAiI,EAAA;AAEjI,QAAA,IAAI,CAAC,iBAAiB;AACpB,YAAA,YAAY,IAAI,MAAM;AACpB,kBAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;kBACzB,WAAW,IAAI,MAAM;AACrB,sBAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;sBACxB,OAAO,IAAI,MAAM;AACjB,0BAAE,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACzD,0BAAE,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KACjE;IAED,QAAQ,GAAA;QACN,OAAO,CAAA,EAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA,MAAA,CAAQ,CAAA;KACzD;AAED;;;AAGG;IACH,OAAO,GAAA;AACL,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;KAC9B;;IAGD,OAAO,KAAK,CAAC,MAAuB,EAAA;QAClC,OAAO,IAAI,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;KACzC;;IAGD,OAAO,IAAI,CAAC,MAAuB,EAAA;QACjC,OAAO,IAAI,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;KACzC;;IAGD,OAAO,UAAU,CAAC,MAAuB,EAAA;QACvC,OAAO,IAAI,UAAU,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAA;KAC9C;;IAGD,OAAO,SAAS,CAAC,MAAuB,EAAA;QACtC,OAAO,IAAI,UAAU,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAA;KAC9C;AACF;;;;"}
1
+ {"version":3,"file":"amount.mjs","sources":["../../src/types/amount.ts"],"sourcesContent":["import algosdk from 'algosdk'\n\n/** Wrapper class to ensure safe, explicit conversion between µAlgo, Algo and numbers */\nexport class AlgoAmount {\n private amountInMicroAlgo: bigint\n\n /** Return the amount as a number in µAlgo */\n get microAlgos() {\n return this.amountInMicroAlgo\n }\n\n /** Return the amount as a number in µAlgo */\n get microAlgo() {\n return this.amountInMicroAlgo\n }\n\n /** Return the amount as a number in Algo */\n get algos() {\n return algosdk.microalgosToAlgos(Number(this.amountInMicroAlgo))\n }\n\n /** Return the amount as a number in Algo */\n get algo() {\n return algosdk.microalgosToAlgos(Number(this.amountInMicroAlgo))\n }\n\n constructor(\n amount: { algos: number | bigint } | { algo: number | bigint } | { microAlgos: number | bigint } | { microAlgo: number | bigint },\n ) {\n this.amountInMicroAlgo =\n 'microAlgos' in amount\n ? BigInt(amount.microAlgos)\n : 'microAlgo' in amount\n ? BigInt(amount.microAlgo)\n : 'algos' in amount\n ? BigInt(algosdk.algosToMicroalgos(Number(amount.algos)))\n : BigInt(algosdk.algosToMicroalgos(Number(amount.algo)))\n }\n\n toString(): string {\n return `${this.microAlgo.toLocaleString('en-US')} µALGO`\n }\n\n /** valueOf allows you to use `AlgoAmount` in comparison operations such as `<` and `>=` etc.,\n * but it's not recommended to use this to convert to a number, it's much safer to explicitly call\n * the algos or microAlgos properties\n */\n valueOf(): number {\n return Number(this.microAlgo)\n }\n\n /** Create a `AlgoAmount` object representing the given number of Algo */\n static Algos(amount: number | bigint) {\n return new AlgoAmount({ algos: amount })\n }\n\n /** Create a `AlgoAmount` object representing the given number of Algo */\n static Algo(amount: number | bigint) {\n return new AlgoAmount({ algos: amount })\n }\n\n /** Create a `AlgoAmount` object representing the given number of µAlgo */\n static MicroAlgos(amount: number | bigint) {\n return new AlgoAmount({ microAlgos: amount })\n }\n\n /** Create a `AlgoAmount` object representing the given number of µAlgo */\n static MicroAlgo(amount: number | bigint) {\n return new AlgoAmount({ microAlgos: amount })\n }\n}\n"],"names":[],"mappings":";;AAEA;MACa,UAAU,CAAA;;AAIrB,IAAA,IAAI,UAAU,GAAA;QACZ,OAAO,IAAI,CAAC,iBAAiB;;;AAI/B,IAAA,IAAI,SAAS,GAAA;QACX,OAAO,IAAI,CAAC,iBAAiB;;;AAI/B,IAAA,IAAI,KAAK,GAAA;QACP,OAAO,OAAO,CAAC,iBAAiB,CAAC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@ export declare function getArc56ReturnValue<TReturn extends Uint8Array | algosdk
82
82
  /****************/
83
83
  /** Describes the entire contract. This interface is an extension of the interface described in ARC-4 */
84
84
  export interface Arc56Contract {
85
- /** The ARCs used and/or supported by this contract. All contracts implicity support ARC4 and ARC56 */
85
+ /** The ARCs used and/or supported by this contract. All contracts implicitly support ARC4 and ARC56 */
86
86
  arcs: number[];
87
87
  /** A user-friendly name for the contract */
88
88
  name: string;
@@ -93,7 +93,7 @@ export interface Arc56Contract {
93
93
  * The key is the base64 genesis hash of the network, and the value contains
94
94
  * information about the deployed contract in the network indicated by the
95
95
  * key. A key containing the human-readable name of the network MAY be
96
- * included, but the corresponding genesis hash key MUST also be define
96
+ * included, but the corresponding genesis hash key MUST also be defined
97
97
  */
98
98
  networks?: {
99
99
  [network: string]: {
@@ -101,7 +101,7 @@ export interface Arc56Contract {
101
101
  appID: number;
102
102
  };
103
103
  };
104
- /** Named structs use by the application. Each struct field appears in the same order as ABI encoding. */
104
+ /** Named structs used by the application. Each struct field appears in the same order as ABI encoding. */
105
105
  structs: {
106
106
  [structName: StructName]: StructField[];
107
107
  };
@@ -154,9 +154,9 @@ export interface Arc56Contract {
154
154
  /** Information about the TEAL programs */
155
155
  sourceInfo?: {
156
156
  /** Approval program information */
157
- approval: SourceInfo[];
157
+ approval: ProgramSourceInfo;
158
158
  /** Clear program information */
159
- clear: SourceInfo[];
159
+ clear: ProgramSourceInfo;
160
160
  };
161
161
  /** The pre-compiled TEAL that may contain template variables. MUST be omitted if included as part of ARC23 */
162
162
  source?: {
@@ -186,12 +186,12 @@ export interface Arc56Contract {
186
186
  };
187
187
  /** ARC-28 events that MAY be emitted by this contract */
188
188
  events?: Array<Event>;
189
- /** A mapping of template variable names as they appear in the teal (not including TMPL_ prefix) to their respecive types and values (if applicable) */
189
+ /** A mapping of template variable names as they appear in the TEAL (not including TMPL_ prefix) to their respective types and values (if applicable) */
190
190
  templateVariables?: {
191
191
  [name: string]: {
192
192
  /** The type of the template variable */
193
193
  type: ABIType | AVMType | StructName;
194
- /** If given, the the base64 encoded value used for the given app/program */
194
+ /** If given, the base64 encoded value used for the given app/program */
195
195
  value?: string;
196
196
  };
197
197
  };
@@ -221,17 +221,18 @@ export interface Method {
221
221
  desc?: string;
222
222
  /** The default value that clients should use. */
223
223
  defaultValue?: {
224
- /** Base64 encoded bytes or uint64 */
225
- data: string | number;
224
+ /** Base64 encoded bytes, base64 ARC4 encoded uint64, or UTF-8 method selector */
225
+ data: string;
226
226
  /** How the data is encoded. This is the encoding for the data provided here, not the arg type */
227
- type: ABIType | AVMType;
227
+ type?: ABIType | AVMType;
228
228
  /** Where the default value is coming from
229
229
  * - box: The data key signifies the box key to read the value from
230
230
  * - global: The data key signifies the global state key to read the value from
231
231
  * - local: The data key signifies the local state key to read the value from (for the sender)
232
232
  * - literal: the value is a literal and should be passed directly as the argument
233
+ * - method: The utf8 signature of the method in this contract to call to get the default value. If the method has arguments, they all must have default values. The method **MUST** be readonly so simulate can be used to get the default value
233
234
  */
234
- source: 'box' | 'global' | 'local' | 'literal';
235
+ source: 'box' | 'global' | 'local' | 'literal' | 'method';
235
236
  };
236
237
  }>;
237
238
  /** Information about the method's return value */
@@ -285,7 +286,7 @@ export interface Event {
285
286
  desc?: string;
286
287
  /** The arguments of the event, in order */
287
288
  args: Array<{
288
- /** The type of the argument. The `struct` field should also be checked to determine if this return value is a struct. */
289
+ /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */
289
290
  type: ABIType;
290
291
  /** Optional, user-friendly name for the argument */
291
292
  name?: string;
@@ -336,13 +337,23 @@ export interface StorageMap {
336
337
  /** The base64-encoded prefix of the map keys*/
337
338
  prefix?: string;
338
339
  }
339
- export interface SourceInfo {
340
- /** The line of pre-compiled TEAL */
341
- teal?: number;
342
- /** The program counter offset(s) that correspond to this line of TEAL */
343
- pc?: Array<number>;
344
- /** A human-readable string that describes the error when the program fails at this given line of TEAL */
340
+ interface SourceInfo {
341
+ /** The program counter value(s). Could be offset if pcOffsetMethod is not "none" */
342
+ pc: Array<number>;
343
+ /** A human-readable string that describes the error when the program fails at the given PC */
345
344
  errorMessage?: string;
346
- /** The line of the dissasembled TEAL this line of pre-compiled TEAL corresponds to */
347
- disassembledTeal?: number;
345
+ /** The TEAL line number that corresponds to the given PC. RECOMMENDED to be used for development purposes, but not required for clients */
346
+ teal?: number;
347
+ /** The original source file and line number that corresponds to the given PC. RECOMMENDED to be used for development purposes, but not required for clients */
348
+ source?: string;
349
+ }
350
+ export interface ProgramSourceInfo {
351
+ /** The source information for the program */
352
+ sourceInfo: SourceInfo[];
353
+ /** How the program counter offset is calculated
354
+ * - none: The pc values in sourceInfo are not offset
355
+ * - cblocks: The pc values in sourceInfo are offset by the PC of the first op following the last cblock at the top of the program
356
+ */
357
+ pcOffsetMethod: 'none' | 'cblocks';
348
358
  }
359
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"app-arc56.js","sources":["../../src/types/app-arc56.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { ABIReturn } from './app'\nimport { Expand } from './expand'\n\n/** Type to describe an argument within an `Arc56Method`. */\nexport type Arc56MethodArg = Expand<\n Omit<Method['args'][number], 'type'> & {\n type: algosdk.ABIArgumentType\n }\n>\n\n/** Type to describe a return type within an `Arc56Method`. */\nexport type Arc56MethodReturnType = Expand<\n Omit<Method['returns'], 'type'> & {\n type: algosdk.ABIReturnType\n }\n>\n\n/**\n * Wrapper around `algosdk.ABIMethod` that represents an ARC-56 ABI method.\n */\nexport class Arc56Method extends algosdk.ABIMethod {\n override readonly args: Array<Arc56MethodArg>\n override readonly returns: Arc56MethodReturnType\n\n constructor(public method: Method) {\n super(method)\n this.args = method.args.map((arg) => ({\n ...arg,\n type: algosdk.abiTypeIsTransaction(arg.type) || algosdk.abiTypeIsReference(arg.type) ? arg.type : algosdk.ABIType.from(arg.type),\n }))\n this.returns = {\n ...this.method.returns,\n type: this.method.returns.type === 'void' ? 'void' : algosdk.ABIType.from(this.method.returns.type),\n }\n }\n\n override toJSON(): Method {\n return this.method\n }\n}\n\n/**\n * Returns the `ABITupleType` for the given ARC-56 struct definition\n * @param struct The ARC-56 struct definition\n * @returns The `ABITupleType`\n */\nexport function getABITupleTypeFromABIStructDefinition(\n struct: StructField[],\n structs: Record<string, StructField[]>,\n): algosdk.ABITupleType {\n return new algosdk.ABITupleType(\n struct.map((v) =>\n typeof v.type === 'string'\n ? structs[v.type]\n ? getABITupleTypeFromABIStructDefinition(structs[v.type], structs)\n : algosdk.ABIType.from(v.type)\n : getABITupleTypeFromABIStructDefinition(v.type, structs),\n ),\n )\n}\n\n/**\n * Converts a decoded ABI tuple as a struct.\n * @param decodedABITuple The decoded ABI tuple value\n * @param structFields The struct fields from an ARC-56 app spec\n * @returns The struct as a Record<string, any>\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getABIStructFromABITuple<TReturn extends ABIStruct = Record<string, any>>(\n decodedABITuple: algosdk.ABIValue[],\n structFields: StructField[],\n structs: Record<string, StructField[]>,\n): TReturn {\n return Object.fromEntries(\n structFields.map(({ name: key, type }, i) => {\n const abiValue = decodedABITuple[i]\n return [\n key,\n (typeof type === 'string' && !structs[type]) || !Array.isArray(abiValue)\n ? decodedABITuple[i]\n : getABIStructFromABITuple(abiValue, typeof type === 'string' ? structs[type] : type, structs),\n ]\n }),\n ) as TReturn\n}\n\n/**\n * Converts an ARC-56 struct as an ABI tuple.\n * @param struct The struct to convert\n * @param structFields The struct fields from an ARC-56 app spec\n * @returns The struct as a decoded ABI tuple\n */\nexport function getABITupleFromABIStruct(\n struct: ABIStruct,\n structFields: StructField[],\n structs: Record<string, StructField[]>,\n): algosdk.ABIValue[] {\n return structFields.map(({ name: key, type }) => {\n const value = struct[key]\n return typeof type === 'string' && !structs[type]\n ? (value as algosdk.ABIValue)\n : getABITupleFromABIStruct(value as ABIStruct, typeof type === 'string' ? structs[type] : type, structs)\n })\n}\n\n/** Decoded ARC-56 struct as a struct rather than a tuple. */\nexport type ABIStruct = {\n [key: string]: ABIStruct | algosdk.ABIValue\n}\n\n/**\n * Returns the decoded ABI value (or struct for a struct type)\n * for the given raw Algorand value given an ARC-56 type and defined ARC-56 structs.\n * @param value The raw Algorand value (bytes or uint64)\n * @param type The ARC-56 type - either an ABI Type string or a struct name\n * @param structs The defined ARC-56 structs\n * @returns The decoded ABI value or struct\n */\nexport function getABIDecodedValue(\n value: Uint8Array | number | bigint,\n type: string,\n structs: Record<string, StructField[]>,\n): algosdk.ABIValue | ABIStruct {\n if (type === 'AVMBytes' || typeof value !== 'object') return value\n if (type === 'AVMString') return Buffer.from(value).toString('utf-8')\n if (type === 'AVMUint64') return algosdk.ABIType.from('uint64').decode(value)\n if (structs[type]) {\n const tupleValue = getABITupleTypeFromABIStructDefinition(structs[type], structs).decode(value)\n return getABIStructFromABITuple(tupleValue, structs[type], structs)\n }\n return algosdk.ABIType.from(type).decode(value)\n}\n\n/**\n * Returns the ABI-encoded value for the given value.\n * @param value The value to encode either already in encoded binary form (`Uint8Array`), a decoded ABI value or an ARC-56 struct\n * @param type The ARC-56 type - either an ABI Type string or a struct name\n * @param structs The defined ARC-56 structs\n * @returns The binary ABI-encoded value\n */\nexport function getABIEncodedValue(\n value: Uint8Array | algosdk.ABIValue | ABIStruct,\n type: string,\n structs: Record<string, StructField[]>,\n): Uint8Array {\n if (typeof value === 'object' && value instanceof Uint8Array) return value\n if (type === 'AVMUint64') return algosdk.ABIType.from('uint64').encode(value as bigint | number)\n if (type === 'AVMBytes' || type === 'AVMString') {\n if (typeof value === 'string') return Buffer.from(value, 'utf-8')\n if (typeof value !== 'object' || !(value instanceof Uint8Array)) throw new Error(`Expected bytes value for ${type}, but got ${value}`)\n return value\n }\n if (structs[type]) {\n const tupleType = getABITupleTypeFromABIStructDefinition(structs[type], structs)\n if (Array.isArray(value)) {\n tupleType.encode(value as algosdk.ABIValue[])\n } else {\n return tupleType.encode(getABITupleFromABIStruct(value as ABIStruct, structs[type], structs))\n }\n }\n return algosdk.ABIType.from(type).encode(value as algosdk.ABIValue)\n}\n\n/**\n * Returns the ARC-56 ABI method object for a given method name or signature and ARC-56 app spec.\n * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.\n * e.g. `my_method` or `my_method(unit64,string)bytes`\n * @param appSpec The app spec for the app\n * @returns The `Arc56Method`\n */\nexport function getArc56Method(methodNameOrSignature: string, appSpec: Arc56Contract): Arc56Method {\n let method: Method\n if (!methodNameOrSignature.includes('(')) {\n const methods = appSpec.methods.filter((m) => m.name === methodNameOrSignature)\n if (methods.length === 0) throw new Error(`Unable to find method ${methodNameOrSignature} in ${appSpec.name} app.`)\n if (methods.length > 1) {\n throw new Error(\n `Received a call to method ${methodNameOrSignature} in contract ${\n appSpec.name\n }, but this resolved to multiple methods; please pass in an ABI signature instead: ${appSpec.methods\n .map((m) => new algosdk.ABIMethod(m).getSignature())\n .join(', ')}`,\n )\n }\n method = methods[0]\n } else {\n const m = appSpec.methods.find((m) => new algosdk.ABIMethod(m).getSignature() === methodNameOrSignature)\n if (!m) throw new Error(`Unable to find method ${methodNameOrSignature} in ${appSpec.name} app.`)\n method = m\n }\n return new Arc56Method(method)\n}\n\n/**\n * Checks for decode errors on the AppCallTransactionResult and maps the return value to the specified generic type\n *\n * @param returnValue The smart contract response\n * @param method The method that was called\n * @param structs The struct fields from the app spec\n * @returns The smart contract response with an updated return value\n */\nexport function getArc56ReturnValue<TReturn extends Uint8Array | algosdk.ABIValue | ABIStruct | undefined>(\n returnValue: ABIReturn | undefined,\n method: Method | Arc56Method,\n structs: Record<string, StructField[]>,\n): TReturn {\n const m = 'method' in method ? method.method : method\n const type = m.returns.struct ?? m.returns.type\n if (returnValue?.decodeError) {\n throw returnValue.decodeError\n }\n if (type === undefined || type === 'void' || returnValue?.returnValue === undefined) return undefined as TReturn\n\n if (type === 'AVMBytes') return returnValue.rawReturnValue as TReturn\n if (type === 'AVMString') return Buffer.from(returnValue.rawReturnValue).toString('utf-8') as TReturn\n if (type === 'AVMUint64') return algosdk.ABIType.from('uint64').decode(returnValue.rawReturnValue) as TReturn\n\n if (structs[type]) {\n return getABIStructFromABITuple(returnValue.returnValue as algosdk.ABIValue[], structs[type], structs) as TReturn\n }\n\n return returnValue.returnValue as TReturn\n}\n\n/****************/\n/** ARC-56 spec */\n/****************/\n\n/** Describes the entire contract. This interface is an extension of the interface described in ARC-4 */\nexport interface Arc56Contract {\n /** The ARCs used and/or supported by this contract. All contracts implicity support ARC4 and ARC56 */\n arcs: number[]\n /** A user-friendly name for the contract */\n name: string\n /** Optional, user-friendly description for the interface */\n desc?: string\n /**\n * Optional object listing the contract instances across different networks.\n * The key is the base64 genesis hash of the network, and the value contains\n * information about the deployed contract in the network indicated by the\n * key. A key containing the human-readable name of the network MAY be\n * included, but the corresponding genesis hash key MUST also be define\n */\n networks?: {\n [network: string]: {\n /** The app ID of the deployed contract in this network */\n appID: number\n }\n }\n /** Named structs use by the application. Each struct field appears in the same order as ABI encoding. */\n structs: { [structName: StructName]: StructField[] }\n /** All of the methods that the contract implements */\n methods: Method[]\n state: {\n /** Defines the values that should be used for GlobalNumUint, GlobalNumByteSlice, LocalNumUint, and LocalNumByteSlice when creating the application */\n schema: {\n global: {\n ints: number\n bytes: number\n }\n local: {\n ints: number\n bytes: number\n }\n }\n /** Mapping of human-readable names to StorageKey objects */\n keys: {\n global: { [name: string]: StorageKey }\n local: { [name: string]: StorageKey }\n box: { [name: string]: StorageKey }\n }\n /** Mapping of human-readable names to StorageMap objects */\n maps: {\n global: { [name: string]: StorageMap }\n local: { [name: string]: StorageMap }\n box: { [name: string]: StorageMap }\n }\n }\n /** Supported bare actions for the contract. An action is a combination of call/create and an OnComplete */\n bareActions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** Information about the TEAL programs */\n sourceInfo?: {\n /** Approval program information */\n approval: SourceInfo[]\n /** Clear program information */\n clear: SourceInfo[]\n }\n /** The pre-compiled TEAL that may contain template variables. MUST be omitted if included as part of ARC23 */\n source?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** The compiled bytecode for the application. MUST be omitted if included as part of ARC23 */\n byteCode?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** Information used to get the given byteCode and/or PC values in sourceInfo. MUST be given if byteCode or PC values are present */\n compilerInfo?: {\n /** The name of the compiler */\n compiler: 'algod' | 'puya'\n /** Compiler version information */\n compilerVersion: {\n major: number\n minor: number\n patch: number\n commitHash?: string\n }\n }\n /** ARC-28 events that MAY be emitted by this contract */\n events?: Array<Event>\n /** A mapping of template variable names as they appear in the teal (not including TMPL_ prefix) to their respecive types and values (if applicable) */\n templateVariables?: {\n [name: string]: {\n /** The type of the template variable */\n type: ABIType | AVMType | StructName\n /** If given, the the base64 encoded value used for the given app/program */\n value?: string\n }\n }\n /** The scratch variables used during runtime */\n scratchVariables?: {\n [name: string]: {\n slot: number\n type: ABIType | AVMType | StructName\n }\n }\n}\n\n/** Describes a method in the contract. This interface is an extension of the interface described in ARC-4 */\nexport interface Method {\n /** The name of the method */\n name: string\n /** Optional, user-friendly description for the method */\n desc?: string\n /** The arguments of the method, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */\n type: ABIType\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** The default value that clients should use. */\n defaultValue?: {\n /** Base64 encoded bytes or uint64 */\n data: string | number\n /** How the data is encoded. This is the encoding for the data provided here, not the arg type */\n type: ABIType | AVMType\n /** Where the default value is coming from\n * - box: The data key signifies the box key to read the value from\n * - global: The data key signifies the global state key to read the value from\n * - local: The data key signifies the local state key to read the value from (for the sender)\n * - literal: the value is a literal and should be passed directly as the argument\n */\n source: 'box' | 'global' | 'local' | 'literal'\n }\n }>\n /** Information about the method's return value */\n returns: {\n /** The type of the return value, or \"void\" to indicate no return value. The `struct` field should also be checked to determine if this return value is a struct. */\n type: ABIType\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly description for the return value */\n desc?: string\n }\n /** an action is a combination of call/create and an OnComplete */\n actions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** If this method does not write anything to the ledger (ARC-22) */\n readonly?: boolean\n /** ARC-28 events that MAY be emitted by this method */\n events?: Array<Event>\n /** Information that clients can use when calling the method */\n recommendations?: {\n /** The number of inner transactions the caller should cover the fees for */\n innerTransactionCount?: number\n /** Recommended box references to include */\n boxes?: {\n /** The app ID for the box */\n app?: number\n /** The base64 encoded box key */\n key: string\n /** The number of bytes being read from the box */\n readBytes: number\n /** The number of bytes being written to the box */\n writeBytes: number\n }\n /** Recommended foreign accounts */\n accounts?: string[]\n /** Recommended foreign apps */\n apps?: number[]\n /** Recommended foreign assets */\n assets?: number[]\n }\n}\n\n/** ARC-28 event */\nexport interface Event {\n /** The name of the event */\n name: string\n /** Optional, user-friendly description for the event */\n desc?: string\n /** The arguments of the event, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this return value is a struct. */\n type: ABIType\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n }>\n}\n\n/** An ABI-encoded type */\nexport type ABIType = string\n\n/** The name of a defined struct */\nexport type StructName = string\n\n/** Raw byteslice without the length prefixed that is specified in ARC-4 */\nexport type AVMBytes = 'AVMBytes'\n\n/** A utf-8 string without the length prefix that is specified in ARC-4 */\nexport type AVMString = 'AVMString'\n\n/** A 64-bit unsigned integer */\nexport type AVMUint64 = 'AVMUint64'\n\n/** A native AVM type */\nexport type AVMType = AVMBytes | AVMString | AVMUint64\n\n/** Information about a single field in a struct */\nexport interface StructField {\n /** The name of the struct field */\n name: string\n /** The type of the struct field's value */\n type: ABIType | StructName | StructField[]\n}\n\n/** Describes a single key in app storage */\nexport interface StorageKey {\n /** Description of what this storage key holds */\n desc?: string\n /** The type of the key */\n keyType: ABIType | AVMType | StructName\n\n /** The type of the value */\n valueType: ABIType | AVMType | StructName\n /** The bytes of the key encoded as base64 */\n key: string\n}\n\n/** Describes a mapping of key-value pairs in storage */\nexport interface StorageMap {\n /** Description of what the key-value pairs in this mapping hold */\n desc?: string\n /** The type of the keys in the map */\n keyType: ABIType | AVMType | StructName\n /** The type of the values in the map */\n valueType: ABIType | AVMType | StructName\n /** The base64-encoded prefix of the map keys*/\n prefix?: string\n}\n\nexport interface SourceInfo {\n /** The line of pre-compiled TEAL */\n teal?: number\n /** The program counter offset(s) that correspond to this line of TEAL */\n pc?: Array<number>\n /** A human-readable string that describes the error when the program fails at this given line of TEAL */\n errorMessage?: string\n /** The line of the dissasembled TEAL this line of pre-compiled TEAL corresponds to */\n disassembledTeal?: number\n}\n"],"names":[],"mappings":";;;;AAkBA;;AAEG;AACU,MAAA,WAAY,SAAQ,OAAO,CAAC,SAAS,CAAA;AAIhD,IAAA,WAAA,CAAmB,MAAc,EAAA;QAC/B,KAAK,CAAC,MAAM,CAAC,CAAA;QADI,IAAM,CAAA,MAAA,GAAN,MAAM,CAAQ;AAE/B,QAAA,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM;AACpC,YAAA,GAAG,GAAG;AACN,YAAA,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,OAAO,C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AAE7G,IAAA,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;AACjB,QAAA,OAAO,wBAAwB,CAAC,WAAW,CAAC,WAAiC,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAY,CAAA;KAClH;IAED,OAAO,WAAW,CAAC,WAAsB,CAAA;AAC3C;;;;;;;;;;;"}
1
+ {"version":3,"file":"app-arc56.js","sources":["../../src/types/app-arc56.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { ABIReturn } from './app'\nimport { Expand } from './expand'\n\n/** Type to describe an argument within an `Arc56Method`. */\nexport type Arc56MethodArg = Expand<\n Omit<Method['args'][number], 'type'> & {\n type: algosdk.ABIArgumentType\n }\n>\n\n/** Type to describe a return type within an `Arc56Method`. */\nexport type Arc56MethodReturnType = Expand<\n Omit<Method['returns'], 'type'> & {\n type: algosdk.ABIReturnType\n }\n>\n\n/**\n * Wrapper around `algosdk.ABIMethod` that represents an ARC-56 ABI method.\n */\nexport class Arc56Method extends algosdk.ABIMethod {\n override readonly args: Array<Arc56MethodArg>\n override readonly returns: Arc56MethodReturnType\n\n constructor(public method: Method) {\n super(method)\n this.args = method.args.map((arg) => ({\n ...arg,\n type: algosdk.abiTypeIsTransaction(arg.type) || algosdk.abiTypeIsReference(arg.type) ? arg.type : algosdk.ABIType.from(arg.type),\n }))\n this.returns = {\n ...this.method.returns,\n type: this.method.returns.type === 'void' ? 'void' : algosdk.ABIType.from(this.method.returns.type),\n }\n }\n\n override toJSON(): Method {\n return this.method\n }\n}\n\n/**\n * Returns the `ABITupleType` for the given ARC-56 struct definition\n * @param struct The ARC-56 struct definition\n * @returns The `ABITupleType`\n */\nexport function getABITupleTypeFromABIStructDefinition(\n struct: StructField[],\n structs: Record<string, StructField[]>,\n): algosdk.ABITupleType {\n return new algosdk.ABITupleType(\n struct.map((v) =>\n typeof v.type === 'string'\n ? structs[v.type]\n ? getABITupleTypeFromABIStructDefinition(structs[v.type], structs)\n : algosdk.ABIType.from(v.type)\n : getABITupleTypeFromABIStructDefinition(v.type, structs),\n ),\n )\n}\n\n/**\n * Converts a decoded ABI tuple as a struct.\n * @param decodedABITuple The decoded ABI tuple value\n * @param structFields The struct fields from an ARC-56 app spec\n * @returns The struct as a Record<string, any>\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getABIStructFromABITuple<TReturn extends ABIStruct = Record<string, any>>(\n decodedABITuple: algosdk.ABIValue[],\n structFields: StructField[],\n structs: Record<string, StructField[]>,\n): TReturn {\n return Object.fromEntries(\n structFields.map(({ name: key, type }, i) => {\n const abiValue = decodedABITuple[i]\n return [\n key,\n (typeof type === 'string' && !structs[type]) || !Array.isArray(abiValue)\n ? decodedABITuple[i]\n : getABIStructFromABITuple(abiValue, typeof type === 'string' ? structs[type] : type, structs),\n ]\n }),\n ) as TReturn\n}\n\n/**\n * Converts an ARC-56 struct as an ABI tuple.\n * @param struct The struct to convert\n * @param structFields The struct fields from an ARC-56 app spec\n * @returns The struct as a decoded ABI tuple\n */\nexport function getABITupleFromABIStruct(\n struct: ABIStruct,\n structFields: StructField[],\n structs: Record<string, StructField[]>,\n): algosdk.ABIValue[] {\n return structFields.map(({ name: key, type }) => {\n const value = struct[key]\n return typeof type === 'string' && !structs[type]\n ? (value as algosdk.ABIValue)\n : getABITupleFromABIStruct(value as ABIStruct, typeof type === 'string' ? structs[type] : type, structs)\n })\n}\n\n/** Decoded ARC-56 struct as a struct rather than a tuple. */\nexport type ABIStruct = {\n [key: string]: ABIStruct | algosdk.ABIValue\n}\n\n/**\n * Returns the decoded ABI value (or struct for a struct type)\n * for the given raw Algorand value given an ARC-56 type and defined ARC-56 structs.\n * @param value The raw Algorand value (bytes or uint64)\n * @param type The ARC-56 type - either an ABI Type string or a struct name\n * @param structs The defined ARC-56 structs\n * @returns The decoded ABI value or struct\n */\nexport function getABIDecodedValue(\n value: Uint8Array | number | bigint,\n type: string,\n structs: Record<string, StructField[]>,\n): algosdk.ABIValue | ABIStruct {\n if (type === 'AVMBytes' || typeof value !== 'object') return value\n if (type === 'AVMString') return Buffer.from(value).toString('utf-8')\n if (type === 'AVMUint64') return algosdk.ABIType.from('uint64').decode(value)\n if (structs[type]) {\n const tupleValue = getABITupleTypeFromABIStructDefinition(structs[type], structs).decode(value)\n return getABIStructFromABITuple(tupleValue, structs[type], structs)\n }\n return algosdk.ABIType.from(type).decode(value)\n}\n\n/**\n * Returns the ABI-encoded value for the given value.\n * @param value The value to encode either already in encoded binary form (`Uint8Array`), a decoded ABI value or an ARC-56 struct\n * @param type The ARC-56 type - either an ABI Type string or a struct name\n * @param structs The defined ARC-56 structs\n * @returns The binary ABI-encoded value\n */\nexport function getABIEncodedValue(\n value: Uint8Array | algosdk.ABIValue | ABIStruct,\n type: string,\n structs: Record<string, StructField[]>,\n): Uint8Array {\n if (typeof value === 'object' && value instanceof Uint8Array) return value\n if (type === 'AVMUint64') return algosdk.ABIType.from('uint64').encode(value as bigint | number)\n if (type === 'AVMBytes' || type === 'AVMString') {\n if (typeof value === 'string') return Buffer.from(value, 'utf-8')\n if (typeof value !== 'object' || !(value instanceof Uint8Array)) throw new Error(`Expected bytes value for ${type}, but got ${value}`)\n return value\n }\n if (structs[type]) {\n const tupleType = getABITupleTypeFromABIStructDefinition(structs[type], structs)\n if (Array.isArray(value)) {\n tupleType.encode(value as algosdk.ABIValue[])\n } else {\n return tupleType.encode(getABITupleFromABIStruct(value as ABIStruct, structs[type], structs))\n }\n }\n return algosdk.ABIType.from(type).encode(value as algosdk.ABIValue)\n}\n\n/**\n * Returns the ARC-56 ABI method object for a given method name or signature and ARC-56 app spec.\n * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.\n * e.g. `my_method` or `my_method(unit64,string)bytes`\n * @param appSpec The app spec for the app\n * @returns The `Arc56Method`\n */\nexport function getArc56Method(methodNameOrSignature: string, appSpec: Arc56Contract): Arc56Method {\n let method: Method\n if (!methodNameOrSignature.includes('(')) {\n const methods = appSpec.methods.filter((m) => m.name === methodNameOrSignature)\n if (methods.length === 0) throw new Error(`Unable to find method ${methodNameOrSignature} in ${appSpec.name} app.`)\n if (methods.length > 1) {\n throw new Error(\n `Received a call to method ${methodNameOrSignature} in contract ${\n appSpec.name\n }, but this resolved to multiple methods; please pass in an ABI signature instead: ${appSpec.methods\n .map((m) => new algosdk.ABIMethod(m).getSignature())\n .join(', ')}`,\n )\n }\n method = methods[0]\n } else {\n const m = appSpec.methods.find((m) => new algosdk.ABIMethod(m).getSignature() === methodNameOrSignature)\n if (!m) throw new Error(`Unable to find method ${methodNameOrSignature} in ${appSpec.name} app.`)\n method = m\n }\n return new Arc56Method(method)\n}\n\n/**\n * Checks for decode errors on the AppCallTransactionResult and maps the return value to the specified generic type\n *\n * @param returnValue The smart contract response\n * @param method The method that was called\n * @param structs The struct fields from the app spec\n * @returns The smart contract response with an updated return value\n */\nexport function getArc56ReturnValue<TReturn extends Uint8Array | algosdk.ABIValue | ABIStruct | undefined>(\n returnValue: ABIReturn | undefined,\n method: Method | Arc56Method,\n structs: Record<string, StructField[]>,\n): TReturn {\n const m = 'method' in method ? method.method : method\n const type = m.returns.struct ?? m.returns.type\n if (returnValue?.decodeError) {\n throw returnValue.decodeError\n }\n if (type === undefined || type === 'void' || returnValue?.returnValue === undefined) return undefined as TReturn\n\n if (type === 'AVMBytes') return returnValue.rawReturnValue as TReturn\n if (type === 'AVMString') return Buffer.from(returnValue.rawReturnValue).toString('utf-8') as TReturn\n if (type === 'AVMUint64') return algosdk.ABIType.from('uint64').decode(returnValue.rawReturnValue) as TReturn\n\n if (structs[type]) {\n return getABIStructFromABITuple(returnValue.returnValue as algosdk.ABIValue[], structs[type], structs) as TReturn\n }\n\n return returnValue.returnValue as TReturn\n}\n\n/****************/\n/** ARC-56 spec */\n/****************/\n\n/** Describes the entire contract. This interface is an extension of the interface described in ARC-4 */\nexport interface Arc56Contract {\n /** The ARCs used and/or supported by this contract. All contracts implicitly support ARC4 and ARC56 */\n arcs: number[]\n /** A user-friendly name for the contract */\n name: string\n /** Optional, user-friendly description for the interface */\n desc?: string\n /**\n * Optional object listing the contract instances across different networks.\n * The key is the base64 genesis hash of the network, and the value contains\n * information about the deployed contract in the network indicated by the\n * key. A key containing the human-readable name of the network MAY be\n * included, but the corresponding genesis hash key MUST also be defined\n */\n networks?: {\n [network: string]: {\n /** The app ID of the deployed contract in this network */\n appID: number\n }\n }\n /** Named structs used by the application. Each struct field appears in the same order as ABI encoding. */\n structs: { [structName: StructName]: StructField[] }\n /** All of the methods that the contract implements */\n methods: Method[]\n state: {\n /** Defines the values that should be used for GlobalNumUint, GlobalNumByteSlice, LocalNumUint, and LocalNumByteSlice when creating the application */\n schema: {\n global: {\n ints: number\n bytes: number\n }\n local: {\n ints: number\n bytes: number\n }\n }\n /** Mapping of human-readable names to StorageKey objects */\n keys: {\n global: { [name: string]: StorageKey }\n local: { [name: string]: StorageKey }\n box: { [name: string]: StorageKey }\n }\n /** Mapping of human-readable names to StorageMap objects */\n maps: {\n global: { [name: string]: StorageMap }\n local: { [name: string]: StorageMap }\n box: { [name: string]: StorageMap }\n }\n }\n /** Supported bare actions for the contract. An action is a combination of call/create and an OnComplete */\n bareActions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** Information about the TEAL programs */\n sourceInfo?: {\n /** Approval program information */\n approval: ProgramSourceInfo\n /** Clear program information */\n clear: ProgramSourceInfo\n }\n /** The pre-compiled TEAL that may contain template variables. MUST be omitted if included as part of ARC23 */\n source?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** The compiled bytecode for the application. MUST be omitted if included as part of ARC23 */\n byteCode?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** Information used to get the given byteCode and/or PC values in sourceInfo. MUST be given if byteCode or PC values are present */\n compilerInfo?: {\n /** The name of the compiler */\n compiler: 'algod' | 'puya'\n /** Compiler version information */\n compilerVersion: {\n major: number\n minor: number\n patch: number\n commitHash?: string\n }\n }\n /** ARC-28 events that MAY be emitted by this contract */\n events?: Array<Event>\n /** A mapping of template variable names as they appear in the TEAL (not including TMPL_ prefix) to their respective types and values (if applicable) */\n templateVariables?: {\n [name: string]: {\n /** The type of the template variable */\n type: ABIType | AVMType | StructName\n /** If given, the base64 encoded value used for the given app/program */\n value?: string\n }\n }\n /** The scratch variables used during runtime */\n scratchVariables?: {\n [name: string]: {\n slot: number\n type: ABIType | AVMType | StructName\n }\n }\n}\n\n/** Describes a method in the contract. This interface is an extension of the interface described in ARC-4 */\nexport interface Method {\n /** The name of the method */\n name: string\n /** Optional, user-friendly description for the method */\n desc?: string\n /** The arguments of the method, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */\n type: ABIType\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** The default value that clients should use. */\n defaultValue?: {\n /** Base64 encoded bytes, base64 ARC4 encoded uint64, or UTF-8 method selector */\n data: string\n /** How the data is encoded. This is the encoding for the data provided here, not the arg type */\n type?: ABIType | AVMType\n /** Where the default value is coming from\n * - box: The data key signifies the box key to read the value from\n * - global: The data key signifies the global state key to read the value from\n * - local: The data key signifies the local state key to read the value from (for the sender)\n * - literal: the value is a literal and should be passed directly as the argument\n * - method: The utf8 signature of the method in this contract to call to get the default value. If the method has arguments, they all must have default values. The method **MUST** be readonly so simulate can be used to get the default value\n */\n source: 'box' | 'global' | 'local' | 'literal' | 'method'\n }\n }>\n /** Information about the method's return value */\n returns: {\n /** The type of the return value, or \"void\" to indicate no return value. The `struct` field should also be checked to determine if this return value is a struct. */\n type: ABIType\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly description for the return value */\n desc?: string\n }\n /** an action is a combination of call/create and an OnComplete */\n actions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** If this method does not write anything to the ledger (ARC-22) */\n readonly?: boolean\n /** ARC-28 events that MAY be emitted by this method */\n events?: Array<Event>\n /** Information that clients can use when calling the method */\n recommendations?: {\n /** The number of inner transactions the caller should cover the fees for */\n innerTransactionCount?: number\n /** Recommended box references to include */\n boxes?: {\n /** The app ID for the box */\n app?: number\n /** The base64 encoded box key */\n key: string\n /** The number of bytes being read from the box */\n readBytes: number\n /** The number of bytes being written to the box */\n writeBytes: number\n }\n /** Recommended foreign accounts */\n accounts?: string[]\n /** Recommended foreign apps */\n apps?: number[]\n /** Recommended foreign assets */\n assets?: number[]\n }\n}\n\n/** ARC-28 event */\nexport interface Event {\n /** The name of the event */\n name: string\n /** Optional, user-friendly description for the event */\n desc?: string\n /** The arguments of the event, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */\n type: ABIType\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n }>\n}\n\n/** An ABI-encoded type */\nexport type ABIType = string\n\n/** The name of a defined struct */\nexport type StructName = string\n\n/** Raw byteslice without the length prefixed that is specified in ARC-4 */\nexport type AVMBytes = 'AVMBytes'\n\n/** A utf-8 string without the length prefix that is specified in ARC-4 */\nexport type AVMString = 'AVMString'\n\n/** A 64-bit unsigned integer */\nexport type AVMUint64 = 'AVMUint64'\n\n/** A native AVM type */\nexport type AVMType = AVMBytes | AVMString | AVMUint64\n\n/** Information about a single field in a struct */\nexport interface StructField {\n /** The name of the struct field */\n name: string\n /** The type of the struct field's value */\n type: ABIType | StructName | StructField[]\n}\n\n/** Describes a single key in app storage */\nexport interface StorageKey {\n /** Description of what this storage key holds */\n desc?: string\n /** The type of the key */\n keyType: ABIType | AVMType | StructName\n\n /** The type of the value */\n valueType: ABIType | AVMType | StructName\n /** The bytes of the key encoded as base64 */\n key: string\n}\n\n/** Describes a mapping of key-value pairs in storage */\nexport interface StorageMap {\n /** Description of what the key-value pairs in this mapping hold */\n desc?: string\n /** The type of the keys in the map */\n keyType: ABIType | AVMType | StructName\n /** The type of the values in the map */\n valueType: ABIType | AVMType | StructName\n /** The base64-encoded prefix of the map keys*/\n prefix?: string\n}\n\ninterface SourceInfo {\n /** The program counter value(s). Could be offset if pcOffsetMethod is not \"none\" */\n pc: Array<number>\n /** A human-readable string that describes the error when the program fails at the given PC */\n errorMessage?: string\n /** The TEAL line number that corresponds to the given PC. RECOMMENDED to be used for development purposes, but not required for clients */\n teal?: number\n /** The original source file and line number that corresponds to the given PC. RECOMMENDED to be used for development purposes, but not required for clients */\n source?: string\n}\n\nexport interface ProgramSourceInfo {\n /** The source information for the program */\n sourceInfo: SourceInfo[]\n /** How the program counter offset is calculated\n * - none: The pc values in sourceInfo are not offset\n * - cblocks: The pc values in sourceInfo are offset by the PC of the first op following the last cblock at the top of the program\n */\n pcOffsetMethod: 'none' | 'cblocks'\n}\n"],"names":[],"mappings":";;;;AAkBA;;AAEG;AACU,MAAA,WAAY,SAAQ,OAAO,CAAC,SAAS,CAAA;AAIhD,IAAA,WAAA,CAAmB,MAAc,EAAA;QAC/B,KAAK,CAAC,MAAM,CAAC;QADI,IAAM,CAAA,MAAA,GAAN,MAAM;AAEvB,QAAA,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM;AACpC,YAAA,GAAG,GAAG;AACN,YAAA,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,GAAG,OAAO,C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GAAG,CAAC;;AAEZ,IAAA,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC;AAChC;AAEA;;;;;;;AAOG;SACa,mBAAmB,CACjC,WAAkC,EAClC,MAA4B,EAC5B,OAAsC,EAAA;AAEtC,IAAA,MAAM,CAAC,GAAG,QAAQ,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM;AACrD,IAAA,MAAM,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI;AAC/C,IAAA,IAAI,WAAW,EAAE,WAAW,EAAE;QAC5B,MAAM,WAAW,CAAC,WAAW;;AAE/B,IAAA,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,MAAM,IAAI,WAAW,EAAE,WAAW,KAAK,SAAS;AAAE,QAAA,OAAO,SAAoB;IAEhH,IAAI,IAAI,KAAK,UAAU;QAAE,OAAO,WAAW,CAAC,cAAyB;IACrE,IAAI,IAAI,KAAK,WAAW;AAAE,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAY;IACrG,IAAI,IAAI,KAAK,WAAW;AAAE,QAAA,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAY;AAE7G,IAAA,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;AACjB,QAAA,OAAO,wBAAwB,CAAC,WAAW,CAAC,WAAiC,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAY;;IAGnH,OAAO,WAAW,CAAC,WAAsB;AAC3C;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"app-arc56.mjs","sources":["../../src/types/app-arc56.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { ABIReturn } from './app'\nimport { Expand } from './expand'\n\n/** Type to describe an argument within an `Arc56Method`. */\nexport type Arc56MethodArg = Expand<\n Omit<Method['args'][number], 'type'> & {\n type: algosdk.ABIArgumentType\n }\n>\n\n/** Type to describe a return type within an `Arc56Method`. */\nexport type Arc56MethodReturnType = Expand<\n Omit<Method['returns'], 'type'> & {\n type: algosdk.ABIReturnType\n }\n>\n\n/**\n * Wrapper around `algosdk.ABIMethod` that represents an ARC-56 ABI method.\n */\nexport class Arc56Method extends algosdk.ABIMethod {\n override readonly args: Array<Arc56MethodArg>\n override readonly returns: Arc56MethodReturnType\n\n constructor(public method: Method) {\n super(method)\n this.args = method.args.map((arg) => ({\n ...arg,\n type: algosdk.abiTypeIsTransaction(arg.type) || algosdk.abiTypeIsReference(arg.type) ? arg.type : algosdk.ABIType.from(arg.type),\n }))\n this.returns = {\n ...this.method.returns,\n type: this.method.returns.type === 'void' ? 'void' : algosdk.ABIType.from(this.method.returns.type),\n }\n }\n\n override toJSON(): Method {\n return this.method\n }\n}\n\n/**\n * Returns the `ABITupleType` for the given ARC-56 struct definition\n * @param struct The ARC-56 struct definition\n * @returns The `ABITupleType`\n */\nexport function getABITupleTypeFromABIStructDefinition(\n struct: StructField[],\n structs: Record<string, StructField[]>,\n): algosdk.ABITupleType {\n return new algosdk.ABITupleType(\n struct.map((v) =>\n typeof v.type === 'string'\n ? structs[v.type]\n ? getABITupleTypeFromABIStructDefinition(structs[v.type], structs)\n : algosdk.ABIType.from(v.type)\n : getABITupleTypeFromABIStructDefinition(v.type, structs),\n ),\n )\n}\n\n/**\n * Converts a decoded ABI tuple as a struct.\n * @param decodedABITuple The decoded ABI tuple value\n * @param structFields The struct fields from an ARC-56 app spec\n * @returns The struct as a Record<string, any>\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getABIStructFromABITuple<TReturn extends ABIStruct = Record<string, any>>(\n decodedABITuple: algosdk.ABIValue[],\n structFields: StructField[],\n structs: Record<string, StructField[]>,\n): TReturn {\n return Object.fromEntries(\n structFields.map(({ name: key, type }, i) => {\n const abiValue = decodedABITuple[i]\n return [\n key,\n (typeof type === 'string' && !structs[type]) || !Array.isArray(abiValue)\n ? decodedABITuple[i]\n : getABIStructFromABITuple(abiValue, typeof type === 'string' ? structs[type] : type, structs),\n ]\n }),\n ) as TReturn\n}\n\n/**\n * Converts an ARC-56 struct as an ABI tuple.\n * @param struct The struct to convert\n * @param structFields The struct fields from an ARC-56 app spec\n * @returns The struct as a decoded ABI tuple\n */\nexport function getABITupleFromABIStruct(\n struct: ABIStruct,\n structFields: StructField[],\n structs: Record<string, StructField[]>,\n): algosdk.ABIValue[] {\n return structFields.map(({ name: key, type }) => {\n const value = struct[key]\n return typeof type === 'string' && !structs[type]\n ? (value as algosdk.ABIValue)\n : getABITupleFromABIStruct(value as ABIStruct, typeof type === 'string' ? structs[type] : type, structs)\n })\n}\n\n/** Decoded ARC-56 struct as a struct rather than a tuple. */\nexport type ABIStruct = {\n [key: string]: ABIStruct | algosdk.ABIValue\n}\n\n/**\n * Returns the decoded ABI value (or struct for a struct type)\n * for the given raw Algorand value given an ARC-56 type and defined ARC-56 structs.\n * @param value The raw Algorand value (bytes or uint64)\n * @param type The ARC-56 type - either an ABI Type string or a struct name\n * @param structs The defined ARC-56 structs\n * @returns The decoded ABI value or struct\n */\nexport function getABIDecodedValue(\n value: Uint8Array | number | bigint,\n type: string,\n structs: Record<string, StructField[]>,\n): algosdk.ABIValue | ABIStruct {\n if (type === 'AVMBytes' || typeof value !== 'object') return value\n if (type === 'AVMString') return Buffer.from(value).toString('utf-8')\n if (type === 'AVMUint64') return algosdk.ABIType.from('uint64').decode(value)\n if (structs[type]) {\n const tupleValue = getABITupleTypeFromABIStructDefinition(structs[type], structs).decode(value)\n return getABIStructFromABITuple(tupleValue, structs[type], structs)\n }\n return algosdk.ABIType.from(type).decode(value)\n}\n\n/**\n * Returns the ABI-encoded value for the given value.\n * @param value The value to encode either already in encoded binary form (`Uint8Array`), a decoded ABI value or an ARC-56 struct\n * @param type The ARC-56 type - either an ABI Type string or a struct name\n * @param structs The defined ARC-56 structs\n * @returns The binary ABI-encoded value\n */\nexport function getABIEncodedValue(\n value: Uint8Array | algosdk.ABIValue | ABIStruct,\n type: string,\n structs: Record<string, StructField[]>,\n): Uint8Array {\n if (typeof value === 'object' && value instanceof Uint8Array) return value\n if (type === 'AVMUint64') return algosdk.ABIType.from('uint64').encode(value as bigint | number)\n if (type === 'AVMBytes' || type === 'AVMString') {\n if (typeof value === 'string') return Buffer.from(value, 'utf-8')\n if (typeof value !== 'object' || !(value instanceof Uint8Array)) throw new Error(`Expected bytes value for ${type}, but got ${value}`)\n return value\n }\n if (structs[type]) {\n const tupleType = getABITupleTypeFromABIStructDefinition(structs[type], structs)\n if (Array.isArray(value)) {\n tupleType.encode(value as algosdk.ABIValue[])\n } else {\n return tupleType.encode(getABITupleFromABIStruct(value as ABIStruct, structs[type], structs))\n }\n }\n return algosdk.ABIType.from(type).encode(value as algosdk.ABIValue)\n}\n\n/**\n * Returns the ARC-56 ABI method object for a given method name or signature and ARC-56 app spec.\n * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.\n * e.g. `my_method` or `my_method(unit64,string)bytes`\n * @param appSpec The app spec for the app\n * @returns The `Arc56Method`\n */\nexport function getArc56Method(methodNameOrSignature: string, appSpec: Arc56Contract): Arc56Method {\n let method: Method\n if (!methodNameOrSignature.includes('(')) {\n const methods = appSpec.methods.filter((m) => m.name === methodNameOrSignature)\n if (methods.length === 0) throw new Error(`Unable to find method ${methodNameOrSignature} in ${appSpec.name} app.`)\n if (methods.length > 1) {\n throw new Error(\n `Received a call to method ${methodNameOrSignature} in contract ${\n appSpec.name\n }, but this resolved to multiple methods; please pass in an ABI signature instead: ${appSpec.methods\n .map((m) => new algosdk.ABIMethod(m).getSignature())\n .join(', ')}`,\n )\n }\n method = methods[0]\n } else {\n const m = appSpec.methods.find((m) => new algosdk.ABIMethod(m).getSignature() === methodNameOrSignature)\n if (!m) throw new Error(`Unable to find method ${methodNameOrSignature} in ${appSpec.name} app.`)\n method = m\n }\n return new Arc56Method(method)\n}\n\n/**\n * Checks for decode errors on the AppCallTransactionResult and maps the return value to the specified generic type\n *\n * @param returnValue The smart contract response\n * @param method The method that was called\n * @param structs The struct fields from the app spec\n * @returns The smart contract response with an updated return value\n */\nexport function getArc56ReturnValue<TReturn extends Uint8Array | algosdk.ABIValue | ABIStruct | undefined>(\n returnValue: ABIReturn | undefined,\n method: Method | Arc56Method,\n structs: Record<string, StructField[]>,\n): TReturn {\n const m = 'method' in method ? method.method : method\n const type = m.returns.struct ?? m.returns.type\n if (returnValue?.decodeError) {\n throw returnValue.decodeError\n }\n if (type === undefined || type === 'void' || returnValue?.returnValue === undefined) return undefined as TReturn\n\n if (type === 'AVMBytes') return returnValue.rawReturnValue as TReturn\n if (type === 'AVMString') return Buffer.from(returnValue.rawReturnValue).toString('utf-8') as TReturn\n if (type === 'AVMUint64') return algosdk.ABIType.from('uint64').decode(returnValue.rawReturnValue) as TReturn\n\n if (structs[type]) {\n return getABIStructFromABITuple(returnValue.returnValue as algosdk.ABIValue[], structs[type], structs) as TReturn\n }\n\n return returnValue.returnValue as TReturn\n}\n\n/****************/\n/** ARC-56 spec */\n/****************/\n\n/** Describes the entire contract. This interface is an extension of the interface described in ARC-4 */\nexport interface Arc56Contract {\n /** The ARCs used and/or supported by this contract. All contracts implicity support ARC4 and ARC56 */\n arcs: number[]\n /** A user-friendly name for the contract */\n name: string\n /** Optional, user-friendly description for the interface */\n desc?: string\n /**\n * Optional object listing the contract instances across different networks.\n * The key is the base64 genesis hash of the network, and the value contains\n * information about the deployed contract in the network indicated by the\n * key. A key containing the human-readable name of the network MAY be\n * included, but the corresponding genesis hash key MUST also be define\n */\n networks?: {\n [network: string]: {\n /** The app ID of the deployed contract in this network */\n appID: number\n }\n }\n /** Named structs use by the application. Each struct field appears in the same order as ABI encoding. */\n structs: { [structName: StructName]: StructField[] }\n /** All of the methods that the contract implements */\n methods: Method[]\n state: {\n /** Defines the values that should be used for GlobalNumUint, GlobalNumByteSlice, LocalNumUint, and LocalNumByteSlice when creating the application */\n schema: {\n global: {\n ints: number\n bytes: number\n }\n local: {\n ints: number\n bytes: number\n }\n }\n /** Mapping of human-readable names to StorageKey objects */\n keys: {\n global: { [name: string]: StorageKey }\n local: { [name: string]: StorageKey }\n box: { [name: string]: StorageKey }\n }\n /** Mapping of human-readable names to StorageMap objects */\n maps: {\n global: { [name: string]: StorageMap }\n local: { [name: string]: StorageMap }\n box: { [name: string]: StorageMap }\n }\n }\n /** Supported bare actions for the contract. An action is a combination of call/create and an OnComplete */\n bareActions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** Information about the TEAL programs */\n sourceInfo?: {\n /** Approval program information */\n approval: SourceInfo[]\n /** Clear program information */\n clear: SourceInfo[]\n }\n /** The pre-compiled TEAL that may contain template variables. MUST be omitted if included as part of ARC23 */\n source?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** The compiled bytecode for the application. MUST be omitted if included as part of ARC23 */\n byteCode?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** Information used to get the given byteCode and/or PC values in sourceInfo. MUST be given if byteCode or PC values are present */\n compilerInfo?: {\n /** The name of the compiler */\n compiler: 'algod' | 'puya'\n /** Compiler version information */\n compilerVersion: {\n major: number\n minor: number\n patch: number\n commitHash?: string\n }\n }\n /** ARC-28 events that MAY be emitted by this contract */\n events?: Array<Event>\n /** A mapping of template variable names as they appear in the teal (not including TMPL_ prefix) to their respecive types and values (if applicable) */\n templateVariables?: {\n [name: string]: {\n /** The type of the template variable */\n type: ABIType | AVMType | StructName\n /** If given, the the base64 encoded value used for the given app/program */\n value?: string\n }\n }\n /** The scratch variables used during runtime */\n scratchVariables?: {\n [name: string]: {\n slot: number\n type: ABIType | AVMType | StructName\n }\n }\n}\n\n/** Describes a method in the contract. This interface is an extension of the interface described in ARC-4 */\nexport interface Method {\n /** The name of the method */\n name: string\n /** Optional, user-friendly description for the method */\n desc?: string\n /** The arguments of the method, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */\n type: ABIType\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** The default value that clients should use. */\n defaultValue?: {\n /** Base64 encoded bytes or uint64 */\n data: string | number\n /** How the data is encoded. This is the encoding for the data provided here, not the arg type */\n type: ABIType | AVMType\n /** Where the default value is coming from\n * - box: The data key signifies the box key to read the value from\n * - global: The data key signifies the global state key to read the value from\n * - local: The data key signifies the local state key to read the value from (for the sender)\n * - literal: the value is a literal and should be passed directly as the argument\n */\n source: 'box' | 'global' | 'local' | 'literal'\n }\n }>\n /** Information about the method's return value */\n returns: {\n /** The type of the return value, or \"void\" to indicate no return value. The `struct` field should also be checked to determine if this return value is a struct. */\n type: ABIType\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly description for the return value */\n desc?: string\n }\n /** an action is a combination of call/create and an OnComplete */\n actions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** If this method does not write anything to the ledger (ARC-22) */\n readonly?: boolean\n /** ARC-28 events that MAY be emitted by this method */\n events?: Array<Event>\n /** Information that clients can use when calling the method */\n recommendations?: {\n /** The number of inner transactions the caller should cover the fees for */\n innerTransactionCount?: number\n /** Recommended box references to include */\n boxes?: {\n /** The app ID for the box */\n app?: number\n /** The base64 encoded box key */\n key: string\n /** The number of bytes being read from the box */\n readBytes: number\n /** The number of bytes being written to the box */\n writeBytes: number\n }\n /** Recommended foreign accounts */\n accounts?: string[]\n /** Recommended foreign apps */\n apps?: number[]\n /** Recommended foreign assets */\n assets?: number[]\n }\n}\n\n/** ARC-28 event */\nexport interface Event {\n /** The name of the event */\n name: string\n /** Optional, user-friendly description for the event */\n desc?: string\n /** The arguments of the event, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this return value is a struct. */\n type: ABIType\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n }>\n}\n\n/** An ABI-encoded type */\nexport type ABIType = string\n\n/** The name of a defined struct */\nexport type StructName = string\n\n/** Raw byteslice without the length prefixed that is specified in ARC-4 */\nexport type AVMBytes = 'AVMBytes'\n\n/** A utf-8 string without the length prefix that is specified in ARC-4 */\nexport type AVMString = 'AVMString'\n\n/** A 64-bit unsigned integer */\nexport type AVMUint64 = 'AVMUint64'\n\n/** A native AVM type */\nexport type AVMType = AVMBytes | AVMString | AVMUint64\n\n/** Information about a single field in a struct */\nexport interface StructField {\n /** The name of the struct field */\n name: string\n /** The type of the struct field's value */\n type: ABIType | StructName | StructField[]\n}\n\n/** Describes a single key in app storage */\nexport interface StorageKey {\n /** Description of what this storage key holds */\n desc?: string\n /** The type of the key */\n keyType: ABIType | AVMType | StructName\n\n /** The type of the value */\n valueType: ABIType | AVMType | StructName\n /** The bytes of the key encoded as base64 */\n key: string\n}\n\n/** Describes a mapping of key-value pairs in storage */\nexport interface StorageMap {\n /** Description of what the key-value pairs in this mapping hold */\n desc?: string\n /** The type of the keys in the map */\n keyType: ABIType | AVMType | StructName\n /** The type of the values in the map */\n valueType: ABIType | AVMType | StructName\n /** The base64-encoded prefix of the map keys*/\n prefix?: string\n}\n\nexport interface SourceInfo {\n /** The line of pre-compiled TEAL */\n teal?: number\n /** The program counter offset(s) that correspond to this line of TEAL */\n pc?: Array<number>\n /** A human-readable string that describes the error when the program fails at this given line of TEAL */\n errorMessage?: string\n /** The line of the dissasembled TEA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EAAE,WAAW,EAAE;QAC5B,MAAM,WAAW,CAAC,WAAW,CAAA;KAC9B;AACD,IAAA,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,MAAM,IAAI,WAAW,EAAE,WAAW,KAAK,SAAS;AAAE,QAAA,OAAO,SAAoB,CAAA;IAEhH,IAAI,IAAI,KAAK,UAAU;QAAE,OAAO,WAAW,CAAC,cAAyB,CAAA;IACrE,IAAI,IAAI,KAAK,WAAW;AAAE,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAY,CAAA;IACrG,IAAI,IAAI,KAAK,WAAW;AAAE,QAAA,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAY,CAAA;AAE7G,IAAA,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;AACjB,QAAA,OAAO,wBAAwB,CAAC,WAAW,CAAC,WAAiC,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAY,CAAA;KAClH;IAED,OAAO,WAAW,CAAC,WAAsB,CAAA;AAC3C;;;;"}
1
+ {"version":3,"file":"app-arc56.mjs","sources":["../../src/types/app-arc56.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { ABIReturn } from './app'\nimport { Expand } from './expand'\n\n/** Type to describe an argument within an `Arc56Method`. */\nexport type Arc56MethodArg = Expand<\n Omit<Method['args'][number], 'type'> & {\n type: algosdk.ABIArgumentType\n }\n>\n\n/** Type to describe a return type within an `Arc56Method`. */\nexport type Arc56MethodReturnType = Expand<\n Omit<Method['returns'], 'type'> & {\n type: algosdk.ABIReturnType\n }\n>\n\n/**\n * Wrapper around `algosdk.ABIMethod` that represents an ARC-56 ABI method.\n */\nexport class Arc56Method extends algosdk.ABIMethod {\n override readonly args: Array<Arc56MethodArg>\n override readonly returns: Arc56MethodReturnType\n\n constructor(public method: Method) {\n super(method)\n this.args = method.args.map((arg) => ({\n ...arg,\n type: algosdk.abiTypeIsTransaction(arg.type) || algosdk.abiTypeIsReference(arg.type) ? arg.type : algosdk.ABIType.from(arg.type),\n }))\n this.returns = {\n ...this.method.returns,\n type: this.method.returns.type === 'void' ? 'void' : algosdk.ABIType.from(this.method.returns.type),\n }\n }\n\n override toJSON(): Method {\n return this.method\n }\n}\n\n/**\n * Returns the `ABITupleType` for the given ARC-56 struct definition\n * @param struct The ARC-56 struct definition\n * @returns The `ABITupleType`\n */\nexport function getABITupleTypeFromABIStructDefinition(\n struct: StructField[],\n structs: Record<string, StructField[]>,\n): algosdk.ABITupleType {\n return new algosdk.ABITupleType(\n struct.map((v) =>\n typeof v.type === 'string'\n ? structs[v.type]\n ? getABITupleTypeFromABIStructDefinition(structs[v.type], structs)\n : algosdk.ABIType.from(v.type)\n : getABITupleTypeFromABIStructDefinition(v.type, structs),\n ),\n )\n}\n\n/**\n * Converts a decoded ABI tuple as a struct.\n * @param decodedABITuple The decoded ABI tuple value\n * @param structFields The struct fields from an ARC-56 app spec\n * @returns The struct as a Record<string, any>\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getABIStructFromABITuple<TReturn extends ABIStruct = Record<string, any>>(\n decodedABITuple: algosdk.ABIValue[],\n structFields: StructField[],\n structs: Record<string, StructField[]>,\n): TReturn {\n return Object.fromEntries(\n structFields.map(({ name: key, type }, i) => {\n const abiValue = decodedABITuple[i]\n return [\n key,\n (typeof type === 'string' && !structs[type]) || !Array.isArray(abiValue)\n ? decodedABITuple[i]\n : getABIStructFromABITuple(abiValue, typeof type === 'string' ? structs[type] : type, structs),\n ]\n }),\n ) as TReturn\n}\n\n/**\n * Converts an ARC-56 struct as an ABI tuple.\n * @param struct The struct to convert\n * @param structFields The struct fields from an ARC-56 app spec\n * @returns The struct as a decoded ABI tuple\n */\nexport function getABITupleFromABIStruct(\n struct: ABIStruct,\n structFields: StructField[],\n structs: Record<string, StructField[]>,\n): algosdk.ABIValue[] {\n return structFields.map(({ name: key, type }) => {\n const value = struct[key]\n return typeof type === 'string' && !structs[type]\n ? (value as algosdk.ABIValue)\n : getABITupleFromABIStruct(value as ABIStruct, typeof type === 'string' ? structs[type] : type, structs)\n })\n}\n\n/** Decoded ARC-56 struct as a struct rather than a tuple. */\nexport type ABIStruct = {\n [key: string]: ABIStruct | algosdk.ABIValue\n}\n\n/**\n * Returns the decoded ABI value (or struct for a struct type)\n * for the given raw Algorand value given an ARC-56 type and defined ARC-56 structs.\n * @param value The raw Algorand value (bytes or uint64)\n * @param type The ARC-56 type - either an ABI Type string or a struct name\n * @param structs The defined ARC-56 structs\n * @returns The decoded ABI value or struct\n */\nexport function getABIDecodedValue(\n value: Uint8Array | number | bigint,\n type: string,\n structs: Record<string, StructField[]>,\n): algosdk.ABIValue | ABIStruct {\n if (type === 'AVMBytes' || typeof value !== 'object') return value\n if (type === 'AVMString') return Buffer.from(value).toString('utf-8')\n if (type === 'AVMUint64') return algosdk.ABIType.from('uint64').decode(value)\n if (structs[type]) {\n const tupleValue = getABITupleTypeFromABIStructDefinition(structs[type], structs).decode(value)\n return getABIStructFromABITuple(tupleValue, structs[type], structs)\n }\n return algosdk.ABIType.from(type).decode(value)\n}\n\n/**\n * Returns the ABI-encoded value for the given value.\n * @param value The value to encode either already in encoded binary form (`Uint8Array`), a decoded ABI value or an ARC-56 struct\n * @param type The ARC-56 type - either an ABI Type string or a struct name\n * @param structs The defined ARC-56 structs\n * @returns The binary ABI-encoded value\n */\nexport function getABIEncodedValue(\n value: Uint8Array | algosdk.ABIValue | ABIStruct,\n type: string,\n structs: Record<string, StructField[]>,\n): Uint8Array {\n if (typeof value === 'object' && value instanceof Uint8Array) return value\n if (type === 'AVMUint64') return algosdk.ABIType.from('uint64').encode(value as bigint | number)\n if (type === 'AVMBytes' || type === 'AVMString') {\n if (typeof value === 'string') return Buffer.from(value, 'utf-8')\n if (typeof value !== 'object' || !(value instanceof Uint8Array)) throw new Error(`Expected bytes value for ${type}, but got ${value}`)\n return value\n }\n if (structs[type]) {\n const tupleType = getABITupleTypeFromABIStructDefinition(structs[type], structs)\n if (Array.isArray(value)) {\n tupleType.encode(value as algosdk.ABIValue[])\n } else {\n return tupleType.encode(getABITupleFromABIStruct(value as ABIStruct, structs[type], structs))\n }\n }\n return algosdk.ABIType.from(type).encode(value as algosdk.ABIValue)\n}\n\n/**\n * Returns the ARC-56 ABI method object for a given method name or signature and ARC-56 app spec.\n * @param methodNameOrSignature The method name or method signature to call if an ABI call is being emitted.\n * e.g. `my_method` or `my_method(unit64,string)bytes`\n * @param appSpec The app spec for the app\n * @returns The `Arc56Method`\n */\nexport function getArc56Method(methodNameOrSignature: string, appSpec: Arc56Contract): Arc56Method {\n let method: Method\n if (!methodNameOrSignature.includes('(')) {\n const methods = appSpec.methods.filter((m) => m.name === methodNameOrSignature)\n if (methods.length === 0) throw new Error(`Unable to find method ${methodNameOrSignature} in ${appSpec.name} app.`)\n if (methods.length > 1) {\n throw new Error(\n `Received a call to method ${methodNameOrSignature} in contract ${\n appSpec.name\n }, but this resolved to multiple methods; please pass in an ABI signature instead: ${appSpec.methods\n .map((m) => new algosdk.ABIMethod(m).getSignature())\n .join(', ')}`,\n )\n }\n method = methods[0]\n } else {\n const m = appSpec.methods.find((m) => new algosdk.ABIMethod(m).getSignature() === methodNameOrSignature)\n if (!m) throw new Error(`Unable to find method ${methodNameOrSignature} in ${appSpec.name} app.`)\n method = m\n }\n return new Arc56Method(method)\n}\n\n/**\n * Checks for decode errors on the AppCallTransactionResult and maps the return value to the specified generic type\n *\n * @param returnValue The smart contract response\n * @param method The method that was called\n * @param structs The struct fields from the app spec\n * @returns The smart contract response with an updated return value\n */\nexport function getArc56ReturnValue<TReturn extends Uint8Array | algosdk.ABIValue | ABIStruct | undefined>(\n returnValue: ABIReturn | undefined,\n method: Method | Arc56Method,\n structs: Record<string, StructField[]>,\n): TReturn {\n const m = 'method' in method ? method.method : method\n const type = m.returns.struct ?? m.returns.type\n if (returnValue?.decodeError) {\n throw returnValue.decodeError\n }\n if (type === undefined || type === 'void' || returnValue?.returnValue === undefined) return undefined as TReturn\n\n if (type === 'AVMBytes') return returnValue.rawReturnValue as TReturn\n if (type === 'AVMString') return Buffer.from(returnValue.rawReturnValue).toString('utf-8') as TReturn\n if (type === 'AVMUint64') return algosdk.ABIType.from('uint64').decode(returnValue.rawReturnValue) as TReturn\n\n if (structs[type]) {\n return getABIStructFromABITuple(returnValue.returnValue as algosdk.ABIValue[], structs[type], structs) as TReturn\n }\n\n return returnValue.returnValue as TReturn\n}\n\n/****************/\n/** ARC-56 spec */\n/****************/\n\n/** Describes the entire contract. This interface is an extension of the interface described in ARC-4 */\nexport interface Arc56Contract {\n /** The ARCs used and/or supported by this contract. All contracts implicitly support ARC4 and ARC56 */\n arcs: number[]\n /** A user-friendly name for the contract */\n name: string\n /** Optional, user-friendly description for the interface */\n desc?: string\n /**\n * Optional object listing the contract instances across different networks.\n * The key is the base64 genesis hash of the network, and the value contains\n * information about the deployed contract in the network indicated by the\n * key. A key containing the human-readable name of the network MAY be\n * included, but the corresponding genesis hash key MUST also be defined\n */\n networks?: {\n [network: string]: {\n /** The app ID of the deployed contract in this network */\n appID: number\n }\n }\n /** Named structs used by the application. Each struct field appears in the same order as ABI encoding. */\n structs: { [structName: StructName]: StructField[] }\n /** All of the methods that the contract implements */\n methods: Method[]\n state: {\n /** Defines the values that should be used for GlobalNumUint, GlobalNumByteSlice, LocalNumUint, and LocalNumByteSlice when creating the application */\n schema: {\n global: {\n ints: number\n bytes: number\n }\n local: {\n ints: number\n bytes: number\n }\n }\n /** Mapping of human-readable names to StorageKey objects */\n keys: {\n global: { [name: string]: StorageKey }\n local: { [name: string]: StorageKey }\n box: { [name: string]: StorageKey }\n }\n /** Mapping of human-readable names to StorageMap objects */\n maps: {\n global: { [name: string]: StorageMap }\n local: { [name: string]: StorageMap }\n box: { [name: string]: StorageMap }\n }\n }\n /** Supported bare actions for the contract. An action is a combination of call/create and an OnComplete */\n bareActions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** Information about the TEAL programs */\n sourceInfo?: {\n /** Approval program information */\n approval: ProgramSourceInfo\n /** Clear program information */\n clear: ProgramSourceInfo\n }\n /** The pre-compiled TEAL that may contain template variables. MUST be omitted if included as part of ARC23 */\n source?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** The compiled bytecode for the application. MUST be omitted if included as part of ARC23 */\n byteCode?: {\n /** The approval program */\n approval: string\n /** The clear program */\n clear: string\n }\n /** Information used to get the given byteCode and/or PC values in sourceInfo. MUST be given if byteCode or PC values are present */\n compilerInfo?: {\n /** The name of the compiler */\n compiler: 'algod' | 'puya'\n /** Compiler version information */\n compilerVersion: {\n major: number\n minor: number\n patch: number\n commitHash?: string\n }\n }\n /** ARC-28 events that MAY be emitted by this contract */\n events?: Array<Event>\n /** A mapping of template variable names as they appear in the TEAL (not including TMPL_ prefix) to their respective types and values (if applicable) */\n templateVariables?: {\n [name: string]: {\n /** The type of the template variable */\n type: ABIType | AVMType | StructName\n /** If given, the base64 encoded value used for the given app/program */\n value?: string\n }\n }\n /** The scratch variables used during runtime */\n scratchVariables?: {\n [name: string]: {\n slot: number\n type: ABIType | AVMType | StructName\n }\n }\n}\n\n/** Describes a method in the contract. This interface is an extension of the interface described in ARC-4 */\nexport interface Method {\n /** The name of the method */\n name: string\n /** Optional, user-friendly description for the method */\n desc?: string\n /** The arguments of the method, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */\n type: ABIType\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** The default value that clients should use. */\n defaultValue?: {\n /** Base64 encoded bytes, base64 ARC4 encoded uint64, or UTF-8 method selector */\n data: string\n /** How the data is encoded. This is the encoding for the data provided here, not the arg type */\n type?: ABIType | AVMType\n /** Where the default value is coming from\n * - box: The data key signifies the box key to read the value from\n * - global: The data key signifies the global state key to read the value from\n * - local: The data key signifies the local state key to read the value from (for the sender)\n * - literal: the value is a literal and should be passed directly as the argument\n * - method: The utf8 signature of the method in this contract to call to get the default value. If the method has arguments, they all must have default values. The method **MUST** be readonly so simulate can be used to get the default value\n */\n source: 'box' | 'global' | 'local' | 'literal' | 'method'\n }\n }>\n /** Information about the method's return value */\n returns: {\n /** The type of the return value, or \"void\" to indicate no return value. The `struct` field should also be checked to determine if this return value is a struct. */\n type: ABIType\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n /** Optional, user-friendly description for the return value */\n desc?: string\n }\n /** an action is a combination of call/create and an OnComplete */\n actions: {\n /** OnCompletes this method allows when appID === 0 */\n create: ('NoOp' | 'OptIn' | 'DeleteApplication')[]\n /** OnCompletes this method allows when appID !== 0 */\n call: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[]\n }\n /** If this method does not write anything to the ledger (ARC-22) */\n readonly?: boolean\n /** ARC-28 events that MAY be emitted by this method */\n events?: Array<Event>\n /** Information that clients can use when calling the method */\n recommendations?: {\n /** The number of inner transactions the caller should cover the fees for */\n innerTransactionCount?: number\n /** Recommended box references to include */\n boxes?: {\n /** The app ID for the box */\n app?: number\n /** The base64 encoded box key */\n key: string\n /** The number of bytes being read from the box */\n readBytes: number\n /** The number of bytes being written to the box */\n writeBytes: number\n }\n /** Recommended foreign accounts */\n accounts?: string[]\n /** Recommended foreign apps */\n apps?: number[]\n /** Recommended foreign assets */\n assets?: number[]\n }\n}\n\n/** ARC-28 event */\nexport interface Event {\n /** The name of the event */\n name: string\n /** Optional, user-friendly description for the event */\n desc?: string\n /** The arguments of the event, in order */\n args: Array<{\n /** The type of the argument. The `struct` field should also be checked to determine if this arg is a struct. */\n type: ABIType\n /** Optional, user-friendly name for the argument */\n name?: string\n /** Optional, user-friendly description for the argument */\n desc?: string\n /** If the type is a struct, the name of the struct */\n struct?: StructName\n }>\n}\n\n/** An ABI-encoded type */\nexport type ABIType = string\n\n/** The name of a defined struct */\nexport type StructName = string\n\n/** Raw byteslice without the length prefixed that is specified in ARC-4 */\nexport type AVMBytes = 'AVMBytes'\n\n/** A utf-8 string without the length prefix that is specified in ARC-4 */\nexport type AVMString = 'AVMString'\n\n/** A 64-bit unsigned integer */\nexport type AVMUint64 = 'AVMUint64'\n\n/** A native AVM type */\nexport type AVMType = AVMBytes | AVMString | AVMUint64\n\n/** Information about a single field in a struct */\nexport interface StructField {\n /** The name of the struct field */\n name: string\n /** The type of the struct field's value */\n type: ABIType | StructName | StructField[]\n}\n\n/** Describes a single key in app storage */\nexport interface StorageKey {\n /** Description of what this storage key holds */\n desc?: string\n /** The type of the key */\n keyType: ABIType | AVMType | StructName\n\n /** The type of the value */\n valueType: ABIType | AVMType | StructName\n /** The bytes of the key encoded as base64 */\n key: string\n}\n\n/** Describes a mapping of key-value pairs in storage */\nexport interface StorageMap {\n /** Description of what the key-value pairs in this mapping hold */\n desc?: string\n /** The type of the keys in the map */\n keyType: ABIType | AVMType | StructName\n /** The type of the values in the map */\n valueType: ABIType | AVMType | StructName\n /** The base64-encoded prefix of the map keys*/\n prefix?: string\n}\n\ninterface SourceInfo {\n /** The program counter value(s). Could be offset if pcOffsetMethod is not \"none\" */\n pc: Array<number>\n /** A human-readable string that describes the error when the program fails at the given PC */\n errorMessage?: string\n /** The TEAL line number that corresponds to the given PC. RECOMMENDED to be used for development purposes, but not required for clients */\n teal?: number\n /** The original source file and line number that corresponds to the given PC. RECOMMENDED to be used for development purposes, but not required for clients */\n source?: string\n}\n\nexport interface ProgramSourceInfo {\n /** The source information for the program */\n sourceInfo: SourceInfo[]\n /** How the program counter offset is calculated\n * - none: The pc values in sourceInfo are not offset\n * - cblocks: The pc values in sourceInfo are offset by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