Skip to content

Commit

Permalink
fix: use custom fetch ponyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
janek26 committed Jul 28, 2022
1 parent c63b6a1 commit 78f904a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 30 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,3 @@ This library would not be possible without these rockstars.
Copyright (c) 2022 0xs34n

Licensed under the [MIT license](https://github.com/0xs34n/starknet.js/blob/main/LICENSE).

4 changes: 2 additions & 2 deletions __tests__/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
import 'isomorphic-unfetch';
import 'isomorphic-fetch';

/* eslint-disable no-console */
import { register } from 'fetch-intercept';

jest.setTimeout(50 * 60 * 1000);
Expand Down
38 changes: 13 additions & 25 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"elliptic": "^6.5.4",
"ethereum-cryptography": "^1.0.3",
"hash.js": "^1.1.7",
"isomorphic-unfetch": "^3.1.0",
"isomorphic-fetch": "^3.0.0",
"json-bigint": "^1.0.0",
"minimalistic-assert": "^1.0.1",
"pako": "^2.0.4",
Expand Down
2 changes: 1 addition & 1 deletion src/provider/default.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import fetch from 'isomorphic-unfetch';
import urljoin from 'url-join';

import { ONE, StarknetChainId, ZERO } from '../constants';
Expand All @@ -20,6 +19,7 @@ import {
Invocation,
TransactionReceiptResponse,
} from '../types';
import fetch from '../utils/fetchPonyfill';
import { getSelectorFromName } from '../utils/hash';
import { parse, parseAlwaysAsBig, stringify } from '../utils/json';
import { BigNumberish, bigNumberishArrayToDecimalStringArray, toBN, toHex } from '../utils/number';
Expand Down
4 changes: 4 additions & 0 deletions src/utils/fetchPonyfill.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default (typeof window !== 'undefined' && window.fetch) || // use buildin fetch in browser if available
(typeof global !== 'undefined' && global.fetch) || // use buildin fetch in node, react-native and service worker if available
// eslint-disable-next-line global-require
require('isomorphic-fetch'); // ponyfill fetch in node and browsers that don't have it

0 comments on commit 78f904a

Please sign in to comment.