Skip to content
This repository was archived by the owner on Apr 18, 2023. It is now read-only.

Add ethers support #50

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
support for using ethers.js provider
mholtzman committed Dec 15, 2021
commit a82906ba06903b86384055bb1b586b1f734fa2c8
16 changes: 15 additions & 1 deletion src/helpers.js
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ export function isEmpty(obj) {
return !obj || Object.keys(obj).length === 0;
}

export async function ethCall(rawData, { id, web3, rpcUrl, block, multicallAddress, ws, wsResponseTimeout }) {
export async function ethCall(rawData, { id, web3, ethers, rpcUrl, block, chain, multicallAddress, ws, wsResponseTimeout }) {
const abiEncodedData = AGGREGATE_SELECTOR + strip0x(rawData);
if (ws) {
log('Sending via WebSocket');
@@ -92,6 +92,20 @@ export async function ethCall(rawData, { id, web3, rpcUrl, block, multicallAddre
ws.onmessage = onMessage;
});
}
else if (ethers) {
log('Sending via ethers provider');
return ethers.send({
method: 'eth_call',
chain,
params: [
{
to: multicallAddress,
data: abiEncodedData
},
block || 'latest'
]
})
}
else if (web3) {
log('Sending via web3 provider');
return web3.eth.call({