algosdk 1.24.1 → 2.1.0

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 (222) hide show
  1. package/README.md +4 -4
  2. package/dist/browser/algosdk.min.js +1 -1
  3. package/dist/browser/algosdk.min.js.LICENSE.txt +0 -18
  4. package/dist/browser/algosdk.min.js.map +1 -1
  5. package/dist/cjs/abi/abi_type.js +6 -5
  6. package/dist/cjs/abi/abi_type.js.map +1 -1
  7. package/dist/cjs/bid.js +6 -5
  8. package/dist/cjs/bid.js.map +1 -1
  9. package/dist/cjs/client/client.js +4 -3
  10. package/dist/cjs/client/client.js.map +1 -1
  11. package/dist/cjs/client/kmd.js +12 -11
  12. package/dist/cjs/client/kmd.js.map +1 -1
  13. package/dist/cjs/client/urlTokenBaseHTTPClient.js +2 -1
  14. package/dist/cjs/client/urlTokenBaseHTTPClient.js.map +1 -1
  15. package/dist/cjs/client/v2/algod/algod.js +17 -1
  16. package/dist/cjs/client/v2/algod/algod.js.map +1 -1
  17. package/dist/cjs/client/v2/algod/compile.js +2 -1
  18. package/dist/cjs/client/v2/algod/compile.js.map +1 -1
  19. package/dist/cjs/client/v2/algod/disassemble.js +46 -0
  20. package/dist/cjs/client/v2/algod/disassemble.js.map +1 -0
  21. package/dist/cjs/client/v2/algod/dryrun.js +2 -1
  22. package/dist/cjs/client/v2/algod/dryrun.js.map +1 -1
  23. package/dist/cjs/client/v2/algod/getApplicationBoxByName.js +2 -1
  24. package/dist/cjs/client/v2/algod/getApplicationBoxByName.js.map +1 -1
  25. package/dist/cjs/client/v2/algod/models/types.js +182 -143
  26. package/dist/cjs/client/v2/algod/models/types.js.map +1 -1
  27. package/dist/cjs/client/v2/algod/sendRawTransaction.js +2 -1
  28. package/dist/cjs/client/v2/algod/sendRawTransaction.js.map +1 -1
  29. package/dist/cjs/client/v2/basemodel.js +3 -2
  30. package/dist/cjs/client/v2/basemodel.js.map +1 -1
  31. package/dist/cjs/client/v2/indexer/lookupAccountTransactions.js +2 -1
  32. package/dist/cjs/client/v2/indexer/lookupAccountTransactions.js.map +1 -1
  33. package/dist/cjs/client/v2/indexer/lookupApplicationBoxByIDandName.js +2 -1
  34. package/dist/cjs/client/v2/indexer/lookupApplicationBoxByIDandName.js.map +1 -1
  35. package/dist/cjs/client/v2/indexer/lookupAssetTransactions.js +0 -7
  36. package/dist/cjs/client/v2/indexer/lookupAssetTransactions.js.map +1 -1
  37. package/dist/cjs/client/v2/indexer/models/types.js +39 -38
  38. package/dist/cjs/client/v2/indexer/models/types.js.map +1 -1
  39. package/dist/cjs/composer.js +7 -6
  40. package/dist/cjs/composer.js.map +1 -1
  41. package/dist/cjs/dryrun.js +22 -12
  42. package/dist/cjs/dryrun.js.map +1 -1
  43. package/dist/cjs/encoding/address.js +2 -1
  44. package/dist/cjs/encoding/address.js.map +1 -1
  45. package/dist/cjs/encoding/bigint.js +2 -1
  46. package/dist/cjs/encoding/bigint.js.map +1 -1
  47. package/dist/cjs/encoding/uint64.js +14 -8
  48. package/dist/cjs/encoding/uint64.js.map +1 -1
  49. package/dist/cjs/group.js +6 -5
  50. package/dist/cjs/group.js.map +1 -1
  51. package/dist/cjs/logicsig.js +24 -21
  52. package/dist/cjs/logicsig.js.map +1 -1
  53. package/dist/cjs/main.js +8 -9
  54. package/dist/cjs/main.js.map +1 -1
  55. package/dist/cjs/makeTxn.js +1 -193
  56. package/dist/cjs/makeTxn.js.map +1 -1
  57. package/dist/cjs/multisig.js +6 -5
  58. package/dist/cjs/multisig.js.map +1 -1
  59. package/dist/cjs/transaction.js +64 -63
  60. package/dist/cjs/transaction.js.map +1 -1
  61. package/dist/cjs/types/transactions/encoded.js +0 -3
  62. package/dist/cjs/types/transactions/encoded.js.map +1 -1
  63. package/dist/cjs/utils/utils.js +5 -1
  64. package/dist/cjs/utils/utils.js.map +1 -1
  65. package/dist/esm/abi/abi_type.js +1 -0
  66. package/dist/esm/abi/abi_type.js.map +1 -1
  67. package/dist/esm/bid.js +1 -0
  68. package/dist/esm/bid.js.map +1 -1
  69. package/dist/esm/client/client.js +1 -0
  70. package/dist/esm/client/client.js.map +1 -1
  71. package/dist/esm/client/kmd.js +1 -0
  72. package/dist/esm/client/kmd.js.map +1 -1
  73. package/dist/esm/client/urlTokenBaseHTTPClient.js +1 -0
  74. package/dist/esm/client/urlTokenBaseHTTPClient.js.map +1 -1
  75. package/dist/esm/client/v2/algod/algod.js +17 -1
  76. package/dist/esm/client/v2/algod/algod.js.map +1 -1
  77. package/dist/esm/client/v2/algod/compile.js +1 -0
  78. package/dist/esm/client/v2/algod/compile.js.map +1 -1
  79. package/dist/esm/client/v2/algod/disassemble.js +38 -0
  80. package/dist/esm/client/v2/algod/disassemble.js.map +1 -0
  81. package/dist/esm/client/v2/algod/dryrun.js +1 -0
  82. package/dist/esm/client/v2/algod/dryrun.js.map +1 -1
  83. package/dist/esm/client/v2/algod/getApplicationBoxByName.js +1 -0
  84. package/dist/esm/client/v2/algod/getApplicationBoxByName.js.map +1 -1
  85. package/dist/esm/client/v2/algod/models/types.js +161 -120
  86. package/dist/esm/client/v2/algod/models/types.js.map +1 -1
  87. package/dist/esm/client/v2/algod/sendRawTransaction.js +1 -0
  88. package/dist/esm/client/v2/algod/sendRawTransaction.js.map +1 -1
  89. package/dist/esm/client/v2/basemodel.js +1 -0
  90. package/dist/esm/client/v2/basemodel.js.map +1 -1
  91. package/dist/esm/client/v2/indexer/lookupAccountTransactions.js +1 -0
  92. package/dist/esm/client/v2/indexer/lookupAccountTransactions.js.map +1 -1
  93. package/dist/esm/client/v2/indexer/lookupApplicationBoxByIDandName.js +1 -0
  94. package/dist/esm/client/v2/indexer/lookupApplicationBoxByIDandName.js.map +1 -1
  95. package/dist/esm/client/v2/indexer/lookupAssetTransactions.js +0 -7
  96. package/dist/esm/client/v2/indexer/lookupAssetTransactions.js.map +1 -1
  97. package/dist/esm/client/v2/indexer/models/types.js +1 -0
  98. package/dist/esm/client/v2/indexer/models/types.js.map +1 -1
  99. package/dist/esm/composer.js +5 -4
  100. package/dist/esm/composer.js.map +1 -1
  101. package/dist/esm/dryrun.js +17 -7
  102. package/dist/esm/dryrun.js.map +1 -1
  103. package/dist/esm/encoding/address.js +1 -0
  104. package/dist/esm/encoding/address.js.map +1 -1
  105. package/dist/esm/encoding/bigint.js +1 -0
  106. package/dist/esm/encoding/bigint.js.map +1 -1
  107. package/dist/esm/encoding/uint64.js +14 -8
  108. package/dist/esm/encoding/uint64.js.map +1 -1
  109. package/dist/esm/group.js +1 -0
  110. package/dist/esm/group.js.map +1 -1
  111. package/dist/esm/logicsig.js +15 -12
  112. package/dist/esm/logicsig.js.map +1 -1
  113. package/dist/esm/main.js +2 -4
  114. package/dist/esm/main.js.map +1 -1
  115. package/dist/esm/makeTxn.js +0 -185
  116. package/dist/esm/makeTxn.js.map +1 -1
  117. package/dist/esm/multisig.js +1 -0
  118. package/dist/esm/multisig.js.map +1 -1
  119. package/dist/esm/transaction.js +1 -0
  120. package/dist/esm/transaction.js.map +1 -1
  121. package/dist/esm/types/transactions/encoded.js +0 -3
  122. package/dist/esm/types/transactions/encoded.js.map +1 -1
  123. package/dist/esm/utils/utils.js +5 -1
  124. package/dist/esm/utils/utils.js.map +1 -1
  125. package/dist/types/client/v2/algod/algod.d.ts +15 -1
  126. package/dist/types/client/v2/algod/disassemble.d.ts +20 -0
  127. package/dist/types/client/v2/algod/models/types.d.ts +122 -67
  128. package/dist/types/client/v2/basemodel.d.ts +0 -3
  129. package/dist/types/client/v2/indexer/lookupAssetTransactions.d.ts +0 -4
  130. package/dist/types/composer.d.ts +7 -1
  131. package/dist/types/logicsig.d.ts +10 -10
  132. package/dist/types/main.d.ts +1 -3
  133. package/dist/types/makeTxn.d.ts +1 -147
  134. package/dist/types/types/transactions/encoded.d.ts +1 -16
  135. package/package.json +2 -3
  136. package/src/abi/abi_type.ts +1 -0
  137. package/src/bid.ts +1 -0
  138. package/src/client/client.ts +1 -0
  139. package/src/client/kmd.ts +1 -0
  140. package/src/client/urlTokenBaseHTTPClient.ts +1 -0
  141. package/src/client/v2/algod/algod.ts +19 -2
  142. package/src/client/v2/algod/compile.ts +1 -0
  143. package/src/client/v2/algod/disassemble.ts +46 -0
  144. package/src/client/v2/algod/dryrun.ts +1 -0
  145. package/src/client/v2/algod/getApplicationBoxByName.ts +1 -0
  146. package/src/client/v2/algod/models/types.ts +319 -249
  147. package/src/client/v2/algod/sendRawTransaction.ts +1 -0
  148. package/src/client/v2/basemodel.ts +2 -0
  149. package/src/client/v2/indexer/lookupAccountTransactions.ts +1 -0
  150. package/src/client/v2/indexer/lookupApplicationBoxByIDandName.ts +1 -0
  151. package/src/client/v2/indexer/lookupAssetTransactions.ts +0 -8
  152. package/src/client/v2/indexer/models/types.ts +1 -0
  153. package/src/composer.ts +16 -3
  154. package/src/dryrun.ts +14 -13
  155. package/src/encoding/address.ts +1 -0
  156. package/src/encoding/bigint.ts +2 -0
  157. package/src/encoding/uint64.ts +16 -10
  158. package/src/group.ts +1 -0
  159. package/src/logicsig.ts +26 -13
  160. package/src/main.ts +3 -5
  161. package/src/makeTxn.ts +0 -421
  162. package/src/multisig.ts +1 -0
  163. package/src/transaction.ts +1 -0
  164. package/src/types/transactions/encoded.ts +2 -17
  165. package/src/utils/utils.ts +3 -0
  166. package/dist/cjs/client/algod.js +0 -295
  167. package/dist/cjs/client/algod.js.map +0 -1
  168. package/dist/cjs/logic/langspec.json +0 -2014
  169. package/dist/cjs/logic/logic.js +0 -262
  170. package/dist/cjs/logic/logic.js.map +0 -1
  171. package/dist/cjs/logicTemplates/dynamicfee.js +0 -192
  172. package/dist/cjs/logicTemplates/dynamicfee.js.map +0 -1
  173. package/dist/cjs/logicTemplates/htlc.js +0 -145
  174. package/dist/cjs/logicTemplates/htlc.js.map +0 -1
  175. package/dist/cjs/logicTemplates/index.js +0 -19
  176. package/dist/cjs/logicTemplates/index.js.map +0 -1
  177. package/dist/cjs/logicTemplates/limitorder.js +0 -167
  178. package/dist/cjs/logicTemplates/limitorder.js.map +0 -1
  179. package/dist/cjs/logicTemplates/periodicpayment.js +0 -163
  180. package/dist/cjs/logicTemplates/periodicpayment.js.map +0 -1
  181. package/dist/cjs/logicTemplates/split.js +0 -154
  182. package/dist/cjs/logicTemplates/split.js.map +0 -1
  183. package/dist/cjs/logicTemplates/templates.js +0 -67
  184. package/dist/cjs/logicTemplates/templates.js.map +0 -1
  185. package/dist/esm/client/algod.js +0 -295
  186. package/dist/esm/client/algod.js.map +0 -1
  187. package/dist/esm/logic/langspec.json +0 -2014
  188. package/dist/esm/logic/logic.js +0 -249
  189. package/dist/esm/logic/logic.js.map +0 -1
  190. package/dist/esm/logicTemplates/dynamicfee.js +0 -192
  191. package/dist/esm/logicTemplates/dynamicfee.js.map +0 -1
  192. package/dist/esm/logicTemplates/htlc.js +0 -145
  193. package/dist/esm/logicTemplates/htlc.js.map +0 -1
  194. package/dist/esm/logicTemplates/index.js +0 -19
  195. package/dist/esm/logicTemplates/index.js.map +0 -1
  196. package/dist/esm/logicTemplates/limitorder.js +0 -167
  197. package/dist/esm/logicTemplates/limitorder.js.map +0 -1
  198. package/dist/esm/logicTemplates/periodicpayment.js +0 -163
  199. package/dist/esm/logicTemplates/periodicpayment.js.map +0 -1
  200. package/dist/esm/logicTemplates/split.js +0 -154
  201. package/dist/esm/logicTemplates/split.js.map +0 -1
  202. package/dist/esm/logicTemplates/templates.js +0 -67
  203. package/dist/esm/logicTemplates/templates.js.map +0 -1
  204. package/dist/types/client/algod.d.ts +0 -162
  205. package/dist/types/logic/logic.d.ts +0 -45
  206. package/dist/types/logicTemplates/dynamicfee.d.ts +0 -59
  207. package/dist/types/logicTemplates/htlc.d.ts +0 -51
  208. package/dist/types/logicTemplates/index.d.ts +0 -16
  209. package/dist/types/logicTemplates/limitorder.d.ts +0 -70
  210. package/dist/types/logicTemplates/periodicpayment.d.ts +0 -58
  211. package/dist/types/logicTemplates/split.d.ts +0 -57
  212. package/dist/types/logicTemplates/templates.d.ts +0 -6
  213. package/src/client/algod.js +0 -365
  214. package/src/logic/langspec.json +0 -2014
  215. package/src/logic/logic.ts +0 -316
  216. package/src/logicTemplates/dynamicfee.js +0 -219
  217. package/src/logicTemplates/htlc.js +0 -165
  218. package/src/logicTemplates/index.js +0 -20
  219. package/src/logicTemplates/limitorder.js +0 -227
  220. package/src/logicTemplates/periodicpayment.js +0 -208
  221. package/src/logicTemplates/split.js +0 -208
  222. package/src/logicTemplates/templates.js +0 -78
@@ -1,365 +0,0 @@
1
- const { default: HTTPClient } = require('./client');
2
- const { setSendTransactionHeaders } = require('./v2/algod/sendRawTransaction');
3
-
4
- /** @deprecated v1 algod APIs are deprecated, please use the v2 client */
5
- function Algod(
6
- token = '',
7
- baseServer = 'http://r2.algorand.network',
8
- port = 4180,
9
- headers = {}
10
- ) {
11
- // workaround to allow backwards compatibility for multiple headers
12
- let tokenHeader = token;
13
- if (typeof tokenHeader === 'string') {
14
- tokenHeader = { 'X-Algo-API-Token': tokenHeader };
15
- }
16
-
17
- // Get client
18
- const c = new HTTPClient(tokenHeader, baseServer, port, headers);
19
-
20
- /**
21
- * Takes an object and convert its note field to Buffer, if exist.
22
- * @param o
23
- * @returns {*}
24
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
25
- */
26
- function noteb64ToNote(o) {
27
- if (!(o.noteb64 === undefined || o.noteb64 === null)) {
28
- // eslint-disable-next-line no-param-reassign
29
- o.note = Buffer.from(o.noteb64, 'base64');
30
- }
31
- return o;
32
- }
33
-
34
- /**
35
- * status retrieves the StatusResponse from the running node
36
- * @param headerObj, optional
37
- * @returns {Promise<*>}
38
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
39
- */
40
- this.status = async (headerObj = {}) => {
41
- const res = await c.get('/v1/status', {}, headerObj);
42
- return res.body;
43
- };
44
-
45
- /**
46
- * healthCheck returns an empty object iff the node is running
47
- * @param headerObj, optional
48
- * @returns {Promise<*>}
49
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
50
- */
51
- this.healthCheck = async (headerObj = {}) => {
52
- const res = await c.get('/health', {}, headerObj);
53
- if (!res.ok) {
54
- throw new Error(`Health response: ${res.status}`);
55
- }
56
- return {};
57
- };
58
-
59
- /**
60
- * statusAfterBlock waits for round roundNumber to occur then returns the StatusResponse for this round.
61
- * This call blocks
62
- * @param roundNumber
63
- * @param headerObj, optional
64
- * @returns {Promise<*>}
65
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
66
- */
67
- this.statusAfterBlock = async (roundNumber, headerObj = {}) => {
68
- if (!Number.isInteger(roundNumber))
69
- throw Error('roundNumber should be an integer');
70
- const res = await c.get(
71
- `/v1/status/wait-for-block-after/${roundNumber}`,
72
- {},
73
- headerObj
74
- );
75
- return res.body;
76
- };
77
-
78
- /**
79
- * pendingTransactions asks algod for a snapshot of current pending txns on the node, bounded by maxTxns.
80
- * If maxTxns = 0, fetches as many transactions as possible.
81
- * @param maxTxns - number
82
- * @param headerObj, optional
83
- * @returns {Promise<*>}
84
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
85
- */
86
- this.pendingTransactions = async (maxTxns, headerObj = {}) => {
87
- if (!Number.isInteger(maxTxns)) throw Error('maxTxns should be an integer');
88
- const res = await c.get(
89
- '/v1/transactions/pending',
90
- { max: maxTxns },
91
- headerObj
92
- );
93
- if (
94
- res.statusCode === 200 &&
95
- res.body.truncatedTxns.transactions !== undefined
96
- ) {
97
- for (let i = 0; i < res.body.truncatedTxns.transactions.length; i++) {
98
- res.body.truncatedTxns.transactions[i] = noteb64ToNote(
99
- res.body.truncatedTxns.transactions[i]
100
- );
101
- }
102
- }
103
- return res.body;
104
- };
105
-
106
- /**
107
- * versions retrieves the VersionResponse from the running node
108
- * @param headerObj, optional
109
- * @returns {Promise<*>}
110
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
111
- */
112
- this.versions = async (headerObj = {}) => {
113
- const res = await c.get('/versions', {}, headerObj);
114
- return res.body;
115
- };
116
-
117
- /**
118
- * LedgerSupply gets the supply details for the specified node's Ledger
119
- * @param headerObj, optional
120
- * @returns {Promise<*>}
121
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
122
- */
123
- this.ledgerSupply = async (headerObj = {}) => {
124
- const res = await c.get('/v1/ledger/supply', {}, headerObj);
125
- return res.body;
126
- };
127
-
128
- /**
129
- * transactionsByAddress returns all transactions for a PK [addr] in the [first, last] rounds range.
130
- * @param addr - string
131
- * @param first - number, optional
132
- * @param last - number, optional
133
- * @param maxTxns - number, optional
134
- * @param headers, optional
135
- * @returns {Promise<*>}
136
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
137
- */
138
- this.transactionByAddress = async (
139
- addr,
140
- first = null,
141
- last = null,
142
- maxTxns = null,
143
- headerObj = {}
144
- ) => {
145
- if (first !== null && !Number.isInteger(first)) {
146
- throw Error('first round should be an integer');
147
- }
148
- if (last !== null && !Number.isInteger(last)) {
149
- throw Error('last round should be an integer');
150
- }
151
- const res = await c.get(
152
- `/v1/account/${addr}/transactions`,
153
- { firstRound: first, lastRound: last, max: maxTxns },
154
- headerObj
155
- );
156
- if (res.statusCode === 200 && res.body.transactions !== undefined) {
157
- for (let i = 0; i < res.body.transactions.length; i++) {
158
- res.body.transactions[i] = noteb64ToNote(res.body.transactions[i]);
159
- }
160
- }
161
- return res.body;
162
- };
163
-
164
- /**
165
- * transactionsByAddressAndDate returns all transactions for a PK [addr] in the [fromDate, toDate] date range.
166
- * The date is a string in the YYYY-MM-DD format.
167
- * @param addr - string
168
- * @param fromDate - string
169
- * @param toDate - string
170
- * @param maxTxns - number, optional
171
- * @param headerObj, optional
172
- * @returns {Promise<*>}
173
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
174
- */
175
- this.transactionByAddressAndDate = async (
176
- addr,
177
- fromDate,
178
- toDate,
179
- maxTxns = null,
180
- headerObj = {}
181
- ) => {
182
- const res = await c.get(
183
- `/v1/account/${addr}/transactions`,
184
- { fromDate, toDate, max: maxTxns },
185
- headerObj
186
- );
187
- if (res.statusCode === 200 && res.body.transactions !== undefined) {
188
- for (let i = 0; i < res.body.transactions.length; i++) {
189
- res.body.transactions[i] = noteb64ToNote(res.body.transactions[i]);
190
- }
191
- }
192
- return res.body;
193
- };
194
-
195
- /**
196
- * transactionById returns the a transaction information of a specific txid [txId]
197
- * Note - This method is allowed only when Indexer is enabled.
198
- * @param txid
199
- * @param headerObj, optional
200
- * @returns {Promise<*>}
201
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
202
- */
203
- this.transactionById = async (txid, headerObj = {}) => {
204
- const res = await c.get(`/v1/transaction/${txid}`, {}, headerObj);
205
- if (res.statusCode === 200) {
206
- res.body = noteb64ToNote(res.body);
207
- }
208
- return res.body;
209
- };
210
-
211
- /**
212
- * transactionInformation returns the transaction information of a specific txid and an address
213
- * @param addr
214
- * @param txid
215
- * @param headerObj, optional
216
- * @returns {Promise<*>}
217
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
218
- */
219
- this.transactionInformation = async (addr, txid, headerObj = {}) => {
220
- const res = await c.get(
221
- `/v1/account/${addr}/transaction/${txid}`,
222
- {},
223
- headerObj
224
- );
225
- if (res.statusCode === 200) {
226
- res.body = noteb64ToNote(res.body);
227
- }
228
- return res.body;
229
- };
230
-
231
- /**
232
- * pendingTransactionInformation returns the transaction information for a specific txid of a pending transaction
233
- * @param txid
234
- * @param headerObj, optional
235
- * @returns {Promise<*>}
236
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
237
- */
238
- this.pendingTransactionInformation = async (txid, headerObj = {}) => {
239
- const res = await c.get(`/v1/transactions/pending/${txid}`, {}, headerObj);
240
- if (res.statusCode === 200) {
241
- res.body = noteb64ToNote(res.body);
242
- }
243
- return res.body;
244
- };
245
-
246
- /**
247
- * accountInformation returns the passed account's information
248
- * @param addr - string
249
- * @param headerObj, optional
250
- * @returns {Promise<*>}
251
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
252
- */
253
- this.accountInformation = async (addr, headerObj = {}) => {
254
- const res = await c.get(`/v1/account/${addr}`, {}, headerObj);
255
- return res.body;
256
- };
257
-
258
- /**
259
- * assetInformation returns the information for the asset with the passed creator and index
260
- * @param index - number
261
- * @param headerObj, optional
262
- * @returns {Promise<*>}
263
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
264
- */
265
- this.assetInformation = async (index, headerObj = {}) => {
266
- const res = await c.get(`/v1/asset/${index}`, {}, headerObj);
267
- return res.body;
268
- };
269
-
270
- /**
271
- * suggestedFee gets the recommended transaction fee from the node
272
- * @param headerObj, optional
273
- * @returns {Promise<*>}
274
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
275
- */
276
- this.suggestedFee = async (headerObj = {}) => {
277
- const res = await c.get('/v1/transactions/fee', {}, headerObj);
278
- return res.body;
279
- };
280
-
281
- /**
282
- * sendRawTransaction gets an encoded SignedTxn and broadcasts it to the network
283
- * @param txn - Uin8Array
284
- * @param headerObj, optional
285
- * @returns {Promise<*>}
286
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
287
- */
288
- this.sendRawTransaction = async (txn, headerObj = {}) => {
289
- const txHeaders = setSendTransactionHeaders(headerObj);
290
- const res = await c.post('/v1/transactions', Buffer.from(txn), txHeaders);
291
- return res.body;
292
- };
293
-
294
- /**
295
- * sendRawTransactions gets a list of encoded SignedTxns and broadcasts it to the network
296
- * @param txn - Array of Uin8Array
297
- * @param headerObj, optional
298
- * @returns {Promise<*>}
299
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
300
- */
301
- this.sendRawTransactions = async (txns, headerObj = {}) => {
302
- const txHeaders = setSendTransactionHeaders(headerObj);
303
- const merged = Array.prototype.concat(
304
- ...txns.map((arr) => Array.from(arr))
305
- );
306
- const res = await c.post(
307
- '/v1/transactions',
308
- Buffer.from(merged),
309
- txHeaders
310
- );
311
- return res.body;
312
- };
313
-
314
- /**
315
- * getTransactionParams returns to common needed parameters for a new transaction
316
- * @param headerObj, optional
317
- * @returns {Promise<*>}
318
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
319
- */
320
- this.getTransactionParams = async (headerObj = {}) => {
321
- const res = await c.get('/v1/transactions/params', {}, headerObj);
322
- return res.body;
323
- };
324
-
325
- /**
326
- * suggestParams returns to common needed parameters for a new transaction, in a format the transaction builder expects
327
- * @param headerObj, optional
328
- * @returns {Object}
329
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
330
- */
331
- this.suggestParams = async (headerObj = {}) => {
332
- const result = await this.getTransactionParams(headerObj);
333
- return {
334
- flatFee: false,
335
- fee: result.fee,
336
- firstRound: result.lastRound,
337
- lastRound: result.lastRound + 1000,
338
- genesisID: result.genesisID,
339
- genesisHash: result.genesishashb64,
340
- };
341
- };
342
-
343
- /**
344
- * block gets the block info for the given round This call blocks
345
- * @param roundNumber
346
- * @param headerObj, optional
347
- * @returns {Promise<*>}
348
- * @deprecated v1 algod APIs are deprecated, please use the v2 client
349
- */
350
- this.block = async (roundNumber, headerObj = {}) => {
351
- if (!Number.isInteger(roundNumber))
352
- throw Error('roundNumber should be an integer');
353
- const res = await c.get(`/v1/block/${roundNumber}`, {}, headerObj);
354
- if (res.statusCode === 200 && res.body.txns.transactions !== undefined) {
355
- for (let i = 0; i < res.body.txns.transactions.length; i++) {
356
- res.body.txns.transactions[i] = noteb64ToNote(
357
- res.body.txns.transactions[i]
358
- );
359
- }
360
- }
361
- return res.body;
362
- };
363
- }
364
-
365
- module.exports = { Algod };