Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use namada registry + IBC decoding fixes #1240

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

emccorson
Copy link
Collaborator

@emccorson emccorson commented Nov 11, 2024

This PR integrates Namadillo with Namada registry, as well as fixing some other things related to decoding addresses to assets. This adds support for holding the same asset from multiple chains. To test, you can transfer some NAM from the internal devnet to cosmoshub testnet to housefire, and you should see both your housefire NAM and your internal devnet NAM listed on your account.

The package.json points to a specific branch of namada-chain-registry, but I can update this as soon as anoma/namada-chain-registry#3 is merged. The code integrating the registry is a bit clunky, but this can be improved as the registry develops.


Added

Fixed

@emccorson emccorson changed the title feat: integrate with namada registry feat: use namada registry + IBC decoding fixes Nov 11, 2024
@emccorson emccorson marked this pull request as ready for review November 11, 2024 10:47
apps/namadillo/package.json Outdated Show resolved Hide resolved
@@ -189,13 +189,16 @@ export type ChainRegistryEntry = {
ibc: IBCInfo[];
};

export type AddressWithAssetAndBalance = {
address: string;
export type AddressWithAsset = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To simplify some names, I think we could call this as Token, wdyt?

My reference is the tokens.toml files that is used by the cli, that is basically the tnam... address plus some properties

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if Token should be the best name for it, but I agree we should simplify this name. What about AssetRegistry ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely agree the names I used are not very good. I'm not sure about Token since I think we have other things named similar to Token (but maybe those are not needed now, I have to check). AssetRegistry makes me think more of the full registry, like cosmos/chain-registry.

For now, I created #1244 to track this and I think it should be fairly easy to change the names when we settle on something.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some ChatGPT recommendations:

  1. AssetRecord (address and asset only) and AssetAmountRecord (address, asset, and amount)
  2. AssetReference (address and asset only) and AssetAmountEntry (address, asset, and amount)
  3. ResolvedAsset (address and asset only) and ResolvedAssetAmount (address, asset, and amount)
  4. TokenEntry (address and asset only) and TokenAmountEntry (address, asset, and amount)

I'm not sure about these since they don't indicate that there is an original address, but maybe they're OK.

Copy link
Contributor

@pedrorezende pedrorezende left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing PR! Just a few comments on variables / property names! Great work 🚀

export type AddressWithAssetAndBalanceMap = Record<
string,
AddressWithAssetAndBalance
export type AddressWithAssetAndAmount = AddressWithAsset & {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still on names, maybe this one could be something like FungibleAsset (?) . We will need to differentiate this in the future for nfts

@@ -189,13 +189,16 @@ export type ChainRegistryEntry = {
ibc: IBCInfo[];
};

export type AddressWithAssetAndBalance = {
address: string;
export type AddressWithAsset = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if Token should be the best name for it, but I agree we should simplify this name. What about AssetRegistry ?

apps/namadillo/src/registry/namadaAsset.ts Show resolved Hide resolved
@@ -44,7 +44,8 @@ export const getTransactionFee = (
if (typeof asset !== "undefined") {
return {
amount: BigNumber(0.003), // TODO: remove hardcoding
token: asset,
asset,
address: asset.base,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, reading the code, this property name seems to be more suitable to something like denom or base, once it's not handling the asset address. We might get confused in the future

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added this to #1244 for tracking. I think one problem is that denom, base and address all exist on the Asset type, but what we are calling the address might actually be none of those things. The intention of the property is to be "the thing we pass to Namada/Cosmos SDK to tell it what to transfer", but I have no idea what to call that 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I'll make this originalAddress so it's hopefully less confusing, but this can just be a placeholder until we get something better.

- Use Namada chain registry. Closes #1217
- Index assets by their original address, not by base denom. Fixes #1220
- Look up registry asset by base denom, alias or address
- Use address to index assets in 'Select Asset' list
@emccorson emccorson merged commit 799e84c into main Nov 12, 2024
9 checks passed
@emccorson emccorson deleted the integrate-namada-registry branch November 12, 2024 09:41
@github-actions github-actions bot temporarily deployed to production November 12, 2024 09:52 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants