Skip to content

Commit

Permalink
Review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
grod220 committed Oct 31, 2024
1 parent c98bafb commit 18fe886
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 64 deletions.
76 changes: 20 additions & 56 deletions input/chains/penumbra-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,90 +131,54 @@
"transfer/channel-4/factory/osmo104jtrwcljnxfljhml8mxrw7qetcsdmqvy3sprw/ucosmousd": 10000,
"transfer/channel-4/factory/osmo1g8qypve6l95xmhgc0fddaecerffymsl7kn9muw/squosmo": 10000
},
"badges": {
"osmosis": {
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.svg"
}
},
"badgesByBase": {
"transfer/channel-4/factory/osmo1em6xs47hd82806f5cxgyufguxrrc7l0aqx7nzzptjuqgswczk8csavdxek/alloyed/allUSDT": [
{
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.svg"
}
"osmosis"
],
"transfer/channel-4/factory/osmo1z6r6qdknhgsc0zeracktgpcxf43j6sekq07nw8sxduc9lg0qjjlqfu25e3/alloyed/allBTC": [
{
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.svg"
}
"osmosis"
],
"transfer/channel-4/factory/osmo1z0qrq605sjgcqpylfl4aa6s90x738j7m58wyatt0tdzflg2ha26q67k743/wbtc": [
{
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.svg"
}
"osmosis"
],
"transfer/channel-4/factory/osmo1k6c8jln7ejuqwtqmay3yvzrg3kueaczl96pk067ldg8u835w0yhsw27twm/alloyed/allETH": [
{
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.svg"
}
"osmosis"
],
"transfer/channel-4/factory/osmo1n3n75av8awcnw4jl62n3l48e6e4sxqmaf97w5ua6ddu4s475q5qq9udvx4/alloyed/allSOL": [
{
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.svg"
}
"osmosis"
],
"transfer/channel-4/factory/osmo18zdw5yvs6gfp95rp74qqwug9yduw2fyr8kplk2xgs726s9axc5usa2vpgw/alloyed/allLINK": [
{
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.svg"
}
"osmosis"
],
"transfer/channel-4/factory/osmo1r53fx9fvcdzncrs7zkn4gw5vfelx5gk8k5wc6wqha2jpkh992rusr5tk02/alloyed/allDOT": [
{
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.svg"
}
"osmosis"
],
"transfer/channel-4/factory/osmo14mafhhp337yjj2aujplawz0tks6jd2lel4hkwz4agyzhvvztzaqsqzjq8x/alloyed/allTRX": [
{
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.svg"
}
"osmosis"
],
"transfer/channel-4/factory/osmo1p7x454ex08s4f9ztmm7wfv7lvtgdkfztj2u7v7fezfcauy85q35qmqrdpk/alloyed/allARB": [
{
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.svg"
}
"osmosis"
],
"transfer/channel-4/factory/osmo1nufyzqlm8qhu2w7lm0l4rrax0ec8rsk69mga4tel8eare7c7ljaqpk2lyg/alloyed/allOP": [
{
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.svg"
}
"osmosis"
],
"transfer/channel-4/factory/osmo12lnwf54yd30p6amzaged2atln8k0l32n7ncxf04ctg7u7ymnsy7qkqgsw4/alloyed/allTON": [
{
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.svg"
}
"osmosis"
],
"transfer/channel-4/factory/osmo1f588gk9dazpsueevdl2w6wfkmfmhg5gdvg2uerdlzl0atkasqhsq59qc6a/alloyed/allSHIB": [
{
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.svg"
}
"osmosis"
],
"transfer/channel-4/factory/osmo1nnlxegt0scm9qkzys9c874t0ntapv4epfjy2w49c0xdrp3dr0v4ssmelzx/alloyed/allPEPE": [
{
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.svg"
}
"osmosis"
],
"transfer/channel-4/factory/osmo1eqjda4pc6e09jtxzxggf6jl3jye2yn453ja58we5gxwzmf5ah28qvlnaz8/alloyed/allUNI": [
{
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.svg"
}
"osmosis"
]
}
}
Expand Down
9 changes: 6 additions & 3 deletions input/chains/penumbra-testnet-deimos-8-x6de97e39.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,14 @@
"transfer/channel-1/uusdc"
],
"priorityScoresByBase": {},
"badges": {
"penumbra": {
"png": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/penumbra-favicon.png"
}
},
"badgesByBase": {
"wtest_usd": [
{
"png": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/penumbra-favicon.png"
}
"penumbra"
]
}
}
6 changes: 5 additions & 1 deletion input/chains/penumbra-testnet-phobos-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,11 @@
}
}
],
"canonicalNumeraires": ["wtest_usd", "transfer/channel-1/uusdc"],
"canonicalNumeraires": [
"wtest_usd",
"transfer/channel-1/uusdc"
],
"priorityScoresByBase": {},
"badges": {},
"badgesByBase": {}
}
6 changes: 5 additions & 1 deletion input/chains/penumbra-testnet-phobos-2-x4120f355.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@
}
}
],
"canonicalNumeraires": ["wtest_usd", "transfer/channel-1/uusdc"],
"canonicalNumeraires": [
"wtest_usd",
"transfer/channel-1/uusdc"
],
"priorityScoresByBase": {},
"badges": {},
"badgesByBase": {}
}
6 changes: 5 additions & 1 deletion input/chains/penumbra-testnet-phobos-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@
}
}
],
"canonicalNumeraires": ["wtest_usd", "transfer/channel-1/uusdc"],
"canonicalNumeraires": [
"wtest_usd",
"transfer/channel-1/uusdc"
],
"priorityScoresByBase": {},
"badges": {},
"badgesByBase": {}
}
10 changes: 10 additions & 0 deletions npm/src/registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ describe('Registry', () => {
);
});

it('gets metadata without badges', () => {
const registry = new Registry(testRegistry);
const usdcId = base64ToUint8Array('ra98J77CX10Us2s6+d7bebfpm1Q3+UOycPfaaEeeuAY=');
const res = registry.getMetadata(new AssetId({ inner: usdcId }));
expect(res.base).toEqual(
'transfer/channel-0/factory/osmo1zlkzu72774ynac53necz46u4ycqtp36wedrar0/willyz',
);
expect(res.badges.length).toEqual(0);
});

it('throws when searching for metadata that does not exist', () => {
const registry = new Registry(testRegistry);
const cubeId = base64ToUint8Array('aGVsbG8gd29ybGQ=');
Expand Down
4 changes: 3 additions & 1 deletion tools/compiler/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub struct GlobalsInput {
}

type BaseDenom = String;
type BadgeName = String;

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
Expand All @@ -31,7 +32,8 @@ pub struct ChainConfig {
pub native_assets: Vec<Metadata>,
pub canonical_numeraires: Vec<String>,
pub priority_scores_by_base: HashMap<BaseDenom, u64>,
pub badges_by_base: HashMap<BaseDenom, Vec<AssetImage>>,
pub badges: HashMap<BadgeName, AssetImage>,
pub badges_by_base: HashMap<BaseDenom, Vec<BadgeName>>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down
11 changes: 10 additions & 1 deletion tools/compiler/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,16 @@ fn process_chain_config(chain_config: ChainConfig) -> AppResult<Registry> {
.get(&metadata.base_denom().denom)
{
let mut pb_metadata: pb::Metadata = metadata.clone().into();
pb_metadata.badges = badges.clone();
pb_metadata.badges = badges
.iter()
.map(|b| {
chain_config
.badges
.get(b)
.ok_or_else(|| anyhow::anyhow!("Badge not found: {}", b))
.cloned()
})
.collect::<Result<Vec<_>, _>>()?;
*metadata = Metadata::try_from(pb_metadata)?;
}
}
Expand Down
3 changes: 3 additions & 0 deletions tools/compiler/tests/test_get_chain_configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ fn test_get_chain_configs_reads_configs_correctly() {
"nativeAssets": [],
"canonicalNumeraires": [],
"priorityScoresByBase": {},
"badges": {},
"badgesByBase": {},
})
.to_string();
Expand All @@ -51,6 +52,7 @@ fn test_get_chain_configs_reads_multiple_configs_correctly() {
"nativeAssets": [],
"canonicalNumeraires": [],
"priorityScoresByBase": {},
"badges": {},
"badgesByBase": {},
})
.to_string();
Expand All @@ -70,6 +72,7 @@ fn test_get_chain_configs_reads_multiple_configs_correctly() {
"nativeAssets": [],
"canonicalNumeraires": [],
"priorityScoresByBase": {},
"badges": {},
"badgesByBase": {},
})
.to_string();
Expand Down

0 comments on commit 18fe886

Please sign in to comment.