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 aa7af66 commit 16e9a53
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 32 deletions.
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
3 changes: 1 addition & 2 deletions src/provider/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import fetch from 'isomorphic-unfetch';

import { StarknetChainId } from '../constants';
import {
BlockTag,
Expand All @@ -18,6 +16,7 @@ import {
InvokeFunctionResponse,
} from '../types';
import { RPC } from '../types/api';
import fetch from '../utils/fetchPonyfill';
import { getSelectorFromName } from '../utils/hash';
import { stringify } from '../utils/json';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/provider/sequencer.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 @@ -25,6 +24,7 @@ import {
GetTransactionTraceResponse,
Sequencer,
} from '../types/api';
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
2 changes: 1 addition & 1 deletion www/docs/API/contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ contract.**address** => _string_

The address the contract was constructed/connected with

contract.**providerOrAcount** => ProviderInterface | AccountInterface_
contract.**providerOrAccount** => _ProviderInterface | AccountInterface_

Provider or account that are used to interact with the network

Expand Down

0 comments on commit 16e9a53

Please sign in to comment.