Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update config scheman for custom announcement banner #287

Merged
merged 31 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3a326b0
Update config scheman for custom announcement banner
huy9x101 Dec 12, 2024
b2c2826
update announement banner schema and config
huy9x101 Dec 16, 2024
4f526fe
Merge branch 'master' into feat/custom-announcement-banner-
huy9x101 Dec 16, 2024
3cbd4ee
Update sample json data
huy9x101 Dec 17, 2024
bacf8ed
Remove changes from mainnet/testnet.json
huy9x101 Dec 17, 2024
dee418e
Add devnet content for testing purpose
huy9x101 Dec 17, 2024
aaf0d19
Show announcement
Dec 17, 2024
cbf8322
update config
Dec 17, 2024
daaaff7
Update show time
Dec 17, 2024
90e9868
Update content for banner
Dec 17, 2024
6dcdb17
Hide the banner
Dec 17, 2024
c8cda4b
Show the banner
Dec 17, 2024
fe00065
Update time
Dec 17, 2024
cc28a0b
Merge branch 'master' into feat/custom-announcement-banner-
huy9x101 Dec 17, 2024
08ab0fc
Remove bnb as network_fees token
huy9x101 Dec 17, 2024
69fe4ee
Update check-configs and sample json data
huy9x101 Dec 17, 2024
8890226
add data test
huy9x101 Dec 17, 2024
453f449
Add sample show rely on
huy9x101 Dec 18, 2024
f7e9329
Merge branch 'master' into feat/custom-announcement-banner-
huy9x101 Dec 18, 2024
3bad927
Update config
KimieTran Dec 18, 2024
16dfded
update config
KimieTran Dec 18, 2024
c9ef757
Update test data devnet
huy9x101 Dec 19, 2024
f31c8b6
update test devnet
huy9x101 Dec 19, 2024
181fba4
Update devnet data
huy9x101 Dec 19, 2024
1fc190c
Update devnet data
huy9x101 Dec 19, 2024
7291618
Update devnet data
huy9x101 Dec 19, 2024
9e6d512
Update config to test
Dec 19, 2024
01903a3
Update config to test
Dec 19, 2024
6e6e62c
update config
Dec 19, 2024
bdf75dd
Update to show all pages
Dec 19, 2024
4b62d2c
Update content
huy9x101 Dec 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/markets/pr_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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 |
Expand Down Expand Up @@ -122,6 +123,15 @@ Each json file under the [configs](../../configs) folder correspond to their res
|---|---|---|---|---|
|`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.<br /><br /> This field **MUST** follow the valid ISO 8601 format <br /> 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.<br /><br /> This field **MUST** follow the valid ISO 8601 format <br /> 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, sample: `['/rewards', '/nitron']` |

## QuickSelectToken Data Structure
|Field |Type |Required |Description |Notes |
|---|---|---|---|---|
Expand Down
59 changes: 53 additions & 6 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
"properties": {
"network": {
"type": "string",
"enum": ["mainnet", "testnet", "devnet"]
"enum": [
"mainnet",
"testnet",
"devnet"
]
},
"prelaunch_markets": {
"type": "array",
Expand Down Expand Up @@ -168,7 +172,11 @@
"description": "Ongoing survey configs for typeform survey widget",
"items": {
"type": "object",
"required": ["surveyLink", "endTime", "pages"],
"required": [
"surveyLink",
"endTime",
"pages"
],
"properties": {
"message": {
"type": "string"
Expand Down Expand Up @@ -251,7 +259,10 @@
"description": "List of banner information to be displayed over the TradingView chart for the required market",
"items": {
"type": "object",
"required": ["market_id", "content"],
"required": [
"market_id",
"content"
],
"properties": {
"market_id": {
"$ref": "#/$defs/market_id"
Expand Down Expand Up @@ -421,7 +432,10 @@
"additional_ibc_token_info": {
"type": "object",
"description": "Information for token that (1) is not added on Carbon blockchain or (2) requires packet forwarding.",
"required": ["baseDenom", "chainRoutes"],
"required": [
"baseDenom",
"chainRoutes"
],
"properties": {
"baseDenom": {
"type": "string",
Expand Down Expand Up @@ -461,7 +475,10 @@
"description": "List of perp pool banners",
"items": {
"type": "object",
"required": ["perp_pool_id", "title"],
"required": [
"perp_pool_id",
"title"
],
"properties": {
"perp_pool_id": {
"$ref": "#/$defs/perp_pool_id"
Expand Down Expand Up @@ -516,6 +533,36 @@
}
}
},
"announcement_banner": {
"type": "object",
"description": "Custom announcement banner through all or only on specificed paths",
"required": [
"content",
"show_only_on"
],
"patternProperties": {
"show_from": {
"$ref": "#/$defs/show_from"
},
"show_until": {
"$ref": "#/$defs/show_until"
},
"content": {
"$ref": "#/$defs/content"
},
"hideable": {
"$ref": "#/$defs/hideable"
},
"show_only_on": {
"type": "array",
"description": "List of paths that announcement will be show on. Empty array will be shown on all paths",
"items": {
"type": "string"
},
"minItems": 0
}
}
},
"quick_select_token": {
"type": "object",
"description": "Token denom for quick select in transfer form",
Expand All @@ -539,4 +586,4 @@
}
}
}
}
}
7 changes: 7 additions & 0 deletions configs/devnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
"spot_pool_config": {
"show_apr_tooltip": false
},
"announcement_banner": {
"show_from": "2024-12-19T02:18+00:00",
"show_until": "2024-12-19T02:21+00:00",
"content": "Demex will be down for maintenance from 03:00 - 08:00 UTC, 23 Dec. We recommend closing any open orders during this time to minimize potential risks.",
"hideable": false,
"show_only_on": []
},
"quick_select_deposit_options": [
{
"label_denom": "swth",
Expand Down
7 changes: 7 additions & 0 deletions configs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,13 @@
"spot_pool_config": {
"show_apr_tooltip": true
},
"announcement_banner": {
"show_from": "",
"show_until": "",
"content": "",
"hideable": true,
"show_only_on": []
},
"quick_select_deposit_options": [
{
"label_denom": "brdg/d8c3db91ad4ba11fe52971b4c387b0110c8951ec0f5b8f0fb445ef0306a349e1",
Expand Down
7 changes: 7 additions & 0 deletions configs/testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
"spot_pool_config": {
"show_apr_tooltip": false
},
"announcement_banner": {
"show_from": "",
"show_until": "",
"content": "",
"hideable": true,
"show_only_on": []
},
"quick_select_deposit_options": [
{
"label_denom": "swth",
Expand Down
27 changes: 27 additions & 0 deletions scripts/check_configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ interface ConfigJSON {
market_banners?: MarketBanner[];
market_promo?: {[marketId: string]: MarketPromo};
spot_pool_config?: SpotPoolConfig;
announcement_banner: AnnouncementBanner;
quick_select_deposit_options?: QuickSelectToken[];
}

Expand Down Expand Up @@ -133,6 +134,14 @@ interface SpotPoolConfig {
show_apr_tooltip: boolean;
}

interface AnnouncementBanner {
show_from?: string;
show_until?: string;
content: string;
hideable?: boolean;
show_only_on: string[];
}

interface QuickSelectToken {
label_denom: string;
target_denom: string;
Expand Down Expand Up @@ -391,6 +400,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)
Expand Down Expand Up @@ -785,6 +808,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
Expand Down
Loading