Skip to content

Commit

Permalink
v9.7.3: fix more rpcs and add test:rpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNe0x1 committed Nov 8, 2024
1 parent 66691d2 commit 58b7960
Show file tree
Hide file tree
Showing 13 changed files with 153 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
node-version: '18.x'
- name: Cache node modules
uses: actions/cache@v2
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v2
with:
node-version: '16.x'
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- run: npm install

Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/test-rpc-availability.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test RPC Availability

on:
push:
branches:
- '*' # Matches all branches
schedule:
# Runs at 05:00 UTC every day
- cron: '0 5 * * *'

jobs:
daily-job:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '18.x'
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: npm install
run: |
npm install
- name: npm run build
run: |
npm run build
- name: Run Tests
run: |
yarn test:rpcs
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
node-version: '18.x'
- name: Cache node modules
uses: actions/cache@v2
env:
Expand Down
10 changes: 5 additions & 5 deletions dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ var ethereum = {
if(address) { return `https://etherscan.io/address/${address}` }
},
endpoints: [ // make sure provider supports batch size of 50 batch requests!
'https://eth.rpc.blxrbdn.com',
'https://eth.llamarpc.com',
'https://ethereum.publicnode.com'
'https://ethereum.publicnode.com',
'https://ethereum.rpc.subquery.network/public'
],
tokens: [ // only major tokens
{"address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", "symbol": "ETH", "name": "Ether", "decimals": 18, "logo": currencyLogo$5, "type": "NATIVE"},
Expand Down Expand Up @@ -366,7 +366,8 @@ var avalanche = {
},
endpoints: [ // make sure provider supports batch size of 50 batch requests!
'https://avalanche-c-chain-rpc.publicnode.com',
'https://endpoints.omniatech.io/v1/avax/mainnet/public'
'https://avalanche-c-chain.publicnode.com',
'https://avalanche-api.flare.network/ext/bc/C/rpc',
],
tokens: [ // only major tokens
{"address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", "symbol": "AVAX", "name": "Avalanche", "decimals": 18, "logo": currencyLogo$1, "type": "NATIVE"},
Expand Down Expand Up @@ -572,8 +573,7 @@ var worldchain = {
},
endpoints: [ // make sure provider supports batch size of 50 batch requests!
'https://worldchain-mainnet.g.alchemy.com/public',
'https://480.rpc.thirdweb.com',
'https://worldchain-mainnet.blastapi.io/1b1a6314-79bf-4afe-b48b-c943fca35292'
'https://480.rpc.thirdweb.com'
],
tokens: [ // only major tokens
{"address": "0x2cFc85d8E48F8EAB294be644d9E25C3030863003", "symbol": "WLD", "name": "Worldcoin", "decimals": 18, "logo": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/optimism/assets/0xdC6fF44d5d932Cbd77B52E5612Ba0529DC6226F1/logo.png", "type": "20"},
Expand Down
10 changes: 5 additions & 5 deletions dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@
if(address) { return `https://etherscan.io/address/${address}` }
},
endpoints: [ // make sure provider supports batch size of 50 batch requests!
'https://eth.rpc.blxrbdn.com',
'https://eth.llamarpc.com',
'https://ethereum.publicnode.com'
'https://ethereum.publicnode.com',
'https://ethereum.rpc.subquery.network/public'
],
tokens: [ // only major tokens
{"address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", "symbol": "ETH", "name": "Ether", "decimals": 18, "logo": currencyLogo$5, "type": "NATIVE"},
Expand Down Expand Up @@ -372,7 +372,8 @@
},
endpoints: [ // make sure provider supports batch size of 50 batch requests!
'https://avalanche-c-chain-rpc.publicnode.com',
'https://endpoints.omniatech.io/v1/avax/mainnet/public'
'https://avalanche-c-chain.publicnode.com',
'https://avalanche-api.flare.network/ext/bc/C/rpc',
],
tokens: [ // only major tokens
{"address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", "symbol": "AVAX", "name": "Avalanche", "decimals": 18, "logo": currencyLogo$1, "type": "NATIVE"},
Expand Down Expand Up @@ -578,8 +579,7 @@
},
endpoints: [ // make sure provider supports batch size of 50 batch requests!
'https://worldchain-mainnet.g.alchemy.com/public',
'https://480.rpc.thirdweb.com',
'https://worldchain-mainnet.blastapi.io/1b1a6314-79bf-4afe-b48b-c943fca35292'
'https://480.rpc.thirdweb.com'
],
tokens: [ // only major tokens
{"address": "0x2cFc85d8E48F8EAB294be644d9E25C3030863003", "symbol": "WLD", "name": "Worldcoin", "decimals": 18, "logo": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/optimism/assets/0xdC6fF44d5d932Cbd77B52E5612Ba0529DC6226F1/logo.png", "type": "20"},
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-blockchains",
"moduleName": "Web3Blockchains",
"version": "9.7.2",
"version": "9.7.3",
"description": "JavaScript library containing aggregated information and abstractions for web3 blockchains.",
"main": "dist/umd/index.js",
"module": "dist/esm/index.js",
Expand All @@ -15,7 +15,8 @@
"lint:fix": "eslint \"src/**/*.{js,jsx,ts,tsx}\" --fix",
"dev": "rollup -c rollup.dev.config.js -w",
"test:units": "yarn build && npx jest --no-cache",
"test": "yarn test:units"
"test": "yarn test:units",
"test:rpcs": "npx jest --no-cache test.rpc.availability.spec.js"
},
"repository": "[email protected]:DePayFi/web3-blockchains.git",
"keywords": [
Expand All @@ -32,7 +33,7 @@
"dependencies": {},
"peerDependencies": {},
"engines": {
"node": ">=10"
"node": ">=18"
},
"devDependencies": {
"@babel/core": "^7.12.9",
Expand All @@ -43,6 +44,7 @@
"@rollup/plugin-sucrase": "^3.1.0",
"babel-loader": "^8.2.2",
"babel-preset-env": "^1.7.0",
"cross-fetch": "^4.0.0",
"eslint": "^7.15.0",
"eslint-plugin-import": "^2.22.1",
"eslint-webpack-plugin": "^3.0.1",
Expand Down
3 changes: 2 additions & 1 deletion src/blockchains/avalanche.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export default {
},
endpoints: [ // make sure provider supports batch size of 50 batch requests!
'https://avalanche-c-chain-rpc.publicnode.com',
'https://endpoints.omniatech.io/v1/avax/mainnet/public'
'https://avalanche-c-chain.publicnode.com',
'https://avalanche-api.flare.network/ext/bc/C/rpc',
],
tokens: [ // only major tokens
{"address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", "symbol": "AVAX", "name": "Avalanche", "decimals": 18, "logo": currencyLogo, "type": "NATIVE"},
Expand Down
4 changes: 2 additions & 2 deletions src/blockchains/ethereum.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/blockchains/worldchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export default {
},
endpoints: [ // make sure provider supports batch size of 50 batch requests!
'https://worldchain-mainnet.g.alchemy.com/public',
'https://480.rpc.thirdweb.com',
'https://worldchain-mainnet.blastapi.io/1b1a6314-79bf-4afe-b48b-c943fca35292'
'https://480.rpc.thirdweb.com'
],
tokens: [ // only major tokens
{"address": "0x2cFc85d8E48F8EAB294be644d9E25C3030863003", "symbol": "WLD", "name": "Worldcoin", "decimals": 18, "logo": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/optimism/assets/0xdC6fF44d5d932Cbd77B52E5612Ba0529DC6226F1/logo.png", "type": "20"},
Expand Down
2 changes: 2 additions & 0 deletions tests/setup.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
import 'regenerator-runtime/runtime'

global.fetch = require('cross-fetch')
55 changes: 55 additions & 0 deletions tests/units/test.rpc.availability.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import Blockchains from 'src';

describe('test RPC availability', () => {

Blockchains.all.filter((blockchain)=>!['solana'].includes(blockchain.name)).forEach((blockchain)=>{

describe(blockchain.label, ()=>{

blockchain.endpoints.forEach((endpoint)=>{

it(`${endpoint} works with up to 50 subrequests`, async()=>{

let response = await fetch(endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(
Array.from({ length: 50 }, (_, index)=> index+1).map((index)=> {
return(
{
"jsonrpc": "2.0",
"id": index,
"method": "eth_call",
"params": [
{
"to":"0x1f98431c8ad98523631ae4a59f267346ea31f984",
"data":"0x1698ee82000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000064"
} ,"latest"
]
}
)
})
)
})

if (!response.ok) {
throw new Error('Network response was not ok')
}

let json = await response.json()
await Promise.all(json.map((item)=>{
return new Promise((resolve, reject)=>{
if(item.result && !item.error){
resolve()
} else {
reject('ERROR FOUND')
}
})
}))
})
})
})
})
})
32 changes: 32 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2029,6 +2029,13 @@ core-js@^2.4.0:
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec"
integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==

cross-fetch@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-4.0.0.tgz#f037aef1580bb3a1a35164ea2a848ba81b445983"
integrity sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==
dependencies:
node-fetch "^2.6.12"

cross-spawn@^7.0.2:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
Expand Down Expand Up @@ -3250,6 +3257,13 @@ natural-compare@^1.4.0:
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=

node-fetch@^2.6.12:
version "2.7.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d"
integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==
dependencies:
whatwg-url "^5.0.0"

node-modules-regexp@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz#8d9dbe28964a4ac5712e9131642107c71e90ec40"
Expand Down Expand Up @@ -4024,6 +4038,11 @@ tr46@^3.0.0:
dependencies:
punycode "^2.1.1"

tr46@~0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==

ts-interface-checker@^0.1.9:
version "0.1.13"
resolved "https://registry.yarnpkg.com/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz#784fd3d679722bc103b1b4b8030bcddb5db2a699"
Expand Down Expand Up @@ -4134,6 +4153,11 @@ w3c-xmlserializer@^3.0.0:
dependencies:
xml-name-validator "^4.0.0"

webidl-conversions@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==

webidl-conversions@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-7.0.0.tgz#256b4e1882be7debbf01d05f0aa2039778ea080a"
Expand Down Expand Up @@ -4167,6 +4191,14 @@ whatwg-url@^11.0.0:
tr46 "^3.0.0"
webidl-conversions "^7.0.0"

whatwg-url@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==
dependencies:
tr46 "~0.0.3"
webidl-conversions "^3.0.0"

which-boxed-primitive@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6"
Expand Down

0 comments on commit 58b7960

Please sign in to comment.