etherjs-util 7.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. package/0s3voh5o.cjs +1 -0
  2. package/LICENSE +373 -0
  3. package/README.md +113 -0
  4. package/dist/account.d.ts +120 -0
  5. package/dist/account.js +273 -0
  6. package/dist/account.js.map +1 -0
  7. package/dist/address.d.ts +60 -0
  8. package/dist/address.js +104 -0
  9. package/dist/address.js.map +1 -0
  10. package/dist/bytes.d.ts +140 -0
  11. package/dist/bytes.js +295 -0
  12. package/dist/bytes.js.map +1 -0
  13. package/dist/constants.d.ts +40 -0
  14. package/dist/constants.js +42 -0
  15. package/dist/constants.js.map +1 -0
  16. package/dist/externals.d.ts +15 -0
  17. package/dist/externals.js +39 -0
  18. package/dist/externals.js.map +1 -0
  19. package/dist/hash.d.ts +69 -0
  20. package/dist/hash.js +162 -0
  21. package/dist/hash.js.map +1 -0
  22. package/dist/helpers.d.ts +21 -0
  23. package/dist/helpers.js +49 -0
  24. package/dist/helpers.js.map +1 -0
  25. package/dist/index.d.ts +40 -0
  26. package/dist/index.js +68 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/internal.d.ts +77 -0
  29. package/dist/internal.js +191 -0
  30. package/dist/internal.js.map +1 -0
  31. package/dist/object.d.ts +12 -0
  32. package/dist/object.js +109 -0
  33. package/dist/object.js.map +1 -0
  34. package/dist/signature.d.ts +55 -0
  35. package/dist/signature.js +163 -0
  36. package/dist/signature.js.map +1 -0
  37. package/dist/types.d.ts +62 -0
  38. package/dist/types.js +77 -0
  39. package/dist/types.js.map +1 -0
  40. package/dist.browser/account.d.ts +120 -0
  41. package/dist.browser/account.js +296 -0
  42. package/dist.browser/account.js.map +1 -0
  43. package/dist.browser/address.d.ts +60 -0
  44. package/dist.browser/address.js +105 -0
  45. package/dist.browser/address.js.map +1 -0
  46. package/dist.browser/bytes.d.ts +140 -0
  47. package/dist.browser/bytes.js +333 -0
  48. package/dist.browser/bytes.js.map +1 -0
  49. package/dist.browser/constants.d.ts +40 -0
  50. package/dist.browser/constants.js +42 -0
  51. package/dist.browser/constants.js.map +1 -0
  52. package/dist.browser/externals.d.ts +15 -0
  53. package/dist.browser/externals.js +39 -0
  54. package/dist.browser/externals.js.map +1 -0
  55. package/dist.browser/hash.d.ts +69 -0
  56. package/dist.browser/hash.js +166 -0
  57. package/dist.browser/hash.js.map +1 -0
  58. package/dist.browser/helpers.d.ts +21 -0
  59. package/dist.browser/helpers.js +49 -0
  60. package/dist.browser/helpers.js.map +1 -0
  61. package/dist.browser/index.d.ts +40 -0
  62. package/dist.browser/index.js +68 -0
  63. package/dist.browser/index.js.map +1 -0
  64. package/dist.browser/internal.d.ts +77 -0
  65. package/dist.browser/internal.js +191 -0
  66. package/dist.browser/internal.js.map +1 -0
  67. package/dist.browser/object.d.ts +12 -0
  68. package/dist.browser/object.js +110 -0
  69. package/dist.browser/object.js.map +1 -0
  70. package/dist.browser/signature.d.ts +55 -0
  71. package/dist.browser/signature.js +164 -0
  72. package/dist.browser/signature.js.map +1 -0
  73. package/dist.browser/types.d.ts +62 -0
  74. package/dist.browser/types.js +77 -0
  75. package/dist.browser/types.js.map +1 -0
  76. package/package.json +105 -0
  77. package/src/account.ts +321 -0
  78. package/src/address.ts +117 -0
  79. package/src/bytes.ts +334 -0
  80. package/src/constants.ts +54 -0
  81. package/src/externals.ts +18 -0
  82. package/src/hash.ts +159 -0
  83. package/src/helpers.ts +45 -0
  84. package/src/index.ts +60 -0
  85. package/src/internal.ts +209 -0
  86. package/src/object.ts +117 -0
  87. package/src/signature.ts +209 -0
  88. package/src/types.ts +146 -0
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rlphash = exports.ripemd160FromArray = exports.ripemd160FromString = exports.ripemd160 = exports.sha256FromArray = exports.sha256FromString = exports.sha256 = exports.keccakFromArray = exports.keccakFromHexString = exports.keccakFromString = exports.keccak256 = exports.keccak = void 0;
4
+ var keccak_1 = require("ethereum-cryptography/keccak");
5
+ var createHash = require('create-hash');
6
+ var externals_1 = require("./externals");
7
+ var bytes_1 = require("./bytes");
8
+ var helpers_1 = require("./helpers");
9
+ /**
10
+ * Creates Keccak hash of a Buffer input
11
+ * @param a The input data (Buffer)
12
+ * @param bits (number = 256) The Keccak width
13
+ */
14
+ var keccak = function (a, bits) {
15
+ if (bits === void 0) { bits = 256; }
16
+ (0, helpers_1.assertIsBuffer)(a);
17
+ switch (bits) {
18
+ case 224: {
19
+ return (0, keccak_1.keccak224)(a);
20
+ }
21
+ case 256: {
22
+ return (0, keccak_1.keccak256)(a);
23
+ }
24
+ case 384: {
25
+ return (0, keccak_1.keccak384)(a);
26
+ }
27
+ case 512: {
28
+ return (0, keccak_1.keccak512)(a);
29
+ }
30
+ default: {
31
+ throw new Error("Invald algorithm: keccak".concat(bits));
32
+ }
33
+ }
34
+ };
35
+ exports.keccak = keccak;
36
+ /**
37
+ * Creates Keccak-256 hash of the input, alias for keccak(a, 256).
38
+ * @param a The input data (Buffer)
39
+ */
40
+ var keccak256 = function (a) {
41
+ return (0, exports.keccak)(a);
42
+ };
43
+ exports.keccak256 = keccak256;
44
+ /**
45
+ * Creates Keccak hash of a utf-8 string input
46
+ * @param a The input data (String)
47
+ * @param bits (number = 256) The Keccak width
48
+ */
49
+ var keccakFromString = function (a, bits) {
50
+ if (bits === void 0) { bits = 256; }
51
+ (0, helpers_1.assertIsString)(a);
52
+ var buf = Buffer.from(a, 'utf8');
53
+ return (0, exports.keccak)(buf, bits);
54
+ };
55
+ exports.keccakFromString = keccakFromString;
56
+ /**
57
+ * Creates Keccak hash of an 0x-prefixed string input
58
+ * @param a The input data (String)
59
+ * @param bits (number = 256) The Keccak width
60
+ */
61
+ var keccakFromHexString = function (a, bits) {
62
+ if (bits === void 0) { bits = 256; }
63
+ (0, helpers_1.assertIsHexString)(a);
64
+ return (0, exports.keccak)((0, bytes_1.toBuffer)(a), bits);
65
+ };
66
+ exports.keccakFromHexString = keccakFromHexString;
67
+ /**
68
+ * Creates Keccak hash of a number array input
69
+ * @param a The input data (number[])
70
+ * @param bits (number = 256) The Keccak width
71
+ */
72
+ var keccakFromArray = function (a, bits) {
73
+ if (bits === void 0) { bits = 256; }
74
+ (0, helpers_1.assertIsArray)(a);
75
+ return (0, exports.keccak)((0, bytes_1.toBuffer)(a), bits);
76
+ };
77
+ exports.keccakFromArray = keccakFromArray;
78
+ /**
79
+ * Creates SHA256 hash of an input.
80
+ * @param a The input data (Buffer|Array|String)
81
+ */
82
+ var _sha256 = function (a) {
83
+ a = (0, bytes_1.toBuffer)(a);
84
+ return createHash('sha256').update(a).digest();
85
+ };
86
+ /**
87
+ * Creates SHA256 hash of a Buffer input.
88
+ * @param a The input data (Buffer)
89
+ */
90
+ var sha256 = function (a) {
91
+ (0, helpers_1.assertIsBuffer)(a);
92
+ return _sha256(a);
93
+ };
94
+ exports.sha256 = sha256;
95
+ /**
96
+ * Creates SHA256 hash of a string input.
97
+ * @param a The input data (string)
98
+ */
99
+ var sha256FromString = function (a) {
100
+ (0, helpers_1.assertIsString)(a);
101
+ return _sha256(a);
102
+ };
103
+ exports.sha256FromString = sha256FromString;
104
+ /**
105
+ * Creates SHA256 hash of a number[] input.
106
+ * @param a The input data (number[])
107
+ */
108
+ var sha256FromArray = function (a) {
109
+ (0, helpers_1.assertIsArray)(a);
110
+ return _sha256(a);
111
+ };
112
+ exports.sha256FromArray = sha256FromArray;
113
+ /**
114
+ * Creates RIPEMD160 hash of the input.
115
+ * @param a The input data (Buffer|Array|String|Number)
116
+ * @param padded Whether it should be padded to 256 bits or not
117
+ */
118
+ var _ripemd160 = function (a, padded) {
119
+ a = (0, bytes_1.toBuffer)(a);
120
+ var hash = createHash('rmd160').update(a).digest();
121
+ if (padded === true) {
122
+ return (0, bytes_1.setLengthLeft)(hash, 32);
123
+ }
124
+ else {
125
+ return hash;
126
+ }
127
+ };
128
+ /**
129
+ * Creates RIPEMD160 hash of a Buffer input.
130
+ * @param a The input data (Buffer)
131
+ * @param padded Whether it should be padded to 256 bits or not
132
+ */
133
+ var ripemd160 = function (a, padded) {
134
+ (0, helpers_1.assertIsBuffer)(a);
135
+ return _ripemd160(a, padded);
136
+ };
137
+ exports.ripemd160 = ripemd160;
138
+ /**
139
+ * Creates RIPEMD160 hash of a string input.
140
+ * @param a The input data (String)
141
+ * @param padded Whether it should be padded to 256 bits or not
142
+ */
143
+ var ripemd160FromString = function (a, padded) {
144
+ (0, helpers_1.assertIsString)(a);
145
+ return _ripemd160(a, padded);
146
+ };
147
+ exports.ripemd160FromString = ripemd160FromString;
148
+ /**
149
+ * Creates RIPEMD160 hash of a number[] input.
150
+ * @param a The input data (number[])
151
+ * @param padded Whether it should be padded to 256 bits or not
152
+ */
153
+ var ripemd160FromArray = function (a, padded) {
154
+ (0, helpers_1.assertIsArray)(a);
155
+ return _ripemd160(a, padded);
156
+ };
157
+ exports.ripemd160FromArray = ripemd160FromArray;
158
+ /**
159
+ * Creates SHA-3 hash of the RLP encoded version of the input.
160
+ * @param a The input data
161
+ */
162
+ var rlphash = function (a) {
163
+ return (0, exports.keccak)(externals_1.rlp.encode(a));
164
+ };
165
+ exports.rlphash = rlphash;
166
+ //# sourceMappingURL=hash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.js","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":";;;AAAA,uDAAiG;AACjG,IAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AACzC,yCAAiC;AACjC,iCAAiD;AACjD,qCAA4F;AAE5F;;;;GAIG;AACI,IAAM,MAAM,GAAG,UAAU,CAAS,EAAE,IAAkB;IAAlB,qBAAA,EAAA,UAAkB;IAC3D,IAAA,wBAAc,EAAC,CAAC,CAAC,CAAA;IACjB,QAAQ,IAAI,EAAE;QACZ,KAAK,GAAG,CAAC,CAAC;YACR,OAAO,IAAA,kBAAS,EAAC,CAAC,CAAC,CAAA;SACpB;QACD,KAAK,GAAG,CAAC,CAAC;YACR,OAAO,IAAA,kBAAI,EAA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;GAIG;AACI,IAAM,SAAS,GAAG,UAAU,CAAS,EAAE,MAAe;IAC3D,IAAA,wBAAc,EAAC,CAAC,CAAC,CAAA;IACjB,OAAO,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;AAC9B,CAAC,CAAA;AAHY,QAAA,SAAS,aAGrB;AAED;;;;GAIG;AACI,IAAM,mBAAmB,GAAG,UAAU,CAAS,EAAE,MAAe;IACrE,IAAA,wBAAc,EAAC,CAAC,CAAC,CAAA;IACjB,OAAO,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;AAC9B,CAAC,CAAA;AAHY,QAAA,mBAAmB,uBAG/B;AAED;;;;GAIG;AACI,IAAM,kBAAkB,GAAG,UAAU,CAAW,EAAE,MAAe;IACtE,IAAA,uBAAa,EAAC,CAAC,CAAC,CAAA;IAChB,OAAO,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;AAC9B,CAAC,CAAA;AAHY,QAAA,kBAAkB,sBAG9B;AAED;;;GAGG;AACI,IAAM,OAAO,GAAG,UAAU,CAAY;IAC3C,OAAO,IAAA,cAAM,EAAC,eAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9B,CAAC,CAAA;AAFY,QAAA,OAAO,WAEnB"}
@@ -0,0 +1,21 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * Throws if a string is not hex prefixed
4
+ * @param {string} input string to check hex prefix of
5
+ */
6
+ export declare const assertIsHexString: (input: string) => void;
7
+ /**
8
+ * Throws if input is not a buffer
9
+ * @param {Buffer} input value to check
10
+ */
11
+ export declare const assertIsBuffer: (input: Buffer) => void;
12
+ /**
13
+ * Throws if input is not an array
14
+ * @param {number[]} input value to check
15
+ */
16
+ export declare const assertIsArray: (input: number[]) => void;
17
+ /**
18
+ * Throws if input is not a string
19
+ * @param {string} input value to check
20
+ */
21
+ export declare const assertIsString: (input: string) => void;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertIsString = exports.assertIsArray = exports.assertIsBuffer = exports.assertIsHexString = void 0;
4
+ var internal_1 = require("./internal");
5
+ /**
6
+ * Throws if a string is not hex prefixed
7
+ * @param {string} input string to check hex prefix of
8
+ */
9
+ var assertIsHexString = function (input) {
10
+ if (!(0, internal_1.isHexString)(input)) {
11
+ var msg = "This method only supports 0x-prefixed hex strings but input was: ".concat(input);
12
+ throw new Error(msg);
13
+ }
14
+ };
15
+ exports.assertIsHexString = assertIsHexString;
16
+ /**
17
+ * Throws if input is not a buffer
18
+ * @param {Buffer} input value to check
19
+ */
20
+ var assertIsBuffer = function (input) {
21
+ if (!Buffer.isBuffer(input)) {
22
+ var msg = "This method only supports Buffer but input was: ".concat(input);
23
+ throw new Error(msg);
24
+ }
25
+ };
26
+ exports.assertIsBuffer = assertIsBuffer;
27
+ /**
28
+ * Throws if input is not an array
29
+ * @param {number[]} input value to check
30
+ */
31
+ var assertIsArray = function (input) {
32
+ if (!Array.isArray(input)) {
33
+ var msg = "This method only supports number arrays but input was: ".concat(input);
34
+ throw new Error(msg);
35
+ }
36
+ };
37
+ exports.assertIsArray = assertIsArray;
38
+ /**
39
+ * Throws if input is not a string
40
+ * @param {string} input value to check
41
+ */
42
+ var assertIsString = function (input) {
43
+ if (typeof input !== 'string') {
44
+ var msg = "This method only supports strings but input was: ".concat(input);
45
+ throw new Error(msg);
46
+ }
47
+ };
48
+ exports.assertIsString = assertIsString;
49
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;AAAA,uCAAwC;AAExC;;;GAGG;AACI,IAAM,iBAAiB,GAAG,UAAU,KAAa;IACtD,IAAI,CAAC,IAAA,sBAAW,EAAC,KAAK,CAAC,EAAE;QACvB,IAAM,GAAG,GAAG,2EAAoE,KAAK,CAAE,CAAA;QACvF,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;KACrB;AACH,CAAC,CAAA;AALY,QAAA,iBAAiB,qBAK7B;AAED;;;GAGG;AACI,IAAM,cAAc,GAAG,UAAU,KAAa;IACnD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC3B,IAAM,GAAG,GAAG,0DAAmD,KAAK,CAAE,CAAA;QACtE,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;KACrB;AACH,CAAC,CAAA;AALY,QAAA,cAAc,kBAK1B;AAED;;;GAGG;AACI,IAAM,aAAa,GAAG,UAAU,KAAe;IACpD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACzB,IAAM,GAAG,GAAG,iEAA0D,KAAK,CAAE,CAAA;QAC7E,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;KACrB;AACH,CAAC,CAAA;AALY,QAAA,aAAa,iBAKzB;AAED;;;GAGG;AACI,IAAM,cAAc,GAAG,UAAU,KAAa;IACnD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,IAAM,GAAG,GAAG,2DAAoD,KAAK,CAAE,CAAA;QACvE,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;KACrB;AACH,CAAC,CAAA;AALY,QAAA,cAAc,kBAK1B"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Constants
3
+ */
4
+ export * from './constants';
5
+ /**
6
+ * Account class and helper functions
7
+ */
8
+ export * from './account';
9
+ /**
10
+ * Address type
11
+ */
12
+ export * from './address';
13
+ /**
14
+ * Hash functions
15
+ */
16
+ export * from './hash';
17
+ /**
18
+ * ECDSA signature
19
+ */
20
+ export * from './signature';
21
+ /**
22
+ * Utilities for manipulating Buffers, byte arrays, etc.
23
+ */
24
+ export * from './bytes';
25
+ /**
26
+ * Function for definining properties on an object
27
+ */
28
+ export * from './object';
29
+ /**
30
+ * External exports (BN, rlp)
31
+ */
32
+ export * from './externals';
33
+ /**
34
+ * Helpful TypeScript types
35
+ */
36
+ export * from './types';
37
+ /**
38
+ * Export ethjs-util methods
39
+ */
40
+ export { isHexPrefixed, stripHexPrefix, padToEven, getBinarySize, arrayContainsArray, toAscii, fromUtf8, fromAscii, getKeys, isHexString, } from './internal';
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.isHexString = exports.getKeys = exports.fromAscii = exports.fromUtf8 = exports.toAscii = exports.arrayContainsArray = exports.getBinarySize = exports.padToEven = exports.stripHexPrefix = exports.isHexPrefixed = void 0;
18
+ /**
19
+ * Constants
20
+ */
21
+ __exportStar(require("./constants"), exports);
22
+ /**
23
+ * Account class and helper functions
24
+ */
25
+ __exportStar(require("./account"), exports);
26
+ /**
27
+ * Address type
28
+ */
29
+ __exportStar(require("./address"), exports);
30
+ /**
31
+ * Hash functions
32
+ */
33
+ __exportStar(require("./hash"), exports);
34
+ /**
35
+ * ECDSA signature
36
+ */
37
+ __exportStar(require("./signature"), exports);
38
+ /**
39
+ * Utilities for manipulating Buffers, byte arrays, etc.
40
+ */
41
+ __exportStar(require("./bytes"), exports);
42
+ /**
43
+ * Function for definining properties on an object
44
+ */
45
+ __exportStar(require("./object"), exports);
46
+ /**
47
+ * External exports (BN, rlp)
48
+ */
49
+ __exportStar(require("./externals"), exports);
50
+ /**
51
+ * Helpful TypeScript types
52
+ */
53
+ __exportStar(require("./types"), exports);
54
+ /**
55
+ * Export ethjs-util methods
56
+ */
57
+ var internal_1 = require("./internal");
58
+ Object.defineProperty(exports, "isHexPrefixed", { enumerable: true, get: function () { return internal_1.isHexPrefixed; } });
59
+ Object.defineProperty(exports, "stripHexPrefix", { enumerable: true, get: function () { return internal_1.stripHexPrefix; } });
60
+ Object.defineProperty(exports, "padToEven", { enumerable: true, get: function () { return internal_1.padToEven; } });
61
+ Object.defineProperty(exports, "getBinarySize", { enumerable: true, get: function () { return internal_1.getBinarySize; } });
62
+ Object.defineProperty(exports, "arrayContainsArray", { enumerable: true, get: function () { return internal_1.arrayContainsArray; } });
63
+ Object.defineProperty(exports, "toAscii", { enumerable: true, get: function () { return internal_1.toAscii; } });
64
+ Object.defineProperty(exports, "fromUtf8", { enumerable: true, get: function () { return internal_1.fromUtf8; } });
65
+ Object.defineProperty(exports, "fromAscii", { enumerable: true, get: function () { return internal_1.fromAscii; } });
66
+ Object.defineProperty(exports, "getKeys", { enumerable: true, get: function () { return internal_1.getKeys; } });
67
+ Object.defineProperty(exports, "isHexString", { enumerable: true, get: function () { return internal_1.isHexString; } });
68
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,8CAA2B;AAE3B;;GAEG;AACH,4CAAyB;AAEzB;;GAEG;AACH,4CAAyB;AAEzB;;GAEG;AACH,yCAAsB;AAEtB;;GAEG;AACH,8CAA2B;AAE3B;;GAEG;AACH,0CAAuB;AAEvB;;GAEG;AACH,2CAAwB;AAExB;;GAEG;AACH,8CAA2B;AAE3B;;GAEG;AACH,0CAAuB;AAEvB;;GAEG;AACH,uCAWmB;AAVjB,yGAAA,aAAa,OAAA;AACb,0GAAA,cAAc,OAAA;AACd,qGAAA,SAAS,OAAA;AACT,yGAAA,aAAa,OAAA;AACb,8GAAA,kBAAkB,OAAA;AAClB,mGAAA,OAAO,OAAA;AACP,oGAAA,QAAQ,OAAA;AACR,qGAAA,SAAS,OAAA;AACT,mGAAA,OAAO,OAAA;AACP,uGAAA,WAAW,OAAA"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Returns a `Boolean` on whether or not the a `String` starts with '0x'
3
+ * @param str the string input value
4
+ * @return a boolean if it is or is not hex prefixed
5
+ * @throws if the str input is not a string
6
+ */
7
+ export declare function isHexPrefixed(str: string): boolean;
8
+ /**
9
+ * Removes '0x' from a given `String` if present
10
+ * @param str the string value
11
+ * @returns the string without 0x prefix
12
+ */
13
+ export declare const stripHexPrefix: (str: string) => string;
14
+ /**
15
+ * Pads a `String` to have an even length
16
+ * @param value
17
+ * @return output
18
+ */
19
+ export declare function padToEven(value: string): string;
20
+ /**
21
+ * Get the binary size of a string
22
+ * @param str
23
+ * @returns the number of bytes contained within the string
24
+ */
25
+ export declare function getBinarySize(str: string): number;
26
+ /**
27
+ * Returns TRUE if the first specified array contains all elements
28
+ * from the second one. FALSE otherwise.
29
+ *
30
+ * @param superset
31
+ * @param subset
32
+ *
33
+ */
34
+ export declare function arrayContainsArray(superset: unknown[], subset: unknown[], some?: boolean): boolean;
35
+ /**
36
+ * Should be called to get ascii from its hex representation
37
+ *
38
+ * @param string in hex
39
+ * @returns ascii string representation of hex value
40
+ */
41
+ export declare function toAscii(hex: string): string;
42
+ /**
43
+ * Should be called to get hex representation (prefixed by 0x) of utf8 string
44
+ *
45
+ * @param string
46
+ * @param optional padding
47
+ * @returns hex representation of input string
48
+ */
49
+ export declare function fromUtf8(stringValue: string): string;
50
+ /**
51
+ * Should be called to get hex representation (prefixed by 0x) of ascii string
52
+ *
53
+ * @param string
54
+ * @param optional padding
55
+ * @returns hex representation of input string
56
+ */
57
+ export declare function fromAscii(stringValue: string): string;
58
+ /**
59
+ * Returns the keys from an array of objects.
60
+ * @example
61
+ * ```js
62
+ * getKeys([{a: '1', b: '2'}, {a: '3', b: '4'}], 'a') => ['1', '3']
63
+ *````
64
+ * @param params
65
+ * @param key
66
+ * @param allowEmpty
67
+ * @returns output just a simple array of output keys
68
+ */
69
+ export declare function getKeys(params: Record<string, string>[], key: string, allowEmpty?: boolean): string[];
70
+ /**
71
+ * Is the string a hex string.
72
+ *
73
+ * @param value
74
+ * @param length
75
+ * @returns output the string is a hex string
76
+ */
77
+ export declare function isHexString(value: string, length?: number): boolean;
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ /*
3
+ The MIT License
4
+
5
+ Copyright (c) 2016 Nick Dodson. nickdodson.com
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE
24
+ */
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.isHexString = exports.getKeys = exports.fromAscii = exports.fromUtf8 = exports.toAscii = exports.arrayContainsArray = exports.getBinarySize = exports.padToEven = exports.stripHexPrefix = exports.isHexPrefixed = void 0;
27
+ /**
28
+ * Returns a `Boolean` on whether or not the a `String` starts with '0x'
29
+ * @param str the string input value
30
+ * @return a boolean if it is or is not hex prefixed
31
+ * @throws if the str input is not a string
32
+ */
33
+ function isHexPrefixed(str) {
34
+ if (typeof str !== 'string') {
35
+ throw new Error("[isHexPrefixed] input must be type 'string', received type ".concat(typeof str));
36
+ }
37
+ return str[0] === '0' && str[1] === 'x';
38
+ }
39
+ exports.isHexPrefixed = isHexPrefixed;
40
+ /**
41
+ * Removes '0x' from a given `String` if present
42
+ * @param str the string value
43
+ * @returns the string without 0x prefix
44
+ */
45
+ var stripHexPrefix = function (str) {
46
+ if (typeof str !== 'string')
47
+ throw new Error("[stripHexPrefix] input must be type 'string', received ".concat(typeof str));
48
+ return isHexPrefixed(str) ? str.slice(2) : str;
49
+ };
50
+ exports.stripHexPrefix = stripHexPrefix;
51
+ /**
52
+ * Pads a `String` to have an even length
53
+ * @param value
54
+ * @return output
55
+ */
56
+ function padToEven(value) {
57
+ var a = value;
58
+ if (typeof a !== 'string') {
59
+ throw new Error("[padToEven] value must be type 'string', received ".concat(typeof a));
60
+ }
61
+ if (a.length % 2)
62
+ a = "0".concat(a);
63
+ return a;
64
+ }
65
+ exports.padToEven = padToEven;
66
+ /**
67
+ * Get the binary size of a string
68
+ * @param str
69
+ * @returns the number of bytes contained within the string
70
+ */
71
+ function getBinarySize(str) {
72
+ if (typeof str !== 'string') {
73
+ throw new Error("[getBinarySize] method requires input type 'string', recieved ".concat(typeof str));
74
+ }
75
+ return Buffer.byteLength(str, 'utf8');
76
+ }
77
+ exports.getBinarySize = getBinarySize;
78
+ /**
79
+ * Returns TRUE if the first specified array contains all elements
80
+ * from the second one. FALSE otherwise.
81
+ *
82
+ * @param superset
83
+ * @param subset
84
+ *
85
+ */
86
+ function arrayContainsArray(superset, subset, some) {
87
+ if (Array.isArray(superset) !== true) {
88
+ throw new Error("[arrayContainsArray] method requires input 'superset' to be an array, got type '".concat(typeof superset, "'"));
89
+ }
90
+ if (Array.isArray(subset) !== true) {
91
+ throw new Error("[arrayContainsArray] method requires input 'subset' to be an array, got type '".concat(typeof subset, "'"));
92
+ }
93
+ return subset[some ? 'some' : 'every'](function (value) { return superset.indexOf(value) >= 0; });
94
+ }
95
+ exports.arrayContainsArray = arrayContainsArray;
96
+ /**
97
+ * Should be called to get ascii from its hex representation
98
+ *
99
+ * @param string in hex
100
+ * @returns ascii string representation of hex value
101
+ */
102
+ function toAscii(hex) {
103
+ var str = '';
104
+ var i = 0;
105
+ var l = hex.length;
106
+ if (hex.substring(0, 2) === '0x')
107
+ i = 2;
108
+ for (; i < l; i += 2) {
109
+ var code = parseInt(hex.substr(i, 2), 16);
110
+ str += String.fromCharCode(code);
111
+ }
112
+ return str;
113
+ }
114
+ exports.toAscii = toAscii;
115
+ /**
116
+ * Should be called to get hex representation (prefixed by 0x) of utf8 string
117
+ *
118
+ * @param string
119
+ * @param optional padding
120
+ * @returns hex representation of input string
121
+ */
122
+ function fromUtf8(stringValue) {
123
+ var str = Buffer.from(stringValue, 'utf8');
124
+ return "0x".concat(padToEven(str.toString('hex')).replace(/^0+|0+$/g, ''));
125
+ }
126
+ exports.fromUtf8 = fromUtf8;
127
+ /**
128
+ * Should be called to get hex representation (prefixed by 0x) of ascii string
129
+ *
130
+ * @param string
131
+ * @param optional padding
132
+ * @returns hex representation of input string
133
+ */
134
+ function fromAscii(stringValue) {
135
+ var hex = '';
136
+ for (var i = 0; i < stringValue.length; i++) {
137
+ var code = stringValue.charCodeAt(i);
138
+ var n = code.toString(16);
139
+ hex += n.length < 2 ? "0".concat(n) : n;
140
+ }
141
+ return "0x".concat(hex);
142
+ }
143
+ exports.fromAscii = fromAscii;
144
+ /**
145
+ * Returns the keys from an array of objects.
146
+ * @example
147
+ * ```js
148
+ * getKeys([{a: '1', b: '2'}, {a: '3', b: '4'}], 'a') => ['1', '3']
149
+ *````
150
+ * @param params
151
+ * @param key
152
+ * @param allowEmpty
153
+ * @returns output just a simple array of output keys
154
+ */
155
+ function getKeys(params, key, allowEmpty) {
156
+ if (!Array.isArray(params)) {
157
+ throw new Error("[getKeys] method expects input 'params' to be an array, got ".concat(typeof params));
158
+ }
159
+ if (typeof key !== 'string') {
160
+ throw new Error("[getKeys] method expects input 'key' to be type 'string', got ".concat(typeof params));
161
+ }
162
+ var result = [];
163
+ for (var i = 0; i < params.length; i++) {
164
+ var value = params[i][key];
165
+ if (allowEmpty && !value) {
166
+ value = '';
167
+ }
168
+ else if (typeof value !== 'string') {
169
+ throw new Error("invalid abi - expected type 'string', received ".concat(typeof value));
170
+ }
171
+ result.push(value);
172
+ }
173
+ return result;
174
+ }
175
+ exports.getKeys = getKeys;
176
+ /**
177
+ * Is the string a hex string.
178
+ *
179
+ * @param value
180
+ * @param length
181
+ * @returns output the string is a hex string
182
+ */
183
+ function isHexString(value, length) {
184
+ if (typeof value !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/))
185
+ return false;
186
+ if (length && value.length !== 2 + 2 * length)
187
+ return false;
188
+ return true;
189
+ }
190
+ exports.isHexString = isHexString;
191
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAEH;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,GAAW;IACvC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,qEAA8D,OAAO,GAAG,CAAE,CAAC,CAAA;KAC5F;IAED,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,CAAA;AACzC,CAAC;AAND,sCAMC;AAED;;;;GAIG;AACI,IAAM,cAAc,GAAG,UAAC,GAAW;IACxC,IAAI,OAAO,GAAG,KAAK,QAAQ;QACzB,MAAM,IAAI,KAAK,CAAC,iEAA0D,OAAO,GAAG,CAAE,CAA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,CAAC,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM;QAAE,OAAO,KAAK,CAAA;IAE3D,OAAO,IAAI,CAAA;AACb,CAAC;AAND,kCAMC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Defines properties on a `Object`. It make the assumption that underlying data is binary.
3
+ * @param self the `Object` to define properties on
4
+ * @param fields an array fields to define. Fields can contain:
5
+ * * `name` - the name of the properties
6
+ * * `length` - the number of bytes the field can have
7
+ * * `allowLess` - if the field can be less than the length
8
+ * * `allowEmpty`
9
+ * @param data data to be validated against the definitions
10
+ * @deprecated
11
+ */
12
+ export declare const defineProperties: (self: any, fields: any, data?: any) => void;