UNPKG

@hiero-ledger/sdk

Version:
3 lines (2 loc) 2.06 kB
import t from"../contract/ContractFunctionParameters.js";class e{constructor(){this._contractId=null,this._contractEvmAddress=null,this._sender=null,this._senderEvmAddress=null,this._functionName=null,this._functionParameters=null,this._value=null,this._gasLimit=null,this._gasPrice=null,this._blockNumber=null}setContractId(t){return this._contractId=t,this}setSender(t){return this._sender=t,this}setSenderEvmAddress(t){return this._senderEvmAddress=t,this}setFunction(e,r){return this._functionParameters=null!=r?r._build(e):(new t)._build(e),this}setValue(t){return this._value=t,this}setGasLimit(t){return this._gasLimit=t,this}setGasPrice(t){return this._gasPrice=t,this}setBlockNumber(t){return this._blockNumber=t,this}get contractId(){return this._contractId}get contractEvmAddress(){const t=this._contractId?.toEvmAddress();if(null==t)throw new Error("Contract ID is not set");return t}get sender(){return this._sender}get senderEvmAddress(){return this._senderEvmAddress}get callData(){return this._functionParameters}get value(){return this._value}get gasLimit(){return this._gasLimit}get gasPrice(){return this._gasPrice}get blockNumber(){return this._blockNumber}async performMirrorNodeRequest(t,e){if(null==this.contractId)throw new Error("Contract ID is not set");this._fillEvmAddress();let r=t.mirrorNetwork[0];const s="/api/v1/contracts/call";if(!t.ledgerId||t.ledgerId?.isLocalNode())r="http://".concat(t.mirrorNetwork[0].replace("5600","8545")).concat(s);else{let e=t.mirrorNetwork[0].split(":");r="https://".concat(e[0]).concat(s)}const n=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return await n.json()}_fillEvmAddress(){null==this.senderEvmAddress&&null!=this.sender&&(this._senderEvmAddress=this.sender.toEvmAddress())}get JSONPayload(){throw new Error("JSONPayload getter is not implemented. Please implement this method in the subclass.")}}export{e as default}; //# sourceMappingURL=MirrorNodeContractQuery.js.map