diff --git a/cmd/coldImport.go b/cmd/coldImport.go index ddd1048b..1883d0b6 100644 --- a/cmd/coldImport.go +++ b/cmd/coldImport.go @@ -23,10 +23,10 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/crypto" "github.com/vulcanize/vulcanizedb/pkg/datastore/ethereum" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" + "github.com/vulcanize/vulcanizedb/pkg/eth/cold_import" + "github.com/vulcanize/vulcanizedb/pkg/eth/converters/cold_db" + vulcCommon "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common" "github.com/vulcanize/vulcanizedb/pkg/fs" - "github.com/vulcanize/vulcanizedb/pkg/geth/cold_import" - "github.com/vulcanize/vulcanizedb/pkg/geth/converters/cold_db" - vulcCommon "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common" "github.com/vulcanize/vulcanizedb/utils" ) diff --git a/cmd/headerSync.go b/cmd/headerSync.go index 0b2f5a1a..87ff22da 100644 --- a/cmd/headerSync.go +++ b/cmd/headerSync.go @@ -25,7 +25,7 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/datastore" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/geth" + "github.com/vulcanize/vulcanizedb/pkg/eth" "github.com/vulcanize/vulcanizedb/pkg/history" "github.com/vulcanize/vulcanizedb/utils" ) @@ -100,7 +100,7 @@ func headerSync() { } } -func validateArgs(blockChain *geth.BlockChain) { +func validateArgs(blockChain *eth.BlockChain) { lastBlock, err := blockChain.LastBlock() if err != nil { LogWithCommand.Error("validateArgs: Error getting last block: ", err) diff --git a/cmd/root.go b/cmd/root.go index f8174f74..fb6a1375 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -28,10 +28,10 @@ import ( "github.com/spf13/viper" "github.com/vulcanize/vulcanizedb/pkg/config" - "github.com/vulcanize/vulcanizedb/pkg/geth" - "github.com/vulcanize/vulcanizedb/pkg/geth/client" - vRpc "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc" - "github.com/vulcanize/vulcanizedb/pkg/geth/node" + "github.com/vulcanize/vulcanizedb/pkg/eth" + "github.com/vulcanize/vulcanizedb/pkg/eth/client" + vRpc "github.com/vulcanize/vulcanizedb/pkg/eth/converters/rpc" + "github.com/vulcanize/vulcanizedb/pkg/eth/node" ) var ( @@ -155,12 +155,12 @@ func initConfig() { } } -func getBlockChain() *geth.BlockChain { +func getBlockChain() *eth.BlockChain { rpcClient, ethClient := getClients() vdbEthClient := client.NewEthClient(ethClient) vdbNode := node.MakeNode(rpcClient) transactionConverter := vRpc.NewRpcTransactionConverter(ethClient) - return geth.NewBlockChain(vdbEthClient, rpcClient, vdbNode, transactionConverter) + return eth.NewBlockChain(vdbEthClient, rpcClient, vdbNode, transactionConverter) } func getClients() (client.RpcClient, *ethclient.Client) { diff --git a/integration_test/block_rewards_test.go b/integration_test/block_rewards_test.go index 7e66f374..c2ef087b 100644 --- a/integration_test/block_rewards_test.go +++ b/integration_test/block_rewards_test.go @@ -22,10 +22,10 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/geth" - "github.com/vulcanize/vulcanizedb/pkg/geth/client" - vRpc "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc" - "github.com/vulcanize/vulcanizedb/pkg/geth/node" + "github.com/vulcanize/vulcanizedb/pkg/eth" + "github.com/vulcanize/vulcanizedb/pkg/eth/client" + vRpc "github.com/vulcanize/vulcanizedb/pkg/eth/converters/rpc" + "github.com/vulcanize/vulcanizedb/pkg/eth/node" "github.com/vulcanize/vulcanizedb/test_config" ) @@ -39,7 +39,7 @@ var _ = Describe("Rewards calculations", func() { blockChainClient := client.NewEthClient(ethClient) node := node.MakeNode(rpcClient) transactionConverter := vRpc.NewRpcTransactionConverter(ethClient) - blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) + blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) block, err := blockChain.GetBlockByNumber(1071819) Expect(err).ToNot(HaveOccurred()) Expect(block.Reward).To(Equal("5313550000000000000")) @@ -53,7 +53,7 @@ var _ = Describe("Rewards calculations", func() { blockChainClient := client.NewEthClient(ethClient) node := node.MakeNode(rpcClient) transactionConverter := vRpc.NewRpcTransactionConverter(ethClient) - blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) + blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) block, err := blockChain.GetBlockByNumber(1071819) Expect(err).ToNot(HaveOccurred()) Expect(block.UnclesReward).To(Equal("6875000000000000000")) diff --git a/integration_test/contract_test.go b/integration_test/contract_test.go index b5d0b07f..9abc1f6e 100644 --- a/integration_test/contract_test.go +++ b/integration_test/contract_test.go @@ -26,11 +26,11 @@ import ( . "github.com/onsi/gomega" "github.com/vulcanize/vulcanizedb/pkg/core" - "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/geth/testing" + "github.com/vulcanize/vulcanizedb/pkg/eth" + "github.com/vulcanize/vulcanizedb/pkg/eth/client" + rpc2 "github.com/vulcanize/vulcanizedb/pkg/eth/converters/rpc" + "github.com/vulcanize/vulcanizedb/pkg/eth/node" + "github.com/vulcanize/vulcanizedb/pkg/eth/testing" "github.com/vulcanize/vulcanizedb/test_config" ) @@ -56,7 +56,7 @@ var _ = Describe("Reading contracts", func() { blockChainClient := client.NewEthClient(ethClient) node := node.MakeNode(rpcClient) transactionConverter := rpc2.NewRpcTransactionConverter(ethClient) - blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) + blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) contract := testing.SampleContract() logs, err := blockChain.GetFullSyncLogs(contract, big.NewInt(4703824), nil) @@ -74,7 +74,7 @@ var _ = Describe("Reading contracts", func() { blockChainClient := client.NewEthClient(ethClient) node := node.MakeNode(rpcClient) transactionConverter := rpc2.NewRpcTransactionConverter(ethClient) - blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) + blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) logs, err := blockChain.GetFullSyncLogs(core.Contract{Hash: "0x123"}, big.NewInt(4703824), nil) @@ -92,7 +92,7 @@ var _ = Describe("Reading contracts", func() { blockChainClient := client.NewEthClient(ethClient) node := node.MakeNode(rpcClient) transactionConverter := rpc2.NewRpcTransactionConverter(ethClient) - blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) + blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) contract := testing.SampleContract() var balance = new(big.Int) diff --git a/integration_test/geth_blockchain_test.go b/integration_test/geth_blockchain_test.go index 69b15a82..27f7476f 100644 --- a/integration_test/geth_blockchain_test.go +++ b/integration_test/geth_blockchain_test.go @@ -24,17 +24,17 @@ import ( . "github.com/onsi/gomega" "github.com/vulcanize/vulcanizedb/pkg/core" + "github.com/vulcanize/vulcanizedb/pkg/eth" + "github.com/vulcanize/vulcanizedb/pkg/eth/client" + rpc2 "github.com/vulcanize/vulcanizedb/pkg/eth/converters/rpc" + "github.com/vulcanize/vulcanizedb/pkg/eth/node" "github.com/vulcanize/vulcanizedb/pkg/fakes" - "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/history" "github.com/vulcanize/vulcanizedb/test_config" ) var _ = Describe("Reading from the Geth blockchain", func() { - var blockChain *geth.BlockChain + var blockChain *eth.BlockChain BeforeEach(func() { rawRpcClient, err := rpc.Dial(test_config.InfuraClient.IPCPath) @@ -44,7 +44,7 @@ var _ = Describe("Reading from the Geth blockchain", func() { blockChainClient := client.NewEthClient(ethClient) node := node.MakeNode(rpcClient) transactionConverter := rpc2.NewRpcTransactionConverter(ethClient) - blockChain = geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) + blockChain = eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) }) It("reads two blocks", func(done Done) { diff --git a/pkg/config/contract.go b/pkg/config/contract.go index 50b8366a..fe415cd7 100644 --- a/pkg/config/contract.go +++ b/pkg/config/contract.go @@ -19,7 +19,7 @@ package config import ( log "github.com/sirupsen/logrus" "github.com/spf13/viper" - "github.com/vulcanize/vulcanizedb/pkg/geth" + "github.com/vulcanize/vulcanizedb/pkg/eth" "strings" ) @@ -98,7 +98,7 @@ func (contractConfig *ContractConfig) PrepConfig() { } } if abi != "" { - if _, abiErr := geth.ParseAbi(abi); abiErr != nil { + if _, abiErr := eth.ParseAbi(abi); abiErr != nil { log.Fatal(addr, "transformer `abi` not valid JSON") } } diff --git a/pkg/contract_watcher/shared/getter/getter_test.go b/pkg/contract_watcher/shared/getter/getter_test.go index 80084c64..e4e58c64 100644 --- a/pkg/contract_watcher/shared/getter/getter_test.go +++ b/pkg/contract_watcher/shared/getter/getter_test.go @@ -24,10 +24,10 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/constants" "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/getter" - "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/eth" + "github.com/vulcanize/vulcanizedb/pkg/eth/client" + rpc2 "github.com/vulcanize/vulcanizedb/pkg/eth/converters/rpc" + "github.com/vulcanize/vulcanizedb/pkg/eth/node" "github.com/vulcanize/vulcanizedb/test_config" ) @@ -45,12 +45,12 @@ var _ = Describe("Interface Getter", func() { blockChainClient := client.NewEthClient(ethClient) node := node.MakeNode(rpcClient) transactionConverter := rpc2.NewRpcTransactionConverter(ethClient) - blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) + blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) interfaceGetter := getter.NewInterfaceGetter(blockChain) abi, err := interfaceGetter.GetABI(constants.PublicResolverAddress, blockNumber) Expect(err).NotTo(HaveOccurred()) Expect(abi).To(Equal(expectedABI)) - _, err = geth.ParseAbi(abi) + _, err = eth.ParseAbi(abi) Expect(err).ToNot(HaveOccurred()) }) }) diff --git a/pkg/contract_watcher/shared/helpers/test_helpers/database.go b/pkg/contract_watcher/shared/helpers/test_helpers/database.go index a997c9df..352ad79b 100644 --- a/pkg/contract_watcher/shared/helpers/test_helpers/database.go +++ b/pkg/contract_watcher/shared/helpers/test_helpers/database.go @@ -30,10 +30,10 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "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/eth" + "github.com/vulcanize/vulcanizedb/pkg/eth/client" + rpc2 "github.com/vulcanize/vulcanizedb/pkg/eth/converters/rpc" + "github.com/vulcanize/vulcanizedb/pkg/eth/node" "github.com/vulcanize/vulcanizedb/test_config" ) @@ -117,7 +117,7 @@ func SetupDBandBC() (*postgres.DB, core.BlockChain) { blockChainClient := client.NewEthClient(ethClient) madeNode := node.MakeNode(rpcClient) transactionConverter := rpc2.NewRpcTransactionConverter(ethClient) - blockChain := geth.NewBlockChain(blockChainClient, rpcClient, madeNode, transactionConverter) + blockChain := eth.NewBlockChain(blockChainClient, rpcClient, madeNode, transactionConverter) db, err := postgres.NewDB(config.Database{ Hostname: "localhost", diff --git a/pkg/contract_watcher/shared/helpers/test_helpers/mocks/parser.go b/pkg/contract_watcher/shared/helpers/test_helpers/mocks/parser.go index 6ea0948d..f8784a04 100644 --- a/pkg/contract_watcher/shared/helpers/test_helpers/mocks/parser.go +++ b/pkg/contract_watcher/shared/helpers/test_helpers/mocks/parser.go @@ -20,7 +20,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/types" - "github.com/vulcanize/vulcanizedb/pkg/geth" + "github.com/vulcanize/vulcanizedb/pkg/eth" ) // Mock parser @@ -50,7 +50,7 @@ func (p *parser) ParsedAbi() abi.ABI { // for the given contract address func (p *parser) Parse() error { var err error - p.parsedAbi, err = geth.ParseAbi(p.abi) + p.parsedAbi, err = eth.ParseAbi(p.abi) return err } diff --git a/pkg/contract_watcher/shared/parser/parser.go b/pkg/contract_watcher/shared/parser/parser.go index 77af237b..a8247b52 100644 --- a/pkg/contract_watcher/shared/parser/parser.go +++ b/pkg/contract_watcher/shared/parser/parser.go @@ -24,7 +24,7 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/constants" "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/types" - "github.com/vulcanize/vulcanizedb/pkg/geth" + "github.com/vulcanize/vulcanizedb/pkg/eth" ) // Parser is used to fetch and parse contract ABIs @@ -40,16 +40,16 @@ type Parser interface { } type parser struct { - client *geth.EtherScanAPI + client *eth.EtherScanAPI abi string parsedAbi abi.ABI } func NewParser(network string) *parser { - url := geth.GenURL(network) + url := eth.GenURL(network) return &parser{ - client: geth.NewEtherScanClient(url), + client: eth.NewEtherScanClient(url), } } @@ -69,7 +69,7 @@ func (p *parser) Parse(contractAddr string) error { knownAbi, err := p.lookUp(contractAddr) if err == nil { p.abi = knownAbi - p.parsedAbi, err = geth.ParseAbi(knownAbi) + p.parsedAbi, err = eth.ParseAbi(knownAbi) return err } // Try getting abi from etherscan @@ -79,7 +79,7 @@ func (p *parser) Parse(contractAddr string) error { } //TODO: Implement other ways to fetch abi p.abi = abiStr - p.parsedAbi, err = geth.ParseAbi(abiStr) + p.parsedAbi, err = eth.ParseAbi(abiStr) return err } @@ -88,7 +88,7 @@ func (p *parser) Parse(contractAddr string) error { func (p *parser) ParseAbiStr(abiStr string) error { var err error p.abi = abiStr - p.parsedAbi, err = geth.ParseAbi(abiStr) + p.parsedAbi, err = eth.ParseAbi(abiStr) return err } diff --git a/pkg/contract_watcher/shared/parser/parser_test.go b/pkg/contract_watcher/shared/parser/parser_test.go index 2b7ba88f..3830fbe7 100644 --- a/pkg/contract_watcher/shared/parser/parser_test.go +++ b/pkg/contract_watcher/shared/parser/parser_test.go @@ -25,7 +25,7 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/helpers/test_helpers/mocks" "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/parser" "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/types" - "github.com/vulcanize/vulcanizedb/pkg/geth" + "github.com/vulcanize/vulcanizedb/pkg/eth" ) var _ = Describe("Parser", func() { @@ -44,7 +44,7 @@ var _ = Describe("Parser", func() { Expect(err).ToNot(HaveOccurred()) parsedAbi := mp.ParsedAbi() - expectedAbi, err := geth.ParseAbi(constants.DaiAbiString) + expectedAbi, err := eth.ParseAbi(constants.DaiAbiString) Expect(err).ToNot(HaveOccurred()) Expect(parsedAbi).To(Equal(expectedAbi)) @@ -73,7 +73,7 @@ var _ = Describe("Parser", func() { expectedAbi := constants.DaiAbiString Expect(p.Abi()).To(Equal(expectedAbi)) - expectedParsedAbi, err := geth.ParseAbi(expectedAbi) + expectedParsedAbi, err := eth.ParseAbi(expectedAbi) Expect(err).ToNot(HaveOccurred()) Expect(p.ParsedAbi()).To(Equal(expectedParsedAbi)) }) diff --git a/pkg/core/rpc_client.go b/pkg/core/rpc_client.go index a89ca230..b78543cd 100644 --- a/pkg/core/rpc_client.go +++ b/pkg/core/rpc_client.go @@ -20,7 +20,7 @@ import ( "context" "github.com/ethereum/go-ethereum/rpc" - "github.com/vulcanize/vulcanizedb/pkg/geth/client" + "github.com/vulcanize/vulcanizedb/pkg/eth/client" ) type RpcClient interface { diff --git a/pkg/geth/abi.go b/pkg/eth/abi.go similarity index 99% rename from pkg/geth/abi.go rename to pkg/eth/abi.go index 37d3bd77..5b752d75 100644 --- a/pkg/geth/abi.go +++ b/pkg/eth/abi.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package geth +package eth import ( "errors" diff --git a/pkg/geth/abi_test.go b/pkg/eth/abi_test.go similarity index 83% rename from pkg/geth/abi_test.go rename to pkg/eth/abi_test.go index 8e601783..ee0b84a8 100644 --- a/pkg/geth/abi_test.go +++ b/pkg/eth/abi_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package geth_test +package eth_test import ( "net/http" @@ -25,7 +25,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" - "github.com/vulcanize/vulcanizedb/pkg/geth" + "github.com/vulcanize/vulcanizedb/pkg/eth" "github.com/vulcanize/vulcanizedb/test_config" ) @@ -36,7 +36,7 @@ var _ = Describe("ABI files", func() { It("loads a valid ABI file", func() { path := test_config.ABIFilePath + "valid_abi.json" - contractAbi, err := geth.ParseAbiFile(path) + contractAbi, err := eth.ParseAbiFile(path) Expect(contractAbi).NotTo(BeNil()) Expect(err).To(BeNil()) @@ -45,7 +45,7 @@ var _ = Describe("ABI files", func() { It("reads the contents of a valid ABI file", func() { path := test_config.ABIFilePath + "valid_abi.json" - contractAbi, err := geth.ReadAbiFile(path) + contractAbi, err := eth.ReadAbiFile(path) Expect(contractAbi).To(Equal("[{\"foo\": \"bar\"}]")) Expect(err).To(BeNil()) @@ -54,38 +54,38 @@ var _ = Describe("ABI files", func() { It("returns an error when the file does not exist", func() { path := test_config.ABIFilePath + "missing_abi.json" - contractAbi, err := geth.ParseAbiFile(path) + contractAbi, err := eth.ParseAbiFile(path) Expect(contractAbi).To(Equal(abi.ABI{})) - Expect(err).To(Equal(geth.ErrMissingAbiFile)) + Expect(err).To(Equal(eth.ErrMissingAbiFile)) }) It("returns an error when the file has invalid contents", func() { path := test_config.ABIFilePath + "invalid_abi.json" - contractAbi, err := geth.ParseAbiFile(path) + contractAbi, err := eth.ParseAbiFile(path) Expect(contractAbi).To(Equal(abi.ABI{})) - Expect(err).To(Equal(geth.ErrInvalidAbiFile)) + Expect(err).To(Equal(eth.ErrInvalidAbiFile)) }) Describe("Request ABI from endpoint", func() { var ( server *ghttp.Server - client *geth.EtherScanAPI + client *eth.EtherScanAPI abiString string err error ) BeforeEach(func() { server = ghttp.NewServer() - client = geth.NewEtherScanClient(server.URL()) + client = eth.NewEtherScanClient(server.URL()) path := test_config.ABIFilePath + "sample_abi.json" - abiString, err = geth.ReadAbiFile(path) + abiString, err = eth.ReadAbiFile(path) Expect(err).NotTo(HaveOccurred()) - _, err = geth.ParseAbi(abiString) + _, err = eth.ParseAbi(abiString) Expect(err).NotTo(HaveOccurred()) }) @@ -117,14 +117,14 @@ var _ = Describe("ABI files", func() { Describe("Generating etherscan endpoints based on network", func() { It("should return the main endpoint as the default", func() { - url := geth.GenURL("") + url := eth.GenURL("") Expect(url).To(Equal("https://api.etherscan.io")) }) It("generates various test network endpoint if test network is supplied", func() { - ropstenUrl := geth.GenURL("ropsten") - rinkebyUrl := geth.GenURL("rinkeby") - kovanUrl := geth.GenURL("kovan") + ropstenUrl := eth.GenURL("ropsten") + rinkebyUrl := eth.GenURL("rinkeby") + kovanUrl := eth.GenURL("kovan") Expect(ropstenUrl).To(Equal("https://ropsten.etherscan.io")) Expect(kovanUrl).To(Equal("https://kovan.etherscan.io")) diff --git a/pkg/geth/blockchain.go b/pkg/eth/blockchain.go similarity index 98% rename from pkg/geth/blockchain.go rename to pkg/eth/blockchain.go index f834654a..92f5524a 100644 --- a/pkg/geth/blockchain.go +++ b/pkg/eth/blockchain.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package geth +package eth import ( "errors" @@ -28,8 +28,8 @@ import ( "golang.org/x/net/context" "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/geth/client" - vulcCommon "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common" + "github.com/vulcanize/vulcanizedb/pkg/eth/client" + vulcCommon "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common" ) var ErrEmptyHeader = errors.New("empty header returned over RPC") diff --git a/pkg/geth/blockchain_test.go b/pkg/eth/blockchain_test.go similarity index 93% rename from pkg/geth/blockchain_test.go rename to pkg/eth/blockchain_test.go index 21b71cf3..30ab0a3f 100644 --- a/pkg/geth/blockchain_test.go +++ b/pkg/eth/blockchain_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package geth_test +package eth_test import ( "context" @@ -29,14 +29,14 @@ import ( . "github.com/onsi/gomega" vulcCore "github.com/vulcanize/vulcanizedb/pkg/core" + "github.com/vulcanize/vulcanizedb/pkg/eth" "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/geth" ) var _ = Describe("Geth blockchain", func() { var ( mockClient *fakes.MockEthClient - blockChain *geth.BlockChain + blockChain *eth.BlockChain mockRpcClient *fakes.MockRpcClient mockTransactionConverter *fakes.MockTransactionConverter node vulcCore.Node @@ -47,7 +47,7 @@ var _ = Describe("Geth blockchain", func() { mockRpcClient = fakes.NewMockRpcClient() mockTransactionConverter = fakes.NewMockTransactionConverter() node = vulcCore.Node{} - blockChain = geth.NewBlockChain(mockClient, mockRpcClient, node, mockTransactionConverter) + blockChain = eth.NewBlockChain(mockClient, mockRpcClient, node, mockTransactionConverter) }) Describe("getting a block", func() { @@ -105,7 +105,7 @@ var _ = Describe("Geth blockchain", func() { node.NetworkID = vulcCore.KOVAN_NETWORK_ID blockNumber := hexutil.Big(*big.NewInt(100)) mockRpcClient.SetReturnPOAHeader(vulcCore.POAHeader{Number: &blockNumber}) - blockChain = geth.NewBlockChain(mockClient, mockRpcClient, node, fakes.NewMockTransactionConverter()) + blockChain = eth.NewBlockChain(mockClient, mockRpcClient, node, fakes.NewMockTransactionConverter()) _, err := blockChain.GetHeaderByNumber(100) @@ -116,7 +116,7 @@ var _ = Describe("Geth blockchain", func() { It("returns err if rpcClient returns err", func() { node.NetworkID = vulcCore.KOVAN_NETWORK_ID mockRpcClient.SetCallContextErr(fakes.FakeError) - blockChain = geth.NewBlockChain(mockClient, mockRpcClient, node, fakes.NewMockTransactionConverter()) + blockChain = eth.NewBlockChain(mockClient, mockRpcClient, node, fakes.NewMockTransactionConverter()) _, err := blockChain.GetHeaderByNumber(100) @@ -126,12 +126,12 @@ var _ = Describe("Geth blockchain", func() { It("returns error if returned header is empty", func() { node.NetworkID = vulcCore.KOVAN_NETWORK_ID - blockChain = geth.NewBlockChain(mockClient, mockRpcClient, node, fakes.NewMockTransactionConverter()) + blockChain = eth.NewBlockChain(mockClient, mockRpcClient, node, fakes.NewMockTransactionConverter()) _, err := blockChain.GetHeaderByNumber(100) Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(geth.ErrEmptyHeader)) + Expect(err).To(MatchError(eth.ErrEmptyHeader)) }) It("returns multiple headers with multiple blocknumbers", func() { diff --git a/pkg/geth/client/eth_client.go b/pkg/eth/client/eth_client.go similarity index 100% rename from pkg/geth/client/eth_client.go rename to pkg/eth/client/eth_client.go diff --git a/pkg/geth/client/rpc_client.go b/pkg/eth/client/rpc_client.go similarity index 100% rename from pkg/geth/client/rpc_client.go rename to pkg/eth/client/rpc_client.go diff --git a/pkg/geth/cold_import/cold_import_suite_test.go b/pkg/eth/cold_import/cold_import_suite_test.go similarity index 100% rename from pkg/geth/cold_import/cold_import_suite_test.go rename to pkg/eth/cold_import/cold_import_suite_test.go diff --git a/pkg/geth/cold_import/importer.go b/pkg/eth/cold_import/importer.go similarity index 97% rename from pkg/geth/cold_import/importer.go rename to pkg/eth/cold_import/importer.go index 280ed15a..3f1ecf2f 100644 --- a/pkg/geth/cold_import/importer.go +++ b/pkg/eth/cold_import/importer.go @@ -19,7 +19,7 @@ package cold_import import ( "github.com/vulcanize/vulcanizedb/pkg/datastore" "github.com/vulcanize/vulcanizedb/pkg/datastore/ethereum" - "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common" + "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common" ) type ColdImporter struct { diff --git a/pkg/geth/cold_import/importer_test.go b/pkg/eth/cold_import/importer_test.go similarity index 98% rename from pkg/geth/cold_import/importer_test.go rename to pkg/eth/cold_import/importer_test.go index ed435f5f..705cee90 100644 --- a/pkg/geth/cold_import/importer_test.go +++ b/pkg/eth/cold_import/importer_test.go @@ -21,9 +21,9 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" + "github.com/vulcanize/vulcanizedb/pkg/eth/cold_import" + vulcCommon "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common" "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/geth/cold_import" - vulcCommon "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common" ) var _ = Describe("Geth cold importer", func() { diff --git a/pkg/geth/cold_import/node_builder.go b/pkg/eth/cold_import/node_builder.go similarity index 100% rename from pkg/geth/cold_import/node_builder.go rename to pkg/eth/cold_import/node_builder.go diff --git a/pkg/geth/cold_import/node_builder_test.go b/pkg/eth/cold_import/node_builder_test.go similarity index 98% rename from pkg/geth/cold_import/node_builder_test.go rename to pkg/eth/cold_import/node_builder_test.go index e2be8620..21af752c 100644 --- a/pkg/geth/cold_import/node_builder_test.go +++ b/pkg/eth/cold_import/node_builder_test.go @@ -21,8 +21,8 @@ import ( "github.com/ethereum/go-ethereum/common" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "github.com/vulcanize/vulcanizedb/pkg/eth/cold_import" "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/geth/cold_import" ) var _ = Describe("Cold importer node builder", func() { diff --git a/pkg/geth/contract.go b/pkg/eth/contract.go similarity index 99% rename from pkg/geth/contract.go rename to pkg/eth/contract.go index b5f968ec..768ccb12 100644 --- a/pkg/geth/contract.go +++ b/pkg/eth/contract.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package geth +package eth import ( "context" diff --git a/pkg/geth/converters/cold_db/transaction_converter.go b/pkg/eth/converters/cold_db/transaction_converter.go similarity index 100% rename from pkg/geth/converters/cold_db/transaction_converter.go rename to pkg/eth/converters/cold_db/transaction_converter.go diff --git a/pkg/geth/converters/common/block_converter.go b/pkg/eth/converters/common/block_converter.go similarity index 100% rename from pkg/geth/converters/common/block_converter.go rename to pkg/eth/converters/common/block_converter.go diff --git a/pkg/geth/converters/common/block_converter_test.go b/pkg/eth/converters/common/block_converter_test.go similarity index 99% rename from pkg/geth/converters/common/block_converter_test.go rename to pkg/eth/converters/common/block_converter_test.go index 2ddb10f7..35be0f4c 100644 --- a/pkg/geth/converters/common/block_converter_test.go +++ b/pkg/eth/converters/common/block_converter_test.go @@ -29,9 +29,9 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + vulcCommon "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common" + "github.com/vulcanize/vulcanizedb/pkg/eth/converters/rpc" "github.com/vulcanize/vulcanizedb/pkg/fakes" - vulcCommon "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common" - "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc" ) var _ = Describe("Conversion of GethBlock to core.Block", func() { diff --git a/pkg/geth/converters/common/block_rewards.go b/pkg/eth/converters/common/block_rewards.go similarity index 100% rename from pkg/geth/converters/common/block_rewards.go rename to pkg/eth/converters/common/block_rewards.go diff --git a/pkg/geth/converters/common/common_suite_test.go b/pkg/eth/converters/common/common_suite_test.go similarity index 100% rename from pkg/geth/converters/common/common_suite_test.go rename to pkg/eth/converters/common/common_suite_test.go diff --git a/pkg/geth/converters/common/full_sync_log_converter.go b/pkg/eth/converters/common/full_sync_log_converter.go similarity index 100% rename from pkg/geth/converters/common/full_sync_log_converter.go rename to pkg/eth/converters/common/full_sync_log_converter.go diff --git a/pkg/geth/converters/common/full_sync_log_converter_test.go b/pkg/eth/converters/common/full_sync_log_converter_test.go similarity index 98% rename from pkg/geth/converters/common/full_sync_log_converter_test.go rename to pkg/eth/converters/common/full_sync_log_converter_test.go index fb0ad9c2..65eb7378 100644 --- a/pkg/geth/converters/common/full_sync_log_converter_test.go +++ b/pkg/eth/converters/common/full_sync_log_converter_test.go @@ -26,7 +26,7 @@ import ( . "github.com/onsi/gomega" "github.com/vulcanize/vulcanizedb/pkg/core" - vulcCommon "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common" + vulcCommon "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common" ) var _ = Describe("Conversion of GethLog to core.FullSyncLog", func() { diff --git a/pkg/geth/converters/common/header_converter.go b/pkg/eth/converters/common/header_converter.go similarity index 100% rename from pkg/geth/converters/common/header_converter.go rename to pkg/eth/converters/common/header_converter.go diff --git a/pkg/geth/converters/common/header_converter_test.go b/pkg/eth/converters/common/header_converter_test.go similarity index 96% rename from pkg/geth/converters/common/header_converter_test.go rename to pkg/eth/converters/common/header_converter_test.go index 6309d3a9..5123b74f 100644 --- a/pkg/geth/converters/common/header_converter_test.go +++ b/pkg/eth/converters/common/header_converter_test.go @@ -26,8 +26,8 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + common2 "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common" "github.com/vulcanize/vulcanizedb/pkg/fakes" - common2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common" ) var _ = Describe("Block header converter", func() { diff --git a/pkg/geth/converters/common/receipt_converter.go b/pkg/eth/converters/common/receipt_converter.go similarity index 100% rename from pkg/geth/converters/common/receipt_converter.go rename to pkg/eth/converters/common/receipt_converter.go diff --git a/pkg/geth/converters/common/receipt_converter_test.go b/pkg/eth/converters/common/receipt_converter_test.go similarity index 98% rename from pkg/geth/converters/common/receipt_converter_test.go rename to pkg/eth/converters/common/receipt_converter_test.go index 6788d80c..a861b770 100644 --- a/pkg/geth/converters/common/receipt_converter_test.go +++ b/pkg/eth/converters/common/receipt_converter_test.go @@ -25,7 +25,7 @@ import ( . "github.com/onsi/gomega" "github.com/vulcanize/vulcanizedb/pkg/core" - vulcCommon "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common" + vulcCommon "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common" ) var _ = Describe("Conversion of GethReceipt to core.Receipt", func() { diff --git a/pkg/geth/converters/common/transaction_converter.go b/pkg/eth/converters/common/transaction_converter.go similarity index 100% rename from pkg/geth/converters/common/transaction_converter.go rename to pkg/eth/converters/common/transaction_converter.go diff --git a/pkg/geth/converters/rpc/rpc_suite_test.go b/pkg/eth/converters/rpc/rpc_suite_test.go similarity index 100% rename from pkg/geth/converters/rpc/rpc_suite_test.go rename to pkg/eth/converters/rpc/rpc_suite_test.go diff --git a/pkg/geth/converters/rpc/transaction_converter.go b/pkg/eth/converters/rpc/transaction_converter.go similarity index 98% rename from pkg/geth/converters/rpc/transaction_converter.go rename to pkg/eth/converters/rpc/transaction_converter.go index c5cfc234..51f2ffc9 100644 --- a/pkg/geth/converters/rpc/transaction_converter.go +++ b/pkg/eth/converters/rpc/transaction_converter.go @@ -31,7 +31,7 @@ import ( "golang.org/x/sync/errgroup" "github.com/vulcanize/vulcanizedb/pkg/core" - vulcCommon "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common" + vulcCommon "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common" ) type RpcTransactionConverter struct { diff --git a/pkg/geth/converters/rpc/transaction_converter_test.go b/pkg/eth/converters/rpc/transaction_converter_test.go similarity index 98% rename from pkg/geth/converters/rpc/transaction_converter_test.go rename to pkg/eth/converters/rpc/transaction_converter_test.go index bcd7b725..d03909b4 100644 --- a/pkg/geth/converters/rpc/transaction_converter_test.go +++ b/pkg/eth/converters/rpc/transaction_converter_test.go @@ -20,8 +20,8 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/vulcanize/vulcanizedb/pkg/core" + "github.com/vulcanize/vulcanizedb/pkg/eth/converters/rpc" "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc" ) var _ = Describe("RPC transaction converter", func() { diff --git a/pkg/geth/geth_suite_test.go b/pkg/eth/eth_suite_test.go similarity index 94% rename from pkg/geth/geth_suite_test.go rename to pkg/eth/eth_suite_test.go index 1a151480..6271dca1 100644 --- a/pkg/geth/geth_suite_test.go +++ b/pkg/eth/eth_suite_test.go @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package geth_test +package eth_test import ( . "github.com/onsi/ginkgo" @@ -25,5 +25,5 @@ import ( func TestGeth(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, "Geth Suite") + RunSpecs(t, "eth Suite") } diff --git a/pkg/geth/node/node.go b/pkg/eth/node/node.go similarity index 100% rename from pkg/geth/node/node.go rename to pkg/eth/node/node.go diff --git a/pkg/geth/node/node_suite_test.go b/pkg/eth/node/node_suite_test.go similarity index 100% rename from pkg/geth/node/node_suite_test.go rename to pkg/eth/node/node_suite_test.go diff --git a/pkg/geth/node/node_test.go b/pkg/eth/node/node_test.go similarity index 98% rename from pkg/geth/node/node_test.go rename to pkg/eth/node/node_test.go index 8a74a441..ea96670a 100644 --- a/pkg/geth/node/node_test.go +++ b/pkg/eth/node/node_test.go @@ -23,8 +23,8 @@ import ( . "github.com/onsi/gomega" "github.com/vulcanize/vulcanizedb/pkg/core" + "github.com/vulcanize/vulcanizedb/pkg/eth/node" "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/geth/node" ) var EmpytHeaderHash = "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" diff --git a/pkg/geth/testing/helpers.go b/pkg/eth/testing/helpers.go similarity index 89% rename from pkg/geth/testing/helpers.go rename to pkg/eth/testing/helpers.go index 70929e40..dff6e4cb 100644 --- a/pkg/geth/testing/helpers.go +++ b/pkg/eth/testing/helpers.go @@ -20,7 +20,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/geth" + "github.com/vulcanize/vulcanizedb/pkg/eth" "github.com/vulcanize/vulcanizedb/test_config" ) @@ -32,7 +32,7 @@ func SampleContract() core.Contract { } func sampleAbiFileContents() string { - abiFileContents, err := geth.ReadAbiFile(test_config.ABIFilePath + "sample_abi.json") + abiFileContents, err := eth.ReadAbiFile(test_config.ABIFilePath + "sample_abi.json") if err != nil { log.Fatal(err) } diff --git a/pkg/geth/testing/invalid_abi.json b/pkg/eth/testing/invalid_abi.json similarity index 100% rename from pkg/geth/testing/invalid_abi.json rename to pkg/eth/testing/invalid_abi.json diff --git a/pkg/geth/testing/sample_abi.json b/pkg/eth/testing/sample_abi.json similarity index 100% rename from pkg/geth/testing/sample_abi.json rename to pkg/eth/testing/sample_abi.json diff --git a/pkg/geth/testing/valid_abi.json b/pkg/eth/testing/valid_abi.json similarity index 100% rename from pkg/geth/testing/valid_abi.json rename to pkg/eth/testing/valid_abi.json diff --git a/pkg/fakes/mock_eth_client.go b/pkg/fakes/mock_eth_client.go index 033232d5..97e668a3 100644 --- a/pkg/fakes/mock_eth_client.go +++ b/pkg/fakes/mock_eth_client.go @@ -25,7 +25,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/geth/client" + "github.com/vulcanize/vulcanizedb/pkg/eth/client" ) type MockEthClient struct { diff --git a/pkg/fakes/mock_rpc_client.go b/pkg/fakes/mock_rpc_client.go index 9acfdbe8..67982022 100644 --- a/pkg/fakes/mock_rpc_client.go +++ b/pkg/fakes/mock_rpc_client.go @@ -28,7 +28,7 @@ import ( . "github.com/onsi/gomega" "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/geth/client" + "github.com/vulcanize/vulcanizedb/pkg/eth/client" ) type MockRpcClient struct { diff --git a/test_config/test_config.go b/test_config/test_config.go index eb830d34..c5a24372 100644 --- a/test_config/test_config.go +++ b/test_config/test_config.go @@ -91,7 +91,7 @@ func setInfuraConfig() { func setABIPath() { gp := os.Getenv("GOPATH") - ABIFilePath = gp + "/src/github.com/vulcanize/vulcanizedb/pkg/geth/testing/" + ABIFilePath = gp + "/src/github.com/vulcanize/vulcanizedb/pkg/eth/testing/" } func NewTestDB(node core.Node) *postgres.DB { diff --git a/utils/utils.go b/utils/utils.go index 91354fcf..ce624616 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -18,7 +18,7 @@ package utils import ( "github.com/jmoiron/sqlx" - logrus "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus" "math/big" "os" "path/filepath" @@ -26,7 +26,7 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/config" "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/geth" + "github.com/vulcanize/vulcanizedb/pkg/eth" ) func LoadPostgres(database config.Database, node core.Node) postgres.DB { @@ -39,7 +39,7 @@ func LoadPostgres(database config.Database, node core.Node) postgres.DB { func ReadAbiFile(abiFilepath string) string { abiFilepath = AbsFilePath(abiFilepath) - abi, err := geth.ReadAbiFile(abiFilepath) + abi, err := eth.ReadAbiFile(abiFilepath) if err != nil { logrus.Fatalf("Error reading ABI file at \"%s\"\n %v", abiFilepath, err) } @@ -59,12 +59,12 @@ func GetAbi(abiFilepath string, contractHash string, network string) string { if abiFilepath != "" { contractAbiString = ReadAbiFile(abiFilepath) } else { - url := geth.GenURL(network) - etherscan := geth.NewEtherScanClient(url) + url := eth.GenURL(network) + etherscan := eth.NewEtherScanClient(url) logrus.Printf("No ABI supplied. Retrieving ABI from Etherscan: %s", url) contractAbiString, _ = etherscan.GetAbi(contractHash) } - _, err := geth.ParseAbi(contractAbiString) + _, err := eth.ParseAbi(contractAbiString) if err != nil { logrus.Fatalln("Invalid ABI: ", err) }