mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 06:02:36 +03:00
isomorphic-fetch
This commit is contained in:
55
package-lock.json
generated
55
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.3.4",
|
||||
"version": "0.4.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.3.4",
|
||||
"version": "0.4.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@ethersproject/abstract-signer": "^5.6.0",
|
||||
@@ -16,10 +16,10 @@
|
||||
"buffer": "^6.0.3",
|
||||
"crypto-browserify": "^3.12.0",
|
||||
"ethers": "^5.6.2",
|
||||
"isomorphic-unfetch": "^3.1.0",
|
||||
"isomorphic-ws": "^4.0.1",
|
||||
"just-clone": "^5.0.1",
|
||||
"neverthrow": "^4.3.1",
|
||||
"node-fetch": "^2.6.7",
|
||||
"socket.io-client": "2.4.0",
|
||||
"stream-browserify": "^3.0.0",
|
||||
"tiny-invariant": "^1.2.0",
|
||||
@@ -30,7 +30,6 @@
|
||||
"devDependencies": {
|
||||
"@typechain/ethers-v5": "^10.0.0",
|
||||
"@types/node": "^17.0.23",
|
||||
"@types/node-fetch": "^2.6.1",
|
||||
"@types/socket.io-client": "1.4.33",
|
||||
"@types/uuid": "^8.3.4",
|
||||
"@types/ws": "^8.5.3",
|
||||
@@ -2630,16 +2629,6 @@
|
||||
"integrity": "sha512-UxDxWn7dl97rKVeVS61vErvw086aCYhDLyvRQZ5Rk65rZKepaFdm53GeqXaKBuOhED4e9uWq34IC3TdSdJJ2Gw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"form-data": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/prettier": {
|
||||
"version": "2.4.4",
|
||||
"dev": true,
|
||||
@@ -6500,6 +6489,15 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/isomorphic-unfetch": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/isomorphic-unfetch/-/isomorphic-unfetch-3.1.0.tgz",
|
||||
"integrity": "sha512-geDJjpoZ8N0kWexiwkX8F9NkTsXhetLPVbZFQ+JTW239QNOwvB0gniuR1Wc6f0AMTn7/mFGyXvHTifrCp/GH8Q==",
|
||||
"dependencies": {
|
||||
"node-fetch": "^2.6.1",
|
||||
"unfetch": "^4.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/isomorphic-ws": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz",
|
||||
@@ -10656,6 +10654,11 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/unfetch": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/unfetch/-/unfetch-4.2.0.tgz",
|
||||
"integrity": "sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA=="
|
||||
},
|
||||
"node_modules/universalify": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
|
||||
@@ -12825,16 +12828,6 @@
|
||||
"integrity": "sha512-UxDxWn7dl97rKVeVS61vErvw086aCYhDLyvRQZ5Rk65rZKepaFdm53GeqXaKBuOhED4e9uWq34IC3TdSdJJ2Gw==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*",
|
||||
"form-data": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"@types/prettier": {
|
||||
"version": "2.4.4",
|
||||
"dev": true
|
||||
@@ -15595,6 +15588,15 @@
|
||||
"integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=",
|
||||
"dev": true
|
||||
},
|
||||
"isomorphic-unfetch": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/isomorphic-unfetch/-/isomorphic-unfetch-3.1.0.tgz",
|
||||
"integrity": "sha512-geDJjpoZ8N0kWexiwkX8F9NkTsXhetLPVbZFQ+JTW239QNOwvB0gniuR1Wc6f0AMTn7/mFGyXvHTifrCp/GH8Q==",
|
||||
"requires": {
|
||||
"node-fetch": "^2.6.1",
|
||||
"unfetch": "^4.2.0"
|
||||
}
|
||||
},
|
||||
"isomorphic-ws": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz",
|
||||
@@ -18528,6 +18530,11 @@
|
||||
"which-boxed-primitive": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"unfetch": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/unfetch/-/unfetch-4.2.0.tgz",
|
||||
"integrity": "sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA=="
|
||||
},
|
||||
"universalify": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@orionprotocol/sdk",
|
||||
"version": "0.4.0",
|
||||
"version": "0.4.1",
|
||||
"description": "Orion Protocol SDK",
|
||||
"main": "./lib/esm/index.js",
|
||||
"module": "./lib/esm/index.js",
|
||||
@@ -40,7 +40,6 @@
|
||||
"devDependencies": {
|
||||
"@typechain/ethers-v5": "^10.0.0",
|
||||
"@types/node": "^17.0.23",
|
||||
"@types/node-fetch": "^2.6.1",
|
||||
"@types/socket.io-client": "1.4.33",
|
||||
"@types/uuid": "^8.3.4",
|
||||
"@types/ws": "^8.5.3",
|
||||
@@ -68,10 +67,10 @@
|
||||
"buffer": "^6.0.3",
|
||||
"crypto-browserify": "^3.12.0",
|
||||
"ethers": "^5.6.2",
|
||||
"isomorphic-unfetch": "^3.1.0",
|
||||
"isomorphic-ws": "^4.0.1",
|
||||
"just-clone": "^5.0.1",
|
||||
"neverthrow": "^4.3.1",
|
||||
"node-fetch": "^2.6.7",
|
||||
"socket.io-client": "2.4.0",
|
||||
"stream-browserify": "^3.0.0",
|
||||
"tiny-invariant": "^1.2.0",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Schema, z } from 'zod';
|
||||
import fetch, { FetchError, RequestInit } from 'node-fetch';
|
||||
import fetch from 'isomorphic-unfetch';
|
||||
|
||||
import {
|
||||
err, fromPromise, fromThrowable, ok,
|
||||
} from 'neverthrow';
|
||||
@@ -32,17 +33,10 @@ export default async function fetchWithValidation<DataOut, DataIn, ErrorOut, Err
|
||||
...(options ? options.headers : {}),
|
||||
},
|
||||
}), (e) => {
|
||||
if (e instanceof FetchError) {
|
||||
if (e instanceof Error) {
|
||||
return err({
|
||||
type: 'fetchError' as const,
|
||||
url,
|
||||
message: `${e.message} (${e.type})`,
|
||||
error: e,
|
||||
});
|
||||
} if (e instanceof Error) {
|
||||
return err({
|
||||
type: 'unknownFetchError' as const,
|
||||
url,
|
||||
message: e.message,
|
||||
error: e,
|
||||
});
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Schema, z } from 'zod';
|
||||
import { RequestInit } from 'node-fetch';
|
||||
import fetchWithValidation from './fetchWithValidation';
|
||||
|
||||
// https://stackoverflow.com/a/64919133
|
||||
|
||||
Reference in New Issue
Block a user