essential-eth 0.6.1 → 0.7.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/cjs/classes/Contract.js +310 -71
- package/dist/cjs/classes/test/Contract/crv-abi.js +252 -256
- package/dist/cjs/classes/test/Contract/crv.test.js +690 -0
- package/dist/cjs/classes/test/Contract/ens-abi.js +497 -212
- package/dist/cjs/classes/test/Contract/ens.test.js +217 -0
- package/dist/cjs/classes/test/Contract/fei-abi.js +605 -284
- package/dist/cjs/classes/test/Contract/fei.test.js +224 -0
- package/dist/cjs/classes/test/Contract/foo-abi.js +44 -21
- package/dist/cjs/classes/test/Contract/foo.test.js +33 -0
- package/dist/cjs/classes/test/Contract/uni.test.js +387 -0
- package/dist/cjs/classes/test/Contract/uniswap-abi.js +64 -68
- package/dist/cjs/classes/utils/clean-block.d.ts +1 -2
- package/dist/cjs/classes/utils/clean-block.js +52 -30
- package/dist/cjs/classes/utils/clean-log.js +42 -20
- package/dist/cjs/classes/utils/clean-transaction-receipt.js +51 -29
- package/dist/cjs/classes/utils/clean-transaction.js +52 -29
- package/dist/cjs/classes/utils/encode-decode-transaction.d.ts +1 -1
- package/dist/cjs/classes/utils/encode-decode-transaction.js +163 -83
- package/dist/cjs/classes/utils/fetchers.js +169 -42
- package/dist/cjs/classes/utils/hex-to-decimal.js +1 -6
- package/dist/cjs/classes/utils/prepare-transaction.js +59 -36
- package/dist/cjs/index.js +25 -54
- package/dist/cjs/index.umd.js +1 -1
- package/dist/cjs/index.umd.js.map +1 -1
- package/dist/cjs/logger/logger.js +79 -23
- package/dist/cjs/logger/package-version.d.ts +1 -1
- package/dist/cjs/logger/package-version.js +1 -4
- package/dist/cjs/providers/BaseProvider.js +824 -475
- package/dist/cjs/providers/FallthroughProvider.js +118 -37
- package/dist/cjs/providers/JsonRpcProvider.js +93 -28
- package/dist/cjs/providers/test/fallthrough-provider/get-gas-price.test.js +228 -0
- package/dist/cjs/providers/test/get-transaction-count.test.js +276 -0
- package/dist/cjs/providers/test/json-rpc-provider/call.test.js +436 -0
- package/dist/cjs/providers/test/json-rpc-provider/estimate-gas.test.js +288 -0
- package/dist/cjs/providers/test/json-rpc-provider/get-balance.test.js +261 -0
- package/dist/cjs/providers/test/json-rpc-provider/get-block-number.test.js +230 -0
- package/dist/cjs/providers/test/json-rpc-provider/get-block.test.js +501 -0
- package/dist/cjs/providers/test/json-rpc-provider/get-code.test.js +311 -0
- package/dist/cjs/providers/test/json-rpc-provider/get-gas-price.test.js +202 -0
- package/dist/cjs/providers/test/json-rpc-provider/get-logs.test.js +361 -0
- package/dist/cjs/providers/test/json-rpc-provider/get-network.test.js +274 -0
- package/dist/cjs/providers/test/json-rpc-provider/get-transaction-receipt.test.js +301 -0
- package/dist/cjs/providers/test/json-rpc-provider/get-transaction.test.js +307 -0
- package/dist/cjs/providers/test/rpc-urls.js +9 -12
- package/dist/cjs/providers/utils/chains-info.js +1 -3
- package/dist/cjs/shared/tiny-big/helpers.js +93 -42
- package/dist/cjs/shared/tiny-big/helpers.test.js +29 -0
- package/dist/cjs/shared/tiny-big/tiny-big.js +161 -72
- package/dist/cjs/shared/tiny-big/tiny-big.test.js +34 -0
- package/dist/cjs/shared/validate-type.js +7 -7
- package/dist/cjs/types/Block.types.js +1 -2
- package/dist/cjs/types/Contract.types.js +1 -2
- package/dist/cjs/types/Filter.types.js +1 -2
- package/dist/cjs/types/Network.types.js +3 -2
- package/dist/cjs/types/Transaction.types.js +1 -2
- package/dist/cjs/utils/bytes.js +286 -318
- package/dist/cjs/utils/compute-address.js +8 -14
- package/dist/cjs/utils/compute-public-key.js +5 -10
- package/dist/cjs/utils/ether-to-gwei.js +10 -11
- package/dist/cjs/utils/ether-to-wei.js +10 -11
- package/dist/cjs/utils/gwei-to-ether.js +10 -11
- package/dist/cjs/utils/hash-message.d.ts +1 -1
- package/dist/cjs/utils/hash-message.js +11 -14
- package/dist/cjs/utils/is-address.js +8 -12
- package/dist/cjs/utils/keccak256.js +8 -14
- package/dist/cjs/utils/solidity-keccak256.js +49 -60
- package/dist/cjs/utils/split-signature.js +55 -73
- package/dist/cjs/utils/tests/bytes/arrayify.test.js +40 -0
- package/dist/cjs/utils/tests/bytes/concat.test.js +15 -0
- package/dist/cjs/utils/tests/bytes/hex-concat.test.js +63 -0
- package/dist/cjs/utils/tests/bytes/hex-data-length.test.js +49 -0
- package/dist/cjs/utils/tests/bytes/hex-data-slice.test.js +52 -0
- package/dist/cjs/utils/tests/bytes/hex-strip-zeros.test.js +58 -0
- package/dist/cjs/utils/tests/bytes/hex-value.test.js +85 -0
- package/dist/cjs/utils/tests/bytes/hex-zero-pad.test.js +62 -0
- package/dist/cjs/utils/tests/bytes/hexlify.test.js +62 -0
- package/dist/cjs/utils/tests/bytes/is-bytes-like.test.js +69 -0
- package/dist/cjs/utils/tests/bytes/is-bytes.test.js +33 -0
- package/dist/cjs/utils/tests/bytes/is-hex-string.test.js +88 -0
- package/dist/cjs/utils/tests/bytes/strip-zeros.test.js +57 -0
- package/dist/cjs/utils/tests/bytes/zero-pad.test.js +80 -0
- package/dist/cjs/utils/tests/compute-address.test.js +27 -0
- package/dist/cjs/utils/tests/compute-public-key.test.js +15 -0
- package/dist/cjs/utils/tests/ether-to-gwei.test.js +26 -0
- package/dist/cjs/utils/tests/ether-to-wei.test.js +44 -0
- package/dist/cjs/utils/tests/gwei-to-ether.test.js +28 -0
- package/dist/cjs/utils/tests/hash-message.test.js +21 -0
- package/dist/cjs/utils/tests/is-address.test.js +55 -0
- package/dist/cjs/utils/tests/keccak256.test.js +97 -0
- package/dist/cjs/utils/tests/solidity-keccak256.test.js +310 -0
- package/dist/cjs/utils/tests/split-signature.test.js +25 -0
- package/dist/cjs/utils/tests/to-checksum-address.test.js +42 -0
- package/dist/cjs/utils/tests/to-utf8-bytes.test.js +14 -0
- package/dist/cjs/utils/tests/wei-to-ether.test.js +51 -0
- package/dist/cjs/utils/to-checksum-address.js +15 -20
- package/dist/cjs/utils/to-utf8-bytes.js +1 -6
- package/dist/cjs/utils/wei-to-ether.js +13 -15
- package/dist/esm/classes/Contract.js +3 -7
- package/dist/esm/classes/utils/clean-block.d.ts +1 -2
- package/dist/esm/classes/utils/clean-block.js +1 -1
- package/dist/esm/classes/utils/clean-transaction-receipt.js +2 -1
- package/dist/esm/classes/utils/clean-transaction.js +2 -1
- package/dist/esm/classes/utils/encode-decode-transaction.d.ts +1 -1
- package/dist/esm/classes/utils/encode-decode-transaction.js +37 -2
- package/dist/esm/logger/package-version.d.ts +1 -1
- package/dist/esm/logger/package-version.js +1 -1
- package/dist/esm/utils/compute-address.js +2 -1
- package/dist/esm/utils/hash-message.d.ts +1 -1
- package/dist/esm/utils/hash-message.js +3 -1
- package/dist/esm/utils/is-address.js +1 -1
- package/package.json +8 -6
- package/readme.md +34 -3
|
@@ -1,8 +1,29 @@
|
|
|
1
1
|
import { Keccak } from 'sha3';
|
|
2
|
-
import { tinyBig
|
|
2
|
+
import { tinyBig } from '../../shared/tiny-big/tiny-big';
|
|
3
|
+
import { toChecksumAddress } from '../../utils/to-checksum-address';
|
|
3
4
|
import { hexToDecimal } from './hex-to-decimal';
|
|
4
5
|
export const hexFalse = '0'.repeat(64);
|
|
5
6
|
const hexTrue = '0'.repeat(63) + '1';
|
|
7
|
+
function hexToUtf8(hex) {
|
|
8
|
+
let str = '';
|
|
9
|
+
let i = 0;
|
|
10
|
+
const l = hex.length;
|
|
11
|
+
if (hex.substring(0, 2) === '0x') {
|
|
12
|
+
i = 2;
|
|
13
|
+
}
|
|
14
|
+
for (; i < l; i += 2) {
|
|
15
|
+
const code = parseInt(hex.substr(i, 2), 16);
|
|
16
|
+
if (code === 0)
|
|
17
|
+
continue;
|
|
18
|
+
str += String.fromCharCode(code);
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
return decodeURIComponent(escape(str));
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
return str;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
6
27
|
function expandType(type) {
|
|
7
28
|
if (type === 'uint[]') {
|
|
8
29
|
return 'uint256[]';
|
|
@@ -75,8 +96,22 @@ export function encodeData(jsonABIArgument, args) {
|
|
|
75
96
|
return data;
|
|
76
97
|
}
|
|
77
98
|
export function decodeRPCResponse(jsonABIArgument, nodeResponse) {
|
|
99
|
+
var _a;
|
|
78
100
|
const rawOutputs = jsonABIArgument.outputs;
|
|
79
|
-
const
|
|
101
|
+
const slicedResponse = nodeResponse.slice(2);
|
|
102
|
+
if (((_a = jsonABIArgument === null || jsonABIArgument === void 0 ? void 0 : jsonABIArgument.outputs) === null || _a === void 0 ? void 0 : _a.length) === 1 &&
|
|
103
|
+
jsonABIArgument.outputs[0].type === 'string') {
|
|
104
|
+
const [hexOffset, responseData] = [
|
|
105
|
+
slicedResponse.slice(0, 64),
|
|
106
|
+
slicedResponse.slice(64),
|
|
107
|
+
];
|
|
108
|
+
const decimalOffset = Number(hexToDecimal(`0x${hexOffset}`));
|
|
109
|
+
const hexLength = responseData.slice(0, decimalOffset * 2);
|
|
110
|
+
const decimalLength = Number(hexToDecimal(`0x${hexLength}`));
|
|
111
|
+
const hexToDecode = responseData.slice(decimalOffset * 2, decimalOffset * 2 + decimalLength * 2);
|
|
112
|
+
return hexToUtf8(hexToDecode);
|
|
113
|
+
}
|
|
114
|
+
const encodedOutputs = slicedResponse.match(/.{1,64}/g);
|
|
80
115
|
const outputs = (encodedOutputs || []).map((output, i) => {
|
|
81
116
|
const outputType = (rawOutputs || [])[i].type;
|
|
82
117
|
switch (outputType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.
|
|
1
|
+
export declare const version = "0.7.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.
|
|
1
|
+
export const version = '0.7.0';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { computePublicKey, toChecksumAddress } from '..';
|
|
2
1
|
import { hexDataSlice } from './bytes';
|
|
2
|
+
import { computePublicKey } from './compute-public-key';
|
|
3
3
|
import { keccak256 } from './keccak256';
|
|
4
|
+
import { toChecksumAddress } from './to-checksum-address';
|
|
4
5
|
export function computeAddress(key) {
|
|
5
6
|
if (!key.startsWith('0x04') &&
|
|
6
7
|
!key.startsWith('0x03') &&
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Bytes } from '
|
|
1
|
+
import type { Bytes } from './bytes';
|
|
2
2
|
export declare function hashMessage(message: Bytes | string): string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { concat
|
|
1
|
+
import { concat } from './bytes';
|
|
2
|
+
import { keccak256 } from './keccak256';
|
|
3
|
+
import { toUtf8Bytes } from './to-utf8-bytes';
|
|
2
4
|
const messagePrefix = '\x19Ethereum Signed Message:\n';
|
|
3
5
|
export function hashMessage(message) {
|
|
4
6
|
if (typeof message === 'string') {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "essential-eth",
|
|
3
3
|
"description": "Ultralight JS for Ethereum",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"private": false,
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"compile": "npm-run-all --parallel build:esm build:cjs build:umd",
|
|
48
48
|
"build": "rm -rf dist && npm run compile",
|
|
49
49
|
"build:esm": "tsc -p tsconfig.json",
|
|
50
|
-
"build:cjs": "
|
|
50
|
+
"build:cjs": "swc src -d dist/cjs",
|
|
51
51
|
"build:umd": "microbundle --external none --format umd",
|
|
52
52
|
"build:readme": "bash ./scripts/markdown-magic/build-readme.sh",
|
|
53
53
|
"jest": "jest",
|
|
@@ -62,6 +62,8 @@
|
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@size-limit/preset-small-lib": "^7.0.8",
|
|
65
|
+
"@swc/cli": "^0.1.57",
|
|
66
|
+
"@swc/core": "^1.3.21",
|
|
65
67
|
"@types/body-parser": "^1.19.1",
|
|
66
68
|
"@types/eslint": "^8.4.2",
|
|
67
69
|
"@types/express": "^4.17.13",
|
|
@@ -76,7 +78,7 @@
|
|
|
76
78
|
"eslint": "^8.16.0",
|
|
77
79
|
"eslint-plugin-jest": "^26.2.2",
|
|
78
80
|
"eslint-plugin-jsdoc": "38.0.2",
|
|
79
|
-
"ethers": "^5.7.
|
|
81
|
+
"ethers": "^5.7.2",
|
|
80
82
|
"express": "^4.17.1",
|
|
81
83
|
"husky": "^7.0.4",
|
|
82
84
|
"jest": "^27.5.1",
|
|
@@ -86,18 +88,18 @@
|
|
|
86
88
|
"microbundle": "^0.15.0",
|
|
87
89
|
"npm-run-all": "^4.1.5",
|
|
88
90
|
"perf_hooks": "^0.0.1",
|
|
89
|
-
"prettier": "^2.
|
|
91
|
+
"prettier": "^2.8.4",
|
|
90
92
|
"prettier-plugin-organize-imports": "^2.3.4",
|
|
91
93
|
"size-limit": "^7.0.8",
|
|
92
94
|
"ts-jest": "^27.1.4",
|
|
93
95
|
"ts-node": "^10.2.1",
|
|
94
96
|
"typedoc": "^0.22.15",
|
|
95
97
|
"typescript": "^4.6.4",
|
|
96
|
-
"web3": "^1.
|
|
98
|
+
"web3": "^1.8.1"
|
|
97
99
|
},
|
|
98
100
|
"dependencies": {
|
|
99
101
|
"@noble/secp256k1": "^1.5.5",
|
|
100
|
-
"@types/big.js": "^6.1.
|
|
102
|
+
"@types/big.js": "^6.1.6",
|
|
101
103
|
"big.js": "^6.2.1",
|
|
102
104
|
"isomorphic-unfetch": "^3.1.0",
|
|
103
105
|
"sha3": "^2.1.4"
|
package/readme.md
CHANGED
|
@@ -100,8 +100,12 @@
|
|
|
100
100
|
- [Contract](#contract)
|
|
101
101
|
- [`contractFunctionName(args)`](#contractfunctionnameargs)
|
|
102
102
|
- [More Info](#more-info)
|
|
103
|
-
- [Identical vs Similar vs
|
|
103
|
+
- [Identical vs Similar vs Dissimilar {#isd}](#identical-vs-similar-vs-dissimilar-isd)
|
|
104
104
|
- [Miscellaneous](#miscellaneous)
|
|
105
|
+
- [GitPOAP](#gitpoap)
|
|
106
|
+
- [What is a GitPOAP?](#what-is-a-gitpoap)
|
|
107
|
+
- [How can I claim?](#how-can-i-claim)
|
|
108
|
+
- [What issues should I start on first?](#what-issues-should-i-start-on-first)
|
|
105
109
|
|
|
106
110
|
</details>
|
|
107
111
|
|
|
@@ -124,7 +128,7 @@ Browsers:
|
|
|
124
128
|
|
|
125
129
|
```html
|
|
126
130
|
<!-- index.html -->
|
|
127
|
-
<script src="https://unpkg.com/essential-eth@0.
|
|
131
|
+
<script src="https://unpkg.com/essential-eth@0.7.0"></script>
|
|
128
132
|
```
|
|
129
133
|
|
|
130
134
|
<!-- ⛔️ AUTO-GENERATED-CONTENT:END (UNPKG_SCRIPT_TAG) -->
|
|
@@ -1473,6 +1477,7 @@ Decoding support:
|
|
|
1473
1477
|
- `uint256`
|
|
1474
1478
|
- `bytes32`
|
|
1475
1479
|
- `uint8`
|
|
1480
|
+
- `string` (only if there is one string output, not multiple yet)
|
|
1476
1481
|
|
|
1477
1482
|
_Assume all types outside the above types will break for now_
|
|
1478
1483
|
|
|
@@ -1535,7 +1540,7 @@ Any function on a contract. Returns are the same as `ethers.js`, except that ins
|
|
|
1535
1540
|
|
|
1536
1541
|
<br/>
|
|
1537
1542
|
|
|
1538
|
-
### Identical vs Similar vs
|
|
1543
|
+
### Identical vs Similar vs Dissimilar {#isd}
|
|
1539
1544
|
|
|
1540
1545
|
Throughout the documentation for `essential-eth`, you may notice that some functions are compared to `ethers.js` and `web3.js`. The keywords `identical`, `similar`, and `dissimilar` are used to help you migrate to `essential-eth`. Here's a guide on what these keywords mean:
|
|
1541
1546
|
|
|
@@ -1549,3 +1554,29 @@ Note: In `web3.js`, almost every method or function can be passed a callback. `e
|
|
|
1549
1554
|
|
|
1550
1555
|
- [📓 View full docs](https://eeth.dev)
|
|
1551
1556
|
- [📓 View changelog (by looking at releases diff)](https://github.com/dawsbot/essential-eth/releases)
|
|
1557
|
+
|
|
1558
|
+
### GitPOAP
|
|
1559
|
+
|
|
1560
|
+
In partnership with GitPOAP, Essential ETH wants to recognize **all** contributors for their contributions toward the growth of this library. Developers can validate their contributions on Github and showcase their GitPOAP as proof-of-work toward their Web3 identity.
|
|
1561
|
+
|
|
1562
|
+
<br/>
|
|
1563
|
+
|
|
1564
|
+

|
|
1565
|
+
|
|
1566
|
+
<br/>
|
|
1567
|
+
|
|
1568
|
+
#### What is a GitPOAP?
|
|
1569
|
+
|
|
1570
|
+
GitPOAP is a contributor recognition platform built on top of the POAP Protocol (Proof of Attendance Protocol). Similar to a POAP, each GitPOAP represents a digital collectible. It serves as a badge of validation for the action taken by the individual. By serving as a bridge between Github and Web3, it allows repo maintainers to recognize contributors for their meaningful contributions. Learn more about GitPOAP, [here](https://www.gitpoap.io/).
|
|
1571
|
+
|
|
1572
|
+
#### How can I claim?
|
|
1573
|
+
|
|
1574
|
+
Here are two steps that you can take to qualify for a GitPOAP:
|
|
1575
|
+
|
|
1576
|
+
1. Contribute to [any open issue](https://github.com/dawsbot/essential-eth/issues) and submit a PR. Upon approval of PR merge, the GitPOAP will automatically be issued to the Github account.
|
|
1577
|
+
|
|
1578
|
+
2. Head to gitpoap.io and connect your GitHub account to mint!
|
|
1579
|
+
|
|
1580
|
+
#### What issues should I start on first?
|
|
1581
|
+
|
|
1582
|
+
We have set up a GitHub project [here](https://github.com/dawsbot/essential-eth/projects/1) for you to see all the issues by priority.
|