Skip to content

Commit

Permalink
v10.18.8: fix and catch endpoint connection issues during endpoint setup
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNe0x1 committed Aug 16, 2024
1 parent 0c14a4c commit a54aef4
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 47 deletions.
2 changes: 1 addition & 1 deletion dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://cdn.ethers.io/lib/ethers-5.7.umd.min.js" type="application/javascript"></script>
<script crossorigin src="https://unpkg.com/@depay/solana-web3.js@1"></script>
<script crossorigin src="https://unpkg.com/@depay/[email protected].2"></script>
<script crossorigin src="https://unpkg.com/@depay/[email protected].3"></script>
<script src="tmp/index.dev.js"></script>
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions package.evm.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-client-evm",
"moduleName": "Web3Client",
"version": "10.18.7",
"version": "10.18.8",
"description": "A web3 client to fetch blockchain data just like you are used to with HTTP clients.",
"main": "dist/umd/index.evm.js",
"module": "dist/esm/index.evm.js",
Expand All @@ -23,7 +23,7 @@
"homepage": "https://depay.com",
"private": false,
"peerDependencies": {
"@depay/web3-blockchains": "^9.4.2",
"@depay/web3-blockchains": "^9.4.3",
"ethers": "^5.7.1"
},
"engines": {
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-client",
"moduleName": "Web3Client",
"version": "10.18.7",
"version": "10.18.8",
"description": "A web3 client to fetch blockchain data just like you are used to with HTTP clients.",
"main": "dist/umd/index.js",
"module": "dist/esm/index.js",
Expand Down Expand Up @@ -33,8 +33,8 @@
"homepage": "https://depay.com",
"private": false,
"peerDependencies": {
"@depay/solana-web3.js": "^1.25.1",
"@depay/web3-blockchains": "^9.4.2",
"@depay/solana-web3.js": "^1.26.0",
"@depay/web3-blockchains": "^9.4.3",
"ethers": "^5.7.1"
},
"engines": {
Expand All @@ -43,9 +43,9 @@
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/preset-env": "^7.12.7",
"@depay/solana-web3.js": "^1.25.1",
"@depay/web3-blockchains": "^9.4.2",
"@depay/web3-mock": "^14.17.0",
"@depay/solana-web3.js": "^1.26.0",
"@depay/web3-blockchains": "^9.4.3",
"@depay/web3-mock": "^14.18.0",
"@rollup/plugin-commonjs": "^22.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.3.0",
Expand Down
6 changes: 3 additions & 3 deletions package.solana.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-client-solana",
"moduleName": "Web3Client",
"version": "10.18.7",
"version": "10.18.8",
"description": "A web3 client to fetch blockchain data just like you are used to with HTTP clients.",
"main": "dist/umd/index.solana.js",
"module": "dist/esm/index.solana.js",
Expand All @@ -23,8 +23,8 @@
"homepage": "https://depay.com",
"private": false,
"peerDependencies": {
"@depay/web3-blockchains": "^9.4.2",
"@depay/solana-web3.js": "^1.25.1",
"@depay/web3-blockchains": "^9.4.3",
"@depay/solana-web3.js": "^1.26.0",
"ethers": "^5.7.1"
},
"engines": {
Expand Down
25 changes: 14 additions & 11 deletions src/platforms/evm/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,20 @@ const setProviderEndpoints = async (blockchain, endpoints, detectFastest = true)
let timeout = 900
let before = new Date().getTime()
setTimeout(()=>resolve(timeout), timeout)
const response = await fetch(endpoint, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
referrer: "",
referrerPolicy: "no-referrer",
body: JSON.stringify({ method: 'net_version', id: 1, jsonrpc: '2.0' })
})
if(!response.ok) { return resolve(999) }
let response
try {
response = await fetch(endpoint, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
referrer: "",
referrerPolicy: "no-referrer",
body: JSON.stringify({ method: 'net_version', id: 1, jsonrpc: '2.0' })
})
} catch {}
if(!response?.ok) { return resolve(999) }
let after = new Date().getTime()
resolve(after-before)
})
Expand Down
25 changes: 14 additions & 11 deletions src/platforms/solana/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,20 @@ const setProviderEndpoints = async (blockchain, endpoints, detectFastest = true)
let timeout = 900
let before = new Date().getTime()
setTimeout(()=>resolve(timeout), timeout)
const response = await fetch(endpoint, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
referrer: "",
referrerPolicy: "no-referrer",
body: JSON.stringify({ method: 'getIdentity', id: 1, jsonrpc: '2.0' })
})
if(!response.ok) { return resolve(999) }
let response
try {
response = await fetch(endpoint, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
referrer: "",
referrerPolicy: "no-referrer",
body: JSON.stringify({ method: 'getIdentity', id: 1, jsonrpc: '2.0' })
})
} catch {}
if(!response?.ok) { return resolve(999) }
let after = new Date().getTime()
resolve(after-before)
})
Expand Down
26 changes: 13 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -896,10 +896,10 @@
"@babel/helper-validator-identifier" "^7.14.9"
to-fast-properties "^2.0.0"

"@depay/solana-web3.js@^1.25.1":
version "1.25.1"
resolved "https://registry.yarnpkg.com/@depay/solana-web3.js/-/solana-web3.js-1.25.1.tgz#2f4725007ff4cfc14af2606eb3d333e68097e13f"
integrity sha512-tKCHHQVoZV85wZ8r3ZuxuQlejBcVolIUf52Bq2Pne3KR1BpxYJF2/9XRTH9qCrLZMQsgsQHikQEH5eglDCKJkA==
"@depay/solana-web3.js@^1.26.0":
version "1.26.0"
resolved "https://registry.yarnpkg.com/@depay/solana-web3.js/-/solana-web3.js-1.26.0.tgz#6234cd46779924a930d6b6021b66a25c18b38365"
integrity sha512-aAhDxfNGraE8VBwM5g/BhHnNCENlLSKDJ3yIh2EZd4mfmKM/4utv0cNUhTEytUAvvFoaMcOXXQ5U5sE1IMXFrQ==
dependencies:
bs58 "^5.0.0"

Expand All @@ -908,17 +908,17 @@
resolved "https://registry.yarnpkg.com/@depay/web3-blockchains/-/web3-blockchains-9.1.4.tgz#f006c29c887c433e1824e2bfabf8f39ad13da907"
integrity sha512-CQnXCNAt3sA1MphZDMPbrhAPtemzeQ/NKeHcd2aBF61nTjJCRUmSh1Ox8Z6rlSjgDP66842iy6JAoRiFDtlmFw==

"@depay/web3-blockchains@^9.4.2":
version "9.4.2"
resolved "https://registry.yarnpkg.com/@depay/web3-blockchains/-/web3-blockchains-9.4.2.tgz#61cbe215482b6c2e70255291d10c7c9b4d2bd90c"
integrity sha512-1aT9ZhMEXl87BOZsdFgVEl9aY1MgO0uB7/Qf4Wb4+L0omiydygIhITPh4JlCNz2yVdFtcU35N4/xS+4jli+nCg==
"@depay/web3-blockchains@^9.4.3":
version "9.4.3"
resolved "https://registry.yarnpkg.com/@depay/web3-blockchains/-/web3-blockchains-9.4.3.tgz#df7d1ae5bb6cf7ac1b1e556ab09eb314d7c5eee4"
integrity sha512-Pl+7EdTZGm1jUZWAYtShqE/xOszblCoWYQQ5p00eHuUkobHs3vg6Ih7fSINL3TvTIxaVTpTjhyyAc2afkbhbmQ==

"@depay/web3-mock@^14.17.0":
version "14.17.0"
resolved "https://registry.yarnpkg.com/@depay/web3-mock/-/web3-mock-14.17.0.tgz#cf188a9d810c49f7af4aeb60bc06b5ec61bc75b8"
integrity sha512-0WCIpHqGUTPmOb5l3iN+4wCY+P3nHnGWd3uyWB+Wrt5DygS6MWI2b50gwtSCgYUCfgmEv9KlRuCnHDC4TDKCeA==
"@depay/web3-mock@^14.18.0":
version "14.18.0"
resolved "https://registry.yarnpkg.com/@depay/web3-mock/-/web3-mock-14.18.0.tgz#149dcdc2e39f265beefa9b4ffa8a00512bc25d01"
integrity sha512-TGhb/8k4qHR6OlxQcFxAZXX8fuJzPA3wfobKtCRhldyKV0ZotNIUEgN5MXq0aNGJ7FAPVjZPjHk1T7bL4ipj0g==
dependencies:
"@depay/solana-web3.js" "^1.25.1"
"@depay/solana-web3.js" "^1.26.0"
"@depay/web3-blockchains" "^9.1.4"
ethers "^5.7.1"

Expand Down

0 comments on commit a54aef4

Please sign in to comment.