@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.
- package/CHANGELOG.md +21 -11
- package/README.md +223 -148
- package/dist/cjs/client.d.ts +23 -42
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +44 -53
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/core/errors.d.ts +18 -18
- package/dist/cjs/core/errors.d.ts.map +1 -1
- package/dist/cjs/core/errors.js +17 -17
- package/dist/cjs/core/errors.js.map +1 -1
- package/dist/cjs/core/http.d.ts +22 -26
- package/dist/cjs/core/http.d.ts.map +1 -1
- package/dist/cjs/core/http.js +28 -36
- package/dist/cjs/core/http.js.map +1 -1
- package/dist/cjs/core/pagination.d.ts +6 -7
- package/dist/cjs/core/pagination.d.ts.map +1 -1
- package/dist/cjs/core/pagination.js +1 -1
- package/dist/cjs/core/pagination.js.map +1 -1
- package/dist/cjs/core/scope.d.ts +8 -0
- package/dist/cjs/core/scope.d.ts.map +1 -0
- package/dist/cjs/core/scope.js +3 -0
- package/dist/cjs/core/scope.js.map +1 -0
- package/dist/cjs/generated/types.d.ts +129 -117
- package/dist/cjs/generated/types.d.ts.map +1 -1
- package/dist/cjs/generated/types.js +1 -1
- package/dist/cjs/generated/types.js.map +1 -1
- package/dist/cjs/index.d.ts +6 -6
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +13 -16
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/resources/account.d.ts +12 -51
- package/dist/cjs/resources/account.d.ts.map +1 -1
- package/dist/cjs/resources/account.js +17 -61
- package/dist/cjs/resources/account.js.map +1 -1
- package/dist/cjs/resources/addresses.d.ts +49 -65
- package/dist/cjs/resources/addresses.d.ts.map +1 -1
- package/dist/cjs/resources/addresses.js +60 -69
- package/dist/cjs/resources/addresses.js.map +1 -1
- package/dist/cjs/resources/catalog.d.ts +17 -10
- package/dist/cjs/resources/catalog.d.ts.map +1 -1
- package/dist/cjs/resources/catalog.js +23 -17
- package/dist/cjs/resources/catalog.js.map +1 -1
- package/dist/cjs/resources/deliveries.d.ts +34 -23
- package/dist/cjs/resources/deliveries.d.ts.map +1 -1
- package/dist/cjs/resources/deliveries.js +27 -17
- package/dist/cjs/resources/deliveries.js.map +1 -1
- package/dist/cjs/resources/transactions.d.ts +14 -14
- package/dist/cjs/resources/transactions.d.ts.map +1 -1
- package/dist/cjs/resources/transactions.js +15 -16
- package/dist/cjs/resources/transactions.js.map +1 -1
- package/dist/cjs/resources/webhooks.d.ts +22 -0
- package/dist/cjs/resources/webhooks.d.ts.map +1 -0
- package/dist/cjs/resources/webhooks.js +35 -0
- package/dist/cjs/resources/webhooks.js.map +1 -0
- package/dist/cjs/units.d.ts +11 -11
- package/dist/cjs/units.js +14 -14
- package/dist/cjs/units.js.map +1 -1
- package/dist/cjs/version.d.ts +3 -3
- package/dist/cjs/version.d.ts.map +1 -1
- package/dist/cjs/version.js +3 -3
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/webhooks.d.ts +33 -28
- package/dist/cjs/webhooks.d.ts.map +1 -1
- package/dist/cjs/webhooks.js +33 -28
- package/dist/cjs/webhooks.js.map +1 -1
- package/dist/esm/client.d.ts +23 -42
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +46 -55
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/core/errors.d.ts +18 -18
- package/dist/esm/core/errors.d.ts.map +1 -1
- package/dist/esm/core/errors.js +17 -17
- package/dist/esm/core/errors.js.map +1 -1
- package/dist/esm/core/http.d.ts +22 -26
- package/dist/esm/core/http.d.ts.map +1 -1
- package/dist/esm/core/http.js +28 -36
- package/dist/esm/core/http.js.map +1 -1
- package/dist/esm/core/pagination.d.ts +6 -7
- package/dist/esm/core/pagination.d.ts.map +1 -1
- package/dist/esm/core/pagination.js +1 -1
- package/dist/esm/core/pagination.js.map +1 -1
- package/dist/esm/core/scope.d.ts +8 -0
- package/dist/esm/core/scope.d.ts.map +1 -0
- package/dist/esm/core/scope.js +2 -0
- package/dist/esm/core/scope.js.map +1 -0
- package/dist/esm/generated/types.d.ts +129 -117
- package/dist/esm/generated/types.d.ts.map +1 -1
- package/dist/esm/generated/types.js +1 -1
- package/dist/esm/generated/types.js.map +1 -1
- package/dist/esm/index.d.ts +6 -6
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +6 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/resources/account.d.ts +12 -51
- package/dist/esm/resources/account.d.ts.map +1 -1
- package/dist/esm/resources/account.js +15 -57
- package/dist/esm/resources/account.js.map +1 -1
- package/dist/esm/resources/addresses.d.ts +49 -65
- package/dist/esm/resources/addresses.d.ts.map +1 -1
- package/dist/esm/resources/addresses.js +60 -69
- package/dist/esm/resources/addresses.js.map +1 -1
- package/dist/esm/resources/catalog.d.ts +17 -10
- package/dist/esm/resources/catalog.d.ts.map +1 -1
- package/dist/esm/resources/catalog.js +23 -17
- package/dist/esm/resources/catalog.js.map +1 -1
- package/dist/esm/resources/deliveries.d.ts +34 -23
- package/dist/esm/resources/deliveries.d.ts.map +1 -1
- package/dist/esm/resources/deliveries.js +27 -17
- package/dist/esm/resources/deliveries.js.map +1 -1
- package/dist/esm/resources/transactions.d.ts +14 -14
- package/dist/esm/resources/transactions.d.ts.map +1 -1
- package/dist/esm/resources/transactions.js +15 -16
- package/dist/esm/resources/transactions.js.map +1 -1
- package/dist/esm/resources/webhooks.d.ts +22 -0
- package/dist/esm/resources/webhooks.d.ts.map +1 -0
- package/dist/esm/resources/webhooks.js +31 -0
- package/dist/esm/resources/webhooks.js.map +1 -0
- package/dist/esm/units.d.ts +11 -11
- package/dist/esm/units.js +14 -14
- package/dist/esm/units.js.map +1 -1
- package/dist/esm/version.d.ts +3 -3
- package/dist/esm/version.d.ts.map +1 -1
- package/dist/esm/version.js +3 -3
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/webhooks.d.ts +33 -28
- package/dist/esm/webhooks.d.ts.map +1 -1
- package/dist/esm/webhooks.js +33 -28
- package/dist/esm/webhooks.js.map +1 -1
- package/package.json +8 -5
- package/src/client.ts +50 -61
- package/src/core/errors.ts +18 -18
- package/src/core/http.ts +45 -55
- package/src/core/pagination.ts +7 -8
- package/src/core/scope.ts +8 -0
- package/src/generated/types.ts +139 -125
- package/src/index.ts +7 -24
- package/src/resources/account.ts +18 -72
- package/src/resources/addresses.ts +84 -109
- package/src/resources/catalog.ts +28 -19
- package/src/resources/deliveries.ts +43 -30
- package/src/resources/transactions.ts +18 -17
- package/src/resources/webhooks.ts +36 -0
- package/src/units.ts +14 -14
- package/src/version.ts +3 -3
- package/src/webhooks.ts +37 -32
- package/dist/cjs/resources/clients.d.ts +0 -84
- package/dist/cjs/resources/clients.d.ts.map +0 -1
- package/dist/cjs/resources/clients.js +0 -102
- package/dist/cjs/resources/clients.js.map +0 -1
- package/dist/esm/resources/clients.d.ts +0 -84
- package/dist/esm/resources/clients.d.ts.map +0 -1
- package/dist/esm/resources/clients.js +0 -97
- package/dist/esm/resources/clients.js.map +0 -1
- package/src/resources/clients.ts +0 -135
|
@@ -1,41 +1,47 @@
|
|
|
1
1
|
import { seg } from '../core/http.js';
|
|
2
|
-
/**
|
|
2
|
+
/** Supported networks. */
|
|
3
3
|
export class NetworksResource {
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
#scope;
|
|
5
|
+
/** @internal */
|
|
6
|
+
constructor(scope) {
|
|
7
|
+
this.#scope = scope;
|
|
7
8
|
}
|
|
8
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
23
|
+
/** Native coins and tokens. You are notified about transfers of enabled assets of at least `minAmount`. */
|
|
19
24
|
export class AssetsResource {
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
|
|
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((
|
|
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,
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../../src/resources/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAuB,MAAM,iBAAiB,CAAA;AAI1D,0BAA0B;AAC1B,MAAM,OAAO,gBAAgB;IAClB,MAAM,CAAO;IAEtB,gBAAgB;IAChB,YAAY,KAAY;QACtB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;IAED,oFAAoF;IACpF,KAAK,CAAC,IAAI,CAAC,OAAwB;QACjC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAc,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;QACzH,OAAO,CAAC,CAAC,KAAK,CAAA;IAChB,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,OAAe,EAAE,OAAwB;QAC3C,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,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;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
|
|
2
|
-
import {
|
|
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
|
|
6
|
+
/** `delivered`, `retrying` or `failed`. */
|
|
7
7
|
status?: DeliveryStatus;
|
|
8
|
-
/**
|
|
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
|
-
/**
|
|
23
|
+
/** Page size, up to 500. Defaults to 100. */
|
|
23
24
|
limit?: number;
|
|
24
|
-
/**
|
|
25
|
+
/** Cursor: `next` of the previous page. */
|
|
25
26
|
before?: number;
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
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
|
-
|
|
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(
|
|
41
|
+
* const { items } = await monitoring.deliveries.list({ status: 'failed', since: new Date(Date.now() - 86_400_000) })
|
|
40
42
|
* ```
|
|
41
43
|
*/
|
|
42
|
-
list(
|
|
43
|
-
/**
|
|
44
|
-
|
|
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
|
-
/**
|
|
48
|
-
get(
|
|
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,
|
|
1
|
+
{"version":3,"file":"deliveries.d.ts","sourceRoot":"","sources":["../../../src/resources/deliveries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAE1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEnG,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB,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 = (
|
|
3
|
+
const iso = (value) => (value instanceof Date ? value.toISOString() : value);
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
-
#
|
|
10
|
-
|
|
11
|
-
|
|
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(
|
|
19
|
+
* const { items } = await monitoring.deliveries.list({ status: 'failed', since: new Date(Date.now() - 86_400_000) })
|
|
19
20
|
* ```
|
|
20
21
|
*/
|
|
21
|
-
list(
|
|
22
|
-
return this.#http.request({
|
|
22
|
+
async list(params = {}, options) {
|
|
23
|
+
return this.#scope.http.request({
|
|
23
24
|
method: 'GET',
|
|
24
|
-
path:
|
|
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
|
-
|
|
32
|
-
|
|
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
|
-
/**
|
|
35
|
-
get(
|
|
36
|
-
return this.#http.request({ method: 'GET', path:
|
|
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,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,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
|
|
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
|
-
|
|
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`
|
|
12
|
-
*
|
|
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
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* @
|
|
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',
|
|
23
|
-
* if (tx.status === 'success' && tx.final) credit(
|
|
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,
|
|
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
|
-
#
|
|
5
|
-
|
|
6
|
-
|
|
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`
|
|
13
|
-
*
|
|
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
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @
|
|
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',
|
|
24
|
-
* if (tx.status === 'success' && tx.final) credit(
|
|
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,
|
|
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"}
|
package/dist/esm/units.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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)
|
|
12
|
-
* formatUnits('1500000', 6)
|
|
13
|
-
* formatUnits('10090000000000000', 18)
|
|
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)
|
|
25
|
-
* parseUnits('100', 6)
|
|
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
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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)
|
|
14
|
-
* formatUnits('1500000', 6)
|
|
15
|
-
* formatUnits('10090000000000000', 18)
|
|
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
|
|
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)
|
|
41
|
-
* parseUnits('100', 6)
|
|
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
|
|
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
|
|
56
|
+
throw new RangeError(`decimals: expected an integer from 0 to 255, got ${decimals}`);
|
|
57
57
|
}
|
|
58
58
|
//# sourceMappingURL=units.js.map
|
package/dist/esm/units.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"units.js","sourceRoot":"","sources":["../../src/units.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,OAAO,GAAG,SAAS,CAAA;AACzB,MAAM,OAAO,GAAG,qBAAqB,CAAA;AAErC;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAAC,KAAsB,EAAE,QAAgB;IAClE,cAAc,CAAC,QAAQ,CAAC,CAAA;IACxB,MAAM,GAAG,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;IACvE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"units.js","sourceRoot":"","sources":["../../src/units.ts"],"names":[],"mappings":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
|
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,
|
|
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"}
|
package/dist/esm/version.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export const SDK_VERSION = '0.
|
|
3
|
-
/**
|
|
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
|
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,
|
|
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"}
|