Skip to content

Commit

Permalink
feat: drop isomorphic-fetch dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
penovicp committed Apr 12, 2024
1 parent 74eeb63 commit e97b18b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 15 deletions.
14 changes: 10 additions & 4 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 @@ -78,6 +78,7 @@
"fetch-intercept": "^2.4.0",
"husky": "^9.0.11",
"import-sort-style-module": "^6.0.0",
"isomorphic-fetch": "^3.0.0",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest-json-schema": "^6.1.0",
Expand All @@ -95,7 +96,6 @@
"@scure/starknet": "~1.0.0",
"abi-wan-kanabi": "^2.2.2",
"fetch-cookie": "^3.0.0",
"isomorphic-fetch": "^3.0.0",
"lossless-json": "^4.0.1",
"pako": "^2.0.4",
"starknet-types": "^0.0.5",
Expand Down
2 changes: 1 addition & 1 deletion src/channel/rpc_0_6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { JRPC, RPCSPEC06 as RPC } from '../types/api';
import { CallData } from '../utils/calldata';
import { isSierra } from '../utils/contract';
import { validateAndParseEthAddress } from '../utils/eth';
import fetch from '../utils/fetchPonyfill';
import fetch from '../utils/fetch';
import { getSelector, getSelectorFromName } from '../utils/hash';
import { stringify } from '../utils/json';
import { getHexStringArray, toHex, toStorageKey } from '../utils/num';
Expand Down
2 changes: 1 addition & 1 deletion src/channel/rpc_0_7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { JRPC, RPCSPEC07 as RPC } from '../types/api';
import { CallData } from '../utils/calldata';
import { isSierra } from '../utils/contract';
import { validateAndParseEthAddress } from '../utils/eth';
import fetch from '../utils/fetchPonyfill';
import fetch from '../utils/fetch';
import { getSelector, getSelectorFromName } from '../utils/hash';
import { stringify } from '../utils/json';
import { getHexStringArray, toHex, toStorageKey } from '../utils/num';
Expand Down
15 changes: 15 additions & 0 deletions src/utils/fetch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// the ts-ignore suppresses an esm to cjs import error that is resolved with entry point resolution
// @ts-ignore
import makeFetchCookie from 'fetch-cookie';
import { LibraryError } from '../provider/errors';

// use built-in fetch in browser if available
export default (typeof window !== 'undefined' && window.fetch) ||
// use built-in fetch in node, react-native and service worker if available
(typeof global !== 'undefined' && makeFetchCookie(global.fetch)) ||
// throw with instructions when no fetch is detected
((() => {
throw new LibraryError(
"'fetch()' not detected, use the 'baseFetch' constructor parameter to set it"
);
}) as WindowOrWorkerGlobalScope['fetch']);
8 changes: 0 additions & 8 deletions src/utils/fetchPonyfill.ts

This file was deleted.

0 comments on commit e97b18b

Please sign in to comment.