@hiero-ledger/sdk
Version:
3 lines (2 loc) • 3.08 kB
JavaScript
import t from"./ContractId.js";import o from"../account/AccountId.js";import n from"../StakingInfo.js";import e from"../Timestamp.js";import i from"../Duration.js";import a from"../Hbar.js";import s from"long";import*as r from"@hashgraph/proto";import c from"../account/TokenRelationshipMap.js";import u from"../Key.js";import l from"../LedgerId.js";const{proto:m}=r;class d{constructor(t){this.contractId=t.contractId,this.accountId=t.accountId,this.contractAccountId=t.contractAccountId,this.adminKey=null!=t.adminKey?t.adminKey:null,this.expirationTime=t.expirationTime,this.autoRenewPeriod=t.autoRenewPeriod,this.autoRenewAccountId=t.autoRenewAccountId,this.storage=t.storage,this.contractMemo=t.contractMemo,this.balance=t.balance,this.isDeleted=t.isDeleted,this.tokenRelationships=t.tokenRelationships,this.maxAutomaticTokenAssociations=t.maxAutomaticTokenAssociations,this.ledgerId=t.ledgerId,this.stakingInfo=t.stakingInfo,Object.freeze(this)}static _fromProtobuf(r){const m=r.autoRenewPeriod.seconds;return new d({contractId:t._fromProtobuf(r.contractID),accountId:o._fromProtobuf(r.accountID),contractAccountId:null!=r.contractAccountID?r.contractAccountID:"",adminKey:null!=r.adminKey?u._fromProtobufKey(r.adminKey):null,expirationTime:e._fromProtobuf(r.expirationTime),autoRenewPeriod:new i(m),autoRenewAccountId:null!=r.autoRenewAccountId?o._fromProtobuf(r.autoRenewAccountId):null,storage:null!=r.storage?r.storage instanceof s?r.storage:s.fromValue(r.storage):s.ZERO,contractMemo:null!=r.memo?r.memo:"",balance:a.fromTinybars(null!=r.balance?r.balance:0),isDeleted:r.deleted,tokenRelationships:c._fromProtobuf(null!=r.tokenRelationships?r.tokenRelationships:[]),ledgerId:null!=r.ledgerId?l.fromBytes(r.ledgerId):null,stakingInfo:null!=r.stakingInfo?n._fromProtobuf(r.stakingInfo):null,maxAutomaticTokenAssociations:null!=r.maxAutomaticTokenAssociations?s.isLong(r.maxAutomaticTokenAssociations)?r.maxAutomaticTokenAssociations:s.fromValue(r.maxAutomaticTokenAssociations):s.ZERO})}_toProtobuf(){return{contractID:this.contractId._toProtobuf(),accountID:this.accountId._toProtobuf(),contractAccountID:this.contractAccountId,adminKey:null!=this.adminKey?this.adminKey._toProtobufKey():null,expirationTime:this.expirationTime._toProtobuf(),autoRenewPeriod:null!=this.autoRenewPeriod?this.autoRenewPeriod._toProtobuf():null,autoRenewAccountId:null!=this.autoRenewAccountId?this.autoRenewAccountId._toProtobuf():null,storage:this.storage,memo:this.contractMemo,balance:this.balance.toTinybars(),deleted:this.isDeleted,tokenRelationships:null!=this.tokenRelationships?this.tokenRelationships._toProtobuf():null,ledgerId:null!=this.ledgerId?this.ledgerId.toBytes():null,stakingInfo:null!=this.stakingInfo?this.stakingInfo._toProtobuf():null,maxAutomaticTokenAssociations:this.maxAutomaticTokenAssociations.toNumber()}}static fromBytes(t){return d._fromProtobuf(m.ContractGetInfoResponse.ContractInfo.decode(t))}toBytes(){return m.ContractGetInfoResponse.ContractInfo.encode(this._toProtobuf()).finish()}}export{d as default};
//# sourceMappingURL=ContractInfo.js.map