apeunit / interchain.neueux.com

https://interchain.neueux.com
3 stars 0 forks source link

tutorial for verifying ibc asset #1

Open okwme opened 3 years ago

okwme commented 3 years ago

create a tutorial for a wallet/dapp developer to use CosmJS and accepts an account address for some network (probably Cosmos Hub). What are the necessary steps to query that user account and see that they have an IBC asset, and prove the origin of that asset. It will involve querying the IBC module for chain id and app hash info, then querying the github.com/cosmos/registry and/or atlas.cosmos.network to check the networks with that chain-id, verify the app state to prove that is the actual network and then tell the user that asset for sure came from that network.

randomshinichi commented 3 years ago

Is there a sample "IBC asset" I can already refer to in this tutorial?

randomshinichi commented 3 years ago

get the balances of a user account on chainA chainB's asset will show up as ibc/hash. : 1000000ibc/27A6394C3F9FF9C9DCF5DFFADF9BB5FE9A37C7E92B006199894CF1824DF9AC7C,100000000000samoleans,99999977256stake

** Need to get complete DenomPath, but how from cosmjs? cosmos-sdk/docs/basics/query-lifecycle.md cosmos-sdk/docs/core/grpc_rest.md GRPC interface at tcp:9090. Use [[https://github.com/fullstorydev/grpcurl][grpcurl]] to quickly test endpoints. REST interface at tcp:1317, which is actually generated from the GRPC interface. However, relayer doesn't seem to enable this interface for the gaia it starts.

cosmos-sdk/x/ibc/applications/transfer/spec/01_concepts.md Get the full path of the denomination. : GET /ibc_transfer/v1beta1/denom_traces/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2->{"path": "transfer/channelToA", "base_denom": "uatom"} Ask for information about the channel. It should give the clientID and chainID, which we will ask the chain registry about later. : GET /ibc/channel/v1beta1/channels/channelToA/ports/transfer/client_state"->{"client_id": "clientA", "chain-id": "chainA", ...} Ask for information about the IBC client. If the chain is not connected to the channel, this will say "not found" : GET /ibc/channel/v1beta1/channels/channelToA/ports/transfer"->{"channel_id": "channelToA", port_id": "transfer", counterparty: {"channel_id": "channelToB", port_id": "transfer"}, ...} Presumably I'd have to verify that the IBC client is within the trusting period (336h = 14d)

verify that ibc light client for chainB has not expired yet

problem: atlas.cosmos.network seems to have no relevant info. github.com/cosmos/registry: which information here is relevant? registry/cosmoshub-3/light-roots/latest.json was last updated 4 months ago, how can this be relevant? Compare clientID, channelID, portID, chainID and say yes.

okwme commented 3 years ago

Don't forget there's a live swagger API here that is by default pointed to the hub but can be directed to a local node (as long as https/http mixed content doesn't prevent the queries): https://cosmos.network/rpc/v0.41.4

problem: atlas.cosmos.network seems to have no relevant info.

atlas.cosmos.network is a list of all publicly available tendermint nodes. These are all IPs that could be used as endpoints for the CLI or CosmJS to make queries against. There is no guarantee that they are all fully available tho, some may have restrictions of who can access or whther they support historical queries etc.

randomshinichi commented 3 years ago

Blockers Latest version of CosmJS on npm, 0.24.1, lacks two things: