@hiero-ledger/sdk
Version:
3 lines (2 loc) • 2.78 kB
JavaScript
import t from"../account/AccountId.js";import s from"./Endpoint.js";import{encode as e,decode as i}from"../encoding/utf8.js";import n from"long";class d{constructor(t={}){this._publicKey=null,null!=t.publicKey&&this.setPublicKey(t.publicKey),this._nodeId=null,null!=t.nodeId&&this.setNodeId(t.nodeId),this._accountId=null,null!=t.accountId&&this.setAccountId(t.accountId),this._certHash=null,null!=t.certHash&&this.setCertHash(t.certHash),this._addresses=[],null!=t.addresses&&this.setAddresses(t.addresses),this._description=null,null!=t.description&&this.setDescription(t.description),this._stake=null,null!=t.stake&&this.setStake(t.stake)}get publicKey(){return this._publicKey}setPublicKey(t){return this._publicKey=t,this}get nodeId(){return this._nodeId}setNodeId(t){return this._nodeId=t,this}get accountId(){return this._accountId}setAccountId(s){return this._accountId="string"==typeof s?t.fromString(s):s.clone(),this}get certHash(){return this._certHash}setCertHash(t){return this._certHash=t,this}get addresses(){return this._addresses}setAddresses(t){return this._addresses=t,this}get description(){return this._description}setDescription(t){return this._description=t,this}get stake(){return this._stake}setStake(t){return this._stake=t,this}static _fromProtobuf(e){return new d({publicKey:null!=e.RSA_PubKey?e.RSA_PubKey:void 0,nodeId:null!=e.nodeId?e.nodeId:void 0,accountId:null!=e.nodeAccountId?t._fromProtobuf(e.nodeAccountId):void 0,certHash:null!=e.nodeCertHash?e.nodeCertHash:void 0,addresses:null!=e.serviceEndpoint?e.serviceEndpoint.map(t=>s._fromProtobuf(t)):void 0,description:null!=e.description?e.description:void 0,stake:null!=e.stake?e.stake:void 0})}_toProtobuf(){return{RSA_PubKey:this._publicKey,nodeId:this._nodeId,nodeAccountId:null!=this._accountId?this._accountId._toProtobuf():null,nodeCertHash:this._certHash,serviceEndpoint:this._addresses.map(t=>t._toProtobuf()),description:this._description,stake:this._stake}}static fromJSON(i){return new d({publicKey:i.publicKey??void 0,nodeId:null!=i.nodeId?n.fromString(i.nodeId):void 0,accountId:i.accountId?t.fromString(i.accountId):void 0,certHash:null!=i.certHash?e(i.certHash):void 0,addresses:null!=i.addresses?i.addresses.map(t=>s.fromJSON(t)):void 0,description:i.description??void 0,stake:null!=i.stake?n.fromString(i.stake):void 0})}toString(){return JSON.stringify(this.toJSON())}toJSON(){return{publicKey:this._publicKey,nodeId:null!=this._nodeId?this._nodeId.toString():null,accountId:null!=this._accountId?this._accountId.toString():null,certHash:null!=this._certHash?i(this._certHash):null,addresses:this._addresses.map(t=>t.toJSON()),description:this._description,stake:null!=this._stake?this._stake.toString():null}}}export{d as default};
//# sourceMappingURL=NodeAddress.js.map