UNPKG

@hashgraph/sdk

Version:
3 lines (2 loc) 2.02 kB
import t from"../contract/ContractFunctionParameters.js";class r{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(r,e){return this._functionParameters=null!=e?e._build(r):(new t)._build(r),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,r){if(null==this.contractId)throw new Error("Contract ID is not set");this._fillEvmAddress();let e=t.mirrorRestApiBaseUrl;const s=t._mirrorNetwork.getNextMirrorNode().address.address;if("localhost"===s||"127.0.0.1"===s){const t=new URL(e);t.protocol="http:",t.port="8545",e=t.toString()}const n=`${e}/contracts/call`,i=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return await i.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{r as default}; //# sourceMappingURL=MirrorNodeContractQuery.js.map