UNPKG

@hiero-ledger/sdk

Version:
3 lines (2 loc) 5.44 kB
import t from"../account/AccountId.js";import e from"../Key.js";import i,{TRANSACTION_REGISTRY as n}from"../transaction/Transaction.js";import r from"./ServiceEndpoint.js";import o from"long";class s extends i{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._grpcWebProxyEndpoint=t?.grpcWebProxyEndpoint||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 i._fromProtobufTransactions(new s({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=>r._fromProtobuf(t)):void 0,serviceEndpoints:null!=u.serviceEndpoint?u.serviceEndpoint.map(t=>r._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,grpcWebProxyEndpoint:null!=u.grpcProxyEndpoint?r._fromProtobuf(u.grpcProxyEndpoint):void 0,adminKey:null!=u.adminKey?e._fromProtobufKey(u.adminKey):void 0,declineReward:null!=u.declineReward?.value?u.declineReward.value:void 0}),n,o,d,a,c)}setNodeId(t){if(this._requireNotFrozen(),null==t)return this._nodeId=null,this;const e=o.isLong(t)?t:o.fromValue(t);if(e.toNumber()<0)throw new Error("NodeUpdateTransaction: 'nodeId' must be positive.");return this._nodeId=e,this}get nodeId(){return this._nodeId}setAccountId(e){return this._requireNotFrozen(),this._accountId=e instanceof t?e:t.fromString(e),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}setGrpcWebProxyEndpoint(t){return this._requireNotFrozen(),this._grpcWebProxyEndpoint=t,this}get grpcWebProxyEndpoint(){return this._grpcWebProxyEndpoint}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}deleteGrpcWebProxyEndpoint(){return this._grpcWebProxyEndpoint=new r,this}freezeWith(t){if(null==this.nodeId)throw new Error("NodeUpdateTransaction: 'nodeId' must be explicitly set before calling freeze().");return super.freezeWith(t)}_execute(t,e){return t.addressBook.updateNode(e)}_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,grpcProxyEndpoint:null!=this._grpcWebProxyEndpoint?this._grpcWebProxyEndpoint._toProtobuf():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",s._fromProtobuf);export{s as default}; //# sourceMappingURL=NodeUpdateTransaction.js.map