From b950a0d63218e0030c93686f83a94913cd7c24eb Mon Sep 17 00:00:00 2001 From: thanhpn Date: Tue, 17 Dec 2024 19:55:31 +0700 Subject: [PATCH] Address reviewser comments --- .github/markets/pr_template.md | 6 ++++-- configs/devnet.json | 24 ++++++++++++++++-------- configs/mainnet.json | 24 ++++++++++++++++-------- configs/testnet.json | 24 ++++++++++++++++-------- scripts/check_configs.ts | 33 +++++++++++---------------------- 5 files changed, 63 insertions(+), 48 deletions(-) diff --git a/.github/markets/pr_template.md b/.github/markets/pr_template.md index 66da4e6..91b4a84 100644 --- a/.github/markets/pr_template.md +++ b/.github/markets/pr_template.md @@ -125,5 +125,7 @@ Each json file under the [configs](../../configs) folder correspond to their res ## TransferQuickSelectToken Data Structure |Field |Type |Required |Description |Notes | |---|---|---|---|---| -|`show` |`string` |true |The default token will be show on UI deposit/withdrawal forms | -|`real` |`string` |true |The default token will be use to transfer in deposit/withdrawal | \ No newline at end of file +|`priority` |`string` |true |The priority to sort | +|`label` |`string` |true |The token symbol to show | +|`icon_denom` |`string` |true |The token denom to mapping token icon to show | +|`quick_select_denom` |`string` |true |The default token will be use to transfer in deposit/withdrawal | \ No newline at end of file diff --git a/configs/devnet.json b/configs/devnet.json index 71b9380..9a8bb1f 100644 --- a/configs/devnet.json +++ b/configs/devnet.json @@ -48,20 +48,28 @@ }, "transfer_quick_select_tokens": [ { - "show": "swth", - "real" : "swth" + "priority": "1", + "label": "SWTH", + "icon_denom": "swth", + "quick_select_denom" : "swth" }, { - "show": "usdc", - "real" : "usdc" + "priority": "2", + "label": "USDC", + "icon_denom": "usdc", + "quick_select_denom" : "usdc" }, { - "show": "eth", - "real" : "eth" + "priority": "3", + "label": "ETH", + "icon_denom": "eth", + "requick_select_denomal" : "eth" }, { - "show": "dai", - "real" : "dai" + "priority": "4", + "label": "DAI", + "icon_denom": "dai", + "quick_select_denom" : "dai" } ] } \ No newline at end of file diff --git a/configs/mainnet.json b/configs/mainnet.json index 8ad5cb0..9bcf6f9 100644 --- a/configs/mainnet.json +++ b/configs/mainnet.json @@ -480,20 +480,28 @@ }, "transfer_quick_select_tokens": [ { - "show": "brdg/4b90a8d1225d11ed7af0661ff7309714189a527302892cad03ace7615d417d38", - "real" : "cgt/1" + "priority": "1", + "label": "USDC", + "icon_denom": "brdg/4b90a8d1225d11ed7af0661ff7309714189a527302892cad03ace7615d417d38", + "quick_select_denom" : "cgt/1" }, { - "show": "swth", - "real" : "swth" + "priority": "2", + "label": "SWTH", + "icon_denom": "swth", + "quick_select_denom" : "swth" }, { - "show": "eth.1.2.942d87", - "real" : "eth.1.2.942d87" + "priority": "3", + "label": "ETH", + "icon_denom": "eth.1.2.942d87", + "quick_select_denom" : "eth.1.2.942d87" }, { - "show": "brdg/a02afc2c1edf77cc023eefa25fc036c184612faf9365cda9c1daa3b1675ebf8f", - "real" : "brdg/a02afc2c1edf77cc023eefa25fc036c184612faf9365cda9c1daa3b1675ebf8f" + "priority": "4", + "label": "MNT", + "icon_denom": "brdg/a02afc2c1edf77cc023eefa25fc036c184612faf9365cda9c1daa3b1675ebf8f", + "quick_select_denom" : "brdg/a02afc2c1edf77cc023eefa25fc036c184612faf9365cda9c1daa3b1675ebf8f" } ] } diff --git a/configs/testnet.json b/configs/testnet.json index faf2c78..b37a372 100644 --- a/configs/testnet.json +++ b/configs/testnet.json @@ -62,20 +62,28 @@ }, "transfer_quick_select_tokens": [ { - "show": "swth", - "real" : "swth" + "priority": "1", + "label": "SWTH", + "icon_denom": "swth", + "quick_select_denom" : "swth" }, { - "show": "usdc", - "real" : "usdc" + "priority": "2", + "label": "USDC", + "icon_denom": "usdc", + "quick_select_denom" : "usdc" }, { - "show": "eth", - "real" : "eth" + "priority": "3", + "label": "ETH", + "icon_denom": "eth", + "quick_select_denom" : "eth" }, { - "show": "dai", - "real" : "dai" + "priority": "4", + "label": "DAI", + "icon_denom": "dai", + "quick_select_denom" : "dai" } ] } diff --git a/scripts/check_configs.ts b/scripts/check_configs.ts index 49c4174..5456e4a 100644 --- a/scripts/check_configs.ts +++ b/scripts/check_configs.ts @@ -134,8 +134,10 @@ interface SpotPoolConfig { } interface TransferQuickSelectToken { - show: string; - real: string; + priority: string; + label: string; + icon_denom: string; + quick_select_denom: string; } type OutcomeMap = { [key in CarbonSDK.Network]: boolean }; // true = success, false = failure @@ -427,35 +429,22 @@ function isValidMarketPromo(marketPromo: {[marketId: string]: MarketPromo}, netw } function isValidQuickSelectTokens(quickSelectTokens: TransferQuickSelectToken[], network: CarbonSDK.Network, denoms: string[]): boolean { - const duplicateQuickSelectTokens = checkDuplicateEntries(quickSelectTokens.map(token => token.show)); - const invalidQuickSelectTokens = checkValidEntries(quickSelectTokens.map(token => token.show), denoms); + const dupTokenLabel = checkDuplicateEntries(quickSelectTokens.map(token => token.label)); + const invalidTokenDenoms = checkValidEntries(quickSelectTokens.map(token => token.quick_select_denom), denoms); - const duplicateRealTokens = checkDuplicateEntries(quickSelectTokens.map(token => token.real)); - const invalidRealTokens = checkValidEntries(quickSelectTokens.map(token => token.real), denoms); - if (duplicateQuickSelectTokens.status && duplicateQuickSelectTokens.entry) { - let listOfDuplicates: string = duplicateQuickSelectTokens.entry.join(", "); - console.error(`ERROR: ${network}.json has the following duplicated quick select tokens: ${listOfDuplicates}. Please make sure to input each token only once in ${network}`); + if (dupTokenLabel.status && dupTokenLabel.entry) { + let listOfDuplicates: string = dupTokenLabel.entry.join(", "); + console.error(`ERROR: ${network}.json has the following duplicated quick select token labels: ${listOfDuplicates}. Please make sure to input each token only once in ${network}`); return false; } - if (invalidQuickSelectTokens.status && invalidQuickSelectTokens.entry) { - let listOfInvalidTokens: string = invalidQuickSelectTokens.entry.join(", "); + if (invalidTokenDenoms.status && invalidTokenDenoms.entry) { + let listOfInvalidTokens: string = invalidTokenDenoms.entry.join(", "); console.error(`ERROR: ${network}.json has the following invalid quick select token denoms: ${listOfInvalidTokens}. Please make sure to only input valid token denoms in ${network}`); return false; } - if (duplicateRealTokens.status && duplicateRealTokens.entry) { - let listOfDuplicates: string = duplicateRealTokens.entry.join(", "); - console.error(`ERROR: ${network}.json has the following duplicated real tokens: ${listOfDuplicates}. Please make sure to input each token only once in ${network}`); - return false; - } - - if (invalidRealTokens.status && invalidRealTokens.entry) { - let listOfInvalidTokens: string = invalidRealTokens.entry.join(", "); - console.error(`ERROR: ${network}.json has the following invalid real token denoms: ${listOfInvalidTokens}. Please make sure to only input valid token denoms in ${network}`); - return false; - } return true; }