UNPKG

@hiero-ledger/sdk

Version:
3 lines (2 loc) 4.54 kB
import e from"../account/AccountId.js";import t from"../token/CustomFixedFee.js";import o,{TRANSACTION_REGISTRY as s,DEFAULT_AUTO_RENEW_PERIOD as u}from"../transaction/Transaction.js";import i from"../Duration.js";import n from"../Key.js";import r from"../Hbar.js";class c extends o{constructor(e={}){super(),this._defaultMaxTransactionFee=new r(25),this._adminKey=null,this._submitKey=null,this._feeScheduleKey=null,this._feeExemptKeys=[],this._autoRenewAccountId=null,this._autoRenewPeriod=new i(u),this._customFees=[],this._topicMemo=null,null!=e.adminKey&&this.setAdminKey(e.adminKey),null!=e.submitKey&&this.setSubmitKey(e.submitKey),null!=e.feeScheduleKey&&this.setFeeScheduleKey(e.feeScheduleKey),null!=e.feeExemptKeys&&this.setFeeExemptKeys(e.feeExemptKeys),null!=e.autoRenewAccountId&&this.setAutoRenewAccountId(e.autoRenewAccountId),null!=e.autoRenewPeriod&&this.setAutoRenewPeriod(e.autoRenewPeriod),null!=e.customFees&&this.setCustomFees(e.customFees),null!=e.topicMemo&&this.setTopicMemo(e.topicMemo)}static _fromProtobuf(s,u,i,r,m){const h=m[0].consensusCreateTopic;return o._fromProtobufTransactions(new c({adminKey:null!=h.adminKey?n._fromProtobufKey(h.adminKey):void 0,submitKey:null!=h.submitKey?n._fromProtobufKey(h.submitKey):void 0,feeScheduleKey:null!=h.feeScheduleKey?n._fromProtobufKey(h.feeScheduleKey):void 0,feeExemptKeys:null!=h.feeExemptKeyList?h.feeExemptKeyList.map((e=>n._fromProtobufKey(e))):void 0,autoRenewAccountId:null!=h.autoRenewAccount?e._fromProtobuf(h.autoRenewAccount):void 0,autoRenewPeriod:null!=h.autoRenewPeriod&&null!=h.autoRenewPeriod.seconds?h.autoRenewPeriod.seconds:void 0,customFees:null!=h.customFees?h.customFees.map((e=>t._fromProtobuf(e))):void 0,topicMemo:null!=h.memo?h.memo:void 0}),s,u,i,r,m)}get topicMemo(){return this._topicMemo}getTopicMemo(){return this._topicMemo}setTopicMemo(e){return this._requireNotFrozen(),this._topicMemo=e,this}get adminKey(){return this._adminKey}getAdminKey(){return this._adminKey}setAdminKey(e){return this._requireNotFrozen(),this._adminKey=e,this}get submitKey(){return this._submitKey}getSubmitKey(){return this._submitKey}setSubmitKey(e){return this._requireNotFrozen(),this._submitKey=e,this}getFeeScheduleKey(){return this._feeScheduleKey}setFeeScheduleKey(e){return this._requireNotFrozen(),this._feeScheduleKey=e,this}getFeeExemptKeys(){return this._feeExemptKeys}setFeeExemptKeys(e){return this._requireNotFrozen(),this._feeExemptKeys=e,this}addFeeExemptKey(e){return this._requireNotFrozen(),this._feeExemptKeys.push(e),this}clearFeeExemptKeys(){return this._requireNotFrozen(),this._feeExemptKeys=[],this}get autoRenewAccountId(){return this._autoRenewAccountId}getAutoRenewAccountId(){return this._autoRenewAccountId}setAutoRenewAccountId(t){return this._requireNotFrozen(),this._autoRenewAccountId=t instanceof e?t:e.fromString(t),this}get autoRenewPeriod(){return this._autoRenewPeriod}getAutoRenewPeriod(){return this._autoRenewPeriod}setAutoRenewPeriod(e){return this._requireNotFrozen(),this._autoRenewPeriod=e instanceof i?e:new i(e),this}getCustomFees(){return this._customFees}setCustomFees(e){return this._requireNotFrozen(),this._customFees=e,this}addCustomFee(e){return this._requireNotFrozen(),this._customFees.push(e),this}clearCustomFees(){return this._requireNotFrozen(),this._customFees=[],this}_validateChecksums(e){null!=this._autoRenewAccountId&&this._autoRenewAccountId.validateChecksum(e)}freezeWith(e){return!this._autoRenewAccountId&&this.transactionId?.accountId?this.setAutoRenewAccountId(this.transactionId?.accountId):!this._autoRenewAccountId&&e?.operatorAccountId&&this.setAutoRenewAccountId(e.operatorAccountId),super.freezeWith(e)}_execute(e,t){return e.consensus.createTopic(t)}_getTransactionDataCase(){return"consensusCreateTopic"}_makeTransactionData(){return{adminKey:null!=this._adminKey?this._adminKey._toProtobufKey():null,submitKey:null!=this._submitKey?this._submitKey._toProtobufKey():null,feeScheduleKey:null!=this._feeScheduleKey?this._feeScheduleKey._toProtobufKey():null,feeExemptKeyList:this._feeExemptKeys.map((e=>e._toProtobufKey())),autoRenewAccount:null!=this._autoRenewAccountId?this._autoRenewAccountId._toProtobuf():null,autoRenewPeriod:this._autoRenewPeriod._toProtobuf(),customFees:this._customFees.map((e=>e._toTopicFeeProtobuf())),memo:this._topicMemo}}_getLogId(){return`TopicCreateTransaction:${this._transactionIds.current.validStart.toString()}`}}s.set("consensusCreateTopic",c._fromProtobuf);export{c as default}; //# sourceMappingURL=TopicCreateTransaction.js.map