econia-labs / emojicoin-dot-fun

https://emojicoin-dot-fun.vercel.app
Other
6 stars 14 forks source link

[ECO-2488] Fix emojicoin balance query by using the view function instead of the external indexer API #404

Closed xbtmatt closed 1 week ago

xbtmatt commented 1 week ago

Description

The external indexer API (the Aptos Labs hosted one) expects addresses without leading zeroes. If you send a CoinType with a leading zero in the first third of the MoveStruct (e.g. 0x0...beef::coin_module::CoinType, even if the address is correct, the current_fungible_asset_balance query will return zero.

One out of 16 addresses will start with a 0, so this was a fairly pervasive issue.

An example is the two billiard coin:

https://explorer.aptoslabs.com/coin/0x072a70c925a8260880de81b500ecd743e652cd74797eb1d024f44ea195cbf8bb::coin_factory::Emojicoin?network=mainnet

Note the address starts with 0x072

The issue is that AIP-40 stipulates that a standardized address does include leading zeros, but the indexer expects no leading zeroes.

We could parse it and conform to the expected indexer format, but it's simpler to just use a view function instead, since the address is serialized and thus the leading zero is no longer an issue.

Testing

Testing it in the preview build

Checklist

vercel[bot] commented 1 week ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
emojicoin-dot-fun ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 21, 2024 7:34pm
emojicoin-dot-fun-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 21, 2024 7:34pm