@alephium/web3 0.0.1-test.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 (137) hide show
  1. package/.editorconfig +13 -0
  2. package/.eslintignore +2 -0
  3. package/.eslintrc.json +21 -0
  4. package/.gitattributes +1 -0
  5. package/LICENSE +165 -0
  6. package/README.md +136 -0
  7. package/contracts/add.ral +16 -0
  8. package/contracts/greeter.ral +7 -0
  9. package/contracts/greeter_interface.ral +3 -0
  10. package/contracts/greeter_main.ral +9 -0
  11. package/contracts/main.ral +6 -0
  12. package/contracts/sub.ral +9 -0
  13. package/dev/user.conf +29 -0
  14. package/dist/alephium-web3.min.js +3 -0
  15. package/dist/alephium-web3.min.js.LICENSE.txt +27 -0
  16. package/dist/alephium-web3.min.js.map +1 -0
  17. package/dist/scripts/check-versions.d.ts +1 -0
  18. package/dist/scripts/check-versions.js +39 -0
  19. package/dist/scripts/create-project.d.ts +2 -0
  20. package/dist/scripts/create-project.js +124 -0
  21. package/dist/scripts/header.d.ts +0 -0
  22. package/dist/scripts/header.js +18 -0
  23. package/dist/scripts/rename-gitignore.d.ts +1 -0
  24. package/dist/scripts/rename-gitignore.js +24 -0
  25. package/dist/scripts/start-devnet.d.ts +1 -0
  26. package/dist/scripts/start-devnet.js +131 -0
  27. package/dist/scripts/stop-devnet.d.ts +1 -0
  28. package/dist/scripts/stop-devnet.js +32 -0
  29. package/dist/src/api/api-alephium.d.ts +1473 -0
  30. package/dist/src/api/api-alephium.js +1143 -0
  31. package/dist/src/api/api-explorer.d.ts +475 -0
  32. package/dist/src/api/api-explorer.js +457 -0
  33. package/dist/src/api/index.d.ts +10 -0
  34. package/dist/src/api/index.js +55 -0
  35. package/dist/src/constants.d.ts +2 -0
  36. package/dist/src/constants.js +22 -0
  37. package/dist/src/contract/contract.d.ts +182 -0
  38. package/dist/src/contract/contract.js +760 -0
  39. package/dist/src/contract/events.d.ts +11 -0
  40. package/dist/src/contract/events.js +64 -0
  41. package/dist/src/contract/index.d.ts +3 -0
  42. package/dist/src/contract/index.js +32 -0
  43. package/dist/src/contract/ralph.d.ts +12 -0
  44. package/dist/src/contract/ralph.js +362 -0
  45. package/dist/src/index.d.ts +6 -0
  46. package/dist/src/index.js +35 -0
  47. package/dist/src/signer/index.d.ts +2 -0
  48. package/dist/src/signer/index.js +31 -0
  49. package/dist/src/signer/node-wallet.d.ts +13 -0
  50. package/dist/src/signer/node-wallet.js +60 -0
  51. package/dist/src/signer/signer.d.ts +143 -0
  52. package/dist/src/signer/signer.js +184 -0
  53. package/dist/src/test/index.d.ts +7 -0
  54. package/dist/src/test/index.js +41 -0
  55. package/dist/src/test/privatekey-wallet.d.ts +12 -0
  56. package/dist/src/test/privatekey-wallet.js +68 -0
  57. package/dist/src/transaction/index.d.ts +2 -0
  58. package/dist/src/transaction/index.js +31 -0
  59. package/dist/src/transaction/sign-verify.d.ts +2 -0
  60. package/dist/src/transaction/sign-verify.js +58 -0
  61. package/dist/src/transaction/status.d.ts +10 -0
  62. package/dist/src/transaction/status.js +48 -0
  63. package/dist/src/utils/address.d.ts +1 -0
  64. package/dist/src/utils/address.js +42 -0
  65. package/dist/src/utils/bs58.d.ts +4 -0
  66. package/dist/src/utils/bs58.js +28 -0
  67. package/dist/src/utils/djb2.d.ts +1 -0
  68. package/dist/src/utils/djb2.js +27 -0
  69. package/dist/src/utils/index.d.ts +6 -0
  70. package/dist/src/utils/index.js +35 -0
  71. package/dist/src/utils/password-crypto.d.ts +2 -0
  72. package/dist/src/utils/password-crypto.js +69 -0
  73. package/dist/src/utils/subscription.d.ts +24 -0
  74. package/dist/src/utils/subscription.js +52 -0
  75. package/dist/src/utils/utils.d.ts +30 -0
  76. package/dist/src/utils/utils.js +199 -0
  77. package/gitignore +10 -0
  78. package/package.json +127 -0
  79. package/scripts/check-versions.js +45 -0
  80. package/scripts/create-project.ts +136 -0
  81. package/scripts/header.js +17 -0
  82. package/scripts/rename-gitignore.js +24 -0
  83. package/scripts/start-devnet.js +141 -0
  84. package/scripts/stop-devnet.js +32 -0
  85. package/src/api/api-alephium.ts +2430 -0
  86. package/src/api/api-explorer.ts +852 -0
  87. package/src/api/index.ts +35 -0
  88. package/src/constants.ts +20 -0
  89. package/src/contract/contract.ts +1014 -0
  90. package/src/contract/events.ts +75 -0
  91. package/src/contract/index.ts +21 -0
  92. package/src/contract/ralph.test.ts +178 -0
  93. package/src/contract/ralph.ts +362 -0
  94. package/src/fixtures/address.json +36 -0
  95. package/src/fixtures/balance.json +9 -0
  96. package/src/fixtures/self-clique.json +19 -0
  97. package/src/fixtures/transaction.json +13 -0
  98. package/src/fixtures/transactions.json +179 -0
  99. package/src/index.ts +25 -0
  100. package/src/signer/fixtures/genesis.json +26 -0
  101. package/src/signer/fixtures/wallets.json +26 -0
  102. package/src/signer/index.ts +20 -0
  103. package/src/signer/node-wallet.ts +74 -0
  104. package/src/signer/signer.ts +313 -0
  105. package/src/test/index.ts +32 -0
  106. package/src/test/privatekey-wallet.ts +58 -0
  107. package/src/transaction/index.ts +20 -0
  108. package/src/transaction/sign-verify.test.ts +50 -0
  109. package/src/transaction/sign-verify.ts +39 -0
  110. package/src/transaction/status.ts +58 -0
  111. package/src/utils/address.test.ts +47 -0
  112. package/src/utils/address.ts +39 -0
  113. package/src/utils/bs58.ts +26 -0
  114. package/src/utils/djb2.test.ts +35 -0
  115. package/src/utils/djb2.ts +25 -0
  116. package/src/utils/index.ts +24 -0
  117. package/src/utils/password-crypto.test.ts +27 -0
  118. package/src/utils/password-crypto.ts +77 -0
  119. package/src/utils/subscription.ts +72 -0
  120. package/src/utils/utils.test.ts +160 -0
  121. package/src/utils/utils.ts +209 -0
  122. package/templates/base/README.md +34 -0
  123. package/templates/base/package.json +35 -0
  124. package/templates/base/src/greeter.ts +41 -0
  125. package/templates/base/tsconfig.json +19 -0
  126. package/templates/react/README.md +34 -0
  127. package/templates/react/config-overrides.js +18 -0
  128. package/templates/react/package.json +66 -0
  129. package/templates/react/src/App.tsx +42 -0
  130. package/templates/react/src/artifacts/greeter.ral.json +26 -0
  131. package/templates/react/src/artifacts/greeter_main.ral.json +22 -0
  132. package/templates/shared/.eslintrc.json +12 -0
  133. package/templates/shared/scripts/header.js +0 -0
  134. package/test/contract.test.ts +161 -0
  135. package/test/events.test.ts +138 -0
  136. package/test/transaction.test.ts +72 -0
  137. package/webpack.config.js +57 -0
@@ -0,0 +1,852 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ /*
4
+ * ---------------------------------------------------------------
5
+ * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
6
+ * ## ##
7
+ * ## AUTHOR: acacode ##
8
+ * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
9
+ * ---------------------------------------------------------------
10
+ */
11
+
12
+ export interface AddressBalance {
13
+ /** @format uint256 */
14
+ balance: string
15
+
16
+ /** @format uint256 */
17
+ lockedBalance: string
18
+ }
19
+
20
+ export interface AddressInfo {
21
+ /** @format uint256 */
22
+ balance: string
23
+
24
+ /** @format uint256 */
25
+ lockedBalance: string
26
+
27
+ /** @format int32 */
28
+ txNumber: number
29
+ }
30
+
31
+ export interface BadRequest {
32
+ detail: string
33
+ }
34
+
35
+ export interface BlockEntryLite {
36
+ /** @format block-hash */
37
+ hash: string
38
+
39
+ /** @format int64 */
40
+ timestamp: number
41
+
42
+ /** @format int32 */
43
+ chainFrom: number
44
+
45
+ /** @format int32 */
46
+ chainTo: number
47
+
48
+ /** @format int32 */
49
+ height: number
50
+
51
+ /** @format int32 */
52
+ txNumber: number
53
+ mainChain: boolean
54
+
55
+ /** @format bigint */
56
+ hashRate: string
57
+ }
58
+
59
+ export interface ConfirmedTransaction {
60
+ /** @format 32-byte-hash */
61
+ hash: string
62
+
63
+ /** @format block-hash */
64
+ blockHash: string
65
+
66
+ /** @format int64 */
67
+ timestamp: number
68
+ inputs?: Input[]
69
+ outputs?: Output[]
70
+
71
+ /** @format int32 */
72
+ gasAmount: number
73
+
74
+ /** @format uint256 */
75
+ gasPrice: string
76
+ type: string
77
+ }
78
+
79
+ export interface ExplorerInfo {
80
+ releaseVersion: string
81
+ commit: string
82
+ }
83
+
84
+ export interface Hashrate {
85
+ /** @format int64 */
86
+ timestamp: number
87
+ hashrate: number
88
+ value: number
89
+ }
90
+
91
+ export interface Input {
92
+ outputRef: OutputRef
93
+ unlockScript?: string
94
+
95
+ /** @format 32-byte-hash */
96
+ txHashRef: string
97
+ address: string
98
+
99
+ /** @format uint256 */
100
+ amount: string
101
+ }
102
+
103
+ export interface InternalServerError {
104
+ detail: string
105
+ }
106
+
107
+ export interface ListBlocks {
108
+ /** @format int32 */
109
+ total: number
110
+ blocks?: BlockEntryLite[]
111
+ }
112
+
113
+ export interface NotFound {
114
+ detail: string
115
+ resource: string
116
+ }
117
+
118
+ export interface Output {
119
+ /** @format int32 */
120
+ hint: number
121
+
122
+ /** @format 32-byte-hash */
123
+ key: string
124
+
125
+ /** @format uint256 */
126
+ amount: string
127
+ address: string
128
+
129
+ /** @format int64 */
130
+ lockTime?: number
131
+
132
+ /** @format 32-byte-hash */
133
+ spent?: string
134
+ }
135
+
136
+ export interface OutputRef {
137
+ /** @format int32 */
138
+ hint: number
139
+
140
+ /** @format 32-byte-hash */
141
+ key: string
142
+ }
143
+
144
+ export interface PerChainCount {
145
+ /** @format int32 */
146
+ chainFrom: number
147
+
148
+ /** @format int32 */
149
+ chainTo: number
150
+
151
+ /** @format int64 */
152
+ count: number
153
+ }
154
+
155
+ export interface PerChainDuration {
156
+ /** @format int32 */
157
+ chainFrom: number
158
+
159
+ /** @format int32 */
160
+ chainTo: number
161
+
162
+ /** @format int64 */
163
+ duration: number
164
+
165
+ /** @format int64 */
166
+ value: number
167
+ }
168
+
169
+ export interface PerChainHeight {
170
+ /** @format int32 */
171
+ chainFrom: number
172
+
173
+ /** @format int32 */
174
+ chainTo: number
175
+
176
+ /** @format int64 */
177
+ height: number
178
+
179
+ /** @format int64 */
180
+ value: number
181
+ }
182
+
183
+ export interface PerChainTimedCount {
184
+ /** @format int64 */
185
+ timestamp: number
186
+ totalCountPerChain?: PerChainCount[]
187
+ }
188
+
189
+ export interface ServiceUnavailable {
190
+ detail: string
191
+ }
192
+
193
+ export interface TimedCount {
194
+ /** @format int64 */
195
+ timestamp: number
196
+
197
+ /** @format int64 */
198
+ totalCountAllChains: number
199
+ }
200
+
201
+ export interface TokenSupply {
202
+ /** @format int64 */
203
+ timestamp: number
204
+
205
+ /** @format uint256 */
206
+ total: string
207
+
208
+ /** @format uint256 */
209
+ circulating: string
210
+
211
+ /** @format uint256 */
212
+ reserved: string
213
+
214
+ /** @format uint256 */
215
+ locked: string
216
+
217
+ /** @format uint256 */
218
+ maximum: string
219
+ }
220
+
221
+ export interface Transaction {
222
+ /** @format 32-byte-hash */
223
+ hash: string
224
+
225
+ /** @format block-hash */
226
+ blockHash: string
227
+
228
+ /** @format int64 */
229
+ timestamp: number
230
+ inputs?: Input[]
231
+ outputs?: Output[]
232
+
233
+ /** @format int32 */
234
+ gasAmount: number
235
+
236
+ /** @format uint256 */
237
+ gasPrice: string
238
+ }
239
+
240
+ export type TransactionLike = ConfirmedTransaction | UnconfirmedTransaction
241
+
242
+ export interface UInput {
243
+ outputRef: OutputRef
244
+ unlockScript?: string
245
+ }
246
+
247
+ export interface UOutput {
248
+ /** @format uint256 */
249
+ amount: string
250
+ address: string
251
+
252
+ /** @format int64 */
253
+ lockTime?: number
254
+ }
255
+
256
+ export interface Unauthorized {
257
+ detail: string
258
+ }
259
+
260
+ export interface UnconfirmedTransaction {
261
+ /** @format 32-byte-hash */
262
+ hash: string
263
+
264
+ /** @format int32 */
265
+ chainFrom: number
266
+
267
+ /** @format int32 */
268
+ chainTo: number
269
+ inputs?: UInput[]
270
+ outputs?: UOutput[]
271
+
272
+ /** @format int32 */
273
+ gasAmount: number
274
+
275
+ /** @format uint256 */
276
+ gasPrice: string
277
+ type: string
278
+ }
279
+
280
+ import 'cross-fetch/polyfill'
281
+
282
+ function convertHttpResponse<T>(
283
+ response: HttpResponse<T, { detail: string }> | HttpResponse<T, { detail: string }>
284
+ ): T {
285
+ if (response.error) {
286
+ throw new Error(response.error.detail)
287
+ } else {
288
+ return response.data
289
+ }
290
+ }
291
+
292
+ export type QueryParamsType = Record<string | number, any>
293
+ export type ResponseFormat = keyof Omit<Body, 'body' | 'bodyUsed'>
294
+
295
+ export interface FullRequestParams extends Omit<RequestInit, 'body'> {
296
+ /** set parameter to `true` for call `securityWorker` for this request */
297
+ secure?: boolean
298
+ /** request path */
299
+ path: string
300
+ /** content type of request body */
301
+ type?: ContentType
302
+ /** query params */
303
+ query?: QueryParamsType
304
+ /** format of response (i.e. response.json() -> format: "json") */
305
+ format?: ResponseFormat
306
+ /** request body */
307
+ body?: unknown
308
+ /** base url */
309
+ baseUrl?: string
310
+ /** request cancellation token */
311
+ cancelToken?: CancelToken
312
+ }
313
+
314
+ export type RequestParams = Omit<FullRequestParams, 'body' | 'method' | 'query' | 'path'>
315
+
316
+ export interface ApiConfig<SecurityDataType = unknown> {
317
+ baseUrl?: string
318
+ baseApiParams?: Omit<RequestParams, 'baseUrl' | 'cancelToken' | 'signal'>
319
+ securityWorker?: (securityData: SecurityDataType | null) => Promise<RequestParams | void> | RequestParams | void
320
+ customFetch?: typeof fetch
321
+ }
322
+
323
+ export interface HttpResponse<D extends unknown, E extends unknown = unknown> extends Response {
324
+ data: D
325
+ error: E
326
+ }
327
+
328
+ type CancelToken = Symbol | string | number
329
+
330
+ export enum ContentType {
331
+ Json = 'application/json',
332
+ FormData = 'multipart/form-data',
333
+ UrlEncoded = 'application/x-www-form-urlencoded'
334
+ }
335
+
336
+ export class HttpClient<SecurityDataType = unknown> {
337
+ public baseUrl: string = ''
338
+ private securityData: SecurityDataType | null = null
339
+ private securityWorker?: ApiConfig<SecurityDataType>['securityWorker']
340
+ private abortControllers = new Map<CancelToken, AbortController>()
341
+ private customFetch = (...fetchParams: Parameters<typeof fetch>) => fetch(...fetchParams)
342
+
343
+ private baseApiParams: RequestParams = {
344
+ credentials: 'same-origin',
345
+ headers: {},
346
+ redirect: 'follow',
347
+ referrerPolicy: 'no-referrer'
348
+ }
349
+
350
+ constructor(apiConfig: ApiConfig<SecurityDataType> = {}) {
351
+ Object.assign(this, apiConfig)
352
+ }
353
+
354
+ public setSecurityData = (data: SecurityDataType | null) => {
355
+ this.securityData = data
356
+ }
357
+
358
+ private encodeQueryParam(key: string, value: any) {
359
+ const encodedKey = encodeURIComponent(key)
360
+ return `${encodedKey}=${encodeURIComponent(typeof value === 'number' ? value : `${value}`)}`
361
+ }
362
+
363
+ private addQueryParam(query: QueryParamsType, key: string) {
364
+ return this.encodeQueryParam(key, query[key])
365
+ }
366
+
367
+ private addArrayQueryParam(query: QueryParamsType, key: string) {
368
+ const value = query[key]
369
+ return value.map((v: any) => this.encodeQueryParam(key, v)).join('&')
370
+ }
371
+
372
+ protected toQueryString(rawQuery?: QueryParamsType): string {
373
+ const query = rawQuery || {}
374
+ const keys = Object.keys(query).filter((key) => 'undefined' !== typeof query[key])
375
+ return keys
376
+ .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key)))
377
+ .join('&')
378
+ }
379
+
380
+ protected addQueryParams(rawQuery?: QueryParamsType): string {
381
+ const queryString = this.toQueryString(rawQuery)
382
+ return queryString ? `?${queryString}` : ''
383
+ }
384
+
385
+ private contentFormatters: Record<ContentType, (input: any) => any> = {
386
+ [ContentType.Json]: (input: any) =>
387
+ input !== null && (typeof input === 'object' || typeof input === 'string') ? JSON.stringify(input) : input,
388
+ [ContentType.FormData]: (input: any) =>
389
+ Object.keys(input || {}).reduce((formData, key) => {
390
+ const property = input[key]
391
+ formData.append(
392
+ key,
393
+ property instanceof Blob
394
+ ? property
395
+ : typeof property === 'object' && property !== null
396
+ ? JSON.stringify(property)
397
+ : `${property}`
398
+ )
399
+ return formData
400
+ }, new FormData()),
401
+ [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input)
402
+ }
403
+
404
+ private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams {
405
+ return {
406
+ ...this.baseApiParams,
407
+ ...params1,
408
+ ...(params2 || {}),
409
+ headers: {
410
+ ...(this.baseApiParams.headers || {}),
411
+ ...(params1.headers || {}),
412
+ ...((params2 && params2.headers) || {})
413
+ }
414
+ }
415
+ }
416
+
417
+ private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => {
418
+ if (this.abortControllers.has(cancelToken)) {
419
+ const abortController = this.abortControllers.get(cancelToken)
420
+ if (abortController) {
421
+ return abortController.signal
422
+ }
423
+ return void 0
424
+ }
425
+
426
+ const abortController = new AbortController()
427
+ this.abortControllers.set(cancelToken, abortController)
428
+ return abortController.signal
429
+ }
430
+
431
+ public abortRequest = (cancelToken: CancelToken) => {
432
+ const abortController = this.abortControllers.get(cancelToken)
433
+
434
+ if (abortController) {
435
+ abortController.abort()
436
+ this.abortControllers.delete(cancelToken)
437
+ }
438
+ }
439
+
440
+ public request = async <T = any, E = any>({
441
+ body,
442
+ secure,
443
+ path,
444
+ type,
445
+ query,
446
+ format,
447
+ baseUrl,
448
+ cancelToken,
449
+ ...params
450
+ }: FullRequestParams): Promise<HttpResponse<T, E>> => {
451
+ const secureParams =
452
+ ((typeof secure === 'boolean' ? secure : this.baseApiParams.secure) &&
453
+ this.securityWorker &&
454
+ (await this.securityWorker(this.securityData))) ||
455
+ {}
456
+ const requestParams = this.mergeRequestParams(params, secureParams)
457
+ const queryString = query && this.toQueryString(query)
458
+ const payloadFormatter = this.contentFormatters[type || ContentType.Json]
459
+ const responseFormat = format || requestParams.format
460
+
461
+ return this.customFetch(`${baseUrl || this.baseUrl || ''}${path}${queryString ? `?${queryString}` : ''}`, {
462
+ ...requestParams,
463
+ headers: {
464
+ ...(type && type !== ContentType.FormData ? { 'Content-Type': type } : {}),
465
+ ...(requestParams.headers || {})
466
+ },
467
+ signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0,
468
+ body: typeof body === 'undefined' || body === null ? null : payloadFormatter(body)
469
+ }).then(async (response) => {
470
+ const r = response as HttpResponse<T, E>
471
+ r.data = null as unknown as T
472
+ r.error = null as unknown as E
473
+
474
+ const data = !responseFormat
475
+ ? r
476
+ : await response[responseFormat]()
477
+ .then((data) => {
478
+ if (r.ok) {
479
+ r.data = data
480
+ } else {
481
+ r.error = data
482
+ }
483
+ return r
484
+ })
485
+ .catch((e) => {
486
+ r.error = e
487
+ return r
488
+ })
489
+
490
+ if (cancelToken) {
491
+ this.abortControllers.delete(cancelToken)
492
+ }
493
+
494
+ if (!response.ok) throw data
495
+ return data
496
+ })
497
+ }
498
+ }
499
+
500
+ /**
501
+ * @title Alephium Explorer API
502
+ * @version 1.0
503
+ */
504
+ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
505
+ blocks = {
506
+ /**
507
+ * @description List blocks within time interval
508
+ *
509
+ * @tags Blocks
510
+ * @name GetBlocks
511
+ * @request GET:/blocks
512
+ */
513
+ getBlocks: (query?: { page?: number; limit?: number; reverse?: boolean }, params: RequestParams = {}) =>
514
+ this.request<ListBlocks, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
515
+ path: `/blocks`,
516
+ method: 'GET',
517
+ query: query,
518
+ format: 'json',
519
+ ...params
520
+ }).then(convertHttpResponse),
521
+
522
+ /**
523
+ * @description Get a block with hash
524
+ *
525
+ * @tags Blocks
526
+ * @name GetBlocksBlockHash
527
+ * @request GET:/blocks/{block-hash}
528
+ */
529
+ getBlocksBlockHash: (blockHash: string, params: RequestParams = {}) =>
530
+ this.request<BlockEntryLite, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
531
+ path: `/blocks/${blockHash}`,
532
+ method: 'GET',
533
+ format: 'json',
534
+ ...params
535
+ }).then(convertHttpResponse),
536
+
537
+ /**
538
+ * @description Get block's transactions
539
+ *
540
+ * @tags Blocks
541
+ * @name GetBlocksBlockHashTransactions
542
+ * @request GET:/blocks/{block-hash}/transactions
543
+ */
544
+ getBlocksBlockHashTransactions: (
545
+ blockHash: string,
546
+ query?: { page?: number; limit?: number; reverse?: boolean },
547
+ params: RequestParams = {}
548
+ ) =>
549
+ this.request<Transaction[], BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
550
+ path: `/blocks/${blockHash}/transactions`,
551
+ method: 'GET',
552
+ query: query,
553
+ format: 'json',
554
+ ...params
555
+ }).then(convertHttpResponse)
556
+ }
557
+ transactions = {
558
+ /**
559
+ * @description Get a transaction with hash
560
+ *
561
+ * @tags Transactions
562
+ * @name GetTransactionsTransactionHash
563
+ * @request GET:/transactions/{transaction-hash}
564
+ */
565
+ getTransactionsTransactionHash: (transactionHash: string, params: RequestParams = {}) =>
566
+ this.request<TransactionLike, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
567
+ path: `/transactions/${transactionHash}`,
568
+ method: 'GET',
569
+ format: 'json',
570
+ ...params
571
+ }).then(convertHttpResponse)
572
+ }
573
+ addresses = {
574
+ /**
575
+ * @description Get address information
576
+ *
577
+ * @tags Addresses
578
+ * @name GetAddressesAddress
579
+ * @request GET:/addresses/{address}
580
+ */
581
+ getAddressesAddress: (address: string, params: RequestParams = {}) =>
582
+ this.request<AddressInfo, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
583
+ path: `/addresses/${address}`,
584
+ method: 'GET',
585
+ format: 'json',
586
+ ...params
587
+ }).then(convertHttpResponse),
588
+
589
+ /**
590
+ * @description List transactions of a given address
591
+ *
592
+ * @tags Addresses
593
+ * @name GetAddressesAddressTransactions
594
+ * @request GET:/addresses/{address}/transactions
595
+ */
596
+ getAddressesAddressTransactions: (
597
+ address: string,
598
+ query?: { page?: number; limit?: number; reverse?: boolean },
599
+ params: RequestParams = {}
600
+ ) =>
601
+ this.request<Transaction[], BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
602
+ path: `/addresses/${address}/transactions`,
603
+ method: 'GET',
604
+ query: query,
605
+ format: 'json',
606
+ ...params
607
+ }).then(convertHttpResponse),
608
+
609
+ /**
610
+ * @description Get total transactions of a given address
611
+ *
612
+ * @tags Addresses
613
+ * @name GetAddressesAddressTotalTransactions
614
+ * @request GET:/addresses/{address}/total-transactions
615
+ */
616
+ getAddressesAddressTotalTransactions: (address: string, params: RequestParams = {}) =>
617
+ this.request<number, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
618
+ path: `/addresses/${address}/total-transactions`,
619
+ method: 'GET',
620
+ format: 'json',
621
+ ...params
622
+ }).then(convertHttpResponse),
623
+
624
+ /**
625
+ * @description Get address balance
626
+ *
627
+ * @tags Addresses
628
+ * @name GetAddressesAddressBalance
629
+ * @request GET:/addresses/{address}/balance
630
+ */
631
+ getAddressesAddressBalance: (address: string, params: RequestParams = {}) =>
632
+ this.request<AddressBalance, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
633
+ path: `/addresses/${address}/balance`,
634
+ method: 'GET',
635
+ format: 'json',
636
+ ...params
637
+ }).then(convertHttpResponse)
638
+ }
639
+ infos = {
640
+ /**
641
+ * @description Get explorer informations
642
+ *
643
+ * @tags Infos
644
+ * @name GetInfos
645
+ * @request GET:/infos
646
+ */
647
+ getInfos: (params: RequestParams = {}) =>
648
+ this.request<ExplorerInfo, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
649
+ path: `/infos`,
650
+ method: 'GET',
651
+ format: 'json',
652
+ ...params
653
+ }).then(convertHttpResponse),
654
+
655
+ /**
656
+ * @description List latest height for each chain
657
+ *
658
+ * @tags Infos
659
+ * @name GetInfosHeights
660
+ * @request GET:/infos/heights
661
+ */
662
+ getInfosHeights: (params: RequestParams = {}) =>
663
+ this.request<PerChainHeight[], BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
664
+ path: `/infos/heights`,
665
+ method: 'GET',
666
+ format: 'json',
667
+ ...params
668
+ }).then(convertHttpResponse),
669
+
670
+ /**
671
+ * @description Get token supply list
672
+ *
673
+ * @tags Infos
674
+ * @name GetInfosSupply
675
+ * @request GET:/infos/supply
676
+ */
677
+ getInfosSupply: (query?: { page?: number; limit?: number; reverse?: boolean }, params: RequestParams = {}) =>
678
+ this.request<TokenSupply[], BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
679
+ path: `/infos/supply`,
680
+ method: 'GET',
681
+ query: query,
682
+ format: 'json',
683
+ ...params
684
+ }).then(convertHttpResponse),
685
+
686
+ /**
687
+ * @description Get the ALPH total supply
688
+ *
689
+ * @tags Infos
690
+ * @name GetInfosSupplyTotalAlph
691
+ * @request GET:/infos/supply/total-alph
692
+ */
693
+ getInfosSupplyTotalAlph: (params: RequestParams = {}) =>
694
+ this.request<number, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
695
+ path: `/infos/supply/total-alph`,
696
+ method: 'GET',
697
+ ...params
698
+ }).then(convertHttpResponse),
699
+
700
+ /**
701
+ * @description Get the ALPH circulating supply
702
+ *
703
+ * @tags Infos
704
+ * @name GetInfosSupplyCirculatingAlph
705
+ * @request GET:/infos/supply/circulating-alph
706
+ */
707
+ getInfosSupplyCirculatingAlph: (params: RequestParams = {}) =>
708
+ this.request<number, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
709
+ path: `/infos/supply/circulating-alph`,
710
+ method: 'GET',
711
+ ...params
712
+ }).then(convertHttpResponse),
713
+
714
+ /**
715
+ * @description Get the ALPH reserved supply
716
+ *
717
+ * @tags Infos
718
+ * @name GetInfosSupplyReservedAlph
719
+ * @request GET:/infos/supply/reserved-alph
720
+ */
721
+ getInfosSupplyReservedAlph: (params: RequestParams = {}) =>
722
+ this.request<number, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
723
+ path: `/infos/supply/reserved-alph`,
724
+ method: 'GET',
725
+ ...params
726
+ }).then(convertHttpResponse),
727
+
728
+ /**
729
+ * @description Get the ALPH locked supply
730
+ *
731
+ * @tags Infos
732
+ * @name GetInfosSupplyLockedAlph
733
+ * @request GET:/infos/supply/locked-alph
734
+ */
735
+ getInfosSupplyLockedAlph: (params: RequestParams = {}) =>
736
+ this.request<number, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
737
+ path: `/infos/supply/locked-alph`,
738
+ method: 'GET',
739
+ ...params
740
+ }).then(convertHttpResponse),
741
+
742
+ /**
743
+ * @description Get the total number of transactions
744
+ *
745
+ * @tags Infos
746
+ * @name GetInfosTotalTransactions
747
+ * @request GET:/infos/total-transactions
748
+ */
749
+ getInfosTotalTransactions: (params: RequestParams = {}) =>
750
+ this.request<number, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
751
+ path: `/infos/total-transactions`,
752
+ method: 'GET',
753
+ ...params
754
+ }).then(convertHttpResponse),
755
+
756
+ /**
757
+ * @description Get the average block time for each chain
758
+ *
759
+ * @tags Infos
760
+ * @name GetInfosAverageBlockTimes
761
+ * @request GET:/infos/average-block-times
762
+ */
763
+ getInfosAverageBlockTimes: (params: RequestParams = {}) =>
764
+ this.request<PerChainDuration[], BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>(
765
+ {
766
+ path: `/infos/average-block-times`,
767
+ method: 'GET',
768
+ format: 'json',
769
+ ...params
770
+ }
771
+ ).then(convertHttpResponse)
772
+ }
773
+ charts = {
774
+ /**
775
+ * @description `interval-type` query param: hourly, daily
776
+ *
777
+ * @tags Charts
778
+ * @name GetChartsHashrates
779
+ * @summary Get hashrate chart in H/s
780
+ * @request GET:/charts/hashrates
781
+ */
782
+ getChartsHashrates: (
783
+ query: { fromTs: number; toTs: number; 'interval-type': string },
784
+ params: RequestParams = {}
785
+ ) =>
786
+ this.request<Hashrate[], BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
787
+ path: `/charts/hashrates`,
788
+ method: 'GET',
789
+ query: query,
790
+ format: 'json',
791
+ ...params
792
+ }).then(convertHttpResponse),
793
+
794
+ /**
795
+ * @description `interval-type` query param: hourly, daily
796
+ *
797
+ * @tags Charts
798
+ * @name GetChartsTransactionsCount
799
+ * @summary Get transaction count history
800
+ * @request GET:/charts/transactions-count
801
+ */
802
+ getChartsTransactionsCount: (
803
+ query: { fromTs: number; toTs: number; 'interval-type': string },
804
+ params: RequestParams = {}
805
+ ) =>
806
+ this.request<TimedCount[], BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
807
+ path: `/charts/transactions-count`,
808
+ method: 'GET',
809
+ query: query,
810
+ format: 'json',
811
+ ...params
812
+ }).then(convertHttpResponse),
813
+
814
+ /**
815
+ * @description `interval-type` query param: hourly, daily
816
+ *
817
+ * @tags Charts
818
+ * @name GetChartsTransactionsCountPerChain
819
+ * @summary Get transaction count history per chain
820
+ * @request GET:/charts/transactions-count-per-chain
821
+ */
822
+ getChartsTransactionsCountPerChain: (
823
+ query: { fromTs: number; toTs: number; 'interval-type': string },
824
+ params: RequestParams = {}
825
+ ) =>
826
+ this.request<
827
+ PerChainTimedCount[],
828
+ BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable
829
+ >({
830
+ path: `/charts/transactions-count-per-chain`,
831
+ method: 'GET',
832
+ query: query,
833
+ format: 'json',
834
+ ...params
835
+ }).then(convertHttpResponse)
836
+ }
837
+ utils = {
838
+ /**
839
+ * @description Perform a sanity check
840
+ *
841
+ * @tags Utils
842
+ * @name PutUtilsSanityCheck
843
+ * @request PUT:/utils/sanity-check
844
+ */
845
+ putUtilsSanityCheck: (params: RequestParams = {}) =>
846
+ this.request<void, BadRequest | Unauthorized | NotFound | InternalServerError | ServiceUnavailable>({
847
+ path: `/utils/sanity-check`,
848
+ method: 'PUT',
849
+ ...params
850
+ }).then(convertHttpResponse)
851
+ }
852
+ }