@hashgraph/sdk
Version:
3 lines (2 loc) • 4.5 kB
JavaScript
import t from"../account/AccountId.js";import e from"../contract/ContractId.js";import n from"../file/FileId.js";import o from"../topic/TopicId.js";import i from"../token/TokenId.js";import l from"../schedule/ScheduleId.js";import u from"../ExchangeRate.js";import c from"../Status.js";import s from"long";import*as r from"@hashgraph/proto";import a from"./TransactionId.js";import{encode as h}from"../encoding/hex.js";class d{constructor(t){this.status=t.status,this.accountId=t.accountId,this.fileId=t.fileId,this.contractId=t.contractId,this.topicId=t.topicId,this.tokenId=t.tokenId,this.scheduleId=t.scheduleId,this.exchangeRate=t.exchangeRate,this.nextExchangeRate=t.nextExchangeRate,this.topicSequenceNumber=t.topicSequenceNumber,this.topicRunningHash=t.topicRunningHash,this.totalSupply=t.totalSupply,this.scheduledTransactionId=t.scheduledTransactionId,this.serials=t.serials??[],this.duplicates=t.duplicates??[],this.children=t.children??[],this.nodeId=t.nodeId,Object.freeze(this)}_toProtobuf(){return{duplicateTransactionReceipts:this.duplicates.map(t=>t._toProtobuf().receipt),childTransactionReceipts:this.children.map(t=>t._toProtobuf().receipt),receipt:{status:this.status.valueOf(),accountID:null!=this.accountId?this.accountId._toProtobuf():null,fileID:null!=this.fileId?this.fileId._toProtobuf():null,contractID:null!=this.contractId?this.contractId._toProtobuf():null,topicID:null!=this.topicId?this.topicId._toProtobuf():null,tokenID:null!=this.tokenId?this.tokenId._toProtobuf():null,scheduleID:null!=this.scheduleId?this.scheduleId._toProtobuf():null,topicRunningHash:null==this.topicRunningHash?null:this.topicRunningHash,topicSequenceNumber:this.topicSequenceNumber,exchangeRate:{nextRate:null!=this.nextExchangeRate?this.nextExchangeRate._toProtobuf():null,currentRate:null!=this.exchangeRate?this.exchangeRate._toProtobuf():null},scheduledTransactionID:null!=this.scheduledTransactionId?this.scheduledTransactionId._toProtobuf():null,serialNumbers:this.serials,newTotalSupply:this.totalSupply,nodeId:this.nodeId}}}static _fromProtobuf(r){const h=r.receipt,p=null!=r.childTransactionReceipts?r.childTransactionReceipts.map(t=>d._fromProtobuf({receipt:t})):[],I=null!=r.duplicateTransactionReceipts?r.duplicateTransactionReceipts.map(t=>d._fromProtobuf({receipt:t})):[];return new d({status:c._fromCode(null!=h.status?h.status:0),accountId:null!=h.accountID?t._fromProtobuf(h.accountID):null,fileId:null!=h.fileID?n._fromProtobuf(h.fileID):null,contractId:null!=h.contractID?e._fromProtobuf(h.contractID):null,topicId:null!=h.topicID?o._fromProtobuf(h.topicID):null,tokenId:null!=h.tokenID?i._fromProtobuf(h.tokenID):null,scheduleId:null!=h.scheduleID?l._fromProtobuf(h.scheduleID):null,exchangeRate:null!=h.exchangeRate?u._fromProtobuf(h.exchangeRate.currentRate):null,nextExchangeRate:null!=h.exchangeRate?u._fromProtobuf(h.exchangeRate.nextRate):null,topicSequenceNumber:null==h.topicSequenceNumber?null:s.fromString(h.topicSequenceNumber.toString()),topicRunningHash:null!=h.topicRunningHash?new Uint8Array(h.topicRunningHash):null,totalSupply:null!=h.newTotalSupply?s.fromString(h.newTotalSupply.toString()):null,scheduledTransactionId:null!=h.scheduledTransactionID?a._fromProtobuf(h.scheduledTransactionID):null,serials:null!=h.serialNumbers?h.serialNumbers.map(t=>s.fromValue(t)):[],children:p,duplicates:I,nodeId:null!=h.nodeId?h.nodeId:null})}static fromBytes(t){return d._fromProtobuf(r.proto.TransactionGetReceiptResponse.decode(t))}toBytes(){return r.proto.TransactionGetReceiptResponse.encode(this._toProtobuf()).finish()}toJSON(){return{status:this.status.toString(),accountId:this.accountId?.toString()||null,filedId:this.fileId?.toString()||null,contractId:this.contractId?.toString()||null,topicId:this.topicId?.toString()||null,tokenId:this.tokenId?.toString()||null,scheduleId:this.scheduleId?.toString()||null,exchangeRate:this.exchangeRate?.toJSON()||null,nextExchangeRate:this.nextExchangeRate?.toJSON()||null,topicSequenceNumber:this.topicSequenceNumber?.toString()||null,topicRunningHash:null!=this.topicRunningHash?h(this.topicRunningHash):null,totalSupply:this.totalSupply?.toString()||null,scheduledTransactionId:this.scheduledTransactionId?.toString()||null,serials:this.serials.map(t=>t.toString()),duplicates:this.duplicates.map(t=>t.toJSON()),children:this.children.map(t=>t.toJSON()),nodeId:this.nodeId?.toString()||null}}toString(){return JSON.stringify(this.toJSON())}}export{d as default};
//# sourceMappingURL=TransactionReceipt.js.map