Skip to content

Commit

Permalink
Address reviewser comments
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhpn committed Dec 17, 2024
1 parent 3b24d60 commit b950a0d
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 48 deletions.
6 changes: 4 additions & 2 deletions .github/markets/pr_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
|`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 |
24 changes: 16 additions & 8 deletions configs/devnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
24 changes: 16 additions & 8 deletions configs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
24 changes: 16 additions & 8 deletions configs/testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
33 changes: 11 additions & 22 deletions scripts/check_configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit b950a0d

Please sign in to comment.