forked from cerc-io/ipld-eth-server
move interface_getter.go from ens_watcher to vDB pkging- used to construct a custom ABI based on results from calls to supportsInterface; also moved fetcher.go from examples to pkg
This commit is contained in:
parent
59cdaa05e6
commit
aa4e698240
@ -19,8 +19,8 @@ package every_block
|
|||||||
import (
|
import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/vulcanize/vulcanizedb/examples/generic"
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/omni/shared/fetcher"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Getter serves as a higher level data fetcher that invokes its underlying Fetcher methods for a given contract method
|
// Getter serves as a higher level data fetcher that invokes its underlying Fetcher methods for a given contract method
|
||||||
@ -35,13 +35,13 @@ type ERC20GetterInterface interface {
|
|||||||
|
|
||||||
// Getter struct
|
// Getter struct
|
||||||
type ERC20Getter struct {
|
type ERC20Getter struct {
|
||||||
generic.Fetcher
|
fetcher.Fetcher
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initializes and returns a Getter with the given blockchain
|
// Initializes and returns a Getter with the given blockchain
|
||||||
func NewGetter(blockChain core.BlockChain) ERC20Getter {
|
func NewGetter(blockChain core.BlockChain) ERC20Getter {
|
||||||
return ERC20Getter{
|
return ERC20Getter{
|
||||||
Fetcher: generic.Fetcher{
|
Fetcher: fetcher.Fetcher{
|
||||||
BlockChain: blockChain,
|
BlockChain: blockChain,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,12 @@
|
|||||||
package every_block
|
package every_block
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/vulcanize/vulcanizedb/examples/generic"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/omni/shared/fetcher"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Getter serves as a higher level data fetcher that invokes its underlying Fetcher methods for a given contract method
|
// Getter serves as a higher level data fetcher that invokes its underlying Fetcher methods for a given contract method
|
||||||
@ -41,13 +41,13 @@ type GenericGetterInterface interface {
|
|||||||
|
|
||||||
// Getter struct
|
// Getter struct
|
||||||
type GenericGetter struct {
|
type GenericGetter struct {
|
||||||
generic.Fetcher // Underlying Fetcher
|
fetcher.Fetcher // Underlying Fetcher
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initializes and returns a Getter with the given blockchain
|
// Initializes and returns a Getter with the given blockchain
|
||||||
func NewGetter(blockChain core.BlockChain) GenericGetter {
|
func NewGetter(blockChain core.BlockChain) GenericGetter {
|
||||||
return GenericGetter{
|
return GenericGetter{
|
||||||
Fetcher: generic.Fetcher{
|
Fetcher: fetcher.Fetcher{
|
||||||
BlockChain: blockChain,
|
BlockChain: blockChain,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,7 @@ func (e Event) Signature() string {
|
|||||||
var DaiContractAddress = "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"
|
var DaiContractAddress = "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"
|
||||||
var TusdContractAddress = "0x8dd5fbCe2F6a956C3022bA3663759011Dd51e73E"
|
var TusdContractAddress = "0x8dd5fbCe2F6a956C3022bA3663759011Dd51e73E"
|
||||||
var EnsContractAddress = "0x314159265dD8dbb310642f98f50C066173C1259b"
|
var EnsContractAddress = "0x314159265dD8dbb310642f98f50C066173C1259b"
|
||||||
|
var PublicResolverAddress = "0x1da022710dF5002339274AaDEe8D58218e9D6AB5"
|
||||||
|
|
||||||
// Contract Owner
|
// Contract Owner
|
||||||
var DaiContractOwner = "0x0000000000000000000000000000000000000000"
|
var DaiContractOwner = "0x0000000000000000000000000000000000000000"
|
||||||
|
127
pkg/omni/shared/constants/interface.go
Normal file
127
pkg/omni/shared/constants/interface.go
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
// VulcanizeDB
|
||||||
|
// Copyright © 2018 Vulcanize
|
||||||
|
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package constants
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Basic abi needed to check which interfaces are adhered to
|
||||||
|
var SupportsInterfaceABI = `[{"constant":true,"inputs":[{"name":"interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"}]`
|
||||||
|
|
||||||
|
// Individual event interfaces for constructing ABI from
|
||||||
|
var SupportsInterace = `{"constant":true,"inputs":[{"name":"interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"}`
|
||||||
|
var AddrChangeInterface = `{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"a","type":"address"}],"name":"AddrChanged","type":"event"}`
|
||||||
|
var ContentChangeInterface = `{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"hash","type":"bytes32"}],"name":"ContentChanged","type":"event"}`
|
||||||
|
var NameChangeInterface = `{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"name","type":"string"}],"name":"NameChanged","type":"event"}`
|
||||||
|
var AbiChangeInterface = `{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":true,"name":"contentType","type":"uint256"}],"name":"ABIChanged","type":"event"}`
|
||||||
|
var PubkeyChangeInterface = `{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"x","type":"bytes32"},{"indexed":false,"name":"y","type":"bytes32"}],"name":"PubkeyChanged","type":"event"}`
|
||||||
|
var TextChangeInterface = `{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"indexedKey","type":"string"},{"indexed":false,"name":"key","type":"string"}],"name":"TextChanged","type":"event"}`
|
||||||
|
var MultihashChangeInterface = `{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"hash","type":"bytes"}],"name":"MultihashChanged","type":"event"}`
|
||||||
|
var ContenthashChangeInterface = `{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"hash","type":"bytes"}],"name":"ContenthashChanged","type":"event"}`
|
||||||
|
|
||||||
|
var StartingBlock = int64(3648359)
|
||||||
|
|
||||||
|
// Resolver interface signatures
|
||||||
|
type Interface int
|
||||||
|
|
||||||
|
const (
|
||||||
|
MetaSig Interface = iota
|
||||||
|
AddrChangeSig
|
||||||
|
ContentChangeSig
|
||||||
|
NameChangeSig
|
||||||
|
AbiChangeSig
|
||||||
|
PubkeyChangeSig
|
||||||
|
TextChangeSig
|
||||||
|
MultihashChangeSig
|
||||||
|
ContentHashChangeSig
|
||||||
|
)
|
||||||
|
|
||||||
|
func (e Interface) Hex() string {
|
||||||
|
strings := [...]string{
|
||||||
|
"0x01ffc9a7",
|
||||||
|
"0x3b3b57de",
|
||||||
|
"0xd8389dc5",
|
||||||
|
"0x691f3431",
|
||||||
|
"0x2203ab56",
|
||||||
|
"0xc8690233",
|
||||||
|
"0x59d1d43c",
|
||||||
|
"0xe89401a1",
|
||||||
|
"0xbc1c58d1",
|
||||||
|
}
|
||||||
|
|
||||||
|
if e < MetaSig || e > ContentHashChangeSig {
|
||||||
|
return "Unknown"
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings[e]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e Interface) Bytes() [4]uint8 {
|
||||||
|
if e < MetaSig || e > ContentHashChangeSig {
|
||||||
|
return [4]byte{}
|
||||||
|
}
|
||||||
|
|
||||||
|
str := e.Hex()
|
||||||
|
by, _ := hexutil.Decode(str)
|
||||||
|
var byArray [4]uint8
|
||||||
|
for i := 0; i < 4; i++ {
|
||||||
|
byArray[i] = by[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
return byArray
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e Interface) EventSig() string {
|
||||||
|
strings := [...]string{
|
||||||
|
"",
|
||||||
|
"AddrChanged(bytes32,address)",
|
||||||
|
"ContentChanged(bytes32,bytes32)",
|
||||||
|
"NameChanged(bytes32,string)",
|
||||||
|
"ABIChanged(bytes32,uint256)",
|
||||||
|
"PubkeyChanged(bytes32,bytes32,bytes32)",
|
||||||
|
"TextChanged(bytes32,string,string)",
|
||||||
|
"MultihashChanged(bytes32,bytes)",
|
||||||
|
"ContenthashChanged(bytes32,bytes)",
|
||||||
|
}
|
||||||
|
|
||||||
|
if e < MetaSig || e > ContentHashChangeSig {
|
||||||
|
return "Unknown"
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings[e]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e Interface) MethodSig() string {
|
||||||
|
strings := [...]string{
|
||||||
|
"supportsInterface(bytes4)",
|
||||||
|
"addr(bytes32)",
|
||||||
|
"content(bytes32)",
|
||||||
|
"name(bytes32)",
|
||||||
|
"ABI(bytes32,uint256)",
|
||||||
|
"pubkey(bytes32)",
|
||||||
|
"text(bytes32,string)",
|
||||||
|
"multihash(bytes32)",
|
||||||
|
"setContenthash(bytes32,bytes)",
|
||||||
|
}
|
||||||
|
|
||||||
|
if e < MetaSig || e > ContentHashChangeSig {
|
||||||
|
return "Unknown"
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings[e]
|
||||||
|
}
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package generic
|
package fetcher
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
35
pkg/omni/shared/getter/getter_suite_test.go
Normal file
35
pkg/omni/shared/getter/getter_suite_test.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// VulcanizeDB
|
||||||
|
// Copyright © 2018 Vulcanize
|
||||||
|
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package getter_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRepository(t *testing.T) {
|
||||||
|
RegisterFailHandler(Fail)
|
||||||
|
RunSpecs(t, "Getter Suite Test")
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ = BeforeSuite(func() {
|
||||||
|
log.SetOutput(ioutil.Discard)
|
||||||
|
})
|
55
pkg/omni/shared/getter/getter_test.go
Normal file
55
pkg/omni/shared/getter/getter_test.go
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// VulcanizeDB
|
||||||
|
// Copyright © 2018 Vulcanize
|
||||||
|
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package getter_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ethereum/go-ethereum/ethclient"
|
||||||
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
|
||||||
|
rpc2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/geth/node"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/omni/shared/constants"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/omni/shared/getter"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = Describe("Interface Getter", func() {
|
||||||
|
Describe("GetAbi", func() {
|
||||||
|
It("Constructs and returns a custom abi based on results from supportsInterface calls", func() {
|
||||||
|
expectedABI := `[` + constants.AddrChangeInterface + `,` + constants.NameChangeInterface + `,` + constants.ContentChangeInterface + `,` + constants.AbiChangeInterface + `,` + constants.PubkeyChangeInterface + `]`
|
||||||
|
|
||||||
|
blockNumber := int64(6885696)
|
||||||
|
infuraIPC := "https://mainnet.infura.io/v3/b09888c1113640cc9ab42750ce750c05"
|
||||||
|
rawRpcClient, err := rpc.Dial(infuraIPC)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
rpcClient := client.NewRpcClient(rawRpcClient, infuraIPC)
|
||||||
|
ethClient := ethclient.NewClient(rawRpcClient)
|
||||||
|
blockChainClient := client.NewEthClient(ethClient)
|
||||||
|
node := node.MakeNode(rpcClient)
|
||||||
|
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
|
||||||
|
blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||||
|
interfaceGetter := getter.NewInterfaceGetter(blockChain)
|
||||||
|
abi := interfaceGetter.GetABI(constants.PublicResolverAddress, blockNumber)
|
||||||
|
Expect(abi).To(Equal(expectedABI))
|
||||||
|
_, err = geth.ParseAbi(abi)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
105
pkg/omni/shared/getter/interface_getter.go
Normal file
105
pkg/omni/shared/getter/interface_getter.go
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
// VulcanizeDB
|
||||||
|
// Copyright © 2018 Vulcanize
|
||||||
|
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package getter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/omni/shared/constants"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/omni/shared/fetcher"
|
||||||
|
)
|
||||||
|
|
||||||
|
type InterfaceGetter interface {
|
||||||
|
GetABI(resolverAddr string, blockNumber int64) string
|
||||||
|
GetBlockChain() core.BlockChain
|
||||||
|
}
|
||||||
|
|
||||||
|
type interfaceGetter struct {
|
||||||
|
fetcher.Fetcher
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewInterfaceGetter(blockChain core.BlockChain) *interfaceGetter {
|
||||||
|
return &interfaceGetter{
|
||||||
|
Fetcher: fetcher.Fetcher{
|
||||||
|
BlockChain: blockChain,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Used to construct a custom ABI based on the results from calling supportsInterface
|
||||||
|
func (g *interfaceGetter) GetABI(resolverAddr string, blockNumber int64) string {
|
||||||
|
a := constants.SupportsInterfaceABI
|
||||||
|
args := make([]interface{}, 1)
|
||||||
|
args[0] = constants.MetaSig.Bytes()
|
||||||
|
supports, err := g.getSupportsInterface(a, resolverAddr, blockNumber, args)
|
||||||
|
if err != nil || !supports {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
abiStr := `[`
|
||||||
|
args[0] = constants.AddrChangeSig.Bytes()
|
||||||
|
supports, err = g.getSupportsInterface(a, resolverAddr, blockNumber, args)
|
||||||
|
if err == nil && supports {
|
||||||
|
abiStr += constants.AddrChangeInterface + ","
|
||||||
|
}
|
||||||
|
args[0] = constants.NameChangeSig.Bytes()
|
||||||
|
supports, err = g.getSupportsInterface(a, resolverAddr, blockNumber, args)
|
||||||
|
if err == nil && supports {
|
||||||
|
abiStr += constants.NameChangeInterface + ","
|
||||||
|
}
|
||||||
|
args[0] = constants.ContentChangeSig.Bytes()
|
||||||
|
supports, err = g.getSupportsInterface(a, resolverAddr, blockNumber, args)
|
||||||
|
if err == nil && supports {
|
||||||
|
abiStr += constants.ContentChangeInterface + ","
|
||||||
|
}
|
||||||
|
args[0] = constants.AbiChangeSig.Bytes()
|
||||||
|
supports, err = g.getSupportsInterface(a, resolverAddr, blockNumber, args)
|
||||||
|
if err == nil && supports {
|
||||||
|
abiStr += constants.AbiChangeInterface + ","
|
||||||
|
}
|
||||||
|
args[0] = constants.PubkeyChangeSig.Bytes()
|
||||||
|
supports, err = g.getSupportsInterface(a, resolverAddr, blockNumber, args)
|
||||||
|
if err == nil && supports {
|
||||||
|
abiStr += constants.PubkeyChangeInterface + ","
|
||||||
|
}
|
||||||
|
args[0] = constants.ContentHashChangeSig.Bytes()
|
||||||
|
supports, err = g.getSupportsInterface(a, resolverAddr, blockNumber, args)
|
||||||
|
if err == nil && supports {
|
||||||
|
abiStr += constants.ContenthashChangeInterface + ","
|
||||||
|
}
|
||||||
|
args[0] = constants.MultihashChangeSig.Bytes()
|
||||||
|
supports, err = g.getSupportsInterface(a, resolverAddr, blockNumber, args)
|
||||||
|
if err == nil && supports {
|
||||||
|
abiStr += constants.MultihashChangeInterface + ","
|
||||||
|
}
|
||||||
|
args[0] = constants.TextChangeSig.Bytes()
|
||||||
|
supports, err = g.getSupportsInterface(a, resolverAddr, blockNumber, args)
|
||||||
|
if err == nil && supports {
|
||||||
|
abiStr += constants.TextChangeInterface + ","
|
||||||
|
}
|
||||||
|
abiStr = abiStr[:len(abiStr)-1] + `]`
|
||||||
|
|
||||||
|
return abiStr
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use this method to check whether or not a contract supports a given method/event interface
|
||||||
|
func (g *interfaceGetter) getSupportsInterface(contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (bool, error) {
|
||||||
|
return g.Fetcher.FetchBool("supportsInterface", contractAbi, contractAddress, blockNumber, methodArgs)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to retrieve the Getter's blockchain
|
||||||
|
func (g *interfaceGetter) GetBlockChain() core.BlockChain {
|
||||||
|
return g.Fetcher.BlockChain
|
||||||
|
}
|
@ -245,9 +245,6 @@ func TearDown(db *postgres.DB) {
|
|||||||
_, err = tx.Exec(`DELETE FROM headers`)
|
_, err = tx.Exec(`DELETE FROM headers`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
_, err = tx.Exec(`DELETE FROM checked_headers`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
|
|
||||||
_, err = tx.Exec(`DELETE FROM logs`)
|
_, err = tx.Exec(`DELETE FROM logs`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
@ -260,10 +257,10 @@ func TearDown(db *postgres.DB) {
|
|||||||
_, err = tx.Exec(`DELETE FROM receipts`)
|
_, err = tx.Exec(`DELETE FROM receipts`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
_, err = tx.Exec(`DROP TABLE public.checked_headers`)
|
_, err = tx.Exec(`DROP TABLE checked_headers`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
_, err = tx.Exec(`CREATE TABLE public.checked_headers (id SERIAL PRIMARY KEY, header_id INTEGER UNIQUE NOT NULL REFERENCES headers (id) ON DELETE CASCADE);`)
|
_, err = tx.Exec(`CREATE TABLE checked_headers (id SERIAL PRIMARY KEY, header_id INTEGER UNIQUE NOT NULL REFERENCES headers (id) ON DELETE CASCADE);`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
_, err = tx.Exec(`DROP SCHEMA IF EXISTS full_0x8dd5fbce2f6a956c3022ba3663759011dd51e73e CASCADE`)
|
_, err = tx.Exec(`DROP SCHEMA IF EXISTS full_0x8dd5fbce2f6a956c3022ba3663759011dd51e73e CASCADE`)
|
||||||
|
@ -31,6 +31,7 @@ import (
|
|||||||
// It is dependent on etherscan's api
|
// It is dependent on etherscan's api
|
||||||
type Parser interface {
|
type Parser interface {
|
||||||
Parse(contractAddr string) error
|
Parse(contractAddr string) error
|
||||||
|
ParseAbiStr(abiStr string) error
|
||||||
Abi() string
|
Abi() string
|
||||||
ParsedAbi() abi.ABI
|
ParsedAbi() abi.ABI
|
||||||
GetMethods(wanted []string) []types.Method
|
GetMethods(wanted []string) []types.Method
|
||||||
@ -83,6 +84,15 @@ func (p *parser) Parse(contractAddr string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Loads and parses an abi from a given abi string
|
||||||
|
func (p *parser) ParseAbiStr(abiStr string) error {
|
||||||
|
var err error
|
||||||
|
p.abi = abiStr
|
||||||
|
p.parsedAbi, err = geth.ParseAbi(abiStr)
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (p *parser) lookUp(contractAddr string) (string, error) {
|
func (p *parser) lookUp(contractAddr string) (string, error) {
|
||||||
if v, ok := constants.Abis[common.HexToAddress(contractAddr)]; ok {
|
if v, ok := constants.Abis[common.HexToAddress(contractAddr)]; ok {
|
||||||
return v, nil
|
return v, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user