import t from"../account/AccountId.js";import i from"../Key.js";import e,{TRANSACTION_REGISTRY as n}from"../transaction/Transaction.js";import s from"./ServiceEndpoint.js";class r extends e{constructor(t){super(),this._nodeId=null!=t?.nodeId?t.nodeId:null,this._accountId=null!=t?.accountId?t.accountId:null,this._description=null!=t?.description?t.description:null,this._gossipEndpoints=null!=t?.gossipEndpoints?t.gossipEndpoints:null,this._serviceEndpoints=null!=t?.serviceEndpoints?t.serviceEndpoints:null,this._gossipCaCertificate=null!=t?.gossipCaCertificate?t.gossipCaCertificate:null,this._grpcCertificateHash=null!=t?.grpcCertificateHash?t.grpcCertificateHash:null,this._adminKey=null!=t?.adminKey?t.adminKey:null,this._declineReward=null!=t?.declineReward?t.declineReward:null}static _fromProtobuf(n,o,d,a,c){const u=c[0].nodeUpdate;return e._fromProtobufTransactions(new r({nodeId:null!=u.nodeId?u.nodeId:void 0,accountId:null!=u.accountId?t._fromProtobuf(u.accountId):void 0,description:null!=u.description&&Object.hasOwn(u.description,"value")?u.description.value:void 0,gossipEndpoints:null!=u.gossipEndpoint?u.gossipEndpoint.map((t=>s._fromProtobuf(t))):void 0,serviceEndpoints:null!=u.serviceEndpoint?u.serviceEndpoint.map((t=>s._fromProtobuf(t))):void 0,gossipCaCertificate:null!=u.gossipCaCertificate&&Object.hasOwn(u.gossipCaCertificate,"value")?u.gossipCaCertificate.value:void 0,grpcCertificateHash:null!=u.grpcCertificateHash&&Object.hasOwn(u.grpcCertificateHash,"value")?u.grpcCertificateHash.value:void 0,adminKey:null!=u.adminKey?i._fromProtobufKey(u.adminKey):void 0,declineReward:null!=u.declineReward?.value?u.declineReward.value:void 0}),n,o,d,a,c)}setNodeId(t){return this._requireNotFrozen(),this._nodeId=t,this}get nodeId(){return this._nodeId}setAccountId(i){return this._requireNotFrozen(),this._accountId=i instanceof t?i:t.fromString(i),this}get accountId(){return this._accountId}setDescription(t){if(this._requireNotFrozen(),t.length>100)throw new Error("Description must be at most 100 characters.");return this._description=t,this}clearDescription(){this._description=""}get description(){return this._description}setGossipEndpoints(t){if(this._requireNotFrozen(),0==t.length)throw new Error("GossipEndpoints list must not be empty.");if(t.length>10)throw new Error("GossipEndpoints list must not contain more than 10 entries.");return this._gossipEndpoints=[...t],this}get gossipEndpoints(){return this._gossipEndpoints}addGossipEndpoint(t){return this._requireNotFrozen(),null!=this._gossipEndpoints&&this._gossipEndpoints.push(t),this}setServiceEndpoints(t){if(this._requireNotFrozen(),0==t.length)throw new Error("ServiceEndpoints list must not be empty.");if(t.length>8)throw new Error("ServiceEndpoints list must not contain more than 8 entries.");return this._serviceEndpoints=[...t],this}get serviceEndpoints(){return this._serviceEndpoints}addServiceEndpoint(t){return this._requireNotFrozen(),null!=this._serviceEndpoints&&this._serviceEndpoints.push(t),this}setGossipCaCertificate(t){if(this._requireNotFrozen(),0==t.length)throw new Error("GossipCaCertificate must not be empty.");return this._gossipCaCertificate=t,this}get gossipCaCertificate(){return this._gossipCaCertificate}setCertificateHash(t){return this._requireNotFrozen(),this._grpcCertificateHash=t,this}get certificateHash(){return this._grpcCertificateHash}setAdminKey(t){return this._requireNotFrozen(),this._adminKey=t,this}get adminKey(){return this._adminKey}setDeclineReward(t){return this._requireNotFrozen(),this._declineReward=t,this}get declineReward(){return this._declineReward}_execute(t,i){return t.addressBook.updateNode(i)}_getTransactionDataCase(){return"nodeUpdate"}_makeTransactionData(){return{accountId:null!=this._accountId?this._accountId._toProtobuf():null,description:{value:null!=this._description?this._description:null},gossipEndpoint:null!=this._gossipEndpoints?this._gossipEndpoints.map((t=>t._toProtobuf())):null,serviceEndpoint:null!=this._serviceEndpoints?this._serviceEndpoints.map((t=>t._toProtobuf())):null,gossipCaCertificate:null!=this._gossipCaCertificate?{value:this._gossipCaCertificate}:null,grpcCertificateHash:null!=this._grpcCertificateHash?{value:this._grpcCertificateHash}:null,adminKey:null!=this._adminKey?this._adminKey._toProtobufKey():null,nodeId:null!=this._nodeId?this._nodeId:null,declineReward:null!=this._declineReward?{value:this._declineReward}:null}}_getLogId(){return`NodeUpdateTransaction:${this._transactionIds.current.validStart.toString()}`}}n.set("nodeUpdate",r._fromProtobuf);export{r as default};
//# sourceMappingURL=NodeUpdateTransaction.js.map
