Skip to content

Commit

Permalink
Addressing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jaegerfe committed Aug 9, 2024
1 parent 8bcb7b6 commit 9402d35
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
14 changes: 3 additions & 11 deletions src/config/BaseChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,14 @@ export const baseUiConfiguration: UiCustomization = {
};

export default abstract class BaseChain implements Chain {
protected name: string;

constructor(name: string) {
this.name = name;
}

getName(): string {
return this.name;
}
abstract getName(): string;

getLargeLogoPath(): string {
return `~/assets/${this.name}/logo_lg.svg`;
return `~/assets/${this.getName()}/logo_lg.svg`;
}

getSmallLogoPath(): string {
return `~/assets/${this.name}/logo_sm.svg`;
return `~/assets/${this.getName()}/logo_sm.svg`;
}

abstract getSystemToken(): Token;
Expand Down
13 changes: 6 additions & 7 deletions src/config/NetworkFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@ import TelosTestnet from 'src/config/chains/telos-testnet';

import { Chain } from 'src/types/Chain';

// TODO: turn these classes into functions and remove name parameter
export const createNetwork = (name: string): Chain => {
switch (name) {
case 'eos':
return new EOS('eos');
return new EOS();
case 'telos':
return new Telos('telos');
return new Telos();
case 'ux':
return new UX('ux');
return new UX();
case 'wax':
return new Wax('wax');
return new Wax();
case 'jungle':
return new Jungle('jungle');
return new Jungle();
case 'telos-testnet':
return new TelosTestnet('telos-testnet');
return new TelosTestnet();
default:
console.error(`Network ${name} not supported`);
}
Expand Down
11 changes: 6 additions & 5 deletions src/stores/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export interface NetworksStateInterface {
}
const CHAIN_LOCAL_STORAGE = 'selectedChainName';
const PREFERRED_CHAIN_LOCAL_STORAGE = 'preferredChainName';
const SUPPORTED_NETWORKS: string[] = process.env.SUPPORTED_NETWORKS.split(' ');

const supportedNetworks: string[] = process.env.SUPPORTED_NETWORKS.split(' ');

export const useNetworksStore = defineStore('networks', {
state: (): NetworksStateInterface => ({
Expand All @@ -30,9 +31,9 @@ export const useNetworksStore = defineStore('networks', {
},
actions: {
setupNetworks() {
const supportedNetworks: Chain[] = [];
SUPPORTED_NETWORKS.forEach((networkName: string) => supportedNetworks.push(createNetwork(networkName)));
this.networks = supportedNetworks;
const supportedNetworksObjs: Chain[] = [];
supportedNetworks.forEach((networkName: string) => supportedNetworksObjs.push(createNetwork(networkName)));
this.networks = supportedNetworksObjs;

if (this.currentNetworkName) {
// checks if current network is supported
Expand Down Expand Up @@ -76,7 +77,7 @@ export const useNetworksStore = defineStore('networks', {
});

/**
* SUPPORTED_NETWORKS defines all networks we want to show
* supportedNetworks defines all networks we want to show
* if length > 1, we enable the multichain selector
* initial state loads all networks
*/

0 comments on commit 9402d35

Please sign in to comment.