import Web3 from "web3";
import { provider as Provider } from 'web3-core';
import { EnvTypes } from "../typesBundle";
import { Network } from '../types/CommonTypes';
/**
* @typedef {Object} IMyriaClient
* @property {string | extendedProvider} Provider Provider for Myria client
* @property {number} NetworkId Network
* @property {Web3} Web3 Instance of web3
* @property {EnvTypes} EnvTypes Target environment
*/
export interface IMyriaClient {
provider: Provider;
networkId: Network;
web3: Web3;
env: EnvTypes;
}
export class MyriaClient {
public provider: Provider;
public networkId: Network;
public web3: Web3;
public env: EnvTypes;
constructor(
client: IMyriaClient,
) {
this.provider = client.provider;
this.networkId = client.networkId;
this.web3 = client.web3;
this.env = client.env;
}
public setProvider(provider: Provider): void {
this.provider = provider;
}
public setNetworkId(networkId: number): void {
this.networkId = networkId;
}
public setWeb3(web3: Web3): void {
this.web3 = web3;
}
public setEnv(env: EnvTypes): void {
this.env = env;
}
public getProvider(): Provider {
return this.provider;
}
public getNetworkId(): number {
return this.networkId;
}
public getWeb3(): Web3 {
return this.web3;
}
public getEnv(): EnvTypes {
return this.env;
}
}
Source