Skip to content

Commit 9da0083

Browse files
committed
feat: drop isomorphic-fetch dependency
1 parent 5b7fdf1 commit 9da0083

File tree

7 files changed

+29
-18
lines changed

7 files changed

+29
-18
lines changed

__tests__/utils/batch.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fetch from '../../src/utils/fetchPonyfill';
1+
import fetch from '../../src/utils/fetch';
22
import { BatchClient } from '../../src/utils/batch';
33
import { createBlockForDevnet, createTestProvider } from '../config/fixtures';
44
import { initializeMatcher } from '../config/schema';

package-lock.json

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"fetch-intercept": "^2.4.0",
8484
"husky": "^9.0.11",
8585
"import-sort-style-module": "^6.0.0",
86+
"isomorphic-fetch": "~3.0.0",
8687
"jest": "^29.5.0",
8788
"jest-environment-jsdom": "^29.5.0",
8889
"jest-json-schema": "^6.1.0",
@@ -103,7 +104,6 @@
103104
"@scure/starknet": "1.1.0",
104105
"abi-wan-kanabi": "^2.2.3",
105106
"fetch-cookie": "~3.0.0",
106-
"isomorphic-fetch": "~3.0.0",
107107
"isows": "^1.0.6",
108108
"lossless-json": "^4.0.1",
109109
"pako": "^2.0.4",

src/channel/rpc_0_7.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { BatchClient } from '../utils/batch';
2828
import { CallData } from '../utils/calldata';
2929
import { isSierra } from '../utils/contract';
3030
import { validateAndParseEthAddress } from '../utils/eth';
31-
import fetch from '../utils/fetchPonyfill';
31+
import fetch from '../utils/fetch';
3232
import { getSelector, getSelectorFromName } from '../utils/hash';
3333
import { stringify } from '../utils/json';
3434
import { getHexStringArray, toHex, toStorageKey } from '../utils/num';

src/channel/rpc_0_8.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { BatchClient } from '../utils/batch';
2828
import { CallData } from '../utils/calldata';
2929
import { isSierra } from '../utils/contract';
3030
import { validateAndParseEthAddress } from '../utils/eth';
31-
import fetch from '../utils/fetchPonyfill';
31+
import fetch from '../utils/fetch';
3232
import { getSelector, getSelectorFromName } from '../utils/hash';
3333
import { stringify } from '../utils/json';
3434
import {

src/utils/fetch.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// the ts-ignore suppresses an esm to cjs import error that is resolved with entry point resolution
2+
// @ts-ignore
3+
import makeFetchCookie from 'fetch-cookie';
4+
import { IS_BROWSER } from './encode';
5+
import { LibraryError } from './errors';
6+
import { isUndefined } from './typed';
7+
8+
export default (IS_BROWSER && window.fetch.bind(window)) || // use built-in fetch in browser if available
9+
(!isUndefined(global) && makeFetchCookie(global.fetch)) || // use built-in fetch in node, react-native and service worker if available
10+
// throw with instructions when no fetch is detected
11+
((() => {
12+
throw new LibraryError(
13+
"'fetch()' not detected, use the 'baseFetch' constructor parameter to set it"
14+
);
15+
}) as WindowOrWorkerGlobalScope['fetch']);

src/utils/fetchPonyfill.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)