essential-eth 0.10.0 → 0.10.3
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/test/Contract/jokerrace-abi.js +11 -0
- package/dist/cjs/classes/utils/encode-decode-transaction.js +15 -12
- package/dist/cjs/index.umd.js +1 -1
- package/dist/cjs/index.umd.js.map +1 -1
- package/dist/cjs/logger/package-version.d.ts +1 -1
- package/dist/cjs/logger/package-version.js +1 -1
- package/dist/cjs/providers/test/mock-of.d.ts +1 -2
- package/dist/cjs/providers/test/rpc-urls.js +3 -1
- package/dist/esm/classes/test/Contract/jokerrace-abi.js +10 -0
- package/dist/esm/classes/utils/encode-decode-transaction.js +15 -11
- package/dist/esm/logger/package-version.d.ts +1 -1
- package/dist/esm/logger/package-version.js +1 -1
- package/dist/esm/providers/test/mock-of.d.ts +1 -2
- package/dist/esm/providers/test/rpc-urls.js +3 -1
- package/package.json +7 -11
- package/readme.md +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.10.
|
|
1
|
+
export declare const version = "0.10.3";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
1
|
/**
|
|
3
2
|
* Helper function for mocking other functions.
|
|
4
3
|
*
|
|
@@ -6,4 +5,4 @@
|
|
|
6
5
|
* @example mockOf(stripe.checkout.sessions.create).mockResolvedValue(mockSession);
|
|
7
6
|
* @see https://twitter.com/scastiel/status/1631354119192473601?s=20
|
|
8
7
|
*/
|
|
9
|
-
export declare const mockOf: <FunctionParameters extends unknown[], FunctionReturnType>(fn: (...args: FunctionParameters) => FunctionReturnType) =>
|
|
8
|
+
export declare const mockOf: <FunctionParameters extends unknown[], FunctionReturnType>(fn: (...args: FunctionParameters) => FunctionReturnType) => (...args: FunctionParameters) => FunctionReturnType;
|
|
@@ -14,8 +14,10 @@ zod_1.default.string({
|
|
|
14
14
|
})
|
|
15
15
|
.url('Expected url for "RPC_ORIGIN"')
|
|
16
16
|
.parse(RPC_ORIGIN);
|
|
17
|
+
const ALCHEMY_API_KEY = process.env.ALCHEMY_API_KEY;
|
|
18
|
+
const MAINNET_RPC_ORIGIN = `https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`;
|
|
17
19
|
exports.rpcUrls = {
|
|
18
|
-
mainnet:
|
|
20
|
+
mainnet: MAINNET_RPC_ORIGIN,
|
|
19
21
|
oeth: `${RPC_ORIGIN}/api/oeth`,
|
|
20
22
|
matic: `${RPC_ORIGIN}/api/MATIC`,
|
|
21
23
|
gno: `${RPC_ORIGIN}/api/gno`,
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
export const abi = [
|
|
2
2
|
{
|
|
3
|
+
payable: false,
|
|
3
4
|
name: 'getAllAddressesThatHaveVoted',
|
|
4
5
|
outputs: [{ type: 'address[]', name: '' }],
|
|
5
6
|
inputs: [],
|
|
6
7
|
type: 'function',
|
|
8
|
+
stateMutability: 'view',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
payable: false,
|
|
12
|
+
name: 'getAllProposalIds',
|
|
13
|
+
outputs: [{ type: 'uint256[]', name: '' }],
|
|
14
|
+
inputs: [],
|
|
15
|
+
type: 'function',
|
|
16
|
+
stateMutability: 'view',
|
|
7
17
|
},
|
|
8
18
|
];
|
|
@@ -67,11 +67,11 @@ export function encodeData(jsonABIArgument, args) {
|
|
|
67
67
|
break;
|
|
68
68
|
default:
|
|
69
69
|
if (inputType.startsWith('bytes')) {
|
|
70
|
-
|
|
71
|
-
.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const paddedEncodedArg = argEncoded.
|
|
70
|
+
if (Array.isArray(arg)) {
|
|
71
|
+
throw new Error(`essential-eth does not yet support "${inputType}[]" inputs. Make a PR today!"`);
|
|
72
|
+
}
|
|
73
|
+
const argEncoded = BigInt(arg).toString(16);
|
|
74
|
+
const paddedEncodedArg = argEncoded.padStart(64, '0');
|
|
75
75
|
return paddedEncodedArg;
|
|
76
76
|
}
|
|
77
77
|
else if (inputType === 'uint256') {
|
|
@@ -95,10 +95,9 @@ export function encodeData(jsonABIArgument, args) {
|
|
|
95
95
|
return data;
|
|
96
96
|
}
|
|
97
97
|
export function decodeRPCResponse(jsonABIArgument, nodeResponse) {
|
|
98
|
-
const rawOutputs = jsonABIArgument.outputs;
|
|
98
|
+
const rawOutputs = jsonABIArgument.outputs || [];
|
|
99
99
|
const slicedResponse = nodeResponse.slice(2);
|
|
100
|
-
if (
|
|
101
|
-
jsonABIArgument.outputs[0].type === 'string') {
|
|
100
|
+
if (rawOutputs.length === 1 && rawOutputs[0].type === 'string') {
|
|
102
101
|
const [hexOffset, responseData] = [
|
|
103
102
|
slicedResponse.slice(0, 64),
|
|
104
103
|
slicedResponse.slice(64),
|
|
@@ -110,15 +109,20 @@ export function decodeRPCResponse(jsonABIArgument, nodeResponse) {
|
|
|
110
109
|
return hexToUtf8(hexToDecode);
|
|
111
110
|
}
|
|
112
111
|
const encodedOutputs = slicedResponse.match(/.{1,64}/g) || [];
|
|
113
|
-
if (
|
|
114
|
-
jsonABIArgument.outputs[0].type === 'address[]') {
|
|
112
|
+
if (rawOutputs.length === 1 && rawOutputs[0].type === 'address[]') {
|
|
115
113
|
const unformattedAddresses = encodedOutputs.slice(2);
|
|
116
114
|
return unformattedAddresses.map((unformattedAddress) => {
|
|
117
115
|
return toChecksumAddress(`0x${unformattedAddress.slice(24)}`);
|
|
118
116
|
});
|
|
119
117
|
}
|
|
118
|
+
if (rawOutputs?.length === 1 && rawOutputs[0].type === 'uint256[]') {
|
|
119
|
+
const outputs = encodedOutputs.slice(2);
|
|
120
|
+
return outputs.map((output) => {
|
|
121
|
+
return tinyBig(hexToDecimal(`0x${output}`));
|
|
122
|
+
});
|
|
123
|
+
}
|
|
120
124
|
const outputs = encodedOutputs.map((output, i) => {
|
|
121
|
-
const outputType =
|
|
125
|
+
const outputType = rawOutputs[i].type;
|
|
122
126
|
switch (outputType) {
|
|
123
127
|
case 'bool':
|
|
124
128
|
return output === hexTrue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.10.
|
|
1
|
+
export declare const version = "0.10.3";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.10.
|
|
1
|
+
export const version = '0.10.3';
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const mockOf: <FunctionParameters extends unknown[], FunctionReturnType>(fn: (...args: FunctionParameters) => FunctionReturnType) => jest.Mock<FunctionReturnType, FunctionParameters>;
|
|
1
|
+
export declare const mockOf: <FunctionParameters extends unknown[], FunctionReturnType>(fn: (...args: FunctionParameters) => FunctionReturnType) => (...args: FunctionParameters) => FunctionReturnType;
|
|
@@ -8,8 +8,10 @@ z.string({
|
|
|
8
8
|
})
|
|
9
9
|
.url('Expected url for "RPC_ORIGIN"')
|
|
10
10
|
.parse(RPC_ORIGIN);
|
|
11
|
+
const ALCHEMY_API_KEY = process.env.ALCHEMY_API_KEY;
|
|
12
|
+
const MAINNET_RPC_ORIGIN = `https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`;
|
|
11
13
|
export const rpcUrls = {
|
|
12
|
-
mainnet:
|
|
14
|
+
mainnet: MAINNET_RPC_ORIGIN,
|
|
13
15
|
oeth: `${RPC_ORIGIN}/api/oeth`,
|
|
14
16
|
matic: `${RPC_ORIGIN}/api/MATIC`,
|
|
15
17
|
gno: `${RPC_ORIGIN}/api/gno`,
|
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.10.
|
|
4
|
+
"version": "0.10.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"type": "module",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"repository": "https://github.com/dawsbot/essential-eth.git",
|
|
28
28
|
"author": "@dawsbot",
|
|
29
29
|
"scripts": {
|
|
30
|
-
"test": "npm-run-all --parallel
|
|
30
|
+
"test": "npm-run-all --parallel vitest compile lint",
|
|
31
31
|
"test:all-node-versions": "npx trevor",
|
|
32
32
|
"lint": "eslint --cache --fix . --config .eslintrc.cjs",
|
|
33
33
|
"compile": "npm-run-all --parallel build:esm build:cjs build:umd",
|
|
@@ -36,23 +36,20 @@
|
|
|
36
36
|
"build:cjs": "tsc -p tsconfig-cjs.json && printf '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json",
|
|
37
37
|
"build:umd": "microbundle --external none --format umd",
|
|
38
38
|
"build:readme": "bash ./scripts/markdown-magic/build-readme.sh",
|
|
39
|
-
"
|
|
39
|
+
"vitest": "vitest run",
|
|
40
40
|
"build:chains-info": "npx tsx scripts/update-chains-info/index.ts # used in getNetwork()",
|
|
41
41
|
"update-deps": "sh ./scripts/pre-commit.sh",
|
|
42
42
|
"pre-commit": "npm run update-deps",
|
|
43
43
|
"prepare": "husky install",
|
|
44
|
-
"version": "
|
|
44
|
+
"version": "bunx genversion --es6 src/logger/package-version.ts && git add src/logger/package-version.ts",
|
|
45
45
|
"postversion": "git push --follow-tags",
|
|
46
46
|
"prepublishOnly": "npm run build",
|
|
47
47
|
"doc": "typedoc"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@size-limit/preset-small-lib": "^8.2.4",
|
|
51
|
-
"@swc/cli": "^0.1.62",
|
|
52
|
-
"@swc/core": "^1.3.53",
|
|
53
51
|
"@types/bn.js": "^5.1.1",
|
|
54
52
|
"@types/eslint": "^8.37.0",
|
|
55
|
-
"@types/jest": "^27.4.1",
|
|
56
53
|
"@types/node": "^18.16.0",
|
|
57
54
|
"@types/prettier": "^2.7.2",
|
|
58
55
|
"@typescript-eslint/eslint-plugin": "^5.59.0",
|
|
@@ -60,10 +57,9 @@
|
|
|
60
57
|
"bn.js": "^5.2.1",
|
|
61
58
|
"dotenv": "^16.0.0",
|
|
62
59
|
"eslint": "^8.16.0",
|
|
63
|
-
"eslint-plugin-jest": "^26.2.2",
|
|
64
60
|
"eslint-plugin-jsdoc": "^38.0.2",
|
|
61
|
+
"eslint-plugin-vitest": "^0.1.5",
|
|
65
62
|
"husky": "^7.0.4",
|
|
66
|
-
"jest": "^27.5.1",
|
|
67
63
|
"lint-staged": "^13.2.1",
|
|
68
64
|
"markdown-magic": "^2.6.1",
|
|
69
65
|
"microbundle": "^0.15.1",
|
|
@@ -71,16 +67,16 @@
|
|
|
71
67
|
"perf_hooks": "^0.0.1",
|
|
72
68
|
"prettier": "^3.2.5",
|
|
73
69
|
"prettier-plugin-organize-imports": "^3.2.4",
|
|
74
|
-
"ts-jest": "^27.1.4",
|
|
75
|
-
"ts-node": "^10.2.1",
|
|
76
70
|
"typedoc": "^0.24.5",
|
|
77
71
|
"typescript": "^4.9.4",
|
|
72
|
+
"vitest": "^0.34.6",
|
|
78
73
|
"zod": "^3.21.4"
|
|
79
74
|
},
|
|
80
75
|
"dependencies": {
|
|
81
76
|
"@noble/secp256k1": "^1.5.5",
|
|
82
77
|
"@types/big.js": "^6.1.6",
|
|
83
78
|
"big.js": "^6.2.1",
|
|
79
|
+
"ethers": "^5.7.2",
|
|
84
80
|
"isomorphic-unfetch": "^3.1.0",
|
|
85
81
|
"sha3": "^2.1.4"
|
|
86
82
|
},
|
package/readme.md
CHANGED
|
@@ -126,7 +126,7 @@ Browsers:
|
|
|
126
126
|
|
|
127
127
|
```html
|
|
128
128
|
<!-- index.html -->
|
|
129
|
-
<script src="https://unpkg.com/essential-eth@0.10.
|
|
129
|
+
<script src="https://unpkg.com/essential-eth@0.10.3"></script>
|
|
130
130
|
```
|
|
131
131
|
|
|
132
132
|
<!-- ⛔️ AUTO-GENERATED-CONTENT:END (UNPKG_SCRIPT_TAG) -->
|