diff --git a/.github/markets/pr_template.md b/.github/markets/pr_template.md index 6ecb128..d177299 100644 --- a/.github/markets/pr_template.md +++ b/.github/markets/pr_template.md @@ -35,6 +35,7 @@ Each json file under the [configs](../../configs) folder correspond to their res |---|---|---|---|---| |`deposit` |`string[]` |true |List of tokens for which deposits are temporarily disabled |The token denoms listed here **MUST** match the token denoms listed under the Carbon [Tokens API](https://api.carbon.network/carbon/coin/v1/tokens?pagination.limit=10000). | |`withdraw` |`string[]` |true |List of tokens for which withdrawals are temporarily disabled |The token denoms listed here **MUST** match the token denoms listed under the Carbon [Tokens API](https://api.carbon.network/carbon/coin/v1/tokens?pagination.limit=10000). | +|`announcement_banner` |`AnnouncementBanner` |false |Custom announcement banner through all or only on specificed paths | ## Maintenance Data Structure |Field |Type |Required |Description |Notes | @@ -119,4 +120,13 @@ Each json file under the [configs](../../configs) folder correspond to their res ## SpotPoolConfig Data Structure |Field |Type |Required |Description |Notes | |---|---|---|---|---| -|`show_apr_tooltip` |`boolean` |true |Indicates whether or not to show the Annual Percentage Returns (APR) tooltip on [Spot Pools](https://app.dem.exchange/pools/spot) page | \ No newline at end of file +|`show_apr_tooltip` |`boolean` |true |Indicates whether or not to show the Annual Percentage Returns (APR) tooltip on [Spot Pools](https://app.dem.exchange/pools/spot) page | + +## AnnouncementBanner +|Field |Type |Required |Description |Notes | +|---|---|---|---|---| +|`show_from` |`string` |false |The date and time when the market banner is scheduled to begin displaying. |If not provided, the banner will be shown immediately.

This field **MUST** follow the valid ISO 8601 format
e.g. *2024-01-23T09:00+00:00* (23 Jan 2024, 9am UTC) | +|`show_until` |`string` |false |The date and time when the market banner is scheduled to stop displaying. |If not provided, the banner will continue to display indefinitely.

This field **MUST** follow the valid ISO 8601 format
e.g. *2024-01-23T09:00+00:00* (23 Jan 2024, 9am UTC) | +|`content` |`string` |true |The content shown on the market banner. | +|`hideable` |`boolean` |false |Indicates if user can hide the banner by clicking on the close button |If set to `false`, the close button will not be rendered on the banner, and user will not be able to dismiss the banner. | +|`show_only_on` |`string[]` |true |Default is empty list, then banner will be shown on all pages |If list has specified path(s), the banner will be shown on these/that path(s) only. | diff --git a/config.schema.json b/config.schema.json index 0242745..9a280ac 100644 --- a/config.schema.json +++ b/config.schema.json @@ -537,7 +537,8 @@ "type": "object", "description": "Custom announcement banner through all or only on specificed paths", "required": [ - "content" + "content", + "show_only_on" ], "patternProperties": { "show_from": { diff --git a/configs/mainnet.json b/configs/mainnet.json index 5f4175f..d13f698 100644 --- a/configs/mainnet.json +++ b/configs/mainnet.json @@ -482,5 +482,12 @@ }, "spot_pool_config": { "show_apr_tooltip": true + }, + "announcement_banner": { + "show_from": "", + "show_until": "", + "content": "", + "hideable": true, + "show_only_on": [] } } diff --git a/configs/testnet.json b/configs/testnet.json index 2d3c393..39caa1f 100644 --- a/configs/testnet.json +++ b/configs/testnet.json @@ -59,5 +59,12 @@ }, "spot_pool_config": { "show_apr_tooltip": false + }, + "announcement_banner": { + "show_from": "", + "show_until": "", + "content": "", + "hideable": true, + "show_only_on": [] } } diff --git a/scripts/check_configs.ts b/scripts/check_configs.ts index c13f7d3..fe3e524 100644 --- a/scripts/check_configs.ts +++ b/scripts/check_configs.ts @@ -34,6 +34,7 @@ interface ConfigJSON { market_banners?: MarketBanner[]; market_promo?: {[marketId: string]: MarketPromo}; spot_pool_config?: SpotPoolConfig; + announcement_banner: AnnouncementBanner; } interface InvalidEntry { @@ -132,6 +133,14 @@ interface SpotPoolConfig { show_apr_tooltip: boolean; } +interface AnnouncementBanner { + show_from?: string; + show_until?: string; + content: string; + hideable?: boolean; + show_only_on: string[]; +} + type OutcomeMap = { [key in CarbonSDK.Network]: boolean }; // true = success, false = failure const outcomeMap: OutcomeMap = { @@ -385,6 +394,20 @@ function isValidMarketBanners(marketBanners: MarketBanner[], network: CarbonSDK. return true; } +function isValidAnnouncementBanner(announcementBanner: AnnouncementBanner, network: CarbonSDK.Network): boolean { + const startTime = announcementBanner.show_from ? new Date(announcementBanner.show_from) : null + const endTime = announcementBanner.show_until ? new Date(announcementBanner.show_until) : null + + if (startTime && endTime) { + const isValidStartEndTime = endTime.getTime() > startTime.getTime() + if (!isValidStartEndTime) { + console.error(`ERROR: ${network}.json has the following invalid show_from ${announcementBanner.show_from} and invalid show_until ${announcementBanner.show_until} `); + return false + } + } + return true +} + function isValidMarketPromo(marketPromo: {[marketId: string]: MarketPromo}, network: CarbonSDK.Network, marketIds: string[]): boolean { const marketPromoIds = Object.keys(marketPromo) const hasInvalidMarketPromoIds = checkValidEntries(marketPromoIds, marketIds) @@ -753,6 +776,10 @@ async function main() { outcomeMap[network] = false; } + if(jsonData.announcement_banner && !isValidAnnouncementBanner(jsonData.announcement_banner, network)) { + outcomeMap[network] = false; + } + // check for spot pool config if (jsonData.spot_pool_config) { const spotPoolConfig = jsonData.spot_pool_config