essential-eth 0.10.3 → 0.10.4-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2024 -0
- package/dist/index.d.cts +330 -0
- package/dist/index.d.ts +330 -0
- package/dist/index.js +1952 -0
- package/package.json +13 -14
- package/dist/cjs/classes/Contract.d.ts +0 -81
- package/dist/cjs/classes/Contract.js +0 -139
- package/dist/cjs/classes/test/Contract/crv-abi.d.ts +0 -2
- package/dist/cjs/classes/test/Contract/crv-abi.js +0 -413
- package/dist/cjs/classes/test/Contract/ens-abi.d.ts +0 -2
- package/dist/cjs/classes/test/Contract/ens-abi.js +0 -453
- package/dist/cjs/classes/test/Contract/fei-abi.d.ts +0 -2
- package/dist/cjs/classes/test/Contract/fei-abi.js +0 -526
- package/dist/cjs/classes/test/Contract/foo-abi.d.ts +0 -2
- package/dist/cjs/classes/test/Contract/foo-abi.js +0 -42
- package/dist/cjs/classes/test/Contract/jokerrace-abi.d.ts +0 -2
- package/dist/cjs/classes/test/Contract/jokerrace-abi.js +0 -22
- package/dist/cjs/classes/test/Contract/uniswap-abi.d.ts +0 -2
- package/dist/cjs/classes/test/Contract/uniswap-abi.js +0 -121
- package/dist/cjs/classes/utils/clean-block.d.ts +0 -120
- package/dist/cjs/classes/utils/clean-block.js +0 -160
- package/dist/cjs/classes/utils/clean-log.d.ts +0 -9
- package/dist/cjs/classes/utils/clean-log.js +0 -39
- package/dist/cjs/classes/utils/clean-transaction-receipt.d.ts +0 -14
- package/dist/cjs/classes/utils/clean-transaction-receipt.js +0 -53
- package/dist/cjs/classes/utils/clean-transaction.d.ts +0 -14
- package/dist/cjs/classes/utils/clean-transaction.js +0 -54
- package/dist/cjs/classes/utils/encode-decode-transaction.d.ts +0 -16
- package/dist/cjs/classes/utils/encode-decode-transaction.js +0 -185
- package/dist/cjs/classes/utils/fetchers.d.ts +0 -53
- package/dist/cjs/classes/utils/fetchers.js +0 -85
- package/dist/cjs/classes/utils/hex-to-decimal.d.ts +0 -18
- package/dist/cjs/classes/utils/hex-to-decimal.js +0 -24
- package/dist/cjs/classes/utils/prepare-transaction.d.ts +0 -6
- package/dist/cjs/classes/utils/prepare-transaction.js +0 -47
- package/dist/cjs/index.d.ts +0 -24
- package/dist/cjs/index.js +0 -58
- package/dist/cjs/index.umd.js +0 -2
- package/dist/cjs/index.umd.js.map +0 -1
- package/dist/cjs/logger/logger.d.ts +0 -11
- package/dist/cjs/logger/logger.js +0 -37
- package/dist/cjs/logger/package-version.d.ts +0 -1
- package/dist/cjs/logger/package-version.js +0 -5
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/providers/AlchemyProvider.d.ts +0 -4
- package/dist/cjs/providers/AlchemyProvider.js +0 -11
- package/dist/cjs/providers/BaseProvider.d.ts +0 -374
- package/dist/cjs/providers/BaseProvider.js +0 -514
- package/dist/cjs/providers/FallthroughProvider.d.ts +0 -24
- package/dist/cjs/providers/FallthroughProvider.js +0 -74
- package/dist/cjs/providers/JsonRpcProvider.d.ts +0 -33
- package/dist/cjs/providers/JsonRpcProvider.js +0 -46
- package/dist/cjs/providers/test/json-rpc-provider/get-logs/mocks.d.ts +0 -14
- package/dist/cjs/providers/test/json-rpc-provider/get-logs/mocks.js +0 -152
- package/dist/cjs/providers/test/mock-of.d.ts +0 -8
- package/dist/cjs/providers/test/mock-of.js +0 -12
- package/dist/cjs/providers/test/rpc-urls.d.ts +0 -12
- package/dist/cjs/providers/test/rpc-urls.js +0 -27
- package/dist/cjs/providers/utils/chains-info.d.ts +0 -24
- package/dist/cjs/providers/utils/chains-info.js +0 -71
- package/dist/cjs/shared/tiny-big/helpers.d.ts +0 -17
- package/dist/cjs/shared/tiny-big/helpers.js +0 -97
- package/dist/cjs/shared/tiny-big/tiny-big.d.ts +0 -58
- package/dist/cjs/shared/tiny-big/tiny-big.js +0 -101
- package/dist/cjs/shared/validate-type.d.ts +0 -3
- package/dist/cjs/shared/validate-type.js +0 -9
- package/dist/cjs/types/Block.types.d.ts +0 -41
- package/dist/cjs/types/Block.types.js +0 -2
- package/dist/cjs/types/Contract.types.d.ts +0 -24
- package/dist/cjs/types/Contract.types.js +0 -2
- package/dist/cjs/types/FeeData.types.d.ts +0 -7
- package/dist/cjs/types/FeeData.types.js +0 -2
- package/dist/cjs/types/Filter.types.d.ts +0 -16
- package/dist/cjs/types/Filter.types.js +0 -2
- package/dist/cjs/types/Network.types.d.ts +0 -8
- package/dist/cjs/types/Network.types.js +0 -2
- package/dist/cjs/types/Transaction.types.d.ts +0 -123
- package/dist/cjs/types/Transaction.types.js +0 -2
- package/dist/cjs/utils/bytes.d.ts +0 -289
- package/dist/cjs/utils/bytes.js +0 -711
- package/dist/cjs/utils/compute-address.d.ts +0 -17
- package/dist/cjs/utils/compute-address.js +0 -34
- package/dist/cjs/utils/compute-public-key.d.ts +0 -18
- package/dist/cjs/utils/compute-public-key.js +0 -26
- package/dist/cjs/utils/ether-to-gwei.d.ts +0 -27
- package/dist/cjs/utils/ether-to-gwei.js +0 -35
- package/dist/cjs/utils/ether-to-wei.d.ts +0 -27
- package/dist/cjs/utils/ether-to-wei.js +0 -35
- package/dist/cjs/utils/gwei-to-ether.d.ts +0 -27
- package/dist/cjs/utils/gwei-to-ether.js +0 -35
- package/dist/cjs/utils/hash-message.d.ts +0 -14
- package/dist/cjs/utils/hash-message.js +0 -30
- package/dist/cjs/utils/is-address.d.ts +0 -24
- package/dist/cjs/utils/is-address.js +0 -39
- package/dist/cjs/utils/keccak256.d.ts +0 -16
- package/dist/cjs/utils/keccak256.js +0 -31
- package/dist/cjs/utils/solidity-keccak256.d.ts +0 -39
- package/dist/cjs/utils/solidity-keccak256.js +0 -138
- package/dist/cjs/utils/split-signature.d.ts +0 -24
- package/dist/cjs/utils/split-signature.js +0 -163
- package/dist/cjs/utils/to-checksum-address.d.ts +0 -17
- package/dist/cjs/utils/to-checksum-address.js +0 -46
- package/dist/cjs/utils/to-utf8-bytes.d.ts +0 -15
- package/dist/cjs/utils/to-utf8-bytes.js +0 -21
- package/dist/cjs/utils/wei-to-ether.d.ts +0 -27
- package/dist/cjs/utils/wei-to-ether.js +0 -45
- package/dist/esm/classes/Contract.d.ts +0 -11
- package/dist/esm/classes/Contract.js +0 -58
- package/dist/esm/classes/test/Contract/crv-abi.d.ts +0 -2
- package/dist/esm/classes/test/Contract/crv-abi.js +0 -395
- package/dist/esm/classes/test/Contract/ens-abi.d.ts +0 -2
- package/dist/esm/classes/test/Contract/ens-abi.js +0 -435
- package/dist/esm/classes/test/Contract/fei-abi.d.ts +0 -2
- package/dist/esm/classes/test/Contract/fei-abi.js +0 -521
- package/dist/esm/classes/test/Contract/foo-abi.d.ts +0 -2
- package/dist/esm/classes/test/Contract/foo-abi.js +0 -33
- package/dist/esm/classes/test/Contract/jokerrace-abi.d.ts +0 -2
- package/dist/esm/classes/test/Contract/jokerrace-abi.js +0 -18
- package/dist/esm/classes/test/Contract/uniswap-abi.d.ts +0 -2
- package/dist/esm/classes/test/Contract/uniswap-abi.js +0 -116
- package/dist/esm/classes/utils/clean-block.d.ts +0 -2
- package/dist/esm/classes/utils/clean-block.js +0 -35
- package/dist/esm/classes/utils/clean-log.d.ts +0 -2
- package/dist/esm/classes/utils/clean-log.js +0 -28
- package/dist/esm/classes/utils/clean-transaction-receipt.d.ts +0 -2
- package/dist/esm/classes/utils/clean-transaction-receipt.js +0 -37
- package/dist/esm/classes/utils/clean-transaction.d.ts +0 -2
- package/dist/esm/classes/utils/clean-transaction.js +0 -36
- package/dist/esm/classes/utils/encode-decode-transaction.d.ts +0 -4
- package/dist/esm/classes/utils/encode-decode-transaction.js +0 -143
- package/dist/esm/classes/utils/fetchers.d.ts +0 -15
- package/dist/esm/classes/utils/fetchers.js +0 -37
- package/dist/esm/classes/utils/hex-to-decimal.d.ts +0 -1
- package/dist/esm/classes/utils/hex-to-decimal.js +0 -3
- package/dist/esm/classes/utils/prepare-transaction.d.ts +0 -2
- package/dist/esm/classes/utils/prepare-transaction.js +0 -36
- package/dist/esm/index.d.ts +0 -24
- package/dist/esm/index.js +0 -19
- package/dist/esm/logger/logger.d.ts +0 -11
- package/dist/esm/logger/logger.js +0 -34
- package/dist/esm/logger/package-version.d.ts +0 -1
- package/dist/esm/logger/package-version.js +0 -1
- package/dist/esm/providers/AlchemyProvider.d.ts +0 -4
- package/dist/esm/providers/AlchemyProvider.js +0 -7
- package/dist/esm/providers/BaseProvider.d.ts +0 -26
- package/dist/esm/providers/BaseProvider.js +0 -137
- package/dist/esm/providers/FallthroughProvider.d.ts +0 -11
- package/dist/esm/providers/FallthroughProvider.js +0 -50
- package/dist/esm/providers/JsonRpcProvider.d.ts +0 -7
- package/dist/esm/providers/JsonRpcProvider.js +0 -15
- package/dist/esm/providers/test/json-rpc-provider/get-logs/mocks.d.ts +0 -14
- package/dist/esm/providers/test/json-rpc-provider/get-logs/mocks.js +0 -142
- package/dist/esm/providers/test/mock-of.d.ts +0 -1
- package/dist/esm/providers/test/mock-of.js +0 -1
- package/dist/esm/providers/test/rpc-urls.d.ts +0 -12
- package/dist/esm/providers/test/rpc-urls.js +0 -21
- package/dist/esm/providers/utils/chains-info.d.ts +0 -24
- package/dist/esm/providers/utils/chains-info.js +0 -67
- package/dist/esm/shared/tiny-big/helpers.d.ts +0 -1
- package/dist/esm/shared/tiny-big/helpers.js +0 -58
- package/dist/esm/shared/tiny-big/tiny-big.d.ts +0 -10
- package/dist/esm/shared/tiny-big/tiny-big.js +0 -45
- package/dist/esm/shared/validate-type.d.ts +0 -3
- package/dist/esm/shared/validate-type.js +0 -5
- package/dist/esm/types/Block.types.d.ts +0 -40
- package/dist/esm/types/Block.types.js +0 -1
- package/dist/esm/types/Contract.types.d.ts +0 -24
- package/dist/esm/types/Contract.types.js +0 -1
- package/dist/esm/types/FeeData.types.d.ts +0 -7
- package/dist/esm/types/FeeData.types.js +0 -1
- package/dist/esm/types/Filter.types.d.ts +0 -12
- package/dist/esm/types/Filter.types.js +0 -1
- package/dist/esm/types/Network.types.d.ts +0 -5
- package/dist/esm/types/Network.types.js +0 -1
- package/dist/esm/types/Transaction.types.d.ts +0 -113
- package/dist/esm/types/Transaction.types.js +0 -1
- package/dist/esm/utils/bytes.d.ts +0 -40
- package/dist/esm/utils/bytes.js +0 -245
- package/dist/esm/utils/compute-address.d.ts +0 -1
- package/dist/esm/utils/compute-address.js +0 -12
- package/dist/esm/utils/compute-public-key.d.ts +0 -2
- package/dist/esm/utils/compute-public-key.js +0 -6
- package/dist/esm/utils/ether-to-gwei.d.ts +0 -3
- package/dist/esm/utils/ether-to-gwei.js +0 -7
- package/dist/esm/utils/ether-to-wei.d.ts +0 -3
- package/dist/esm/utils/ether-to-wei.js +0 -7
- package/dist/esm/utils/gwei-to-ether.d.ts +0 -3
- package/dist/esm/utils/gwei-to-ether.js +0 -7
- package/dist/esm/utils/hash-message.d.ts +0 -2
- package/dist/esm/utils/hash-message.js +0 -14
- package/dist/esm/utils/is-address.d.ts +0 -1
- package/dist/esm/utils/is-address.js +0 -12
- package/dist/esm/utils/keccak256.d.ts +0 -2
- package/dist/esm/utils/keccak256.js +0 -13
- package/dist/esm/utils/solidity-keccak256.d.ts +0 -2
- package/dist/esm/utils/solidity-keccak256.js +0 -85
- package/dist/esm/utils/split-signature.d.ts +0 -2
- package/dist/esm/utils/split-signature.js +0 -126
- package/dist/esm/utils/to-checksum-address.d.ts +0 -1
- package/dist/esm/utils/to-checksum-address.js +0 -25
- package/dist/esm/utils/to-utf8-bytes.d.ts +0 -1
- package/dist/esm/utils/to-utf8-bytes.js +0 -3
- package/dist/esm/utils/wei-to-ether.d.ts +0 -3
- package/dist/esm/utils/wei-to-ether.js +0 -16
package/dist/cjs/utils/bytes.js
DELETED
|
@@ -1,711 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hexZeroPad = exports.hexStripZeros = exports.hexValue = exports.hexConcat = exports.hexDataSlice = exports.hexDataLength = exports.hexlify = exports.isHexString = exports.zeroPad = exports.stripZeros = exports.concat = exports.arrayify = exports.isBytes = exports.isBytesLike = void 0;
|
|
4
|
-
// primarily duplicate code from https://github.com/ethers-io/ethers.js/blob/f599d6f23dad0d0acaa3828d6b7acaab2d5e455b/packages/bytes/src.ts/index.ts
|
|
5
|
-
const logger_1 = require("../logger/logger");
|
|
6
|
-
/**
|
|
7
|
-
* Check if a value can be converted to a hex string
|
|
8
|
-
*
|
|
9
|
-
* @param value the value to check whether or not it's Hexable
|
|
10
|
-
* @returns whether or not the value is Hexable
|
|
11
|
-
* @example
|
|
12
|
-
* ```javascript
|
|
13
|
-
* const val = tinyBig(203);
|
|
14
|
-
* isHexable(val);
|
|
15
|
-
* // true
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
function isHexable(value) {
|
|
19
|
-
return !!value.toHexString;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Returns true if and only if value is a valid [Bytes](#bytes) or DataHexString
|
|
23
|
-
* Same as [`ethers.utils.isBytesLike`](https://docs.ethers.io/v5/api/utils/bytes/#utils-isBytesLike)
|
|
24
|
-
*
|
|
25
|
-
* @param value the value to check whether or not it matches BytesLike
|
|
26
|
-
* @returns whether or not the value matches BytesLike
|
|
27
|
-
* @example
|
|
28
|
-
* ```javascript
|
|
29
|
-
* isBytesLike([1,2,3]);
|
|
30
|
-
* // true
|
|
31
|
-
* ```
|
|
32
|
-
* @example
|
|
33
|
-
* ```javascript
|
|
34
|
-
* isBytesLike(false);
|
|
35
|
-
* // false
|
|
36
|
-
* ```
|
|
37
|
-
* @example
|
|
38
|
-
* ```javascript
|
|
39
|
-
* isBytesLike(new Uint8Array(1));
|
|
40
|
-
* // true
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
function isBytesLike(value) {
|
|
44
|
-
return (isHexString(value) && !(value.length % 2)) || isBytes(value);
|
|
45
|
-
}
|
|
46
|
-
exports.isBytesLike = isBytesLike;
|
|
47
|
-
/**
|
|
48
|
-
* Checks if a value is an integer
|
|
49
|
-
*
|
|
50
|
-
* @param value the value to check whether or not it's an integer
|
|
51
|
-
* @returns whether or not value is an integer
|
|
52
|
-
* @example
|
|
53
|
-
* ```javascript
|
|
54
|
-
* isInteger(4)
|
|
55
|
-
* // true
|
|
56
|
-
* ```
|
|
57
|
-
* @example
|
|
58
|
-
* ```javascript
|
|
59
|
-
* isInteger(6.2)
|
|
60
|
-
* // false
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
function isInteger(value) {
|
|
64
|
-
return typeof value === 'number' && value == value && value % 1 === 0;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Returns true if and only if value is a valid [Bytes](#bytes)
|
|
68
|
-
* Same as [`ethers.utils.isBytes`](https://docs.ethers.io/v5/api/utils/bytes/#utils-isBytes)
|
|
69
|
-
*
|
|
70
|
-
* @param value the value to check whether or not it matches Bytes
|
|
71
|
-
* @returns whether or not the value matches Bytes
|
|
72
|
-
* @example
|
|
73
|
-
* ```javascript
|
|
74
|
-
* isBytes([1,2,3]);
|
|
75
|
-
* // true
|
|
76
|
-
* ```
|
|
77
|
-
* @example
|
|
78
|
-
* ```javascript
|
|
79
|
-
* isBytes(false);
|
|
80
|
-
* // false
|
|
81
|
-
* ```
|
|
82
|
-
* @example
|
|
83
|
-
* ```javascript
|
|
84
|
-
* isBytes(new Uint8Array(1));
|
|
85
|
-
* // true
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
function isBytes(value) {
|
|
89
|
-
if (value == null) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
if (value.constructor === Uint8Array) {
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
if (typeof value === 'string') {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
if (!isInteger(value.length) || value.length < 0) {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
for (let i = 0; i < value.length; i++) {
|
|
102
|
-
const v = value[i];
|
|
103
|
-
if (!isInteger(v) || v < 0 || v >= 256) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
exports.isBytes = isBytes;
|
|
110
|
-
/**
|
|
111
|
-
* Converts DataHexStringOrArrayish to a Uint8Array
|
|
112
|
-
* Same as [`ethers.utils.arrayify`](https://docs.ethers.io/v5/api/utils/bytes/#utils-arrayify)
|
|
113
|
-
*
|
|
114
|
-
* @param value the value to convert to a Uint8Array
|
|
115
|
-
* @param options options to use when converting the value to a Uint8Array
|
|
116
|
-
* @returns the value represented as a Uint8Array
|
|
117
|
-
* @example
|
|
118
|
-
* ```javascript
|
|
119
|
-
* arrayify(1);
|
|
120
|
-
* // Uint8Array(1) [ 1 ]
|
|
121
|
-
* ```
|
|
122
|
-
* @example
|
|
123
|
-
* ```javascript
|
|
124
|
-
* arrayify(0x1234);
|
|
125
|
-
* // Uint8Array(2) [ 18, 52 ]
|
|
126
|
-
* ```
|
|
127
|
-
* @example
|
|
128
|
-
* ```javascript
|
|
129
|
-
* arrayify('0x1', { hexPad: 'right' });
|
|
130
|
-
* // Uint8Array(1) [ 16 ]
|
|
131
|
-
* ```
|
|
132
|
-
*/
|
|
133
|
-
function arrayify(value, options) {
|
|
134
|
-
if (!options) {
|
|
135
|
-
options = {};
|
|
136
|
-
}
|
|
137
|
-
if (typeof value === 'number') {
|
|
138
|
-
logger_1.logger.checkSafeUint53(value, 'invalid arrayify value');
|
|
139
|
-
const result = [];
|
|
140
|
-
while (value) {
|
|
141
|
-
result.unshift(value & 0xff);
|
|
142
|
-
value = parseInt(String(value / 256));
|
|
143
|
-
}
|
|
144
|
-
if (result.length === 0) {
|
|
145
|
-
result.push(0);
|
|
146
|
-
}
|
|
147
|
-
return new Uint8Array(result);
|
|
148
|
-
}
|
|
149
|
-
if (options.allowMissingPrefix &&
|
|
150
|
-
typeof value === 'string' &&
|
|
151
|
-
value.substring(0, 2) !== '0x') {
|
|
152
|
-
value = '0x' + value;
|
|
153
|
-
}
|
|
154
|
-
if (isHexable(value)) {
|
|
155
|
-
value = value.toHexString();
|
|
156
|
-
}
|
|
157
|
-
if (isHexString(value)) {
|
|
158
|
-
let hex = value.substring(2);
|
|
159
|
-
if (hex.length % 2) {
|
|
160
|
-
if (options.hexPad === 'left') {
|
|
161
|
-
hex = '0' + hex;
|
|
162
|
-
}
|
|
163
|
-
else if (options.hexPad === 'right') {
|
|
164
|
-
hex += '0';
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
logger_1.logger.throwArgumentError('hex data is odd-length', 'value', value);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
const result = [];
|
|
171
|
-
for (let i = 0; i < hex.length; i += 2) {
|
|
172
|
-
result.push(parseInt(hex.substring(i, i + 2), 16));
|
|
173
|
-
}
|
|
174
|
-
return new Uint8Array(result);
|
|
175
|
-
}
|
|
176
|
-
if (isBytes(value)) {
|
|
177
|
-
return new Uint8Array(value);
|
|
178
|
-
}
|
|
179
|
-
return logger_1.logger.throwArgumentError('invalid arrayify value', 'value', value);
|
|
180
|
-
}
|
|
181
|
-
exports.arrayify = arrayify;
|
|
182
|
-
/**
|
|
183
|
-
* Concatenates all the BytesLike in arrayOfBytesLike into a single Uint8Array.
|
|
184
|
-
* Same as [`ethers.utils.concat`](https://docs.ethers.io/v5/api/utils/bytes/#utils-concat)
|
|
185
|
-
*
|
|
186
|
-
* @param arrayOfBytesLike the array of {@link BytesLike} to concatenate together
|
|
187
|
-
* @returns a concatenated Uint8Array
|
|
188
|
-
* @example
|
|
189
|
-
* ```javascript
|
|
190
|
-
* concat([0, 1]);
|
|
191
|
-
* // Uint8Array(2) [ 0, 1 ]
|
|
192
|
-
* ```
|
|
193
|
-
*/
|
|
194
|
-
function concat(arrayOfBytesLike) {
|
|
195
|
-
const objects = arrayOfBytesLike.map((item) => arrayify(item));
|
|
196
|
-
const length = objects.reduce((accum, item) => accum + item.length, 0);
|
|
197
|
-
const result = new Uint8Array(length);
|
|
198
|
-
objects.reduce((offset, object) => {
|
|
199
|
-
result.set(object, offset);
|
|
200
|
-
return offset + object.length;
|
|
201
|
-
}, 0);
|
|
202
|
-
return result;
|
|
203
|
-
}
|
|
204
|
-
exports.concat = concat;
|
|
205
|
-
/**
|
|
206
|
-
* Strips leading zeros from a BytesLike object
|
|
207
|
-
*
|
|
208
|
-
* @param value the value to strip leading zeros from
|
|
209
|
-
* @returns value without leading zeroes, expressed as a Uint8Array
|
|
210
|
-
* @example
|
|
211
|
-
* ```javascript
|
|
212
|
-
* stripZeros('0x00002834');
|
|
213
|
-
* // Uint8Array { [Iterator] 0: 40, 1: 52 }
|
|
214
|
-
* // Equivalent to '0x2834'
|
|
215
|
-
* ```
|
|
216
|
-
*/
|
|
217
|
-
function stripZeros(value) {
|
|
218
|
-
let result = arrayify(value);
|
|
219
|
-
if (result.length === 0) {
|
|
220
|
-
return result;
|
|
221
|
-
}
|
|
222
|
-
// Find the first non-zero entry
|
|
223
|
-
let start = 0;
|
|
224
|
-
while (start < result.length && result[start] === 0) {
|
|
225
|
-
start++;
|
|
226
|
-
}
|
|
227
|
-
// If we started with zeros, strip them
|
|
228
|
-
if (start) {
|
|
229
|
-
result = result.slice(start);
|
|
230
|
-
}
|
|
231
|
-
return result;
|
|
232
|
-
}
|
|
233
|
-
exports.stripZeros = stripZeros;
|
|
234
|
-
/**
|
|
235
|
-
* Pads the beginning of a {@link BytesLike} with zeros so it's the specified length as a Uint8Array
|
|
236
|
-
*
|
|
237
|
-
* @param value the value to pad
|
|
238
|
-
* @param length the desired length of the value
|
|
239
|
-
* @returns the value padded with zeros to the specified length
|
|
240
|
-
* @example
|
|
241
|
-
* ```javascript
|
|
242
|
-
* zeroPad('0x039284');
|
|
243
|
-
* // Uint8Array { [Iterator] 0: 0, 1: 0, 2: 0, 3: 3, 4: 146, 5: 132 }
|
|
244
|
-
* // Equivalent to 0x000000039284
|
|
245
|
-
* ```
|
|
246
|
-
* @example
|
|
247
|
-
* ```javascript
|
|
248
|
-
* zeroPad([39, 25, 103, 45], 5);
|
|
249
|
-
* // Uint8Array { [Iterator] 0: 0, 1: 39, 2: 25, 3: 103, 4: 45 }
|
|
250
|
-
* ```
|
|
251
|
-
*/
|
|
252
|
-
function zeroPad(value, length) {
|
|
253
|
-
value = arrayify(value);
|
|
254
|
-
if (value.length > length) {
|
|
255
|
-
logger_1.logger.throwArgumentError('value out of range', 'value', value);
|
|
256
|
-
}
|
|
257
|
-
const result = new Uint8Array(length);
|
|
258
|
-
result.set(value, length - value.length);
|
|
259
|
-
return result;
|
|
260
|
-
}
|
|
261
|
-
exports.zeroPad = zeroPad;
|
|
262
|
-
/**
|
|
263
|
-
* Returns true if and only if object is a valid hex string.
|
|
264
|
-
* If length is specified and object is not a valid DataHexString of length bytes, an InvalidArgument error is thrown.
|
|
265
|
-
* Same as [`ethers.utils.isHexString`](https://docs.ethers.io/v5/api/utils/bytes/#utils-isHexString)
|
|
266
|
-
*
|
|
267
|
-
* @param value the value to check whether or not it's a hex string
|
|
268
|
-
* @param length a length of bytes that the value should be equal to
|
|
269
|
-
* @returns whether the value is a valid hex string (and optionally, whether it matches the length specified)
|
|
270
|
-
* @example
|
|
271
|
-
* ```javascript
|
|
272
|
-
* isHexString('0x4924');
|
|
273
|
-
* // true
|
|
274
|
-
* ```
|
|
275
|
-
* @example
|
|
276
|
-
* ```javascript
|
|
277
|
-
* isHexString('0x4924', 4);
|
|
278
|
-
* // false
|
|
279
|
-
* // length of 4 in bytes would mean a hex string with 8 characters
|
|
280
|
-
* ```
|
|
281
|
-
*/
|
|
282
|
-
function isHexString(value, length) {
|
|
283
|
-
if (typeof value !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/)) {
|
|
284
|
-
return false;
|
|
285
|
-
}
|
|
286
|
-
if (length && value.length !== 2 + 2 * length) {
|
|
287
|
-
return false;
|
|
288
|
-
}
|
|
289
|
-
return true;
|
|
290
|
-
}
|
|
291
|
-
exports.isHexString = isHexString;
|
|
292
|
-
const HexCharacters = '0123456789abcdef';
|
|
293
|
-
/**
|
|
294
|
-
* Converts a value into a hex string
|
|
295
|
-
*
|
|
296
|
-
* @param value the value to convert
|
|
297
|
-
* @param options options to use when converting the value to a hex string
|
|
298
|
-
* @returns the value represented as a hex string
|
|
299
|
-
* @example
|
|
300
|
-
* ```javascript
|
|
301
|
-
* hexlify(4);
|
|
302
|
-
* // '0x04'
|
|
303
|
-
* ```
|
|
304
|
-
* @example
|
|
305
|
-
* ```javascript
|
|
306
|
-
* hexlify(14);
|
|
307
|
-
* // '0x0e'
|
|
308
|
-
* ```
|
|
309
|
-
*/
|
|
310
|
-
function hexlify(value, options) {
|
|
311
|
-
if (!options) {
|
|
312
|
-
options = {};
|
|
313
|
-
}
|
|
314
|
-
if (typeof value === 'number') {
|
|
315
|
-
logger_1.logger.checkSafeUint53(value, 'invalid hexlify value');
|
|
316
|
-
let hex = '';
|
|
317
|
-
while (value) {
|
|
318
|
-
hex = HexCharacters[value & 0xf] + hex;
|
|
319
|
-
value = Math.floor(value / 16);
|
|
320
|
-
}
|
|
321
|
-
if (hex.length) {
|
|
322
|
-
if (hex.length % 2) {
|
|
323
|
-
hex = '0' + hex;
|
|
324
|
-
}
|
|
325
|
-
return '0x' + hex;
|
|
326
|
-
}
|
|
327
|
-
return '0x00';
|
|
328
|
-
}
|
|
329
|
-
if (typeof value === 'bigint') {
|
|
330
|
-
value = value.toString(16);
|
|
331
|
-
if (value.length % 2) {
|
|
332
|
-
return '0x0' + value;
|
|
333
|
-
}
|
|
334
|
-
return '0x' + value;
|
|
335
|
-
}
|
|
336
|
-
if (options.allowMissingPrefix &&
|
|
337
|
-
typeof value === 'string' &&
|
|
338
|
-
value.substring(0, 2) !== '0x') {
|
|
339
|
-
value = '0x' + value;
|
|
340
|
-
}
|
|
341
|
-
if (isHexable(value)) {
|
|
342
|
-
return value.toHexString();
|
|
343
|
-
}
|
|
344
|
-
if (isHexString(value)) {
|
|
345
|
-
if (value.length % 2) {
|
|
346
|
-
if (options.hexPad === 'left') {
|
|
347
|
-
value = '0x0' + value.substring(2);
|
|
348
|
-
}
|
|
349
|
-
else if (options.hexPad === 'right') {
|
|
350
|
-
value += '0';
|
|
351
|
-
}
|
|
352
|
-
else {
|
|
353
|
-
logger_1.logger.throwArgumentError('hex data is odd-length', 'value', value);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
return value.toLowerCase();
|
|
357
|
-
}
|
|
358
|
-
if (isBytes(value)) {
|
|
359
|
-
let result = '0x';
|
|
360
|
-
for (let i = 0; i < value.length; i++) {
|
|
361
|
-
const v = value[i];
|
|
362
|
-
result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f];
|
|
363
|
-
}
|
|
364
|
-
return result;
|
|
365
|
-
}
|
|
366
|
-
return logger_1.logger.throwArgumentError('invalid hexlify value', 'value', value);
|
|
367
|
-
}
|
|
368
|
-
exports.hexlify = hexlify;
|
|
369
|
-
/**
|
|
370
|
-
* Gets the length of data represented as a hex string
|
|
371
|
-
*
|
|
372
|
-
* @param data the data to check the length of
|
|
373
|
-
* @returns the length of the data
|
|
374
|
-
* @example
|
|
375
|
-
* ```javascript
|
|
376
|
-
* hexDataLength([2, 4, 0, 1]);
|
|
377
|
-
* // 4
|
|
378
|
-
* ```
|
|
379
|
-
* @example
|
|
380
|
-
* ```javascript
|
|
381
|
-
* hexDataLength('0x3925');
|
|
382
|
-
* // 2
|
|
383
|
-
* ```
|
|
384
|
-
*/
|
|
385
|
-
function hexDataLength(data) {
|
|
386
|
-
if (typeof data !== 'string') {
|
|
387
|
-
data = hexlify(data);
|
|
388
|
-
}
|
|
389
|
-
else if (!isHexString(data) || data.length % 2) {
|
|
390
|
-
return null;
|
|
391
|
-
}
|
|
392
|
-
return (data.length - 2) / 2;
|
|
393
|
-
}
|
|
394
|
-
exports.hexDataLength = hexDataLength;
|
|
395
|
-
/**
|
|
396
|
-
* Slices a {@link BytesLike} to extract a certain part of the input
|
|
397
|
-
*
|
|
398
|
-
* @param data the data to slice from
|
|
399
|
-
* @param offset the index to start extraction at
|
|
400
|
-
* @param endOffset the index to end extraction at
|
|
401
|
-
* @returns the extracted data as a hex string
|
|
402
|
-
* @example
|
|
403
|
-
* ```javascript
|
|
404
|
-
* hexDataSlice([20, 6, 48], 0, 2);
|
|
405
|
-
* // '0x1406'
|
|
406
|
-
* ```
|
|
407
|
-
*/
|
|
408
|
-
function hexDataSlice(data, offset, endOffset) {
|
|
409
|
-
if (typeof data !== 'string') {
|
|
410
|
-
data = hexlify(data);
|
|
411
|
-
}
|
|
412
|
-
else if (!isHexString(data) || data.length % 2) {
|
|
413
|
-
logger_1.logger.throwArgumentError('invalid hexData', 'value', data);
|
|
414
|
-
}
|
|
415
|
-
offset = 2 + 2 * offset;
|
|
416
|
-
if (endOffset != null) {
|
|
417
|
-
return '0x' + data.substring(offset, 2 + 2 * endOffset);
|
|
418
|
-
}
|
|
419
|
-
return '0x' + data.substring(offset);
|
|
420
|
-
}
|
|
421
|
-
exports.hexDataSlice = hexDataSlice;
|
|
422
|
-
/**
|
|
423
|
-
* Concatenates values together into one hex string
|
|
424
|
-
*
|
|
425
|
-
* @param items the items to concatenate together
|
|
426
|
-
* @returns a single hex string including all of the items to be concatenated
|
|
427
|
-
* @example
|
|
428
|
-
* ```javascript
|
|
429
|
-
* hexConcat([[2, 4, 0, 1], 9, '0x2934', '0x3947']);
|
|
430
|
-
* // '0x020400010929343947'
|
|
431
|
-
* ```
|
|
432
|
-
*/
|
|
433
|
-
function hexConcat(items) {
|
|
434
|
-
let result = '0x';
|
|
435
|
-
items.forEach((item) => {
|
|
436
|
-
result += hexlify(item).substring(2);
|
|
437
|
-
});
|
|
438
|
-
return result;
|
|
439
|
-
}
|
|
440
|
-
exports.hexConcat = hexConcat;
|
|
441
|
-
/**
|
|
442
|
-
* Converts a number of different types into a hex string
|
|
443
|
-
*
|
|
444
|
-
* @param value the value to convert into a hex string
|
|
445
|
-
* @returns the value represented as a hex string
|
|
446
|
-
* @example
|
|
447
|
-
* ```javascript
|
|
448
|
-
* hexValue(39);
|
|
449
|
-
* // '0x27'
|
|
450
|
-
* ```
|
|
451
|
-
* @example
|
|
452
|
-
* ```javascript
|
|
453
|
-
* hexValue([9, 4, 19, 4]);
|
|
454
|
-
* // '0x9041304'
|
|
455
|
-
* ```
|
|
456
|
-
*/
|
|
457
|
-
function hexValue(value) {
|
|
458
|
-
const trimmed = hexStripZeros(hexlify(value, { hexPad: 'left' }));
|
|
459
|
-
if (trimmed === '0x') {
|
|
460
|
-
return '0x0';
|
|
461
|
-
}
|
|
462
|
-
return trimmed;
|
|
463
|
-
}
|
|
464
|
-
exports.hexValue = hexValue;
|
|
465
|
-
/**
|
|
466
|
-
* Strips the leading zeros from a value and returns it as a hex string
|
|
467
|
-
*
|
|
468
|
-
* @param value the value to strip zeros from
|
|
469
|
-
* @returns a hex string representation of the value, without leading zeros
|
|
470
|
-
* @example
|
|
471
|
-
* ```javascript
|
|
472
|
-
* hexStripZeros([0,0,0,48]);
|
|
473
|
-
* // '0x30'
|
|
474
|
-
* ```
|
|
475
|
-
*/
|
|
476
|
-
function hexStripZeros(value) {
|
|
477
|
-
if (typeof value !== 'string') {
|
|
478
|
-
value = hexlify(value);
|
|
479
|
-
}
|
|
480
|
-
if (!isHexString(value)) {
|
|
481
|
-
logger_1.logger.throwArgumentError('invalid hex string', 'value', value);
|
|
482
|
-
}
|
|
483
|
-
value = value.substring(2);
|
|
484
|
-
let offset = 0;
|
|
485
|
-
while (offset < value.length && value[offset] === '0') {
|
|
486
|
-
offset++;
|
|
487
|
-
}
|
|
488
|
-
return '0x' + value.substring(offset);
|
|
489
|
-
}
|
|
490
|
-
exports.hexStripZeros = hexStripZeros;
|
|
491
|
-
/**
|
|
492
|
-
* Returns a hex string padded to a specified length of bytes.
|
|
493
|
-
*
|
|
494
|
-
* Similar to ["hexZeroPad" in ethers.js](https://docs.ethers.io/v5/api/utils/bytes/#utils-hexZeroPad)
|
|
495
|
-
*
|
|
496
|
-
* Differs from ["padLeft" in web3.js](https://web3js.readthedocs.io/en/v1.7.1/web3-utils.html#padleft) because web3 counts by characters, not bytes.
|
|
497
|
-
*
|
|
498
|
-
* @param value A hex-string, hex-number, or decimal number (auto-converts to base-16) to be padded
|
|
499
|
-
* @param length The final length in bytes
|
|
500
|
-
* @returns A hex string padded to the specified length
|
|
501
|
-
* @throws If the value is not a hex string or number
|
|
502
|
-
* @throws If the value is longer than the length
|
|
503
|
-
* @example
|
|
504
|
-
* ```javascript
|
|
505
|
-
* hexZeroPad('0x60', 2);
|
|
506
|
-
* // '0x0060'
|
|
507
|
-
* ```
|
|
508
|
-
* @example
|
|
509
|
-
* ```javascript
|
|
510
|
-
* hexZeroPad(0x60, 3);
|
|
511
|
-
* // '0x000060'
|
|
512
|
-
* ```
|
|
513
|
-
* @example
|
|
514
|
-
* ```javascript
|
|
515
|
-
* hexZeroPad('12345', 1);
|
|
516
|
-
* // Throws
|
|
517
|
-
* ```
|
|
518
|
-
*/
|
|
519
|
-
function hexZeroPad(value, length) {
|
|
520
|
-
if (typeof value !== 'string') {
|
|
521
|
-
value = hexlify(value);
|
|
522
|
-
}
|
|
523
|
-
else if (!isHexString(value)) {
|
|
524
|
-
logger_1.logger.throwArgumentError('invalid hex string', 'value', value);
|
|
525
|
-
}
|
|
526
|
-
if (value.length > 2 * length + 2) {
|
|
527
|
-
logger_1.logger.throwError('value out of range', { value, length });
|
|
528
|
-
}
|
|
529
|
-
while (value.length < 2 * length + 2) {
|
|
530
|
-
value = '0x0' + value.substring(2);
|
|
531
|
-
}
|
|
532
|
-
return value;
|
|
533
|
-
}
|
|
534
|
-
exports.hexZeroPad = hexZeroPad;
|
|
535
|
-
// export function splitSignature(signature: SignatureLike): Signature {
|
|
536
|
-
// const result: Signature = {
|
|
537
|
-
// r: '0x',
|
|
538
|
-
// s: '0x',
|
|
539
|
-
// _vs: '0x',
|
|
540
|
-
// recoveryParam: 0,
|
|
541
|
-
// v: 0,
|
|
542
|
-
// yParityAndS: '0x',
|
|
543
|
-
// compact: '0x',
|
|
544
|
-
// };
|
|
545
|
-
// if (isBytesLike(signature)) {
|
|
546
|
-
// const bytes: Uint8Array = arrayify(signature);
|
|
547
|
-
// // Get the r, s and v
|
|
548
|
-
// if (bytes.length === 64) {
|
|
549
|
-
// // EIP-2098; pull the v from the top bit of s and clear it
|
|
550
|
-
// result.v = 27 + (bytes[32] >> 7);
|
|
551
|
-
// bytes[32] &= 0x7f;
|
|
552
|
-
// result.r = hexlify(bytes.slice(0, 32));
|
|
553
|
-
// result.s = hexlify(bytes.slice(32, 64));
|
|
554
|
-
// } else if (bytes.length === 65) {
|
|
555
|
-
// result.r = hexlify(bytes.slice(0, 32));
|
|
556
|
-
// result.s = hexlify(bytes.slice(32, 64));
|
|
557
|
-
// result.v = bytes[64];
|
|
558
|
-
// } else {
|
|
559
|
-
// logger.throwArgumentError(
|
|
560
|
-
// 'invalid signature string',
|
|
561
|
-
// 'signature',
|
|
562
|
-
// signature,
|
|
563
|
-
// );
|
|
564
|
-
// }
|
|
565
|
-
// // Allow a recid to be used as the v
|
|
566
|
-
// if (result.v < 27) {
|
|
567
|
-
// if (result.v === 0 || result.v === 1) {
|
|
568
|
-
// result.v += 27;
|
|
569
|
-
// } else {
|
|
570
|
-
// logger.throwArgumentError(
|
|
571
|
-
// 'signature invalid v byte',
|
|
572
|
-
// 'signature',
|
|
573
|
-
// signature,
|
|
574
|
-
// );
|
|
575
|
-
// }
|
|
576
|
-
// }
|
|
577
|
-
// // Compute recoveryParam from v
|
|
578
|
-
// result.recoveryParam = 1 - (result.v % 2);
|
|
579
|
-
// // Compute _vs from recoveryParam and s
|
|
580
|
-
// if (result.recoveryParam) {
|
|
581
|
-
// bytes[32] |= 0x80;
|
|
582
|
-
// }
|
|
583
|
-
// result._vs = hexlify(bytes.slice(32, 64));
|
|
584
|
-
// } else {
|
|
585
|
-
// result.r = signature.r;
|
|
586
|
-
// result.s = signature.s;
|
|
587
|
-
// result.v = signature.v;
|
|
588
|
-
// result.recoveryParam = signature.recoveryParam;
|
|
589
|
-
// result._vs = signature._vs;
|
|
590
|
-
// // If the _vs is available, use it to populate missing s, v and recoveryParam
|
|
591
|
-
// // and verify non-missing s, v and recoveryParam
|
|
592
|
-
// if (result._vs != null) {
|
|
593
|
-
// const vs = zeroPad(arrayify(result._vs), 32);
|
|
594
|
-
// result._vs = hexlify(vs);
|
|
595
|
-
// // Set or check the recid
|
|
596
|
-
// const recoveryParam = vs[0] >= 128 ? 1 : 0;
|
|
597
|
-
// if (result.recoveryParam == null) {
|
|
598
|
-
// result.recoveryParam = recoveryParam;
|
|
599
|
-
// } else if (result.recoveryParam !== recoveryParam) {
|
|
600
|
-
// logger.throwArgumentError(
|
|
601
|
-
// 'signature recoveryParam mismatch _vs',
|
|
602
|
-
// 'signature',
|
|
603
|
-
// signature,
|
|
604
|
-
// );
|
|
605
|
-
// }
|
|
606
|
-
// // Set or check the s
|
|
607
|
-
// vs[0] &= 0x7f;
|
|
608
|
-
// const s = hexlify(vs);
|
|
609
|
-
// if (result.s == null) {
|
|
610
|
-
// result.s = s;
|
|
611
|
-
// } else if (result.s !== s) {
|
|
612
|
-
// logger.throwArgumentError(
|
|
613
|
-
// 'signature v mismatch _vs',
|
|
614
|
-
// 'signature',
|
|
615
|
-
// signature,
|
|
616
|
-
// );
|
|
617
|
-
// }
|
|
618
|
-
// }
|
|
619
|
-
// // Use recid and v to populate each other
|
|
620
|
-
// if (result.recoveryParam == null) {
|
|
621
|
-
// if (result.v == null) {
|
|
622
|
-
// logger.throwArgumentError(
|
|
623
|
-
// 'signature missing v and recoveryParam',
|
|
624
|
-
// 'signature',
|
|
625
|
-
// signature,
|
|
626
|
-
// );
|
|
627
|
-
// } else if (result.v === 0 || result.v === 1) {
|
|
628
|
-
// result.recoveryParam = result.v;
|
|
629
|
-
// } else {
|
|
630
|
-
// result.recoveryParam = 1 - (result.v % 2);
|
|
631
|
-
// }
|
|
632
|
-
// } else {
|
|
633
|
-
// if (result.v == null) {
|
|
634
|
-
// result.v = 27 + result.recoveryParam;
|
|
635
|
-
// } else {
|
|
636
|
-
// const recId =
|
|
637
|
-
// result.v === 0 || result.v === 1 ? result.v : 1 - (result.v % 2);
|
|
638
|
-
// if (result.recoveryParam !== recId) {
|
|
639
|
-
// logger.throwArgumentError(
|
|
640
|
-
// 'signature recoveryParam mismatch v',
|
|
641
|
-
// 'signature',
|
|
642
|
-
// signature,
|
|
643
|
-
// );
|
|
644
|
-
// }
|
|
645
|
-
// }
|
|
646
|
-
// }
|
|
647
|
-
// if (result.r == null || !isHexString(result.r)) {
|
|
648
|
-
// logger.throwArgumentError(
|
|
649
|
-
// 'signature missing or invalid r',
|
|
650
|
-
// 'signature',
|
|
651
|
-
// signature,
|
|
652
|
-
// );
|
|
653
|
-
// } else {
|
|
654
|
-
// result.r = hexZeroPad(result.r, 32);
|
|
655
|
-
// }
|
|
656
|
-
// if (result.s == null || !isHexString(result.s)) {
|
|
657
|
-
// logger.throwArgumentError(
|
|
658
|
-
// 'signature missing or invalid s',
|
|
659
|
-
// 'signature',
|
|
660
|
-
// signature,
|
|
661
|
-
// );
|
|
662
|
-
// } else {
|
|
663
|
-
// result.s = hexZeroPad(result.s, 32);
|
|
664
|
-
// }
|
|
665
|
-
// const vs = arrayify(result.s);
|
|
666
|
-
// if (vs[0] >= 128) {
|
|
667
|
-
// logger.throwArgumentError(
|
|
668
|
-
// 'signature s out of range',
|
|
669
|
-
// 'signature',
|
|
670
|
-
// signature,
|
|
671
|
-
// );
|
|
672
|
-
// }
|
|
673
|
-
// if (result.recoveryParam) {
|
|
674
|
-
// vs[0] |= 0x80;
|
|
675
|
-
// }
|
|
676
|
-
// const _vs = hexlify(vs);
|
|
677
|
-
// if (result._vs) {
|
|
678
|
-
// if (!isHexString(result._vs)) {
|
|
679
|
-
// logger.throwArgumentError(
|
|
680
|
-
// 'signature invalid _vs',
|
|
681
|
-
// 'signature',
|
|
682
|
-
// signature,
|
|
683
|
-
// );
|
|
684
|
-
// }
|
|
685
|
-
// result._vs = hexZeroPad(result._vs, 32);
|
|
686
|
-
// }
|
|
687
|
-
// // Set or check the _vs
|
|
688
|
-
// if (result._vs == null) {
|
|
689
|
-
// result._vs = _vs;
|
|
690
|
-
// } else if (result._vs !== _vs) {
|
|
691
|
-
// logger.throwArgumentError(
|
|
692
|
-
// 'signature _vs mismatch v and s',
|
|
693
|
-
// 'signature',
|
|
694
|
-
// signature,
|
|
695
|
-
// );
|
|
696
|
-
// }
|
|
697
|
-
// }
|
|
698
|
-
// result.yParityAndS = result._vs;
|
|
699
|
-
// result.compact = result.r + result.yParityAndS.substring(2);
|
|
700
|
-
// return result;
|
|
701
|
-
// }
|
|
702
|
-
// export function joinSignature(signature: SignatureLike): string {
|
|
703
|
-
// signature = splitSignature(signature);
|
|
704
|
-
// return hexlify(
|
|
705
|
-
// concat([
|
|
706
|
-
// signature.r,
|
|
707
|
-
// signature.s,
|
|
708
|
-
// signature.recoveryParam ? '0x1c' : '0x1b',
|
|
709
|
-
// ]),
|
|
710
|
-
// );
|
|
711
|
-
// }
|