@v3finance/monitoring-sdk 0.1.0 → 0.2.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 (154) hide show
  1. package/CHANGELOG.md +21 -11
  2. package/README.md +223 -148
  3. package/dist/cjs/client.d.ts +23 -42
  4. package/dist/cjs/client.d.ts.map +1 -1
  5. package/dist/cjs/client.js +44 -53
  6. package/dist/cjs/client.js.map +1 -1
  7. package/dist/cjs/core/errors.d.ts +18 -18
  8. package/dist/cjs/core/errors.d.ts.map +1 -1
  9. package/dist/cjs/core/errors.js +17 -17
  10. package/dist/cjs/core/errors.js.map +1 -1
  11. package/dist/cjs/core/http.d.ts +22 -26
  12. package/dist/cjs/core/http.d.ts.map +1 -1
  13. package/dist/cjs/core/http.js +28 -36
  14. package/dist/cjs/core/http.js.map +1 -1
  15. package/dist/cjs/core/pagination.d.ts +6 -7
  16. package/dist/cjs/core/pagination.d.ts.map +1 -1
  17. package/dist/cjs/core/pagination.js +1 -1
  18. package/dist/cjs/core/pagination.js.map +1 -1
  19. package/dist/cjs/core/scope.d.ts +8 -0
  20. package/dist/cjs/core/scope.d.ts.map +1 -0
  21. package/dist/cjs/core/scope.js +3 -0
  22. package/dist/cjs/core/scope.js.map +1 -0
  23. package/dist/cjs/generated/types.d.ts +129 -117
  24. package/dist/cjs/generated/types.d.ts.map +1 -1
  25. package/dist/cjs/generated/types.js +1 -1
  26. package/dist/cjs/generated/types.js.map +1 -1
  27. package/dist/cjs/index.d.ts +6 -6
  28. package/dist/cjs/index.d.ts.map +1 -1
  29. package/dist/cjs/index.js +13 -16
  30. package/dist/cjs/index.js.map +1 -1
  31. package/dist/cjs/resources/account.d.ts +12 -51
  32. package/dist/cjs/resources/account.d.ts.map +1 -1
  33. package/dist/cjs/resources/account.js +17 -61
  34. package/dist/cjs/resources/account.js.map +1 -1
  35. package/dist/cjs/resources/addresses.d.ts +49 -65
  36. package/dist/cjs/resources/addresses.d.ts.map +1 -1
  37. package/dist/cjs/resources/addresses.js +60 -69
  38. package/dist/cjs/resources/addresses.js.map +1 -1
  39. package/dist/cjs/resources/catalog.d.ts +17 -10
  40. package/dist/cjs/resources/catalog.d.ts.map +1 -1
  41. package/dist/cjs/resources/catalog.js +23 -17
  42. package/dist/cjs/resources/catalog.js.map +1 -1
  43. package/dist/cjs/resources/deliveries.d.ts +34 -23
  44. package/dist/cjs/resources/deliveries.d.ts.map +1 -1
  45. package/dist/cjs/resources/deliveries.js +27 -17
  46. package/dist/cjs/resources/deliveries.js.map +1 -1
  47. package/dist/cjs/resources/transactions.d.ts +14 -14
  48. package/dist/cjs/resources/transactions.d.ts.map +1 -1
  49. package/dist/cjs/resources/transactions.js +15 -16
  50. package/dist/cjs/resources/transactions.js.map +1 -1
  51. package/dist/cjs/resources/webhooks.d.ts +22 -0
  52. package/dist/cjs/resources/webhooks.d.ts.map +1 -0
  53. package/dist/cjs/resources/webhooks.js +35 -0
  54. package/dist/cjs/resources/webhooks.js.map +1 -0
  55. package/dist/cjs/units.d.ts +11 -11
  56. package/dist/cjs/units.js +14 -14
  57. package/dist/cjs/units.js.map +1 -1
  58. package/dist/cjs/version.d.ts +3 -3
  59. package/dist/cjs/version.d.ts.map +1 -1
  60. package/dist/cjs/version.js +3 -3
  61. package/dist/cjs/version.js.map +1 -1
  62. package/dist/cjs/webhooks.d.ts +33 -28
  63. package/dist/cjs/webhooks.d.ts.map +1 -1
  64. package/dist/cjs/webhooks.js +33 -28
  65. package/dist/cjs/webhooks.js.map +1 -1
  66. package/dist/esm/client.d.ts +23 -42
  67. package/dist/esm/client.d.ts.map +1 -1
  68. package/dist/esm/client.js +46 -55
  69. package/dist/esm/client.js.map +1 -1
  70. package/dist/esm/core/errors.d.ts +18 -18
  71. package/dist/esm/core/errors.d.ts.map +1 -1
  72. package/dist/esm/core/errors.js +17 -17
  73. package/dist/esm/core/errors.js.map +1 -1
  74. package/dist/esm/core/http.d.ts +22 -26
  75. package/dist/esm/core/http.d.ts.map +1 -1
  76. package/dist/esm/core/http.js +28 -36
  77. package/dist/esm/core/http.js.map +1 -1
  78. package/dist/esm/core/pagination.d.ts +6 -7
  79. package/dist/esm/core/pagination.d.ts.map +1 -1
  80. package/dist/esm/core/pagination.js +1 -1
  81. package/dist/esm/core/pagination.js.map +1 -1
  82. package/dist/esm/core/scope.d.ts +8 -0
  83. package/dist/esm/core/scope.d.ts.map +1 -0
  84. package/dist/esm/core/scope.js +2 -0
  85. package/dist/esm/core/scope.js.map +1 -0
  86. package/dist/esm/generated/types.d.ts +129 -117
  87. package/dist/esm/generated/types.d.ts.map +1 -1
  88. package/dist/esm/generated/types.js +1 -1
  89. package/dist/esm/generated/types.js.map +1 -1
  90. package/dist/esm/index.d.ts +6 -6
  91. package/dist/esm/index.d.ts.map +1 -1
  92. package/dist/esm/index.js +6 -6
  93. package/dist/esm/index.js.map +1 -1
  94. package/dist/esm/resources/account.d.ts +12 -51
  95. package/dist/esm/resources/account.d.ts.map +1 -1
  96. package/dist/esm/resources/account.js +15 -57
  97. package/dist/esm/resources/account.js.map +1 -1
  98. package/dist/esm/resources/addresses.d.ts +49 -65
  99. package/dist/esm/resources/addresses.d.ts.map +1 -1
  100. package/dist/esm/resources/addresses.js +60 -69
  101. package/dist/esm/resources/addresses.js.map +1 -1
  102. package/dist/esm/resources/catalog.d.ts +17 -10
  103. package/dist/esm/resources/catalog.d.ts.map +1 -1
  104. package/dist/esm/resources/catalog.js +23 -17
  105. package/dist/esm/resources/catalog.js.map +1 -1
  106. package/dist/esm/resources/deliveries.d.ts +34 -23
  107. package/dist/esm/resources/deliveries.d.ts.map +1 -1
  108. package/dist/esm/resources/deliveries.js +27 -17
  109. package/dist/esm/resources/deliveries.js.map +1 -1
  110. package/dist/esm/resources/transactions.d.ts +14 -14
  111. package/dist/esm/resources/transactions.d.ts.map +1 -1
  112. package/dist/esm/resources/transactions.js +15 -16
  113. package/dist/esm/resources/transactions.js.map +1 -1
  114. package/dist/esm/resources/webhooks.d.ts +22 -0
  115. package/dist/esm/resources/webhooks.d.ts.map +1 -0
  116. package/dist/esm/resources/webhooks.js +31 -0
  117. package/dist/esm/resources/webhooks.js.map +1 -0
  118. package/dist/esm/units.d.ts +11 -11
  119. package/dist/esm/units.js +14 -14
  120. package/dist/esm/units.js.map +1 -1
  121. package/dist/esm/version.d.ts +3 -3
  122. package/dist/esm/version.d.ts.map +1 -1
  123. package/dist/esm/version.js +3 -3
  124. package/dist/esm/version.js.map +1 -1
  125. package/dist/esm/webhooks.d.ts +33 -28
  126. package/dist/esm/webhooks.d.ts.map +1 -1
  127. package/dist/esm/webhooks.js +33 -28
  128. package/dist/esm/webhooks.js.map +1 -1
  129. package/package.json +8 -5
  130. package/src/client.ts +50 -61
  131. package/src/core/errors.ts +18 -18
  132. package/src/core/http.ts +45 -55
  133. package/src/core/pagination.ts +7 -8
  134. package/src/core/scope.ts +8 -0
  135. package/src/generated/types.ts +139 -125
  136. package/src/index.ts +7 -24
  137. package/src/resources/account.ts +18 -72
  138. package/src/resources/addresses.ts +84 -109
  139. package/src/resources/catalog.ts +28 -19
  140. package/src/resources/deliveries.ts +43 -30
  141. package/src/resources/transactions.ts +18 -17
  142. package/src/resources/webhooks.ts +36 -0
  143. package/src/units.ts +14 -14
  144. package/src/version.ts +3 -3
  145. package/src/webhooks.ts +37 -32
  146. package/dist/cjs/resources/clients.d.ts +0 -84
  147. package/dist/cjs/resources/clients.d.ts.map +0 -1
  148. package/dist/cjs/resources/clients.js +0 -102
  149. package/dist/cjs/resources/clients.js.map +0 -1
  150. package/dist/esm/resources/clients.d.ts +0 -84
  151. package/dist/esm/resources/clients.d.ts.map +0 -1
  152. package/dist/esm/resources/clients.js +0 -97
  153. package/dist/esm/resources/clients.js.map +0 -1
  154. package/src/resources/clients.ts +0 -135
@@ -1,41 +1,47 @@
1
1
  import { seg } from '../core/http.js';
2
- /** Сети: TRON и EVM-сети с идентификаторами CAIP-2 */
2
+ /** Supported networks. */
3
3
  export class NetworksResource {
4
- #http;
5
- constructor(http) {
6
- this.#http = http;
4
+ #scope;
5
+ /** @internal */
6
+ constructor(scope) {
7
+ this.#scope = scope;
7
8
  }
8
- /** Все сети. `enabled: false` — сеть описана, но не читается: вебхуков по ней нет */
9
+ /** Lists all networks. Transfers are monitored on networks with `enabled: true`. */
9
10
  async list(options) {
10
- const r = await this.#http.request({ method: 'GET', path: '/v1/networks', idempotent: true, options });
11
+ const r = await this.#scope.http.request({ method: 'GET', path: '/v1/networks', idempotent: true, options });
11
12
  return r.items;
12
13
  }
13
- /** Сеть по slug (`tron`) или CAIP-2 (`eip155:1`) */
14
+ /**
15
+ * Retrieves a network.
16
+ *
17
+ * @param network - Network slug (`tron`, `ethereum`) or CAIP-2 ID (`eip155:1`).
18
+ */
14
19
  get(network, options) {
15
- return this.#http.request({ method: 'GET', path: `/v1/networks/${seg(network)}`, idempotent: true, options });
20
+ return this.#scope.http.request({ method: 'GET', path: `/v1/networks/${seg(network)}`, idempotent: true, options });
16
21
  }
17
22
  }
18
- /** Активы: нативные монеты и токены. Вебхуки приходят о переводах включённых активов не меньше порога `minAmount` */
23
+ /** Native coins and tokens. You are notified about transfers of enabled assets of at least `minAmount`. */
19
24
  export class AssetsResource {
20
- #http;
21
- constructor(http) {
22
- this.#http = http;
25
+ #scope;
26
+ /** @internal */
27
+ constructor(scope) {
28
+ this.#scope = scope;
23
29
  }
24
30
  /**
25
- * Активы — все или одной сети.
31
+ * Lists assets, optionally of one network.
26
32
  *
27
33
  * @example
28
34
  * ```ts
29
- * const usdt = (await monitoring.assets.list({ network: 'tron' })).find((a) => a.symbol === 'USDT')
30
- * formatUnits(webhook.tx.value, usdt!.decimals)
35
+ * const usdt = (await monitoring.assets.list({ network: 'tron' })).find((asset) => asset.symbol === 'USDT')
31
36
  * ```
32
37
  */
33
38
  async list(params = {}, options) {
34
- const r = await this.#http.request({ method: 'GET', path: '/v1/assets', query: params, idempotent: true, options });
39
+ const r = await this.#scope.http.request({ method: 'GET', path: '/v1/assets', query: params, idempotent: true, options });
35
40
  return r.items;
36
41
  }
42
+ /** Retrieves an asset by ID. */
37
43
  get(assetId, options) {
38
- return this.#http.request({ method: 'GET', path: `/v1/assets/${seg(assetId)}`, idempotent: true, options });
44
+ return this.#scope.http.request({ method: 'GET', path: `/v1/assets/${seg(assetId)}`, idempotent: true, options });
39
45
  }
40
46
  }
41
47
  //# sourceMappingURL=catalog.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../../src/resources/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAwC,MAAM,iBAAiB,CAAA;AAG3E,sDAAsD;AACtD,MAAM,OAAO,gBAAgB;IAClB,KAAK,CAAY;IAC1B,YAAY,IAAgB;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;IACnB,CAAC;IAED,qFAAqF;IACrF,KAAK,CAAC,IAAI,CAAC,OAAwB;QACjC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAuB,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;QAC5H,OAAO,CAAC,CAAC,KAAK,CAAA;IAChB,CAAC;IAED,oDAAoD;IACpD,GAAG,CAAC,OAAe,EAAE,OAAwB;QAC3C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;IAC/G,CAAC;CACF;AAED,qHAAqH;AACrH,MAAM,OAAO,cAAc;IAChB,KAAK,CAAY;IAC1B,YAAY,IAAgB;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;IACnB,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,IAAI,CAAC,MAAM,GAAy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O,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;IACrH,CAAC;CACF;AAED,2GAA2G;AAC3G,MAAM,OAAO,cAAc;IAChB,MAAM,CAAO;IAEtB,gBAAgB;IAChB,YAAY,KAAY;QACtB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,CAAC,MAAM,GAAyB,EAAE,EAAE,OAAwB;QACpE,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAY,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;QACpI,OAAO,CAAC,CAAC,KAAK,CAAA;IAChB,CAAC;IAED,gCAAgC;IAChC,GAAG,CAAC,OAAe,EAAE,OAAwB;QAC3C,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;IACnH,CAAC;CACF"}
@@ -1,50 +1,61 @@
1
- import { type HttpClient, type RequestOptions } from '../core/http.js';
2
- import { type Page } from '../core/pagination.js';
3
- import type { Delivery, DeliveryDetail, DeliveryStatus } from '../generated/types.js';
4
- /** Фильтры истории; все необязательны и сочетаются */
1
+ import { type RequestOptions } from '../core/http.js';
2
+ import type { Scope } from '../core/scope.js';
3
+ import type { Delivery, DeliveryDetail, DeliveryPage, DeliveryStatus } from '../generated/types.js';
4
+ /** Filters for webhook deliveries. All are optional and can be combined. */
5
5
  export interface DeliveryFilter {
6
- /** `delivered` — вы ответили 2xx, `retrying` — будет повтор, `failed` — повторы исчерпаны */
6
+ /** `delivered`, `retrying` or `failed`. */
7
7
  status?: DeliveryStatus;
8
- /** Сеть: slug или CAIP-2 */
8
+ /** Network slug or CAIP-2 ID. */
9
9
  network?: string;
10
- /** Символ актива */
10
+ /** Asset symbol. */
11
11
  asset?: string;
12
- /** Хеш транзакции */
12
+ /** Transaction hash. */
13
13
  tx?: string;
14
- /** Отправитель или получатель */
14
+ /** Sender or recipient address. */
15
15
  address?: string;
16
- /** Первая попытка не раньше (дата или время) */
16
+ /** First attempt at or after this time. */
17
17
  since?: Date | string;
18
- /** Первая попытка раньше (не включая) */
18
+ /** First attempt before this time. */
19
19
  until?: Date | string;
20
20
  }
21
+ /** Parameters of {@link DeliveriesResource.list}. */
21
22
  export interface ListDeliveriesParams extends DeliveryFilter {
22
- /** Размер страницы, до 500; по умолчанию 100 */
23
+ /** Page size, up to 500. Defaults to 100. */
23
24
  limit?: number;
24
- /** Курсор: `next` прошлой страницы */
25
+ /** Cursor: `next` of the previous page. */
25
26
  before?: number;
26
27
  }
27
28
  /**
28
- * История вебхуков клиента: что, когда и куда отправлено, сколько было попыток и что вы ответили.
29
- * Повторы одного вебхука — одна запись. Хранится 90 дней.
29
+ * Every webhook sent to you: status, attempts and your endpoint's response. Retries of the same webhook are one
30
+ * delivery with an attempt count. Deliveries are kept for 90 days.
30
31
  */
31
32
  export declare class DeliveriesResource {
32
33
  #private;
33
- constructor(http: HttpClient);
34
+ /** @internal */
35
+ constructor(scope: Scope);
34
36
  /**
35
- * Страница истории, новые сверху.
37
+ * Lists deliveries, newest first, one page at a time.
36
38
  *
37
39
  * @example
38
40
  * ```ts
39
- * const { items } = await monitoring.deliveries.list(clientId, { status: 'failed', since: new Date(Date.now() - 86_400_000) })
41
+ * const { items } = await monitoring.deliveries.list({ status: 'failed', since: new Date(Date.now() - 86_400_000) })
40
42
  * ```
41
43
  */
42
- list(clientId: string, params?: ListDeliveriesParams, options?: RequestOptions): Promise<Page<Delivery, number>>;
43
- /** Вся история по фильтру — от новых к старым, страница за страницей */
44
- iterate(clientId: string, filter?: DeliveryFilter & {
44
+ list(params?: ListDeliveriesParams, options?: RequestOptions): Promise<DeliveryPage>;
45
+ /**
46
+ * Iterates over all deliveries matching the filter, newest first.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * for await (const delivery of monitoring.deliveries.iterate({ status: 'failed' })) {
51
+ * console.log(delivery.txId, delivery.attempts, delivery.lastHttpStatus ?? delivery.lastError)
52
+ * }
53
+ * ```
54
+ */
55
+ iterate(filter?: DeliveryFilter & {
45
56
  limit?: number;
46
57
  }, options?: RequestOptions): AsyncGenerator<Delivery, void, undefined>;
47
- /** Одна запись с URL последней попытки и точным телом запроса */
48
- get(clientId: string, deliveryId: number, options?: RequestOptions): Promise<DeliveryDetail>;
58
+ /** Retrieves a delivery with the URL of the last attempt and the exact request body. */
59
+ get(deliveryId: number, options?: RequestOptions): Promise<DeliveryDetail>;
49
60
  }
50
61
  //# sourceMappingURL=deliveries.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deliveries.d.ts","sourceRoot":"","sources":["../../../src/resources/deliveries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC3E,OAAO,EAAY,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAErF,sDAAsD;AACtD,MAAM,WAAW,cAAc;IAC7B,6FAA6F;IAC7F,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB,4BAA4B;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,qBAAqB;IACrB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,gDAAgD;IAChD,KAAK,CAAC,EAAE,IAAI,GAA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,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,wBAAwB;IACxB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,2CAA2C;IAC3C,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,sCAAsC;IACtC,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;CACtB;AAED,qDAAqD;AACrD,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAID;;;GAGG;AACH,qBAAa,kBAAkB;;IAG7B,gBAAgB;IAChB,YAAY,KAAK,EAAE,KAAK,EAEvB;IAED;;;;;;;OAOG;IACG,IAAI,CAAC,MAAM,GAAE,oBAAyB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAQ7F;IAED;;;;;;;;;OASG;IACH,OAAO,CAAC,MAAM,GAAE,cAAc,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,CAAC,CAE7H;IAED,wFAAwF;IAClF,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAE/E;CACF"}
@@ -1,39 +1,49 @@
1
1
  import { seg } from '../core/http.js';
2
2
  import { paginate } from '../core/pagination.js';
3
- const iso = (v) => (v instanceof Date ? v.toISOString() : v);
3
+ const iso = (value) => (value instanceof Date ? value.toISOString() : value);
4
4
  /**
5
- * История вебхуков клиента: что, когда и куда отправлено, сколько было попыток и что вы ответили.
6
- * Повторы одного вебхука — одна запись. Хранится 90 дней.
5
+ * Every webhook sent to you: status, attempts and your endpoint's response. Retries of the same webhook are one
6
+ * delivery with an attempt count. Deliveries are kept for 90 days.
7
7
  */
8
8
  export class DeliveriesResource {
9
- #http;
10
- constructor(http) {
11
- this.#http = http;
9
+ #scope;
10
+ /** @internal */
11
+ constructor(scope) {
12
+ this.#scope = scope;
12
13
  }
13
14
  /**
14
- * Страница истории, новые сверху.
15
+ * Lists deliveries, newest first, one page at a time.
15
16
  *
16
17
  * @example
17
18
  * ```ts
18
- * const { items } = await monitoring.deliveries.list(clientId, { status: 'failed', since: new Date(Date.now() - 86_400_000) })
19
+ * const { items } = await monitoring.deliveries.list({ status: 'failed', since: new Date(Date.now() - 86_400_000) })
19
20
  * ```
20
21
  */
21
- list(clientId, params = {}, options) {
22
- return this.#http.request({
22
+ async list(params = {}, options) {
23
+ return this.#scope.http.request({
23
24
  method: 'GET',
24
- path: `/v1/clients/${seg(clientId)}/deliveries`,
25
+ path: `${await this.#scope.clientPath()}/deliveries`,
25
26
  query: { ...params, since: iso(params.since), until: iso(params.until) },
26
27
  idempotent: true,
27
28
  options,
28
29
  });
29
30
  }
30
- /** Вся история по фильтру — от новых к старым, страница за страницей */
31
- iterate(clientId, filter = {}, options) {
32
- return paginate((before) => this.list(clientId, { ...filter, before }, options));
31
+ /**
32
+ * Iterates over all deliveries matching the filter, newest first.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * for await (const delivery of monitoring.deliveries.iterate({ status: 'failed' })) {
37
+ * console.log(delivery.txId, delivery.attempts, delivery.lastHttpStatus ?? delivery.lastError)
38
+ * }
39
+ * ```
40
+ */
41
+ iterate(filter = {}, options) {
42
+ return paginate((before) => this.list({ ...filter, before }, options));
33
43
  }
34
- /** Одна запись с URL последней попытки и точным телом запроса */
35
- get(clientId, deliveryId, options) {
36
- return this.#http.request({ method: 'GET', path: `/v1/clients/${seg(clientId)}/deliveries/${seg(deliveryId)}`, idempotent: true, options });
44
+ /** Retrieves a delivery with the URL of the last attempt and the exact request body. */
45
+ async get(deliveryId, options) {
46
+ return this.#scope.http.request({ method: 'GET', path: `${await this.#scope.clientPath()}/deliveries/${seg(deliveryId)}`, idempotent: true, options });
37
47
  }
38
48
  }
39
49
  //# sourceMappingURL=deliveries.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"deliveries.js","sourceRoot":"","sources":["../../../src/resources/deliveries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAwC,MAAM,iBAAiB,CAAA;AAC3E,OAAO,EAAE,QAAQ,EAAa,MAAM,uBAAuB,CAAA;AA4B3D,MAAM,GAAG,GAAG,CAAC,CAA4B,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAEvF;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IACpB,KAAK,CAAY;IAC1B,YAAY,IAAgB;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;IACnB,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,CAAC,QAAgB,EAAE,MAAM,GAAyB,EAAE,EAAE,OAAwB;QAChF,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;YACxB,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,eAAe,GAAG,CAAC,QAAQ,CAAC,aAAa;YAC/C,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YACxE,UAAU,EAAE,IAAI;YAChB,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;IAED,wEAAwE;IACxE,OAAO,CAAC,QAAgB,EAAE,MAAM,GAAwC,EAAE,EAAE,OAAwB;QAClG,OAAO,QAAQ,CAAmB,CAAC,MAAM,EAAE,EAAE,CAAC,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AAK,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YACxE,UAAU,EAAE,IAAI;YAChB,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;;;;OASG;IACH,OAAO,CAAC,MAAM,GAAwC,EAAE,EAAE,OAAwB;QAChF,OAAO,QAAQ,CAAW,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC,CAAA;IAClF,CAAC;IAED,wFAAwF;IACxF,KAAK,CAAC,GAAG,CAAC,UAAkB,EAAE,OAAwB;QACpD,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,eAAe,GAAG,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;IACxJ,CAAC;CACF"}
@@ -1,26 +1,26 @@
1
- import { type HttpClient, type RequestOptions } from '../core/http.js';
1
+ import { type RequestOptions } from '../core/http.js';
2
+ import type { Scope } from '../core/scope.js';
2
3
  import type { Transaction } from '../generated/types.js';
3
- /** Любая транзакция сети по хешу — не только те, о которых пришёл вебхук */
4
+ /** Any transaction on a supported network, by hash. */
4
5
  export declare class TransactionsResource {
5
6
  #private;
6
- constructor(http: HttpClient);
7
+ /** @internal */
8
+ constructor(scope: Scope);
7
9
  /**
8
- * Статус, блок, подтверждения, финальность, комиссия и все переводы внутри транзакции; для ваших адресов —
9
- * направление и вебхуки, которые мы по ней отправили.
10
+ * Retrieves a transaction — not only the ones you were notified about: status, confirmations, finality, fee and
11
+ * every transfer inside it, plus your monitored addresses and the webhooks sent to you for it.
10
12
  *
11
- * `final: true` — транзакцию уже не отменить: в TRON блок солидифицирован (около минуты), в EVM —
12
- * финализирован (Ethereum — около 13 минут). Крупные суммы зачисляйте после `final`.
13
+ * `final: true` means the transaction can no longer be reverted: on TRON the block is solidified (about 1 minute),
14
+ * on EVM networks it is finalized (about 13 minutes on Ethereum). Credit large amounts once the transaction is final.
13
15
  *
14
- * Не больше 60 запросов в минуту на ключ; при превышении SDK подождёт и повторит.
15
- *
16
- * @param network - slug (`tron`, `ethereum`) или CAIP-2
17
- * @param hash - EVM — `0x` + 64 hex; TRON — 64 hex (можно с `0x`)
18
- * @throws {@link MonitoringApiError} 404 — такой транзакции в сети нет
16
+ * @param network - Network slug (`tron`, `ethereum`) or CAIP-2 ID.
17
+ * @param hash - EVM: `0x` followed by 64 hex characters. TRON: 64 hex characters.
18
+ * @throws {@link MonitoringApiError} `404` when the transaction does not exist on the network.
19
19
  *
20
20
  * @example
21
21
  * ```ts
22
- * const tx = await monitoring.transactions.get('tron', webhook.tx.id)
23
- * if (tx.status === 'success' && tx.final) credit(webhook)
22
+ * const tx = await monitoring.transactions.get('tron', event.tx.id)
23
+ * if (tx.status === 'success' && tx.final) await credit(event.tx)
24
24
  * ```
25
25
  */
26
26
  get(network: string, hash: string, options?: RequestOptions): Promise<Transaction>;
@@ -1 +1 @@
1
- {"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../../../src/resources/transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,4EAA4E;AAC5E,qBAAa,oBAAoB;;IAE/B,YAAY,IAAI,EAAE,UAAU,EAE3B;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,CAEjF;CACF"}
1
+ {"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../../../src/resources/transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,uDAAuD;AACvD,qBAAa,oBAAoB;;IAG/B,gBAAgB;IAChB,YAAY,KAAK,EAAE,KAAK,EAEvB;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,CAEjF;CACF"}
@@ -1,31 +1,30 @@
1
1
  import { seg } from '../core/http.js';
2
- /** Любая транзакция сети по хешу — не только те, о которых пришёл вебхук */
2
+ /** Any transaction on a supported network, by hash. */
3
3
  export class TransactionsResource {
4
- #http;
5
- constructor(http) {
6
- this.#http = http;
4
+ #scope;
5
+ /** @internal */
6
+ constructor(scope) {
7
+ this.#scope = scope;
7
8
  }
8
9
  /**
9
- * Статус, блок, подтверждения, финальность, комиссия и все переводы внутри транзакции; для ваших адресов —
10
- * направление и вебхуки, которые мы по ней отправили.
10
+ * Retrieves a transaction — not only the ones you were notified about: status, confirmations, finality, fee and
11
+ * every transfer inside it, plus your monitored addresses and the webhooks sent to you for it.
11
12
  *
12
- * `final: true` — транзакцию уже не отменить: в TRON блок солидифицирован (около минуты), в EVM —
13
- * финализирован (Ethereum — около 13 минут). Крупные суммы зачисляйте после `final`.
13
+ * `final: true` means the transaction can no longer be reverted: on TRON the block is solidified (about 1 minute),
14
+ * on EVM networks it is finalized (about 13 minutes on Ethereum). Credit large amounts once the transaction is final.
14
15
  *
15
- * Не больше 60 запросов в минуту на ключ; при превышении SDK подождёт и повторит.
16
- *
17
- * @param network - slug (`tron`, `ethereum`) или CAIP-2
18
- * @param hash - EVM — `0x` + 64 hex; TRON — 64 hex (можно с `0x`)
19
- * @throws {@link MonitoringApiError} 404 — такой транзакции в сети нет
16
+ * @param network - Network slug (`tron`, `ethereum`) or CAIP-2 ID.
17
+ * @param hash - EVM: `0x` followed by 64 hex characters. TRON: 64 hex characters.
18
+ * @throws {@link MonitoringApiError} `404` when the transaction does not exist on the network.
20
19
  *
21
20
  * @example
22
21
  * ```ts
23
- * const tx = await monitoring.transactions.get('tron', webhook.tx.id)
24
- * if (tx.status === 'success' && tx.final) credit(webhook)
22
+ * const tx = await monitoring.transactions.get('tron', event.tx.id)
23
+ * if (tx.status === 'success' && tx.final) await credit(event.tx)
25
24
  * ```
26
25
  */
27
26
  get(network, hash, options) {
28
- return this.#http.request({ method: 'GET', path: `/v1/networks/${seg(network)}/transactions/${seg(hash)}`, idempotent: true, options });
27
+ return this.#scope.http.request({ method: 'GET', path: `/v1/networks/${seg(network)}/transactions/${seg(hash)}`, idempotent: true, options });
29
28
  }
30
29
  }
31
30
  //# sourceMappingURL=transactions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transactions.js","sourceRoot":"","sources":["../../../src/resources/transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAwC,MAAM,iBAAiB,CAAA;AAG3E,4EAA4E;AAC5E,MAAM,OAAO,oBAAoB;IACtB,KAAK,CAAY;IAC1B,YAAY,IAAgB;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;IACnB,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,GAAG,CAAC,OAAe,EAAE,IAAY,EAAE,OAAwB;QACzD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,GAAG,CAAC,OAAO,CAAC,iBAAiB,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;IACzI,CAAC;CACF"}
1
+ {"version":3,"file":"transactions.js","sourceRoot":"","sources":["../../../src/resources/transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAuB,MAAM,iBAAiB,CAAA;AAI1D,uDAAuD;AACvD,MAAM,OAAO,oBAAoB;IACtB,MAAM,CAAO;IAEtB,gBAAgB;IAChB,YAAY,KAAY;QACtB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,GAAG,CAAC,OAAe,EAAE,IAAY,EAAE,OAAwB;QACzD,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,GAAG,CAAC,OAAO,CAAC,iBAAiB,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;IAC/I,CAAC;CACF"}
@@ -0,0 +1,22 @@
1
+ import type { RequestOptions } from '../core/http.js';
2
+ import type { Scope } from '../core/scope.js';
3
+ import type { TestWebhookRequest, TestWebhookResult } from '../generated/types.js';
4
+ /** Test your webhook endpoint. To receive webhooks, see {@link parseWebhook}. */
5
+ export declare class WebhooksResource {
6
+ #private;
7
+ /** @internal */
8
+ constructor(scope: Scope);
9
+ /**
10
+ * Sends a signed test webhook to your webhook URL and returns the outcome, the signature and the exact body sent.
11
+ * Test webhooks have `"test": true` in the body and the `x-webhook-test: 1` header — do not credit them.
12
+ * Limited to 10 per minute.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const { delivery } = await monitoring.webhooks.sendTest({ asset: 'USDT' })
17
+ * if (!delivery.ok) console.error('Endpoint responded with', delivery.status ?? delivery.error)
18
+ * ```
19
+ */
20
+ sendTest(params?: TestWebhookRequest, options?: RequestOptions): Promise<TestWebhookResult>;
21
+ }
22
+ //# sourceMappingURL=webhooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../../src/resources/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAElF,iFAAiF;AACjF,qBAAa,gBAAgB;;IAG3B,gBAAgB;IAChB,YAAY,KAAK,EAAE,KAAK,EAEvB;IAED;;;;;;;;;;OAUG;IACG,QAAQ,CAAC,MAAM,GAAE,kBAAuB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAUpG;CACF"}
@@ -0,0 +1,31 @@
1
+ /** Test your webhook endpoint. To receive webhooks, see {@link parseWebhook}. */
2
+ export class WebhooksResource {
3
+ #scope;
4
+ /** @internal */
5
+ constructor(scope) {
6
+ this.#scope = scope;
7
+ }
8
+ /**
9
+ * Sends a signed test webhook to your webhook URL and returns the outcome, the signature and the exact body sent.
10
+ * Test webhooks have `"test": true` in the body and the `x-webhook-test: 1` header — do not credit them.
11
+ * Limited to 10 per minute.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const { delivery } = await monitoring.webhooks.sendTest({ asset: 'USDT' })
16
+ * if (!delivery.ok) console.error('Endpoint responded with', delivery.status ?? delivery.error)
17
+ * ```
18
+ */
19
+ async sendTest(params = {}, options) {
20
+ return this.#scope.http.request({
21
+ method: 'POST',
22
+ path: `${await this.#scope.clientPath()}/webhooks/test`,
23
+ body: params,
24
+ idempotent: false,
25
+ // 502 means "your endpoint did not accept it": an outcome, not a failed request
26
+ acceptStatuses: [502],
27
+ options,
28
+ });
29
+ }
30
+ }
31
+ //# sourceMappingURL=webhooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../../src/resources/webhooks.ts"],"names":[],"mappings":"AAIA,iFAAiF;AACjF,MAAM,OAAO,gBAAgB;IAClB,MAAM,CAAO;IAEtB,gBAAgB;IAChB,YAAY,KAAY;QACtB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAuB,EAAE,EAAE,OAAwB;QACtE,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;YAC9B,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,gBAAgB;YACvD,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,KAAK;YACjB,gFAAgF;YAChF,cAAc,EAAE,CAAC,GAAG,CAAC;YACrB,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -1,28 +1,28 @@
1
1
  /**
2
- * Суммы в API и вебхуках — строки в минимальных единицах (sun, wei; у USDT 6 знаков после запятой): uint256 не
3
- * помещается в `number`. Эти функции переводят их в привычный вид и обратно без потери точности.
4
- * Знаки после запятой актива — `decimals` из `monitoring.assets.list()`.
2
+ * Amounts in the API and in webhooks are decimal strings in the asset's smallest unit (sun, wei; USDT has 6 decimals),
3
+ * because uint256 values do not fit in a `number`. These helpers convert them without losing precision. The decimals
4
+ * of every asset are returned by `monitoring.assets.list()`.
5
5
  */
6
6
  /**
7
- * Минимальные единицы → строка в монетах.
7
+ * Converts an amount in the smallest unit to a decimal string.
8
8
  *
9
9
  * @example
10
10
  * ```ts
11
- * formatUnits('100000000', 6) // '100' — 100 USDT
12
- * formatUnits('1500000', 6) // '1.5'
13
- * formatUnits('10090000000000000', 18) // '0.01009' — ETH
11
+ * formatUnits('100000000', 6) // '100' — 100 USDT
12
+ * formatUnits('1500000', 6) // '1.5'
13
+ * formatUnits('10090000000000000', 18) // '0.01009' — ETH
14
14
  * ```
15
15
  */
16
16
  export declare function formatUnits(value: string | bigint, decimals: number): string;
17
17
  /**
18
- * Строка в монетах → минимальные единицы.
18
+ * Converts a decimal string to an amount in the smallest unit.
19
19
  *
20
- * @throws RangeError — больше знаков после запятой, чем у актива, или не число
20
+ * @throws RangeError when the amount is not a non-negative decimal or has more decimal places than the asset.
21
21
  *
22
22
  * @example
23
23
  * ```ts
24
- * parseUnits('1.5', 6) // '1500000'
25
- * parseUnits('100', 6) // '100000000'
24
+ * parseUnits('1.5', 6) // '1500000'
25
+ * parseUnits('100', 6) // '100000000'
26
26
  * ```
27
27
  */
28
28
  export declare function parseUnits(amount: string, decimals: number): string;
package/dist/esm/units.js CHANGED
@@ -1,25 +1,25 @@
1
1
  /**
2
- * Суммы в API и вебхуках — строки в минимальных единицах (sun, wei; у USDT 6 знаков после запятой): uint256 не
3
- * помещается в `number`. Эти функции переводят их в привычный вид и обратно без потери точности.
4
- * Знаки после запятой актива — `decimals` из `monitoring.assets.list()`.
2
+ * Amounts in the API and in webhooks are decimal strings in the asset's smallest unit (sun, wei; USDT has 6 decimals),
3
+ * because uint256 values do not fit in a `number`. These helpers convert them without losing precision. The decimals
4
+ * of every asset are returned by `monitoring.assets.list()`.
5
5
  */
6
6
  const INTEGER = /^-?\d+$/;
7
7
  const DECIMAL = /^(\d+)(?:\.(\d+))?$/;
8
8
  /**
9
- * Минимальные единицы → строка в монетах.
9
+ * Converts an amount in the smallest unit to a decimal string.
10
10
  *
11
11
  * @example
12
12
  * ```ts
13
- * formatUnits('100000000', 6) // '100' — 100 USDT
14
- * formatUnits('1500000', 6) // '1.5'
15
- * formatUnits('10090000000000000', 18) // '0.01009' — ETH
13
+ * formatUnits('100000000', 6) // '100' — 100 USDT
14
+ * formatUnits('1500000', 6) // '1.5'
15
+ * formatUnits('10090000000000000', 18) // '0.01009' — ETH
16
16
  * ```
17
17
  */
18
18
  export function formatUnits(value, decimals) {
19
19
  assertDecimals(decimals);
20
20
  const raw = typeof value === 'bigint' ? value.toString() : value.trim();
21
21
  if (!INTEGER.test(raw))
22
- throw new RangeError(`formatUnits: integer in minimal units expected, got ${JSON.stringify(value)}`);
22
+ throw new RangeError(`formatUnits: expected an integer amount in the smallest unit, got ${JSON.stringify(value)}`);
23
23
  const negative = raw.startsWith('-');
24
24
  const digits = (negative ? raw.slice(1) : raw).replace(/^0+(?=\d)/, '');
25
25
  if (decimals === 0)
@@ -31,21 +31,21 @@ export function formatUnits(value, decimals) {
31
31
  return `${sign}${whole}${fraction ? `.${fraction}` : ''}`;
32
32
  }
33
33
  /**
34
- * Строка в монетах → минимальные единицы.
34
+ * Converts a decimal string to an amount in the smallest unit.
35
35
  *
36
- * @throws RangeError — больше знаков после запятой, чем у актива, или не число
36
+ * @throws RangeError when the amount is not a non-negative decimal or has more decimal places than the asset.
37
37
  *
38
38
  * @example
39
39
  * ```ts
40
- * parseUnits('1.5', 6) // '1500000'
41
- * parseUnits('100', 6) // '100000000'
40
+ * parseUnits('1.5', 6) // '1500000'
41
+ * parseUnits('100', 6) // '100000000'
42
42
  * ```
43
43
  */
44
44
  export function parseUnits(amount, decimals) {
45
45
  assertDecimals(decimals);
46
46
  const m = DECIMAL.exec(amount.trim());
47
47
  if (!m)
48
- throw new RangeError(`parseUnits: non-negative decimal expected, got ${JSON.stringify(amount)}`);
48
+ throw new RangeError(`parseUnits: expected a non-negative decimal, got ${JSON.stringify(amount)}`);
49
49
  const fraction = m[2] ?? '';
50
50
  if (fraction.length > decimals)
51
51
  throw new RangeError(`parseUnits: ${amount} has more than ${decimals} decimal places`);
@@ -53,6 +53,6 @@ export function parseUnits(amount, decimals) {
53
53
  }
54
54
  function assertDecimals(decimals) {
55
55
  if (!Number.isInteger(decimals) || decimals < 0 || decimals > 255)
56
- throw new RangeError(`decimals: integer 0..255 expected, got ${decimals}`);
56
+ throw new RangeError(`decimals: expected an integer from 0 to 255, got ${decimals}`);
57
57
  }
58
58
  //# sourceMappingURL=units.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"units.js","sourceRoot":"","sources":["../../src/units.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA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,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;AAC3D,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,QAAgB;IACzD,cAAc,CAAC,QAAQ,CAAC,CAAA;IACxB,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;IACrC,IAAI,CAAC,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,oDAAoD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAC1G,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IAC3B,IAAI,QAAQ,CAAC,MAAM,GAAG,QAAQ;QAAE,MAAM,IAAI,UAAU,CAAC,eAAe,MAAM,kBAAkB,QAAQ,iBAAiB,CAAC,CAAA;IACtH,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,CAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;AAClE,CAAC;AAED,SAAS,cAAc,CAAC,QAAgB;IACtC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,IAAI,QAAQ,GAAG,GAAG;QAAE,MAAM,IAAI,UAAU,CAAC,oDAAoD,QAAQ,EAAE,CAAC,CAAA;AACzJ,CAAC"}
@@ -1,5 +1,5 @@
1
- /** Версия SDK: уходит в заголовке `user-agent`. Тест сверяет её с package.json */
2
- export declare const SDK_VERSION = "0.1.0";
3
- /** Адрес API по умолчанию */
1
+ /** SDK version, sent in the `user-agent` header. */
2
+ export declare const SDK_VERSION = "0.2.0";
3
+ /** Default API base URL. */
4
4
  export declare const DEFAULT_BASE_URL = "https://monitoring.v3.finance";
5
5
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,eAAO,MAAM,WAAW,UAAU,CAAA;AAElC,6BAA6B;AAC7B,eAAO,MAAM,gBAAgB,kCAAkC,CAAA"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,eAAO,MAAM,WAAW,UAAU,CAAA;AAElC,4BAA4B;AAC5B,eAAO,MAAM,gBAAgB,kCAAkC,CAAA"}
@@ -1,5 +1,5 @@
1
- /** Версия SDK: уходит в заголовке `user-agent`. Тест сверяет её с package.json */
2
- export const SDK_VERSION = '0.1.0';
3
- /** Адрес API по умолчанию */
1
+ /** SDK version, sent in the `user-agent` header. */
2
+ export const SDK_VERSION = '0.2.0';
3
+ /** Default API base URL. */
4
4
  export const DEFAULT_BASE_URL = 'https://monitoring.v3.finance';
5
5
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAA;AAElC,6BAA6B;AAC7B,MAAM,CAAC,MAAM,gBAAgB,GAAG,+BAA+B,CAAA"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAA;AAElC,4BAA4B;AAC5B,MAAM,CAAC,MAAM,gBAAgB,GAAG,+BAA+B,CAAA"}