@xylabs/eth-address 2.12.22 → 2.12.23
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/package.json +6 -6
- package/dist/browser/EthAddress.cjs +0 -102
- package/dist/browser/EthAddress.cjs.map +0 -1
- package/dist/browser/EthAddress.js +0 -81
- package/dist/browser/EthAddress.js.map +0 -1
- package/dist/browser/ellipsize.cjs +0 -31
- package/dist/browser/ellipsize.cjs.map +0 -1
- package/dist/browser/ellipsize.js +0 -10
- package/dist/browser/ellipsize.js.map +0 -1
- package/dist/browser/padHex.cjs +0 -38
- package/dist/browser/padHex.cjs.map +0 -1
- package/dist/browser/padHex.js +0 -17
- package/dist/browser/padHex.js.map +0 -1
- package/dist/node/EthAddress.cjs +0 -107
- package/dist/node/EthAddress.cjs.map +0 -1
- package/dist/node/EthAddress.js +0 -81
- package/dist/node/EthAddress.js.map +0 -1
- package/dist/node/ellipsize.cjs +0 -35
- package/dist/node/ellipsize.cjs.map +0 -1
- package/dist/node/ellipsize.js +0 -10
- package/dist/node/ellipsize.js.map +0 -1
- package/dist/node/padHex.cjs +0 -42
- package/dist/node/padHex.cjs.map +0 -1
- package/dist/node/padHex.js +0 -17
- package/dist/node/padHex.js.map +0 -1
package/package.json
CHANGED
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
"esm"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@xylabs/assert": "~2.12.
|
|
46
|
-
"@xylabs/bignumber": "~2.12.
|
|
45
|
+
"@xylabs/assert": "~2.12.23",
|
|
46
|
+
"@xylabs/bignumber": "~2.12.23"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@xylabs/ts-scripts-yarn3": "^3.
|
|
50
|
-
"@xylabs/tsconfig": "^3.
|
|
51
|
-
"@xylabs/tsconfig-jest": "^3.
|
|
49
|
+
"@xylabs/ts-scripts-yarn3": "^3.1.1",
|
|
50
|
+
"@xylabs/tsconfig": "^3.1.1",
|
|
51
|
+
"@xylabs/tsconfig-jest": "^3.1.1",
|
|
52
52
|
"typescript": "^5.2.2"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
@@ -59,6 +59,6 @@
|
|
|
59
59
|
"url": "https://github.com/xylabs/sdk-js.git"
|
|
60
60
|
},
|
|
61
61
|
"sideEffects": false,
|
|
62
|
-
"version": "2.12.
|
|
62
|
+
"version": "2.12.23",
|
|
63
63
|
"type": "module"
|
|
64
64
|
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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);
|
|
19
|
-
|
|
20
|
-
// src/EthAddress.ts
|
|
21
|
-
var EthAddress_exports = {};
|
|
22
|
-
__export(EthAddress_exports, {
|
|
23
|
-
EthAddress: () => EthAddress,
|
|
24
|
-
isEthAddress: () => isEthAddress
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(EthAddress_exports);
|
|
27
|
-
var import_assert = require("@xylabs/assert");
|
|
28
|
-
var import_bignumber = require("@xylabs/bignumber");
|
|
29
|
-
|
|
30
|
-
// src/ellipsize.ts
|
|
31
|
-
var ellipsize = (value, length = 2) => {
|
|
32
|
-
const part1 = value.slice(0, length);
|
|
33
|
-
const part2 = value.slice(value.length - length, value.length);
|
|
34
|
-
return `${part1}...${part2}`;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// src/padHex.ts
|
|
38
|
-
var padHex = (hex, byteCount) => {
|
|
39
|
-
let result = hex;
|
|
40
|
-
if (hex.length % 2 !== 0) {
|
|
41
|
-
result = `0${hex}`;
|
|
42
|
-
}
|
|
43
|
-
if (byteCount) {
|
|
44
|
-
while (result.length / 2 < byteCount) {
|
|
45
|
-
result = `00${result}`;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return result;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// src/EthAddress.ts
|
|
52
|
-
var isEthAddress = (obj) => obj?.type === EthAddress.type;
|
|
53
|
-
var EthAddress = class _EthAddress {
|
|
54
|
-
static type = "EthAddress";
|
|
55
|
-
type = _EthAddress.type;
|
|
56
|
-
address;
|
|
57
|
-
constructor(address) {
|
|
58
|
-
this.address = address;
|
|
59
|
-
}
|
|
60
|
-
static fromString(value, base = 16) {
|
|
61
|
-
if (value) {
|
|
62
|
-
const bn = new import_bignumber.BigNumber(value.startsWith("0x") ? value.substring(2) : value, base);
|
|
63
|
-
return new _EthAddress(bn);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
static parse(value, base) {
|
|
67
|
-
if (typeof value === "string") {
|
|
68
|
-
return this.fromString(value, base);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
equals(address) {
|
|
72
|
-
if (address) {
|
|
73
|
-
let inAddress;
|
|
74
|
-
if (typeof address === "string") {
|
|
75
|
-
inAddress = (0, import_assert.assertEx)(_EthAddress.fromString(address), "Bad Address");
|
|
76
|
-
} else {
|
|
77
|
-
inAddress = address;
|
|
78
|
-
}
|
|
79
|
-
return this.address.eq(inAddress.address);
|
|
80
|
-
}
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
toBigNumber() {
|
|
84
|
-
return this.address;
|
|
85
|
-
}
|
|
86
|
-
toHex() {
|
|
87
|
-
return padHex(this.address.toString(16), 20);
|
|
88
|
-
}
|
|
89
|
-
toJSON() {
|
|
90
|
-
return `0x${this.toHex()}`;
|
|
91
|
-
}
|
|
92
|
-
toLowerCaseString() {
|
|
93
|
-
return this.toString().toLowerCase();
|
|
94
|
-
}
|
|
95
|
-
toShortString(length = 2) {
|
|
96
|
-
return `0x${ellipsize(this.toHex(), length)}`;
|
|
97
|
-
}
|
|
98
|
-
toString() {
|
|
99
|
-
return `0x${this.toHex()}`;
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
//# sourceMappingURL=EthAddress.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/EthAddress.ts","../../src/ellipsize.ts","../../src/padHex.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { BigNumber } from '@xylabs/bignumber'\n\nimport { ellipsize } from './ellipsize'\nimport { padHex } from './padHex'\n\nexport const isEthAddress = (obj: { type: string }) => obj?.type === EthAddress.type\n\nexport class EthAddress {\n static type = 'EthAddress'\n\n type = EthAddress.type\n\n private address: BigNumber\n\n private constructor(address: BigNumber) {\n this.address = address\n }\n\n static fromString(value?: string, base = 16) {\n if (value) {\n const bn = new BigNumber(value.startsWith('0x') ? value.substring(2) : value, base)\n return new EthAddress(bn)\n }\n }\n\n static parse(value: unknown, base?: number) {\n if (typeof value === 'string') {\n return this.fromString(value, base)\n }\n }\n\n equals(address?: EthAddress | string | null): boolean {\n if (address) {\n let inAddress: EthAddress\n if (typeof address === 'string') {\n inAddress = assertEx(EthAddress.fromString(address), 'Bad Address')\n } else {\n inAddress = address\n }\n return this.address.eq(inAddress.address)\n }\n return false\n }\n\n toBigNumber() {\n return this.address\n }\n\n toHex() {\n return padHex(this.address.toString(16), 20)\n }\n\n toJSON(): string {\n return `0x${this.toHex()}`\n }\n\n toLowerCaseString() {\n return this.toString().toLowerCase()\n }\n\n toShortString(length = 2) {\n return `0x${ellipsize(this.toHex(), length)}`\n }\n\n toString() {\n return `0x${this.toHex()}`\n }\n}\n","export const ellipsize = (value: string, length = 2) => {\n const part1 = value.slice(0, length)\n const part2 = value.slice(value.length - length, value.length)\n return `${part1}...${part2}`\n}\n","const padHex = (hex: string, byteCount?: number) => {\n let result = hex\n if (hex.length % 2 !== 0) {\n result = `0${hex}`\n }\n if (byteCount) {\n while (result.length / 2 < byteCount) {\n result = `00${result}`\n }\n }\n return result\n}\n\nexport { padHex }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyB;AACzB,uBAA0B;;;ACDnB,IAAM,YAAY,CAAC,OAAe,SAAS,MAAM;AACtD,QAAM,QAAQ,MAAM,MAAM,GAAG,MAAM;AACnC,QAAM,QAAQ,MAAM,MAAM,MAAM,SAAS,QAAQ,MAAM,MAAM;AAC7D,SAAO,GAAG,KAAK,MAAM,KAAK;AAC5B;;;ACJA,IAAM,SAAS,CAAC,KAAa,cAAuB;AAClD,MAAI,SAAS;AACb,MAAI,IAAI,SAAS,MAAM,GAAG;AACxB,aAAS,IAAI,GAAG;AAAA,EAClB;AACA,MAAI,WAAW;AACb,WAAO,OAAO,SAAS,IAAI,WAAW;AACpC,eAAS,KAAK,MAAM;AAAA,IACtB;AAAA,EACF;AACA,SAAO;AACT;;;AFLO,IAAM,eAAe,CAAC,QAA0B,KAAK,SAAS,WAAW;AAEzE,IAAM,aAAN,MAAM,YAAW;AAAA,EACtB,OAAO,OAAO;AAAA,EAEd,OAAO,YAAW;AAAA,EAEV;AAAA,EAEA,YAAY,SAAoB;AACtC,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,OAAO,WAAW,OAAgB,OAAO,IAAI;AAC3C,QAAI,OAAO;AACT,YAAM,KAAK,IAAI,2BAAU,MAAM,WAAW,IAAI,IAAI,MAAM,UAAU,CAAC,IAAI,OAAO,IAAI;AAClF,aAAO,IAAI,YAAW,EAAE;AAAA,IAC1B;AAAA,EACF;AAAA,EAEA,OAAO,MAAM,OAAgB,MAAe;AAC1C,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO,KAAK,WAAW,OAAO,IAAI;AAAA,IACpC;AAAA,EACF;AAAA,EAEA,OAAO,SAA+C;AACpD,QAAI,SAAS;AACX,UAAI;AACJ,UAAI,OAAO,YAAY,UAAU;AAC/B,wBAAY,wBAAS,YAAW,WAAW,OAAO,GAAG,aAAa;AAAA,MACpE,OAAO;AACL,oBAAY;AAAA,MACd;AACA,aAAO,KAAK,QAAQ,GAAG,UAAU,OAAO;AAAA,IAC1C;AACA,WAAO;AAAA,EACT;AAAA,EAEA,cAAc;AACZ,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,QAAQ;AACN,WAAO,OAAO,KAAK,QAAQ,SAAS,EAAE,GAAG,EAAE;AAAA,EAC7C;AAAA,EAEA,SAAiB;AACf,WAAO,KAAK,KAAK,MAAM,CAAC;AAAA,EAC1B;AAAA,EAEA,oBAAoB;AAClB,WAAO,KAAK,SAAS,EAAE,YAAY;AAAA,EACrC;AAAA,EAEA,cAAc,SAAS,GAAG;AACxB,WAAO,KAAK,UAAU,KAAK,MAAM,GAAG,MAAM,CAAC;AAAA,EAC7C;AAAA,EAEA,WAAW;AACT,WAAO,KAAK,KAAK,MAAM,CAAC;AAAA,EAC1B;AACF;","names":[]}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
// src/EthAddress.ts
|
|
2
|
-
import { assertEx } from "@xylabs/assert";
|
|
3
|
-
import { BigNumber } from "@xylabs/bignumber";
|
|
4
|
-
|
|
5
|
-
// src/ellipsize.ts
|
|
6
|
-
var 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}`;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// src/padHex.ts
|
|
13
|
-
var padHex = (hex, byteCount) => {
|
|
14
|
-
let result = hex;
|
|
15
|
-
if (hex.length % 2 !== 0) {
|
|
16
|
-
result = `0${hex}`;
|
|
17
|
-
}
|
|
18
|
-
if (byteCount) {
|
|
19
|
-
while (result.length / 2 < byteCount) {
|
|
20
|
-
result = `00${result}`;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// src/EthAddress.ts
|
|
27
|
-
var isEthAddress = (obj) => obj?.type === EthAddress.type;
|
|
28
|
-
var EthAddress = class _EthAddress {
|
|
29
|
-
static type = "EthAddress";
|
|
30
|
-
type = _EthAddress.type;
|
|
31
|
-
address;
|
|
32
|
-
constructor(address) {
|
|
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);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
static parse(value, base) {
|
|
42
|
-
if (typeof value === "string") {
|
|
43
|
-
return this.fromString(value, base);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
equals(address) {
|
|
47
|
-
if (address) {
|
|
48
|
-
let inAddress;
|
|
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);
|
|
55
|
-
}
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
toBigNumber() {
|
|
59
|
-
return this.address;
|
|
60
|
-
}
|
|
61
|
-
toHex() {
|
|
62
|
-
return padHex(this.address.toString(16), 20);
|
|
63
|
-
}
|
|
64
|
-
toJSON() {
|
|
65
|
-
return `0x${this.toHex()}`;
|
|
66
|
-
}
|
|
67
|
-
toLowerCaseString() {
|
|
68
|
-
return this.toString().toLowerCase();
|
|
69
|
-
}
|
|
70
|
-
toShortString(length = 2) {
|
|
71
|
-
return `0x${ellipsize(this.toHex(), length)}`;
|
|
72
|
-
}
|
|
73
|
-
toString() {
|
|
74
|
-
return `0x${this.toHex()}`;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
export {
|
|
78
|
-
EthAddress,
|
|
79
|
-
isEthAddress
|
|
80
|
-
};
|
|
81
|
-
//# sourceMappingURL=EthAddress.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/EthAddress.ts","../../src/ellipsize.ts","../../src/padHex.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { BigNumber } from '@xylabs/bignumber'\n\nimport { ellipsize } from './ellipsize'\nimport { padHex } from './padHex'\n\nexport const isEthAddress = (obj: { type: string }) => obj?.type === EthAddress.type\n\nexport class EthAddress {\n static type = 'EthAddress'\n\n type = EthAddress.type\n\n private address: BigNumber\n\n private constructor(address: BigNumber) {\n this.address = address\n }\n\n static fromString(value?: string, base = 16) {\n if (value) {\n const bn = new BigNumber(value.startsWith('0x') ? value.substring(2) : value, base)\n return new EthAddress(bn)\n }\n }\n\n static parse(value: unknown, base?: number) {\n if (typeof value === 'string') {\n return this.fromString(value, base)\n }\n }\n\n equals(address?: EthAddress | string | null): boolean {\n if (address) {\n let inAddress: EthAddress\n if (typeof address === 'string') {\n inAddress = assertEx(EthAddress.fromString(address), 'Bad Address')\n } else {\n inAddress = address\n }\n return this.address.eq(inAddress.address)\n }\n return false\n }\n\n toBigNumber() {\n return this.address\n }\n\n toHex() {\n return padHex(this.address.toString(16), 20)\n }\n\n toJSON(): string {\n return `0x${this.toHex()}`\n }\n\n toLowerCaseString() {\n return this.toString().toLowerCase()\n }\n\n toShortString(length = 2) {\n return `0x${ellipsize(this.toHex(), length)}`\n }\n\n toString() {\n return `0x${this.toHex()}`\n }\n}\n","export const ellipsize = (value: string, length = 2) => {\n const part1 = value.slice(0, length)\n const part2 = value.slice(value.length - length, value.length)\n return `${part1}...${part2}`\n}\n","const padHex = (hex: string, byteCount?: number) => {\n let result = hex\n if (hex.length % 2 !== 0) {\n result = `0${hex}`\n }\n if (byteCount) {\n while (result.length / 2 < byteCount) {\n result = `00${result}`\n }\n }\n return result\n}\n\nexport { padHex }\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;;;ACDnB,IAAM,YAAY,CAAC,OAAe,SAAS,MAAM;AACtD,QAAM,QAAQ,MAAM,MAAM,GAAG,MAAM;AACnC,QAAM,QAAQ,MAAM,MAAM,MAAM,SAAS,QAAQ,MAAM,MAAM;AAC7D,SAAO,GAAG,KAAK,MAAM,KAAK;AAC5B;;;ACJA,IAAM,SAAS,CAAC,KAAa,cAAuB;AAClD,MAAI,SAAS;AACb,MAAI,IAAI,SAAS,MAAM,GAAG;AACxB,aAAS,IAAI,GAAG;AAAA,EAClB;AACA,MAAI,WAAW;AACb,WAAO,OAAO,SAAS,IAAI,WAAW;AACpC,eAAS,KAAK,MAAM;AAAA,IACtB;AAAA,EACF;AACA,SAAO;AACT;;;AFLO,IAAM,eAAe,CAAC,QAA0B,KAAK,SAAS,WAAW;AAEzE,IAAM,aAAN,MAAM,YAAW;AAAA,EACtB,OAAO,OAAO;AAAA,EAEd,OAAO,YAAW;AAAA,EAEV;AAAA,EAEA,YAAY,SAAoB;AACtC,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,OAAO,WAAW,OAAgB,OAAO,IAAI;AAC3C,QAAI,OAAO;AACT,YAAM,KAAK,IAAI,UAAU,MAAM,WAAW,IAAI,IAAI,MAAM,UAAU,CAAC,IAAI,OAAO,IAAI;AAClF,aAAO,IAAI,YAAW,EAAE;AAAA,IAC1B;AAAA,EACF;AAAA,EAEA,OAAO,MAAM,OAAgB,MAAe;AAC1C,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO,KAAK,WAAW,OAAO,IAAI;AAAA,IACpC;AAAA,EACF;AAAA,EAEA,OAAO,SAA+C;AACpD,QAAI,SAAS;AACX,UAAI;AACJ,UAAI,OAAO,YAAY,UAAU;AAC/B,oBAAY,SAAS,YAAW,WAAW,OAAO,GAAG,aAAa;AAAA,MACpE,OAAO;AACL,oBAAY;AAAA,MACd;AACA,aAAO,KAAK,QAAQ,GAAG,UAAU,OAAO;AAAA,IAC1C;AACA,WAAO;AAAA,EACT;AAAA,EAEA,cAAc;AACZ,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,QAAQ;AACN,WAAO,OAAO,KAAK,QAAQ,SAAS,EAAE,GAAG,EAAE;AAAA,EAC7C;AAAA,EAEA,SAAiB;AACf,WAAO,KAAK,KAAK,MAAM,CAAC;AAAA,EAC1B;AAAA,EAEA,oBAAoB;AAClB,WAAO,KAAK,SAAS,EAAE,YAAY;AAAA,EACrC;AAAA,EAEA,cAAc,SAAS,GAAG;AACxB,WAAO,KAAK,UAAU,KAAK,MAAM,GAAG,MAAM,CAAC;AAAA,EAC7C;AAAA,EAEA,WAAW;AACT,WAAO,KAAK,KAAK,MAAM,CAAC;AAAA,EAC1B;AACF;","names":[]}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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);
|
|
19
|
-
|
|
20
|
-
// src/ellipsize.ts
|
|
21
|
-
var ellipsize_exports = {};
|
|
22
|
-
__export(ellipsize_exports, {
|
|
23
|
-
ellipsize: () => ellipsize
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(ellipsize_exports);
|
|
26
|
-
var ellipsize = (value, length = 2) => {
|
|
27
|
-
const part1 = value.slice(0, length);
|
|
28
|
-
const part2 = value.slice(value.length - length, value.length);
|
|
29
|
-
return `${part1}...${part2}`;
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=ellipsize.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ellipsize.ts"],"sourcesContent":["export const ellipsize = (value: string, length = 2) => {\n const part1 = value.slice(0, length)\n const part2 = value.slice(value.length - length, value.length)\n return `${part1}...${part2}`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,YAAY,CAAC,OAAe,SAAS,MAAM;AACtD,QAAM,QAAQ,MAAM,MAAM,GAAG,MAAM;AACnC,QAAM,QAAQ,MAAM,MAAM,MAAM,SAAS,QAAQ,MAAM,MAAM;AAC7D,SAAO,GAAG,KAAK,MAAM,KAAK;AAC5B;","names":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// src/ellipsize.ts
|
|
2
|
-
var ellipsize = (value, length = 2) => {
|
|
3
|
-
const part1 = value.slice(0, length);
|
|
4
|
-
const part2 = value.slice(value.length - length, value.length);
|
|
5
|
-
return `${part1}...${part2}`;
|
|
6
|
-
};
|
|
7
|
-
export {
|
|
8
|
-
ellipsize
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=ellipsize.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ellipsize.ts"],"sourcesContent":["export const ellipsize = (value: string, length = 2) => {\n const part1 = value.slice(0, length)\n const part2 = value.slice(value.length - length, value.length)\n return `${part1}...${part2}`\n}\n"],"mappings":";AAAO,IAAM,YAAY,CAAC,OAAe,SAAS,MAAM;AACtD,QAAM,QAAQ,MAAM,MAAM,GAAG,MAAM;AACnC,QAAM,QAAQ,MAAM,MAAM,MAAM,SAAS,QAAQ,MAAM,MAAM;AAC7D,SAAO,GAAG,KAAK,MAAM,KAAK;AAC5B;","names":[]}
|
package/dist/browser/padHex.cjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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);
|
|
19
|
-
|
|
20
|
-
// src/padHex.ts
|
|
21
|
-
var padHex_exports = {};
|
|
22
|
-
__export(padHex_exports, {
|
|
23
|
-
padHex: () => padHex
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(padHex_exports);
|
|
26
|
-
var padHex = (hex, byteCount) => {
|
|
27
|
-
let result = hex;
|
|
28
|
-
if (hex.length % 2 !== 0) {
|
|
29
|
-
result = `0${hex}`;
|
|
30
|
-
}
|
|
31
|
-
if (byteCount) {
|
|
32
|
-
while (result.length / 2 < byteCount) {
|
|
33
|
-
result = `00${result}`;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=padHex.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/padHex.ts"],"sourcesContent":["const padHex = (hex: string, byteCount?: number) => {\n let result = hex\n if (hex.length % 2 !== 0) {\n result = `0${hex}`\n }\n if (byteCount) {\n while (result.length / 2 < byteCount) {\n result = `00${result}`\n }\n }\n return result\n}\n\nexport { padHex }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAM,SAAS,CAAC,KAAa,cAAuB;AAClD,MAAI,SAAS;AACb,MAAI,IAAI,SAAS,MAAM,GAAG;AACxB,aAAS,IAAI,GAAG;AAAA,EAClB;AACA,MAAI,WAAW;AACb,WAAO,OAAO,SAAS,IAAI,WAAW;AACpC,eAAS,KAAK,MAAM;AAAA,IACtB;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
package/dist/browser/padHex.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// src/padHex.ts
|
|
2
|
-
var padHex = (hex, byteCount) => {
|
|
3
|
-
let result = hex;
|
|
4
|
-
if (hex.length % 2 !== 0) {
|
|
5
|
-
result = `0${hex}`;
|
|
6
|
-
}
|
|
7
|
-
if (byteCount) {
|
|
8
|
-
while (result.length / 2 < byteCount) {
|
|
9
|
-
result = `00${result}`;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return result;
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
padHex
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=padHex.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/padHex.ts"],"sourcesContent":["const padHex = (hex: string, byteCount?: number) => {\n let result = hex\n if (hex.length % 2 !== 0) {\n result = `0${hex}`\n }\n if (byteCount) {\n while (result.length / 2 < byteCount) {\n result = `00${result}`\n }\n }\n return result\n}\n\nexport { padHex }\n"],"mappings":";AAAA,IAAM,SAAS,CAAC,KAAa,cAAuB;AAClD,MAAI,SAAS;AACb,MAAI,IAAI,SAAS,MAAM,GAAG;AACxB,aAAS,IAAI,GAAG;AAAA,EAClB;AACA,MAAI,WAAW;AACb,WAAO,OAAO,SAAS,IAAI,WAAW;AACpC,eAAS,KAAK,MAAM;AAAA,IACtB;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
package/dist/node/EthAddress.cjs
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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);
|
|
19
|
-
|
|
20
|
-
// src/EthAddress.ts
|
|
21
|
-
var EthAddress_exports = {};
|
|
22
|
-
__export(EthAddress_exports, {
|
|
23
|
-
EthAddress: () => EthAddress,
|
|
24
|
-
isEthAddress: () => isEthAddress
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(EthAddress_exports);
|
|
27
|
-
var import_assert = require("@xylabs/assert");
|
|
28
|
-
var import_bignumber = require("@xylabs/bignumber");
|
|
29
|
-
|
|
30
|
-
// src/ellipsize.ts
|
|
31
|
-
var ellipsize = (value, length = 2) => {
|
|
32
|
-
const part1 = value.slice(0, length);
|
|
33
|
-
const part2 = value.slice(value.length - length, value.length);
|
|
34
|
-
return `${part1}...${part2}`;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// src/padHex.ts
|
|
38
|
-
var padHex = (hex, byteCount) => {
|
|
39
|
-
let result = hex;
|
|
40
|
-
if (hex.length % 2 !== 0) {
|
|
41
|
-
result = `0${hex}`;
|
|
42
|
-
}
|
|
43
|
-
if (byteCount) {
|
|
44
|
-
while (result.length / 2 < byteCount) {
|
|
45
|
-
result = `00${result}`;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return result;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// src/EthAddress.ts
|
|
52
|
-
var isEthAddress = (obj) => (obj == null ? void 0 : obj.type) === EthAddress.type;
|
|
53
|
-
var EthAddress = class _EthAddress {
|
|
54
|
-
static type = "EthAddress";
|
|
55
|
-
type = _EthAddress.type;
|
|
56
|
-
address;
|
|
57
|
-
constructor(address) {
|
|
58
|
-
this.address = address;
|
|
59
|
-
}
|
|
60
|
-
static fromString(value, base = 16) {
|
|
61
|
-
if (value) {
|
|
62
|
-
const bn = new import_bignumber.BigNumber(value.startsWith("0x") ? value.substring(2) : value, base);
|
|
63
|
-
return new _EthAddress(bn);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
static parse(value, base) {
|
|
67
|
-
if (typeof value === "string") {
|
|
68
|
-
return this.fromString(value, base);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
equals(address) {
|
|
72
|
-
if (address) {
|
|
73
|
-
let inAddress;
|
|
74
|
-
if (typeof address === "string") {
|
|
75
|
-
inAddress = (0, import_assert.assertEx)(_EthAddress.fromString(address), "Bad Address");
|
|
76
|
-
} else {
|
|
77
|
-
inAddress = address;
|
|
78
|
-
}
|
|
79
|
-
return this.address.eq(inAddress.address);
|
|
80
|
-
}
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
toBigNumber() {
|
|
84
|
-
return this.address;
|
|
85
|
-
}
|
|
86
|
-
toHex() {
|
|
87
|
-
return padHex(this.address.toString(16), 20);
|
|
88
|
-
}
|
|
89
|
-
toJSON() {
|
|
90
|
-
return `0x${this.toHex()}`;
|
|
91
|
-
}
|
|
92
|
-
toLowerCaseString() {
|
|
93
|
-
return this.toString().toLowerCase();
|
|
94
|
-
}
|
|
95
|
-
toShortString(length = 2) {
|
|
96
|
-
return `0x${ellipsize(this.toHex(), length)}`;
|
|
97
|
-
}
|
|
98
|
-
toString() {
|
|
99
|
-
return `0x${this.toHex()}`;
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
-
0 && (module.exports = {
|
|
104
|
-
EthAddress,
|
|
105
|
-
isEthAddress
|
|
106
|
-
});
|
|
107
|
-
//# sourceMappingURL=EthAddress.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/EthAddress.ts","../../src/ellipsize.ts","../../src/padHex.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { BigNumber } from '@xylabs/bignumber'\n\nimport { ellipsize } from './ellipsize'\nimport { padHex } from './padHex'\n\nexport const isEthAddress = (obj: { type: string }) => obj?.type === EthAddress.type\n\nexport class EthAddress {\n static type = 'EthAddress'\n\n type = EthAddress.type\n\n private address: BigNumber\n\n private constructor(address: BigNumber) {\n this.address = address\n }\n\n static fromString(value?: string, base = 16) {\n if (value) {\n const bn = new BigNumber(value.startsWith('0x') ? value.substring(2) : value, base)\n return new EthAddress(bn)\n }\n }\n\n static parse(value: unknown, base?: number) {\n if (typeof value === 'string') {\n return this.fromString(value, base)\n }\n }\n\n equals(address?: EthAddress | string | null): boolean {\n if (address) {\n let inAddress: EthAddress\n if (typeof address === 'string') {\n inAddress = assertEx(EthAddress.fromString(address), 'Bad Address')\n } else {\n inAddress = address\n }\n return this.address.eq(inAddress.address)\n }\n return false\n }\n\n toBigNumber() {\n return this.address\n }\n\n toHex() {\n return padHex(this.address.toString(16), 20)\n }\n\n toJSON(): string {\n return `0x${this.toHex()}`\n }\n\n toLowerCaseString() {\n return this.toString().toLowerCase()\n }\n\n toShortString(length = 2) {\n return `0x${ellipsize(this.toHex(), length)}`\n }\n\n toString() {\n return `0x${this.toHex()}`\n }\n}\n","export const ellipsize = (value: string, length = 2) => {\n const part1 = value.slice(0, length)\n const part2 = value.slice(value.length - length, value.length)\n return `${part1}...${part2}`\n}\n","const padHex = (hex: string, byteCount?: number) => {\n let result = hex\n if (hex.length % 2 !== 0) {\n result = `0${hex}`\n }\n if (byteCount) {\n while (result.length / 2 < byteCount) {\n result = `00${result}`\n }\n }\n return result\n}\n\nexport { padHex }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyB;AACzB,uBAA0B;;;ACDnB,IAAM,YAAY,CAAC,OAAe,SAAS,MAAM;AACtD,QAAM,QAAQ,MAAM,MAAM,GAAG,MAAM;AACnC,QAAM,QAAQ,MAAM,MAAM,MAAM,SAAS,QAAQ,MAAM,MAAM;AAC7D,SAAO,GAAG,KAAK,MAAM,KAAK;AAC5B;;;ACJA,IAAM,SAAS,CAAC,KAAa,cAAuB;AAClD,MAAI,SAAS;AACb,MAAI,IAAI,SAAS,MAAM,GAAG;AACxB,aAAS,IAAI,GAAG;AAAA,EAClB;AACA,MAAI,WAAW;AACb,WAAO,OAAO,SAAS,IAAI,WAAW;AACpC,eAAS,KAAK,MAAM;AAAA,IACtB;AAAA,EACF;AACA,SAAO;AACT;;;AFLO,IAAM,eAAe,CAAC,SAA0B,2BAAK,UAAS,WAAW;AAEzE,IAAM,aAAN,MAAM,YAAW;AAAA,EACtB,OAAO,OAAO;AAAA,EAEd,OAAO,YAAW;AAAA,EAEV;AAAA,EAEA,YAAY,SAAoB;AACtC,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,OAAO,WAAW,OAAgB,OAAO,IAAI;AAC3C,QAAI,OAAO;AACT,YAAM,KAAK,IAAI,2BAAU,MAAM,WAAW,IAAI,IAAI,MAAM,UAAU,CAAC,IAAI,OAAO,IAAI;AAClF,aAAO,IAAI,YAAW,EAAE;AAAA,IAC1B;AAAA,EACF;AAAA,EAEA,OAAO,MAAM,OAAgB,MAAe;AAC1C,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO,KAAK,WAAW,OAAO,IAAI;AAAA,IACpC;AAAA,EACF;AAAA,EAEA,OAAO,SAA+C;AACpD,QAAI,SAAS;AACX,UAAI;AACJ,UAAI,OAAO,YAAY,UAAU;AAC/B,wBAAY,wBAAS,YAAW,WAAW,OAAO,GAAG,aAAa;AAAA,MACpE,OAAO;AACL,oBAAY;AAAA,MACd;AACA,aAAO,KAAK,QAAQ,GAAG,UAAU,OAAO;AAAA,IAC1C;AACA,WAAO;AAAA,EACT;AAAA,EAEA,cAAc;AACZ,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,QAAQ;AACN,WAAO,OAAO,KAAK,QAAQ,SAAS,EAAE,GAAG,EAAE;AAAA,EAC7C;AAAA,EAEA,SAAiB;AACf,WAAO,KAAK,KAAK,MAAM,CAAC;AAAA,EAC1B;AAAA,EAEA,oBAAoB;AAClB,WAAO,KAAK,SAAS,EAAE,YAAY;AAAA,EACrC;AAAA,EAEA,cAAc,SAAS,GAAG;AACxB,WAAO,KAAK,UAAU,KAAK,MAAM,GAAG,MAAM,CAAC;AAAA,EAC7C;AAAA,EAEA,WAAW;AACT,WAAO,KAAK,KAAK,MAAM,CAAC;AAAA,EAC1B;AACF;","names":[]}
|
package/dist/node/EthAddress.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
// src/EthAddress.ts
|
|
2
|
-
import { assertEx } from "@xylabs/assert";
|
|
3
|
-
import { BigNumber } from "@xylabs/bignumber";
|
|
4
|
-
|
|
5
|
-
// src/ellipsize.ts
|
|
6
|
-
var 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}`;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// src/padHex.ts
|
|
13
|
-
var padHex = (hex, byteCount) => {
|
|
14
|
-
let result = hex;
|
|
15
|
-
if (hex.length % 2 !== 0) {
|
|
16
|
-
result = `0${hex}`;
|
|
17
|
-
}
|
|
18
|
-
if (byteCount) {
|
|
19
|
-
while (result.length / 2 < byteCount) {
|
|
20
|
-
result = `00${result}`;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// src/EthAddress.ts
|
|
27
|
-
var isEthAddress = (obj) => (obj == null ? void 0 : obj.type) === EthAddress.type;
|
|
28
|
-
var EthAddress = class _EthAddress {
|
|
29
|
-
static type = "EthAddress";
|
|
30
|
-
type = _EthAddress.type;
|
|
31
|
-
address;
|
|
32
|
-
constructor(address) {
|
|
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);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
static parse(value, base) {
|
|
42
|
-
if (typeof value === "string") {
|
|
43
|
-
return this.fromString(value, base);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
equals(address) {
|
|
47
|
-
if (address) {
|
|
48
|
-
let inAddress;
|
|
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);
|
|
55
|
-
}
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
toBigNumber() {
|
|
59
|
-
return this.address;
|
|
60
|
-
}
|
|
61
|
-
toHex() {
|
|
62
|
-
return padHex(this.address.toString(16), 20);
|
|
63
|
-
}
|
|
64
|
-
toJSON() {
|
|
65
|
-
return `0x${this.toHex()}`;
|
|
66
|
-
}
|
|
67
|
-
toLowerCaseString() {
|
|
68
|
-
return this.toString().toLowerCase();
|
|
69
|
-
}
|
|
70
|
-
toShortString(length = 2) {
|
|
71
|
-
return `0x${ellipsize(this.toHex(), length)}`;
|
|
72
|
-
}
|
|
73
|
-
toString() {
|
|
74
|
-
return `0x${this.toHex()}`;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
export {
|
|
78
|
-
EthAddress,
|
|
79
|
-
isEthAddress
|
|
80
|
-
};
|
|
81
|
-
//# sourceMappingURL=EthAddress.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/EthAddress.ts","../../src/ellipsize.ts","../../src/padHex.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { BigNumber } from '@xylabs/bignumber'\n\nimport { ellipsize } from './ellipsize'\nimport { padHex } from './padHex'\n\nexport const isEthAddress = (obj: { type: string }) => obj?.type === EthAddress.type\n\nexport class EthAddress {\n static type = 'EthAddress'\n\n type = EthAddress.type\n\n private address: BigNumber\n\n private constructor(address: BigNumber) {\n this.address = address\n }\n\n static fromString(value?: string, base = 16) {\n if (value) {\n const bn = new BigNumber(value.startsWith('0x') ? value.substring(2) : value, base)\n return new EthAddress(bn)\n }\n }\n\n static parse(value: unknown, base?: number) {\n if (typeof value === 'string') {\n return this.fromString(value, base)\n }\n }\n\n equals(address?: EthAddress | string | null): boolean {\n if (address) {\n let inAddress: EthAddress\n if (typeof address === 'string') {\n inAddress = assertEx(EthAddress.fromString(address), 'Bad Address')\n } else {\n inAddress = address\n }\n return this.address.eq(inAddress.address)\n }\n return false\n }\n\n toBigNumber() {\n return this.address\n }\n\n toHex() {\n return padHex(this.address.toString(16), 20)\n }\n\n toJSON(): string {\n return `0x${this.toHex()}`\n }\n\n toLowerCaseString() {\n return this.toString().toLowerCase()\n }\n\n toShortString(length = 2) {\n return `0x${ellipsize(this.toHex(), length)}`\n }\n\n toString() {\n return `0x${this.toHex()}`\n }\n}\n","export const ellipsize = (value: string, length = 2) => {\n const part1 = value.slice(0, length)\n const part2 = value.slice(value.length - length, value.length)\n return `${part1}...${part2}`\n}\n","const padHex = (hex: string, byteCount?: number) => {\n let result = hex\n if (hex.length % 2 !== 0) {\n result = `0${hex}`\n }\n if (byteCount) {\n while (result.length / 2 < byteCount) {\n result = `00${result}`\n }\n }\n return result\n}\n\nexport { padHex }\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;;;ACDnB,IAAM,YAAY,CAAC,OAAe,SAAS,MAAM;AACtD,QAAM,QAAQ,MAAM,MAAM,GAAG,MAAM;AACnC,QAAM,QAAQ,MAAM,MAAM,MAAM,SAAS,QAAQ,MAAM,MAAM;AAC7D,SAAO,GAAG,KAAK,MAAM,KAAK;AAC5B;;;ACJA,IAAM,SAAS,CAAC,KAAa,cAAuB;AAClD,MAAI,SAAS;AACb,MAAI,IAAI,SAAS,MAAM,GAAG;AACxB,aAAS,IAAI,GAAG;AAAA,EAClB;AACA,MAAI,WAAW;AACb,WAAO,OAAO,SAAS,IAAI,WAAW;AACpC,eAAS,KAAK,MAAM;AAAA,IACtB;AAAA,EACF;AACA,SAAO;AACT;;;AFLO,IAAM,eAAe,CAAC,SAA0B,2BAAK,UAAS,WAAW;AAEzE,IAAM,aAAN,MAAM,YAAW;AAAA,EACtB,OAAO,OAAO;AAAA,EAEd,OAAO,YAAW;AAAA,EAEV;AAAA,EAEA,YAAY,SAAoB;AACtC,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,OAAO,WAAW,OAAgB,OAAO,IAAI;AAC3C,QAAI,OAAO;AACT,YAAM,KAAK,IAAI,UAAU,MAAM,WAAW,IAAI,IAAI,MAAM,UAAU,CAAC,IAAI,OAAO,IAAI;AAClF,aAAO,IAAI,YAAW,EAAE;AAAA,IAC1B;AAAA,EACF;AAAA,EAEA,OAAO,MAAM,OAAgB,MAAe;AAC1C,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO,KAAK,WAAW,OAAO,IAAI;AAAA,IACpC;AAAA,EACF;AAAA,EAEA,OAAO,SAA+C;AACpD,QAAI,SAAS;AACX,UAAI;AACJ,UAAI,OAAO,YAAY,UAAU;AAC/B,oBAAY,SAAS,YAAW,WAAW,OAAO,GAAG,aAAa;AAAA,MACpE,OAAO;AACL,oBAAY;AAAA,MACd;AACA,aAAO,KAAK,QAAQ,GAAG,UAAU,OAAO;AAAA,IAC1C;AACA,WAAO;AAAA,EACT;AAAA,EAEA,cAAc;AACZ,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,QAAQ;AACN,WAAO,OAAO,KAAK,QAAQ,SAAS,EAAE,GAAG,EAAE;AAAA,EAC7C;AAAA,EAEA,SAAiB;AACf,WAAO,KAAK,KAAK,MAAM,CAAC;AAAA,EAC1B;AAAA,EAEA,oBAAoB;AAClB,WAAO,KAAK,SAAS,EAAE,YAAY;AAAA,EACrC;AAAA,EAEA,cAAc,SAAS,GAAG;AACxB,WAAO,KAAK,UAAU,KAAK,MAAM,GAAG,MAAM,CAAC;AAAA,EAC7C;AAAA,EAEA,WAAW;AACT,WAAO,KAAK,KAAK,MAAM,CAAC;AAAA,EAC1B;AACF;","names":[]}
|
package/dist/node/ellipsize.cjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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);
|
|
19
|
-
|
|
20
|
-
// src/ellipsize.ts
|
|
21
|
-
var ellipsize_exports = {};
|
|
22
|
-
__export(ellipsize_exports, {
|
|
23
|
-
ellipsize: () => ellipsize
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(ellipsize_exports);
|
|
26
|
-
var ellipsize = (value, length = 2) => {
|
|
27
|
-
const part1 = value.slice(0, length);
|
|
28
|
-
const part2 = value.slice(value.length - length, value.length);
|
|
29
|
-
return `${part1}...${part2}`;
|
|
30
|
-
};
|
|
31
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
-
0 && (module.exports = {
|
|
33
|
-
ellipsize
|
|
34
|
-
});
|
|
35
|
-
//# sourceMappingURL=ellipsize.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ellipsize.ts"],"sourcesContent":["export const ellipsize = (value: string, length = 2) => {\n const part1 = value.slice(0, length)\n const part2 = value.slice(value.length - length, value.length)\n return `${part1}...${part2}`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,YAAY,CAAC,OAAe,SAAS,MAAM;AACtD,QAAM,QAAQ,MAAM,MAAM,GAAG,MAAM;AACnC,QAAM,QAAQ,MAAM,MAAM,MAAM,SAAS,QAAQ,MAAM,MAAM;AAC7D,SAAO,GAAG,KAAK,MAAM,KAAK;AAC5B;","names":[]}
|
package/dist/node/ellipsize.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// src/ellipsize.ts
|
|
2
|
-
var ellipsize = (value, length = 2) => {
|
|
3
|
-
const part1 = value.slice(0, length);
|
|
4
|
-
const part2 = value.slice(value.length - length, value.length);
|
|
5
|
-
return `${part1}...${part2}`;
|
|
6
|
-
};
|
|
7
|
-
export {
|
|
8
|
-
ellipsize
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=ellipsize.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ellipsize.ts"],"sourcesContent":["export const ellipsize = (value: string, length = 2) => {\n const part1 = value.slice(0, length)\n const part2 = value.slice(value.length - length, value.length)\n return `${part1}...${part2}`\n}\n"],"mappings":";AAAO,IAAM,YAAY,CAAC,OAAe,SAAS,MAAM;AACtD,QAAM,QAAQ,MAAM,MAAM,GAAG,MAAM;AACnC,QAAM,QAAQ,MAAM,MAAM,MAAM,SAAS,QAAQ,MAAM,MAAM;AAC7D,SAAO,GAAG,KAAK,MAAM,KAAK;AAC5B;","names":[]}
|
package/dist/node/padHex.cjs
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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);
|
|
19
|
-
|
|
20
|
-
// src/padHex.ts
|
|
21
|
-
var padHex_exports = {};
|
|
22
|
-
__export(padHex_exports, {
|
|
23
|
-
padHex: () => padHex
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(padHex_exports);
|
|
26
|
-
var padHex = (hex, byteCount) => {
|
|
27
|
-
let result = hex;
|
|
28
|
-
if (hex.length % 2 !== 0) {
|
|
29
|
-
result = `0${hex}`;
|
|
30
|
-
}
|
|
31
|
-
if (byteCount) {
|
|
32
|
-
while (result.length / 2 < byteCount) {
|
|
33
|
-
result = `00${result}`;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
-
0 && (module.exports = {
|
|
40
|
-
padHex
|
|
41
|
-
});
|
|
42
|
-
//# sourceMappingURL=padHex.cjs.map
|
package/dist/node/padHex.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/padHex.ts"],"sourcesContent":["const padHex = (hex: string, byteCount?: number) => {\n let result = hex\n if (hex.length % 2 !== 0) {\n result = `0${hex}`\n }\n if (byteCount) {\n while (result.length / 2 < byteCount) {\n result = `00${result}`\n }\n }\n return result\n}\n\nexport { padHex }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAM,SAAS,CAAC,KAAa,cAAuB;AAClD,MAAI,SAAS;AACb,MAAI,IAAI,SAAS,MAAM,GAAG;AACxB,aAAS,IAAI,GAAG;AAAA,EAClB;AACA,MAAI,WAAW;AACb,WAAO,OAAO,SAAS,IAAI,WAAW;AACpC,eAAS,KAAK,MAAM;AAAA,IACtB;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
package/dist/node/padHex.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// src/padHex.ts
|
|
2
|
-
var padHex = (hex, byteCount) => {
|
|
3
|
-
let result = hex;
|
|
4
|
-
if (hex.length % 2 !== 0) {
|
|
5
|
-
result = `0${hex}`;
|
|
6
|
-
}
|
|
7
|
-
if (byteCount) {
|
|
8
|
-
while (result.length / 2 < byteCount) {
|
|
9
|
-
result = `00${result}`;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return result;
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
padHex
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=padHex.js.map
|
package/dist/node/padHex.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/padHex.ts"],"sourcesContent":["const padHex = (hex: string, byteCount?: number) => {\n let result = hex\n if (hex.length % 2 !== 0) {\n result = `0${hex}`\n }\n if (byteCount) {\n while (result.length / 2 < byteCount) {\n result = `00${result}`\n }\n }\n return result\n}\n\nexport { padHex }\n"],"mappings":";AAAA,IAAM,SAAS,CAAC,KAAa,cAAuB;AAClD,MAAI,SAAS;AACb,MAAI,IAAI,SAAS,MAAM,GAAG;AACxB,aAAS,IAAI,GAAG;AAAA,EAClB;AACA,MAAI,WAAW;AACb,WAAO,OAAO,SAAS,IAAI,WAAW;AACpC,eAAS,KAAK,MAAM;AAAA,IACtB;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|