diff --git a/README.md b/README.md index bdd281c..f6ffba2 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ Blockchains known to the platform and their integration statuses. Each chain has * `getSupportedChainNames(): ChainName[]` * `getChainsTotals(): {[status in ChainStatus]: number}` +* `getChainByName(chainName: ChainName): Chain` ### 🌐 Integrations diff --git a/package.json b/package.json index 63008fc..4419c96 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@stabilitydao/stability", - "version": "0.18.2", + "version": "0.18.3", "description": "Stability Integration Library", "main": "out/index.js", "types": "out/index.d.ts", diff --git a/src/chains.ts b/src/chains.ts index 40a058d..216cd58 100644 --- a/src/chains.ts +++ b/src/chains.ts @@ -573,3 +573,13 @@ export const getChainsTotals = (): { [status in ChainStatus]: number } => { [ChainStatus.NOT_SUPPORTED]: ids.filter(networkId => chains[networkId].status == ChainStatus.NOT_SUPPORTED).length, } } + +export const getChainByName = (chainName: ChainName): Chain => { + for (const chainId in chains) { + const chain = chains[chainId] + if (chain && chain.name === chainName) { + return chain + } + } + throw new Error(`Incorrect chain name ${chainName}`) +} diff --git a/src/contests.ts b/src/contests.ts index 6e31f0a..abf0ec6 100644 --- a/src/contests.ts +++ b/src/contests.ts @@ -7,9 +7,10 @@ export interface YieldContest { start: number, // end timestamp end: number, - minEarn: number, + // minimal USD income to pass contest + minEarn: number|"TBA", // contest rewards - rewards: Reward[], + rewards: Reward[]|"TBA", // integration of quest platform campaign integration?: { // Intract campaign id @@ -144,4 +145,20 @@ export const contests: { [contestId: string]: YieldContest } = { }, ], }, + "y4": { + // 05 Dec 2024 - 18 Dec 2024 + name: "Yield Contest #4", + start: 1733356800, // Thu, 05 Dec 2024 00:00:00 GMT + end: 1734566399, // Wed, 18 Dec 2024 23:59:59 GMT + minEarn: "TBA", + rewards: "TBA", + }, + "y5": { + // 19 Dec 2024 - 01 Jan 2025 + name: "Yield Contest #5", + start: 1734566400, // Thu, 19 Dec 2024 00:00:00 GMT + end: 1735775999, // Wed, 01 Jan 2025 23:59:59 GMT + minEarn: "TBA", + rewards: "TBA", + }, } diff --git a/src/index.ts b/src/index.ts index fb4efbf..9376fbc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,7 +7,8 @@ import { Chain, ChainStatusInfo, getSupportedChainNames, - getChainsTotals + getChainsTotals, + getChainByName } from "./chains"; import { strategies, @@ -71,6 +72,7 @@ export { getChainProtocols, getChainStrategies, getSupportedChainNames, + getChainByName, assets, Asset, getAsset, diff --git a/tests/chains.test.ts b/tests/chains.test.ts new file mode 100644 index 0000000..c845fce --- /dev/null +++ b/tests/chains.test.ts @@ -0,0 +1,19 @@ +import {ChainName, getChainByName, getChainsTotals, getSupportedChainNames} from "../src"; + +describe('testing chains', () => { + test('get supported chain names', () => { + expect(getSupportedChainNames().length).toBeGreaterThan(1) + }) + test('getChainsTotals', () => { + const s = getChainsTotals() + expect(s.SUPPORTED).toBeGreaterThan(1) + }) + test('getChainByName', () => { + let s = getChainByName(ChainName.POLYGON) + expect(s.name).toEqual("Polygon") + const t = () => { + s = getChainByName('incorrect' as ChainName) + }; + expect(t).toThrow(Error); + }) +}) diff --git a/tests/contests.test.ts b/tests/contests.test.ts index 758cadf..f81d078 100644 --- a/tests/contests.test.ts +++ b/tests/contests.test.ts @@ -1,4 +1,4 @@ -import {contests} from "../src"; +import {contests, Reward, RewardType, YieldContest} from "../src"; describe('testing contests', () => { test('check start less then end', () => { @@ -6,4 +6,8 @@ describe('testing contests', () => { expect(contests[contestId].start).toBeLessThan(contests[contestId].end) } }) + test('types', () => { + const c: YieldContest = contests["y1"] + expect((c.rewards[0] as Reward).type).toEqual(RewardType.POINTS) + }) }) diff --git a/tests/networks.test.ts b/tests/networks.test.ts deleted file mode 100644 index c0fca83..0000000 --- a/tests/networks.test.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {getChainsTotals, getSupportedChainNames} from "../src"; - -describe('testing chains', () => { - test('get supported network IDs', () => { - expect(getSupportedChainNames().length).toBeGreaterThan(1) - }) - test('getNetworksTotals', () => { - const s = getChainsTotals() - expect(s.SUPPORTED).toBeGreaterThan(1) - }) -}) diff --git a/tools/create-contests.ts b/tools/create-contests.ts index 889b586..43c7b2b 100644 --- a/tools/create-contests.ts +++ b/tools/create-contests.ts @@ -20,6 +20,8 @@ for (let i = +(lastId.replace('y', '') || 0) + 1; i < +(lastId.replace('y', '') name: "${name}", start: ${start}, // ${new Date(start * 1000).toUTCString()} end: ${end}, // ${new Date(end * 1000).toUTCString()} + minEarn: "TBA", + rewards: "TBA", \},`) prevTs += PERIOD }