feat: added frontage service

This commit is contained in:
Mikhail Gladchenko
2024-03-29 08:49:00 +00:00
parent d17fed1e9e
commit 57474d2872
10 changed files with 148 additions and 3 deletions

View File

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

View File

@@ -60,7 +60,10 @@ export default class Orion {
},
indexer: {
api: networkConfig.api + networkConfig.services.indexer?.http,
}
},
frontage: {
api: networkConfig.api + networkConfig.services.frontage.http,
},
},
};
})

View File

@@ -11,7 +11,7 @@ import Exchange from './Exchange/index.js';
import { chains, envs } from '../config';
import type { networkCodes } from '../constants/index.js';
import { IndexerService } from '../services/Indexer';
import Pmm from "./Pmm";
import Pmm from './Pmm';
type KnownConfig = {
env: KnownEnv
@@ -88,6 +88,9 @@ export default class Unit {
indexer: {
api: networkConfig.api + networkConfig.services.indexer?.http,
},
frontage: {
api: networkConfig.api + networkConfig.services.frontage.http,
},
},
};
} else {

View File

@@ -17,6 +17,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
},
"liquidityMigratorAddress": "0x23a1820a47BcD022E29f6058a5FD224242F50D1A"
@@ -36,6 +39,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -54,6 +60,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -72,6 +81,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -90,6 +102,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -108,6 +123,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -126,6 +144,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -144,6 +165,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -162,6 +186,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -180,6 +207,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
}
@@ -203,6 +233,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
},
"liquidityMigratorAddress": "0x01b10dds12478C88A5E18e2707E729906bC25CfF6"
@@ -222,6 +255,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -240,6 +276,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -258,6 +297,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -276,6 +318,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -294,6 +339,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
}
@@ -317,6 +365,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -335,6 +386,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -353,6 +407,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -371,6 +428,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -389,6 +449,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -407,6 +470,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -425,6 +491,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -443,6 +512,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -461,6 +533,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -479,6 +554,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
}
@@ -502,6 +580,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -520,6 +601,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
}
@@ -543,6 +627,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
},
"liquidityMigratorAddress": "0x23a1820a47BcD022E29f6058a5FD224242F50D1A"
@@ -562,6 +649,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -580,6 +670,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -598,6 +691,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
},
@@ -616,6 +712,9 @@
},
"indexer": {
"http": "/orion-indexer/"
},
"frontage": {
"http": "/frontage"
}
}
}

View File

@@ -17,6 +17,9 @@ export const pureEnvNetworksSchema = z.object({
indexer: z.object({
http: z.string(),
}).optional(),
frontage: z.object({
http: z.string(),
}),
}),
rpc: z.string().optional(),
liquidityMigratorAddress: z.string().optional(),

View File

@@ -0,0 +1,20 @@
import { fetchWithValidation } from 'simple-typed-fetch';
import { searchTickersSchema } from './schemas';
export class Frontage {
private readonly apiUrl: string;
constructor(apiUrl: string) {
this.apiUrl = apiUrl;
this.searchTickers = this.searchTickers.bind(this);
}
searchTickers = () => {
return fetchWithValidation(`${this.apiUrl}/api/v1/tickers/search`,
searchTickersSchema
);
};
}
export * as schemas from './schemas/index.js';

View File

@@ -0,0 +1 @@
export * from './search-tickers-schema';

View File

@@ -0,0 +1,9 @@
import { z } from 'zod';
export const searchTickersSchema = z.array(z.object({
pair: z.string(),
volume24: z.number(),
change24: z.number(),
lastPrice: z.number(),
networks: z.array(z.string()),
}));

View File

@@ -3,3 +3,4 @@ export * as blockchainService from './BlockchainService/index.js';
export * as priceFeed from './PriceFeed/index.js';
export * as referralSystem from './ReferralSystem/index.js';
export * as indexer from './Indexer/index.js';
export * as frontage from './Frontage/index.js';

View File

@@ -271,6 +271,12 @@ export type VerboseUnitConfig = {
// http://localhost:3004/,
// http://
} | undefined
frontage: {
api: string
// For example:
// http://localhost:3004/,
// http://
}
}
basicAuth?: BasicAuthCredentials
}