essential-eth 0.9.2 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- export declare const version = "0.9.2";
1
+ export declare const version = "0.10.2";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // Generated by genversion.
5
- exports.version = '0.9.2';
5
+ exports.version = '0.10.2';
@@ -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) => jest.Mock<FunctionReturnType, FunctionParameters>;
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: `${RPC_ORIGIN}/api/eth`,
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,79 +1,4 @@
1
1
  export const abi = [
2
- {
3
- name: 'Fund',
4
- inputs: [
5
- {
6
- type: 'address',
7
- name: 'recipient',
8
- indexed: true,
9
- },
10
- {
11
- type: 'uint256',
12
- name: 'amount',
13
- indexed: false,
14
- },
15
- ],
16
- anonymous: false,
17
- type: 'event',
18
- },
19
- {
20
- name: 'Claim',
21
- inputs: [
22
- {
23
- type: 'address',
24
- name: 'recipient',
25
- indexed: true,
26
- },
27
- {
28
- type: 'uint256',
29
- name: 'claimed',
30
- indexed: false,
31
- },
32
- ],
33
- anonymous: false,
34
- type: 'event',
35
- },
36
- {
37
- name: 'ToggleDisable',
38
- inputs: [
39
- {
40
- type: 'address',
41
- name: 'recipient',
42
- indexed: false,
43
- },
44
- {
45
- type: 'bool',
46
- name: 'disabled',
47
- indexed: false,
48
- },
49
- ],
50
- anonymous: false,
51
- type: 'event',
52
- },
53
- {
54
- name: 'CommitOwnership',
55
- inputs: [
56
- {
57
- type: 'address',
58
- name: 'admin',
59
- indexed: false,
60
- },
61
- ],
62
- anonymous: false,
63
- type: 'event',
64
- },
65
- {
66
- name: 'ApplyOwnership',
67
- inputs: [
68
- {
69
- type: 'address',
70
- name: 'admin',
71
- indexed: false,
72
- },
73
- ],
74
- anonymous: false,
75
- type: 'event',
76
- },
77
2
  {
78
3
  outputs: [],
79
4
  inputs: [
@@ -0,0 +1,2 @@
1
+ import type { JSONABI } from '../../../types/Contract.types';
2
+ export declare const abi: JSONABI;
@@ -0,0 +1,18 @@
1
+ export const abi = [
2
+ {
3
+ payable: false,
4
+ name: 'getAllAddressesThatHaveVoted',
5
+ outputs: [{ type: 'address[]', name: '' }],
6
+ inputs: [],
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',
17
+ },
18
+ ];
@@ -28,7 +28,7 @@ function expandType(type) {
28
28
  if (type === 'uint[]') {
29
29
  return 'uint256[]';
30
30
  }
31
- else if (type === 'int[]') {
31
+ if (type === 'int[]') {
32
32
  return 'int256[]';
33
33
  }
34
34
  return type;
@@ -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 (jsonABIArgument?.outputs?.length === 1 &&
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),
@@ -109,9 +108,21 @@ export function decodeRPCResponse(jsonABIArgument, nodeResponse) {
109
108
  const hexToDecode = responseData.slice(decimalOffset * 2, decimalOffset * 2 + decimalLength * 2);
110
109
  return hexToUtf8(hexToDecode);
111
110
  }
112
- const encodedOutputs = slicedResponse.match(/.{1,64}/g);
113
- const outputs = (encodedOutputs || []).map((output, i) => {
114
- const outputType = (rawOutputs || [])[i].type;
111
+ const encodedOutputs = slicedResponse.match(/.{1,64}/g) || [];
112
+ if (rawOutputs.length === 1 && rawOutputs[0].type === 'address[]') {
113
+ const unformattedAddresses = encodedOutputs.slice(2);
114
+ return unformattedAddresses.map((unformattedAddress) => {
115
+ return toChecksumAddress(`0x${unformattedAddress.slice(24)}`);
116
+ });
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
+ }
124
+ const outputs = encodedOutputs.map((output, i) => {
125
+ const outputType = rawOutputs[i].type;
115
126
  switch (outputType) {
116
127
  case 'bool':
117
128
  return output === hexTrue;
@@ -1,13 +1,14 @@
1
- export { Contract, BaseContract } from './classes/Contract';
1
+ export { BaseContract, Contract } from './classes/Contract';
2
2
  export { AlchemyProvider } from './providers/AlchemyProvider';
3
- export { FallthroughProvider, ConstructorOptions, } from './providers/FallthroughProvider';
3
+ export { ConstructorOptions, FallthroughProvider, } from './providers/FallthroughProvider';
4
4
  export { jsonRpcProvider, JsonRpcProvider } from './providers/JsonRpcProvider';
5
5
  export { tinyBig, TinyBig } from './shared/tiny-big/tiny-big';
6
- export { BlockResponse, RPCBlock, BlockTag } from './types/Block.types';
6
+ export { BlockResponse, BlockTag, RPCBlock } from './types/Block.types';
7
7
  export { ContractTypes, JSONABI, JSONABIArgument, } from './types/Contract.types';
8
8
  export { Filter, FilterByBlockHash } from './types/Filter.types';
9
9
  export { Network } from './types/Network.types';
10
- export { TransactionResponse, RPCTransaction, RPCTransactionReceipt, TransactionRequest, RPCTransactionRequest, TransactionReceipt, RPCLog, Log, BlockTransactionResponse, } from './types/Transaction.types';
10
+ export { BlockTransactionResponse, Log, RPCLog, RPCTransaction, RPCTransactionReceipt, RPCTransactionRequest, TransactionReceipt, TransactionRequest, TransactionResponse, } from './types/Transaction.types';
11
+ export { arrayify, Bytes, BytesLike, BytesLikeWithNumber, concat, DataOptions, Hexable, hexConcat, hexDataLength, hexDataSlice, hexlify, hexStripZeros, hexValue, hexZeroPad, isBytes, isBytesLike, isHexString, Signature, SignatureLike, stripZeros, zeroPad, } from './utils/bytes';
11
12
  export { computeAddress } from './utils/compute-address';
12
13
  export { computePublicKey } from './utils/compute-public-key';
13
14
  export { etherToGwei } from './utils/ether-to-gwei';
@@ -15,10 +16,9 @@ export { etherToWei } from './utils/ether-to-wei';
15
16
  export { gweiToEther } from './utils/gwei-to-ether';
16
17
  export { hashMessage } from './utils/hash-message';
17
18
  export { isAddress } from './utils/is-address';
19
+ export { keccak256 } from './utils/keccak256';
20
+ export { pack, solidityKeccak256 } from './utils/solidity-keccak256';
18
21
  export { splitSignature } from './utils/split-signature';
19
22
  export { toChecksumAddress } from './utils/to-checksum-address';
20
23
  export { toUtf8Bytes } from './utils/to-utf8-bytes';
21
24
  export { weiToEther } from './utils/wei-to-ether';
22
- export { Bytes, BytesLike, BytesLikeWithNumber, DataOptions, Hexable, SignatureLike, Signature, isBytesLike, isBytes, arrayify, concat, stripZeros, zeroPad, isHexString, hexlify, hexDataLength, hexDataSlice, hexConcat, hexValue, hexStripZeros, hexZeroPad, } from './utils/bytes';
23
- export { keccak256 } from './utils/keccak256';
24
- export { pack, solidityKeccak256 } from './utils/solidity-keccak256';
package/dist/esm/index.js CHANGED
@@ -1,8 +1,9 @@
1
- export { Contract, BaseContract } from './classes/Contract';
1
+ export { BaseContract, Contract } from './classes/Contract';
2
2
  export { AlchemyProvider } from './providers/AlchemyProvider';
3
3
  export { FallthroughProvider, } from './providers/FallthroughProvider';
4
4
  export { jsonRpcProvider, JsonRpcProvider } from './providers/JsonRpcProvider';
5
5
  export { tinyBig, TinyBig } from './shared/tiny-big/tiny-big';
6
+ export { arrayify, concat, hexConcat, hexDataLength, hexDataSlice, hexlify, hexStripZeros, hexValue, hexZeroPad, isBytes, isBytesLike, isHexString, stripZeros, zeroPad, } from './utils/bytes';
6
7
  export { computeAddress } from './utils/compute-address';
7
8
  export { computePublicKey } from './utils/compute-public-key';
8
9
  export { etherToGwei } from './utils/ether-to-gwei';
@@ -10,10 +11,9 @@ export { etherToWei } from './utils/ether-to-wei';
10
11
  export { gweiToEther } from './utils/gwei-to-ether';
11
12
  export { hashMessage } from './utils/hash-message';
12
13
  export { isAddress } from './utils/is-address';
14
+ export { keccak256 } from './utils/keccak256';
15
+ export { pack, solidityKeccak256 } from './utils/solidity-keccak256';
13
16
  export { splitSignature } from './utils/split-signature';
14
17
  export { toChecksumAddress } from './utils/to-checksum-address';
15
18
  export { toUtf8Bytes } from './utils/to-utf8-bytes';
16
19
  export { weiToEther } from './utils/wei-to-ether';
17
- export { isBytesLike, isBytes, arrayify, concat, stripZeros, zeroPad, isHexString, hexlify, hexDataLength, hexDataSlice, hexConcat, hexValue, hexStripZeros, hexZeroPad, } from './utils/bytes';
18
- export { keccak256 } from './utils/keccak256';
19
- export { pack, solidityKeccak256 } from './utils/solidity-keccak256';
@@ -1 +1 @@
1
- export declare const version = "0.9.2";
1
+ export declare const version = "0.10.2";
@@ -1 +1 @@
1
- export const version = '0.9.2';
1
+ export const version = '0.10.2';
@@ -1,2 +1 @@
1
- /// <reference types="jest" />
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: `${RPC_ORIGIN}/api/eth`,
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.9.2",
4
+ "version": "0.10.2",
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 jest compile lint",
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
- "jest": "jest",
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": "npx genversion --es6 src/logger/package-version.ts && git add src/logger/package-version.ts",
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
  },
@@ -93,7 +89,10 @@
93
89
  "prettier": {
94
90
  "trailingComma": "all",
95
91
  "tabWidth": 2,
96
- "singleQuote": true
92
+ "singleQuote": true,
93
+ "plugins": [
94
+ "prettier-plugin-organize-imports"
95
+ ]
97
96
  },
98
97
  "keywords": [
99
98
  "ethereum",
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.9.2"></script>
129
+ <script src="https://unpkg.com/essential-eth@0.10.2"></script>
130
130
  ```
131
131
 
132
132
  <!-- ⛔️ AUTO-GENERATED-CONTENT:END (UNPKG_SCRIPT_TAG) -->