@hashgraph/sdk
Version:
3 lines (2 loc) • 4.52 kB
JavaScript
import t from"../account/AccountId.js";import i from"../Key.js";import e,{TRANSACTION_REGISTRY as n}from"../transaction/Transaction.js";import r from"./ServiceEndpoint.js";class s extends e{constructor(t){super(),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,c,a,d){const p=d[0].nodeCreate;return e._fromProtobufTransactions(new s({accountId:null!=p.accountId?t._fromProtobuf(p.accountId):void 0,description:null!=p.description?p.description:void 0,gossipEndpoints:null!=p.gossipEndpoint?p.gossipEndpoint.map((t=>r._fromProtobuf(t))):void 0,serviceEndpoints:null!=p.serviceEndpoint?p.serviceEndpoint.map((t=>r._fromProtobuf(t))):void 0,gossipCaCertificate:null!=p.gossipCaCertificate?p.gossipCaCertificate:void 0,grpcCertificateHash:null!=p.grpcCertificateHash?p.grpcCertificateHash:void 0,adminKey:null!=p.adminKey?i._fromProtobufKey(p.adminKey):void 0,declineReward:null!=p.declineReward?p.declineReward:void 0,grpcWebProxyEndpoint:null!=p.grpcProxyEndpoint?r._fromProtobuf(p.grpcProxyEndpoint):void 0}),n,o,c,a,d)}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}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 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 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}_execute(t,i){return t.addressBook.createNode(i)}_getTransactionDataCase(){return"nodeCreate"}_makeTransactionData(){return{accountId:null!=this._accountId?this._accountId._toProtobuf():null,description: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?this._gossipCaCertificate:null,grpcCertificateHash:null!=this._grpcCertificateHash?this._grpcCertificateHash:null,adminKey:null!=this._adminKey?this._adminKey._toProtobufKey():null,declineReward:null!=this._declineReward?this._declineReward:null,grpcProxyEndpoint:null!=this._grpcWebProxyEndpoint?this._grpcWebProxyEndpoint._toProtobuf():null}}_getLogId(){return`NodeCreateTransaction:${this._transactionIds.current.validStart.toString()}`}}n.set("nodeCreate",s._fromProtobuf);export{s as default};
//# sourceMappingURL=NodeCreateTransaction.js.map