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

feat: announcement banner on deposit withdraw screens #297

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
8 changes: 4 additions & 4 deletions .github/markets/pr_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Each json file under the [configs](../../configs) folder correspond to their res
|`market_promo` |`MarketPromo` |false |Map of Objects that contains market promo parameters for each market |If the `market_promo` property is omitted, no promo will be shown. The key of each entry is the ids of the market with existing promo. |
|`spot_pool_config` |`SpotPoolConfig` |false |Object that contains the config parameters for the [Spot Pools](https://app.dem.exchange/pools/spot) page on Demex |
|`quick_select_tokens` |`QuickSelectToken[]` |true |List of quick select tokens for deposit and withdrawal forms. |
kylehoang92 marked this conversation as resolved.
Show resolved Hide resolved

|`disabled_transfer_banner_config` |`DisabledTransferBannerConfig` |false |Config parameters for displaying banner to inform users that transfers for the relevant tokens are disabled |
## TransferDisabledTokens Data Structure
|Field |Type |Required |Description |Notes |
|---|---|---|---|---|
Expand Down Expand Up @@ -131,6 +131,6 @@ Each json file under the [configs](../../configs) folder correspond to their res
## TransferBanner Data Structure
sarah-thong marked this conversation as resolved.
Show resolved Hide resolved
|Field |Type |Required |Description |Notes |
|---|---|---|---|---|
|`no_longer_supported_tokens` |`string[]` |false |List of tokens are no longer supported |
|`temporary_disabled_transfer_tokens` |`object` |false |List of tokens for which deposits and withdrawals have been temporarily disabled |
|`temporary_disabled_bridges` |`object` |false |List of bridges for which deposits and withdrawals have been temporarily disabled |
|`unsupported_tokens` |`string[]` |false |List of tokens that are no longer supported | 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) |
|`temp_disabled_transfer_tokens` |`object` |false |List of tokens for which deposits and withdrawals have been temporarily disabled | The token denoms listed in this object **MUST** match the token denoms listed under the Carbon [Tokens API](https://api.carbon.network/carbon/coin/v1/tokens?pagination.limit=10000) |
|`temp_disabled_bridges` |`object` |false |List of bridges for which deposits and withdrawals have been temporarily disabled | Blockchain network listed here **MUST** match the valid chainName of the bridges listed under BridgeAll RPC call.<br /><br /> To view the values of BridgeAll RPC call, simply run yarn get-bridges [network]on the command line. Sample for mainnet:yarn get-bridges mainnet`` |
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ More metadata will be added in the future if required by the Demex frontend. Ple
"currentCompPerpPoolId": 1
},
"transfer_banner": {
"no_longer_supported_tokens": ["denom_1", "denom_2"],
"temporary_disabled_transfer_tokens": {
"unsupported_tokens": ["denom_1", "denom_2"],
"temp_disabled_transfer_tokens": {
"denom_1": {
"start": "",
"end": ""
}
},
"temporary_disabled_bridges": {
"temp_disabled_bridges": {
"bridge_address_1": {
"start": "",
"end": ""
Expand Down
66 changes: 29 additions & 37 deletions config.schema.json
kylehoang92 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,12 @@
},
"start": {
"type": "string",
"description": "The start time of perp pool promo",
"description": "The start time of the relevant program (in timestamp format)",
"pattern": "^\\d{4}(-\\d\\d(-\\d\\d(T\\d\\d:\\d\\d(:\\d\\d)?(\\.\\d+)?(([+-]\\d\\d:\\d\\d)|Z)?)?)?)?$"
},
"end": {
"type": "string",
"description": "The end time of perp pool promo",
"description": "The end time of the relevant program (in timestamp format)",
"pattern": "^\\d{4}(-\\d\\d(-\\d\\d(T\\d\\d:\\d\\d(:\\d\\d)?(\\.\\d+)?(([+-]\\d\\d:\\d\\d)|Z)?)?)?)?$"
},
"perpPoolDepositBoost": {
Expand Down Expand Up @@ -516,27 +516,45 @@
}
}
},
"transfer_banner": {
"quick_select_token": {
"type": "object",
"description": "Token denom for quick select in transfer form",
"required": ["label_denom", "target_denom"],
"properties": {
"label_denom": {
"type": "string",
"description": "Token denom to show on UI"
},
"target_denom": {
"type": "string",
"description": "Token denom to use in transfer"
}
}
},
"quick_select_tokens": {
"type": "array",
"description": "List of tokens for quick select in transfer form",
"items": {
"$ref": "#/$defs/quick_select_token"
}
},
"disabled_transfer_banner_config": {
"type": "object",
"description": "Config parameters to show banner for deposit and withdraw screens",
"description": "Config parameters for displaying banner to inform users that transfers for the relevant tokens are disabled",
"properties": {
"no_longer_supported_tokens": {
"unsupported_tokens": {
"type": "array",
"description": "List of tokens are no longer supported",
"items": {
"type": "string"
}
},
"temporary_disabled_transfer_tokens": {
"temp_disabled_transfer_tokens": {
"type": "object",
"description": "List of tokens for which deposits and withdrawals have been temporarily disabled",
"patternProperties": {
".*": {
"type": "object",
"required": [
"start",
"end"
],
"properties": {
"start": {
"$ref": "#/$defs/start"
Expand All @@ -548,16 +566,12 @@
}
}
},
"temporary_disabled_bridges": {
"temp_disabled_bridges": {
"type": "object",
"description": "List of bridges for which deposits and withdrawals have been temporarily disabled",
"patternProperties": {
".*": {
"type": "object",
"required": [
"start",
"end"
],
"properties": {
"start": {
"$ref": "#/$defs/start"
Expand All @@ -570,28 +584,6 @@
}
sarah-thong marked this conversation as resolved.
Show resolved Hide resolved
}
}
},
"quick_select_token": {
"type": "object",
"description": "Token denom for quick select in transfer form",
"required": ["label_denom", "target_denom"],
"properties": {
"label_denom": {
"type": "string",
"description": "Token denom to show on UI"
},
"target_denom": {
"type": "string",
"description": "Token denom to use in transfer"
}
}
},
"quick_select_tokens": {
"type": "array",
"description": "List of tokens for quick select in transfer form",
"items": {
"$ref": "#/$defs/quick_select_token"
}
}
}
}
8 changes: 4 additions & 4 deletions configs/devnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
"target_denom" : "dai"
}
],
"transfer_banner": {
"no_longer_supported_tokens": [],
"temporary_disabled_transfer_tokens": {},
"temporary_disabled_bridges": {}
"disabled_transfer_banner_config": {
"unsupported_tokens": [],
"temp_disabled_transfer_tokens": {},
"temp_disabled_bridges": {}
}
kylehoang92 marked this conversation as resolved.
Show resolved Hide resolved
}
8 changes: 4 additions & 4 deletions configs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,9 @@
"target_denom": "brdg/a02afc2c1edf77cc023eefa25fc036c184612faf9365cda9c1daa3b1675ebf8f"
}
],
"transfer_banner": {
"no_longer_supported_tokens": [],
"temporary_disabled_transfer_tokens": {},
"temporary_disabled_bridges": {}
"disabled_transfer_banner_config": {
"unsupported_tokens": [],
"temp_disabled_transfer_tokens": {},
"temp_disabled_bridges": {}
}
kylehoang92 marked this conversation as resolved.
Show resolved Hide resolved
}
8 changes: 4 additions & 4 deletions configs/testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
"target_denom" : "dai"
}
],
"transfer_banner": {
"no_longer_supported_tokens": [],
"temporary_disabled_transfer_tokens": {},
"temporary_disabled_bridges": {}
"disabled_transfer_banner_config": {
"unsupported_tokens": [],
"temp_disabled_transfer_tokens": {},
"temp_disabled_bridges": {}
}
kylehoang92 marked this conversation as resolved.
Show resolved Hide resolved
}
63 changes: 35 additions & 28 deletions scripts/check_configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface ConfigJSON {
market_banners?: MarketBanner[];
market_promo?: {[marketId: string]: MarketPromo};
spot_pool_config?: SpotPoolConfig;
transfer_banner?: TransferBanner;
disabled_transfer_banner_config?: DisabledTransferBannerConfig;
quick_select_deposit_options?: QuickSelectToken[];
}

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

interface TransferBanner {
no_longer_supported_tokens: [],
temporary_disabled_transfer_tokens: {
interface DisabledTransferBannerConfig {
unsupported_tokens?: [],
temp_disabled_transfer_tokens?: {
[denom: string]: {
start: string,
end: string
start?: string,
end?: string
}
},
temporary_disabled_bridges: {
temp_disabled_bridges?: {
[bridgeAddress: string]: {
start: string,
end: string
start?: string,
end?: string
}
}
kylehoang92 marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down Expand Up @@ -443,28 +443,35 @@ function isValidMarketPromo(marketPromo: {[marketId: string]: MarketPromo}, netw
return true;
}

function isValidTransferBanner(transferBanner: TransferBanner, network: CarbonSDK.Network): boolean {
const { temporary_disabled_transfer_tokens, temporary_disabled_bridges } = transferBanner;
if (Object.keys(temporary_disabled_transfer_tokens).length > 0) {
Object.keys(temporary_disabled_transfer_tokens).map((key) => {
const { start, end } = temporary_disabled_transfer_tokens[key];
const startTime = new Date(start);
const endTime = new Date(end);
if (endTime < startTime) {
console.error(`ERROR: ${network}.json has invalid end time (${end}) is before start time (${start}) for token denom ${key}.`);
return false;
function isValidTransferBanner(transferBanner: DisabledTransferBannerConfig, network: CarbonSDK.Network): boolean {
const { temp_disabled_transfer_tokens = {}, temp_disabled_bridges = {} } = transferBanner;
const disabledTokenKeys = Object.keys(temp_disabled_transfer_tokens)

if (disabledTokenKeys.length > 0) {
disabledTokenKeys.map((key) => {
sarah-thong marked this conversation as resolved.
Show resolved Hide resolved
const { start, end } = temp_disabled_transfer_tokens[key];
if (end && start) {
const startTime = new Date(start);
const endTime = new Date(end);
if (endTime < startTime) {
console.error(`ERROR: ${network}.json has an invalid end time (${end}) as it is before start time (${start}) for token denom ${key}.`);
sarah-thong marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
}
});
}

if (Object.keys(temporary_disabled_bridges).length > 0) {
Object.keys(temporary_disabled_bridges).map((key) => {
const { start, end } = temporary_disabled_bridges[key];
const startTime = new Date(start);
const endTime = new Date(end);
if (endTime < startTime) {
console.error(`ERROR: ${network}.json has invalid end time (${end}) is before start time (${start}) for bridge address ${key}.`);
return false;
const disabledBridgeKeys = Object.keys(temp_disabled_bridges)
if (disabledBridgeKeys.length > 0) {
disabledBridgeKeys.map((key) => {
sarah-thong marked this conversation as resolved.
Show resolved Hide resolved
const { start, end } = temp_disabled_bridges[key];
if (start && end) {
const startTime = new Date(start);
const endTime = new Date(end);
if (endTime < startTime) {
console.error(`ERROR: ${network}.json has an invalid end time (${end}) as it is before start time (${start}) for bridge ${key}.`);
sarah-thong marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
}
});
}
Expand Down Expand Up @@ -855,7 +862,7 @@ async function main() {
}

// transfer banner check
if (jsonData.transfer_banner && !isValidTransferBanner(jsonData.transfer_banner, network)) {
if (jsonData.disabled_transfer_banner_config && !isValidTransferBanner(jsonData.disabled_transfer_banner_config, network)) {
outcomeMap[network] = false;
}

Expand Down