UNPKG

@hiero-ledger/sdk

Version:
3 lines (2 loc) 1.73 kB
import e from"./Client.js";import t from"../channel/NativeChannel.js";import"../account/AccountId.js";import r from"../LedgerId.js";import{NATIVE_PREVIEWNET as n,NATIVE_TESTNET as s,MAINNET as o}from"../constants/ClientConstants.js";const w={MAINNET:o,TESTNET:s,PREVIEWNET:n};class a extends e{constructor(t){if(super(t),null!=t)if("string"==typeof t.network)switch(t.network){case"mainnet":this.setNetwork(w.MAINNET),this.setLedgerId(r.MAINNET);break;case"testnet":this.setNetwork(w.TESTNET),this.setLedgerId(r.TESTNET);break;case"previewnet":this.setNetwork(w.PREVIEWNET),this.setLedgerId(r.PREVIEWNET);break;default:throw new Error(`unknown network: ${t.network}`)}else if(null!=t.network){e._validateNetworkConsistency(t.network);const{shard:r,realm:n}=e._extractShardRealm(t.network);this._shard=r,this._realm=n,this.setNetwork(t.network)}}static fromConfig(e){return new a("string"==typeof e?JSON.parse(e):e)}static forNetwork(e){return new a({network:e,scheduleNetworkUpdate:!1})}static forName(e){return new a({network:e,scheduleNetworkUpdate:!1})}static forMainnet(){return new a({network:"mainnet",scheduleNetworkUpdate:!1})}static forTestnet(){return new a({network:"testnet",scheduleNetworkUpdate:!1})}static forPreviewnet(){return new a({network:"previewnet",scheduleNetworkUpdate:!1})}setNetwork(e){if("string"==typeof e)switch(e){case"previewnet":this._network.setNetwork(w.PREVIEWNET);break;case"testnet":this._network.setNetwork(w.TESTNET);break;case"mainnet":this._network.setNetwork(w.MAINNET)}else this._network.setNetwork(e)}setMirrorNetwork(e){}_createNetworkChannel(){return e=>new t(e)}_createMirrorNetworkChannel(){return e=>null}}export{w as Network,a as default}; //# sourceMappingURL=NativeClient.js.map