UNPKG

@moonsong-labs/moonwall-util

Version:

Testing framework for the Moon family of projects

50 lines (47 loc) 1.24 kB
import { alith } from "./chunk-EG7W3V7T.js"; import { MIN_GAS_PRICE } from "./chunk-T4WI4Q5B.js"; // src/functions/providers.ts import "@moonbeam-network/api-augment"; async function customWeb3Request(web3, method, params) { return new Promise((resolve, reject) => { web3.currentProvider.send( { jsonrpc: "2.0", id: 1, method, params }, (error, result) => { if (error) { reject( `Failed to send custom request (${method} (${params.map((p) => { const str = p.toString(); return str.length > 128 ? `${str.slice(0, 96)}...${str.slice(-28)}` : str; }).join(",")})): ${error.message || error.toString()}` ); } resolve(result); } ); }); } async function web3EthCall(web3, options) { return await customWeb3Request(web3, "eth_call", [ { from: options.from == void 0 ? options.from : alith.address, value: options.value, gas: options.gas == void 0 ? options.gas : 256e3, gasPrice: options.gas == void 0 ? options.gas : `0x${MIN_GAS_PRICE}`, to: options.to, data: options.data } ]); } export { customWeb3Request, web3EthCall };