Skip to content

Commit

Permalink
Update chain registry replacement generation
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyParish69 committed Aug 27, 2024
1 parent 0f54bea commit ecf5291
Show file tree
Hide file tree
Showing 3 changed files with 1,115 additions and 456 deletions.
82 changes: 71 additions & 11 deletions .github/workflows/utility/generate_assetlist_functions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -503,15 +503,16 @@ export function setSymbol(asset_data) {

let symbol = getAssetProperty(asset_data.origin_asset, "symbol");

asset_data.chain_reg.symbol =
getAssetProperty(asset_data.local_asset, "symbol") ??
getAssetProperty(asset_data.canonical_asset, "symbol");
//asset_data.chain_reg.symbol =
//getAssetProperty(asset_data.local_asset, "symbol") ??
//getAssetProperty(asset_data.canonical_asset, "symbol");
//getAssetProperty(asset_data.source_asset, "symbol"); //change this to source asset, since canonical only applies to osmosis zone

if (asset_data.zone_asset?.override_properties?.symbol) {
symbol = asset_data.zone_asset?.override_properties?.symbol;
asset_data.frontend.symbol = symbol;
asset_data.asset_detail.symbol = symbol;
asset_data.chain_reg.symbol = symbol;
return;
}

Expand All @@ -522,6 +523,7 @@ export function setSymbol(asset_data) {
if (asset_data.frontend.is_canonical) {
asset_data.frontend.symbol = symbol;
asset_data.asset_detail.symbol = symbol;
asset_data.chain_reg.symbol = symbol;
return;
}

Expand Down Expand Up @@ -585,6 +587,7 @@ export function setSymbol(asset_data) {

asset_data.frontend.symbol = symbol;
asset_data.asset_detail.symbol = symbol;
asset_data.chain_reg.symbol = symbol;
return;


Expand All @@ -595,15 +598,16 @@ export function setName(asset_data) {

let name;

asset_data.chain_reg.name =
getAssetProperty(asset_data.local_asset, "name") ??
getAssetProperty(asset_data.source_asset, "name");
//asset_data.chain_reg.name =
//getAssetProperty(asset_data.local_asset, "name") ??
//getAssetProperty(asset_data.source_asset, "name");


if (asset_data.zone_asset?.override_properties?.name) {
name = asset_data.zone_asset?.override_properties?.name;
asset_data.frontend.name = name;
asset_data.asset_detail.name = name;
asset_data.chain_reg.name = name;
return;
}

Expand All @@ -628,6 +632,7 @@ export function setName(asset_data) {
if (asset_data.frontend.is_canonical) {
asset_data.frontend.name = name;
asset_data.asset_detail.name = name;
asset_data.chain_reg.name = name;
return;
}

Expand Down Expand Up @@ -707,6 +712,7 @@ export function setName(asset_data) {

asset_data.frontend.name = name;
asset_data.asset_detail.name = name;
asset_data.chain_reg.name = name;


}
Expand Down Expand Up @@ -891,18 +897,72 @@ export function setDecimals(asset_data) {

export function setImages(asset_data) {

let images = getAssetProperty(asset_data.local_asset, "images") ?? getAssetProperty(asset_data.canonical_asset, "images");
asset_data.chain_reg.images = images;
let localImages = getAssetProperty(asset_data.local_asset, "images");
let canonicalImages = getAssetProperty(asset_data.canonical_asset, "images");
let primaryImage = asset_data.zone_asset?.override_properties?.logo_URIs ?? canonicalImages?.[0];
let images = [];

//Generated chain reg images array is:
//canonicalAsset's image (e.g., USDT) + localAsset's Images(e.g., allUSDT),
//with any override image placed at the beginning
let firstCanonicalImage = true;
canonicalImages?.forEach((canonicalImage) => {
addUniqueArrayItem(canonicalImage, images);
if (
firstCanonicalImage
&&
asset_data.canonical_asset.chain_name !== asset_data.chainName
) {
images[0].image_sync = { ...asset_data.canonical_asset };
for (const key in images[0]) {
if (key !== "image_sync") {
const value = images[0][key];
delete images[0][key];
images[0][key] = value;
}
}
}
firstCanonicalImage = false;
});

images = getAssetProperty(asset_data.canonical_asset, "images");

localImages?.forEach((localImage) => {
let containsImage = false;
images?.forEach((image) => {
if (
(image.png && image.png === localImage.png)
||
(image.svg && image.svg === localImage.svg)
) {
containsImage = true;
}
});

if (!containsImage) {
addUniqueArrayItem(localImage, images);
}
});

let primaryImage = asset_data.zone_asset?.override_properties?.logo_URIs ?? images?.[0];
let newImagesArray = [];
images.forEach((image) => {
if (
(image.png && image.png === primaryImage.png)
||
(image.svg && image.svg === primaryImage.svg)
) {
primaryImage = { ...image };
} else {
newImagesArray.push(image);
}
});
newImagesArray.unshift(primaryImage);

asset_data.frontend.logoURIs = {...primaryImage};
delete asset_data.frontend.logoURIs.theme;
delete asset_data.frontend.logoURIs.image_sync;
asset_data.chain_reg.logo_URIs = asset_data.frontend.logoURIs;

asset_data.chain_reg.logo_URIs = getAssetProperty(asset_data.local_asset, "logo_URIs");
asset_data.chain_reg.images = newImagesArray;

}

Expand Down
61 changes: 43 additions & 18 deletions osmo-test-5/generated/chain_registry/assetlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
],
"type_asset": "ics20",
"base": "ibc/2164BDB48DE5501430E71286448D87C6D2240EC0E078CF113CAB85E21A352BB0",
"name": "USD Coin (Axelar)",
"name": "USD Coin (Axelar Testnet)",
"display": "ausdc",
"symbol": "aUSDC.axl",
"traces": [
Expand Down Expand Up @@ -170,8 +170,8 @@
"images": [
{
"image_sync": {
"chain_name": "ethereumtestnet",
"base_denom": "0x254d06f33bDc5b8ee05b2ea472107E300226659A"
"chain_name": "axelartestnet",
"base_denom": "uausdc"
},
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/ethereum/images/usdc.svg"
}
Expand All @@ -194,7 +194,7 @@
],
"type_asset": "ics20",
"base": "ibc/1F42AC9631DBE03009219ECCFE151786F53A038DE9F7A07C709158514F1D5942",
"name": "Wrapped Ether (Axelar)",
"name": "Ether (Axelar Testnet)",
"display": "weth",
"symbol": "ETH",
"traces": [
Expand Down Expand Up @@ -233,8 +233,8 @@
"images": [
{
"image_sync": {
"chain_name": "ethereumtestnet",
"base_denom": "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6"
"chain_name": "axelartestnet",
"base_denom": "eth-wei"
},
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/ethereum/images/weth.svg"
}
Expand Down Expand Up @@ -507,12 +507,12 @@
},
"images": [
{
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/kyve/images/kyve-token.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/kyve/images/kyve-token.svg",
"image_sync": {
"chain_name": "kyve",
"base_denom": "ukyve"
}
"chain_name": "kyvetestnet",
"base_denom": "tkyve"
},
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/kyve/images/kyve-token.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/kyve/images/kyve-token.svg"
}
]
},
Expand Down Expand Up @@ -581,7 +581,7 @@
],
"type_asset": "ics20",
"base": "ibc/539BC2B6E70117D220834D6DF8E27307655D1325C0CADF7E3AF90AB00D9F8D69",
"name": "Chain4Energy",
"name": "Chain4Energy Testnet",
"display": "c4e",
"symbol": "C4E",
"traces": [
Expand All @@ -598,8 +598,15 @@
}
}
],
"logo_URIs": {
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/testnets/chain4energytestnet/images/c4e.png"
},
"images": [
{
"image_sync": {
"chain_name": "chain4energytestnet",
"base_denom": "uc4e"
},
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/testnets/chain4energytestnet/images/c4e.png"
}
]
Expand Down Expand Up @@ -674,7 +681,7 @@
],
"type_asset": "ics20",
"base": "ibc/5C274155106FEB0C093F76A12BB67222E479E1EBE043F319CE4463E54F7A357C",
"name": "xion",
"name": "Xion Testnet",
"display": "XION",
"symbol": "XION",
"traces": [
Expand All @@ -691,8 +698,15 @@
}
}
],
"logo_URIs": {
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/xion/images/burnt-round.png"
},
"images": [
{
"image_sync": {
"chain_name": "xiontestnet",
"base_denom": "uxion"
},
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/xion/images/burnt-round.png"
}
]
Expand Down Expand Up @@ -796,7 +810,7 @@
"images": [
{
"image_sync": {
"chain_name": "impacthub",
"chain_name": "impacthubtestnet",
"base_denom": "uixo"
},
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/impacthub/images/ixo.png",
Expand Down Expand Up @@ -825,7 +839,7 @@
],
"type_asset": "ics20",
"base": "ibc/5F10B4BED1A80DC44975D95D716AEF8CEBFB99B3F088C98361436A7D0CF5A830",
"name": "Archway",
"name": "Archway Testnet",
"display": "const",
"symbol": "CONST",
"traces": [
Expand All @@ -850,11 +864,15 @@
}
}
],
"logo_URIs": {
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/archway/images/archway.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/archway/images/archway.svg"
},
"images": [
{
"image_sync": {
"chain_name": "archway",
"base_denom": "aarch"
"chain_name": "archwaytestnet",
"base_denom": "aconst"
},
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/archway/images/archway.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/archway/images/archway.svg",
Expand Down Expand Up @@ -884,7 +902,7 @@
],
"type_asset": "ics20",
"base": "ibc/B8435C53F8B5CC87703531FF736508875DF473D0C231E93A3EF5C2C934E562A4",
"name": "Melody",
"name": "Symphony Testnet",
"display": "mld",
"symbol": "MLD",
"traces": [
Expand All @@ -901,8 +919,15 @@
}
}
],
"logo_URIs": {
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/testnets/symphonytestnet/images/coin_icon.png"
},
"images": [
{
"image_sync": {
"chain_name": "symphonytestnet",
"base_denom": "note"
},
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/testnets/symphonytestnet/images/coin_icon.png"
}
]
Expand Down
Loading

0 comments on commit ecf5291

Please sign in to comment.