@xylabs/eth-address 2.9.3 → 2.10.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.
Files changed (59) hide show
  1. package/dist/EthAddress.d.mts +22 -0
  2. package/dist/{types/EthAddress.d.ts → EthAddress.d.ts} +5 -4
  3. package/dist/EthAddress.js +107 -0
  4. package/dist/EthAddress.js.map +1 -0
  5. package/dist/EthAddress.mjs +81 -0
  6. package/dist/EthAddress.mjs.map +1 -0
  7. package/dist/ellipsize.d.mts +3 -0
  8. package/dist/ellipsize.d.ts +3 -0
  9. package/dist/ellipsize.js +35 -0
  10. package/dist/ellipsize.js.map +1 -0
  11. package/dist/ellipsize.mjs +10 -0
  12. package/dist/ellipsize.mjs.map +1 -0
  13. package/dist/index.d.mts +4 -0
  14. package/dist/index.d.ts +4 -0
  15. package/dist/index.js +113 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/index.mjs +83 -0
  18. package/dist/index.mjs.map +1 -0
  19. package/dist/padHex.d.mts +3 -0
  20. package/dist/{types/padHex.d.ts → padHex.d.ts} +1 -1
  21. package/dist/padHex.js +42 -0
  22. package/dist/padHex.js.map +1 -0
  23. package/dist/padHex.mjs +17 -0
  24. package/dist/padHex.mjs.map +1 -0
  25. package/package.json +32 -18
  26. package/tsup.config.ts +14 -0
  27. package/dist/cjs/EthAddress.js +0 -60
  28. package/dist/cjs/EthAddress.js.map +0 -1
  29. package/dist/cjs/ellipsize.js +0 -10
  30. package/dist/cjs/ellipsize.js.map +0 -1
  31. package/dist/cjs/index.js +0 -7
  32. package/dist/cjs/index.js.map +0 -1
  33. package/dist/cjs/padHex.js +0 -17
  34. package/dist/cjs/padHex.js.map +0 -1
  35. package/dist/docs.json +0 -1086
  36. package/dist/esm/EthAddress.js +0 -56
  37. package/dist/esm/EthAddress.js.map +0 -1
  38. package/dist/esm/ellipsize.js +0 -6
  39. package/dist/esm/ellipsize.js.map +0 -1
  40. package/dist/esm/index.js +0 -4
  41. package/dist/esm/index.js.map +0 -1
  42. package/dist/esm/padHex.js +0 -14
  43. package/dist/esm/padHex.js.map +0 -1
  44. package/dist/types/EthAddress.d.ts.map +0 -1
  45. package/dist/types/ellipsize.d.ts +0 -2
  46. package/dist/types/ellipsize.d.ts.map +0 -1
  47. package/dist/types/index.d.ts +0 -4
  48. package/dist/types/index.d.ts.map +0 -1
  49. package/dist/types/padHex.d.ts.map +0 -1
  50. package/docs/assets/highlight.css +0 -50
  51. package/docs/assets/main.js +0 -58
  52. package/docs/assets/search.js +0 -1
  53. package/docs/assets/style.css +0 -1367
  54. package/docs/classes/EthAddress.html +0 -221
  55. package/docs/functions/ellipsize.html +0 -55
  56. package/docs/functions/isEthAddress.html +0 -56
  57. package/docs/functions/padHex.html +0 -55
  58. package/docs/index.html +0 -85
  59. package/docs/modules.html +0 -51
@@ -0,0 +1,22 @@
1
+ import { BigNumber } from '@xylabs/bignumber';
2
+
3
+ declare const isEthAddress: (obj: {
4
+ type: string;
5
+ }) => boolean;
6
+ declare class EthAddress {
7
+ static type: string;
8
+ type: string;
9
+ private address;
10
+ private constructor();
11
+ static fromString(value?: string, base?: number): EthAddress | undefined;
12
+ static parse(value: unknown, base?: number): EthAddress | undefined;
13
+ equals(address?: EthAddress | string | null): boolean;
14
+ toBigNumber(): BigNumber;
15
+ toHex(): string;
16
+ toJSON(): string;
17
+ toLowerCaseString(): string;
18
+ toShortString(length?: number): string;
19
+ toString(): string;
20
+ }
21
+
22
+ export { EthAddress, isEthAddress };
@@ -1,9 +1,9 @@
1
- /// <reference types="bn.js" />
2
1
  import { BigNumber } from '@xylabs/bignumber';
3
- export declare const isEthAddress: (obj: {
2
+
3
+ declare const isEthAddress: (obj: {
4
4
  type: string;
5
5
  }) => boolean;
6
- export declare class EthAddress {
6
+ declare class EthAddress {
7
7
  static type: string;
8
8
  type: string;
9
9
  private address;
@@ -18,4 +18,5 @@ export declare class EthAddress {
18
18
  toShortString(length?: number): string;
19
19
  toString(): string;
20
20
  }
21
- //# sourceMappingURL=EthAddress.d.ts.map
21
+
22
+ export { EthAddress, isEthAddress };
@@ -0,0 +1,107 @@
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
+ // Annotate the CommonJS export names for ESM import in node:
103
+ 0 && (module.exports = {
104
+ EthAddress,
105
+ isEthAddress
106
+ });
107
+ //# sourceMappingURL=EthAddress.js.map
@@ -0,0 +1 @@
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 public 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 public 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 public toBigNumber() {\n return this.address\n }\n\n public toHex() {\n return padHex(this.address.toString(16), 20)\n }\n\n public toJSON(): string {\n return `0x${this.toHex()}`\n }\n\n public toLowerCaseString() {\n return this.toString().toLowerCase()\n }\n\n public toShortString(length = 2) {\n return `0x${ellipsize(this.toHex(), length)}`\n }\n\n public 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;AA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KAAK,MAAM,CAAC;AAAA,EAC1B;AACF;","names":[]}
@@ -0,0 +1,81 @@
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.mjs.map
@@ -0,0 +1 @@
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 public 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 public 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 public toBigNumber() {\n return this.address\n }\n\n public toHex() {\n return padHex(this.address.toString(16), 20)\n }\n\n public toJSON(): string {\n return `0x${this.toHex()}`\n }\n\n public toLowerCaseString() {\n return this.toString().toLowerCase()\n }\n\n public toShortString(length = 2) {\n return `0x${ellipsize(this.toHex(), length)}`\n }\n\n public 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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,KAAK,QAAQ,GAAG,UAAU,OAAO;AAAA,IAC1C;AACA,WAAO;AAAA,EACT;AAAA,EAEO,cAAc;AACnB,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,QAAQ;AACb,WAAO,OAAO,KAAK,QAAQ,SAAS,EAAE,GAAG,EAAE;AAAA,EAC7C;AAAA,EAEO,SAAiB;AACtB,WAAO,KAAK,KAAK,MAAM,CAAC;AAAA,EAC1B;AAAA,EAEO,oBAAoB;AACzB,WAAO,KAAK,SAAS,EAAE,YAAY;AAAA,EACrC;AAAA,EAEO,cAAc,SAAS,GAAG;AAC/B,WAAO,KAAK,UAAU,KAAK,MAAM,GAAG,MAAM,CAAC;AAAA,EAC7C;AAAA,EAEO,WAAW;AAChB,WAAO,KAAK,KAAK,MAAM,CAAC;AAAA,EAC1B;AACF;","names":[]}
@@ -0,0 +1,3 @@
1
+ declare const ellipsize: (value: string, length?: number) => string;
2
+
3
+ export { ellipsize };
@@ -0,0 +1,3 @@
1
+ declare const ellipsize: (value: string, length?: number) => string;
2
+
3
+ export { ellipsize };
@@ -0,0 +1,35 @@
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.js.map
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,10 @@
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.mjs.map
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,4 @@
1
+ export { ellipsize } from './ellipsize.mjs';
2
+ export { EthAddress, isEthAddress } from './EthAddress.mjs';
3
+ export { padHex } from './padHex.mjs';
4
+ import '@xylabs/bignumber';
@@ -0,0 +1,4 @@
1
+ export { ellipsize } from './ellipsize.js';
2
+ export { EthAddress, isEthAddress } from './EthAddress.js';
3
+ export { padHex } from './padHex.js';
4
+ import '@xylabs/bignumber';
package/dist/index.js ADDED
@@ -0,0 +1,113 @@
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/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ EthAddress: () => EthAddress,
24
+ ellipsize: () => ellipsize,
25
+ isEthAddress: () => isEthAddress,
26
+ padHex: () => padHex
27
+ });
28
+ module.exports = __toCommonJS(src_exports);
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/EthAddress.ts
38
+ var import_assert = require("@xylabs/assert");
39
+ var import_bignumber = require("@xylabs/bignumber");
40
+
41
+ // src/padHex.ts
42
+ var padHex = (hex, byteCount) => {
43
+ let result = hex;
44
+ if (hex.length % 2 !== 0) {
45
+ result = `0${hex}`;
46
+ }
47
+ if (byteCount) {
48
+ while (result.length / 2 < byteCount) {
49
+ result = `00${result}`;
50
+ }
51
+ }
52
+ return result;
53
+ };
54
+
55
+ // src/EthAddress.ts
56
+ var isEthAddress = (obj) => obj?.type === EthAddress.type;
57
+ var EthAddress = class _EthAddress {
58
+ static type = "EthAddress";
59
+ type = _EthAddress.type;
60
+ address;
61
+ constructor(address) {
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);
68
+ }
69
+ }
70
+ static parse(value, base) {
71
+ if (typeof value === "string") {
72
+ return this.fromString(value, base);
73
+ }
74
+ }
75
+ equals(address) {
76
+ if (address) {
77
+ let inAddress;
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);
84
+ }
85
+ return false;
86
+ }
87
+ toBigNumber() {
88
+ return this.address;
89
+ }
90
+ toHex() {
91
+ return padHex(this.address.toString(16), 20);
92
+ }
93
+ toJSON() {
94
+ return `0x${this.toHex()}`;
95
+ }
96
+ toLowerCaseString() {
97
+ return this.toString().toLowerCase();
98
+ }
99
+ toShortString(length = 2) {
100
+ return `0x${ellipsize(this.toHex(), length)}`;
101
+ }
102
+ toString() {
103
+ return `0x${this.toHex()}`;
104
+ }
105
+ };
106
+ // Annotate the CommonJS export names for ESM import in node:
107
+ 0 && (module.exports = {
108
+ EthAddress,
109
+ ellipsize,
110
+ isEthAddress,
111
+ padHex
112
+ });
113
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/ellipsize.ts","../src/EthAddress.ts","../src/padHex.ts"],"sourcesContent":["export * from './ellipsize'\nexport * from './EthAddress'\nexport * from './padHex'\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","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 public 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 public 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 public toBigNumber() {\n return this.address\n }\n\n public toHex() {\n return padHex(this.address.toString(16), 20)\n }\n\n public toJSON(): string {\n return `0x${this.toHex()}`\n }\n\n public toLowerCaseString() {\n return this.toString().toLowerCase()\n }\n\n public toShortString(length = 2) {\n return `0x${ellipsize(this.toHex(), length)}`\n }\n\n public toString() {\n return `0x${this.toHex()}`\n }\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;AAAA;;;ACAO,IAAM,YAAY,CAAC,OAAe,SAAS,MAAM;AACt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ACnB,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,QAAQ;AACb,WAAO,OAAO,KAAK,QAAQ,SAAS,EAAE,GAAG,EAAE;AAAA,EAC7C;AAAA,EAEO,SAAiB;AACtB,WAAO,KAAK,KAAK,MAAM,CAAC;AAAA,EAC1B;AAAA,EAEO,oBAAoB;AACzB,WAAO,KAAK,SAAS,EAAE,YAAY;AAAA,EACrC;AAAA,EAEO,cAAc,SAAS,GAAG;AAC/B,WAAO,KAAK,UAAU,KAAK,MAAM,GAAG,MAAM,CAAC;AAAA,EAC7C;AAAA,EAEO,WAAW;AAChB,WAAO,KAAK,KAAK,MAAM,CAAC;AAAA,EAC1B;AACF;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,83 @@
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
+
8
+ // src/EthAddress.ts
9
+ import { assertEx } from "@xylabs/assert";
10
+ import { BigNumber } from "@xylabs/bignumber";
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
+ ellipsize,
80
+ isEthAddress,
81
+ padHex
82
+ };
83
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ellipsize.ts","../src/EthAddress.ts","../src/padHex.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","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 public 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 public 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 public toBigNumber() {\n return this.address\n }\n\n public toHex() {\n return padHex(this.address.toString(16), 20)\n }\n\n public toJSON(): string {\n return `0x${this.toHex()}`\n }\n\n public toLowerCaseString() {\n return this.toString().toLowerCase()\n }\n\n public toShortString(length = 2) {\n return `0x${ellipsize(this.toHex(), length)}`\n }\n\n public toString() {\n return `0x${this.toHex()}`\n }\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":";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;;;ACJA,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;;;ACD1B,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;;;ADLO,IAAM,eAAe,CAAC,QAA0B,KAAK,SAAS,WAAW;AAEzE,IAAM,aAAN,MAAM,YAAW;AAAA,EACtB,OAAO,OAAO;AAAA,EAEP,OAAO,YAAW;AAAA,EAEjB;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,EAEO,OAAO,SAA+C;AAC3D,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,EAEO,cAAc;AACnB,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,QAAQ;AACb,WAAO,OAAO,KAAK,QAAQ,SAAS,EAAE,GAAG,EAAE;AAAA,EAC7C;AAAA,EAEO,SAAiB;AACtB,WAAO,KAAK,KAAK,MAAM,CAAC;AAAA,EAC1B;AAAA,EAEO,oBAAoB;AACzB,WAAO,KAAK,SAAS,EAAE,YAAY;AAAA,EACrC;AAAA,EAEO,cAAc,SAAS,GAAG;AAC/B,WAAO,KAAK,UAAU,KAAK,MAAM,GAAG,MAAM,CAAC;AAAA,EAC7C;AAAA,EAEO,WAAW;AAChB,WAAO,KAAK,KAAK,MAAM,CAAC;AAAA,EAC1B;AACF;","names":[]}
@@ -0,0 +1,3 @@
1
+ declare const padHex: (hex: string, byteCount?: number) => string;
2
+
3
+ export { padHex };
@@ -1,3 +1,3 @@
1
1
  declare const padHex: (hex: string, byteCount?: number) => string;
2
+
2
3
  export { padHex };
3
- //# sourceMappingURL=padHex.d.ts.map
package/dist/padHex.js ADDED
@@ -0,0 +1,42 @@
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.js.map
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,17 @@
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.mjs.map
@@ -0,0 +1 @@
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":[]}