forked from cerc-io/ipld-eth-server
work on erc20 event_triggered functionality and generic helper for log unpacking and converting. helpers.ConvertToLog and helpers.createTopics have been adjusted to be variadic to work with event logs with any number of topics. Also uncovered issue with Dai and TrueUSD that means they doesn't really conform to the ERC20 standard. this is because they named their arguments to standard events like Approval and Trasnfer differently (e.g. Approval(src address, guy address, wad uint) and Approval(owner address, spender address, value uint) instead of the standard which is Approval(tokenOwner address, spender address, tokens uint)). This causes incompatibility with generic ERC20 entities and converters for these events.
This commit is contained in:
@@ -18,8 +18,8 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/vulcanize/vulcanizedb/examples/constants"
|
||||
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher"
|
||||
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/every_block"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic"
|
||||
"github.com/vulcanize/vulcanizedb/examples/test_helpers"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
@@ -45,7 +45,7 @@ var _ = Describe("Everyblock transformers", func() {
|
||||
|
||||
BeforeEach(func() {
|
||||
blockChain = fakes.NewMockBlockChain()
|
||||
blockNumber = erc20_watcher.DaiConfig.FirstBlock
|
||||
blockNumber = generic.DaiConfig.FirstBlock
|
||||
lastBlockNumber := blockNumber + 1
|
||||
db = test_helpers.CreateNewDatabase()
|
||||
setLastBlockOnChain(blockChain, lastBlockNumber)
|
||||
@@ -59,7 +59,7 @@ var _ = Describe("Everyblock transformers", func() {
|
||||
})
|
||||
|
||||
It("creates a token_supply record for each block in the given range", func() {
|
||||
initializer := every_block.ERC20TokenTransformerInitializer{Config: erc20_watcher.DaiConfig}
|
||||
initializer := every_block.ERC20TokenTransformerInitializer{Config: generic.DaiConfig}
|
||||
transformer := initializer.NewERC20TokenTransformer(db, blockChain)
|
||||
transformer.Execute()
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ package every_block
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic"
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
@@ -30,15 +29,15 @@ type Transformer struct {
|
||||
Getter ERC20GetterInterface
|
||||
Repository ERC20RepositoryInterface
|
||||
Retriever generic.Retriever
|
||||
Config erc20_watcher.ContractConfig
|
||||
Config generic.ContractConfig
|
||||
}
|
||||
|
||||
func (t *Transformer) SetConfiguration(config erc20_watcher.ContractConfig) {
|
||||
func (t *Transformer) SetConfiguration(config generic.ContractConfig) {
|
||||
t.Config = config
|
||||
}
|
||||
|
||||
type ERC20TokenTransformerInitializer struct {
|
||||
Config erc20_watcher.ContractConfig
|
||||
Config generic.ContractConfig
|
||||
}
|
||||
|
||||
func (i ERC20TokenTransformerInitializer) NewERC20TokenTransformer(db *postgres.DB, blockchain core.BlockChain) shared.Transformer {
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/vulcanize/vulcanizedb/examples/constants"
|
||||
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher"
|
||||
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/every_block"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic"
|
||||
"github.com/vulcanize/vulcanizedb/examples/mocks"
|
||||
@@ -29,7 +28,7 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
var testContractConfig = erc20_watcher.ContractConfig{
|
||||
var testContractConfig = generic.ContractConfig{
|
||||
Address: constants.DaiContractAddress,
|
||||
Abi: constants.DaiAbiString,
|
||||
FirstBlock: int64(4752008),
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
package every_block
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic"
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared"
|
||||
)
|
||||
|
||||
func TransformerInitializers() []shared.TransformerInitializer {
|
||||
config := erc20_watcher.DaiConfig
|
||||
config := generic.DaiConfig
|
||||
initializer := ERC20TokenTransformerInitializer{config}
|
||||
return []shared.TransformerInitializer{
|
||||
initializer.NewERC20TokenTransformer,
|
||||
|
||||
Reference in New Issue
Block a user