@alephium/web3 0.0.3 → 0.1.0-rc.2

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 (144) hide show
  1. package/.editorconfig +13 -0
  2. package/.eslintignore +2 -0
  3. package/.eslintrc.json +21 -0
  4. package/README.md +2 -2
  5. package/contracts/add.ral +7 -3
  6. package/contracts/greeter.ral +3 -1
  7. package/contracts/greeter_interface.ral +3 -0
  8. package/contracts/greeter_main.ral +9 -0
  9. package/contracts/main.ral +3 -5
  10. package/dev/user.conf +8 -4
  11. package/dist/alephium-web3.min.js +1 -1
  12. package/dist/alephium-web3.min.js.map +1 -1
  13. package/dist/scripts/check-versions.d.ts +1 -0
  14. package/dist/scripts/check-versions.js +39 -0
  15. package/dist/{cli → scripts}/create-project.d.ts +0 -0
  16. package/dist/scripts/create-project.js +124 -0
  17. package/dist/scripts/header.d.ts +0 -0
  18. package/dist/scripts/header.js +18 -0
  19. package/dist/scripts/rename-gitignore.d.ts +1 -0
  20. package/dist/scripts/rename-gitignore.js +24 -0
  21. package/dist/scripts/start-devnet.d.ts +1 -0
  22. package/dist/scripts/start-devnet.js +131 -0
  23. package/dist/scripts/stop-devnet.d.ts +1 -0
  24. package/dist/scripts/stop-devnet.js +32 -0
  25. package/dist/{api → src/api}/api-alephium.d.ts +287 -168
  26. package/dist/{api → src/api}/api-alephium.js +497 -115
  27. package/dist/{api → src/api}/api-explorer.d.ts +117 -19
  28. package/dist/{api → src/api}/api-explorer.js +206 -46
  29. package/dist/src/api/index.d.ts +10 -0
  30. package/dist/src/api/index.js +55 -0
  31. package/dist/{lib → src}/constants.d.ts +0 -0
  32. package/dist/{lib → src}/constants.js +0 -0
  33. package/dist/src/contract/contract.d.ts +182 -0
  34. package/dist/src/contract/contract.js +760 -0
  35. package/dist/src/contract/events.d.ts +29 -0
  36. package/dist/src/contract/events.js +77 -0
  37. package/dist/src/contract/index.d.ts +3 -0
  38. package/dist/src/contract/index.js +32 -0
  39. package/dist/src/contract/ralph.d.ts +12 -0
  40. package/dist/src/contract/ralph.js +362 -0
  41. package/dist/src/index.d.ts +5 -0
  42. package/dist/src/index.js +34 -0
  43. package/dist/src/signer/index.d.ts +2 -0
  44. package/dist/src/signer/index.js +31 -0
  45. package/dist/src/signer/node-wallet.d.ts +13 -0
  46. package/dist/src/signer/node-wallet.js +60 -0
  47. package/dist/src/signer/signer.d.ts +143 -0
  48. package/dist/src/signer/signer.js +184 -0
  49. package/dist/src/test/index.d.ts +7 -0
  50. package/dist/src/test/index.js +41 -0
  51. package/dist/src/test/privatekey-wallet.d.ts +12 -0
  52. package/dist/src/test/privatekey-wallet.js +68 -0
  53. package/dist/{lib → src/utils}/address.d.ts +0 -0
  54. package/dist/{lib → src/utils}/address.js +1 -1
  55. package/dist/{lib → src/utils}/bs58.d.ts +2 -2
  56. package/dist/{lib → src/utils}/bs58.js +3 -1
  57. package/dist/{lib → src/utils}/djb2.d.ts +0 -0
  58. package/dist/{lib → src/utils}/djb2.js +1 -1
  59. package/dist/src/utils/index.d.ts +6 -0
  60. package/dist/src/utils/index.js +35 -0
  61. package/dist/{lib → src/utils}/password-crypto.d.ts +0 -0
  62. package/dist/{lib → src/utils}/password-crypto.js +8 -7
  63. package/dist/src/utils/transaction.d.ts +2 -0
  64. package/dist/src/utils/transaction.js +58 -0
  65. package/dist/src/utils/utils.d.ts +30 -0
  66. package/dist/{lib → src/utils}/utils.js +83 -19
  67. package/gitignore +5 -4
  68. package/package.json +55 -41
  69. package/scripts/create-project.ts +136 -0
  70. package/scripts/header.js +17 -0
  71. package/scripts/start-devnet.js +3 -3
  72. package/src/api/api-alephium.ts +2323 -0
  73. package/src/api/api-explorer.ts +808 -0
  74. package/src/api/index.ts +35 -0
  75. package/src/constants.ts +20 -0
  76. package/src/contract/contract.ts +1014 -0
  77. package/src/contract/events.ts +102 -0
  78. package/src/contract/index.ts +21 -0
  79. package/src/contract/ralph.test.ts +178 -0
  80. package/src/contract/ralph.ts +362 -0
  81. package/src/fixtures/address.json +36 -0
  82. package/src/fixtures/balance.json +9 -0
  83. package/src/fixtures/self-clique.json +19 -0
  84. package/src/fixtures/transaction.json +13 -0
  85. package/src/fixtures/transactions.json +179 -0
  86. package/src/index.ts +24 -0
  87. package/src/signer/fixtures/genesis.json +26 -0
  88. package/src/signer/fixtures/wallets.json +26 -0
  89. package/src/signer/index.ts +20 -0
  90. package/src/signer/node-wallet.ts +74 -0
  91. package/src/signer/signer.ts +313 -0
  92. package/src/test/index.ts +32 -0
  93. package/src/test/privatekey-wallet.ts +58 -0
  94. package/src/utils/address.test.ts +47 -0
  95. package/src/utils/address.ts +39 -0
  96. package/src/utils/bs58.ts +26 -0
  97. package/src/utils/djb2.test.ts +35 -0
  98. package/src/utils/djb2.ts +25 -0
  99. package/src/utils/index.ts +24 -0
  100. package/src/utils/password-crypto.test.ts +27 -0
  101. package/src/utils/password-crypto.ts +77 -0
  102. package/src/utils/transaction.test.ts +50 -0
  103. package/src/utils/transaction.ts +39 -0
  104. package/src/utils/utils.test.ts +160 -0
  105. package/src/utils/utils.ts +209 -0
  106. package/templates/{README.md → base/README.md} +4 -4
  107. package/templates/base/package.json +35 -0
  108. package/templates/base/src/greeter.ts +41 -0
  109. package/templates/base/tsconfig.json +19 -0
  110. package/templates/react/README.md +34 -0
  111. package/templates/react/config-overrides.js +18 -0
  112. package/templates/react/package.json +66 -0
  113. package/templates/react/src/App.tsx +42 -0
  114. package/templates/react/src/artifacts/greeter.ral.json +26 -0
  115. package/templates/react/src/artifacts/greeter_main.ral.json +22 -0
  116. package/templates/shared/.eslintrc.json +12 -0
  117. package/templates/shared/scripts/header.js +0 -0
  118. package/test/contract.test.ts +161 -0
  119. package/test/events.test.ts +139 -0
  120. package/webpack.config.js +1 -1
  121. package/contracts/greeter-main.ral +0 -8
  122. package/dist/cli/create-project.js +0 -87
  123. package/dist/lib/clique.d.ts +0 -23
  124. package/dist/lib/clique.js +0 -149
  125. package/dist/lib/contract.d.ts +0 -152
  126. package/dist/lib/contract.js +0 -711
  127. package/dist/lib/explorer.d.ts +0 -8
  128. package/dist/lib/explorer.js +0 -46
  129. package/dist/lib/index.d.ts +0 -12
  130. package/dist/lib/index.js +0 -60
  131. package/dist/lib/node.d.ts +0 -10
  132. package/dist/lib/node.js +0 -64
  133. package/dist/lib/numbers.d.ts +0 -7
  134. package/dist/lib/numbers.js +0 -128
  135. package/dist/lib/signer.d.ts +0 -17
  136. package/dist/lib/signer.js +0 -70
  137. package/dist/lib/storage-browser.d.ts +0 -9
  138. package/dist/lib/storage-browser.js +0 -52
  139. package/dist/lib/storage-node.d.ts +0 -9
  140. package/dist/lib/storage-node.js +0 -65
  141. package/dist/lib/utils.d.ts +0 -11
  142. package/dist/lib/wallet.d.ts +0 -30
  143. package/dist/lib/wallet.js +0 -142
  144. package/templates/package.json +0 -29
@@ -9,29 +9,17 @@
9
9
  * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
10
10
  * ---------------------------------------------------------------
11
11
  */
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __rest = (this && this.__rest) || function (s, e) {
22
- var t = {};
23
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
24
- t[p] = s[p];
25
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
26
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
27
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
28
- t[p[i]] = s[p[i]];
29
- }
30
- return t;
31
- };
32
12
  Object.defineProperty(exports, "__esModule", { value: true });
33
13
  exports.Api = exports.HttpClient = exports.ContentType = void 0;
34
14
  require("cross-fetch/polyfill");
15
+ function convertHttpResponse(response) {
16
+ if (response.error) {
17
+ throw new Error(response.error.detail);
18
+ }
19
+ else {
20
+ return response.data;
21
+ }
22
+ }
35
23
  var ContentType;
36
24
  (function (ContentType) {
37
25
  ContentType["Json"] = "application/json";
@@ -85,23 +73,30 @@ class HttpClient {
85
73
  this.abortControllers.delete(cancelToken);
86
74
  }
87
75
  };
88
- this.request = (_a) => __awaiter(this, void 0, void 0, function* () {
89
- var { body, secure, path, type, query, format, baseUrl, cancelToken } = _a, params = __rest(_a, ["body", "secure", "path", "type", "query", "format", "baseUrl", "cancelToken"]);
76
+ this.request = async ({ body, secure, path, type, query, format, baseUrl, cancelToken, ...params }) => {
90
77
  const secureParams = ((typeof secure === 'boolean' ? secure : this.baseApiParams.secure) &&
91
78
  this.securityWorker &&
92
- (yield this.securityWorker(this.securityData))) ||
79
+ (await this.securityWorker(this.securityData))) ||
93
80
  {};
94
81
  const requestParams = this.mergeRequestParams(params, secureParams);
95
82
  const queryString = query && this.toQueryString(query);
96
83
  const payloadFormatter = this.contentFormatters[type || ContentType.Json];
97
84
  const responseFormat = format || requestParams.format;
98
- return this.customFetch(`${baseUrl || this.baseUrl || ''}${path}${queryString ? `?${queryString}` : ''}`, Object.assign(Object.assign({}, requestParams), { headers: Object.assign(Object.assign({}, (type && type !== ContentType.FormData ? { 'Content-Type': type } : {})), (requestParams.headers || {})), signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, body: typeof body === 'undefined' || body === null ? null : payloadFormatter(body) })).then((response) => __awaiter(this, void 0, void 0, function* () {
85
+ return this.customFetch(`${baseUrl || this.baseUrl || ''}${path}${queryString ? `?${queryString}` : ''}`, {
86
+ ...requestParams,
87
+ headers: {
88
+ ...(type && type !== ContentType.FormData ? { 'Content-Type': type } : {}),
89
+ ...(requestParams.headers || {})
90
+ },
91
+ signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0,
92
+ body: typeof body === 'undefined' || body === null ? null : payloadFormatter(body)
93
+ }).then(async (response) => {
99
94
  const r = response;
100
95
  r.data = null;
101
96
  r.error = null;
102
97
  const data = !responseFormat
103
98
  ? r
104
- : yield response[responseFormat]()
99
+ : await response[responseFormat]()
105
100
  .then((data) => {
106
101
  if (r.ok) {
107
102
  r.data = data;
@@ -121,8 +116,8 @@ class HttpClient {
121
116
  if (!response.ok)
122
117
  throw data;
123
118
  return data;
124
- }));
125
- });
119
+ });
120
+ };
126
121
  Object.assign(this, apiConfig);
127
122
  }
128
123
  encodeQueryParam(key, value) {
@@ -148,7 +143,16 @@ class HttpClient {
148
143
  return queryString ? `?${queryString}` : '';
149
144
  }
150
145
  mergeRequestParams(params1, params2) {
151
- return Object.assign(Object.assign(Object.assign(Object.assign({}, this.baseApiParams), params1), (params2 || {})), { headers: Object.assign(Object.assign(Object.assign({}, (this.baseApiParams.headers || {})), (params1.headers || {})), ((params2 && params2.headers) || {})) });
146
+ return {
147
+ ...this.baseApiParams,
148
+ ...params1,
149
+ ...(params2 || {}),
150
+ headers: {
151
+ ...(this.baseApiParams.headers || {}),
152
+ ...(params1.headers || {}),
153
+ ...((params2 && params2.headers) || {})
154
+ }
155
+ };
152
156
  }
153
157
  }
154
158
  exports.HttpClient = HttpClient;
@@ -167,7 +171,13 @@ class Api extends HttpClient {
167
171
  * @name GetBlocks
168
172
  * @request GET:/blocks
169
173
  */
170
- getBlocks: (query, params = {}) => this.request(Object.assign({ path: `/blocks`, method: 'GET', query: query, format: 'json' }, params)),
174
+ getBlocks: (query, params = {}) => this.request({
175
+ path: `/blocks`,
176
+ method: 'GET',
177
+ query: query,
178
+ format: 'json',
179
+ ...params
180
+ }).then(convertHttpResponse),
171
181
  /**
172
182
  * @description Get a block with hash
173
183
  *
@@ -175,7 +185,12 @@ class Api extends HttpClient {
175
185
  * @name GetBlocksBlockHash
176
186
  * @request GET:/blocks/{block-hash}
177
187
  */
178
- getBlocksBlockHash: (blockHash, params = {}) => this.request(Object.assign({ path: `/blocks/${blockHash}`, method: 'GET', format: 'json' }, params)),
188
+ getBlocksBlockHash: (blockHash, params = {}) => this.request({
189
+ path: `/blocks/${blockHash}`,
190
+ method: 'GET',
191
+ format: 'json',
192
+ ...params
193
+ }).then(convertHttpResponse),
179
194
  /**
180
195
  * @description Get block's transactions
181
196
  *
@@ -183,7 +198,13 @@ class Api extends HttpClient {
183
198
  * @name GetBlocksBlockHashTransactions
184
199
  * @request GET:/blocks/{block-hash}/transactions
185
200
  */
186
- getBlocksBlockHashTransactions: (blockHash, query, params = {}) => this.request(Object.assign({ path: `/blocks/${blockHash}/transactions`, method: 'GET', query: query, format: 'json' }, params))
201
+ getBlocksBlockHashTransactions: (blockHash, query, params = {}) => this.request({
202
+ path: `/blocks/${blockHash}/transactions`,
203
+ method: 'GET',
204
+ query: query,
205
+ format: 'json',
206
+ ...params
207
+ }).then(convertHttpResponse)
187
208
  };
188
209
  this.transactions = {
189
210
  /**
@@ -193,25 +214,67 @@ class Api extends HttpClient {
193
214
  * @name GetTransactionsTransactionHash
194
215
  * @request GET:/transactions/{transaction-hash}
195
216
  */
196
- getTransactionsTransactionHash: (transactionHash, params = {}) => this.request(Object.assign({ path: `/transactions/${transactionHash}`, method: 'GET', format: 'json' }, params))
217
+ getTransactionsTransactionHash: (transactionHash, params = {}) => this.request({
218
+ path: `/transactions/${transactionHash}`,
219
+ method: 'GET',
220
+ format: 'json',
221
+ ...params
222
+ }).then(convertHttpResponse)
197
223
  };
198
224
  this.addresses = {
199
225
  /**
200
226
  * @description Get address information
201
227
  *
202
- * @tags Addressess
228
+ * @tags Addresses
203
229
  * @name GetAddressesAddress
204
230
  * @request GET:/addresses/{address}
205
231
  */
206
- getAddressesAddress: (address, params = {}) => this.request(Object.assign({ path: `/addresses/${address}`, method: 'GET', format: 'json' }, params)),
232
+ getAddressesAddress: (address, params = {}) => this.request({
233
+ path: `/addresses/${address}`,
234
+ method: 'GET',
235
+ format: 'json',
236
+ ...params
237
+ }).then(convertHttpResponse),
207
238
  /**
208
239
  * @description List transactions of a given address
209
240
  *
210
- * @tags Addressess
241
+ * @tags Addresses
211
242
  * @name GetAddressesAddressTransactions
212
243
  * @request GET:/addresses/{address}/transactions
213
244
  */
214
- getAddressesAddressTransactions: (address, query, params = {}) => this.request(Object.assign({ path: `/addresses/${address}/transactions`, method: 'GET', query: query, format: 'json' }, params))
245
+ getAddressesAddressTransactions: (address, query, params = {}) => this.request({
246
+ path: `/addresses/${address}/transactions`,
247
+ method: 'GET',
248
+ query: query,
249
+ format: 'json',
250
+ ...params
251
+ }).then(convertHttpResponse),
252
+ /**
253
+ * @description Get total transactions of a given address
254
+ *
255
+ * @tags Addresses
256
+ * @name GetAddressesAddressTotalTransactions
257
+ * @request GET:/addresses/{address}/total-transactions
258
+ */
259
+ getAddressesAddressTotalTransactions: (address, params = {}) => this.request({
260
+ path: `/addresses/${address}/total-transactions`,
261
+ method: 'GET',
262
+ format: 'json',
263
+ ...params
264
+ }).then(convertHttpResponse),
265
+ /**
266
+ * @description Get address balance
267
+ *
268
+ * @tags Addresses
269
+ * @name GetAddressesAddressBalance
270
+ * @request GET:/addresses/{address}/balance
271
+ */
272
+ getAddressesAddressBalance: (address, params = {}) => this.request({
273
+ path: `/addresses/${address}/balance`,
274
+ method: 'GET',
275
+ format: 'json',
276
+ ...params
277
+ }).then(convertHttpResponse)
215
278
  };
216
279
  this.infos = {
217
280
  /**
@@ -221,7 +284,12 @@ class Api extends HttpClient {
221
284
  * @name GetInfos
222
285
  * @request GET:/infos
223
286
  */
224
- getInfos: (params = {}) => this.request(Object.assign({ path: `/infos`, method: 'GET', format: 'json' }, params)),
287
+ getInfos: (params = {}) => this.request({
288
+ path: `/infos`,
289
+ method: 'GET',
290
+ format: 'json',
291
+ ...params
292
+ }).then(convertHttpResponse),
225
293
  /**
226
294
  * @description List latest height for each chain
227
295
  *
@@ -229,7 +297,12 @@ class Api extends HttpClient {
229
297
  * @name GetInfosHeights
230
298
  * @request GET:/infos/heights
231
299
  */
232
- getInfosHeights: (params = {}) => this.request(Object.assign({ path: `/infos/heights`, method: 'GET', format: 'json' }, params)),
300
+ getInfosHeights: (params = {}) => this.request({
301
+ path: `/infos/heights`,
302
+ method: 'GET',
303
+ format: 'json',
304
+ ...params
305
+ }).then(convertHttpResponse),
233
306
  /**
234
307
  * @description Get token supply list
235
308
  *
@@ -237,7 +310,13 @@ class Api extends HttpClient {
237
310
  * @name GetInfosSupply
238
311
  * @request GET:/infos/supply
239
312
  */
240
- getInfosSupply: (query, params = {}) => this.request(Object.assign({ path: `/infos/supply`, method: 'GET', query: query, format: 'json' }, params)),
313
+ getInfosSupply: (query, params = {}) => this.request({
314
+ path: `/infos/supply`,
315
+ method: 'GET',
316
+ query: query,
317
+ format: 'json',
318
+ ...params
319
+ }).then(convertHttpResponse),
241
320
  /**
242
321
  * @description Get the ALPH total supply
243
322
  *
@@ -245,7 +324,11 @@ class Api extends HttpClient {
245
324
  * @name GetInfosSupplyTotalAlph
246
325
  * @request GET:/infos/supply/total-alph
247
326
  */
248
- getInfosSupplyTotalAlph: (params = {}) => this.request(Object.assign({ path: `/infos/supply/total-alph`, method: 'GET' }, params)),
327
+ getInfosSupplyTotalAlph: (params = {}) => this.request({
328
+ path: `/infos/supply/total-alph`,
329
+ method: 'GET',
330
+ ...params
331
+ }).then(convertHttpResponse),
249
332
  /**
250
333
  * @description Get the ALPH circulating supply
251
334
  *
@@ -253,7 +336,35 @@ class Api extends HttpClient {
253
336
  * @name GetInfosSupplyCirculatingAlph
254
337
  * @request GET:/infos/supply/circulating-alph
255
338
  */
256
- getInfosSupplyCirculatingAlph: (params = {}) => this.request(Object.assign({ path: `/infos/supply/circulating-alph`, method: 'GET' }, params)),
339
+ getInfosSupplyCirculatingAlph: (params = {}) => this.request({
340
+ path: `/infos/supply/circulating-alph`,
341
+ method: 'GET',
342
+ ...params
343
+ }).then(convertHttpResponse),
344
+ /**
345
+ * @description Get the ALPH reserved supply
346
+ *
347
+ * @tags Infos
348
+ * @name GetInfosSupplyReservedAlph
349
+ * @request GET:/infos/supply/reserved-alph
350
+ */
351
+ getInfosSupplyReservedAlph: (params = {}) => this.request({
352
+ path: `/infos/supply/reserved-alph`,
353
+ method: 'GET',
354
+ ...params
355
+ }).then(convertHttpResponse),
356
+ /**
357
+ * @description Get the ALPH locked supply
358
+ *
359
+ * @tags Infos
360
+ * @name GetInfosSupplyLockedAlph
361
+ * @request GET:/infos/supply/locked-alph
362
+ */
363
+ getInfosSupplyLockedAlph: (params = {}) => this.request({
364
+ path: `/infos/supply/locked-alph`,
365
+ method: 'GET',
366
+ ...params
367
+ }).then(convertHttpResponse),
257
368
  /**
258
369
  * @description Get the total number of transactions
259
370
  *
@@ -261,7 +372,11 @@ class Api extends HttpClient {
261
372
  * @name GetInfosTotalTransactions
262
373
  * @request GET:/infos/total-transactions
263
374
  */
264
- getInfosTotalTransactions: (params = {}) => this.request(Object.assign({ path: `/infos/total-transactions`, method: 'GET' }, params)),
375
+ getInfosTotalTransactions: (params = {}) => this.request({
376
+ path: `/infos/total-transactions`,
377
+ method: 'GET',
378
+ ...params
379
+ }).then(convertHttpResponse),
265
380
  /**
266
381
  * @description Get the average block time for each chain
267
382
  *
@@ -269,7 +384,12 @@ class Api extends HttpClient {
269
384
  * @name GetInfosAverageBlockTimes
270
385
  * @request GET:/infos/average-block-times
271
386
  */
272
- getInfosAverageBlockTimes: (params = {}) => this.request(Object.assign({ path: `/infos/average-block-times`, method: 'GET', format: 'json' }, params))
387
+ getInfosAverageBlockTimes: (params = {}) => this.request({
388
+ path: `/infos/average-block-times`,
389
+ method: 'GET',
390
+ format: 'json',
391
+ ...params
392
+ }).then(convertHttpResponse)
273
393
  };
274
394
  this.charts = {
275
395
  /**
@@ -277,10 +397,46 @@ class Api extends HttpClient {
277
397
  *
278
398
  * @tags Charts
279
399
  * @name GetChartsHashrates
280
- * @summary Get explorer informations.
400
+ * @summary Get hashrate chart in H/s
281
401
  * @request GET:/charts/hashrates
282
402
  */
283
- getChartsHashrates: (query, params = {}) => this.request(Object.assign({ path: `/charts/hashrates`, method: 'GET', query: query, format: 'json' }, params))
403
+ getChartsHashrates: (query, params = {}) => this.request({
404
+ path: `/charts/hashrates`,
405
+ method: 'GET',
406
+ query: query,
407
+ format: 'json',
408
+ ...params
409
+ }).then(convertHttpResponse),
410
+ /**
411
+ * @description `interval-type` query param: hourly, daily
412
+ *
413
+ * @tags Charts
414
+ * @name GetChartsTransactionsCount
415
+ * @summary Get transaction count history
416
+ * @request GET:/charts/transactions-count
417
+ */
418
+ getChartsTransactionsCount: (query, params = {}) => this.request({
419
+ path: `/charts/transactions-count`,
420
+ method: 'GET',
421
+ query: query,
422
+ format: 'json',
423
+ ...params
424
+ }).then(convertHttpResponse),
425
+ /**
426
+ * @description `interval-type` query param: hourly, daily
427
+ *
428
+ * @tags Charts
429
+ * @name GetChartsTransactionsCountPerChain
430
+ * @summary Get transaction count history per chain
431
+ * @request GET:/charts/transactions-count-per-chain
432
+ */
433
+ getChartsTransactionsCountPerChain: (query, params = {}) => this.request({
434
+ path: `/charts/transactions-count-per-chain`,
435
+ method: 'GET',
436
+ query: query,
437
+ format: 'json',
438
+ ...params
439
+ }).then(convertHttpResponse)
284
440
  };
285
441
  this.utils = {
286
442
  /**
@@ -290,7 +446,11 @@ class Api extends HttpClient {
290
446
  * @name PutUtilsSanityCheck
291
447
  * @request PUT:/utils/sanity-check
292
448
  */
293
- putUtilsSanityCheck: (params = {}) => this.request(Object.assign({ path: `/utils/sanity-check`, method: 'PUT' }, params))
449
+ putUtilsSanityCheck: (params = {}) => this.request({
450
+ path: `/utils/sanity-check`,
451
+ method: 'PUT',
452
+ ...params
453
+ }).then(convertHttpResponse)
294
454
  };
295
455
  }
296
456
  }
@@ -0,0 +1,10 @@
1
+ import { Api as NodeApi } from './api-alephium';
2
+ import { Api as ExplorerApi } from './api-explorer';
3
+ export declare class NodeProvider extends NodeApi<null> {
4
+ constructor(baseUrl: string);
5
+ }
6
+ export declare class ExplorerProvider extends ExplorerApi<null> {
7
+ constructor(baseUrl: string);
8
+ }
9
+ export * as node from './api-alephium';
10
+ export * as explorer from './api-explorer';
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 - 2022 The Alephium Authors
4
+ This file is part of the alephium project.
5
+
6
+ The library is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ The library is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with the library. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
22
+ }) : (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ o[k2] = m[k];
25
+ }));
26
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
27
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
28
+ }) : function(o, v) {
29
+ o["default"] = v;
30
+ });
31
+ var __importStar = (this && this.__importStar) || function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.explorer = exports.node = exports.ExplorerProvider = exports.NodeProvider = void 0;
40
+ const api_alephium_1 = require("./api-alephium");
41
+ const api_explorer_1 = require("./api-explorer");
42
+ class NodeProvider extends api_alephium_1.Api {
43
+ constructor(baseUrl) {
44
+ super({ baseUrl: baseUrl });
45
+ }
46
+ }
47
+ exports.NodeProvider = NodeProvider;
48
+ class ExplorerProvider extends api_explorer_1.Api {
49
+ constructor(baseUrl) {
50
+ super({ baseUrl: baseUrl });
51
+ }
52
+ }
53
+ exports.ExplorerProvider = ExplorerProvider;
54
+ exports.node = __importStar(require("./api-alephium"));
55
+ exports.explorer = __importStar(require("./api-explorer"));
File without changes
File without changes
@@ -0,0 +1,182 @@
1
+ import { NodeProvider } from '../api';
2
+ import { node } from '../api';
3
+ import { SignDeployContractTxParams, SignExecuteScriptTxParams, SignerWithNodeProvider } from '../signer';
4
+ export declare abstract class Common {
5
+ readonly sourceCodeSha256: string;
6
+ readonly functions: node.FunctionSig[];
7
+ static readonly importRegex: RegExp;
8
+ static readonly contractRegex: RegExp;
9
+ static readonly interfaceRegex: RegExp;
10
+ static readonly scriptRegex: RegExp;
11
+ private static _artifactCache;
12
+ static artifactCacheCapacity: number;
13
+ protected static _getArtifactFromCache(codeHash: string): Contract | Script | undefined;
14
+ protected static _putArtifactToCache(contract: Contract): void;
15
+ constructor(sourceCodeSha256: string, functions: node.FunctionSig[]);
16
+ protected static _contractPath(fileName: string): string;
17
+ protected static _artifactPath(fileName: string): string;
18
+ protected static _artifactsFolder(): string;
19
+ protected static _handleImports(contractStr: string, importsCache: string[]): Promise<string>;
20
+ protected static _loadContractStr(fileName: string, importsCache: string[], validate: (fileName: string) => void): Promise<string>;
21
+ static checkFileNameExtension(fileName: string): void;
22
+ protected static _from<T extends {
23
+ sourceCodeSha256: string;
24
+ }>(provider: NodeProvider, fileName: string, loadContractStr: (fileName: string, importsCache: string[]) => Promise<string>, compile: (provider: NodeProvider, fileName: string, contractStr: string, contractHash: string) => Promise<T>): Promise<T>;
25
+ protected _saveToFile(fileName: string): Promise<void>;
26
+ abstract buildByteCodeToDeploy(initialFields?: Fields): string;
27
+ }
28
+ export declare class Contract extends Common {
29
+ readonly bytecode: string;
30
+ readonly codeHash: string;
31
+ readonly fieldsSig: node.FieldsSig;
32
+ readonly eventsSig: node.EventSig[];
33
+ constructor(sourceCodeSha256: string, bytecode: string, codeHash: string, fieldsSig: node.FieldsSig, eventsSig: node.EventSig[], functions: node.FunctionSig[]);
34
+ static checkCodeType(fileName: string, contractStr: string): void;
35
+ private static loadContractStr;
36
+ static fromSource(provider: NodeProvider, fileName: string): Promise<Contract>;
37
+ private static compile;
38
+ static fromJson(artifact: any): Contract;
39
+ static fromArtifactFile(fileName: string): Promise<Contract>;
40
+ toString(): string;
41
+ toState(fields: Fields, asset: Asset, address?: string): ContractState;
42
+ static randomAddress(): string;
43
+ private _test;
44
+ testPublicMethod(provider: NodeProvider, funcName: string, params: TestContractParams): Promise<TestContractResult>;
45
+ testPrivateMethod(provider: NodeProvider, funcName: string, params: TestContractParams): Promise<TestContractResult>;
46
+ toApiFields(fields?: Fields): node.Val[];
47
+ toApiArgs(funcName: string, args?: Arguments): node.Val[];
48
+ getMethodIndex(funcName: string): number;
49
+ toApiContractStates(states?: ContractState[]): node.ContractState[] | undefined;
50
+ toTestContract(funcName: string, params: TestContractParams): node.TestContract;
51
+ static fromCodeHash(codeHash: string): Promise<Contract>;
52
+ static getFieldsSig(state: node.ContractState): Promise<node.FieldsSig>;
53
+ fromApiContractState(state: node.ContractState): Promise<ContractState>;
54
+ static ContractCreatedEvent: node.EventSig;
55
+ static ContractDestroyedEvent: node.EventSig;
56
+ static fromApiEvent(event: node.ContractEventByTxId, codeHash: string | undefined): Promise<ContractEventByTxId>;
57
+ fromTestContractResult(methodIndex: number, result: node.TestContractResult): Promise<TestContractResult>;
58
+ paramsForDeployment(params: BuildDeployContractTx): Promise<SignDeployContractTxParams>;
59
+ transactionForDeployment(signer: SignerWithNodeProvider, params: Omit<BuildDeployContractTx, 'signerAddress'>): Promise<DeployContractTransaction>;
60
+ buildByteCodeToDeploy(initialFields: Fields): string;
61
+ }
62
+ export declare class Script extends Common {
63
+ readonly bytecodeTemplate: string;
64
+ readonly fieldsSig: node.FieldsSig;
65
+ constructor(sourceCodeSha256: string, bytecodeTemplate: string, fieldsSig: node.FieldsSig, functions: node.FunctionSig[]);
66
+ static checkCodeType(fileName: string, contractStr: string): void;
67
+ private static loadContractStr;
68
+ static fromSource(provider: NodeProvider, fileName: string): Promise<Script>;
69
+ private static compile;
70
+ static fromJson(artifact: any): Script;
71
+ static fromArtifactFile(fileName: string): Promise<Script>;
72
+ toString(): string;
73
+ paramsForDeployment(params: BuildExecuteScriptTx): Promise<SignExecuteScriptTxParams>;
74
+ transactionForDeployment(signer: SignerWithNodeProvider, params: Omit<BuildExecuteScriptTx, 'signerAddress'>): Promise<BuildScriptTxResult>;
75
+ buildByteCodeToDeploy(initialFields: Fields): string;
76
+ }
77
+ export declare type Number256 = number | bigint | string;
78
+ export declare type Val = Number256 | boolean | string | Val[];
79
+ export declare type NamedVals = Record<string, Val>;
80
+ export declare type Fields = NamedVals;
81
+ export declare type Arguments = NamedVals;
82
+ export declare function extractArray(tpe: string, v: Val): node.Val;
83
+ export declare function toApiVal(v: Val, tpe: string): node.Val;
84
+ export interface Asset {
85
+ alphAmount: Number256;
86
+ tokens?: Token[];
87
+ }
88
+ export interface Token {
89
+ id: string;
90
+ amount: Number256;
91
+ }
92
+ export interface InputAsset {
93
+ address: string;
94
+ asset: Asset;
95
+ }
96
+ export interface ContractState {
97
+ address: string;
98
+ contractId: string;
99
+ bytecode: string;
100
+ initialStateHash?: string;
101
+ codeHash: string;
102
+ fields: Fields;
103
+ fieldsSig: node.FieldsSig;
104
+ asset: Asset;
105
+ }
106
+ export interface TestContractParams {
107
+ group?: number;
108
+ address?: string;
109
+ initialFields?: Fields;
110
+ initialAsset?: Asset;
111
+ testMethodIndex?: number;
112
+ testArgs?: Arguments;
113
+ existingContracts?: ContractState[];
114
+ inputAssets?: InputAsset[];
115
+ }
116
+ export interface ContractEvent {
117
+ blockHash: string;
118
+ txId: string;
119
+ name: string;
120
+ fields: Fields;
121
+ }
122
+ export interface ContractEventByTxId {
123
+ blockHash: string;
124
+ contractAddress: string;
125
+ name: string;
126
+ fields: Fields;
127
+ }
128
+ export interface TestContractResult {
129
+ address: string;
130
+ contractId: string;
131
+ returns: Val[];
132
+ gasUsed: number;
133
+ contracts: ContractState[];
134
+ txOutputs: Output[];
135
+ events: ContractEventByTxId[];
136
+ }
137
+ export declare type Output = AssetOutput | ContractOutput;
138
+ export interface AssetOutput extends Asset {
139
+ type: string;
140
+ address: string;
141
+ lockTime: number;
142
+ message: string;
143
+ }
144
+ export interface ContractOutput {
145
+ type: string;
146
+ address: string;
147
+ alphAmount: Number256;
148
+ tokens: Token[];
149
+ }
150
+ export interface DeployContractTransaction {
151
+ fromGroup: number;
152
+ toGroup: number;
153
+ unsignedTx: string;
154
+ txId: string;
155
+ contractAddress: string;
156
+ contractId: string;
157
+ }
158
+ export interface BuildDeployContractTx {
159
+ signerAddress: string;
160
+ initialFields?: Fields;
161
+ initialAlphAmount?: string;
162
+ initialTokenAmounts?: Token[];
163
+ issueTokenAmount?: Number256;
164
+ gasAmount?: number;
165
+ gasPrice?: Number256;
166
+ submitTx?: boolean;
167
+ }
168
+ export interface BuildExecuteScriptTx {
169
+ signerAddress: string;
170
+ initialFields?: Fields;
171
+ alphAmount?: Number256;
172
+ tokens?: Token[];
173
+ gasAmount?: number;
174
+ gasPrice?: Number256;
175
+ submitTx?: boolean;
176
+ }
177
+ export interface BuildScriptTxResult {
178
+ fromGroup: number;
179
+ toGroup: number;
180
+ unsignedTx: string;
181
+ txId: string;
182
+ }