refactored watcher; produces logs
This commit is contained in:
30
abi.js
30
abi.js
@@ -1,3 +1,9 @@
|
||||
import {readFile} from './misc.js'
|
||||
import {ethers} from "ethers";
|
||||
|
||||
const ABI_BASE_PATH = '../contract/out'
|
||||
|
||||
|
||||
export const erc20Abi = [
|
||||
'function name() view returns (string)',
|
||||
'function symbol() view returns (string)',
|
||||
@@ -26,6 +32,7 @@ const TimedOrderSpec = '(' +
|
||||
'bool amountIsInput' +
|
||||
')'
|
||||
|
||||
|
||||
export const timedOrderAbi = [
|
||||
'event TimedOrderCreated (address owner, uint64 index, Spec spec)',
|
||||
'event TimedOrderFilled (address owner, uint64 index, uint256 amountIn, uint256 amountOut)',
|
||||
@@ -35,8 +42,31 @@ export const timedOrderAbi = [
|
||||
]
|
||||
|
||||
|
||||
const vaultDeployerAbi = [
|
||||
'function deployVault(address owner) returns (address vault)',
|
||||
'event VaultCreated( address deployer, address owner )',
|
||||
]
|
||||
|
||||
|
||||
export const abi = {
|
||||
'ERC20': erc20Abi,
|
||||
'TimedOrder': timedOrderAbi,
|
||||
'VaultDeployer': vaultDeployerAbi,
|
||||
}
|
||||
|
||||
|
||||
export async function getAbi(className) {
|
||||
let found = abi[className]
|
||||
if (found === undefined) {
|
||||
console.log('warning: loading ABI from filesystem for '+className)
|
||||
const data = await readFile(ABI_BASE_PATH + `/${className}.sol/${className}.json`)
|
||||
found = JSON.parse(data.toString())['abi']
|
||||
abi[className] = found
|
||||
}
|
||||
return found
|
||||
}
|
||||
|
||||
|
||||
export async function getInterface(className) {
|
||||
return new ethers.Interface(await getAbi(className))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user