@xylabs/eth-address 2.10.17 → 2.11.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/dist/EthAddress.d.ts +20 -0
- package/dist/EthAddress.d.ts.map +1 -0
- package/dist/ellipsize.d.ts +2 -0
- package/dist/ellipsize.d.ts.map +1 -0
- package/dist/index.d.mts +4 -26
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +4 -26
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +71 -103
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -75
- package/dist/index.mjs.map +1 -1
- package/dist/padHex.d.ts +3 -0
- package/dist/padHex.d.ts.map +1 -0
- package/package.json +6 -12
- package/src/EthAddress.ts +8 -8
- package/tsup.config.ts +0 -16
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BigNumber } from '@xylabs/bignumber';
|
|
2
|
+
export declare const isEthAddress: (obj: {
|
|
3
|
+
type: string;
|
|
4
|
+
}) => boolean;
|
|
5
|
+
export declare class EthAddress {
|
|
6
|
+
static type: string;
|
|
7
|
+
type: string;
|
|
8
|
+
private address;
|
|
9
|
+
private constructor();
|
|
10
|
+
static fromString(value?: string, base?: number): EthAddress | undefined;
|
|
11
|
+
static parse(value: unknown, base?: number): EthAddress | undefined;
|
|
12
|
+
equals(address?: EthAddress | string | null): boolean;
|
|
13
|
+
toBigNumber(): BigNumber;
|
|
14
|
+
toHex(): string;
|
|
15
|
+
toJSON(): string;
|
|
16
|
+
toLowerCaseString(): string;
|
|
17
|
+
toShortString(length?: number): string;
|
|
18
|
+
toString(): string;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=EthAddress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EthAddress.d.ts","sourceRoot":"","sources":["../src/EthAddress.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAK7C,eAAO,MAAM,YAAY,QAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,YAAkC,CAAA;AAEpF,qBAAa,UAAU;IACrB,MAAM,CAAC,IAAI,SAAe;IAE1B,IAAI,SAAkB;IAEtB,OAAO,CAAC,OAAO,CAAW;IAE1B,OAAO;IAIP,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,SAAK;IAO3C,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM;IAM1C,MAAM,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO;IAarD,WAAW;IAIX,KAAK;IAIL,MAAM,IAAI,MAAM;IAIhB,iBAAiB;IAIjB,aAAa,CAAC,MAAM,SAAI;IAIxB,QAAQ;CAGT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ellipsize.d.ts","sourceRoot":"","sources":["../src/ellipsize.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,UAAW,MAAM,4BAItC,CAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,26 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare const isEthAddress: (obj: {
|
|
6
|
-
type: string;
|
|
7
|
-
}) => boolean;
|
|
8
|
-
declare class EthAddress {
|
|
9
|
-
static type: string;
|
|
10
|
-
type: string;
|
|
11
|
-
private address;
|
|
12
|
-
private constructor();
|
|
13
|
-
static fromString(value?: string, base?: number): EthAddress | undefined;
|
|
14
|
-
static parse(value: unknown, base?: number): EthAddress | undefined;
|
|
15
|
-
equals(address?: EthAddress | string | null): boolean;
|
|
16
|
-
toBigNumber(): BigNumber;
|
|
17
|
-
toHex(): string;
|
|
18
|
-
toJSON(): string;
|
|
19
|
-
toLowerCaseString(): string;
|
|
20
|
-
toShortString(length?: number): string;
|
|
21
|
-
toString(): string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare const padHex: (hex: string, byteCount?: number) => string;
|
|
25
|
-
|
|
26
|
-
export { EthAddress, ellipsize, isEthAddress, padHex };
|
|
1
|
+
export * from './ellipsize';
|
|
2
|
+
export * from './EthAddress';
|
|
3
|
+
export * from './padHex';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare const isEthAddress: (obj: {
|
|
6
|
-
type: string;
|
|
7
|
-
}) => boolean;
|
|
8
|
-
declare class EthAddress {
|
|
9
|
-
static type: string;
|
|
10
|
-
type: string;
|
|
11
|
-
private address;
|
|
12
|
-
private constructor();
|
|
13
|
-
static fromString(value?: string, base?: number): EthAddress | undefined;
|
|
14
|
-
static parse(value: unknown, base?: number): EthAddress | undefined;
|
|
15
|
-
equals(address?: EthAddress | string | null): boolean;
|
|
16
|
-
toBigNumber(): BigNumber;
|
|
17
|
-
toHex(): string;
|
|
18
|
-
toJSON(): string;
|
|
19
|
-
toLowerCaseString(): string;
|
|
20
|
-
toShortString(length?: number): string;
|
|
21
|
-
toString(): string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare const padHex: (hex: string, byteCount?: number) => string;
|
|
25
|
-
|
|
26
|
-
export { EthAddress, ellipsize, isEthAddress, padHex };
|
|
1
|
+
export * from './ellipsize';
|
|
2
|
+
export * from './EthAddress';
|
|
3
|
+
export * from './padHex';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,113 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
EthAddress: () => EthAddress,
|
|
24
|
-
ellipsize: () => ellipsize,
|
|
25
|
-
isEthAddress: () => isEthAddress,
|
|
26
|
-
padHex: () => padHex
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(src_exports);
|
|
3
|
+
var assert = require('@xylabs/assert');
|
|
4
|
+
var bignumber = require('@xylabs/bignumber');
|
|
29
5
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return `${part1}...${part2}`;
|
|
6
|
+
const ellipsize = (value, length = 2) => {
|
|
7
|
+
const part1 = value.slice(0, length);
|
|
8
|
+
const part2 = value.slice(value.length - length, value.length);
|
|
9
|
+
return `${part1}...${part2}`;
|
|
35
10
|
};
|
|
36
11
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
if (byteCount) {
|
|
48
|
-
while (result.length / 2 < byteCount) {
|
|
49
|
-
result = `00${result}`;
|
|
12
|
+
const padHex = (hex, byteCount) => {
|
|
13
|
+
let result = hex;
|
|
14
|
+
if (hex.length % 2 !== 0) {
|
|
15
|
+
result = `0${hex}`;
|
|
16
|
+
}
|
|
17
|
+
if (byteCount) {
|
|
18
|
+
while (result.length / 2 < byteCount) {
|
|
19
|
+
result = `00${result}`;
|
|
20
|
+
}
|
|
50
21
|
}
|
|
51
|
-
|
|
52
|
-
return result;
|
|
22
|
+
return result;
|
|
53
23
|
};
|
|
54
24
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
this.address = address;
|
|
63
|
-
}
|
|
64
|
-
static fromString(value, base = 16) {
|
|
65
|
-
if (value) {
|
|
66
|
-
const bn = new import_bignumber.BigNumber(value.startsWith("0x") ? value.substring(2) : value, base);
|
|
67
|
-
return new _EthAddress(bn);
|
|
25
|
+
const isEthAddress = (obj) => obj?.type === EthAddress.type;
|
|
26
|
+
class EthAddress {
|
|
27
|
+
static type = 'EthAddress';
|
|
28
|
+
type = EthAddress.type;
|
|
29
|
+
address;
|
|
30
|
+
constructor(address) {
|
|
31
|
+
this.address = address;
|
|
68
32
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
33
|
+
static fromString(value, base = 16) {
|
|
34
|
+
if (value) {
|
|
35
|
+
const bn = new bignumber.BigNumber(value.startsWith('0x') ? value.substring(2) : value, base);
|
|
36
|
+
return new EthAddress(bn);
|
|
37
|
+
}
|
|
73
38
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (typeof address === "string") {
|
|
79
|
-
inAddress = (0, import_assert.assertEx)(_EthAddress.fromString(address), "Bad Address");
|
|
80
|
-
} else {
|
|
81
|
-
inAddress = address;
|
|
82
|
-
}
|
|
83
|
-
return this.address.eq(inAddress.address);
|
|
39
|
+
static parse(value, base) {
|
|
40
|
+
if (typeof value === 'string') {
|
|
41
|
+
return this.fromString(value, base);
|
|
42
|
+
}
|
|
84
43
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
44
|
+
equals(address) {
|
|
45
|
+
if (address) {
|
|
46
|
+
let inAddress;
|
|
47
|
+
if (typeof address === 'string') {
|
|
48
|
+
inAddress = assert.assertEx(EthAddress.fromString(address), 'Bad Address');
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
inAddress = address;
|
|
52
|
+
}
|
|
53
|
+
return this.address.eq(inAddress.address);
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
toBigNumber() {
|
|
58
|
+
return this.address;
|
|
59
|
+
}
|
|
60
|
+
toHex() {
|
|
61
|
+
return padHex(this.address.toString(16), 20);
|
|
62
|
+
}
|
|
63
|
+
toJSON() {
|
|
64
|
+
return `0x${this.toHex()}`;
|
|
65
|
+
}
|
|
66
|
+
toLowerCaseString() {
|
|
67
|
+
return this.toString().toLowerCase();
|
|
68
|
+
}
|
|
69
|
+
toShortString(length = 2) {
|
|
70
|
+
return `0x${ellipsize(this.toHex(), length)}`;
|
|
71
|
+
}
|
|
72
|
+
toString() {
|
|
73
|
+
return `0x${this.toHex()}`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
exports.EthAddress = EthAddress;
|
|
78
|
+
exports.ellipsize = ellipsize;
|
|
79
|
+
exports.isEthAddress = isEthAddress;
|
|
80
|
+
exports.padHex = padHex;
|
|
81
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/ellipsize.ts","../src/padHex.ts","../src/EthAddress.ts"],"sourcesContent":[null,null,null],"names":["BigNumber"],"mappings":";;;;;AAAA,MAAA,SAAa,GAAA,CAAA,KAAoB,EAAA,MAAA,GAAA,CAAA;;;;;;ACAjC,MAAA,SAAY,CAAA,GAAA,EAAA,cAA6B;AAazC,IAAO,IAAA,MAAQ,GAAE,GAAA,CAAA;;;;;;;;;;;;ACLjB,MAAA,YAAuB,GAAA,CAAA,GAAA,KAAA,GAAA,EAAA,IAAA,KAAA,UAAA,CAAA,KAAA;AACf,gBAAoB,CAAA;AAE1B,IAAA,OAAsB,IAAA,GAAA,YAAA,CAAA;IAEtB,IAAO,GAAA,UAAmB,CAAA,IAAA,CAAA;IAE1B,OAAO,CAAA;IAIP,mBAAkB,EAAA;QAOZ,IAAM,CAAA,OAAM,GAAA,QAAS;KAMrB;IAaN,OAAW,UAAA,CAAA,KAAA,EAAA,IAAA,GAAA,EAAA,EAAA;QAIN,IAAA,KAAA,EAAA;AAIL,kBAAgB,EAAA,GAAA,IAAAA,mBAAA,CAAA,KAAA,CAAA,UAAA,CAAA,IAAA,CAAA,GAAA,KAAA,CAAA,SAAA,CAAA,CAAA,CAAA,GAAA,KAAA,EAAA,IAAA,CAAA,CAAA;YAIC,OAAA,IAAA,UAAA,CAAA,EAAA,CAAA,CAAA;SAIJ;KAIL;AAGT,IAAA,OAAA,KAAA,CAAA,KAAA,EAAA,IAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,83 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const part1 = value.slice(0, length);
|
|
4
|
-
const part2 = value.slice(value.length - length, value.length);
|
|
5
|
-
return `${part1}...${part2}`;
|
|
6
|
-
};
|
|
1
|
+
import { assertEx } from '@xylabs/assert';
|
|
2
|
+
import { BigNumber } from '@xylabs/bignumber';
|
|
7
3
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const ellipsize = (value, length = 2) => {
|
|
5
|
+
const part1 = value.slice(0, length);
|
|
6
|
+
const part2 = value.slice(value.length - length, value.length);
|
|
7
|
+
return `${part1}...${part2}`;
|
|
8
|
+
};
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
result = `0${hex}`;
|
|
17
|
-
}
|
|
18
|
-
if (byteCount) {
|
|
19
|
-
while (result.length / 2 < byteCount) {
|
|
20
|
-
result = `00${result}`;
|
|
10
|
+
const padHex = (hex, byteCount) => {
|
|
11
|
+
let result = hex;
|
|
12
|
+
if (hex.length % 2 !== 0) {
|
|
13
|
+
result = `0${hex}`;
|
|
21
14
|
}
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
if (byteCount) {
|
|
16
|
+
while (result.length / 2 < byteCount) {
|
|
17
|
+
result = `00${result}`;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
24
21
|
};
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.address = address;
|
|
34
|
-
}
|
|
35
|
-
static fromString(value, base = 16) {
|
|
36
|
-
if (value) {
|
|
37
|
-
const bn = new BigNumber(value.startsWith("0x") ? value.substring(2) : value, base);
|
|
38
|
-
return new _EthAddress(bn);
|
|
23
|
+
const isEthAddress = (obj) => obj?.type === EthAddress.type;
|
|
24
|
+
class EthAddress {
|
|
25
|
+
static type = 'EthAddress';
|
|
26
|
+
type = EthAddress.type;
|
|
27
|
+
address;
|
|
28
|
+
constructor(address) {
|
|
29
|
+
this.address = address;
|
|
39
30
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
31
|
+
static fromString(value, base = 16) {
|
|
32
|
+
if (value) {
|
|
33
|
+
const bn = new BigNumber(value.startsWith('0x') ? value.substring(2) : value, base);
|
|
34
|
+
return new EthAddress(bn);
|
|
35
|
+
}
|
|
44
36
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (typeof address === "string") {
|
|
50
|
-
inAddress = assertEx(_EthAddress.fromString(address), "Bad Address");
|
|
51
|
-
} else {
|
|
52
|
-
inAddress = address;
|
|
53
|
-
}
|
|
54
|
-
return this.address.eq(inAddress.address);
|
|
37
|
+
static parse(value, base) {
|
|
38
|
+
if (typeof value === 'string') {
|
|
39
|
+
return this.fromString(value, base);
|
|
40
|
+
}
|
|
55
41
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
42
|
+
equals(address) {
|
|
43
|
+
if (address) {
|
|
44
|
+
let inAddress;
|
|
45
|
+
if (typeof address === 'string') {
|
|
46
|
+
inAddress = assertEx(EthAddress.fromString(address), 'Bad Address');
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
inAddress = address;
|
|
50
|
+
}
|
|
51
|
+
return this.address.eq(inAddress.address);
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
toBigNumber() {
|
|
56
|
+
return this.address;
|
|
57
|
+
}
|
|
58
|
+
toHex() {
|
|
59
|
+
return padHex(this.address.toString(16), 20);
|
|
60
|
+
}
|
|
61
|
+
toJSON() {
|
|
62
|
+
return `0x${this.toHex()}`;
|
|
63
|
+
}
|
|
64
|
+
toLowerCaseString() {
|
|
65
|
+
return this.toString().toLowerCase();
|
|
66
|
+
}
|
|
67
|
+
toShortString(length = 2) {
|
|
68
|
+
return `0x${ellipsize(this.toHex(), length)}`;
|
|
69
|
+
}
|
|
70
|
+
toString() {
|
|
71
|
+
return `0x${this.toHex()}`;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { EthAddress, ellipsize, isEthAddress, padHex };
|
|
76
|
+
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ellipsize.ts","../src/
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/ellipsize.ts","../src/padHex.ts","../src/EthAddress.ts"],"sourcesContent":[null,null,null],"names":[],"mappings":";;;AAAA,MAAA,SAAa,GAAA,CAAA,KAAoB,EAAA,MAAA,GAAA,CAAA;;;;;;ACAjC,MAAA,SAAY,CAAA,GAAA,EAAA,cAA6B;AAazC,IAAO,IAAA,MAAQ,GAAE,GAAA,CAAA;;;;;;;;;;;;ACLjB,MAAA,YAAuB,GAAA,CAAA,GAAA,KAAA,GAAA,EAAA,IAAA,KAAA,UAAA,CAAA,KAAA;AACf,gBAAoB,CAAA;AAE1B,IAAA,OAAsB,IAAA,GAAA,YAAA,CAAA;IAEtB,IAAO,GAAA,UAAmB,CAAA,IAAA,CAAA;IAE1B,OAAO,CAAA;IAIP,mBAAkB,EAAA;QAOZ,IAAM,CAAA,OAAM,GAAA,QAAS;KAMrB;IAaN,OAAW,UAAA,CAAA,KAAA,EAAA,IAAA,GAAA,EAAA,EAAA;QAIN,IAAA,KAAA,EAAA;AAIL,kBAAgB,EAAA,GAAA,IAAA,SAAA,CAAA,KAAA,CAAA,UAAA,CAAA,IAAA,CAAA,GAAA,KAAA,CAAA,SAAA,CAAA,CAAA,CAAA,GAAA,KAAA,EAAA,IAAA,CAAA,CAAA;YAIC,OAAA,IAAA,UAAA,CAAA,EAAA,CAAA,CAAA;SAIJ;KAIL;AAGT,IAAA,OAAA,KAAA,CAAA,KAAA,EAAA,IAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/padHex.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"padHex.d.ts","sourceRoot":"","sources":["../src/padHex.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,MAAM,QAAS,MAAM,cAAc,MAAM,WAW9C,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -43,10 +43,6 @@
|
|
|
43
43
|
},
|
|
44
44
|
"main": "dist/index.js",
|
|
45
45
|
"module": "dist/index.mjs",
|
|
46
|
-
"scripts": {
|
|
47
|
-
"package-compile": "tsup && publint",
|
|
48
|
-
"package-recompile": "tsup && publint"
|
|
49
|
-
},
|
|
50
46
|
"homepage": "https://xylabs.com",
|
|
51
47
|
"keywords": [
|
|
52
48
|
"xylabs",
|
|
@@ -55,15 +51,13 @@
|
|
|
55
51
|
"esm"
|
|
56
52
|
],
|
|
57
53
|
"dependencies": {
|
|
58
|
-
"@xylabs/assert": "~2.
|
|
59
|
-
"@xylabs/bignumber": "~2.
|
|
54
|
+
"@xylabs/assert": "~2.11.0",
|
|
55
|
+
"@xylabs/bignumber": "~2.11.0"
|
|
60
56
|
},
|
|
61
57
|
"devDependencies": {
|
|
62
|
-
"@xylabs/ts-scripts-yarn3": "^
|
|
63
|
-
"@xylabs/tsconfig": "^
|
|
64
|
-
"@xylabs/tsconfig-jest": "^
|
|
65
|
-
"publint": "^0.2.2",
|
|
66
|
-
"tsup": "^7.2.0"
|
|
58
|
+
"@xylabs/ts-scripts-yarn3": "^3.0.0-rc.15",
|
|
59
|
+
"@xylabs/tsconfig": "^3.0.0-rc.15",
|
|
60
|
+
"@xylabs/tsconfig-jest": "^3.0.0-rc.15"
|
|
67
61
|
},
|
|
68
62
|
"publishConfig": {
|
|
69
63
|
"access": "public"
|
|
@@ -73,6 +67,6 @@
|
|
|
73
67
|
"url": "https://github.com/xylabs/sdk-js.git"
|
|
74
68
|
},
|
|
75
69
|
"sideEffects": false,
|
|
76
|
-
"version": "2.
|
|
70
|
+
"version": "2.11.0",
|
|
77
71
|
"packageManager": "yarn@3.3.1"
|
|
78
72
|
}
|
package/src/EthAddress.ts
CHANGED
|
@@ -9,7 +9,7 @@ export const isEthAddress = (obj: { type: string }) => obj?.type === EthAddress.
|
|
|
9
9
|
export class EthAddress {
|
|
10
10
|
static type = 'EthAddress'
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
type = EthAddress.type
|
|
13
13
|
|
|
14
14
|
private address: BigNumber
|
|
15
15
|
|
|
@@ -30,7 +30,7 @@ export class EthAddress {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
equals(address?: EthAddress | string | null): boolean {
|
|
34
34
|
if (address) {
|
|
35
35
|
let inAddress: EthAddress
|
|
36
36
|
if (typeof address === 'string') {
|
|
@@ -43,27 +43,27 @@ export class EthAddress {
|
|
|
43
43
|
return false
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
toBigNumber() {
|
|
47
47
|
return this.address
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
toHex() {
|
|
51
51
|
return padHex(this.address.toString(16), 20)
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
toJSON(): string {
|
|
55
55
|
return `0x${this.toHex()}`
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
toLowerCaseString() {
|
|
59
59
|
return this.toString().toLowerCase()
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
toShortString(length = 2) {
|
|
63
63
|
return `0x${ellipsize(this.toHex(), length)}`
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
toString() {
|
|
67
67
|
return `0x${this.toHex()}`
|
|
68
68
|
}
|
|
69
69
|
}
|
package/tsup.config.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'tsup'
|
|
2
|
-
|
|
3
|
-
// eslint-disable-next-line import/no-default-export
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
bundle: true,
|
|
6
|
-
cjsInterop: true,
|
|
7
|
-
clean: false,
|
|
8
|
-
dts: {
|
|
9
|
-
entry: ['src/index.ts'],
|
|
10
|
-
},
|
|
11
|
-
entry: ['src/index.ts'],
|
|
12
|
-
format: ['cjs', 'esm'],
|
|
13
|
-
sourcemap: true,
|
|
14
|
-
splitting: false,
|
|
15
|
-
tsconfig: 'tsconfig.build.json',
|
|
16
|
-
})
|