@spectratools/cli-shared 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9,6 +9,9 @@ function weiToEth(wei, decimals = 6) {
|
|
|
9
9
|
const fracStr = frac.toString().padStart(18, "0").slice(0, decimals).replace(/0+$/, "");
|
|
10
10
|
return fracStr.length > 0 ? `${whole}.${fracStr}` : `${whole}`;
|
|
11
11
|
}
|
|
12
|
+
function isAddress(address) {
|
|
13
|
+
return Address.validate(address);
|
|
14
|
+
}
|
|
12
15
|
function checksumAddress(address) {
|
|
13
16
|
return Address.checksum(address);
|
|
14
17
|
}
|
|
@@ -22,6 +25,7 @@ function truncate(str, prefixLen = 6, suffixLen = 4) {
|
|
|
22
25
|
|
|
23
26
|
export {
|
|
24
27
|
weiToEth,
|
|
28
|
+
isAddress,
|
|
25
29
|
checksumAddress,
|
|
26
30
|
formatTimestamp,
|
|
27
31
|
truncate
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { ApiKeyAuthContext, CursorPaginationOptions, MissingApiKeyError, OffsetPaginationOptions, RateLimitOptions, RetryOptions, apiKeyAuth, createRateLimiter, paginateCursor, paginateOffset, withRateLimit, withRetry } from './middleware/index.js';
|
|
2
2
|
export { MockResponse, MockServer, RecordedRequest, createMockServer } from './testing/index.js';
|
|
3
|
-
export { HttpClientOptions, HttpError, RequestOptions, checksumAddress, createHttpClient, formatTimestamp, truncate, weiToEth } from './utils/index.js';
|
|
3
|
+
export { HttpClientOptions, HttpError, RequestOptions, checksumAddress, createHttpClient, formatTimestamp, isAddress, truncate, weiToEth } from './utils/index.js';
|
package/dist/index.js
CHANGED
|
@@ -7,19 +7,20 @@ import {
|
|
|
7
7
|
withRateLimit,
|
|
8
8
|
withRetry
|
|
9
9
|
} from "./chunk-74BQLM22.js";
|
|
10
|
+
import {
|
|
11
|
+
createMockServer
|
|
12
|
+
} from "./chunk-QEANTXUE.js";
|
|
10
13
|
import {
|
|
11
14
|
checksumAddress,
|
|
12
15
|
formatTimestamp,
|
|
16
|
+
isAddress,
|
|
13
17
|
truncate,
|
|
14
18
|
weiToEth
|
|
15
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-OPDNZWSI.js";
|
|
16
20
|
import {
|
|
17
21
|
HttpError,
|
|
18
22
|
createHttpClient
|
|
19
23
|
} from "./chunk-TKORXDDX.js";
|
|
20
|
-
import {
|
|
21
|
-
createMockServer
|
|
22
|
-
} from "./chunk-QEANTXUE.js";
|
|
23
24
|
export {
|
|
24
25
|
HttpError,
|
|
25
26
|
MissingApiKeyError,
|
|
@@ -29,6 +30,7 @@ export {
|
|
|
29
30
|
createMockServer,
|
|
30
31
|
createRateLimiter,
|
|
31
32
|
formatTimestamp,
|
|
33
|
+
isAddress,
|
|
32
34
|
paginateCursor,
|
|
33
35
|
paginateOffset,
|
|
34
36
|
truncate,
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* Converts wei (as bigint or string) to a human-readable ETH string.
|
|
3
3
|
*/
|
|
4
4
|
declare function weiToEth(wei: bigint | string, decimals?: number): string;
|
|
5
|
+
/**
|
|
6
|
+
* Returns true if the value is a valid 0x-prefixed 20-byte hex address.
|
|
7
|
+
*/
|
|
8
|
+
declare function isAddress(address: string): boolean;
|
|
5
9
|
/**
|
|
6
10
|
* Checksums an Ethereum address using EIP-55.
|
|
7
11
|
* Accepts lowercase or mixed-case hex addresses.
|
|
@@ -40,4 +44,4 @@ declare function createHttpClient(options: HttpClientOptions): {
|
|
|
40
44
|
request: <T>(path: string, opts?: RequestOptions) => Promise<T>;
|
|
41
45
|
};
|
|
42
46
|
|
|
43
|
-
export { type HttpClientOptions, HttpError, type RequestOptions, checksumAddress, createHttpClient, formatTimestamp, truncate, weiToEth };
|
|
47
|
+
export { type HttpClientOptions, HttpError, type RequestOptions, checksumAddress, createHttpClient, formatTimestamp, isAddress, truncate, weiToEth };
|
package/dist/utils/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
checksumAddress,
|
|
3
3
|
formatTimestamp,
|
|
4
|
+
isAddress,
|
|
4
5
|
truncate,
|
|
5
6
|
weiToEth
|
|
6
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-OPDNZWSI.js";
|
|
7
8
|
import {
|
|
8
9
|
HttpError,
|
|
9
10
|
createHttpClient
|
|
@@ -13,6 +14,7 @@ export {
|
|
|
13
14
|
checksumAddress,
|
|
14
15
|
createHttpClient,
|
|
15
16
|
formatTimestamp,
|
|
17
|
+
isAddress,
|
|
16
18
|
truncate,
|
|
17
19
|
weiToEth
|
|
18
20
|
};
|