UNPKG

@hiero-ledger/sdk

Version:
3 lines (2 loc) 2.28 kB
import t from"../Hbar.js";import n,{TRANSACTION_REGISTRY as r}from"../transaction/Transaction.js";import a from"./ContractId.js";import o from"./ContractFunctionParameters.js";import s from"long";import e from"../HbarUnit.js";class i extends n{constructor(t={}){super(),this._contractId=null,this._gas=null,this._amount=null,this._functionParameters=null,null!=t.contractId&&this.setContractId(t.contractId),null!=t.gas&&this.setGas(t.gas),null!=t.amount&&this.setPayableAmount(t.amount),null!=t.functionParameters?this.setFunctionParameters(t.functionParameters):null!=t.function&&this.setFunction(t.function.name,t.function.parameters)}static _fromProtobuf(r,o,s,e,u){const c=u[0].contractCall;return n._fromProtobufTransactions(new i({contractId:null!=c.contractID?a._fromProtobuf(c.contractID):void 0,gas:null!=c.gas?c.gas:void 0,amount:null!=c.amount?t.fromTinybars(c.amount):void 0,functionParameters:null!=c.functionParameters?c.functionParameters:void 0}),r,o,s,e,u)}get contractId(){return this._contractId}setContractId(t){return this._requireNotFrozen(),this._contractId="string"==typeof t?a.fromString(t):t.clone(),this}get gas(){return this._gas}setGas(t){return this._requireNotFrozen(),this._gas=t instanceof s?t:s.fromValue(t),this}get payableAmount(){return this._amount}setPayableAmount(n,r=e.Hbar){return this._requireNotFrozen(),this._amount=n instanceof t?n:t.from(n,r),this}get functionParameters(){return this._functionParameters}setFunctionParameters(t){return this._requireNotFrozen(),this._functionParameters=t,this}setFunction(t,n){return this._requireNotFrozen(),this._functionParameters=null!=n?n._build(t):(new o)._build(t),this}_validateChecksums(t){null!=this._contractId&&this._contractId.validateChecksum(t)}_execute(t,n){return t.smartContract.contractCallMethod(n)}_getTransactionDataCase(){return"contractCall"}_makeTransactionData(){return{contractID:null!=this._contractId?this._contractId._toProtobuf():null,gas:this._gas,amount:null!=this._amount?this._amount.toTinybars():null,functionParameters:this._functionParameters}}_getLogId(){return`ContractExecuteTransaction:${this._transactionIds.current.validStart.toString()}`}}r.set("contractCall",i._fromProtobuf);export{i as default}; //# sourceMappingURL=ContractExecuteTransaction.js.map