Update flip kick and tend transformers due to contract changes
* Update FlipperAddress to new local ganache address * Update flip_kick table * Update flipkick transformer to handle new signature and abi * Update tend table * Update tend converter
This commit is contained in:
parent
807b7accd6
commit
53635ec362
@ -2,15 +2,11 @@ CREATE TABLE maker.flip_kick (
|
||||
db_id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
id NUMERIC NOT NULL UNIQUE,
|
||||
mom VARCHAR,
|
||||
vat VARCHAR,
|
||||
ilk VARCHAR,
|
||||
lot NUMERIC,
|
||||
bid NUMERIC,
|
||||
guy VARCHAR,
|
||||
gal VARCHAR,
|
||||
"end" TIMESTAMP WITH TIME ZONE,
|
||||
era TIMESTAMP WITH TIME ZONE,
|
||||
lad VARCHAR,
|
||||
tab NUMERIC
|
||||
urn VARCHAR,
|
||||
tab NUMERIC,
|
||||
raw_log JSONB
|
||||
);
|
||||
|
@ -1,2 +0,0 @@
|
||||
ALTER TABLE maker.flip_kick
|
||||
DROP COLUMN raw_log;
|
@ -1,2 +0,0 @@
|
||||
ALTER TABLE maker.flip_kick
|
||||
ADD COLUMN raw_log json;
|
@ -1,12 +1,11 @@
|
||||
CREATE TABLE maker.tend (
|
||||
db_id SERIAL PRIMARY KEY,
|
||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||
id NUMERIC NOT NULL UNIQUE,
|
||||
bid_id NUMERIC NOT NULL UNIQUE,
|
||||
lot NUMERIC,
|
||||
bid NUMERIC,
|
||||
guy BYTEA,
|
||||
guy VARCHAR,
|
||||
tic NUMERIC,
|
||||
era TIMESTAMP WITH TIME ZONE,
|
||||
tx_idx INTEGER NOT NUll,
|
||||
raw_log JSONB
|
||||
);
|
||||
|
@ -1,2 +0,0 @@
|
||||
ALTER TABLE maker.flip_kick
|
||||
ADD COLUMN mom VARCHAR;
|
@ -1,2 +0,0 @@
|
||||
ALTER TABLE maker.flip_kick
|
||||
DROP COLUMN mom;
|
@ -87,17 +87,13 @@ CREATE TABLE maker.flip_kick (
|
||||
db_id integer NOT NULL,
|
||||
header_id integer NOT NULL,
|
||||
id numeric NOT NULL,
|
||||
vat character varying,
|
||||
ilk character varying,
|
||||
lot numeric,
|
||||
bid numeric,
|
||||
guy character varying,
|
||||
gal character varying,
|
||||
"end" timestamp with time zone,
|
||||
era timestamp with time zone,
|
||||
lad character varying,
|
||||
urn character varying,
|
||||
tab numeric,
|
||||
raw_log json
|
||||
raw_log jsonb
|
||||
);
|
||||
|
||||
|
||||
@ -200,12 +196,11 @@ ALTER SEQUENCE maker.price_feeds_id_seq OWNED BY maker.price_feeds.id;
|
||||
CREATE TABLE maker.tend (
|
||||
db_id integer NOT NULL,
|
||||
header_id integer NOT NULL,
|
||||
id numeric NOT NULL,
|
||||
bid_id numeric NOT NULL,
|
||||
lot numeric,
|
||||
bid numeric,
|
||||
guy bytea,
|
||||
guy character varying,
|
||||
tic numeric,
|
||||
era timestamp with time zone,
|
||||
tx_idx integer NOT NULL,
|
||||
raw_log jsonb
|
||||
);
|
||||
@ -766,11 +761,11 @@ ALTER TABLE ONLY maker.price_feeds
|
||||
|
||||
|
||||
--
|
||||
-- Name: tend tend_id_key; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
-- Name: tend tend_bid_id_key; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.tend
|
||||
ADD CONSTRAINT tend_id_key UNIQUE (id);
|
||||
ADD CONSTRAINT tend_bid_id_key UNIQUE (bid_id);
|
||||
|
||||
|
||||
--
|
||||
|
@ -17,7 +17,7 @@ package flip_kick
|
||||
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
|
||||
var FlipKickConfig = shared.TransformerConfig{
|
||||
ContractAddresses: "0x08cb6176addcca2e1d1ffe21bee464b72ee4cd8d", //this is a temporary address deployed locally
|
||||
ContractAddresses: shared.FlipperContractAddress,
|
||||
ContractAbi: shared.FlipperABI,
|
||||
Topics: []string{shared.FlipKickSignature},
|
||||
StartingBlockNumber: 0,
|
||||
|
File diff suppressed because one or more lines are too long
@ -17,7 +17,6 @@ package flip_kick
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
@ -45,7 +44,7 @@ func (FlipKickConverter) ToEntity(contractAddress string, contractAbi string, et
|
||||
|
||||
contract := bind.NewBoundContract(address, abi, nil, nil, nil)
|
||||
|
||||
err = contract.UnpackLog(entity, "FlipKick", ethLog)
|
||||
err = contract.UnpackLog(entity, "Kick", ethLog)
|
||||
if err != nil {
|
||||
return entity, err
|
||||
}
|
||||
@ -54,24 +53,17 @@ func (FlipKickConverter) ToEntity(contractAddress string, contractAbi string, et
|
||||
}
|
||||
|
||||
func (FlipKickConverter) ToModel(flipKick FlipKickEntity) (FlipKickModel, error) {
|
||||
//TODO: Confirm if the following values can be/ever will be nil
|
||||
|
||||
if flipKick.Id == nil {
|
||||
return FlipKickModel{}, errors.New("FlipKick log ID cannot be nil.")
|
||||
}
|
||||
|
||||
id := flipKick.Id.String()
|
||||
vat := strings.ToLower(flipKick.Vat.String())
|
||||
ilk := strings.ToLower(common.ToHex(flipKick.Ilk[:]))
|
||||
lot := utilities.ConvertNilToEmptyString(flipKick.Lot.String())
|
||||
bid := utilities.ConvertNilToEmptyString(flipKick.Bid.String())
|
||||
guy := strings.ToLower(flipKick.Guy.String())
|
||||
gal := strings.ToLower(flipKick.Gal.String())
|
||||
gal := flipKick.Gal.String()
|
||||
endValue := utilities.ConvertNilToZeroTimeValue(flipKick.End)
|
||||
end := time.Unix(endValue, 0)
|
||||
eraValue := utilities.ConvertNilToZeroTimeValue(flipKick.Era)
|
||||
era := time.Unix(eraValue, 0)
|
||||
lad := strings.ToLower(flipKick.Lad.String())
|
||||
urn := common.BytesToAddress(flipKick.Urn[:common.AddressLength]).String()
|
||||
tab := utilities.ConvertNilToEmptyString(flipKick.Tab.String())
|
||||
rawLogJson, err := json.Marshal(flipKick.Raw)
|
||||
if err != nil {
|
||||
@ -81,15 +73,11 @@ func (FlipKickConverter) ToModel(flipKick FlipKickEntity) (FlipKickModel, error)
|
||||
|
||||
return FlipKickModel{
|
||||
Id: id,
|
||||
Vat: vat,
|
||||
Ilk: ilk,
|
||||
Lot: lot,
|
||||
Bid: bid,
|
||||
Guy: guy,
|
||||
Gal: gal,
|
||||
End: end,
|
||||
Era: era,
|
||||
Lad: lad,
|
||||
Urn: urn,
|
||||
Tab: tab,
|
||||
Raw: rawLogString,
|
||||
}, nil
|
||||
|
@ -33,25 +33,21 @@ var _ = Describe("FlipKick Converter", func() {
|
||||
|
||||
Describe("ToEntity", func() {
|
||||
It("converts an Eth Log to a FlipKickEntity", func() {
|
||||
entity, err := converter.ToEntity(test_data.FlipAddress, shared.FlipperABI, test_data.EthFlipKickLog)
|
||||
entity, err := converter.ToEntity(shared.FlipperContractAddress, shared.FlipperABI, test_data.EthFlipKickLog)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(entity.Id).To(Equal(test_data.FlipKickEntity.Id))
|
||||
Expect(entity.Vat).To(Equal(test_data.FlipKickEntity.Vat))
|
||||
Expect(entity.Ilk).To(Equal(test_data.FlipKickEntity.Ilk))
|
||||
Expect(entity.Lot).To(Equal(test_data.FlipKickEntity.Lot))
|
||||
Expect(entity.Bid).To(Equal(test_data.FlipKickEntity.Bid))
|
||||
Expect(entity.Guy).To(Equal(test_data.FlipKickEntity.Guy))
|
||||
Expect(entity.Gal).To(Equal(test_data.FlipKickEntity.Gal))
|
||||
Expect(entity.End).To(Equal(test_data.FlipKickEntity.End))
|
||||
Expect(entity.Era).To(Equal(test_data.FlipKickEntity.Era))
|
||||
Expect(entity.Lad).To(Equal(test_data.FlipKickEntity.Lad))
|
||||
Expect(entity.Urn).To(Equal(test_data.FlipKickEntity.Urn))
|
||||
Expect(entity.Tab).To(Equal(test_data.FlipKickEntity.Tab))
|
||||
Expect(entity.Raw).To(Equal(test_data.FlipKickEntity.Raw))
|
||||
})
|
||||
|
||||
It("returns an error if converting log to entity fails", func() {
|
||||
_, err := converter.ToEntity(test_data.FlipAddress, "error abi", test_data.EthFlipKickLog)
|
||||
_, err := converter.ToEntity(shared.FlipperContractAddress, "error abi", test_data.EthFlipKickLog)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
})
|
||||
@ -59,7 +55,6 @@ var _ = Describe("FlipKick Converter", func() {
|
||||
|
||||
Describe("ToModel", func() {
|
||||
var emptyAddressHex = "0x0000000000000000000000000000000000000000"
|
||||
var emptyByteArrayHex = "0x0000000000000000000000000000000000000000000000000000000000000000"
|
||||
var emptyString = ""
|
||||
var emptyTime = time.Unix(0, 0)
|
||||
var emptyEntity = flip_kick.FlipKickEntity{}
|
||||
@ -87,15 +82,11 @@ var _ = Describe("FlipKick Converter", func() {
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(model.Id).To(Equal("1"))
|
||||
Expect(model.Vat).To(Equal(emptyAddressHex))
|
||||
Expect(model.Ilk).To(Equal(emptyByteArrayHex))
|
||||
Expect(model.Lot).To(Equal(emptyString))
|
||||
Expect(model.Bid).To(Equal(emptyString))
|
||||
Expect(model.Guy).To(Equal(emptyAddressHex))
|
||||
Expect(model.Gal).To(Equal(emptyAddressHex))
|
||||
Expect(model.End).To(Equal(emptyTime))
|
||||
Expect(model.Era).To(Equal(emptyTime))
|
||||
Expect(model.Lad).To(Equal(emptyAddressHex))
|
||||
Expect(model.Urn).To(Equal(emptyAddressHex))
|
||||
Expect(model.Tab).To(Equal(emptyString))
|
||||
Expect(model.Raw).To(Equal(emptyRawLog))
|
||||
})
|
||||
|
@ -23,15 +23,11 @@ import (
|
||||
|
||||
type FlipKickEntity struct {
|
||||
Id *big.Int
|
||||
Vat common.Address
|
||||
Ilk [32]byte
|
||||
Lot *big.Int
|
||||
Bid *big.Int
|
||||
Guy common.Address
|
||||
Gal common.Address
|
||||
End *big.Int
|
||||
Era *big.Int
|
||||
Lad common.Address
|
||||
Urn [32]byte
|
||||
Tab *big.Int
|
||||
Raw types.Log
|
||||
}
|
||||
|
@ -17,51 +17,18 @@ package flip_kick_test
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"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/transformers/flip_kick"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
)
|
||||
|
||||
var _ = Describe("Integration tests", func() {
|
||||
XIt("Fetches FlipKickEntity event logs from a local test chain", func() {
|
||||
ipcPath := test_config.TestClient.IPCPath
|
||||
|
||||
rawRpcClient, err := rpc.Dial(ipcPath)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
rpcClient := client.NewRpcClient(rawRpcClient, ipcPath)
|
||||
ethClient := ethclient.NewClient(rawRpcClient)
|
||||
blockChainClient := client.NewEthClient(ethClient)
|
||||
realNode := node.MakeNode(rpcClient)
|
||||
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
|
||||
realBlockChain := geth.NewBlockChain(blockChainClient, realNode, transactionConverter)
|
||||
realFetcher := shared.NewFetcher(realBlockChain)
|
||||
topic0 := common.HexToHash(shared.FlipKickSignature)
|
||||
topics := [][]common.Hash{{topic0}}
|
||||
|
||||
result, err := realFetcher.FetchLogs(test_data.FlipAddress, topics, test_data.FlipKickBlockNumber)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
Expect(len(result) > 0).To(BeTrue())
|
||||
Expect(result[0].Address).To(Equal(test_data.EthFlipKickLog.Address))
|
||||
Expect(result[0].TxHash).To(Equal(test_data.EthFlipKickLog.TxHash))
|
||||
Expect(result[0].BlockNumber).To(Equal(test_data.EthFlipKickLog.BlockNumber))
|
||||
Expect(result[0].Topics).To(Equal(test_data.EthFlipKickLog.Topics))
|
||||
Expect(result[0].Index).To(Equal(test_data.EthFlipKickLog.Index))
|
||||
})
|
||||
|
||||
It("unpacks an event log", func() {
|
||||
address := common.HexToAddress(test_data.FlipAddress)
|
||||
address := common.HexToAddress(shared.FlipperContractAddress)
|
||||
abi, err := geth.ParseAbi(shared.FlipperABI)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
@ -70,20 +37,16 @@ var _ = Describe("Integration tests", func() {
|
||||
|
||||
var eventLog = test_data.EthFlipKickLog
|
||||
|
||||
err = contract.UnpackLog(entity, "FlipKick", eventLog)
|
||||
err = contract.UnpackLog(entity, "Kick", eventLog)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
expectedEntity := test_data.FlipKickEntity
|
||||
Expect(entity.Id).To(Equal(expectedEntity.Id))
|
||||
Expect(entity.Vat).To(Equal(expectedEntity.Vat))
|
||||
Expect(entity.Ilk).To(Equal(expectedEntity.Ilk))
|
||||
Expect(entity.Lot).To(Equal(expectedEntity.Lot))
|
||||
Expect(entity.Bid).To(Equal(expectedEntity.Bid))
|
||||
Expect(entity.Guy).To(Equal(expectedEntity.Guy))
|
||||
Expect(entity.Gal).To(Equal(expectedEntity.Gal))
|
||||
Expect(entity.End).To(Equal(expectedEntity.End))
|
||||
Expect(entity.Era).To(Equal(expectedEntity.Era))
|
||||
Expect(entity.Lad).To(Equal(expectedEntity.Lad))
|
||||
Expect(entity.Urn).To(Equal(expectedEntity.Urn))
|
||||
Expect(entity.Tab).To(Equal(expectedEntity.Tab))
|
||||
})
|
||||
})
|
||||
|
@ -18,15 +18,11 @@ import "time"
|
||||
|
||||
type FlipKickModel struct {
|
||||
Id string
|
||||
Vat string
|
||||
Ilk string
|
||||
Lot string
|
||||
Bid string
|
||||
Guy string
|
||||
Gal string
|
||||
End time.Time
|
||||
Era time.Time
|
||||
Lad string
|
||||
Urn string
|
||||
Tab string
|
||||
Raw string `db:"raw_log"`
|
||||
}
|
||||
|
@ -35,9 +35,9 @@ func NewFlipKickRepository(db *postgres.DB) FlipKickRepository {
|
||||
}
|
||||
func (fkr FlipKickRepository) Create(headerId int64, flipKick FlipKickModel) error {
|
||||
_, err := fkr.DB.Exec(
|
||||
`INSERT into maker.flip_kick (header_id, id, vat, ilk, lot, bid, guy, gal, "end", era, lad, tab, raw_log)
|
||||
VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)`,
|
||||
headerId, flipKick.Id, flipKick.Vat, flipKick.Ilk, flipKick.Lot, flipKick.Bid, flipKick.Guy, flipKick.Gal, flipKick.End, flipKick.Era, flipKick.Lad, flipKick.Tab, flipKick.Raw,
|
||||
`INSERT into maker.flip_kick (header_id, id, lot, bid, gal, "end", urn, tab, raw_log)
|
||||
VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9)`,
|
||||
headerId, flipKick.Id, flipKick.Lot, flipKick.Bid, flipKick.Gal, flipKick.End, flipKick.Urn, flipKick.Tab, flipKick.Raw,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
@ -65,17 +65,13 @@ var _ = Describe("FlipKick Repository", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(dbResult.HeaderId).To(Equal(headerId))
|
||||
Expect(dbResult.Id).To(Equal(flipKick.Id))
|
||||
Expect(dbResult.Vat).To(Equal(flipKick.Vat))
|
||||
Expect(dbResult.Ilk).To(Equal(flipKick.Ilk))
|
||||
Expect(dbResult.Lot).To(Equal(flipKick.Lot))
|
||||
Expect(dbResult.Bid).To(Equal(flipKick.Bid))
|
||||
Expect(dbResult.Guy).To(Equal(flipKick.Guy))
|
||||
Expect(dbResult.Gal).To(Equal(flipKick.Gal))
|
||||
Expect(dbResult.End.Equal(flipKick.End)).To(BeTrue())
|
||||
Expect(dbResult.Era.Equal(flipKick.Era)).To(BeTrue())
|
||||
Expect(dbResult.Lad).To(Equal(flipKick.Lad))
|
||||
Expect(dbResult.Urn).To(Equal(flipKick.Urn))
|
||||
Expect(dbResult.Tab).To(Equal(flipKick.Tab))
|
||||
Expect(dbResult.Raw).To(Equal(flipKick.Raw))
|
||||
Expect(dbResult.Raw).To(MatchJSON(flipKick.Raw))
|
||||
})
|
||||
|
||||
It("returns an error if inserting the flip_kick record fails", func() {
|
||||
|
File diff suppressed because one or more lines are too long
@ -17,9 +17,9 @@ package tend
|
||||
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
|
||||
var TendConfig = shared.TransformerConfig{
|
||||
ContractAddresses: "0x08cb6176addcca2e1d1ffe21bee464b72ee4cd8d", //this is a temporary address deployed locally
|
||||
ContractAddresses: shared.FlipperContractAddress,
|
||||
ContractAbi: shared.FlipperABI,
|
||||
Topics: []string{shared.TendSignature},
|
||||
Topics: []string{shared.TendFunctionSignature},
|
||||
StartingBlockNumber: 0,
|
||||
EndingBlockNumber: 100,
|
||||
}
|
||||
|
@ -16,61 +16,37 @@ package tend
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"time"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/utilities"
|
||||
)
|
||||
|
||||
type Converter interface {
|
||||
ToEntity(contractAddress string, contractAbi string, ethLog types.Log) (TendEntity, error)
|
||||
ToModel(entity TendEntity) (TendModel, error)
|
||||
Convert(contractAddress string, contractAbi string, ethLog types.Log) (TendModel, error)
|
||||
}
|
||||
|
||||
type TendConverter struct{}
|
||||
|
||||
func (c TendConverter) ToEntity(contractAddress string, contractAbi string, ethLog types.Log) (TendEntity, error) {
|
||||
entity := TendEntity{}
|
||||
address := common.HexToAddress(contractAddress)
|
||||
abi, err := geth.ParseAbi(contractAbi)
|
||||
func (c TendConverter) Convert(contractAddress string, contractAbi string, ethLog types.Log) (TendModel, error) {
|
||||
entity := TendModel{}
|
||||
entity.Guy = common.HexToAddress(ethLog.Topics[1].Hex()).String()
|
||||
entity.BidId = ethLog.Topics[2].Big().String()
|
||||
entity.Lot = ethLog.Topics[3].Big().String()
|
||||
|
||||
if err != nil {
|
||||
return entity, err
|
||||
}
|
||||
itemByteLength := 32
|
||||
lastDataItemStartIndex := len(ethLog.Data) - itemByteLength
|
||||
lastItem := ethLog.Data[lastDataItemStartIndex:]
|
||||
last := big.NewInt(0).SetBytes(lastItem)
|
||||
entity.Bid = last.String()
|
||||
|
||||
contract := bind.NewBoundContract(address, abi, nil, nil, nil)
|
||||
err = contract.UnpackLog(&entity, "Tend", ethLog)
|
||||
if err != nil {
|
||||
return entity, err
|
||||
}
|
||||
entity.Tic = "0" //TODO: how do we get the bid tic?
|
||||
entity.TransactionIndex = ethLog.TxIndex
|
||||
entity.Raw = ethLog
|
||||
return entity, nil
|
||||
}
|
||||
|
||||
func (c TendConverter) ToModel(entity TendEntity) (TendModel, error) {
|
||||
if entity.Id == nil {
|
||||
return TendModel{}, errors.New("Tend log ID cannot be nil.")
|
||||
}
|
||||
|
||||
rawJson, err := json.Marshal(entity.Raw)
|
||||
rawJson, err := json.Marshal(ethLog)
|
||||
if err != nil {
|
||||
return TendModel{}, err
|
||||
}
|
||||
era := utilities.ConvertNilToZeroTimeValue(entity.Era)
|
||||
return TendModel{
|
||||
Id: utilities.ConvertNilToEmptyString(entity.Id.String()),
|
||||
Lot: utilities.ConvertNilToEmptyString(entity.Lot.String()),
|
||||
Bid: utilities.ConvertNilToEmptyString(entity.Bid.String()),
|
||||
Guy: entity.Guy[:],
|
||||
Tic: utilities.ConvertNilToEmptyString(entity.Tic.String()),
|
||||
Era: time.Unix(era, 0),
|
||||
TransactionIndex: entity.TransactionIndex,
|
||||
Raw: string(rawJson),
|
||||
}, nil
|
||||
|
||||
entity.Raw = string(rawJson)
|
||||
return entity, err
|
||||
}
|
||||
|
@ -15,11 +15,6 @@
|
||||
package tend_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
@ -30,74 +25,16 @@ import (
|
||||
|
||||
var _ = Describe("Tend TendConverter", func() {
|
||||
var converter tend.TendConverter
|
||||
var emptyEntity tend.TendEntity
|
||||
var testEntity tend.TendEntity
|
||||
|
||||
BeforeEach(func() {
|
||||
converter = tend.TendConverter{}
|
||||
emptyEntity = tend.TendEntity{}
|
||||
testEntity = test_data.TendEntity
|
||||
})
|
||||
|
||||
Describe("ToEntity", func() {
|
||||
It("converts a log to an entity", func() {
|
||||
entity, err := converter.ToEntity(test_data.FlipAddress, shared.FlipperABI, test_data.TendLog)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(entity).To(Equal(testEntity))
|
||||
})
|
||||
|
||||
It("returns an error if there is a failure in parsing the abi", func() {
|
||||
malformedAbi := "bad"
|
||||
entity, err := converter.ToEntity(test_data.FlipAddress, malformedAbi, test_data.TendLog)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("invalid abi"))
|
||||
Expect(entity).To(Equal(emptyEntity))
|
||||
})
|
||||
|
||||
It("returns an error if there is a failure unpacking the log", func() {
|
||||
incompleteAbi := "[{}]"
|
||||
entity, err := converter.ToEntity(test_data.FlipAddress, incompleteAbi, test_data.TendLog)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring("abi: could not locate"))
|
||||
Expect(entity).To(Equal(emptyEntity))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("ToModel", func() {
|
||||
It("converts an entity to a model", func() {
|
||||
model, err := converter.ToModel(testEntity)
|
||||
|
||||
Describe("Convert", func() {
|
||||
It("converts an eth log to a db model", func() {
|
||||
model, err := converter.Convert(shared.FlipperContractAddress, shared.FlipperABI, test_data.TendLogNote)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(model).To(Equal(test_data.TendModel))
|
||||
})
|
||||
|
||||
It("handles nil values", func() {
|
||||
emptyEntity.Id = big.NewInt(1)
|
||||
emptyLog, err := json.Marshal(types.Log{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
expectedModel := tend.TendModel{
|
||||
Id: "1",
|
||||
Lot: "",
|
||||
Bid: "",
|
||||
Guy: []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
Tic: "",
|
||||
Era: time.Unix(0, 0),
|
||||
Raw: string(emptyLog),
|
||||
}
|
||||
model, err := converter.ToModel(emptyEntity)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(model).To(Equal(expectedModel))
|
||||
})
|
||||
|
||||
It("returns an error if the log Id is nil", func() {
|
||||
model, err := converter.ToModel(emptyEntity)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(model).To(Equal(tend.TendModel{}))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -1,33 +0,0 @@
|
||||
// Copyright 2018 Vulcanize
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package tend
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
)
|
||||
|
||||
type TendEntity struct {
|
||||
Id *big.Int
|
||||
Lot *big.Int
|
||||
Bid *big.Int
|
||||
Guy common.Address
|
||||
Tic *big.Int
|
||||
Era *big.Int
|
||||
TransactionIndex uint
|
||||
Raw types.Log
|
||||
}
|
@ -15,7 +15,6 @@
|
||||
package tend_test
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/ethclient"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
@ -27,14 +26,13 @@ import (
|
||||
rpc2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth/node"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/tend"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
)
|
||||
|
||||
// These test are pending either being able to emit a Tend event on a Ganache test chain or until the contracts are deployed to Kovan.
|
||||
var _ = XDescribe("Integration tests", func() {
|
||||
It("Fetches Tend event logs from a local test chain", func() {
|
||||
// These test are marked as pending until the Flip contract is deployed to Kovan.
|
||||
var _ = Describe("Integration tests", func() {
|
||||
XIt("Fetches Tend event logs from a local test chain", func() {
|
||||
ipcPath := test_config.TestClient.IPCPath
|
||||
|
||||
rawRpcClient, err := rpc.Dial(ipcPath)
|
||||
@ -47,10 +45,10 @@ var _ = XDescribe("Integration tests", func() {
|
||||
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
|
||||
realBlockChain := geth.NewBlockChain(blockChainClient, realNode, transactionConverter)
|
||||
realFetcher := shared.NewFetcher(realBlockChain)
|
||||
topic0 := common.HexToHash(shared.TendSignature)
|
||||
topic0 := common.HexToHash(shared.TendFunctionSignature)
|
||||
topics := [][]common.Hash{{topic0}}
|
||||
|
||||
result, err := realFetcher.FetchLogs(test_data.FlipAddress, topics, test_data.FlipKickBlockNumber)
|
||||
result, err := realFetcher.FetchLogs(shared.FlipperContractAddress, topics, test_data.FlipKickBlockNumber)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
Expect(len(result) > 0).To(BeTrue())
|
||||
@ -60,27 +58,4 @@ var _ = XDescribe("Integration tests", func() {
|
||||
Expect(result[0].Topics).To(Equal(test_data.EthFlipKickLog.Topics))
|
||||
Expect(result[0].Index).To(Equal(test_data.EthFlipKickLog.Index))
|
||||
})
|
||||
|
||||
It("unpacks an event log", func() {
|
||||
address := common.HexToAddress(test_data.FlipAddress)
|
||||
abi, err := geth.ParseAbi(shared.FlipperABI)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
contract := bind.NewBoundContract(address, abi, nil, nil, nil)
|
||||
entity := tend.TendEntity{}
|
||||
|
||||
var eventLog = test_data.TendLog
|
||||
|
||||
err = contract.UnpackLog(&entity, "Tend", eventLog)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
expectedEntity := test_data.TendEntity
|
||||
Expect(entity.Id).To(Equal(expectedEntity.Id))
|
||||
Expect(entity.Lot).To(Equal(expectedEntity.Lot))
|
||||
Expect(entity.Bid).To(Equal(expectedEntity.Bid))
|
||||
Expect(entity.Guy).To(Equal(expectedEntity.Guy))
|
||||
Expect(entity.Tic).To(Equal(expectedEntity.Tic))
|
||||
Expect(entity.Era).To(Equal(expectedEntity.Era))
|
||||
Expect(entity.Raw).To(Equal(expectedEntity.Raw))
|
||||
})
|
||||
})
|
||||
|
@ -14,17 +14,12 @@
|
||||
|
||||
package tend
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type TendModel struct {
|
||||
Id string
|
||||
BidId string `db:"bid_id"`
|
||||
Lot string
|
||||
Bid string
|
||||
Guy []byte
|
||||
Guy string
|
||||
Tic string
|
||||
Era time.Time
|
||||
TransactionIndex uint `db:"tx_idx"`
|
||||
Raw string `db:"raw_log"`
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ func NewTendRepository(db *postgres.DB) TendRepository {
|
||||
|
||||
func (r TendRepository) Create(headerId int64, tend TendModel) error {
|
||||
_, err := r.DB.Exec(
|
||||
`INSERT into maker.tend (header_id, id, lot, bid, guy, tic, era, tx_idx, raw_log)
|
||||
VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9)`,
|
||||
headerId, tend.Id, tend.Lot, tend.Bid, tend.Guy, tend.Tic, tend.Era, tend.TransactionIndex, tend.Raw,
|
||||
`INSERT into maker.tend (header_id, bid_id, lot, bid, guy, tic, tx_idx, raw_log)
|
||||
VALUES($1, $2, $3, $4, $5, $6, $7, $8)`,
|
||||
headerId, tend.BidId, tend.Lot, tend.Bid, tend.Guy, tend.Tic, tend.TransactionIndex, tend.Raw,
|
||||
)
|
||||
|
||||
return err
|
||||
|
@ -58,17 +58,16 @@ var _ = Describe("TendRepository", func() {
|
||||
Expect(count).To(Equal(1))
|
||||
|
||||
dbResult := tend.TendModel{}
|
||||
err = db.Get(&dbResult, `SELECT id, lot, bid, guy, tic, era, tx_idx, raw_log FROM maker.tend WHERE header_id = $1`, headerId)
|
||||
err = db.Get(&dbResult, `SELECT bid_id, lot, bid, guy, tic, tx_idx, raw_log FROM maker.tend WHERE header_id = $1`, headerId)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
Expect(dbResult.Id).To(Equal(test_data.TendModel.Id))
|
||||
Expect(dbResult.BidId).To(Equal(test_data.TendModel.BidId))
|
||||
Expect(dbResult.Lot).To(Equal(test_data.TendModel.Lot))
|
||||
Expect(dbResult.Bid).To(Equal(test_data.TendModel.Bid))
|
||||
Expect(dbResult.Guy).To(Equal(test_data.TendModel.Guy))
|
||||
Expect(dbResult.Tic).To(Equal(test_data.TendModel.Tic))
|
||||
Expect(dbResult.Era.Equal(test_data.TendModel.Era)).To(BeTrue())
|
||||
Expect(dbResult.TransactionIndex).To(Equal(test_data.TendModel.TransactionIndex))
|
||||
Expect(dbResult.Raw).To(MatchJSON(test_data.RawJson))
|
||||
Expect(dbResult.Raw).To(MatchJSON(test_data.RawLogNoteJson))
|
||||
})
|
||||
|
||||
It("returns an error if inserting a tend record fails", func() {
|
||||
@ -111,7 +110,7 @@ var _ = Describe("TendRepository", func() {
|
||||
outOfRangeBlockNumber = tendBlockNumber + 2
|
||||
})
|
||||
|
||||
It("returns headers for which there isn't an associated flip_kick record", func() {
|
||||
It("returns headers for which there isn't an associated tend record", func() {
|
||||
var headerIds []int64
|
||||
|
||||
for _, number := range []int64{startingBlockNumber, tendBlockNumber, endingBlockNumber, outOfRangeBlockNumber} {
|
||||
|
@ -50,7 +50,7 @@ func (i TendTransformerInitializer) NewTendTransformer(db *postgres.DB, blockCha
|
||||
|
||||
func (t TendTransformer) Execute() error {
|
||||
config := t.Config
|
||||
topics := [][]common.Hash{{common.HexToHash(shared.TendSignature)}}
|
||||
topics := [][]common.Hash{{common.HexToHash(shared.TendFunctionSignature)}}
|
||||
|
||||
missingHeaders, err := t.Repository.MissingHeaders(config.StartingBlockNumber, config.EndingBlockNumber)
|
||||
if err != nil {
|
||||
@ -66,8 +66,7 @@ func (t TendTransformer) Execute() error {
|
||||
}
|
||||
|
||||
for _, ethLog := range ethLogs {
|
||||
entity, err := t.Converter.ToEntity(config.ContractAddresses, config.ContractAbi, ethLog)
|
||||
model, err := t.Converter.ToModel(entity)
|
||||
model, err := t.Converter.Convert(config.ContractAddresses, config.ContractAbi, ethLog)
|
||||
if err != nil {
|
||||
log.Println("Error converting logs:", err)
|
||||
return err
|
||||
|
@ -69,13 +69,13 @@ var _ = Describe("Tend Transformer", func() {
|
||||
|
||||
It("fetches eth logs for each missing header", func() {
|
||||
repository.SetMissingHeaders([]core.Header{{BlockNumber: blockNumber1}, {BlockNumber: blockNumber2}})
|
||||
expectedTopics := [][]common.Hash{{common.HexToHash(shared.TendSignature)}}
|
||||
expectedTopics := [][]common.Hash{{common.HexToHash(shared.TendFunctionSignature)}}
|
||||
err := transformer.Execute()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(fetcher.FetchedBlocks).To(Equal([]int64{blockNumber1, blockNumber2}))
|
||||
Expect(fetcher.FetchedTopics).To(Equal(expectedTopics))
|
||||
Expect(fetcher.FetchedContractAddress).To(Equal(test_data.FlipAddress))
|
||||
Expect(fetcher.FetchedContractAddress).To(Equal(shared.FlipperContractAddress))
|
||||
})
|
||||
|
||||
It("returns an error if fetching logs fails", func() {
|
||||
@ -87,40 +87,30 @@ var _ = Describe("Tend Transformer", func() {
|
||||
Expect(err).To(MatchError(fakes.FakeError))
|
||||
})
|
||||
|
||||
It("converts an eth log to an Entity", func() {
|
||||
It("converts an eth log to an Model", func() {
|
||||
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}})
|
||||
fetcher.SetFetchedLogs([]types.Log{test_data.TendLog})
|
||||
fetcher.SetFetchedLogs([]types.Log{test_data.TendLogNote})
|
||||
err := transformer.Execute()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(converter.ConverterContract).To(Equal(tend.TendConfig.ContractAddresses))
|
||||
Expect(converter.ConverterAbi).To(Equal(tend.TendConfig.ContractAbi))
|
||||
Expect(converter.LogsToConvert).To(Equal([]types.Log{test_data.TendLog}))
|
||||
Expect(converter.LogsToConvert).To(Equal([]types.Log{test_data.TendLogNote}))
|
||||
})
|
||||
|
||||
It("returns an error if converter fails", func() {
|
||||
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}})
|
||||
fetcher.SetFetchedLogs([]types.Log{test_data.TendLog})
|
||||
fetcher.SetFetchedLogs([]types.Log{test_data.TendLogNote})
|
||||
converter.SetConverterError(fakes.FakeError)
|
||||
err := transformer.Execute()
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(fakes.FakeError))
|
||||
})
|
||||
|
||||
It("returns an error if converter fails", func() {
|
||||
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}})
|
||||
fetcher.SetFetchedLogs([]types.Log{test_data.TendLog})
|
||||
err := transformer.Execute()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(converter.EntitiesToConvert).To(ContainElement(test_data.TendEntity))
|
||||
})
|
||||
|
||||
It("persists the tend record", func() {
|
||||
headerId := int64(1)
|
||||
repository.SetMissingHeaders([]core.Header{{BlockNumber: blockNumber1, Id: headerId}})
|
||||
fetcher.SetFetchedLogs([]types.Log{test_data.TendLog})
|
||||
fetcher.SetFetchedLogs([]types.Log{test_data.TendLogNote})
|
||||
|
||||
err := transformer.Execute()
|
||||
|
||||
@ -131,7 +121,7 @@ var _ = Describe("Tend Transformer", func() {
|
||||
|
||||
It("returns error if persisting tend record fails", func() {
|
||||
repository.SetMissingHeaders([]core.Header{{BlockNumber: blockNumber1}})
|
||||
fetcher.SetFetchedLogs([]types.Log{test_data.TendLog})
|
||||
fetcher.SetFetchedLogs([]types.Log{test_data.TendLogNote})
|
||||
repository.SetCreateError(fakes.FakeError)
|
||||
err := transformer.Execute()
|
||||
|
||||
|
@ -1,27 +0,0 @@
|
||||
// Copyright 2018 Vulcanize
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package test_data
|
||||
|
||||
var (
|
||||
FlipAddress = "0x08cb6176addcca2e1d1ffe21bee464b72ee4cd8d"
|
||||
FlipKickTransactionHash = "0x6b155a55fd77b751195deeebf7abfd8691ca01ee588817a920f19d5b27f65191"
|
||||
FlipKickData = "0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000038219779a699d67d7e7740b8c8f43d3e2dae218266616b6520696c6b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a09200000000000000000000000007fa9ef6609ca7921112231f8f195138ebba2977000000000000000000000000000000000000000000000000000000005b8063b7000000000000000000000000000000000000000000000000000000005b7729370000000000000000000000007340e006f4135ba6970d43bf43d88dcad4e7a8ca0000000000000000000000000000000000000000000000000000000000000032"
|
||||
FlipKickBlockHash = "0x32f8b12023b3a1b4c73f9a46da976931b0355714ada8b8044ebcb2cd295751a9"
|
||||
FlipKickBlockNumber = int64(10)
|
||||
TendData = "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000003200000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a0920000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005b6db414"
|
||||
TendTransactionHash = "0xadeddf804e0fef88b6145807df063c538c9942df2725a0458a084900c0fbf5e9"
|
||||
TendBlockHash = "0xdd6238b841c8cf4d91b05da7540b7f0851176fcc8477cdc4b75c93e28dfe0a88"
|
||||
TendBlockNumber = int64(11)
|
||||
)
|
@ -27,62 +27,64 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
)
|
||||
|
||||
var idString = "1"
|
||||
var id, _ = new(big.Int).SetString(idString, 10)
|
||||
var vat = "0x38219779a699d67d7e7740b8c8f43d3e2dae2182"
|
||||
var ilk = [32]byte{102, 97, 107, 101, 32, 105, 108, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
var lotString = "100"
|
||||
var lot, _ = new(big.Int).SetString(lotString, 10)
|
||||
var bidString = "0"
|
||||
var bid = new(big.Int).SetBytes([]byte{0})
|
||||
var guy = "0x64d922894153be9eef7b7218dc565d1d0ce2a092"
|
||||
var gal = "0x07fa9ef6609ca7921112231f8f195138ebba2977"
|
||||
var end = int64(1535140791)
|
||||
var era = int64(1534535991)
|
||||
var lad = "0x7340e006f4135ba6970d43bf43d88dcad4e7a8ca"
|
||||
var tabString = "50"
|
||||
var tab, _ = new(big.Int).SetString(tabString, 10)
|
||||
var rawLogJson, _ = json.Marshal(EthFlipKickLog)
|
||||
var rawLogString = string(rawLogJson)
|
||||
var (
|
||||
idString = "1"
|
||||
id, _ = new(big.Int).SetString(idString, 10)
|
||||
lotString = "100"
|
||||
lot, _ = new(big.Int).SetString(lotString, 10)
|
||||
bidString = "0"
|
||||
bid = new(big.Int).SetBytes([]byte{0})
|
||||
gal = "0x07Fa9eF6609cA7921112231F8f195138ebbA2977"
|
||||
end = int64(1535991025)
|
||||
urn = [32]byte{115, 64, 224, 6, 244, 19, 91, 166, 151, 13, 67, 191, 67, 216, 141, 202, 212, 231, 168, 202, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
urnString = "0x7340e006f4135BA6970D43bf43d88DCAD4e7a8CA"
|
||||
tabString = "50"
|
||||
tab, _ = new(big.Int).SetString(tabString, 10)
|
||||
rawLogJson, _ = json.Marshal(EthFlipKickLog)
|
||||
rawLogString = string(rawLogJson)
|
||||
)
|
||||
|
||||
var (
|
||||
flipKickTransactionHash = "0xd11ab35cfb1ad71f790d3dd488cc1a2046080e765b150e8997aa0200947d4a9b"
|
||||
flipKickData = "0x0000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007fa9ef6609ca7921112231f8f195138ebba2977000000000000000000000000000000000000000000000000000000005b8d5cf10000000000000000000000000000000000000000000000000000000000000032"
|
||||
flipKickBlockHash = "0x40fcad7863ab4bef421d638b7ad6116e81577f14a62ef847b07f8527944466fd"
|
||||
FlipKickBlockNumber = int64(10)
|
||||
)
|
||||
|
||||
var EthFlipKickLog = types.Log{
|
||||
Address: common.HexToAddress(FlipAddress),
|
||||
Topics: []common.Hash{common.HexToHash(shared.FlipKickSignature)},
|
||||
Data: hexutil.MustDecode(FlipKickData),
|
||||
Address: common.HexToAddress(shared.FlipperContractAddress),
|
||||
Topics: []common.Hash{
|
||||
common.HexToHash(shared.FlipKickSignature),
|
||||
common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000001"),
|
||||
common.HexToHash("0x7340e006f4135ba6970d43bf43d88dcad4e7a8ca000000000000000000000000"),
|
||||
},
|
||||
Data: hexutil.MustDecode(flipKickData),
|
||||
BlockNumber: uint64(FlipKickBlockNumber),
|
||||
TxHash: common.HexToHash(FlipKickTransactionHash),
|
||||
TxHash: common.HexToHash(flipKickTransactionHash),
|
||||
TxIndex: 0,
|
||||
BlockHash: common.HexToHash(FlipKickBlockHash),
|
||||
BlockHash: common.HexToHash(flipKickBlockHash),
|
||||
Index: 0,
|
||||
Removed: false,
|
||||
}
|
||||
|
||||
var FlipKickEntity = flip_kick.FlipKickEntity{
|
||||
Id: id,
|
||||
Vat: common.HexToAddress(vat),
|
||||
Ilk: ilk,
|
||||
Lot: lot,
|
||||
Bid: bid,
|
||||
Guy: common.HexToAddress(guy),
|
||||
Gal: common.HexToAddress(gal),
|
||||
End: big.NewInt(end),
|
||||
Era: big.NewInt(era),
|
||||
Lad: common.HexToAddress(lad),
|
||||
Urn: urn,
|
||||
Tab: tab,
|
||||
Raw: EthFlipKickLog,
|
||||
}
|
||||
|
||||
var FlipKickModel = flip_kick.FlipKickModel{
|
||||
Id: idString,
|
||||
Vat: vat,
|
||||
Ilk: "0x" + common.Bytes2Hex(ilk[:]),
|
||||
Lot: lotString,
|
||||
Bid: bidString,
|
||||
Guy: guy,
|
||||
Gal: gal,
|
||||
End: time.Unix(end, 0),
|
||||
Era: time.Unix(era, 0),
|
||||
Lad: lad,
|
||||
Urn: urnString,
|
||||
Tab: tabString,
|
||||
Raw: rawLogString,
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ var (
|
||||
frobLad = [32]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 217, 34, 137, 65, 83, 190, 158, 239, 123, 114, 24, 220, 86, 93, 29, 12, 226, 160, 146}
|
||||
gem, _ = big.NewInt(0).SetString("115792089237316195423570985008687907853269984665640564039457584007913129639926", 10)
|
||||
ink = big.NewInt(15)
|
||||
ilk = [32]byte{102, 97, 107, 101, 32, 105, 108, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
)
|
||||
|
||||
var EthFrobLog = types.Log{
|
||||
|
@ -16,6 +16,7 @@ package flip_kick
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/flip_kick"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
)
|
||||
|
@ -25,19 +25,13 @@ type MockTendConverter struct {
|
||||
ConverterContract string
|
||||
ConverterAbi string
|
||||
LogsToConvert []types.Log
|
||||
EntitiesToConvert []tend.TendEntity
|
||||
ConverterError error
|
||||
}
|
||||
|
||||
func (c *MockTendConverter) ToEntity(contractAddress string, contractAbi string, ethLog types.Log) (tend.TendEntity, error) {
|
||||
func (c *MockTendConverter) Convert(contractAddress string, contractAbi string, ethLog types.Log) (tend.TendModel, error) {
|
||||
c.ConverterContract = contractAddress
|
||||
c.ConverterAbi = contractAbi
|
||||
c.LogsToConvert = append(c.LogsToConvert, ethLog)
|
||||
return test_data.TendEntity, c.ConverterError
|
||||
}
|
||||
|
||||
func (c *MockTendConverter) ToModel(entity tend.TendEntity) (tend.TendModel, error) {
|
||||
c.EntitiesToConvert = append(c.EntitiesToConvert, entity)
|
||||
return test_data.TendModel, c.ConverterError
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@ import (
|
||||
"encoding/json"
|
||||
"math/big"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
@ -28,45 +27,41 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/tend"
|
||||
)
|
||||
|
||||
var tendLot = big.NewInt(100)
|
||||
var tendBid = big.NewInt(50)
|
||||
var tendGuy = common.HexToAddress("0x64d922894153be9eef7b7218dc565d1d0ce2a092")
|
||||
var tic = new(big.Int).SetBytes([]byte{0})
|
||||
var tendEra = big.NewInt(1533916180)
|
||||
var RawJson, _ = json.Marshal(TendLog)
|
||||
var rawString = string(RawJson)
|
||||
var (
|
||||
tendId = int64(10)
|
||||
tendLot = "85000000000000000000"
|
||||
tendBid = "1000000000000000000"
|
||||
tendGuy = "0x7d7bEe5fCfD8028cf7b00876C5b1421c800561A6"
|
||||
tic = new(big.Int).SetBytes([]byte{0})
|
||||
tendData = "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000644b43ed12000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000049b9ca9a6943400000000000000000000000000000000000000000000000000000de0b6b3a7640000"
|
||||
tendTransactionHash = "0x7909c8793ded2b8348f5db623044fbc26bb7ab78ad5792897abdf68ddc1df63d"
|
||||
tendBlockHash = "0xa8ea87147c0a68daeb6b1d9f8c0937ba975a650809cab80d19c969e8d0df452c"
|
||||
)
|
||||
|
||||
var TendLog = types.Log{
|
||||
Address: common.HexToAddress(FlipAddress),
|
||||
Topics: []common.Hash{common.HexToHash(shared.TendSignature)},
|
||||
Data: hexutil.MustDecode(TendData),
|
||||
BlockNumber: uint64(TendBlockNumber),
|
||||
TxHash: common.HexToHash(TendTransactionHash),
|
||||
TxIndex: 1,
|
||||
BlockHash: common.HexToHash(TendBlockHash),
|
||||
Index: 0,
|
||||
var TendLogNote = types.Log{
|
||||
Address: common.StringToAddress(shared.FlipperContractAddress),
|
||||
Topics: []common.Hash{
|
||||
common.HexToHash("0x4b43ed1200000000000000000000000000000000000000000000000000000000"), //abbreviated tend function signature
|
||||
common.HexToHash("0x0000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6"), //msg caller address
|
||||
common.HexToHash("0x000000000000000000000000000000000000000000000000000000000000000a"), //first param of the function called (i.e. flip kick id)
|
||||
common.HexToHash("0x0000000000000000000000000000000000000000000000049b9ca9a694340000"), //second param of the function called (i.e. lot)
|
||||
},
|
||||
Data: hexutil.MustDecode(tendData),
|
||||
BlockNumber: 11,
|
||||
TxHash: common.HexToHash(tendTransactionHash),
|
||||
TxIndex: 10,
|
||||
BlockHash: common.HexToHash(tendBlockHash),
|
||||
Index: 1,
|
||||
Removed: false,
|
||||
}
|
||||
var RawLogNoteJson, _ = json.Marshal(TendLogNote)
|
||||
|
||||
var tendId = int64(1)
|
||||
var TendEntity = tend.TendEntity{
|
||||
Id: big.NewInt(tendId),
|
||||
var TendModel = tend.TendModel{
|
||||
BidId: strconv.FormatInt(tendId, 10),
|
||||
Lot: tendLot,
|
||||
Bid: tendBid,
|
||||
Guy: tendGuy,
|
||||
Tic: tic,
|
||||
Era: tendEra,
|
||||
TransactionIndex: TendLog.TxIndex,
|
||||
Raw: TendLog,
|
||||
}
|
||||
|
||||
var TendModel = tend.TendModel{
|
||||
Id: strconv.FormatInt(tendId, 10),
|
||||
Lot: tendLot.String(),
|
||||
Bid: tendBid.String(),
|
||||
Guy: tendGuy[:],
|
||||
Tic: tic.String(),
|
||||
Era: time.Unix(tendEra.Int64(), 0),
|
||||
TransactionIndex: TendLog.TxIndex,
|
||||
Raw: rawString,
|
||||
TransactionIndex: TendLogNote.TxIndex,
|
||||
Raw: string(RawLogNoteJson),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user