This commit is contained in:
Aleksandr Kraiz
2023-02-08 04:58:29 +04:00
parent 87e5e4683f
commit afb683ffa7
3 changed files with 27 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.17.0-rc.3",
"version": "0.17.0-rc.4",
"description": "Orion Protocol SDK",
"main": "./lib/esm/index.js",
"module": "./lib/esm/index.js",

View File

@@ -1,28 +1,30 @@
import { z } from 'zod';
import { SupportedChainId } from '../../types';
export const pureEnvNetworksSchema = z.object({
api: z.string(),
services: z.object({
blockchain: z.object({
http: z.string(),
}),
aggregator: z.object({
http: z.string(),
ws: z.string(),
}),
priceFeed: z.object({
all: z.string(),
}),
}),
rpc: z.string().optional(),
liquidityMigratorAddress: z.string().optional(),
});
export const pureEnvPayloadSchema = z.object({
analyticsAPI: z.string().url(),
referralAPI: z.string().url(),
networks: z.record(
z.nativeEnum(SupportedChainId),
z.object({
api: z.string(),
services: z.object({
blockchain: z.object({
http: z.string(),
}),
aggregator: z.object({
http: z.string(),
ws: z.string(),
}),
priceFeed: z.object({
all: z.string(),
}),
}),
rpc: z.string().optional(),
liquidityMigratorAddress: z.string().optional(),
}),
pureEnvNetworksSchema
),
});

View File

@@ -1,5 +1,11 @@
const httpToWS = (url: string) => {
const parsedUrl = new URL(url);
let parsedUrl: URL;
try {
parsedUrl = new URL(url);
} catch (e) {
console.error(`httpToWS: Invalid URL ${url}`);
throw e;
}
if (parsedUrl.protocol === 'https:') {
parsedUrl.protocol = 'wss:';
} else if (parsedUrl.protocol === 'http:') {