Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade dependencies #13

Merged
merged 6 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: '16.x'
node-version: '18.x'
- name: Cache node modules
uses: actions/cache@v2
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-evm.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: mv package.evm.json package.json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-solana.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: mv package.solana.json package.json
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
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: '16.x'
node-version: '18.x'
- name: Cache node modules
uses: actions/cache@v2
env:
Expand Down
3 changes: 1 addition & 2 deletions dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
<script crossorigin src="https://unpkg.com/@depay/solana-web3.js@1"></script>
<script crossorigin src="https://unpkg.com/@depay/web3-blockchains@9"></script>
<script crossorigin src="https://unpkg.com/@depay/web3-client@10"></script>
<script crossorigin src="https://unpkg.com/@depay/walletconnect-v1@1"></script>
<script crossorigin src="https://unpkg.com/@depay/walletconnect-v2@2"></script>
<script crossorigin src="https://unpkg.com/@depay/web3-wallets@16"></script>
<script crossorigin src="https://unpkg.com/@depay/web3-wallets@17"></script>
<script crossorigin src="https://unpkg.com/@depay/web3-tokens@10"></script>
<script crossorigin src="https://unpkg.com/@depay/web3-assets@7"></script>
<script crossorigin src="https://unpkg.com/@depay/web3-exchanges@13"></script>
Expand Down
83 changes: 57 additions & 26 deletions dist/esm/index.evm.js
Original file line number Diff line number Diff line change
Expand Up @@ -47264,6 +47264,7 @@ const getConfiguration = () =>{
function _optionalChain$3$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
const BATCH_INTERVAL$1 = 10;
const CHUNK_SIZE$1 = 99;
const MAX_RETRY$1 = 3;

class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {

Expand All @@ -47280,7 +47281,7 @@ class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
return Promise.resolve(Blockchains.findByName(this._network).id)
}

requestChunk(chunk, endpoint) {
requestChunk(chunk, endpoint, attempt) {

try {

Expand All @@ -47303,11 +47304,11 @@ class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
}
});
}).catch((error) => {
if(error && error.code == 'SERVER_ERROR') {
if(attempt < MAX_RETRY$1 && error && error.code == 'SERVER_ERROR') {
const index = this._endpoints.indexOf(this._endpoint)+1;
this._failover();
this._endpoint = index >= this._endpoints.length ? this._endpoints[0] : this._endpoints[index];
this.requestChunk(chunk, this._endpoint);
this.requestChunk(chunk, this._endpoint, attempt+1);
} else {
chunk.forEach((inflightRequest) => {
inflightRequest.reject(error);
Expand Down Expand Up @@ -47361,7 +47362,7 @@ class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
chunks.forEach((chunk)=>{
// Get the request as an array of requests
chunk.map((inflight) => inflight.request);
return this.requestChunk(chunk, this._endpoint)
return this.requestChunk(chunk, this._endpoint, 1)
});
}, getConfiguration().batchInterval || BATCH_INTERVAL$1);
}
Expand Down Expand Up @@ -47422,6 +47423,8 @@ const setProviderEndpoints$2 = async (blockchain, endpoints, detectFastest = tru
'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) }
Expand Down Expand Up @@ -47482,6 +47485,7 @@ var EVM = {
function _optionalChain$2$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
const BATCH_INTERVAL = 10;
const CHUNK_SIZE = 99;
const MAX_RETRY = 3;

class StaticJsonRpcSequentialProvider extends Connection {

Expand All @@ -47496,30 +47500,55 @@ class StaticJsonRpcSequentialProvider extends Connection {
this._rpcRequest = this._rpcRequestReplacement.bind(this);
}

requestChunk(chunk) {
handleError(error, attempt, chunk) {
if(attempt < MAX_RETRY && error && [
'Failed to fetch', 'limit reached', '504', '503', '502', '500', '429', '426', '422', '413', '409', '408', '406', '405', '404', '403', '402', '401', '400'
].some((errorType)=>error.toString().match(errorType))) {
const index = this._endpoints.indexOf(this._endpoint)+1;
this._endpoint = index >= this._endpoints.length ? this._endpoints[0] : this._endpoints[index];
this._provider = new Connection(this._endpoint);
this.requestChunk(chunk, attempt+1);
} else {
chunk.forEach((inflightRequest) => {
inflightRequest.reject(error);
});
}
}

const batch = chunk.map((inflight) => inflight.request);
batchRequest(requests, attempt) {
return new Promise((resolve, reject) => {
if (requests.length === 0) resolve([]); // Do nothing if requests is empty

const handleError = (error)=>{
if(error && [
'Failed to fetch', 'limit reached', '504', '503', '502', '500', '429', '426', '422', '413', '409', '408', '406', '405', '404', '403', '402', '401', '400'
].some((errorType)=>error.toString().match(errorType))) {
const index = this._endpoints.indexOf(this._endpoint)+1;
this._endpoint = index >= this._endpoints.length ? this._endpoints[0] : this._endpoints[index];
this._provider = new Connection(this._endpoint);
this.requestChunk(chunk);
} else {
chunk.forEach((inflightRequest) => {
inflightRequest.reject(error);
});
}
};
const batch = requests.map(params => {
return this._rpcClient.request(params.methodName, params.args)
});

fetch(
this._endpoint,
{
method: 'POST',
body: JSON.stringify(batch),
headers: { 'Content-Type': 'application/json' },
}
).then((response)=>{
if(response.ok) {
response.json().then((parsedJson)=>{
resolve(parsedJson);
}).catch(reject);
} else {
reject(`${response.status} ${response.text}`);
}
}).catch(reject);
})
}

requestChunk(chunk, attempt) {

const batch = chunk.map((inflight) => inflight.request);

try {
return this._provider._rpcBatchRequest(batch)
return this.batchRequest(batch, attempt)
.then((result) => {
// For each result, feed it to the correct Promise, depending
// on whether it was a success or error
chunk.forEach((inflightRequest, index) => {
const payload = result[index];
if (_optionalChain$2$1([payload, 'optionalAccess', _ => _.error])) {
Expand All @@ -47533,8 +47562,8 @@ class StaticJsonRpcSequentialProvider extends Connection {
inflightRequest.reject();
}
});
}).catch(handleError)
} catch (error){ return handleError(error) }
}).catch((error)=>this.handleError(error, attempt, chunk))
} catch (error){ return this.handleError(error, attempt, chunk) }
}

_rpcRequestReplacement(methodName, args) {
Expand Down Expand Up @@ -47570,7 +47599,7 @@ class StaticJsonRpcSequentialProvider extends Connection {
chunks.forEach((chunk)=>{
// Get the request as an array of requests
chunk.map((inflight) => inflight.request);
return this.requestChunk(chunk)
return this.requestChunk(chunk, 1)
});
}, getConfiguration().batchInterval || BATCH_INTERVAL);
}
Expand Down Expand Up @@ -47630,6 +47659,8 @@ const setProviderEndpoints$1 = async (blockchain, endpoints, detectFastest = tru
'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) }
Expand Down
83 changes: 57 additions & 26 deletions dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ const getConfiguration = () =>{
function _optionalChain$3(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
const BATCH_INTERVAL$1 = 10;
const CHUNK_SIZE$1 = 99;
const MAX_RETRY$1 = 3;

class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {

Expand All @@ -151,7 +152,7 @@ class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
return Promise.resolve(Blockchains.findByName(this._network).id)
}

requestChunk(chunk, endpoint) {
requestChunk(chunk, endpoint, attempt) {

try {

Expand All @@ -174,11 +175,11 @@ class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
}
});
}).catch((error) => {
if(error && error.code == 'SERVER_ERROR') {
if(attempt < MAX_RETRY$1 && error && error.code == 'SERVER_ERROR') {
const index = this._endpoints.indexOf(this._endpoint)+1;
this._failover();
this._endpoint = index >= this._endpoints.length ? this._endpoints[0] : this._endpoints[index];
this.requestChunk(chunk, this._endpoint);
this.requestChunk(chunk, this._endpoint, attempt+1);
} else {
chunk.forEach((inflightRequest) => {
inflightRequest.reject(error);
Expand Down Expand Up @@ -232,7 +233,7 @@ class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
chunks.forEach((chunk)=>{
// Get the request as an array of requests
chunk.map((inflight) => inflight.request);
return this.requestChunk(chunk, this._endpoint)
return this.requestChunk(chunk, this._endpoint, 1)
});
}, getConfiguration().batchInterval || BATCH_INTERVAL$1);
}
Expand Down Expand Up @@ -293,6 +294,8 @@ const setProviderEndpoints$2 = async (blockchain, endpoints, detectFastest = tru
'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) }
Expand Down Expand Up @@ -353,6 +356,7 @@ var EVM = {
function _optionalChain$2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
const BATCH_INTERVAL = 10;
const CHUNK_SIZE = 99;
const MAX_RETRY = 3;

class StaticJsonRpcSequentialProvider extends Connection {

Expand All @@ -367,30 +371,55 @@ class StaticJsonRpcSequentialProvider extends Connection {
this._rpcRequest = this._rpcRequestReplacement.bind(this);
}

requestChunk(chunk) {
handleError(error, attempt, chunk) {
if(attempt < MAX_RETRY && error && [
'Failed to fetch', 'limit reached', '504', '503', '502', '500', '429', '426', '422', '413', '409', '408', '406', '405', '404', '403', '402', '401', '400'
].some((errorType)=>error.toString().match(errorType))) {
const index = this._endpoints.indexOf(this._endpoint)+1;
this._endpoint = index >= this._endpoints.length ? this._endpoints[0] : this._endpoints[index];
this._provider = new Connection(this._endpoint);
this.requestChunk(chunk, attempt+1);
} else {
chunk.forEach((inflightRequest) => {
inflightRequest.reject(error);
});
}
}

const batch = chunk.map((inflight) => inflight.request);
batchRequest(requests, attempt) {
return new Promise((resolve, reject) => {
if (requests.length === 0) resolve([]); // Do nothing if requests is empty

const handleError = (error)=>{
if(error && [
'Failed to fetch', 'limit reached', '504', '503', '502', '500', '429', '426', '422', '413', '409', '408', '406', '405', '404', '403', '402', '401', '400'
].some((errorType)=>error.toString().match(errorType))) {
const index = this._endpoints.indexOf(this._endpoint)+1;
this._endpoint = index >= this._endpoints.length ? this._endpoints[0] : this._endpoints[index];
this._provider = new Connection(this._endpoint);
this.requestChunk(chunk);
} else {
chunk.forEach((inflightRequest) => {
inflightRequest.reject(error);
});
}
};
const batch = requests.map(params => {
return this._rpcClient.request(params.methodName, params.args)
});

fetch(
this._endpoint,
{
method: 'POST',
body: JSON.stringify(batch),
headers: { 'Content-Type': 'application/json' },
}
).then((response)=>{
if(response.ok) {
response.json().then((parsedJson)=>{
resolve(parsedJson);
}).catch(reject);
} else {
reject(`${response.status} ${response.text}`);
}
}).catch(reject);
})
}

requestChunk(chunk, attempt) {

const batch = chunk.map((inflight) => inflight.request);

try {
return this._provider._rpcBatchRequest(batch)
return this.batchRequest(batch, attempt)
.then((result) => {
// For each result, feed it to the correct Promise, depending
// on whether it was a success or error
chunk.forEach((inflightRequest, index) => {
const payload = result[index];
if (_optionalChain$2([payload, 'optionalAccess', _ => _.error])) {
Expand All @@ -404,8 +433,8 @@ class StaticJsonRpcSequentialProvider extends Connection {
inflightRequest.reject();
}
});
}).catch(handleError)
} catch (error){ return handleError(error) }
}).catch((error)=>this.handleError(error, attempt, chunk))
} catch (error){ return this.handleError(error, attempt, chunk) }
}

_rpcRequestReplacement(methodName, args) {
Expand Down Expand Up @@ -441,7 +470,7 @@ class StaticJsonRpcSequentialProvider extends Connection {
chunks.forEach((chunk)=>{
// Get the request as an array of requests
chunk.map((inflight) => inflight.request);
return this.requestChunk(chunk)
return this.requestChunk(chunk, 1)
});
}, getConfiguration().batchInterval || BATCH_INTERVAL);
}
Expand Down Expand Up @@ -501,6 +530,8 @@ const setProviderEndpoints$1 = async (blockchain, endpoints, detectFastest = tru
'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) }
Expand Down
Loading
Loading