tablelandnetwork / table-nft-renderer

https://table-nft-renderer-rho.vercel.app
MIT License
0 stars 0 forks source link

Bug: No longer allows cross Testnet/Mainnet queries #27

Closed awmuncy closed 1 year ago

awmuncy commented 1 year ago

I believe this is due to Validator/SDK updates, though I could be wrong.

awmuncy commented 1 year ago

@andrewxhill This issue is caused by the testnet/mainnet validator split. I was able to fix it for now but specifying the host as testnet.tableland.network, but this will eventually break as the network split moves forward. That is to say, this problem is not solved, so I'm not closing the ticket.

carsonfarmer commented 1 year ago

Yeh this isn't a "bug" though right? It is a feature. What exactly is "breaking here"?

awmuncy commented 1 year ago

This is a bug in the NFT renderer app, not the validator or SDK. It's totally expected and reasonable behavior from those entities. I'm just going to have to figure out how to fix it in the renderer app. When the query parameters include a chaid id, it's pretty easy; just connect to the host associated with that chain. However, if someone loads the app without a query parameter, it becomes a problem. This may never happen, since I don't know of a situation where this would be rendered without the query parameter. Right now, it's only loaded in marketplaces. But if that does happen, I would need to parse the user's query, figure out the chain id of the network they're querying from the table name specified, and connect to the right host from there.

andrewxhill commented 1 year ago

wondering... is that a problem that the sdk should help with? feels... helpful. some ideas

.gatewayFor(tablename) => 'testnet' || 'mainnet'
.gatewayUrlFor(tableland) => 'testnet.tableland.xyz'
.networkFor(tablename) => 'testnet' || 'mainnet'

something like that

andrewxhill commented 1 year ago

another idea, maybe the best

.info(tablename) => {network: string, gateway: string, networkId: int, prefix: string, tokenId: int}
carsonfarmer commented 1 year ago

The refactored SDK (will have, I mean, it has them, but it isn't published) helper functions for getBaseUrl, getChainId, getContractAddress, and others. We could probably also have some helpers explicitly for whether it is a 'testnet' or 'mainnet'?

carsonfarmer commented 1 year ago

With all of that in mind, even with the current parser and sdk, the above information can be extracted. Normalizing a statement can be used to extract the table name, and validateTableName can be used to extract the chainId, etc. Then you simply create a helper function of your own (just for now) that switches on this and returns 'testnet' or 'mainnet' as needed.

carsonfarmer commented 1 year ago

But again, if we can hold off a bit, then we can get all this "for free" via the SDK, because the SDK needs to know all this to route queries appropriately anyway.