From b611cdc59b80f31fcf907291b2663e08655698e9 Mon Sep 17 00:00:00 2001 From: Taehoon Lee <19664986+ttl33@users.noreply.github.com> Date: Wed, 24 Jan 2024 13:59:20 -0800 Subject: [PATCH] export title and summary helpers --- v4-client-js/examples/gov_add_new_market.ts | 19 +++------------- v4-client-js/src/lib/utils.ts | 24 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/v4-client-js/examples/gov_add_new_market.ts b/v4-client-js/examples/gov_add_new_market.ts index e76b63b4..f2122fc7 100644 --- a/v4-client-js/examples/gov_add_new_market.ts +++ b/v4-client-js/examples/gov_add_new_market.ts @@ -3,7 +3,7 @@ import Long from 'long'; import { GovAddNewMarketParams, LocalWallet, ProposalStatus } from '../src'; import { CompositeClient } from '../src/clients/composite-client'; import { BECH32_PREFIX, Network } from '../src/clients/constants'; -import { sleep } from '../src/lib/utils'; +import { getAddNewMarketSummary, getAddNewMarketTitle, sleep } from '../src/lib/utils'; import { DYDX_LOCAL_MNEMONIC } from './constants'; const INITIAL_DEPOSIT_AMOUNT = 10_000_000_000_000; // 10,000 whole native tokens. @@ -66,8 +66,8 @@ async function test(): Promise { const tx = await client.submitGovAddNewMarketProposal( wallet, MOCK_DATA, - getTitle(MOCK_DATA.ticker), - getSummary(MOCK_DATA.ticker, MOCK_DATA.delayBlocks), + getAddNewMarketTitle(MOCK_DATA.ticker), + getAddNewMarketSummary(MOCK_DATA.ticker, MOCK_DATA.delayBlocks), INITIAL_DEPOSIT_AMOUNT, ); console.log('**Tx**'); @@ -88,19 +88,6 @@ async function test(): Promise { console.log(votingProposals); } -function getTitle( - ticker: string, -): string { - return `Add ${ticker} perpetual market`; -} - -function getSummary( - ticker: string, - delayBlocks: number, -): string { - return `Add the x/prices, x/perpetuals and x/clob parameters needed for a ${ticker} perpetual market. Create the market in INITIALIZING status and transition it to ACTIVE status after ${delayBlocks} blocks.`; -} - test().catch((error) => { console.error(error); }); diff --git a/v4-client-js/src/lib/utils.ts b/v4-client-js/src/lib/utils.ts index 18c3ec83..75cbce1a 100644 --- a/v4-client-js/src/lib/utils.ts +++ b/v4-client-js/src/lib/utils.ts @@ -43,3 +43,27 @@ export function clientIdFromString( export async function sleep(ms: number): Promise { return new Promise((resolve) => setTimeout(resolve, ms)); } + +/** + * Returns a title to use for a gov proposal that adds a new market. + * + * @param ticker ticker symbol for the new market. + * @returns title for the gov proposal. + */ +export function getAddNewMarketTitle(ticker: string): string { + return `Add ${ticker} perpetual market`; +} + +/** + * Returns a summary to use for a gov proposal that adds a new market. + * + * @param ticker ticker symbol for the new market. + * @param delayBlocks number of blocks to wait before activating the market. + * @returns summary for the gov proposal. + */ +export function getAddNewMarketSummary( + ticker: string, + delayBlocks: number, +): string { + return `Add the x/prices, x/perpetuals and x/clob parameters needed for a ${ticker} perpetual market. Create the market in INITIALIZING status and transition it to ACTIVE status after ${delayBlocks} blocks.`; +}