Skip to content

Prepare chain upgrading#101

Merged
AndresRamirez9912 merged 12 commits into
mainfrom
feat/prepare-v4
Apr 29, 2025
Merged

Prepare chain upgrading#101
AndresRamirez9912 merged 12 commits into
mainfrom
feat/prepare-v4

Conversation

@AndresRamirez9912
Copy link
Copy Markdown
Collaborator

Description

These changes make the following:

  • Centralize the chain endpoints usage (use constants instead of hardcoded)
  • Centralize the ukii constants (use constants from kiijs instead of hardcoded)
  • Use kiijs staking with the new chain implementation
  • Remove supply side bar element

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Documentation (updates documentation on the project)
  • chore (Updates on dependencies, gitignore, etc)
  • test (For updates on tests)

How Has This Been Tested?

This code has been tested locally

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 25, 2025

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

Name Status Preview Comments Updated (UTC)
kii-explorer-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 29, 2025 3:12pm

const amount = delegation?.balance?.amount || "0";
const formattedAmount = (parseInt(amount) / 1000000).toLocaleString();
const formattedAmount = (
parseInt(amount) / 1000000000000000000
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Centralized the denom into a constant

Comment on lines +119 to +120
"https://rpc.plata-404.kiivalidator.com,
https://rpc.plata-404.kiivalidator.com"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why the exposed links here (and not being a constant)? Also this should be testnet

Comment thread src/services/cosmos.ts Outdated
(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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As the other comment, turn the number to convert into a constant and this conversion function into a util function

Comment thread src/services/cosmos.ts Outdated
Comment on lines +45 to +49
(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;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same thing here, constant and util function

Comment on lines +5 to +21
// 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 };
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

100% sure that this is generating the correct address right?

Comment thread src/services/queries/chainData.ts Outdated
Comment on lines +44 to +66
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";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Constant and util function

@AndresRamirez9912 AndresRamirez9912 merged commit 775e9c7 into main Apr 29, 2025
5 checks passed
@AndresRamirez9912 AndresRamirez9912 deleted the feat/prepare-v4 branch April 29, 2025 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants