@algorandfoundation/algokit-utils 2.3.3-beta.3 → 2.3.3-beta.5

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 (340) hide show
  1. package/cjs/account.d.ts.map +1 -0
  2. package/cjs/account.js.map +1 -0
  3. package/cjs/amount.d.ts.map +1 -0
  4. package/cjs/amount.js.map +1 -0
  5. package/cjs/app-client.d.ts.map +1 -0
  6. package/cjs/app-client.js.map +1 -0
  7. package/cjs/app-deploy.d.ts.map +1 -0
  8. package/cjs/app-deploy.js.map +1 -0
  9. package/cjs/app.d.ts.map +1 -0
  10. package/cjs/app.js.map +1 -0
  11. package/cjs/index.d.ts.map +1 -0
  12. package/cjs/index.js.map +1 -0
  13. package/cjs/indexer-lookup.d.ts.map +1 -0
  14. package/cjs/indexer-lookup.js.map +1 -0
  15. package/cjs/localnet.d.ts.map +1 -0
  16. package/{localnet.js → cjs/localnet.js} +1 -1
  17. package/cjs/localnet.js.map +1 -0
  18. package/cjs/network-client.d.ts.map +1 -0
  19. package/cjs/network-client.js.map +1 -0
  20. package/cjs/testing/account.d.ts.map +1 -0
  21. package/cjs/testing/account.js.map +1 -0
  22. package/cjs/testing/fixtures/algokit-log-capture-fixture.d.ts.map +1 -0
  23. package/cjs/testing/fixtures/algokit-log-capture-fixture.js.map +1 -0
  24. package/cjs/testing/fixtures/algorand-fixture.d.ts.map +1 -0
  25. package/cjs/testing/fixtures/algorand-fixture.js.map +1 -0
  26. package/cjs/testing/fixtures/index.d.ts.map +1 -0
  27. package/cjs/testing/fixtures/index.js.map +1 -0
  28. package/cjs/testing/index.d.ts.map +1 -0
  29. package/cjs/testing/index.js.map +1 -0
  30. package/cjs/testing/indexer.d.ts.map +1 -0
  31. package/cjs/testing/indexer.js.map +1 -0
  32. package/cjs/testing/test-logger.d.ts.map +1 -0
  33. package/{testing → cjs/testing}/test-logger.js +2 -0
  34. package/cjs/testing/test-logger.js.map +1 -0
  35. package/cjs/testing/transaction-logger.d.ts.map +1 -0
  36. package/{testing → cjs/testing}/transaction-logger.js +2 -3
  37. package/cjs/testing/transaction-logger.js.map +1 -0
  38. package/cjs/transaction.d.ts.map +1 -0
  39. package/cjs/transaction.js.map +1 -0
  40. package/cjs/transfer.d.ts.map +1 -0
  41. package/cjs/transfer.js.map +1 -0
  42. package/cjs/types/account.d.ts +66 -0
  43. package/cjs/types/account.d.ts.map +1 -0
  44. package/{types → cjs/types}/account.js +7 -0
  45. package/cjs/types/account.js.map +1 -0
  46. package/cjs/types/algo-http-client-with-retry.d.ts.map +1 -0
  47. package/{types → cjs/types}/algo-http-client-with-retry.js +16 -16
  48. package/cjs/types/algo-http-client-with-retry.js.map +1 -0
  49. package/cjs/types/amount.d.ts +24 -0
  50. package/cjs/types/amount.d.ts.map +1 -0
  51. package/{types → cjs/types}/amount.js +1 -0
  52. package/cjs/types/amount.js.map +1 -0
  53. package/cjs/types/app-client.d.ts +408 -0
  54. package/cjs/types/app-client.d.ts.map +1 -0
  55. package/{types → cjs/types}/app-client.js +13 -0
  56. package/cjs/types/app-client.js.map +1 -0
  57. package/cjs/types/app-spec.d.ts.map +1 -0
  58. package/{types → cjs/types}/app-spec.js.map +1 -1
  59. package/cjs/types/app.d.ts +308 -0
  60. package/cjs/types/app.d.ts.map +1 -0
  61. package/cjs/types/app.js.map +1 -0
  62. package/cjs/types/config.d.ts.map +1 -0
  63. package/{types → cjs/types}/config.js +1 -0
  64. package/cjs/types/config.js.map +1 -0
  65. package/cjs/types/indexer.d.ts.map +1 -0
  66. package/cjs/types/indexer.js.map +1 -0
  67. package/cjs/types/logging.d.ts.map +1 -0
  68. package/cjs/types/logging.js.map +1 -0
  69. package/cjs/types/logic-error.d.ts.map +1 -0
  70. package/{types → cjs/types}/logic-error.js +5 -2
  71. package/cjs/types/logic-error.js.map +1 -0
  72. package/cjs/types/network-client.d.ts +20 -0
  73. package/cjs/types/network-client.d.ts.map +1 -0
  74. package/cjs/types/network-client.js.map +1 -0
  75. package/cjs/types/testing.d.ts.map +1 -0
  76. package/{types → cjs/types}/testing.js.map +1 -1
  77. package/cjs/types/transaction.d.ts +111 -0
  78. package/cjs/types/transaction.d.ts.map +1 -0
  79. package/{types → cjs/types}/transaction.js.map +1 -1
  80. package/cjs/types/transfer.d.ts +32 -0
  81. package/cjs/types/transfer.d.ts.map +1 -0
  82. package/{types → cjs/types}/transfer.js.map +1 -1
  83. package/cjs/types/urlTokenBaseHTTPClient.d.ts.map +1 -0
  84. package/{types → cjs/types}/urlTokenBaseHTTPClient.js +4 -0
  85. package/cjs/types/urlTokenBaseHTTPClient.js.map +1 -0
  86. package/cjs/util.d.ts.map +1 -0
  87. package/cjs/util.js.map +1 -0
  88. package/esm/account.js +170 -0
  89. package/esm/account.js.map +1 -0
  90. package/esm/amount.js +27 -0
  91. package/esm/amount.js.map +1 -0
  92. package/esm/app-client.js +76 -0
  93. package/esm/app-client.js.map +1 -0
  94. package/esm/app-deploy.js +446 -0
  95. package/esm/app-deploy.js.map +1 -0
  96. package/esm/app.js +572 -0
  97. package/esm/app.js.map +1 -0
  98. package/esm/index.js +14 -0
  99. package/esm/index.js.map +1 -0
  100. package/esm/indexer-lookup.js +98 -0
  101. package/esm/indexer-lookup.js.map +1 -0
  102. package/esm/localnet.js +111 -0
  103. package/esm/localnet.js.map +1 -0
  104. package/esm/network-client.js +179 -0
  105. package/esm/network-client.js.map +1 -0
  106. package/esm/testing/account.js +24 -0
  107. package/esm/testing/account.js.map +1 -0
  108. package/esm/testing/fixtures/algokit-log-capture-fixture.js +39 -0
  109. package/esm/testing/fixtures/algokit-log-capture-fixture.js.map +1 -0
  110. package/esm/testing/fixtures/algorand-fixture.js +53 -0
  111. package/esm/testing/fixtures/algorand-fixture.js.map +1 -0
  112. package/esm/testing/fixtures/index.js +3 -0
  113. package/esm/testing/fixtures/index.js.map +1 -0
  114. package/esm/testing/index.js +6 -0
  115. package/esm/testing/index.js.map +1 -0
  116. package/esm/testing/indexer.js +36 -0
  117. package/esm/testing/indexer.js.map +1 -0
  118. package/esm/testing/test-logger.js +69 -0
  119. package/esm/testing/test-logger.js.map +1 -0
  120. package/esm/testing/transaction-logger.js +66 -0
  121. package/esm/testing/transaction-logger.js.map +1 -0
  122. package/esm/transaction.js +365 -0
  123. package/esm/transaction.js.map +1 -0
  124. package/esm/transfer.js +59 -0
  125. package/esm/transfer.js.map +1 -0
  126. package/esm/types/account.js +90 -0
  127. package/esm/types/account.js.map +1 -0
  128. package/esm/types/algo-http-client-with-retry.js +58 -0
  129. package/esm/types/algo-http-client-with-retry.js.map +1 -0
  130. package/esm/types/amount.js +35 -0
  131. package/esm/types/amount.js.map +1 -0
  132. package/esm/types/app-client.js +624 -0
  133. package/esm/types/app-client.js.map +1 -0
  134. package/esm/types/app-spec.js +2 -0
  135. package/esm/types/app-spec.js.map +1 -0
  136. package/esm/types/app.js +33 -0
  137. package/esm/types/app.js.map +1 -0
  138. package/esm/types/config.js +50 -0
  139. package/esm/types/config.js.map +1 -0
  140. package/esm/types/indexer.js +31 -0
  141. package/esm/types/indexer.js.map +1 -0
  142. package/esm/types/logging.js +24 -0
  143. package/esm/types/logging.js.map +1 -0
  144. package/esm/types/logic-error.js +49 -0
  145. package/esm/types/logic-error.js.map +1 -0
  146. package/esm/types/network-client.js +2 -0
  147. package/esm/types/network-client.js.map +1 -0
  148. package/esm/types/testing.js +2 -0
  149. package/esm/types/testing.js.map +1 -0
  150. package/esm/types/transaction.js +2 -0
  151. package/esm/types/transaction.js.map +1 -0
  152. package/esm/types/transfer.js +2 -0
  153. package/esm/types/transfer.js.map +1 -0
  154. package/esm/types/urlTokenBaseHTTPClient.js +151 -0
  155. package/esm/types/urlTokenBaseHTTPClient.js.map +1 -0
  156. package/esm/util.js +20 -0
  157. package/esm/util.js.map +1 -0
  158. package/package.json +42 -6
  159. package/types/account.d.ts +125 -63
  160. package/types/account.d.ts.map +1 -1
  161. package/types/amount.d.ts +18 -22
  162. package/types/amount.d.ts.map +1 -1
  163. package/types/app-client.d.ts +70 -407
  164. package/types/app-client.d.ts.map +1 -1
  165. package/types/app-deploy.d.ts +101 -0
  166. package/types/app-deploy.d.ts.map +1 -0
  167. package/types/app.d.ts +145 -290
  168. package/types/app.d.ts.map +1 -1
  169. package/types/index.d.ts +14 -0
  170. package/types/index.d.ts.map +1 -0
  171. package/types/indexer-lookup.d.ts +38 -0
  172. package/types/indexer-lookup.d.ts.map +1 -0
  173. package/types/localnet.d.ts +54 -0
  174. package/types/localnet.d.ts.map +1 -0
  175. package/types/network-client.d.ts +96 -19
  176. package/types/network-client.d.ts.map +1 -1
  177. package/types/testing/account.d.ts +14 -0
  178. package/types/testing/account.d.ts.map +1 -0
  179. package/types/testing/fixtures/algokit-log-capture-fixture.d.ts +19 -0
  180. package/types/testing/fixtures/algokit-log-capture-fixture.d.ts.map +1 -0
  181. package/types/testing/fixtures/algorand-fixture.d.ts +48 -0
  182. package/types/testing/fixtures/algorand-fixture.d.ts.map +1 -0
  183. package/types/testing/fixtures/index.d.ts +3 -0
  184. package/types/testing/fixtures/index.d.ts.map +1 -0
  185. package/types/testing/index.d.ts +6 -0
  186. package/types/testing/index.d.ts.map +1 -0
  187. package/types/testing/indexer.d.ts +12 -0
  188. package/types/testing/indexer.d.ts.map +1 -0
  189. package/types/testing/test-logger.d.ts +41 -0
  190. package/types/testing/test-logger.d.ts.map +1 -0
  191. package/types/testing/transaction-logger.d.ts +29 -0
  192. package/types/testing/transaction-logger.d.ts.map +1 -0
  193. package/types/transaction.d.ts +133 -106
  194. package/types/transaction.d.ts.map +1 -1
  195. package/types/transfer.d.ts +21 -31
  196. package/types/transfer.d.ts.map +1 -1
  197. package/types/types/account.d.ts +66 -0
  198. package/types/types/account.d.ts.map +1 -0
  199. package/types/types/algo-http-client-with-retry.d.ts +14 -0
  200. package/types/types/algo-http-client-with-retry.d.ts.map +1 -0
  201. package/types/types/amount.d.ts +24 -0
  202. package/types/types/amount.d.ts.map +1 -0
  203. package/types/types/app-client.d.ts +408 -0
  204. package/types/types/app-client.d.ts.map +1 -0
  205. package/types/types/app-spec.d.ts +154 -0
  206. package/types/types/app-spec.d.ts.map +1 -0
  207. package/types/types/app.d.ts +308 -0
  208. package/types/types/app.d.ts.map +1 -0
  209. package/types/types/config.d.ts +32 -0
  210. package/types/types/config.d.ts.map +1 -0
  211. package/types/types/indexer.d.ts +623 -0
  212. package/types/types/indexer.d.ts.map +1 -0
  213. package/types/types/logging.d.ts +13 -0
  214. package/types/types/logging.d.ts.map +1 -0
  215. package/types/types/logic-error.d.ts +37 -0
  216. package/types/types/logic-error.d.ts.map +1 -0
  217. package/types/types/network-client.d.ts +20 -0
  218. package/types/types/network-client.d.ts.map +1 -0
  219. package/types/types/testing.d.ts +89 -0
  220. package/types/types/testing.d.ts.map +1 -0
  221. package/types/types/transaction.d.ts +111 -0
  222. package/types/types/transaction.d.ts.map +1 -0
  223. package/types/types/transfer.d.ts +32 -0
  224. package/types/types/transfer.d.ts.map +1 -0
  225. package/types/types/urlTokenBaseHTTPClient.d.ts +41 -0
  226. package/types/types/urlTokenBaseHTTPClient.d.ts.map +1 -0
  227. package/types/util.d.ts +10 -0
  228. package/types/util.d.ts.map +1 -0
  229. package/account.d.ts.map +0 -1
  230. package/account.js.map +0 -1
  231. package/amount.d.ts.map +0 -1
  232. package/amount.js.map +0 -1
  233. package/app-client.d.ts.map +0 -1
  234. package/app-client.js.map +0 -1
  235. package/app-deploy.d.ts.map +0 -1
  236. package/app-deploy.js.map +0 -1
  237. package/app.d.ts.map +0 -1
  238. package/app.js.map +0 -1
  239. package/index.d.ts.map +0 -1
  240. package/index.js.map +0 -1
  241. package/indexer-lookup.d.ts.map +0 -1
  242. package/indexer-lookup.js.map +0 -1
  243. package/localnet.d.ts.map +0 -1
  244. package/localnet.js.map +0 -1
  245. package/network-client.d.ts.map +0 -1
  246. package/network-client.js.map +0 -1
  247. package/testing/account.d.ts.map +0 -1
  248. package/testing/account.js.map +0 -1
  249. package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +0 -1
  250. package/testing/fixtures/algokit-log-capture-fixture.js.map +0 -1
  251. package/testing/fixtures/algorand-fixture.d.ts.map +0 -1
  252. package/testing/fixtures/algorand-fixture.js.map +0 -1
  253. package/testing/fixtures/index.d.ts.map +0 -1
  254. package/testing/fixtures/index.js.map +0 -1
  255. package/testing/index.d.ts.map +0 -1
  256. package/testing/index.js.map +0 -1
  257. package/testing/indexer.d.ts.map +0 -1
  258. package/testing/indexer.js.map +0 -1
  259. package/testing/test-logger.d.ts.map +0 -1
  260. package/testing/test-logger.js.map +0 -1
  261. package/testing/transaction-logger.d.ts.map +0 -1
  262. package/testing/transaction-logger.js.map +0 -1
  263. package/transaction.d.ts.map +0 -1
  264. package/transaction.js.map +0 -1
  265. package/transfer.d.ts.map +0 -1
  266. package/transfer.js.map +0 -1
  267. package/types/account.js.map +0 -1
  268. package/types/algo-http-client-with-retry.d.ts.map +0 -1
  269. package/types/algo-http-client-with-retry.js.map +0 -1
  270. package/types/amount.js.map +0 -1
  271. package/types/app-client.js.map +0 -1
  272. package/types/app-spec.d.ts.map +0 -1
  273. package/types/app.js.map +0 -1
  274. package/types/config.d.ts.map +0 -1
  275. package/types/config.js.map +0 -1
  276. package/types/indexer.d.ts.map +0 -1
  277. package/types/indexer.js.map +0 -1
  278. package/types/logging.d.ts.map +0 -1
  279. package/types/logging.js.map +0 -1
  280. package/types/logic-error.d.ts.map +0 -1
  281. package/types/logic-error.js.map +0 -1
  282. package/types/network-client.js.map +0 -1
  283. package/types/testing.d.ts.map +0 -1
  284. package/types/urlTokenBaseHTTPClient.d.ts.map +0 -1
  285. package/types/urlTokenBaseHTTPClient.js.map +0 -1
  286. package/util.d.ts.map +0 -1
  287. package/util.js.map +0 -1
  288. /package/{account.d.ts → cjs/account.d.ts} +0 -0
  289. /package/{account.js → cjs/account.js} +0 -0
  290. /package/{amount.d.ts → cjs/amount.d.ts} +0 -0
  291. /package/{amount.js → cjs/amount.js} +0 -0
  292. /package/{app-client.d.ts → cjs/app-client.d.ts} +0 -0
  293. /package/{app-client.js → cjs/app-client.js} +0 -0
  294. /package/{app-deploy.d.ts → cjs/app-deploy.d.ts} +0 -0
  295. /package/{app-deploy.js → cjs/app-deploy.js} +0 -0
  296. /package/{app.d.ts → cjs/app.d.ts} +0 -0
  297. /package/{app.js → cjs/app.js} +0 -0
  298. /package/{index.d.ts → cjs/index.d.ts} +0 -0
  299. /package/{index.js → cjs/index.js} +0 -0
  300. /package/{indexer-lookup.d.ts → cjs/indexer-lookup.d.ts} +0 -0
  301. /package/{indexer-lookup.js → cjs/indexer-lookup.js} +0 -0
  302. /package/{localnet.d.ts → cjs/localnet.d.ts} +0 -0
  303. /package/{network-client.d.ts → cjs/network-client.d.ts} +0 -0
  304. /package/{network-client.js → cjs/network-client.js} +0 -0
  305. /package/{testing → cjs/testing}/account.d.ts +0 -0
  306. /package/{testing → cjs/testing}/account.js +0 -0
  307. /package/{testing → cjs/testing}/fixtures/algokit-log-capture-fixture.d.ts +0 -0
  308. /package/{testing → cjs/testing}/fixtures/algokit-log-capture-fixture.js +0 -0
  309. /package/{testing → cjs/testing}/fixtures/algorand-fixture.d.ts +0 -0
  310. /package/{testing → cjs/testing}/fixtures/algorand-fixture.js +0 -0
  311. /package/{testing → cjs/testing}/fixtures/index.d.ts +0 -0
  312. /package/{testing → cjs/testing}/fixtures/index.js +0 -0
  313. /package/{testing → cjs/testing}/index.d.ts +0 -0
  314. /package/{testing → cjs/testing}/index.js +0 -0
  315. /package/{testing → cjs/testing}/indexer.d.ts +0 -0
  316. /package/{testing → cjs/testing}/indexer.js +0 -0
  317. /package/{testing → cjs/testing}/test-logger.d.ts +0 -0
  318. /package/{testing → cjs/testing}/transaction-logger.d.ts +0 -0
  319. /package/{transaction.d.ts → cjs/transaction.d.ts} +0 -0
  320. /package/{transaction.js → cjs/transaction.js} +0 -0
  321. /package/{transfer.d.ts → cjs/transfer.d.ts} +0 -0
  322. /package/{transfer.js → cjs/transfer.js} +0 -0
  323. /package/{types → cjs/types}/algo-http-client-with-retry.d.ts +0 -0
  324. /package/{types → cjs/types}/app-spec.d.ts +0 -0
  325. /package/{types → cjs/types}/app-spec.js +0 -0
  326. /package/{types → cjs/types}/app.js +0 -0
  327. /package/{types → cjs/types}/config.d.ts +0 -0
  328. /package/{types → cjs/types}/indexer.d.ts +0 -0
  329. /package/{types → cjs/types}/indexer.js +0 -0
  330. /package/{types → cjs/types}/logging.d.ts +0 -0
  331. /package/{types → cjs/types}/logging.js +0 -0
  332. /package/{types → cjs/types}/logic-error.d.ts +0 -0
  333. /package/{types → cjs/types}/network-client.js +0 -0
  334. /package/{types → cjs/types}/testing.d.ts +0 -0
  335. /package/{types → cjs/types}/testing.js +0 -0
  336. /package/{types → cjs/types}/transaction.js +0 -0
  337. /package/{types → cjs/types}/transfer.js +0 -0
  338. /package/{types → cjs/types}/urlTokenBaseHTTPClient.d.ts +0 -0
  339. /package/{util.d.ts → cjs/util.d.ts} +0 -0
  340. /package/{util.js → cjs/util.js} +0 -0
@@ -1,20 +1,97 @@
1
- import type { TokenHeader } from 'algosdk/dist/types/client/urlTokenBaseHTTPClient';
2
- /** Config for an Algorand SDK client */
3
- export interface AlgoClientConfig {
4
- /** Base URL of the server e.g. http://localhost, https://testnet-api.algonode.cloud/, etc. */
5
- server: string;
6
- /** The port to use e.g. 4001, 443, etc. */
7
- port?: string | number;
8
- /** The token to use for API authentication (or undefined if none needed) - can be a string, or an object with the header key => value */
9
- token?: string | TokenHeader;
10
- }
11
- /** Config for an algo config */
12
- export interface AlgoConfig {
13
- /** Algo client configuration */
14
- algodConfig: AlgoClientConfig;
15
- /** Indexer client configuration */
16
- indexerConfig: AlgoClientConfig;
17
- /** Kmd configuration */
18
- kmdConfig: AlgoClientConfig;
19
- }
1
+ import { Algodv2, Indexer, Kmd } from 'algosdk';
2
+ import { AlgoClientConfig, AlgoConfig } from './types/network-client';
3
+ /** Retrieve configurations from environment variables when defined or get defaults (expects to be called from a Node.js environment not algod-side) */
4
+ export declare function getConfigFromEnvOrDefaults(): AlgoConfig;
5
+ /** Retrieve the algod configuration from environment variables (expects to be called from a Node.js environment not algod-side) */
6
+ export declare function getAlgodConfigFromEnvironment(): AlgoClientConfig;
7
+ /** Retrieve the indexer configuration from environment variables (expects to be called from a Node.js environment not algod-side) */
8
+ export declare function getIndexerConfigFromEnvironment(): AlgoClientConfig;
9
+ /** Returns the Algorand configuration to point to the AlgoNode service
10
+ *
11
+ * @param network Which network to connect to - TestNet or MainNet
12
+ * @param config Which algod config to return - Algod or Indexer
13
+ */
14
+ export declare function getAlgoNodeConfig(network: 'testnet' | 'mainnet', config: 'algod' | 'indexer'): AlgoClientConfig;
15
+ /** Returns the Algorand configuration to point to the default LocalNet
16
+ *
17
+ * @param configOrPort Which algod config to return - algod, kmd, or indexer OR a port number
18
+ */
19
+ export declare function getDefaultLocalNetConfig(configOrPort: 'algod' | 'indexer' | 'kmd' | number): AlgoClientConfig;
20
+ /** Returns an algod SDK client that automatically retries on idempotent calls
21
+ *
22
+ * @param config The config if you want to override the default (getting config from process.env)
23
+ * @example Default (load from environment variables)
24
+ *
25
+ * ```typescript
26
+ * // Uses process.env.ALGOD_SERVER, process.env.ALGOD_PORT and process.env.ALGOD_TOKEN
27
+ * // Automatically detects if you are using PureStake to switch in the right header name for ALGOD_TOKEN
28
+ * const algod = getAlgoClient()
29
+ * await algod.healthCheck().do()
30
+ * ```
31
+ * @example AlgoNode (testnet)
32
+ * ```typescript
33
+ * const algod = getAlgoClient(getAlgoNodeConfig('testnet', 'algod'))
34
+ * await algod.healthCheck().do()
35
+ * ```
36
+ * @example AlgoNode (mainnet)
37
+ * ```typescript
38
+ * const algod = getAlgoClient(getAlgoNodeConfig('mainnet', 'algod'))
39
+ * await algod.healthCheck().do()
40
+ * ```
41
+ * @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)
42
+ * ```typescript
43
+ * const algod = getAlgoClient({server: 'http://localhost', port: '4001', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
44
+ * await algod.healthCheck().do()
45
+ * ```
46
+ */
47
+ export declare function getAlgoClient(config?: AlgoClientConfig): Algodv2;
48
+ /** Returns an indexer SDK client that automatically retries on idempotent calls
49
+ *
50
+ * @param config The config if you want to override the default (getting config from process.env)
51
+ * @example Default (load from environment variables)
52
+ *
53
+ * ```typescript
54
+ * // Uses process.env.INDEXER_SERVER, process.env.INDEXER_PORT and process.env.INDEXER_TOKEN
55
+ * // Automatically detects if you are using PureStake to switch in the right header name for INDEXER_TOKEN
56
+ * const indexer = getAlgoIndexerClient()
57
+ * await indexer.makeHealthCheck().do()
58
+ * ```
59
+ * @example AlgoNode (testnet)
60
+ * ```typescript
61
+ * const indexer = getAlgoIndexerClient(getAlgoNodeConfig('testnet', 'indexer'))
62
+ * await indexer.makeHealthCheck().do()
63
+ * ```
64
+ * @example AlgoNode (mainnet)
65
+ * ```typescript
66
+ * const indexer = getAlgoIndexerClient(getAlgoNodeConfig('mainnet', 'indexer'))
67
+ * await indexer.makeHealthCheck().do()
68
+ * ```
69
+ * @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)
70
+ * ```typescript
71
+ * const indexer = getAlgoIndexerClient({server: 'http://localhost', port: '8980', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
72
+ * await indexer.makeHealthCheck().do()
73
+ * ```
74
+ */
75
+ export declare function getAlgoIndexerClient(config?: AlgoClientConfig): Indexer;
76
+ /**
77
+ * Returns a KMD SDK client that automatically retries on idempotent calls
78
+ *
79
+ * KMD client allows you to export private keys, which is useful to get the default account in a LocalNet network.
80
+ *
81
+ * @param config The config if you want to override the default (getting config from process.env)
82
+ * @example Default (load from environment variables)
83
+ *
84
+ * ```typescript
85
+ * // Uses process.env.ALGOD_SERVER, process.env.KMD_PORT (or if not specified: port 4002) and process.env.ALGOD_TOKEN
86
+ * const kmd = getAlgoKmdClient()
87
+ * ```
88
+ * @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)
89
+ * ```typescript
90
+ * const kmd = getAlgoKmdClient({server: 'http://localhost', port: '4002', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
91
+ * ```
92
+ */
93
+ export declare function getAlgoKmdClient(config?: AlgoClientConfig): Kmd;
94
+ export declare function isTestNet(algod: Algodv2): Promise<boolean>;
95
+ export declare function isMainNet(algod: Algodv2): Promise<boolean>;
96
+ export { isLocalNet } from './localnet';
20
97
  //# sourceMappingURL=network-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"network-client.d.ts","sourceRoot":"","sources":["../../src/types/network-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAA;AAEnF,wCAAwC;AACxC,MAAM,WAAW,gBAAgB;IAC/B,8FAA8F;IAC9F,MAAM,EAAE,MAAM,CAAA;IACd,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,yIAAyI;IACzI,KAAK,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;CAC7B;AAED,gCAAgC;AAChC,MAAM,WAAW,UAAU;IACzB,gCAAgC;IAChC,WAAW,EAAE,gBAAgB,CAAA;IAC7B,mCAAmC;IACnC,aAAa,EAAE,gBAAgB,CAAA;IAC/B,wBAAwB;IACxB,SAAS,EAAE,gBAAgB,CAAA;CAC5B"}
1
+ {"version":3,"file":"network-client.d.ts","sourceRoot":"","sources":["../../src/network-client.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAGxD,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAErE,uJAAuJ;AACvJ,wBAAgB,0BAA0B,IAAI,UAAU,CAwBvD;AAED,mIAAmI;AACnI,wBAAgB,6BAA6B,IAAI,gBAAgB,CAchE;AAED,qIAAqI;AACrI,wBAAgB,+BAA+B,IAAI,gBAAgB,CAclE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,EAAE,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,gBAAgB,CAK/G;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,gBAAgB,CAM7G;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAIhE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAIvE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,GAAG,CAK/D;AAED,wBAAsB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAGhE;AACD,wBAAsB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAGhE;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { Account, Algodv2, Kmd } from 'algosdk';
2
+ import { GetTestAccountParams } from '../types/testing';
3
+ /**
4
+ * Creates an ephemeral Algorand account for the purposes of testing.
5
+ * Returns a newly created random test account that is funded from the dispenser
6
+ * DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!
7
+ * Note: By default this will log the mnemonic of the account.
8
+ * @param param0 The config for the test account to generate
9
+ * @param algod An algod client
10
+ * @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables
11
+ * @returns The account, with private key loaded
12
+ */
13
+ export declare function getTestAccount({ suppressLog, initialFunds }: GetTestAccountParams, algod: Algodv2, kmd?: Kmd): Promise<Account>;
14
+ //# sourceMappingURL=account.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../src/testing/account.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAIxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAEvD;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAgBrI"}
@@ -0,0 +1,19 @@
1
+ import { AlgoKitLogCaptureFixture } from '../../types/testing';
2
+ /**
3
+ * Creates a test fixture for capturing AlgoKit logs.
4
+ *
5
+ * @example ```typescript
6
+ * const logs = algoKitLogCaptureFixture()
7
+ *
8
+ * beforeEach(logs.beforeEach)
9
+ * afterEach(logs.afterEach)
10
+ *
11
+ * test('My test', () => {
12
+ * const capturedLogs = logs.testLogger.capturedLogs
13
+ * })
14
+ * ```
15
+ *
16
+ * @returns The fixture
17
+ */
18
+ export declare const algoKitLogCaptureFixture: () => AlgoKitLogCaptureFixture;
19
+ //# sourceMappingURL=algokit-log-capture-fixture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algokit-log-capture-fixture.d.ts","sourceRoot":"","sources":["../../../../src/testing/fixtures/algokit-log-capture-fixture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAG9D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,wBAqB5C,CAAA"}
@@ -0,0 +1,48 @@
1
+ import { AlgoConfig } from '../../types/network-client';
2
+ import { AlgorandFixture, AlgorandFixtureConfig } from '../../types/testing';
3
+ /**
4
+ * Creates a test fixture for automated testing against Algorand.
5
+ * By default it tests against an environment variable specified client
6
+ * if the standard environment variables are specified, otherwise against
7
+ * a default LocalNet instance, but you can pass in an algod, indexer
8
+ * and/or kmd if you want to test against an explicitly defined network.
9
+ *
10
+ * @example ```typescript
11
+ * const algorand = algorandFixture()
12
+ *
13
+ * beforeEach(algorand.beforeEach, 10_000)
14
+ *
15
+ * test('My test', async () => {
16
+ * const {algod, indexer, testAccount, ...} = algorand.context
17
+ * // test things...
18
+ * })
19
+ * ```
20
+ *
21
+ * @param fixtureConfig The fixture configuration
22
+ * @returns The fixture
23
+ */
24
+ export declare function algorandFixture(fixtureConfig?: AlgorandFixtureConfig): AlgorandFixture;
25
+ /**
26
+ * Creates a test fixture for automated testing against Algorand.
27
+ * By default it tests against an environment variable specified client
28
+ * if the standard environment variables are specified, otherwise against
29
+ * a default LocalNet instance, but you can pass in an algod, indexer
30
+ * and/or kmd if you want to test against an explicitly defined network.
31
+ *
32
+ * @example ```typescript
33
+ * const algorand = algorandFixture(undefined, getConfigFromEnvOrDefaults())
34
+ *
35
+ * beforeEach(algorand.beforeEach, 10_000)
36
+ *
37
+ * test('My test', async () => {
38
+ * const {algod, indexer, testAccount, ...} = algorand.context
39
+ * // test things...
40
+ * })
41
+ * ```
42
+ *
43
+ * @param fixtureConfig The fixture configuration
44
+ * @param config The algo configuration
45
+ * @returns The fixture
46
+ */
47
+ export declare function algorandFixture(fixtureConfig: AlgorandFixtureConfig | undefined, config: AlgoConfig): AlgorandFixture;
48
+ //# sourceMappingURL=algorand-fixture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algorand-fixture.d.ts","sourceRoot":"","sources":["../../../../src/testing/fixtures/algorand-fixture.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAuD,MAAM,qBAAqB,CAAA;AAEjI;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,aAAa,CAAC,EAAE,qBAAqB,GAAG,eAAe,CAAA;AAEvF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAAC,aAAa,EAAE,qBAAqB,GAAG,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,eAAe,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './algokit-log-capture-fixture';
2
+ export * from './algorand-fixture';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/fixtures/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA;AAC7C,cAAc,oBAAoB,CAAA"}
@@ -0,0 +1,6 @@
1
+ export * from './account';
2
+ export * from './fixtures';
3
+ export * from './indexer';
4
+ export * from './test-logger';
5
+ export * from './transaction-logger';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Runs the given indexer call until a 404 error is no longer returned.
3
+ * Tried every 200ms up to 20 times.
4
+ * Very rudimentary implementation designed for automated testing.
5
+ * @example ```typescript
6
+ * const transaction = await runWhenIndexerCaughtUp(() => indexer.lookupTransactionByID(txnId).do())
7
+ * ```
8
+ * @param run The code to run
9
+ * @returns The result (as a promise), or throws if the indexer didn't catch up in time
10
+ */
11
+ export declare function runWhenIndexerCaughtUp<T>(run: () => Promise<T>): Promise<T>;
12
+ //# sourceMappingURL=indexer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../../../src/testing/indexer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAuBjF"}
@@ -0,0 +1,41 @@
1
+ import { Logger } from '../types/logging';
2
+ import { LogSnapshotConfig } from '../types/testing';
3
+ /** Exposes an AlgoKit logger which captures log messages, while wrapping an original logger.
4
+ * This is useful for automated testing.
5
+ */
6
+ export declare class TestLogger implements Logger {
7
+ private originalLogger;
8
+ private logs;
9
+ /**
10
+ * Create a new test logger that wraps the given logger if provided.
11
+ * @param originalLogger The optional original logger to wrap.
12
+ */
13
+ constructor(originalLogger?: Logger);
14
+ /** Returns all logs captured thus far. */
15
+ get capturedLogs(): string[];
16
+ /** Clears all logs captured so far. */
17
+ clear(): void;
18
+ /**
19
+ * Returns a captured log snapshot.
20
+ * This helps ensure that the provided configuration items won't appear
21
+ * with random values in the log snapshot, but rather will get substituted with predictable ids.
22
+ *
23
+ * https://jestjs.io/docs/snapshot-testing#2-tests-should-be-deterministic
24
+ *
25
+ * @example Jest Example
26
+ * ```typescript
27
+ * const logger = new TestLogger()
28
+ * ...
29
+ * expect(logger.getLogSnapshot()).toMatchSnapshot()
30
+ * ```
31
+ * @param config The snapshot configuration
32
+ * @returns The snapshotted logs.
33
+ */
34
+ getLogSnapshot(config?: LogSnapshotConfig): string;
35
+ error(message: string, ...optionalParams: unknown[]): void;
36
+ warn(message: string, ...optionalParams: unknown[]): void;
37
+ info(message: string, ...optionalParams: unknown[]): void;
38
+ verbose(message: string, ...optionalParams: unknown[]): void;
39
+ debug(message: string, ...optionalParams: unknown[]): void;
40
+ }
41
+ //# sourceMappingURL=test-logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-logger.d.ts","sourceRoot":"","sources":["../../../src/testing/test-logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD;;GAEG;AACH,qBAAa,UAAW,YAAW,MAAM;IACvC,OAAO,CAAC,cAAc,CAAoB;IAC1C,OAAO,CAAC,IAAI,CAAU;IAEtB;;;OAGG;gBACS,cAAc,CAAC,EAAE,MAAM;IAKnC,0CAA0C;IAC1C,IAAI,YAAY,IAAI,MAAM,EAAE,CAE3B;IAED,uCAAuC;IACvC,KAAK;IAIL;;;;;;;;;;;;;;;OAeG;IACH,cAAc,CAAC,MAAM,CAAC,EAAE,iBAAiB;IAczC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAI1D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAIzD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAIzD,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAI5D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;CAI3D"}
@@ -0,0 +1,29 @@
1
+ import { Algodv2, Indexer } from 'algosdk';
2
+ /**
3
+ * Allows you to keep track of Algorand transaction IDs by wrapping an `Algodv2` in a proxy.
4
+ * Useful for automated tests.
5
+ */
6
+ export declare class TransactionLogger {
7
+ private _sentTransactionIds;
8
+ /**
9
+ * The list of transaction IDs that has been logged thus far.
10
+ */
11
+ get sentTransactionIds(): Readonly<string[]>;
12
+ /**
13
+ * Clear all logged IDs.
14
+ */
15
+ clear(): void;
16
+ /**
17
+ * The method that captures raw transactions and stores the transaction IDs.
18
+ */
19
+ logRawTransaction(signedTransactions: Uint8Array | Uint8Array[]): void;
20
+ /** Return a proxy that wraps the given Algodv2 with this transaction logger.
21
+ *
22
+ * @param algod The `Algodv2` to wrap
23
+ * @returns The wrapped `Algodv2`, any transactions sent using this algod instance will be logged by this transaction logger
24
+ */
25
+ capture(algod: Algodv2): Algodv2;
26
+ /** Wait until all logged transactions IDs appear in the given `Indexer`. */
27
+ waitForIndexer(indexer: Indexer): Promise<void>;
28
+ }
29
+ //# sourceMappingURL=transaction-logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-logger.d.ts","sourceRoot":"","sources":["../../../src/testing/transaction-logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2B,OAAO,EAAE,MAAM,SAAS,CAAA;AAGnE;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,mBAAmB,CAAe;IAE1C;;OAEG;IACH,IAAI,kBAAkB,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC,CAE3C;IAED;;OAEG;IACH,KAAK;IAIL;;OAEG;IACH,iBAAiB,CAAC,kBAAkB,EAAE,UAAU,GAAG,UAAU,EAAE;IAY/D;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAIhC,4EAA4E;IACtE,cAAc,CAAC,OAAO,EAAE,OAAO;CAGtC"}
@@ -1,111 +1,138 @@
1
- import { Account, AtomicTransactionComposer, LogicSigAccount, Transaction, modelsv2 } from 'algosdk';
2
- import { MultisigAccount, SigningAccount, TransactionSignerAccount } from './account';
3
- import { AlgoAmount } from './amount';
4
- import { ABIReturn } from './app';
5
- export type TransactionNote = Uint8Array | TransactionNoteData | Arc2TransactionNote;
6
- export type TransactionNoteData = string | null | undefined | number | any[] | Record<string, any>;
7
- /** ARC-0002 compatible transaction note components https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0002.md */
8
- export type Arc2TransactionNote = {
9
- dAppName: string;
10
- format: 'm' | 'b' | 'u';
11
- data: string;
12
- } | {
13
- dAppName: string;
14
- format: 'j';
15
- data: TransactionNoteData;
16
- };
17
- /** The sending configuration for a transaction */
18
- export interface SendTransactionParams {
19
- /** Whether to skip signing and sending the transaction to the chain (default: transaction signed and sent to chain, unless `atc` specified)
20
- * and instead just return the raw transaction, e.g. so you can add it to a group of transactions */
21
- skipSending?: boolean;
22
- /** Whether to skip waiting for the submitted transaction (only relevant if `skipSending` is `false` or unset) */
23
- skipWaiting?: boolean;
24
- /** An optional `AtomicTransactionComposer` to add the transaction to, if specified then `skipSending: undefined` has the same effect as `skipSending: true` */
25
- atc?: AtomicTransactionComposer;
26
- /** Whether to suppress log messages from transaction send, default: do not suppress */
27
- suppressLog?: boolean;
28
- /** The flat fee you want to pay, useful for covering extra fees in a transaction group or app call */
29
- fee?: AlgoAmount;
30
- /** The maximum fee that you are happy to pay (default: unbounded) - if this is set it's possible the transaction could get rejected during network congestion */
31
- maxFee?: AlgoAmount;
32
- /** The maximum number of rounds to wait for confirmation, only applies if `skipWaiting` is `undefined` or `false`, default: wait up to 5 rounds */
33
- maxRoundsToWaitForConfirmation?: number;
34
- }
35
- /** The result of sending a transaction */
36
- export interface SendTransactionResult {
37
- /** The transaction */
38
- transaction: Transaction;
39
- /** The response if the transaction was sent and waited for */
40
- confirmation?: modelsv2.PendingTransactionResponse;
41
- }
42
- /** The result of preparing and/or sending multiple transactions */
43
- export interface SendTransactionResults {
44
- /** The transactions that have been prepared and/or sent */
45
- transactions: Transaction[];
46
- /** The responses if the transactions were sent and waited for,
47
- * the index of the confirmation will match the index of the underlying transaction
48
- */
49
- confirmations?: modelsv2.PendingTransactionResponse[];
50
- }
51
- /** The result of preparing and/or sending multiple transactions using an `AtomicTransactionComposer` */
52
- export interface SendAtomicTransactionComposerResults extends SendTransactionResults {
53
- /** base64 encoded representation of the group ID of the atomic group */
54
- groupId: string;
55
- /** The transaction IDs that have been prepared and/or sent */
56
- txIds: string[];
57
- /** If ABI method(s) were called the processed return values */
58
- returns?: ABIReturn[];
59
- }
60
- /** The result of sending and confirming a transaction */
61
- export interface ConfirmedTransactionResult extends SendTransactionResult {
62
- /** The response from sending and waiting for the transaction */
63
- confirmation: modelsv2.PendingTransactionResponse;
64
- }
65
- /** The result of sending and confirming one or more transactions, but where there is a primary transaction of interest */
66
- export interface ConfirmedTransactionResults extends SendTransactionResult, SendTransactionResults {
67
- /** The response from sending and waiting for the primary transaction */
68
- confirmation: modelsv2.PendingTransactionResponse;
69
- /** The response from sending and waiting for the transactions */
70
- confirmations: modelsv2.PendingTransactionResponse[];
71
- }
72
- /** Core account abstraction when signing/sending transactions
1
+ import algosdk, { Algodv2, AtomicTransactionComposer, modelsv2, SuggestedParams, Transaction, TransactionWithSigner } from 'algosdk';
2
+ import { AlgoAmount } from './types/amount';
3
+ import { AtomicTransactionComposerToSend, SendAtomicTransactionComposerResults, SendTransactionFrom, SendTransactionParams, SendTransactionResult, TransactionGroupToSend, TransactionNote, TransactionToSign } from './types/transaction';
4
+ /** Encodes a transaction note into a byte array ready to be included in an Algorand transaction.
5
+ *
6
+ * @param note The transaction note
7
+ * @returns the transaction note ready for inclusion in a transaction
8
+ *
9
+ * Case on the value of `data` this either be:
10
+ * * `null` | `undefined`: `undefined`
11
+ * * `string`: The string value
12
+ * * Uint8Array: passthrough
13
+ * * Arc2TransactionNote object: ARC-0002 compatible transaction note
14
+ * * Else: The object/value converted into a JSON string representation
15
+ */
16
+ export declare function encodeTransactionNote(note?: TransactionNote): Uint8Array | undefined;
17
+ /**
18
+ * Returns the public address of the given transaction sender.
19
+ * @param sender A transaction sender
20
+ * @returns The public address
21
+ */
22
+ export declare const getSenderAddress: (sender: SendTransactionFrom) => string;
23
+ /**
24
+ * Given a transaction in a variety of supported formats, returns a TransactionWithSigner object ready to be passed to an
25
+ * AtomicTransactionComposer's addTransaction method.
26
+ * @param transaction One of: A TransactionWithSigner object (returned as is), a TransactionToSign object (signer is obtained from the
27
+ * signer property), a Transaction object (signer is extracted from the defaultSender parameter), an async SendTransactionResult returned by
28
+ * one of algokit utils' helpers (signer is obtained from the defaultSender parameter)
29
+ * @param defaultSender The default sender to be used to obtain a signer where the object provided to the transaction parameter does not
30
+ * include a signer.
31
+ * @returns A TransactionWithSigner object.
32
+ */
33
+ export declare const getTransactionWithSigner: (transaction: TransactionWithSigner | TransactionToSign | Transaction | Promise<SendTransactionResult>, defaultSender?: SendTransactionFrom) => Promise<TransactionWithSigner>;
34
+ /**
35
+ * Returns a `TransactionSigner` for the given transaction sender.
36
+ * This function has memoization, so will return the same transaction signer for a given sender.
37
+ * @param sender A transaction sender
38
+ * @returns A transaction signer
39
+ */
40
+ export declare const getSenderTransactionSigner: (val: SendTransactionFrom) => algosdk.TransactionSigner;
41
+ /**
42
+ * Signs a single transaction by the given signer.
43
+ * @param transaction The transaction to sign
44
+ * @param signer The signer to sign
45
+ * @returns The signed transaction as a `Uint8Array`
46
+ */
47
+ export declare const signTransaction: (transaction: Transaction, signer: SendTransactionFrom) => Promise<Uint8Array>;
48
+ /** Prepares a transaction for sending and then (if instructed) signs and sends the given transaction to the chain.
49
+ *
50
+ * @param send The details for the transaction to prepare/send, including:
51
+ * * `transaction`: The unsigned transaction
52
+ * * `from`: The account to sign the transaction with: either an account with private key loaded or a logic signature account
53
+ * * `config`: The sending configuration for this transaction
54
+ * @param algod An algod client
73
55
  *
74
- * This type is used across the entire AlgoKit Utils library and allows you to pass through
75
- * many types of accounts, including:
76
- * * `Account` - The in-built `algosdk.Account` type for mnemonic accounts
77
- * * `SigningAccount` - An AlgoKit Utils class that wraps Account to provide support for rekeyed accounts
78
- * * `LogicSigAccount` - The in-built `algosdk.LogicSigAccount` type for logic signatures
79
- * * `MultisigAccount` - An AlgoKit Utils class that wraps a multisig account and provides mechanisms to get a multisig account
80
- * * `TransactionSignerAccount` - An AlgoKitUtils class that wraps the in-built `algosdk.TransactionSigner` along with the sender address
56
+ * @returns An object with transaction (`transaction`) and (if `skipWaiting` is `false` or `undefined`) confirmation (`confirmation`)
81
57
  */
82
- export type SendTransactionFrom = Account | SigningAccount | LogicSigAccount | MultisigAccount | TransactionSignerAccount;
83
- /** Defines an unsigned transaction that will appear in a group of transactions along with its signing information */
84
- export interface TransactionToSign {
85
- /** The unsigned transaction to sign and send */
58
+ export declare const sendTransaction: (send: {
86
59
  transaction: Transaction;
87
- /** The account to use to sign the transaction, either an account (with private key loaded) or a logic signature account */
88
- signer: SendTransactionFrom;
89
- }
90
- /** A group of transactions to send together as an atomic group
91
- * https://developer.algorand.org/docs/get-details/atomic_transfers/
60
+ from: SendTransactionFrom;
61
+ sendParams?: SendTransactionParams;
62
+ }, algod: Algodv2) => Promise<SendTransactionResult>;
63
+ /**
64
+ * Signs and sends transactions that have been collected by an `AtomicTransactionComposer`.
65
+ * @param atcSend The parameters controlling the send, including:
66
+ * * `atc` The `AtomicTransactionComposer`
67
+ * * `sendParams` The parameters to control the send behaviour
68
+ * @param algod An algod client
69
+ * @returns An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)
70
+ */
71
+ export declare const sendAtomicTransactionComposer: (atcSend: AtomicTransactionComposerToSend, algod: Algodv2) => Promise<SendAtomicTransactionComposerResults>;
72
+ /**
73
+ * Performs a dry run of the transactions loaded into the given AtomicTransactionComposer`
74
+ * @param atc The AtomicTransactionComposer` with transaction(s) loaded
75
+ * @param algod An Algod client
76
+ * @returns The dryrun result
77
+ */
78
+ export declare function performAtomicTransactionComposerDryrun(atc: AtomicTransactionComposer, algod: Algodv2): Promise<algosdk.DryrunResult>;
79
+ /**
80
+ * Signs and sends a group of [up to 16](https://developer.algorand.org/docs/get-details/atomic_transfers/#create-transactions) transactions to the chain
81
+ *
82
+ * @param groupSend The group details to send, with:
83
+ * * `transactions`: The array of transactions to send along with their signing account
84
+ * * `sendParams`: The parameters to dictate how the group is sent
85
+ * @param algod An algod client
86
+ * @returns An object with transaction IDs, transactions, group transaction ID (`groupTransactionId`) if more than 1 transaction sent, and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)
87
+ */
88
+ export declare const sendGroupOfTransactions: (groupSend: TransactionGroupToSend, algod: Algodv2) => Promise<Omit<SendAtomicTransactionComposerResults, "returns">>;
89
+ /**
90
+ * Wait until the transaction is confirmed or rejected, or until `timeout`
91
+ * number of rounds have passed.
92
+ *
93
+ * @param algod An algod client
94
+ * @param transactionId The transaction ID to wait for
95
+ * @param maxRoundsToWait Maximum number of rounds to wait
96
+ *
97
+ * @return Pending transaction information
98
+ * @throws Throws an error if the transaction is not confirmed or rejected in the next `timeout` rounds
99
+ */
100
+ export declare const waitForConfirmation: (transactionId: string, maxRoundsToWait: number | bigint, algod: Algodv2) => Promise<modelsv2.PendingTransactionResponse>;
101
+ /**
102
+ * Limit the acceptable fee to a defined amount of µALGOs.
103
+ * This also sets the transaction to be flatFee to ensure the transaction only succeeds at
104
+ * the estimated rate.
105
+ * @param transaction The transaction to cap or suggested params object about to be used to create a transaction
106
+ * @param maxAcceptableFee The maximum acceptable fee to pay
107
+ */
108
+ export declare function capTransactionFee(transaction: algosdk.Transaction | SuggestedParams, maxAcceptableFee: AlgoAmount): void;
109
+ /**
110
+ * Allows for control of fees on a `Transaction` or `SuggestedParams` object
111
+ * @param transaction The transaction or suggested params
112
+ * @param feeControl The fee control parameters
113
+ */
114
+ export declare function controlFees<T extends SuggestedParams | Transaction>(transaction: T, feeControl: {
115
+ fee?: AlgoAmount;
116
+ maxFee?: AlgoAmount;
117
+ }): T;
118
+ /**
119
+ * Returns suggested transaction parameters from algod unless some are already provided.
120
+ * @param params Optionally provide parameters to use
121
+ * @param algod Algod algod
122
+ * @returns The suggested transaction parameters
123
+ */
124
+ export declare function getTransactionParams(params: SuggestedParams | undefined, algod: Algodv2): Promise<import("algosdk/dist/types/types/transactions/base").SuggestedParamsWithMinFee | {
125
+ flatFee?: boolean | undefined;
126
+ fee: number;
127
+ firstRound: number;
128
+ lastRound: number;
129
+ genesisID: string;
130
+ genesisHash: string;
131
+ }>;
132
+ /**
133
+ * Returns the array of transactions currently present in the given `AtomicTransactionComposer`
134
+ * @param atc The atomic transaction composer
135
+ * @returns The array of transactions with signers
92
136
  */
93
- export interface TransactionGroupToSend {
94
- /** Any parameters to control the semantics of the send to the network */
95
- sendParams?: Omit<SendTransactionParams, 'fee' | 'maxFee' | 'skipSending' | 'atc'>;
96
- /** The list of transactions to send, which can either be a raw transaction (in which case `signer` is required),
97
- * the async result of an AlgoKit utils method that returns a `SendTransactionResult` (saves unwrapping the promise, be sure to pass `skipSending: true`, `signer` is also required)
98
- * or the transaction with its signer (`signer` is ignored)
99
- **/
100
- transactions: (TransactionToSign | Transaction | Promise<SendTransactionResult>)[];
101
- /** Optional signer to pass in, required if at least one transaction provided is just the transaction, ignored otherwise */
102
- signer?: SendTransactionFrom;
103
- }
104
- /** An `AtomicTransactionComposer` with transactions to send. */
105
- export interface AtomicTransactionComposerToSend {
106
- /** The `AtomicTransactionComposer` with transactions loaded to send */
107
- atc: AtomicTransactionComposer;
108
- /** Any parameters to control the semantics of the send to the network */
109
- sendParams?: Omit<SendTransactionParams, 'fee' | 'maxFee' | 'skipSending' | 'atc'>;
110
- }
137
+ export declare function getAtomicTransactionComposerTransactions(atc: AtomicTransactionComposer): algosdk.TransactionWithSigner[];
111
138
  //# sourceMappingURL=transaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../src/types/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACpG,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,MAAM,MAAM,eAAe,GAAG,UAA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