Skip to content

Commit

Permalink
v10.18.15: only rotate rpc provider if batch limit has been reached
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNe0x1 committed Sep 10, 2024
1 parent 2000ed4 commit 0296c2b
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 25 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
8 changes: 5 additions & 3 deletions dist/esm/index.evm.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
).then((response)=>{
if(response.ok) {
response.json().then((parsedJson)=>{
if(parsedJson.find((entry)=>_optionalChain$2([entry, 'optionalAccess', _ => _.error]))) {
if(parsedJson.find((entry)=>{
return _optionalChain$2([entry, 'optionalAccess', _ => _.error]) && [-32062].includes(_optionalChain$2([entry, 'optionalAccess', _2 => _2.error, 'optionalAccess', _3 => _3.code]))
})) {
if(attempt < MAX_RETRY) {
reject('Error in batch found!');
} else {
Expand Down Expand Up @@ -159,12 +161,12 @@ class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
// on whether it was a success or error
chunk.forEach((inflightRequest, index) => {
const payload = result[index];
if (_optionalChain$2([payload, 'optionalAccess', _2 => _2.error])) {
if (_optionalChain$2([payload, 'optionalAccess', _4 => _4.error])) {
const error = new Error(payload.error.message);
error.code = payload.error.code;
error.data = payload.error.data;
inflightRequest.reject(error);
} else if(_optionalChain$2([payload, 'optionalAccess', _3 => _3.result])) {
} else if(_optionalChain$2([payload, 'optionalAccess', _5 => _5.result])) {
inflightRequest.resolve(payload.result);
} else {
inflightRequest.reject();
Expand Down
8 changes: 5 additions & 3 deletions dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
).then((response)=>{
if(response.ok) {
response.json().then((parsedJson)=>{
if(parsedJson.find((entry)=>_optionalChain$5([entry, 'optionalAccess', _ => _.error]))) {
if(parsedJson.find((entry)=>{
return _optionalChain$5([entry, 'optionalAccess', _ => _.error]) && [-32062].includes(_optionalChain$5([entry, 'optionalAccess', _2 => _2.error, 'optionalAccess', _3 => _3.code]))
})) {
if(attempt < MAX_RETRY$1) {
reject('Error in batch found!');
} else {
Expand Down Expand Up @@ -102,12 +104,12 @@ class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
// on whether it was a success or error
chunk.forEach((inflightRequest, index) => {
const payload = result[index];
if (_optionalChain$5([payload, 'optionalAccess', _2 => _2.error])) {
if (_optionalChain$5([payload, 'optionalAccess', _4 => _4.error])) {
const error = new Error(payload.error.message);
error.code = payload.error.code;
error.data = payload.error.data;
inflightRequest.reject(error);
} else if(_optionalChain$5([payload, 'optionalAccess', _3 => _3.result])) {
} else if(_optionalChain$5([payload, 'optionalAccess', _5 => _5.result])) {
inflightRequest.resolve(payload.result);
} else {
inflightRequest.reject();
Expand Down
8 changes: 5 additions & 3 deletions dist/umd/index.evm.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@
).then((response)=>{
if(response.ok) {
response.json().then((parsedJson)=>{
if(parsedJson.find((entry)=>_optionalChain$2([entry, 'optionalAccess', _ => _.error]))) {
if(parsedJson.find((entry)=>{
return _optionalChain$2([entry, 'optionalAccess', _ => _.error]) && [-32062].includes(_optionalChain$2([entry, 'optionalAccess', _2 => _2.error, 'optionalAccess', _3 => _3.code]))
})) {
if(attempt < MAX_RETRY) {
reject('Error in batch found!');
} else {
Expand Down Expand Up @@ -166,12 +168,12 @@
// on whether it was a success or error
chunk.forEach((inflightRequest, index) => {
const payload = result[index];
if (_optionalChain$2([payload, 'optionalAccess', _2 => _2.error])) {
if (_optionalChain$2([payload, 'optionalAccess', _4 => _4.error])) {
const error = new Error(payload.error.message);
error.code = payload.error.code;
error.data = payload.error.data;
inflightRequest.reject(error);
} else if(_optionalChain$2([payload, 'optionalAccess', _3 => _3.result])) {
} else if(_optionalChain$2([payload, 'optionalAccess', _5 => _5.result])) {
inflightRequest.resolve(payload.result);
} else {
inflightRequest.reject();
Expand Down
8 changes: 5 additions & 3 deletions dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@
).then((response)=>{
if(response.ok) {
response.json().then((parsedJson)=>{
if(parsedJson.find((entry)=>_optionalChain$5([entry, 'optionalAccess', _ => _.error]))) {
if(parsedJson.find((entry)=>{
return _optionalChain$5([entry, 'optionalAccess', _ => _.error]) && [-32062].includes(_optionalChain$5([entry, 'optionalAccess', _2 => _2.error, 'optionalAccess', _3 => _3.code]))
})) {
if(attempt < MAX_RETRY$1) {
reject('Error in batch found!');
} else {
Expand Down Expand Up @@ -108,12 +110,12 @@
// on whether it was a success or error
chunk.forEach((inflightRequest, index) => {
const payload = result[index];
if (_optionalChain$5([payload, 'optionalAccess', _2 => _2.error])) {
if (_optionalChain$5([payload, 'optionalAccess', _4 => _4.error])) {
const error = new Error(payload.error.message);
error.code = payload.error.code;
error.data = payload.error.data;
inflightRequest.reject(error);
} else if(_optionalChain$5([payload, 'optionalAccess', _3 => _3.result])) {
} else if(_optionalChain$5([payload, 'optionalAccess', _5 => _5.result])) {
inflightRequest.resolve(payload.result);
} else {
inflightRequest.reject();
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.14",
"version": "10.18.15",
"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.5.2",
"@depay/web3-blockchains": "^9.5.3",
"ethers": "^5.7.1"
},
"engines": {
Expand Down
6 changes: 3 additions & 3 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.14",
"version": "10.18.15",
"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 @@ -34,7 +34,7 @@
"private": false,
"peerDependencies": {
"@depay/solana-web3.js": "^1.26.0",
"@depay/web3-blockchains": "^9.5.2",
"@depay/web3-blockchains": "^9.5.3",
"ethers": "^5.7.1"
},
"engines": {
Expand All @@ -44,7 +44,7 @@
"@babel/core": "^7.12.9",
"@babel/preset-env": "^7.12.7",
"@depay/solana-web3.js": "^1.26.0",
"@depay/web3-blockchains": "^9.5.2",
"@depay/web3-blockchains": "^9.5.3",
"@depay/web3-mock": "^14.18.0",
"@rollup/plugin-commonjs": "^22.0.1",
"@rollup/plugin-json": "^4.1.0",
Expand Down
4 changes: 2 additions & 2 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.14",
"version": "10.18.15",
"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,7 +23,7 @@
"homepage": "https://depay.com",
"private": false,
"peerDependencies": {
"@depay/web3-blockchains": "^9.5.2",
"@depay/web3-blockchains": "^9.5.3",
"@depay/solana-web3.js": "^1.26.0",
"ethers": "^5.7.1"
},
Expand Down
4 changes: 3 additions & 1 deletion src/clients/ethers/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
).then((response)=>{
if(response.ok) {
response.json().then((parsedJson)=>{
if(parsedJson.find((entry)=>entry?.error)) {
if(parsedJson.find((entry)=>{
return entry?.error && [-32062].includes(entry?.error?.code)
})) {
if(attempt < MAX_RETRY) {
reject('Error in batch found!')
} else {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -908,10 +908,10 @@
resolved "https://registry.yarnpkg.com/@depay/web3-blockchains/-/web3-blockchains-9.1.4.tgz#f006c29c887c433e1824e2bfabf8f39ad13da907"
integrity sha512-CQnXCNAt3sA1MphZDMPbrhAPtemzeQ/NKeHcd2aBF61nTjJCRUmSh1Ox8Z6rlSjgDP66842iy6JAoRiFDtlmFw==

"@depay/web3-blockchains@^9.5.2":
version "9.5.2"
resolved "https://registry.yarnpkg.com/@depay/web3-blockchains/-/web3-blockchains-9.5.2.tgz#f19d0ededa3b059f21af455e2d5b280f23f07575"
integrity sha512-GocEM5I9aBFGrQ0mRAFlZd65SNMKYLAGzYJAE+UnYxTt1gA3p7eYI90VMxAp1KF+T38VAGEZLElilIql9Gb0QQ==
"@depay/web3-blockchains@^9.5.3":
version "9.5.3"
resolved "https://registry.yarnpkg.com/@depay/web3-blockchains/-/web3-blockchains-9.5.3.tgz#6669bfe2cb4ea7708649393ac43e60a2b9a1dce5"
integrity sha512-ZVSMoHaLTJVRwSlegXFiySN7AXOZS4SvnVlOPuPsvZh0c4KE3fDncNMdACds/A/x8pa+adEROeouwCrOuFq7Dw==

"@depay/web3-mock@^14.18.0":
version "14.18.0"
Expand Down

0 comments on commit 0296c2b

Please sign in to comment.