UNPKG

@hiero-ledger/sdk

Version:
3 lines (2 loc) 2.58 kB
import e,{TRANSACTION_REGISTRY as t}from"../transaction/Transaction.js";import i from"../Timestamp.js";import{encode as o}from"../encoding/utf8.js";import n from"./FileId.js";import s from"../Key.js";import r from"../KeyList.js";class l extends e{constructor(e={}){super(),this._fileId=null,this._keys=null,this._expirationTime=null,this._contents=null,this._fileMemo=null,null!=e.fileId&&this.setFileId(e.fileId),null!=e.keys&&this.setKeys(e.keys),null!=e.expirationTime&&this.setExpirationTime(e.expirationTime),null!=e.contents&&this.setContents(e.contents),e.fileMemo&&null!=e.fileMemo&&this.setFileMemo(e.fileMemo)}static _fromProtobuf(t,o,r,u,a){const m=a[0].fileUpdate;return e._fromProtobufTransactions(new l({fileId:null!=m.fileID?n._fromProtobuf(m.fileID):void 0,keys:null!=m.keys&&null!=m.keys.keys?m.keys.keys.map(e=>s._fromProtobufKey(e)):void 0,expirationTime:null!=m.expirationTime?i._fromProtobuf(m.expirationTime):void 0,contents:null!=m.contents?m.contents:void 0,fileMemo:null!=m.memo&&Object.hasOwn(m.memo,"value")?m.memo.value:void 0}),t,o,r,u,a)}get fileId(){return this._fileId}setFileId(e){return this._requireNotFrozen(),this._fileId="string"==typeof e?n.fromString(e):e.clone(),this}get keys(){return this._keys}setKeys(e){if(this._requireNotFrozen(),e instanceof r&&null!=e.threshold)throw new Error("Cannot set threshold key as file key");return this._keys=e instanceof r?e.toArray():e,this}get expirationTime(){return this._expirationTime}setExpirationTime(e){return this._requireNotFrozen(),this._expirationTime=e instanceof i?e:i.fromDate(e),this}get contents(){return this._contents}setContents(e){return this._requireNotFrozen(),this._contents=e instanceof Uint8Array?e:o(e),this}get fileMemo(){return this._fileMemo}setFileMemo(e){return this._requireNotFrozen(),this._fileMemo=e,this}clearFileMemo(){return this._requireNotFrozen(),this._fileMemo=null,this}_validateChecksums(e){null!=this._fileId&&this._fileId.validateChecksum(e)}_execute(e,t){return e.file.updateFile(t)}_getTransactionDataCase(){return"fileUpdate"}_makeTransactionData(){return{fileID:null!=this._fileId?this._fileId._toProtobuf():null,keys:null!=this._keys?{keys:this._keys.map(e=>e._toProtobufKey())}:null,expirationTime:null!=this._expirationTime?this._expirationTime._toProtobuf():null,contents:this._contents,memo:null!=this._fileMemo?{value:this._fileMemo}:null}}_getLogId(){return`FileUpdateTransaction:${this._transactionIds.current.validStart.toString()}`}}t.set("fileUpdate",l._fromProtobuf);export{l as default}; //# sourceMappingURL=FileUpdateTransaction.js.map