@hashgraph/sdk
Version:
3 lines (2 loc) • 2.18 kB
JavaScript
import e from"../Hbar.js";import t,{TRANSACTION_REGISTRY as i,DEFAULT_AUTO_RENEW_PERIOD as o}from"../transaction/Transaction.js";import{encode as n}from"../encoding/utf8.js";import r from"../Timestamp.js";import s from"../Key.js";import a from"../KeyList.js";import m from"long";class l extends t{constructor(t={}){super(),this._keys=null,this._expirationTime=new r(0,0).plusNanos(m.fromNumber(Date.now()).mul(1e6).add(o.mul(1e9))),this._contents=null,this._fileMemo=null,this._defaultMaxTransactionFee=new e(5),null!=t.keys&&this.setKeys(t.keys),null!=t.expirationTime&&this.setExpirationTime(t.expirationTime),null!=t.contents&&this.setContents(t.contents),t.fileMemo&&null!=t.fileMemo&&this.setFileMemo(t.fileMemo)}static _fromProtobuf(e,i,o,n,a){const m=a[0].fileCreate;return t._fromProtobufTransactions(new l({keys:null!=m.keys&&null!=m.keys.keys?m.keys.keys.map((e=>s._fromProtobufKey(e))):void 0,expirationTime:null!=m.expirationTime?r._fromProtobuf(m.expirationTime):void 0,contents:null!=m.contents?m.contents:void 0,fileMemo:null!=m.memo?m.memo:void 0}),e,i,o,n,a)}get keys(){return this._keys}setKeys(e){if(this._requireNotFrozen(),e instanceof a&&null!=e.threshold)throw new Error("Cannot set threshold key as file key");return this._keys=e instanceof a?e.toArray():e,this}get expirationTime(){return this._expirationTime}setExpirationTime(e){return this._requireNotFrozen(),this._expirationTime=e instanceof r?e:r.fromDate(e),this}get contents(){return this._contents}setContents(e){return this._requireNotFrozen(),this._contents=e instanceof Uint8Array?e:n(e),this}get fileMemo(){return this._fileMemo}setFileMemo(e){return this._requireNotFrozen(),this._fileMemo=e,this}_execute(e,t){return e.file.createFile(t)}_getTransactionDataCase(){return"fileCreate"}_makeTransactionData(){return{keys:null!=this._keys?{keys:this._keys.map((e=>e._toProtobufKey()))}:null,expirationTime:this._expirationTime._toProtobuf(),contents:this._contents,memo:this._fileMemo}}_getLogId(){return`FileCreateTransaction:${this._transactionIds.current.validStart.toString()}`}}i.set("fileCreate",l._fromProtobuf);export{l as default};
//# sourceMappingURL=FileCreateTransaction.js.map