essential-eth 0.8.0 → 0.9.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.
@@ -1,9 +1,17 @@
1
1
  import { logger } from '../logger/logger';
2
2
  import { BaseProvider } from './BaseProvider';
3
- const promiseTimeout = (prom, time) => Promise.race([
4
- prom,
5
- new Promise((_r, reject) => setTimeout(() => reject('Promise timed out'), time)),
6
- ]);
3
+ const promiseTimeout = (prom, time) => new Promise((resolve, reject) => {
4
+ const timeout = setTimeout(() => reject(new Error('Promise timed out')), time);
5
+ prom
6
+ .then((result) => {
7
+ clearTimeout(timeout);
8
+ resolve(result);
9
+ })
10
+ .catch((error) => {
11
+ clearTimeout(timeout);
12
+ reject(error);
13
+ });
14
+ });
7
15
  const DEFAULT_TIMEOUT_DURATION = 8000;
8
16
  export class FallthroughProvider extends BaseProvider {
9
17
  constructor(rpcUrls, options = {}) {
@@ -0,0 +1,2 @@
1
+ /// <reference types="jest" />
2
+ export declare const mockOf: <FunctionParameters extends unknown[], FunctionReturnType>(fn: (...args: FunctionParameters) => FunctionReturnType) => jest.Mock<FunctionReturnType, FunctionParameters>;
@@ -0,0 +1 @@
1
+ export const mockOf = (fn) => fn;
@@ -1,11 +1,16 @@
1
+ import z from 'zod';
1
2
  export const fakeUrls = {
2
3
  notRPCButRealHttp: 'https://httpstat.us/200',
3
4
  };
5
+ const RPC_ORIGIN = process.env.RPC_ORIGIN;
6
+ if (!z.string().url().safeParse(RPC_ORIGIN).success) {
7
+ throw new Error('RPC_ORIGIN is not defined or is invalid URL');
8
+ }
4
9
  export const rpcUrls = {
5
- mainnet: `${process.env.RPC_ORIGIN}/api/eth`,
6
- matic: `${process.env.RPC_ORIGIN}/api/MATIC`,
7
- gno: `${process.env.RPC_ORIGIN}/api/gno`,
8
- bnb: `${process.env.RPC_ORIGIN}/api/bnb`,
9
- arb1: `${process.env.RPC_ORIGIN}/api/arb1`,
10
- gor: `${process.env.RPC_ORIGIN}/api/gor`,
10
+ mainnet: `${RPC_ORIGIN}/api/eth`,
11
+ matic: `${RPC_ORIGIN}/api/MATIC`,
12
+ gno: `${RPC_ORIGIN}/api/gno`,
13
+ bnb: `${RPC_ORIGIN}/api/bnb`,
14
+ arb1: `${RPC_ORIGIN}/api/arb1`,
15
+ gor: `${RPC_ORIGIN}/api/gor`,
11
16
  };
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.8.0",
4
+ "version": "0.9.0",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
7
7
  "private": false,
@@ -40,7 +40,7 @@
40
40
  }
41
41
  ],
42
42
  "scripts": {
43
- "size": "size-limit",
43
+ "size": "npx size-limit",
44
44
  "test": "npm-run-all --parallel jest compile lint",
45
45
  "test:all-node-versions": "npx trevor",
46
46
  "lint": "eslint --cache --fix .",
@@ -90,12 +90,12 @@
90
90
  "perf_hooks": "^0.0.1",
91
91
  "prettier": "^2.8.4",
92
92
  "prettier-plugin-organize-imports": "^2.3.4",
93
- "size-limit": "^7.0.8",
94
93
  "ts-jest": "^27.1.4",
95
94
  "ts-node": "^10.2.1",
96
95
  "typedoc": "^0.22.15",
97
96
  "typescript": "^4.6.4",
98
- "web3": "^1.8.1"
97
+ "web3": "^1.8.1",
98
+ "zod": "^3.21.4"
99
99
  },
100
100
  "dependencies": {
101
101
  "@noble/secp256k1": "^1.5.5",
package/readme.md CHANGED
@@ -129,7 +129,7 @@ Browsers:
129
129
 
130
130
  ```html
131
131
  <!-- index.html -->
132
- <script src="https://unpkg.com/essential-eth@0.8.0"></script>
132
+ <script src="https://unpkg.com/essential-eth@0.9.0"></script>
133
133
  ```
134
134
 
135
135
  <!-- ⛔️ AUTO-GENERATED-CONTENT:END (UNPKG_SCRIPT_TAG) -->
@@ -1583,6 +1583,7 @@ Note: In `web3.js`, almost every method or function can be passed a callback. `e
1583
1583
 
1584
1584
  - [📓 View full docs](https://eeth.dev)
1585
1585
  - [📓 View changelog (by looking at releases diff)](https://github.com/dawsbot/essential-eth/releases)
1586
+ - [📋 View our project board](https://github.com/dawsbot/essential-eth/projects/1)
1586
1587
 
1587
1588
  ### GitPOAP
1588
1589