o3-dapi-ont
Version:
Ontology Plugin for o3-dapi
12 lines (10 loc) • 553 B
text/typescript
import { Network } from './constants';
export const methodSelector = (self, namespace, methodName, dapiMethod, requireClientNetwork = true) => {
return data => {
const network = data && data.network;
const isClientNetwork = !requireClientNetwork || network === Network.MainNet || network === Network.TestNet;
const clientMethod = self.clientPlugin && self.clientPlugin[namespace] && self.clientPlugin[namespace][methodName];
const method = isClientNetwork && clientMethod ? clientMethod : dapiMethod;
return method(data);
};
};