@xylabs/eth-address 2.11.24 → 2.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/{EthAddress.mjs → EthAddress.cjs} +33 -7
- package/dist/node/{EthAddress.mjs.map → EthAddress.cjs.map} +1 -1
- package/dist/node/EthAddress.js +6 -32
- package/dist/node/EthAddress.js.map +1 -1
- package/dist/node/ellipsize.cjs +35 -0
- package/dist/node/{ellipsize.mjs.map → ellipsize.cjs.map} +1 -1
- package/dist/node/ellipsize.js +2 -27
- package/dist/node/ellipsize.js.map +1 -1
- package/dist/node/{index.mjs → index.cjs} +37 -7
- package/dist/node/index.cjs.map +1 -0
- package/dist/node/index.js +6 -36
- package/dist/node/index.js.map +1 -1
- package/dist/node/padHex.cjs +42 -0
- package/dist/node/{padHex.mjs.map → padHex.cjs.map} +1 -1
- package/dist/node/padHex.js +2 -27
- package/dist/node/padHex.js.map +1 -1
- package/package.json +10 -9
- package/dist/node/ellipsize.mjs +0 -10
- package/dist/node/index.mjs.map +0 -1
- package/dist/node/padHex.mjs +0 -17
|
@@ -1,6 +1,31 @@
|
|
|
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
|
+
|
|
1
20
|
// src/EthAddress.ts
|
|
2
|
-
|
|
3
|
-
|
|
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");
|
|
4
29
|
|
|
5
30
|
// src/ellipsize.ts
|
|
6
31
|
var ellipsize = (value, length = 2) => {
|
|
@@ -34,7 +59,7 @@ var EthAddress = class _EthAddress {
|
|
|
34
59
|
}
|
|
35
60
|
static fromString(value, base = 16) {
|
|
36
61
|
if (value) {
|
|
37
|
-
const bn = new BigNumber(value.startsWith("0x") ? value.substring(2) : value, base);
|
|
62
|
+
const bn = new import_bignumber.BigNumber(value.startsWith("0x") ? value.substring(2) : value, base);
|
|
38
63
|
return new _EthAddress(bn);
|
|
39
64
|
}
|
|
40
65
|
}
|
|
@@ -47,7 +72,7 @@ var EthAddress = class _EthAddress {
|
|
|
47
72
|
if (address) {
|
|
48
73
|
let inAddress;
|
|
49
74
|
if (typeof address === "string") {
|
|
50
|
-
inAddress = assertEx(_EthAddress.fromString(address), "Bad Address");
|
|
75
|
+
inAddress = (0, import_assert.assertEx)(_EthAddress.fromString(address), "Bad Address");
|
|
51
76
|
} else {
|
|
52
77
|
inAddress = address;
|
|
53
78
|
}
|
|
@@ -74,8 +99,9 @@ var EthAddress = class _EthAddress {
|
|
|
74
99
|
return `0x${this.toHex()}`;
|
|
75
100
|
}
|
|
76
101
|
};
|
|
77
|
-
export
|
|
102
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
+
0 && (module.exports = {
|
|
78
104
|
EthAddress,
|
|
79
105
|
isEthAddress
|
|
80
|
-
};
|
|
81
|
-
//# sourceMappingURL=EthAddress.
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=EthAddress.cjs.map
|
|
@@ -1 +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 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,
|
|
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;A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,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
CHANGED
|
@@ -1,31 +1,6 @@
|
|
|
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
1
|
// src/EthAddress.ts
|
|
21
|
-
|
|
22
|
-
|
|
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");
|
|
2
|
+
import { assertEx } from "@xylabs/assert";
|
|
3
|
+
import { BigNumber } from "@xylabs/bignumber";
|
|
29
4
|
|
|
30
5
|
// src/ellipsize.ts
|
|
31
6
|
var ellipsize = (value, length = 2) => {
|
|
@@ -59,7 +34,7 @@ var EthAddress = class _EthAddress {
|
|
|
59
34
|
}
|
|
60
35
|
static fromString(value, base = 16) {
|
|
61
36
|
if (value) {
|
|
62
|
-
const bn = new
|
|
37
|
+
const bn = new BigNumber(value.startsWith("0x") ? value.substring(2) : value, base);
|
|
63
38
|
return new _EthAddress(bn);
|
|
64
39
|
}
|
|
65
40
|
}
|
|
@@ -72,7 +47,7 @@ var EthAddress = class _EthAddress {
|
|
|
72
47
|
if (address) {
|
|
73
48
|
let inAddress;
|
|
74
49
|
if (typeof address === "string") {
|
|
75
|
-
inAddress =
|
|
50
|
+
inAddress = assertEx(_EthAddress.fromString(address), "Bad Address");
|
|
76
51
|
} else {
|
|
77
52
|
inAddress = address;
|
|
78
53
|
}
|
|
@@ -99,9 +74,8 @@ var EthAddress = class _EthAddress {
|
|
|
99
74
|
return `0x${this.toHex()}`;
|
|
100
75
|
}
|
|
101
76
|
};
|
|
102
|
-
|
|
103
|
-
0 && (module.exports = {
|
|
77
|
+
export {
|
|
104
78
|
EthAddress,
|
|
105
79
|
isEthAddress
|
|
106
|
-
}
|
|
80
|
+
};
|
|
107
81
|
//# sourceMappingURL=EthAddress.js.map
|
|
@@ -1 +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 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":"
|
|
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,W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AAM,CAAC;AAAA,EAC7C;AAAA,EAEA,WAAW;AACT,WAAO,KAAK,KAAK,MAAM,CAAC;AAAA,EAC1B;AACF;","names":[]}
|
|
@@ -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.cjs.map
|
|
@@ -1 +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":[]}
|
|
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
CHANGED
|
@@ -1,35 +1,10 @@
|
|
|
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
1
|
// src/ellipsize.ts
|
|
21
|
-
var ellipsize_exports = {};
|
|
22
|
-
__export(ellipsize_exports, {
|
|
23
|
-
ellipsize: () => ellipsize
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(ellipsize_exports);
|
|
26
2
|
var ellipsize = (value, length = 2) => {
|
|
27
3
|
const part1 = value.slice(0, length);
|
|
28
4
|
const part2 = value.slice(value.length - length, value.length);
|
|
29
5
|
return `${part1}...${part2}`;
|
|
30
6
|
};
|
|
31
|
-
|
|
32
|
-
0 && (module.exports = {
|
|
7
|
+
export {
|
|
33
8
|
ellipsize
|
|
34
|
-
}
|
|
9
|
+
};
|
|
35
10
|
//# sourceMappingURL=ellipsize.js.map
|
|
@@ -1 +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":"
|
|
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":[]}
|
|
@@ -1,3 +1,32 @@
|
|
|
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
|
+
|
|
1
30
|
// src/ellipsize.ts
|
|
2
31
|
var ellipsize = (value, length = 2) => {
|
|
3
32
|
const part1 = value.slice(0, length);
|
|
@@ -6,8 +35,8 @@ var ellipsize = (value, length = 2) => {
|
|
|
6
35
|
};
|
|
7
36
|
|
|
8
37
|
// src/EthAddress.ts
|
|
9
|
-
|
|
10
|
-
|
|
38
|
+
var import_assert = require("@xylabs/assert");
|
|
39
|
+
var import_bignumber = require("@xylabs/bignumber");
|
|
11
40
|
|
|
12
41
|
// src/padHex.ts
|
|
13
42
|
var padHex = (hex, byteCount) => {
|
|
@@ -34,7 +63,7 @@ var EthAddress = class _EthAddress {
|
|
|
34
63
|
}
|
|
35
64
|
static fromString(value, base = 16) {
|
|
36
65
|
if (value) {
|
|
37
|
-
const bn = new BigNumber(value.startsWith("0x") ? value.substring(2) : value, base);
|
|
66
|
+
const bn = new import_bignumber.BigNumber(value.startsWith("0x") ? value.substring(2) : value, base);
|
|
38
67
|
return new _EthAddress(bn);
|
|
39
68
|
}
|
|
40
69
|
}
|
|
@@ -47,7 +76,7 @@ var EthAddress = class _EthAddress {
|
|
|
47
76
|
if (address) {
|
|
48
77
|
let inAddress;
|
|
49
78
|
if (typeof address === "string") {
|
|
50
|
-
inAddress = assertEx(_EthAddress.fromString(address), "Bad Address");
|
|
79
|
+
inAddress = (0, import_assert.assertEx)(_EthAddress.fromString(address), "Bad Address");
|
|
51
80
|
} else {
|
|
52
81
|
inAddress = address;
|
|
53
82
|
}
|
|
@@ -74,10 +103,11 @@ var EthAddress = class _EthAddress {
|
|
|
74
103
|
return `0x${this.toHex()}`;
|
|
75
104
|
}
|
|
76
105
|
};
|
|
77
|
-
export
|
|
106
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
+
0 && (module.exports = {
|
|
78
108
|
EthAddress,
|
|
79
109
|
ellipsize,
|
|
80
110
|
isEthAddress,
|
|
81
111
|
padHex
|
|
82
|
-
};
|
|
83
|
-
//# sourceMappingURL=index.
|
|
112
|
+
});
|
|
113
|
+
//# sourceMappingURL=index.cjs.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 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","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;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,oBAAyB;AACzB,uBAA0B;;;ACD1B,IAAM,SAAS,CAAC,KAAa,c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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/index.js
CHANGED
|
@@ -1,32 +1,3 @@
|
|
|
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
1
|
// src/ellipsize.ts
|
|
31
2
|
var ellipsize = (value, length = 2) => {
|
|
32
3
|
const part1 = value.slice(0, length);
|
|
@@ -35,8 +6,8 @@ var ellipsize = (value, length = 2) => {
|
|
|
35
6
|
};
|
|
36
7
|
|
|
37
8
|
// src/EthAddress.ts
|
|
38
|
-
|
|
39
|
-
|
|
9
|
+
import { assertEx } from "@xylabs/assert";
|
|
10
|
+
import { BigNumber } from "@xylabs/bignumber";
|
|
40
11
|
|
|
41
12
|
// src/padHex.ts
|
|
42
13
|
var padHex = (hex, byteCount) => {
|
|
@@ -63,7 +34,7 @@ var EthAddress = class _EthAddress {
|
|
|
63
34
|
}
|
|
64
35
|
static fromString(value, base = 16) {
|
|
65
36
|
if (value) {
|
|
66
|
-
const bn = new
|
|
37
|
+
const bn = new BigNumber(value.startsWith("0x") ? value.substring(2) : value, base);
|
|
67
38
|
return new _EthAddress(bn);
|
|
68
39
|
}
|
|
69
40
|
}
|
|
@@ -76,7 +47,7 @@ var EthAddress = class _EthAddress {
|
|
|
76
47
|
if (address) {
|
|
77
48
|
let inAddress;
|
|
78
49
|
if (typeof address === "string") {
|
|
79
|
-
inAddress =
|
|
50
|
+
inAddress = assertEx(_EthAddress.fromString(address), "Bad Address");
|
|
80
51
|
} else {
|
|
81
52
|
inAddress = address;
|
|
82
53
|
}
|
|
@@ -103,11 +74,10 @@ var EthAddress = class _EthAddress {
|
|
|
103
74
|
return `0x${this.toHex()}`;
|
|
104
75
|
}
|
|
105
76
|
};
|
|
106
|
-
|
|
107
|
-
0 && (module.exports = {
|
|
77
|
+
export {
|
|
108
78
|
EthAddress,
|
|
109
79
|
ellipsize,
|
|
110
80
|
isEthAddress,
|
|
111
81
|
padHex
|
|
112
|
-
}
|
|
82
|
+
};
|
|
113
83
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
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 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","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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A,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":[]}
|
|
@@ -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.cjs.map
|
|
@@ -1 +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":[]}
|
|
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
CHANGED
|
@@ -1,28 +1,4 @@
|
|
|
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
1
|
// src/padHex.ts
|
|
21
|
-
var padHex_exports = {};
|
|
22
|
-
__export(padHex_exports, {
|
|
23
|
-
padHex: () => padHex
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(padHex_exports);
|
|
26
2
|
var padHex = (hex, byteCount) => {
|
|
27
3
|
let result = hex;
|
|
28
4
|
if (hex.length % 2 !== 0) {
|
|
@@ -35,8 +11,7 @@ var padHex = (hex, byteCount) => {
|
|
|
35
11
|
}
|
|
36
12
|
return result;
|
|
37
13
|
};
|
|
38
|
-
|
|
39
|
-
0 && (module.exports = {
|
|
14
|
+
export {
|
|
40
15
|
padHex
|
|
41
|
-
}
|
|
16
|
+
};
|
|
42
17
|
//# sourceMappingURL=padHex.js.map
|
package/dist/node/padHex.js.map
CHANGED
|
@@ -1 +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":"
|
|
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/package.json
CHANGED
|
@@ -15,16 +15,15 @@
|
|
|
15
15
|
],
|
|
16
16
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
17
17
|
"docs": "dist/docs.json",
|
|
18
|
-
"types": "dist/node/index.d.ts",
|
|
19
18
|
"exports": {
|
|
20
19
|
".": {
|
|
21
20
|
"require": {
|
|
22
21
|
"types": "./dist/node/index.d.ts",
|
|
23
|
-
"default": "./dist/node/index.
|
|
22
|
+
"default": "./dist/node/index.cjs"
|
|
24
23
|
},
|
|
25
24
|
"import": {
|
|
26
25
|
"types": "./dist/node/index.d.mts",
|
|
27
|
-
"default": "./dist/node/index.
|
|
26
|
+
"default": "./dist/node/index.js"
|
|
28
27
|
}
|
|
29
28
|
},
|
|
30
29
|
"./docs": {
|
|
@@ -32,8 +31,9 @@
|
|
|
32
31
|
},
|
|
33
32
|
"./package.json": "./package.json"
|
|
34
33
|
},
|
|
35
|
-
"main": "dist/node/index.
|
|
36
|
-
"
|
|
34
|
+
"main": "./dist/node/index.cjs",
|
|
35
|
+
"types": "./dist/node/index.d.ts",
|
|
36
|
+
"module": "./dist/node/index.js",
|
|
37
37
|
"homepage": "https://xylabs.com",
|
|
38
38
|
"keywords": [
|
|
39
39
|
"xylabs",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"esm"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@xylabs/assert": "~2.
|
|
46
|
-
"@xylabs/bignumber": "~2.
|
|
45
|
+
"@xylabs/assert": "~2.12.2",
|
|
46
|
+
"@xylabs/bignumber": "~2.12.2"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@xylabs/ts-scripts-yarn3": "^3.0.74",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"url": "https://github.com/xylabs/sdk-js.git"
|
|
60
60
|
},
|
|
61
61
|
"sideEffects": false,
|
|
62
|
-
"version": "2.
|
|
63
|
-
"packageManager": "yarn@3.3.1"
|
|
62
|
+
"version": "2.12.2",
|
|
63
|
+
"packageManager": "yarn@3.3.1",
|
|
64
|
+
"type": "module"
|
|
64
65
|
}
|
package/dist/node/ellipsize.mjs
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.mjs.map
|
package/dist/node/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 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","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,I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,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/padHex.mjs
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.mjs.map
|