Skip to content

Commit

Permalink
Feat/swan chain (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
rustin01 authored Nov 13, 2024
1 parent ee2cda9 commit f97ef80
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 5 deletions.
19 changes: 19 additions & 0 deletions apps/wallet/public/chain-icons/Swan.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions apps/wallet/src/pages/select-network/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const SelectNetworkPage: FC = observer(() => {
const chainsMap: Record<string, ChainInfo[]> = {}
const supportedChains = getSupportedChains()
supportedChains.forEach((chain) => {
if (!chainsMap[chain.chainId.type.name]) {
chainsMap[chain.chainId.type.name] = []
if (!chainsMap[chain.ecosystem]) {
chainsMap[chain.ecosystem] = []
}
chainsMap[chain.chainId.type.name].push(chain)
chainsMap[chain.ecosystem].push(chain)
})
return chainsMap
}, [])
Expand Down
10 changes: 10 additions & 0 deletions apps/wallet/src/utils/basicEnums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,13 @@ export enum WalletSignatureSchema {
SolanaEddsa = '0x7da',
IcpEddsa = '0x7e4'
}

// TODO: Add support for other ecosystems
export enum Ecosystem {
EVM = 'EVM',
Bitcoin = 'Bitcoin',
Solana = 'Solana',
Tron = 'Tron',
Ton = 'Ton',
IC = 'Internet Computer'
}
4 changes: 4 additions & 0 deletions apps/wallet/src/utils/basicTypes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import BigNumber from 'bignumber.js';
import { Transform, Type } from 'class-transformer';
import { WalletSignatureSchema } from './basicEnums';
import { Ecosystem } from './basicEnums';

export class AssetId {
value: BigNumber;
Expand Down Expand Up @@ -193,6 +194,8 @@ export class ChainNetwork {
static EvmScrollSepoliaNet = new ChainNetwork(new BigNumber(534351));
static EvmBitlayerNet = new ChainNetwork(new BigNumber(200901));
static EvmBitlayerTestNet = new ChainNetwork(new BigNumber(200810));
static EvmSwanNet = new ChainNetwork(new BigNumber(254));
static EvmSwanTestNet = new ChainNetwork(new BigNumber(20241133));

static SolanaMainNet = new ChainNetwork(new BigNumber(0x3));
static SolanaTestNet = new ChainNetwork(new BigNumber(0x2));
Expand Down Expand Up @@ -280,6 +283,7 @@ export class ChainInfo {
rpcUrls!: string[];
isMainnet!: boolean
isNativeGas!: boolean;
ecosystem!: Ecosystem;
caseSensitiveAddress?: boolean;
getServerFormatAddress?: (address: string) => string | null
getTxLink?: (txId: string) => string
Expand Down
53 changes: 52 additions & 1 deletion apps/wallet/src/utils/chain/chain-list.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WalletSignatureSchema } from "../basicEnums";
import { Ecosystem, WalletSignatureSchema } from "../basicEnums";
import { ChainInfo, ChainId, Chain, ChainNetwork } from "../basicTypes";
import { clusterApiUrl } from '@solana/web3.js';
import { getHttpEndpoint } from "@orbs-network/ton-access";
Expand All @@ -13,6 +13,7 @@ export const Ethereum: ChainInfo = {
nativeAssetDecimals: 18,
isMainnet: true,
isNativeGas: true,
ecosystem: Ecosystem.EVM,
supportedSignaturesSchemas: [WalletSignatureSchema.EvmEcdsa],
explorer: 'https://etherscan.io',
rpcUrls: ['https://ethereum.blockpi.network/v1/rpc/public']
Expand All @@ -26,6 +27,7 @@ export const EthereumSepolia: ChainInfo = {
nativeAssetDecimals: 18,
isMainnet: false,
isNativeGas: true,
ecosystem: Ecosystem.EVM,
supportedSignaturesSchemas: [WalletSignatureSchema.EvmEcdsa],
explorer: 'https://sepolia.etherscan.io',
rpcUrls: ['https://ethereum-sepolia.blockpi.network/v1/rpc/public ']
Expand All @@ -40,6 +42,7 @@ export const EthereumBsc: ChainInfo = {
nativeAssetDecimals: 18,
isMainnet: true,
isNativeGas: true,
ecosystem: Ecosystem.EVM,
supportedSignaturesSchemas: [WalletSignatureSchema.EvmEcdsa],
explorer: 'https://bscscan.com',
rpcUrls: ['https://bsc-dataseed.binance.org']
Expand All @@ -53,6 +56,7 @@ export const EthereumBscTestnet: ChainInfo = {
nativeAssetDecimals: 18,
isMainnet: false,
isNativeGas: true,
ecosystem: Ecosystem.EVM,
supportedSignaturesSchemas: [WalletSignatureSchema.EvmEcdsa],
explorer: 'https://testnet.bscscan.com',
rpcUrls: ['https://bsc-testnet.publicnode.com']
Expand All @@ -67,6 +71,7 @@ export const EthereumScroll: ChainInfo = {
nativeAssetDecimals: 18,
isMainnet: true,
isNativeGas: true,
ecosystem: Ecosystem.EVM,
supportedSignaturesSchemas: [WalletSignatureSchema.EvmEcdsa],
explorer: 'https://scroll.l2scan.co',
rpcUrls: ['https://rpc.scroll.io']
Expand All @@ -80,6 +85,7 @@ export const EthereumScrollSepolia: ChainInfo = {
nativeAssetDecimals: 18,
isMainnet: false,
isNativeGas: true,
ecosystem: Ecosystem.EVM,
supportedSignaturesSchemas: [WalletSignatureSchema.EvmEcdsa],
explorer: 'https://scroll-sepolia.l2scan.co',
rpcUrls: ['https://sepolia-rpc.scroll.io']
Expand All @@ -94,6 +100,7 @@ export const EthereumBase: ChainInfo = {
nativeAssetDecimals: 18,
isMainnet: true,
isNativeGas: true,
ecosystem: Ecosystem.EVM,
supportedSignaturesSchemas: [WalletSignatureSchema.EvmEcdsa],
explorer: 'https://basescan.org',
rpcUrls: ['https://mainnet.base.org']
Expand All @@ -107,6 +114,7 @@ export const EthereumBaseSepolia: ChainInfo = {
nativeAssetDecimals: 18,
isMainnet: false,
isNativeGas: true,
ecosystem: Ecosystem.EVM,
supportedSignaturesSchemas: [WalletSignatureSchema.EvmEcdsa],
explorer: 'https://sepolia.basescan.org',
rpcUrls: ['https://sepolia.base.org']
Expand All @@ -121,6 +129,7 @@ export const EthereumAvalanche: ChainInfo = {
nativeAssetDecimals: 18,
isMainnet: true,
isNativeGas: true,
ecosystem: Ecosystem.EVM,
supportedSignaturesSchemas: [WalletSignatureSchema.EvmEcdsa],
explorer: 'https://snowtrace.io',
rpcUrls: ['https://api.avax.network/ext/bc/C/rpc']
Expand All @@ -134,6 +143,7 @@ export const EthereumAvalancheFuji: ChainInfo = {
nativeAssetDecimals: 18,
isMainnet: false,
isNativeGas: true,
ecosystem: Ecosystem.EVM,
supportedSignaturesSchemas: [WalletSignatureSchema.EvmEcdsa],
explorer: 'https://subnets-test.avax.network/c-chain',
rpcUrls: ['https://api.avax-test.network/ext/bc/C/rpc']
Expand All @@ -148,6 +158,7 @@ export const EthereumBitlayer: ChainInfo = {
nativeAssetDecimals: 18,
isMainnet: true,
isNativeGas: true,
ecosystem: Ecosystem.Bitcoin,
supportedSignaturesSchemas: [WalletSignatureSchema.EvmEcdsa],
explorer: 'https://btrscan.com',
rpcUrls: ['https://rpc.bitlayer.org']
Expand All @@ -161,11 +172,41 @@ export const EthereumBitlayerTestnet: ChainInfo = {
nativeAssetDecimals: 18,
isMainnet: false,
isNativeGas: true,
ecosystem: Ecosystem.Bitcoin,
supportedSignaturesSchemas: [WalletSignatureSchema.EvmEcdsa],
explorer: 'https://testnet.btrscan.com',
rpcUrls: ['https://testnet-rpc.bitlayer.org']
};

export const EthereumSwan: ChainInfo = {
chainId: new ChainId(Chain.Ethereum, ChainNetwork.EvmSwanNet),
name: 'Swan',
fullName: 'Swan Mainnet',
icon: '/chain-icons/Swan.svg',
nativeAssetSymbol: 'ETH',
nativeAssetDecimals: 18,
isMainnet: true,
isNativeGas: true,
ecosystem: Ecosystem.EVM,
supportedSignaturesSchemas: [WalletSignatureSchema.EvmEcdsa],
explorer: 'https://swanscan.io',
rpcUrls: ['https://mainnet-rpc.swanchain.org']
};
export const EthereumSwanTestnet: ChainInfo = {
chainId: new ChainId(Chain.Ethereum, ChainNetwork.EvmSwanTestNet),
name: 'Swan Testnet',
fullName: 'Swan Proxima Testnet',
icon: '/chain-icons/Swan.svg',
nativeAssetSymbol: 'ETH',
nativeAssetDecimals: 18,
isMainnet: false,
isNativeGas: true,
ecosystem: Ecosystem.EVM,
supportedSignaturesSchemas: [WalletSignatureSchema.EvmEcdsa],
explorer: 'https://proxima-explorer.swanchain.io',
rpcUrls: ['https://rpc-proxima.swanchain.io']
};

export const Bitcoin: ChainInfo = {
chainId: new ChainId(Chain.Bitcoin, ChainNetwork.BtcMainNet),
name: 'Bitcoin',
Expand All @@ -175,6 +216,7 @@ export const Bitcoin: ChainInfo = {
nativeAssetDecimals: 8,
isMainnet: true,
isNativeGas: true,
ecosystem: Ecosystem.Bitcoin,
supportedSignaturesSchemas: [WalletSignatureSchema.BtcEcdsa],
explorer: 'https://blockstream.info',
rpcUrls: []
Expand All @@ -188,6 +230,7 @@ export const BitcoinTestnet: ChainInfo = {
nativeAssetDecimals: 8,
isMainnet: false,
isNativeGas: true,
ecosystem: Ecosystem.Bitcoin,
supportedSignaturesSchemas: [WalletSignatureSchema.BtcEcdsa],
explorer: 'https://blockstream.info/testnet',
rpcUrls: []
Expand All @@ -202,6 +245,7 @@ export const Solana: ChainInfo = {
nativeAssetDecimals: 9,
isMainnet: true,
isNativeGas: true,
ecosystem: Ecosystem.Solana,
supportedSignaturesSchemas: [WalletSignatureSchema.SolanaEddsa],
explorer: 'https://explorer.solana.com',
rpcUrls: [clusterApiUrl('mainnet-beta')],
Expand All @@ -216,6 +260,7 @@ export const SolanaTestnet: ChainInfo = {
nativeAssetDecimals: 9,
isMainnet: false,
isNativeGas: true,
ecosystem: Ecosystem.Solana,
supportedSignaturesSchemas: [WalletSignatureSchema.SolanaEddsa],
explorer: 'https://explorer.solana.com?cluster=testnet',
rpcUrls: [clusterApiUrl('testnet')],
Expand All @@ -231,6 +276,7 @@ export const Ton: ChainInfo = {
nativeAssetDecimals: 9,
isMainnet: true,
isNativeGas: true,
ecosystem: Ecosystem.Ton,
supportedSignaturesSchemas: [WalletSignatureSchema.TonEddsaOpenMask],
explorer: 'https://tonviewer.com',
rpcUrls: [],
Expand Down Expand Up @@ -282,6 +328,7 @@ export const TonTestnet: ChainInfo = {
nativeAssetDecimals: 9,
isMainnet: false,
isNativeGas: true,
ecosystem: Ecosystem.Ton,
supportedSignaturesSchemas: [WalletSignatureSchema.TonEddsaOpenMask],
explorer: 'https://testnet.tonviewer.com',
rpcUrls: [],
Expand Down Expand Up @@ -342,6 +389,7 @@ export const Tron: ChainInfo = {
nativeAssetDecimals: 6,
isMainnet: true,
isNativeGas: true,
ecosystem: Ecosystem.Tron,
supportedSignaturesSchemas: [WalletSignatureSchema.TronEcdsa],
explorer: 'https://tronscan.org',
rpcUrls: ['https://rpc.trongrid.io'],
Expand Down Expand Up @@ -369,6 +417,7 @@ export const TronShasta: ChainInfo = {
nativeAssetDecimals: 6,
isMainnet: false,
isNativeGas: true,
ecosystem: Ecosystem.Tron,
supportedSignaturesSchemas: [WalletSignatureSchema.TronEcdsa],
explorer: 'https://shasta.tronscan.org',
rpcUrls: ['https://api.shasta.trongrid.io'],
Expand Down Expand Up @@ -396,6 +445,7 @@ export const TronNile: ChainInfo = {
nativeAssetDecimals: 6,
isMainnet: false,
isNativeGas: true,
ecosystem: Ecosystem.Tron,
supportedSignaturesSchemas: [WalletSignatureSchema.TronEcdsa],
explorer: 'https://nile.tronscan.org',
rpcUrls: ['https://api.nileex.io'],
Expand Down Expand Up @@ -424,6 +474,7 @@ export const Dfinity: ChainInfo = {
nativeAssetDecimals: 8,
isMainnet: true,
isNativeGas: false,
ecosystem: Ecosystem.IC,
supportedSignaturesSchemas: [WalletSignatureSchema.IcpEddsa],
explorer: 'https://dashboard.internetcomputer.org',
rpcUrls: ['https://ic0.app'],
Expand Down
4 changes: 3 additions & 1 deletion apps/wallet/src/utils/chain/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Chain, ChainId } from '../basicTypes';
import { Ethereum, EthereumAvalanche, EthereumAvalancheFuji, EthereumBase, EthereumBaseSepolia, EthereumBsc, EthereumBscTestnet, EthereumScroll, EthereumScrollSepolia, EthereumSepolia, EthereumBitlayer, EthereumBitlayerTestnet, Ton, TonTestnet, Dfinity } from './chain-list';
import { Ethereum, EthereumAvalanche, EthereumAvalancheFuji, EthereumBase, EthereumBaseSepolia, EthereumBsc, EthereumBscTestnet, EthereumScroll, EthereumScrollSepolia, EthereumSepolia, EthereumBitlayer, EthereumBitlayerTestnet, Ton, TonTestnet, Dfinity, EthereumSwan, EthereumSwanTestnet } from './chain-list';
import { ChainInfo } from '../basicTypes';
import { RUNTIME_SUPPORTED_CHAIN_IDS } from '../runtime';
import hibitIdSession from '../../stores/session';
Expand All @@ -14,6 +14,7 @@ const SupportedChainsForMainnet = [
EthereumScroll,
EthereumAvalanche,
EthereumBitlayer,
EthereumSwan,
// Bitcoin,
// Solana,
Ton,
Expand All @@ -27,6 +28,7 @@ const SupportedChainsForTestnet = [
EthereumScrollSepolia,
EthereumAvalancheFuji,
EthereumBitlayerTestnet,
EthereumSwanTestnet,
// BitcoinTestnet,
// SolanaTestnet,
TonTestnet,
Expand Down

0 comments on commit f97ef80

Please sign in to comment.