Skip to content

Commit

Permalink
fix: bnReviver for all remote fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
wighawag committed Mar 20, 2024
1 parent 711759e commit 8b1b2ab
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 7 deletions.
7 changes: 7 additions & 0 deletions examples/mud/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# web-demo

## 0.1.66

### Patch Changes

- Updated dependencies
- ethereum-indexer-browser@0.7.4

## 0.1.65

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/mud/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mud-demo",
"private": true,
"version": "0.1.65",
"version": "0.1.66",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
7 changes: 7 additions & 0 deletions examples/web-demo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# web-demo

## 0.1.66

### Patch Changes

- Updated dependencies
- ethereum-indexer-browser@0.7.4

## 0.1.65

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/web-demo/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "web-demo",
"private": true,
"version": "0.1.65",
"version": "0.1.66",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
6 changes: 6 additions & 0 deletions packages/ethereum-indexer-browser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# ethereum-indexer-browser

## 0.7.4

### Patch Changes

- fix: bnReviver for all remote fetch

## 0.7.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ethereum-indexer-browser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ethereum-indexer-browser",
"version": "0.7.3",
"version": "0.7.4",
"publishConfig": {
"access": "public"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export function keepStateOnIndexedDB<ABI extends Abi, ProcessResultType, Process
try {
const response = await fetch(urlOfRemote);
const text = await response.text();

const json: {
state: ProcessResultType;
lastSync: LastSync<ABI>;
Expand Down Expand Up @@ -113,15 +112,17 @@ export function keepStateOnIndexedDB<ABI extends Abi, ProcessResultType, Process
const url = getURL(remote[latest.index], context);
try {
const response = await fetch(url);
const json = await response.json();
const text = await response.text();
const json = JSON.parse(text, bnReviver);
remoteState = json;
} catch (err) {
console.error(`failed to fetch remote-state, try second`, err);

const url = getURL(remote[(latest.index + 1) % remote.length], context);
try {
const response = await fetch(url);
const json = await response.json();
const text = await response.text();
const json = JSON.parse(text, bnReviver);
remoteState = json;
} catch (err) {
console.error(`failed to fetch second remote-state`, err);
Expand All @@ -132,7 +133,8 @@ export function keepStateOnIndexedDB<ABI extends Abi, ProcessResultType, Process
const url = getURL(remote, context);
try {
const response = await fetch(url);
const json = await response.json();
const text = await response.text();
const json = JSON.parse(text, bnReviver);
remoteState = json;
} catch (err) {
console.error(`failed to fetch remote-state`, err);
Expand Down

0 comments on commit 8b1b2ab

Please sign in to comment.