Skip to content

Commit

Permalink
Merge pull request #45 from oraichain/feat/oasis-ext
Browse files Browse the repository at this point in the history
Feat/oasis ext
  • Loading branch information
toandq2009 authored Feb 26, 2024
2 parents ecba32c + 36ee5b4 commit 0c0dcbc
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 451 deletions.
22 changes: 12 additions & 10 deletions src/chains/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class ChainsService {
return this.cachedChainInfos;
}

const chainInfos = this.embedChainInfos.map(chainInfo => {
const chainInfos = this.embedChainInfos.map((chainInfo) => {
return {
...chainInfo,
embeded: true
Expand All @@ -45,7 +45,7 @@ export class ChainsService {
}

const savedChainInfos: ChainInfoWithEmbed[] = ((await this.kvStore.get<ChainInfo[]>('chain-infos')) ?? [])
.filter(chainInfo => {
.filter((chainInfo) => {
// Filter the overlaped chain info with the embeded chain infos.
return !embedChainInfoIdentifierMap.get(ChainIdHelper.parse(chainInfo.chainId).identifier);
})
Expand All @@ -60,7 +60,7 @@ export class ChainsService {

// Set the updated property of the chain.
result = await Promise.all(
result.map(async chainInfo => {
result.map(async (chainInfo) => {
const updated: ChainInfo = await this.chainUpdaterKeeper.putUpdatedPropertyToChainInfo(chainInfo);

return {
Expand All @@ -87,7 +87,7 @@ export class ChainsService {
}

async getChainInfosWithoutEndpoints(): Promise<ChainInfoWithoutEndpoints[]> {
return (await this.getChainInfos()).map<ChainInfoWithoutEndpoints>(chainInfo => {
return (await this.getChainInfos()).map<ChainInfoWithoutEndpoints>((chainInfo) => {
const chainInfoMutable: Mutable<
Optional<ChainInfoWithCoreTypes, 'rpc' | 'rest' | 'updateFromRepoDisabled' | 'embeded'>
> = {
Expand All @@ -113,26 +113,28 @@ export class ChainsService {
if (networkType) {
if (networkType === 'evm') {
// need to check if network type is evm, then we will convert chain id to number from hex
chainInfo = (await this.getChainInfos()).find(chainInfo => {
chainInfo = (await this.getChainInfos()).find((chainInfo) => {
return (
ChainIdHelper.parse(Number(chainInfo.chainId)).identifier ===
ChainIdHelper.parse(Number(chainId)).identifier && chainInfo.networkType === networkType
);
});
} else {
chainInfo = (await this.getChainInfos()).find(chainInfo => {
chainInfo = (await this.getChainInfos()).find((chainInfo) => {
return (
ChainIdHelper.parse(chainInfo.chainId).identifier === ChainIdHelper.parse(chainId).identifier &&
chainInfo.networkType === networkType
);
});
}
} else {
chainInfo = (await this.getChainInfos()).find(chainInfo => {
chainInfo = (await this.getChainInfos()).find((chainInfo) => {
return ChainIdHelper.parse(chainInfo.chainId).identifier === ChainIdHelper.parse(chainId).identifier;
});
}

chainInfo = (await this.getChainInfos()).find((chainInfo) => {
return ChainIdHelper.parse(chainInfo.chainId).identifier === ChainIdHelper.parse(chainId).identifier;
});
if (!chainInfo) {
throw new Error(`There is no chain info for ${chainId}`);
}
Expand All @@ -150,7 +152,7 @@ export class ChainsService {

async hasChainInfo(chainId: string): Promise<boolean> {
return (
(await this.getChainInfos()).find(chainInfo => {
(await this.getChainInfos()).find((chainInfo) => {
return ChainIdHelper.parse(chainInfo.chainId).identifier === ChainIdHelper.parse(chainId).identifier;
}) != null
);
Expand Down Expand Up @@ -210,7 +212,7 @@ export class ChainsService {

const savedChainInfos = (await this.kvStore.get<ChainInfo[]>('chain-infos')) ?? [];

const resultChainInfo = savedChainInfos.filter(chainInfo => {
const resultChainInfo = savedChainInfos.filter((chainInfo) => {
return ChainIdHelper.parse(chainInfo.chainId).identifier !== ChainIdHelper.parse(chainId).identifier;
});

Expand Down
Loading

0 comments on commit 0c0dcbc

Please sign in to comment.