mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-14 06:02:36 +03:00
Sublings optimization
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { ethers } from 'ethers';
|
||||
import getOrionUnitSiblings from '../getOrionUnitSiblings';
|
||||
import { OrionAggregator } from '../services/OrionAggregator';
|
||||
import OrionAnalytics from '../services/OrionAnalytics';
|
||||
import { OrionBlockchain } from '../services/OrionBlockchain';
|
||||
@@ -143,6 +142,13 @@ export default class OrionUnit {
|
||||
}
|
||||
|
||||
get siblings() {
|
||||
return getOrionUnitSiblings(this.chainId, this.env);
|
||||
const envInfo = envs[this.env];
|
||||
const envNetworks = envInfo?.networks;
|
||||
|
||||
const siblingsNetworks = Object
|
||||
.keys(envNetworks)
|
||||
.filter(isValidChainId)
|
||||
.filter((chainId) => chainId !== this.chainId);
|
||||
return siblingsNetworks.map((chainId) => new OrionUnit(chainId, this.env));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import { SupportedChainId } from './types';
|
||||
import { isValidChainId } from './utils';
|
||||
import { envs } from './config';
|
||||
import OrionUnit from './OrionUnit';
|
||||
|
||||
export default function getOrionUnitSiblings(siblingChain: SupportedChainId, env: string) {
|
||||
if (!(env in envs)) throw new Error(`Env '${env}' not found. Available environments is: ${Object.keys(envs).join(', ')}`);
|
||||
const envInfo = envs[env];
|
||||
const envNetworks = envInfo?.networks;
|
||||
|
||||
if (!(siblingChain in envNetworks)) {
|
||||
throw new Error(`Chain '${siblingChain}' not found. `
|
||||
+ `Available chains in selected environment (${env}) is: ${Object.keys(envNetworks).join(', ')}`);
|
||||
}
|
||||
const siblingsNetworks = Object
|
||||
.keys(envNetworks)
|
||||
.filter(isValidChainId)
|
||||
.filter((chainId) => chainId !== siblingChain);
|
||||
return siblingsNetworks.map((chainId) => new OrionUnit(chainId, env));
|
||||
}
|
||||
Reference in New Issue
Block a user