@hiero-ledger/sdk
Version:
3 lines (2 loc) • 6.37 kB
JavaScript
import t from"../account/AccountId.js";import e from"./ContractId.js";import o from"../file/FileId.js";import n,{TRANSACTION_REGISTRY as i}from"../transaction/Transaction.js";import r from"../Duration.js";import a from"../Timestamp.js";import c from"../Key.js";import s from"long";import*as u from"@hiero-ledger/proto";class d extends n{constructor(t={}){super(),this._contractId=null,this._expirationTime=null,this._adminKey=null,this._proxyAccountId=null,this._autoRenewPeriod=null,this._bytecodeFileId=null,this._contractMemo=null,this._maxAutomaticTokenAssociations=null,this._stakedAccountId=null,this._stakedNodeId=null,this._declineStakingReward=null,this._autoRenewAccountId=null,null!=t.contractId&&this.setContractId(t.contractId),null!=t.expirationTime&&this.setExpirationTime(t.expirationTime),null!=t.adminKey&&this.setAdminKey(t.adminKey),null!=t.proxyAccountId&&this.setProxyAccountId(t.proxyAccountId),null!=t.autoRenewPeriod&&this.setAutoRenewPeriod(t.autoRenewPeriod),null!=t.bytecodeFileId&&this.setBytecodeFileId(t.bytecodeFileId),null!=t.contractMemo&&this.setContractMemo(t.contractMemo),null!=t.maxAutomaticTokenAssociations&&this.setMaxAutomaticTokenAssociations(t.maxAutomaticTokenAssociations),null!=t.stakedAccountId&&this.setStakedAccountId(t.stakedAccountId),null!=t.stakedNodeId&&this.setStakedNodeId(t.stakedNodeId),null!=t.declineStakingReward&&this.setDeclineStakingReward(t.declineStakingReward),null!=t.autoRenewAccountId&&this.setAutoRenewAccountId(t.autoRenewAccountId)}static _fromProtobuf(i,r,s,u,l){const m=l[0].contractUpdateInstance;let h,I,_;return null!=m.autoRenewPeriod&&null!=m.autoRenewPeriod.seconds&&(h=m.autoRenewPeriod.seconds),null!=m.memoWrapper&&Object.hasOwn(m.memoWrapper,"value")&&null!=m.memoWrapper.value&&(I=m.memoWrapper.value),null!=m.maxAutomaticTokenAssociations&&null!=m.maxAutomaticTokenAssociations.value&&(_=m.maxAutomaticTokenAssociations.value),n._fromProtobufTransactions(new d({contractId:null!=m.contractID?e._fromProtobuf(m.contractID):void 0,bytecodeFileId:null!=m.fileID?o._fromProtobuf(m.fileID):void 0,expirationTime:null!=m.expirationTime?a._fromProtobuf(m.expirationTime):void 0,adminKey:null!=m.adminKey?c._fromProtobufKey(m.adminKey):void 0,proxyAccountId:null!=m.proxyAccountID?t._fromProtobuf(m.proxyAccountID):void 0,autoRenewPeriod:h,contractMemo:I,maxAutomaticTokenAssociations:_,stakedAccountId:null!=m.stakedAccountId?t._fromProtobuf(m.stakedAccountId):void 0,stakedNodeId:null!=m.stakedNodeId?m.stakedNodeId:void 0,declineStakingReward:null!=m.declineReward&&1==Boolean(m.declineReward),autoRenewAccountId:null!=m.autoRenewAccountId?t._fromProtobuf(m.autoRenewAccountId):void 0}),i,r,s,u,l)}get contractId(){return this._contractId}setContractId(t){return this._requireNotFrozen(),this._contractId="string"==typeof t?e.fromString(t):t.clone(),this}get expirationTime(){return this._expirationTime}setExpirationTime(t){return this._requireNotFrozen(),this._expirationTime=t instanceof a?t:a.fromDate(t),this}get adminKey(){return this._adminKey}setAdminKey(t){return this._requireNotFrozen(),this._adminKey=t,this}get proxyAccountId(){return this._proxyAccountId}setProxyAccountId(e){return this._requireNotFrozen(),this._proxyAccountId="string"==typeof e?t.fromString(e):e.clone(),this}get autoRenewPeriod(){return this._autoRenewPeriod}setAutoRenewPeriod(t){return this._requireNotFrozen(),this._autoRenewPeriod=t instanceof r?t:new r(t),this}get bytecodeFileId(){return this._bytecodeFileId}setBytecodeFileId(t){return console.warn("Deprecated: there is no replacement"),this._requireNotFrozen(),this._bytecodeFileId="string"==typeof t?o.fromString(t):t.clone(),this}get contractMemo(){return this._contractMemo}setContractMemo(t){return this._requireNotFrozen(),this._contractMemo=t,this}clearContractMemo(){return this._requireNotFrozen(),this._contractMemo=null,this}get maxAutomaticTokenAssociations(){return this._maxAutomaticTokenAssociations}setMaxAutomaticTokenAssociations(t){return this._requireNotFrozen(),this._maxAutomaticTokenAssociations=t,this}get stakedAccountId(){return this._stakedAccountId}setStakedAccountId(e){return this._requireNotFrozen(),this._stakedAccountId="string"==typeof e?t.fromString(e):e,this}get stakedNodeId(){return this._stakedNodeId}setStakedNodeId(t){return this._requireNotFrozen(),this._stakedNodeId=s.fromValue(t),this}get declineStakingRewards(){return this._declineStakingReward}setDeclineStakingReward(t){return this._requireNotFrozen(),this._declineStakingReward=t,this}get autoRenewAccountId(){return this._autoRenewAccountId}setAutoRenewAccountId(e){return this._requireNotFrozen(),this._autoRenewAccountId="string"==typeof e?t.fromString(e):e,this}clearAutoRenewAccountId(){return this._autoRenewAccountId=new t(0),this}_validateChecksums(t){null!=this._contractId&&this._contractId.validateChecksum(t),null!=this._bytecodeFileId&&this._bytecodeFileId.validateChecksum(t),null!=this._proxyAccountId&&this._proxyAccountId.validateChecksum(t)}_execute(t,e){return t.smartContract.updateContract(e)}_getTransactionDataCase(){return"contractUpdateInstance"}_makeTransactionData(){return{contractID:null!=this._contractId?this._contractId._toProtobuf():null,expirationTime:null!=this._expirationTime?this._expirationTime._toProtobuf():null,adminKey:null!=this._adminKey?this._adminKey._toProtobufKey():null,proxyAccountID:null!=this._proxyAccountId?this._proxyAccountId._toProtobuf():null,autoRenewPeriod:null!=this._autoRenewPeriod?this._autoRenewPeriod._toProtobuf():null,fileID:this._bytecodeFileId?this._bytecodeFileId._toProtobuf():null,memoWrapper:null!=this._contractMemo?{value:this._contractMemo}:null,maxAutomaticTokenAssociations:null!=this._maxAutomaticTokenAssociations?{value:this._maxAutomaticTokenAssociations}:null,stakedAccountId:null!=this.stakedAccountId?this.stakedAccountId._toProtobuf():null,stakedNodeId:this.stakedNodeId,declineReward:null!=this.declineStakingRewards?{value:this.declineStakingRewards}:null,autoRenewAccountId:null!=this._autoRenewAccountId?"0.0.0"==this._autoRenewAccountId.toString()?u.proto.AccountID.create():this._autoRenewAccountId._toProtobuf():null}}_getLogId(){return`ContractUpdateTransaction:${this._transactionIds.current.validStart.toString()}`}}i.set("contractUpdateInstance",d._fromProtobuf);export{d as default};
//# sourceMappingURL=ContractUpdateTransaction.js.map