Skip to content

Commit

Permalink
Separate creditcoin and creditcoin_native chain (#1084)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyifeng authored Feb 6, 2025
1 parent 379c487 commit 43ece7f
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions backend/packages/backend/src/consts/networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const networks = Object.freeze({
stafi: "stafi",
creditcoin: "creditcoin",
creditcoin_evm: "creditcoin_evm",
creditcoin_native: "creditcoin_native",
});

const evmNetworks = [
Expand Down
2 changes: 1 addition & 1 deletion backend/packages/backend/src/scripts/spaces/creditcoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const config = {
accessibility: Accessibility.PUBLIC,
networks: [
{
network: networks.creditcoin,
network: networks.creditcoin_native,
ss58Format: 42,
assets: [
{
Expand Down
1 change: 1 addition & 0 deletions backend/packages/node-api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ STAFI_ENDPOINTS=wss://mainnet-rpc.stafi.io

# Creditcoin
CTC_ENDPOINTS=wss://rpc.mainnet.creditcoin.network/ws
CTC_CC3_ENDPOINTS=wss://mainnet3.creditcoin.network

MOVR_ENDPOINTS=wss://wss.api.moonriver.moonbeam.network;wss://moonriver.public.blastapi.io
GLMR_ENDPOINTS=wss://wss.api.moonbeam.network/;wss://moonbeam.public.blastapi.io
Expand Down
1 change: 1 addition & 0 deletions backend/packages/node-api/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const chains = {
moonbeam: "moonbeam",
moonriver: "moonriver",
creditcoin: "creditcoin",
creditcoinNative: "creditcoin_native",
};

const noProxyChains = [chains.kintsugi, chains.interlay, chains.crust];
Expand Down
1 change: 1 addition & 0 deletions backend/packages/node-api/src/env/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const chainEndpointPrefixMap = {
[chains.moonbeam]: "GLMR",
[chains.moonriver]: "MOVR",
[chains.creditcoin]: "CTC",
[chains.creditcoinNative]: "CTC_CC3",
};

// [chain, endpoints]
Expand Down
11 changes: 7 additions & 4 deletions next/components/chainIcon.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import camalCase from "lodash.camelcase";
import { ChainIcon as _ChainIcon, Tooltip } from "@osn/common-ui";
import { getChainDisplayName, normalizeChainName } from "frontedUtils/chain";
import { networks } from "frontedUtils/consts/chains/networks";

export function ChainIcon({ chainName, size }) {
let chain = camalCase(normalizeChainName(chainName));
if (chainName === networks.creditcoinNative) {
chain = networks.creditcoin;
}

return (
<Tooltip content={getChainDisplayName(chainName)}>
<div>
<_ChainIcon
chainName={camalCase(normalizeChainName(chainName))}
size={size}
/>
<_ChainIcon chainName={chain} size={size} />
</div>
</Tooltip>
);
Expand Down
5 changes: 4 additions & 1 deletion next/components/identityOrAddr.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { fetchIdentity } from "services/identity";
import { useEffect, useState } from "react";
import { ExternalLink } from "@osn/common-ui";
import encodeAddressByChain from "frontedUtils/chain/addr";
import { networks } from "frontedUtils/consts/chains/networks";

const IdentityWrapper = styled.span`
display: inline-flex;
Expand Down Expand Up @@ -59,7 +60,9 @@ export default function IdentityOrAddr({
link = `https://moonriver.moonscan.io/address/${address}`;
} else if (evm.moonbeam === network) {
link = `https://moonscan.io/address/${address}`;
} else if ("creditcoin" === network) {
} else if (
[networks.creditcoin, networks.creditcoinNative].includes(network)
) {
link = `https://explorer.creditcoin.org/Account/RecentExtrinsics/${address}`;
} else if (evm.creditcoin_evm === network) {
link = `https://creditcoin.blockscout.com/address/${address}`;
Expand Down
4 changes: 1 addition & 3 deletions next/frontedUtils/chain/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ export function normalizeChainName(chainName) {
}

export function getChainDisplayName(chainName) {
if (chainName === networks.creditcoin) {
return "Creditcoin Native";
} else if (chainName === networks.creditcoinEvm) {
if (chainName === networks.creditcoinEvm) {
return "Creditcoin";
}
return startCase(normalizeChainName(chainName));
Expand Down
1 change: 1 addition & 0 deletions next/frontedUtils/consts/chains/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const chainConfigsMap = {
hydradx,
rococo,
creditcoin,
creditcoin_native: creditcoin,
};

export function getChainConfigs(chain) {
Expand Down
1 change: 1 addition & 0 deletions next/frontedUtils/consts/chains/networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ export const networks = Object.freeze({
stafi: "stafi",
creditcoin: "creditcoin",
creditcoinEvm: "creditcoin_evm",
creditcoinNative: "creditcoin_native",
});

0 comments on commit 43ece7f

Please sign in to comment.