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
6 changes: 3 additions & 3 deletions .github/markets/pr_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ Each json file under the [configs](../../configs) folder correspond to their res
|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. |
|`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']` |

Expand All @@ -138,7 +138,7 @@ Each json file under the [configs](../../configs) folder correspond to their res
|`label_denom` |`string` |true |The default token will be show on UI deposit/withdrawal forms |
|`target_denom` |`string` |true |The default token will be use to transfer in deposit/withdrawal |

## TransferBanner Data Structure
## DisabledTransferBannerConfig Data Structure
|Field |Type |Required |Description |Notes |
|---|---|---|---|---|
|`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) |
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ More metadata will be added in the future if required by the Demex frontend. Ple
"bridge_address_1": {
"start": "",
"end": ""
}
},
"src_channel": {}, // for ibcBridges
"connectionId": {} // for axelarBridges
}
}
}
Expand Down
34 changes: 23 additions & 11 deletions scripts/check_configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,18 +485,18 @@ function isValidDisabledTransferBannerConfig(transferBanner: DisabledTransferBan
const validDisabledTknsOutcome = checkValidEntries(disabledTokenKeys, denoms);

if (validDisabledTknsOutcome.status && isErrorOutcome(validDisabledTknsOutcome)) {
const invalidDissabedTokensStr = joinEntriesIntoStr(validDisabledTknsOutcome.entry!);
console.error(`[ERROR] disabled_transfer_banner_config.temp_disabled_transfer_tokens of ${network}.json has the following invalid token denoms: ${invalidDissabedTokensStr}. Please make sure to input only valid token denoms.`);
const invalidDisabledTokensStr = joinEntriesIntoStr(validDisabledTknsOutcome.entry!);
console.error(`[ERROR] disabled_transfer_banner_config.temp_disabled_transfer_tokens of ${network}.json has the following invalid token denoms: ${invalidDisabledTokensStr}. Please make sure to input only valid token denoms.`);
return false
}

disabledTokenKeys.map((key) => {
disabledTokenKeys.forEach((key) => {
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}.`);
console.error(`ERROR: disabled_transfer_banner_config.temp_disabled_transfer_tokens on ${network}.json has an invalid end time (${end}) for denom ${key} as it is before start time (${start}).`);
return false;
}
}
Expand All @@ -505,20 +505,20 @@ function isValidDisabledTransferBannerConfig(transferBanner: DisabledTransferBan

const disabledBridgeKeys = Object.keys(temp_disabled_bridges)
if (disabledBridgeKeys.length > 0) {
const validDisableBridgesOutcome = checkValidEntries(disabledBridgeKeys, bridges);
if (validDisableBridgesOutcome.status && isErrorOutcome(validDisableBridgesOutcome)) {
const invalidDissabedBridgesStr = joinEntriesIntoStr(validDisableBridgesOutcome.entry!);
console.error(`[ERROR] disabled_transfer_banner_config.temp_disabled_bridges of ${network}.json has the following invalid bridge addreses: ${invalidDissabedBridgesStr}. Please make sure to input only valid bridge addresses.`);
const validDisabledBridgesOutcome = checkValidEntries(disabledBridgeKeys, bridges);
if (validDisabledBridgesOutcome.status && isErrorOutcome(validDisabledBridgesOutcome)) {
const invalidDisabledBridgesStr = joinEntriesIntoStr(validDisabledBridgesOutcome.entry!);
console.error(`[ERROR] disabled_transfer_banner_config.temp_disabled_bridges of ${network}.json has the following invalid bridge addresses: ${invalidDisabledBridgesStr}. Please make sure to input only valid bridge addresses.`);
return false
}

disabledBridgeKeys.map((key) => {
disabledBridgeKeys.forEach((key) => {
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}.`);
console.error(`ERROR: disabled_transfer_banner_config.temp_disabled_bridges on ${network}.json has an invalid end time (${end}) for bridge ${key} as it is before start time (${start}).`);
return false;
}
}
Expand Down Expand Up @@ -681,10 +681,22 @@ async function main() {

if (bridgesMap && bridgesMap.ibc.length && bridgesMap.polynetwork.length) {
sarah-thong marked this conversation as resolved.
Show resolved Hide resolved
const polynetworkBridges = bridgesMap.polynetwork.map((bridge) => bridge.bridgeAddresses).flat()
sarah-thong marked this conversation as resolved.
Show resolved Hide resolved
sarah-thong marked this conversation as resolved.
Show resolved Hide resolved
const ibcBridges = bridgesMap.ibc.map((bridge) => bridge.bridgeAddresses).flat()
const ibcBridges = bridgesMap.ibc.map((bridge) => bridge.channels.src_channel)
bridgesArr = polynetworkBridges.concat(ibcBridges)
sarah-thong marked this conversation as resolved.
Show resolved Hide resolved
sarah-thong marked this conversation as resolved.
Show resolved Hide resolved
}

const res = await sdk.query.bridge.ConnectionAll({
bridgeId: new Long(0),
pagination: PageRequest.fromPartial({
limit: new Long(100000),
}),
})
const axelarBridges: string[] = res.connections.map(bridge => bridge.connectionId)

if (axelarBridges.length > 0) {
bridgesArr = bridgesArr.concat(axelarBridges)
}
sarah-thong marked this conversation as resolved.
Show resolved Hide resolved

// transfer disabled tokens object check
const isTransferDisabledTokensValid = isValidTransferDisabledTokens(jsonData.transfer_disabled_tokens, tokens, network);
if (!isTransferDisabledTokensValid) outcomeMap[network] = false;
Expand Down
Loading