Prepare chain upgrading#101
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| const amount = delegation?.balance?.amount || "0"; | ||
| const formattedAmount = (parseInt(amount) / 1000000).toLocaleString(); | ||
| const formattedAmount = ( | ||
| parseInt(amount) / 1000000000000000000 |
There was a problem hiding this comment.
We have this decimal converter in multiple place, this should be a constant and we should have a util convert function
| }; | ||
|
|
||
| const formatDenom = (denom: string) => (denom === "ukii" ? "kii" : denom); | ||
| const formatDenom = (denom: string) => (denom === "akii" ? "kii" : denom); |
There was a problem hiding this comment.
Centralized the denom into a constant
| "https://rpc.plata-404.kiivalidator.com, | ||
| https://rpc.plata-404.kiivalidator.com" |
There was a problem hiding this comment.
Why the exposed links here (and not being a constant)? Also this should be testnet
| (acc: number, curr: DelegationResponse) => { | ||
| const amount = curr.balance?.amount | ||
| ? parseFloat(curr.balance.amount) / 1_000_000 | ||
| ? parseFloat(curr.balance.amount) / 1_000_000_000_000_000_000 |
There was a problem hiding this comment.
As the other comment, turn the number to convert into a constant and this conversion function into a util function
| (r: Reward) => r.denom === "akii" | ||
| ); | ||
| const amount = kiiReward ? parseFloat(kiiReward.amount) / 1_000_000 : 0; | ||
| const amount = kiiReward | ||
| ? parseFloat(kiiReward.amount) / 1_000_000_000_000_000_000 | ||
| : 0; |
There was a problem hiding this comment.
Same thing here, constant and util function
| // useHexToBech converts the evm address into the cosmos (Bech32) address | ||
| export function useHexToBech(evmAddress?: string) { | ||
| const cosmosAddress = useMemo(() => { | ||
| if (!evmAddress || !evmAddress.startsWith("0x") || !isAddress(evmAddress)) { | ||
| return null; | ||
| } | ||
|
|
||
| const bytes = Buffer.from(evmAddress.slice(2), "hex"); | ||
| if (bytes.length !== 20) { | ||
| return null; | ||
| } | ||
|
|
||
| return toBech32("kii", bytes); | ||
| }, [evmAddress]); | ||
|
|
||
| return { cosmosAddress }; | ||
| } |
There was a problem hiding this comment.
100% sure that this is generating the correct address right?
| parseInt(stakingData.pool.bonded_tokens) / 1_000_000_000_000_000_000 | ||
| ).toFixed(2) | ||
| : "0.0"; | ||
|
|
||
| const communityPoolAmount = communityPoolData?.pool?.find( | ||
| (item: { denom: string }) => item.denom === "ukii" | ||
| (item: { denom: string }) => item.denom === "akii" | ||
| )?.amount; | ||
|
|
||
| const communityPoolKii = communityPoolAmount | ||
| ? (parseFloat(communityPoolAmount) / 1_000_000).toFixed(4) | ||
| : "0.0000"; | ||
| ? (parseFloat(communityPoolAmount) / 1_000_000_000_000_000_000).toFixed( | ||
| 1 | ||
| ) | ||
| : "0.0"; | ||
|
|
||
| const totalSupply = totalSupplyData?.supply?.find( | ||
| (item: { denom: string }) => item.denom === "akii" | ||
| ); | ||
|
|
||
| const totalSupplyKii = totalSupply | ||
| ? (parseFloat(totalSupply.amount) / 1_000_000_000_000_000_000).toFixed( | ||
| 1 | ||
| ) | ||
| : "0.0"; |
There was a problem hiding this comment.
Constant and util function
Description
These changes make the following:
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
This code has been tested locally