Skip to content

Commit

Permalink
Update Assetlist Generation to Recognize Canonical Status on Other Ch…
Browse files Browse the repository at this point in the history
…ains (Injective) (#1881)

* Update generation code to recognize canonical status

* update logic and add override properties
  • Loading branch information
JeremyParish69 authored Sep 5, 2024
1 parent 7ed01f4 commit 65267a6
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 40 deletions.
81 changes: 50 additions & 31 deletions .github/workflows/utility/generate_assetlist_functions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -531,24 +531,27 @@ export function setSymbol(asset_data) {
let last_suffix_is_network = false;

let variantGroup = getAssetProperty(asset_data.origin_asset, "variantGroup");
let accumulative_suffix = "";
if (variantGroup.additionalMintagesExist) {
symbol = symbol + "." + getNetworkSymbolSuffix(asset_data.frontend.variant.mintageNetwork, asset_data);
//symbol = symbol + "." + getNetworkSymbolSuffix(asset_data.frontend.variant.mintageNetwork, asset_data);
accumulative_suffix = "." + getNetworkSymbolSuffix(asset_data.frontend.variant.mintageNetwork, asset_data);
}
asset_data.frontend.variant.hops.forEach((hop) => {
if (
hop.type === "additional-mintage"
||
||
hop.type === "legacy-mintage"
||
||
hop.type === "wrapped"
) { return; }
else if ( traceTypesNeedingProvider.includes(hop.type) ) {
let suffix = hop.provider.symbol_suffix ?? "";
if ( suffix?.startsWith(".e.") ) {
else if (traceTypesNeedingProvider.includes(hop.type)) {
let hop_suffix = hop.provider.symbol_suffix ?? "";

if (hop_suffix?.startsWith(".e.")) {
if (
symbol.slice(symbol.length - 4) === ".eth"
accumulative_suffix.slice(accumulative_suffix.length - 4) === ".eth"
) {
symbol = symbol.slice(0, symbol.length - 4);
accumulative_suffix = accumulative_suffix.slice(0, accumulative_suffix.length - 4);
}
if (
deepEqual(
Expand All @@ -559,18 +562,23 @@ export function setSymbol(asset_data) {
})
)
) {
suffix = suffix.slice(2);
hop_suffix = hop_suffix.slice(2);
}
}
symbol = symbol + suffix;
last_suffix_is_network = false;

if (!hop.provider.destination_network) {
symbol = symbol + "." + getNetworkSymbolSuffix(hop.network, asset_data);

//Add Provider Suffix
if (!hop.provider.canonical) {
accumulative_suffix = accumulative_suffix + hop_suffix;
last_suffix_is_network = false;
}

//Add Destination Network Suffix whenever the provider suffix is skipped or the destination network isn't assumed
if (!hop.provider.destination_network || hop.provider.canonical) {
accumulative_suffix = accumulative_suffix + "." + getNetworkSymbolSuffix(hop.network, asset_data);
last_suffix_is_network = true;
}
} else {
symbol = symbol + "." + getNetworkSymbolSuffix(hop.network, asset_data);
} else { //is IBC
accumulative_suffix = accumulative_suffix + "." + getNetworkSymbolSuffix(hop.network, asset_data);
last_suffix_is_network = true;
}
});
Expand All @@ -580,11 +588,13 @@ export function setSymbol(asset_data) {
if (
last_suffix_is_network
&&
symbol.endsWith(ending)
accumulative_suffix.endsWith(ending)
) {
symbol = symbol.slice(0, -ending.length);
accumulative_suffix = accumulative_suffix.slice(0, -ending.length);
}

symbol = symbol + accumulative_suffix;

asset_data.frontend.symbol = symbol;
asset_data.asset_detail.symbol = symbol;
asset_data.chain_reg.symbol = symbol;
Expand Down Expand Up @@ -640,12 +650,16 @@ export function setName(asset_data) {
let last_suffix_is_network = false;
let this_suffix_is_network = false;

let accumulative_suffix = "";

//Show Mintage Network, if needed
let variantGroup = getAssetProperty(asset_data.origin_asset, "variantGroup");
if (variantGroup.additionalMintagesExist) {
name =
name
+ " (" +
//name =
accumulative_suffix =
//name
//+
" (" +
getNetworkName(asset_data.frontend.variant.mintageNetwork, asset_data)
+ ")";
last_suffix_is_network = true;
Expand All @@ -662,36 +676,39 @@ export function setName(asset_data) {
else if (traceTypesNeedingProvider.includes(hop.type)) {

//Some trace providers don't need indication
if ( hop.provider.name_suffix ) {
if (hop.provider.name_suffix && !hop.provider.canonical) {
this_suffix_is_network = false;
name = appendNameSuffix(
name,
accumulative_suffix = appendNameSuffix(
accumulative_suffix,
hop.provider.name_suffix,
this_suffix_is_network,
last_suffix_is_network
);
last_suffix_is_network = false;
}

if (
!hop.provider.destination_network
||
hop.provider.canonical
||
!hop.provider.name_suffix
) {
this_suffix_is_network = true;
name = appendNameSuffix(
name,
accumulative_suffix = appendNameSuffix(
accumulative_suffix,
getNetworkName(hop.network, asset_data),
this_suffix_is_network,
last_suffix_is_network
);
last_suffix_is_network = true;
}

} else { //type: ibc and ibc-cw20

this_suffix_is_network = true;
name = appendNameSuffix(
name,
accumulative_suffix = appendNameSuffix(
accumulative_suffix,
getNetworkName(hop.network, asset_data),
this_suffix_is_network,
last_suffix_is_network
Expand All @@ -705,11 +722,13 @@ export function setName(asset_data) {
if (
last_suffix_is_network
&&
name.endsWith(ending)
accumulative_suffix.endsWith(ending)
) {
name = name.slice(0, -ending.length);
accumulative_suffix = accumulative_suffix.slice(0, -ending.length);
}

name = name + accumulative_suffix;

asset_data.frontend.name = name;
asset_data.asset_detail.name = name;
asset_data.chain_reg.name = name;
Expand Down
14 changes: 14 additions & 0 deletions language_files/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"osmosis": {
"USDT(dot)eth(dot)peggy": {
"description": "Tether USDt from Ethereum via Peggy bridge."
},
"USDC(dot)eth(dot)e(dot)matic(dot)axl": {
"description": "USDC is a fully collateralized US Dollar stablecoin developed by CENTRE, the open source project with Circle being the first of several forthcoming issuers."
},
"USDT(dot)inj": {
"description": "Tether USDt from Ethereum via Peggy bridge."
}
},
"osmosistestnet": {}
}
4 changes: 2 additions & 2 deletions osmosis-1/generated/asset_detail/assetlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -2517,8 +2517,8 @@
"description": "The Representative factory token for Trump Kemistry"
},
{
"name": "Tether USD (Ethereum) (Injective)",
"symbol": "USDT.eth.inj",
"name": "Tether USD (Injective)",
"symbol": "USDT.inj",
"description": "Tether USDt from Ethereum via Peggy bridge.",
"websiteURL": "https://tether.to/",
"twitterURL": "https://x.com/Tether_to"
Expand Down
4 changes: 2 additions & 2 deletions osmosis-1/generated/chain_registry/assetlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -22892,9 +22892,9 @@
],
"type_asset": "ics20",
"base": "ibc/2AD3C64D19ADFBB522CD738B58F421102143F827C1CAFF574A8BF0B81017D53D",
"name": "Tether USD (Ethereum) (Injective)",
"name": "Tether USD (Injective)",
"display": "usdt",
"symbol": "USDT.eth.inj",
"symbol": "USDT.inj",
"traces": [
{
"type": "synthetic",
Expand Down
8 changes: 6 additions & 2 deletions osmosis-1/generated/frontend/assetlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -24169,7 +24169,7 @@
"chainName": "injective",
"sourceDenom": "peggy0xdAC17F958D2ee523a2206206994597C13D831ec7",
"coinMinimalDenom": "ibc/2AD3C64D19ADFBB522CD738B58F421102143F827C1CAFF574A8BF0B81017D53D",
"symbol": "USDT.eth.inj",
"symbol": "USDT.inj",
"decimals": 6,
"logoURIs": {
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/usdt.inj.svg",
Expand Down Expand Up @@ -24225,12 +24225,16 @@
}
],
"variantGroupKey": "factory/osmo1em6xs47hd82806f5cxgyufguxrrc7l0aqx7nzzptjuqgswczk8csavdxek/alloyed/allUSDT",
"name": "Tether USD (Ethereum) (Injective)",
"name": "Tether USD (Injective)",
"isAlloyed": false,
"verified": false,
"unstable": false,
"disabled": false,
"preview": false,
"sortWith": {
"chainName": "injective",
"sourceDenom": "inj"
},
"listingDate": "2024-08-21T18:00:00.000Z"
},
{
Expand Down
4 changes: 3 additions & 1 deletion osmosis-1/osmosis.zone_assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -4973,12 +4973,14 @@
"peg_mechanism": "collateralized",
"osmosis_verified": false,
"override_properties": {
"symbol": "USDT.inj",
"name": "Tether USD (Injective)",
"logo_URIs": {
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/usdt.inj.svg",
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/usdt.inj.png"
}
},
"_comment": "Tether USD (Ethereum) (Injective) $USDT.eth.inj",
"_comment": "Tether USD (Ethereum via Peggy) $USDT.eth.inj $USDT.inj",
"listing_date_time_utc": "2024-08-21T18:00:00Z",
"categories": [
"stablecoin"
Expand Down
10 changes: 8 additions & 2 deletions osmosis-1/osmosis.zone_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,14 @@
},
{
"provider": "Peggy",
"name_suffix": "",
"symbol_suffix": ""
"name_suffix": "Peggy",
"symbol_suffix": ".peggy",
"token": {
"chain_name": "injective",
"base_denom": "inj"
},
"destination_network": "injective",
"canonical": true
},
{
"provider": "Oraichain Labs TON Bridge",
Expand Down

0 comments on commit 65267a6

Please sign in to comment.