UNPKG

@hashgraph/sdk

Version:
3 lines (2 loc) 5.91 kB
import e,{TRANSACTION_REGISTRY as t}from"../transaction/Transaction.js";import o from"./AccountId.js";import i from"../Timestamp.js";import n from"../Duration.js";import r from"long";import u from"../Key.js";class s extends e{constructor(e={}){super(),this._accountId=null,this._key=null,this._receiverSignatureRequired=null,this._proxyAccountId=null,this._autoRenewPeriod=null,this._expirationTime=null,this._accountMemo=null,this._maxAutomaticTokenAssociations=null,this._aliasKey=null,this._stakedAccountId=null,this._stakedNodeId=null,this._declineStakingReward=null,null!=e.accountId&&this.setAccountId(e.accountId),null!=e.key&&this.setKey(e.key),null!=e.receiverSignatureRequired&&this.setReceiverSignatureRequired(e.receiverSignatureRequired),null!=e.proxyAccountId&&this.setProxyAccountId(e.proxyAccountId),null!=e.autoRenewPeriod&&this.setAutoRenewPeriod(e.autoRenewPeriod),null!=e.expirationTime&&this.setExpirationTime(e.expirationTime),null!=e.accountMemo&&this.setAccountMemo(e.accountMemo),null!=e.maxAutomaticTokenAssociations&&this.setMaxAutomaticTokenAssociations(e.maxAutomaticTokenAssociations),null!=e.stakedAccountId&&this.setStakedAccountId(e.stakedAccountId),null!=e.stakedNodeId&&this.setStakedNodeId(e.stakedNodeId),null!=e.declineStakingReward&&this.setDeclineStakingReward(e.declineStakingReward)}static _fromProtobuf(t,n,a,c,d){const l=d[0].cryptoUpdateAccount;return e._fromProtobufTransactions(new s({accountId:null!=l.accountIDToUpdate?o._fromProtobuf(l.accountIDToUpdate):void 0,key:null!=l.key?u._fromProtobufKey(l.key):void 0,receiverSignatureRequired:null!=l.receiverSigRequiredWrapper&&Object.hasOwn(l.receiverSigRequiredWrapper,"value")?l.receiverSigRequiredWrapper.value:void 0,proxyAccountId:null!=l.proxyAccountID?o._fromProtobuf(l.proxyAccountID):void 0,autoRenewPeriod:null!=l.autoRenewPeriod&&null!=l.autoRenewPeriod.seconds?l.autoRenewPeriod.seconds:void 0,expirationTime:null!=l.expirationTime?i._fromProtobuf(l.expirationTime):void 0,accountMemo:null!=l.memo&&Object.hasOwn(l.memo,"value")?l.memo.value:void 0,maxAutomaticTokenAssociations:null!=l.maxAutomaticTokenAssociations&&null!=l.maxAutomaticTokenAssociations.value&&Object.hasOwn(l.maxAutomaticTokenAssociations,"value")?r.fromNumber(l.maxAutomaticTokenAssociations.value):void 0,stakedAccountId:null!=l.stakedAccountId?o._fromProtobuf(l.stakedAccountId):void 0,stakedNodeId:null!=l.stakedNodeId?l.stakedNodeId:void 0,declineStakingReward:null!=l.declineReward&&Object.hasOwn(l.declineReward,"value")?l.declineReward.value:void 0}),t,n,a,c,d)}get accountId(){return this._accountId}setAccountId(e){return this._requireNotFrozen(),this._accountId="string"==typeof e?o.fromString(e):e.clone(),this}get key(){return this._key}setKey(e){return this._requireNotFrozen(),this._key=e,this}get receiverSignatureRequired(){return this._receiverSignatureRequired}setReceiverSignatureRequired(e){return this._requireNotFrozen(),this._receiverSignatureRequired=e,this}get proxyAccountId(){return this._proxyAccountId}setProxyAccountId(e){return this._requireNotFrozen(),this._proxyAccountId=e,this}get autoRenewPeriod(){return this._autoRenewPeriod}setAutoRenewPeriod(e){return this._requireNotFrozen(),this._autoRenewPeriod=e instanceof n?e:new n(e),this}get expirationTime(){return this._expirationTime}setExpirationTime(e){return this._requireNotFrozen(),this._expirationTime=e instanceof Date?i.fromDate(e):e,this}get accountMemo(){return this._accountMemo}setAccountMemo(e){return this._requireNotFrozen(),this._accountMemo=e,this}clearAccountMemo(){return this._requireNotFrozen(),this._accountMemo=null,this}get maxAutomaticTokenAssociations(){return this._maxAutomaticTokenAssociations}setMaxAutomaticTokenAssociations(e){return this._requireNotFrozen(),this._maxAutomaticTokenAssociations="number"==typeof e?r.fromNumber(e):e,this}get aliasKey(){return null}setAliasKey(e){return this}get stakedAccountId(){return this._stakedAccountId}setStakedAccountId(e){return this._requireNotFrozen(),this._stakedAccountId="string"==typeof e?o.fromString(e):e,this}clearStakedAccountId(){return this._requireNotFrozen(),this._stakedAccountId=new o(0,0,0),this}get stakedNodeId(){return this._stakedNodeId}setStakedNodeId(e){return this._requireNotFrozen(),this._stakedNodeId=r.fromValue(e),this}clearStakedNodeId(){return this._requireNotFrozen(),this._stakedNodeId=r.fromNumber(-1),this}get declineStakingRewards(){return this._declineStakingReward}setDeclineStakingReward(e){return this._requireNotFrozen(),this._declineStakingReward=e,this}_validateChecksums(e){null!=this._accountId&&this._accountId.validateChecksum(e),null!=this._proxyAccountId&&this._proxyAccountId.validateChecksum(e)}_execute(e,t){return e.crypto.updateAccount(t)}_getTransactionDataCase(){return"cryptoUpdateAccount"}_makeTransactionData(){return{accountIDToUpdate:null!=this._accountId?this._accountId._toProtobuf():null,key:null!=this._key?this._key._toProtobufKey():null,expirationTime:null!=this._expirationTime?this._expirationTime._toProtobuf():null,proxyAccountID:null!=this._proxyAccountId?this._proxyAccountId._toProtobuf():null,autoRenewPeriod:null!=this._autoRenewPeriod?this._autoRenewPeriod._toProtobuf():null,receiverSigRequiredWrapper:null==this._receiverSignatureRequired?null:{value:this._receiverSignatureRequired},memo:null!=this._accountMemo?{value:this._accountMemo}:null,maxAutomaticTokenAssociations:null!=this._maxAutomaticTokenAssociations?{value:this._maxAutomaticTokenAssociations.toInt()}:null,stakedAccountId:null!=this.stakedAccountId?this.stakedAccountId._toProtobuf():null,stakedNodeId:this.stakedNodeId,declineReward:null!=this.declineStakingRewards?{value:this.declineStakingRewards}:null}}_getLogId(){return`AccountUpdateTransaction:${this._transactionIds.current.validStart.toString()}`}}t.set("cryptoUpdateAccount",s._fromProtobuf);export{s as default}; //# sourceMappingURL=AccountUpdateTransaction.js.map