return analyticsAPI and make it optional

This commit is contained in:
TheJuze
2024-03-13 14:07:36 +03:00
parent 8dedc46cb5
commit cf2fd889a0
6 changed files with 8 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
```ts ```ts
const orion = new Orion({ const orion = new Orion({
analyticsAPI: "https://analytics-api.orionprotocol.io",
referralAPI: "https://referral-api.orionprotocol.io", referralAPI: "https://referral-api.orionprotocol.io",
networks: { networks: {
1: { 1: {
@@ -25,6 +26,7 @@ const orion = new Orion({
// Also you can set some config as default and override it for some params // Also you can set some config as default and override it for some params
const orion = new Orion("testing", { const orion = new Orion("testing", {
analyticsAPI: "https://analytics-api.orionprotocol.io",
networks: { networks: {
[SupportedChainId.BSC_TESTNET]: { [SupportedChainId.BSC_TESTNET]: {
nodeJsonRpc: "https://data-seed-prebsc-1-s1.binance.org:8545/", nodeJsonRpc: "https://data-seed-prebsc-1-s1.binance.org:8545/",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@orionprotocol/sdk", "name": "@orionprotocol/sdk",
"version": "0.20.72", "version": "0.20.73",
"description": "Orion Protocol SDK", "description": "Orion Protocol SDK",
"main": "./lib/index.cjs", "main": "./lib/index.cjs",
"module": "./lib/index.js", "module": "./lib/index.js",

View File

@@ -33,6 +33,7 @@ export default class Orion {
} }
this.env = envOrConfig; this.env = envOrConfig;
config = { config = {
analyticsAPI: envConfig?.analyticsAPI,
referralAPI: envConfig.referralAPI, referralAPI: envConfig.referralAPI,
networks: Object.entries(envConfig.networks).map(([chainId, networkConfig]) => { networks: Object.entries(envConfig.networks).map(([chainId, networkConfig]) => {
if (!isValidChainId(chainId)) throw new Error(`Invalid chainId: ${chainId}`); if (!isValidChainId(chainId)) throw new Error(`Invalid chainId: ${chainId}`);

View File

@@ -159,6 +159,7 @@ describe('Orion', () => {
const orionPriceFeedAPI = `http://localhost:${server2.port}`; const orionPriceFeedAPI = `http://localhost:${server2.port}`;
const orion = new Orion({ const orion = new Orion({
analyticsAPI: 'https://analytics-api.orionprotocol.io',
referralAPI: 'https://referral-api.orionprotocol.io', referralAPI: 'https://referral-api.orionprotocol.io',
networks: { networks: {
1: { 1: {
@@ -238,6 +239,7 @@ describe('Orion', () => {
test('Init Orion testing with overrides', () => { test('Init Orion testing with overrides', () => {
const orion = new Orion('testing', { const orion = new Orion('testing', {
analyticsAPI: 'https://asdasd.orionprotocol.io',
referralAPI: 'https://zxczxc.orionprotocol.io', referralAPI: 'https://zxczxc.orionprotocol.io',
networks: { networks: {
[SupportedChainId.BSC_TESTNET]: { [SupportedChainId.BSC_TESTNET]: {

View File

@@ -23,6 +23,7 @@ export const pureEnvNetworksSchema = z.object({
}); });
export const pureEnvPayloadSchema = z.object({ export const pureEnvPayloadSchema = z.object({
analyticsAPI: z.string().url().optional(),
referralAPI: z.string().url(), referralAPI: z.string().url(),
networks: z.record( networks: z.record(
z.nativeEnum(SupportedChainId), z.nativeEnum(SupportedChainId),

View File

@@ -279,6 +279,7 @@ export type KnownEnv = typeof knownEnvs[number];
export type Json = string | number | boolean | null | Json[] | { [key: string]: Json }; export type Json = string | number | boolean | null | Json[] | { [key: string]: Json };
export type EnvConfig = { export type EnvConfig = {
analyticsAPI: string | undefined
referralAPI: string referralAPI: string
networks: Partial< networks: Partial<
Record< Record<