@xylabs/eth-address 5.0.94 → 5.0.96
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/README.md +103 -112
- package/package.json +7 -11
package/README.md
CHANGED
|
@@ -1,45 +1,52 @@
|
|
|
1
1
|
# @xylabs/eth-address
|
|
2
2
|
|
|
3
|
-
[![
|
|
3
|
+
[![npm][npm-badge]][npm-link]
|
|
4
|
+
[![license][license-badge]][license-link]
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
[![npm-badge][]][npm-link]
|
|
7
|
-
[![npm-downloads-badge][]][npm-link]
|
|
8
|
-
[![jsdelivr-badge][]][jsdelivr-link]
|
|
9
|
-
[![npm-license-badge][]](LICENSE)
|
|
10
|
-
[![codacy-badge][]][codacy-link]
|
|
11
|
-
[![codeclimate-badge][]][codeclimate-link]
|
|
12
|
-
[![snyk-badge][]][snyk-link]
|
|
13
|
-
[![socket-badge][]][socket-link]
|
|
6
|
+
> Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
14
7
|
|
|
8
|
+
## Install
|
|
15
9
|
|
|
16
|
-
|
|
10
|
+
Using npm:
|
|
17
11
|
|
|
12
|
+
```sh
|
|
13
|
+
npm install {{name}}
|
|
14
|
+
```
|
|
18
15
|
|
|
16
|
+
Using yarn:
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
```sh
|
|
19
|
+
yarn add {{name}}
|
|
20
|
+
```
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Using pnpm:
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
```sh
|
|
25
|
+
pnpm add {{name}}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Using bun:
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
```sh
|
|
31
|
+
bun add {{name}}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
See the [LICENSE](LICENSE) file for license rights and limitations (LGPL-3.0-only).
|
|
38
|
+
|
|
39
|
+
## Reference
|
|
27
40
|
|
|
28
|
-
|
|
29
|
-
| ------ | ------ |
|
|
30
|
-
| [EthAddressWrapper](#classes/EthAddressWrapper) | Wrapper around an Ethereum address providing parsing, formatting, validation, and checksum support. |
|
|
41
|
+
### packages
|
|
31
42
|
|
|
32
|
-
|
|
43
|
+
### eth-address
|
|
33
44
|
|
|
34
|
-
|
|
35
|
-
| ------ | ------ |
|
|
36
|
-
| [isEthAddressWrapper](#functions/isEthAddressWrapper) | Type guard that checks if the given object is an instance of EthAddressWrapper. |
|
|
37
|
-
| [ellipsize](#functions/ellipsize) | Truncates a string to show the first and last `length` characters separated by an ellipsis. |
|
|
38
|
-
| [padHex](#functions/padHex) | - |
|
|
45
|
+
### .temp-typedoc
|
|
39
46
|
|
|
40
|
-
### classes
|
|
47
|
+
### classes
|
|
41
48
|
|
|
42
|
-
|
|
49
|
+
### <a id="EthAddressWrapper"></a>EthAddressWrapper
|
|
43
50
|
|
|
44
51
|
[**@xylabs/eth-address**](#../README)
|
|
45
52
|
|
|
@@ -52,14 +59,14 @@ Wrapper around an Ethereum address providing parsing, formatting, validation, an
|
|
|
52
59
|
### Constructor
|
|
53
60
|
|
|
54
61
|
```ts
|
|
55
|
-
protected new EthAddressWrapper(address
|
|
62
|
+
protected new EthAddressWrapper(address): EthAddressWrapper;
|
|
56
63
|
```
|
|
57
64
|
|
|
58
65
|
### Parameters
|
|
59
66
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
#### address
|
|
68
|
+
|
|
69
|
+
`bigint`
|
|
63
70
|
|
|
64
71
|
### Returns
|
|
65
72
|
|
|
@@ -70,15 +77,18 @@ protected new EthAddressWrapper(address: bigint): EthAddressWrapper;
|
|
|
70
77
|
### fromString()
|
|
71
78
|
|
|
72
79
|
```ts
|
|
73
|
-
static fromString(value
|
|
80
|
+
static fromString(value?, base?): EthAddressWrapper | undefined;
|
|
74
81
|
```
|
|
75
82
|
|
|
76
83
|
### Parameters
|
|
77
84
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
85
|
+
#### value?
|
|
86
|
+
|
|
87
|
+
`string`
|
|
88
|
+
|
|
89
|
+
#### base?
|
|
90
|
+
|
|
91
|
+
`number` = `16`
|
|
82
92
|
|
|
83
93
|
### Returns
|
|
84
94
|
|
|
@@ -89,15 +99,18 @@ static fromString(value?: string, base?: number): EthAddressWrapper | undefined;
|
|
|
89
99
|
### parse()
|
|
90
100
|
|
|
91
101
|
```ts
|
|
92
|
-
static parse(value
|
|
102
|
+
static parse(value, base?): EthAddressWrapper | undefined;
|
|
93
103
|
```
|
|
94
104
|
|
|
95
105
|
### Parameters
|
|
96
106
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
107
|
+
#### value
|
|
108
|
+
|
|
109
|
+
`unknown`
|
|
110
|
+
|
|
111
|
+
#### base?
|
|
112
|
+
|
|
113
|
+
`number`
|
|
101
114
|
|
|
102
115
|
### Returns
|
|
103
116
|
|
|
@@ -108,14 +121,14 @@ static parse(value: unknown, base?: number): EthAddressWrapper | undefined;
|
|
|
108
121
|
### validate()
|
|
109
122
|
|
|
110
123
|
```ts
|
|
111
|
-
static validate(address
|
|
124
|
+
static validate(address): boolean;
|
|
112
125
|
```
|
|
113
126
|
|
|
114
127
|
### Parameters
|
|
115
128
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
129
|
+
#### address
|
|
130
|
+
|
|
131
|
+
`string`
|
|
119
132
|
|
|
120
133
|
### Returns
|
|
121
134
|
|
|
@@ -126,14 +139,14 @@ static validate(address: string): boolean;
|
|
|
126
139
|
### equals()
|
|
127
140
|
|
|
128
141
|
```ts
|
|
129
|
-
equals(address
|
|
142
|
+
equals(address?): boolean;
|
|
130
143
|
```
|
|
131
144
|
|
|
132
145
|
### Parameters
|
|
133
146
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
147
|
+
#### address?
|
|
148
|
+
|
|
149
|
+
`string` \| `EthAddressWrapper` \| `null`
|
|
137
150
|
|
|
138
151
|
### Returns
|
|
139
152
|
|
|
@@ -192,14 +205,14 @@ toLowerCaseString(): string;
|
|
|
192
205
|
### toShortString()
|
|
193
206
|
|
|
194
207
|
```ts
|
|
195
|
-
toShortString(length
|
|
208
|
+
toShortString(length?): string;
|
|
196
209
|
```
|
|
197
210
|
|
|
198
211
|
### Parameters
|
|
199
212
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
213
|
+
#### length?
|
|
214
|
+
|
|
215
|
+
`number` = `2`
|
|
203
216
|
|
|
204
217
|
### Returns
|
|
205
218
|
|
|
@@ -210,15 +223,18 @@ toShortString(length?: number): string;
|
|
|
210
223
|
### toString()
|
|
211
224
|
|
|
212
225
|
```ts
|
|
213
|
-
toString(checksum
|
|
226
|
+
toString(checksum?, chainId?): string;
|
|
214
227
|
```
|
|
215
228
|
|
|
216
229
|
### Parameters
|
|
217
230
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
231
|
+
#### checksum?
|
|
232
|
+
|
|
233
|
+
`boolean`
|
|
234
|
+
|
|
235
|
+
#### chainId?
|
|
236
|
+
|
|
237
|
+
`string`
|
|
222
238
|
|
|
223
239
|
### Returns
|
|
224
240
|
|
|
@@ -236,26 +252,33 @@ validate(): boolean;
|
|
|
236
252
|
|
|
237
253
|
`boolean`
|
|
238
254
|
|
|
239
|
-
### functions
|
|
255
|
+
### functions
|
|
240
256
|
|
|
241
|
-
|
|
257
|
+
### <a id="ellipsize"></a>ellipsize
|
|
242
258
|
|
|
243
259
|
[**@xylabs/eth-address**](#../README)
|
|
244
260
|
|
|
245
261
|
***
|
|
246
262
|
|
|
247
263
|
```ts
|
|
248
|
-
function ellipsize(value
|
|
264
|
+
function ellipsize(value, length?): string;
|
|
249
265
|
```
|
|
250
266
|
|
|
251
267
|
Truncates a string to show the first and last `length` characters separated by an ellipsis.
|
|
252
268
|
|
|
253
269
|
## Parameters
|
|
254
270
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
271
|
+
### value
|
|
272
|
+
|
|
273
|
+
`string`
|
|
274
|
+
|
|
275
|
+
The string to ellipsize
|
|
276
|
+
|
|
277
|
+
### length?
|
|
278
|
+
|
|
279
|
+
`number` = `2`
|
|
280
|
+
|
|
281
|
+
Number of characters to keep at each end (default 2)
|
|
259
282
|
|
|
260
283
|
## Returns
|
|
261
284
|
|
|
@@ -263,88 +286,56 @@ Truncates a string to show the first and last `length` characters separated by a
|
|
|
263
286
|
|
|
264
287
|
The ellipsized string
|
|
265
288
|
|
|
266
|
-
|
|
289
|
+
### <a id="isEthAddressWrapper"></a>isEthAddressWrapper
|
|
267
290
|
|
|
268
291
|
[**@xylabs/eth-address**](#../README)
|
|
269
292
|
|
|
270
293
|
***
|
|
271
294
|
|
|
272
295
|
```ts
|
|
273
|
-
function isEthAddressWrapper(obj: {
|
|
274
|
-
type: string;
|
|
275
|
-
}): obj is { type: string } & EthAddressWrapper;
|
|
296
|
+
function isEthAddressWrapper(obj): obj is { type: string } & EthAddressWrapper;
|
|
276
297
|
```
|
|
277
298
|
|
|
278
299
|
Type guard that checks if the given object is an instance of EthAddressWrapper.
|
|
279
300
|
|
|
280
301
|
## Parameters
|
|
281
302
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
303
|
+
### obj
|
|
304
|
+
|
|
305
|
+
### type
|
|
306
|
+
|
|
307
|
+
`string`
|
|
286
308
|
|
|
287
309
|
## Returns
|
|
288
310
|
|
|
289
311
|
`obj is { type: string } & EthAddressWrapper`
|
|
290
312
|
|
|
291
|
-
|
|
313
|
+
### <a id="padHex"></a>padHex
|
|
292
314
|
|
|
293
315
|
[**@xylabs/eth-address**](#../README)
|
|
294
316
|
|
|
295
317
|
***
|
|
296
318
|
|
|
297
319
|
```ts
|
|
298
|
-
function padHex(hex
|
|
320
|
+
function padHex(hex, byteCount?): string;
|
|
299
321
|
```
|
|
300
322
|
|
|
301
323
|
## Parameters
|
|
302
324
|
|
|
303
|
-
|
|
304
|
-
| ------ | ------ | ------ |
|
|
305
|
-
| `hex` | `string` | `undefined` |
|
|
306
|
-
| `byteCount` | `number` | `0` |
|
|
307
|
-
|
|
308
|
-
## Returns
|
|
325
|
+
### hex
|
|
309
326
|
|
|
310
327
|
`string`
|
|
311
328
|
|
|
329
|
+
### byteCount?
|
|
312
330
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
## Maintainers
|
|
316
|
-
|
|
317
|
-
- [Arie Trouw](https://github.com/arietrouw) ([arietrouw.com](https://arietrouw.com))
|
|
318
|
-
- [Matt Jones](https://github.com/jonesmac)
|
|
319
|
-
- [Joel Carter](https://github.com/JoelBCarter)
|
|
320
|
-
- [Jordan Trouw](https://github.com/jordantrouw)
|
|
321
|
-
|
|
322
|
-
## License
|
|
331
|
+
`number` = `0`
|
|
323
332
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
## Credits
|
|
333
|
+
## Returns
|
|
327
334
|
|
|
328
|
-
|
|
335
|
+
`string`
|
|
329
336
|
|
|
330
|
-
[logo]: https://cdn.xy.company/img/brand/XYPersistentCompany_Logo_Icon_Colored.svg
|
|
331
337
|
|
|
332
|
-
[main-build]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml/badge.svg
|
|
333
|
-
[main-build-link]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml
|
|
334
338
|
[npm-badge]: https://img.shields.io/npm/v/@xylabs/eth-address.svg
|
|
335
339
|
[npm-link]: https://www.npmjs.com/package/@xylabs/eth-address
|
|
336
|
-
[
|
|
337
|
-
[
|
|
338
|
-
[codeclimate-badge]: https://api.codeclimate.com/v1/badges/c5eb068f806f0b047ea7/maintainability
|
|
339
|
-
[codeclimate-link]: https://codeclimate.com/github/xylabs/sdk-js/maintainability
|
|
340
|
-
[snyk-badge]: https://snyk.io/test/github/xylabs/sdk-js/badge.svg?targetFile=package.json
|
|
341
|
-
[snyk-link]: https://snyk.io/test/github/xylabs/sdk-js?targetFile=package.json
|
|
342
|
-
|
|
343
|
-
[npm-downloads-badge]: https://img.shields.io/npm/dw/@xylabs/eth-address
|
|
344
|
-
[npm-license-badge]: https://img.shields.io/npm/l/@xylabs/eth-address
|
|
345
|
-
|
|
346
|
-
[jsdelivr-badge]: https://data.jsdelivr.com/v1/package/npm/@xylabs/eth-address/badge
|
|
347
|
-
[jsdelivr-link]: https://www.jsdelivr.com/package/npm/@xylabs/eth-address
|
|
348
|
-
|
|
349
|
-
[socket-badge]: https://socket.dev/api/badge/npm/package/@xylabs/eth-address
|
|
350
|
-
[socket-link]: https://socket.dev/npm/package/@xylabs/eth-address
|
|
340
|
+
[license-badge]: https://img.shields.io/npm/l/@xylabs/eth-address.svg
|
|
341
|
+
[license-link]: https://github.com/xylabs/sdk-js/blob/main/LICENSE
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/eth-address",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.96",
|
|
4
4
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eth",
|
|
@@ -31,12 +31,10 @@
|
|
|
31
31
|
"exports": {
|
|
32
32
|
".": {
|
|
33
33
|
"types": "./dist/neutral/index.d.ts",
|
|
34
|
-
"import": "./dist/neutral/index.mjs",
|
|
35
34
|
"default": "./dist/neutral/index.mjs"
|
|
36
35
|
},
|
|
37
36
|
"./package.json": "./package.json"
|
|
38
37
|
},
|
|
39
|
-
"types": "./dist/neutral/index.d.ts",
|
|
40
38
|
"files": [
|
|
41
39
|
"dist",
|
|
42
40
|
"!**/*.bench.*",
|
|
@@ -46,18 +44,16 @@
|
|
|
46
44
|
],
|
|
47
45
|
"dependencies": {
|
|
48
46
|
"ethers": "^6.16.0",
|
|
49
|
-
"@xylabs/assert": "~5.0.
|
|
47
|
+
"@xylabs/assert": "~5.0.96"
|
|
50
48
|
},
|
|
51
49
|
"devDependencies": {
|
|
52
|
-
"@types/node": "^25.
|
|
53
|
-
"@xylabs/
|
|
54
|
-
"@xylabs/
|
|
55
|
-
"@xylabs/tsconfig": "~7.7.3",
|
|
56
|
-
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
50
|
+
"@types/node": "^25.6.0",
|
|
51
|
+
"@xylabs/toolchain": "~7.10.4",
|
|
52
|
+
"@xylabs/tsconfig": "~7.10.4",
|
|
57
53
|
"esbuild": "^0.28.0",
|
|
58
54
|
"typescript": "^5",
|
|
59
|
-
"vite": "^
|
|
60
|
-
"vitest": "^4.1.
|
|
55
|
+
"vite": "^8.0.8",
|
|
56
|
+
"vitest": "^4.1.4"
|
|
61
57
|
},
|
|
62
58
|
"engines": {
|
|
63
59
|
"node": ">=18"
|