Add transformers for Cat file events
- transform logs from 3 implementations of file on the Cat contract
This commit is contained in:
@@ -64,7 +64,7 @@ var EthBiteLog = types.Log{
|
||||
var BiteEntity = bite.BiteEntity{
|
||||
Id: big.NewInt(biteId),
|
||||
Ilk: biteIlk,
|
||||
Lad: biteLad,
|
||||
Urn: biteLad,
|
||||
Ink: biteInk,
|
||||
Art: biteArt,
|
||||
Tab: biteTab,
|
||||
@@ -77,7 +77,7 @@ var BiteEntity = bite.BiteEntity{
|
||||
var BiteModel = bite.BiteModel{
|
||||
Id: strconv.FormatInt(biteId, 10),
|
||||
Ilk: biteIlk[:],
|
||||
Lad: biteLad[:],
|
||||
Urn: biteLad[:],
|
||||
Ink: biteInk.String(),
|
||||
Art: biteArt.String(),
|
||||
Tab: biteTab.String(),
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
// 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
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/chop_lump"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/flip"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/pit_vow"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
var EthCatFileChopLumpLog = types.Log{
|
||||
Address: common.HexToAddress(shared.CatContractAddress),
|
||||
Topics: []common.Hash{
|
||||
common.HexToHash("0x1a0b287e00000000000000000000000000000000000000000000000000000000"),
|
||||
common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"),
|
||||
common.HexToHash("0x66616b6520696c6b000000000000000000000000000000000000000000000000"),
|
||||
common.HexToHash("0x63686f7000000000000000000000000000000000000000000000000000000000"),
|
||||
},
|
||||
Data: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000641a0b287e66616b6520696c6b00000000000000000000000000000000000000000000000063686f700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000075bcd15"),
|
||||
BlockNumber: 110,
|
||||
TxHash: common.HexToHash("0xe32dfe6afd7ea28475569756fc30f0eea6ad4cfd32f67436ff1d1c805e4382df"),
|
||||
TxIndex: 13,
|
||||
BlockHash: common.HexToHash("0x2764998a4e048d4c4ba45ea40fd5efaa8e2d4f1dd2b15425a6c6a3dea7f1064a"),
|
||||
Index: 0,
|
||||
Removed: false,
|
||||
}
|
||||
|
||||
var rawCatFileChopLumpLog, _ = json.Marshal(EthCatFileChopLumpLog)
|
||||
var CatFileChopLumpModel = chop_lump.CatFileChopLumpModel{
|
||||
Ilk: "fake ilk",
|
||||
What: "chop",
|
||||
Data: big.NewInt(123456789).String(),
|
||||
TransactionIndex: EthCatFileChopLumpLog.TxIndex,
|
||||
Raw: rawCatFileChopLumpLog,
|
||||
}
|
||||
|
||||
var EthCatFileFlipLog = types.Log{
|
||||
Address: common.HexToAddress(shared.CatContractAddress),
|
||||
Topics: []common.Hash{
|
||||
common.HexToHash("0xebecb39d00000000000000000000000000000000000000000000000000000000"),
|
||||
common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"),
|
||||
common.HexToHash("0x66616b6520696c6b000000000000000000000000000000000000000000000000"),
|
||||
common.HexToHash("0x666c697000000000000000000000000000000000000000000000000000000000"),
|
||||
},
|
||||
Data: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000064ebecb39d66616b6520696c6b000000000000000000000000000000000000000000000000666c69700000000000000000000000000000000000000000000000000000000000000000000000000000000007fa9ef6609ca7921112231f8f195138ebba2977"),
|
||||
BlockNumber: 88,
|
||||
TxHash: common.HexToHash("0xc71ef3e9999595913d31e89446cab35319bd4289520e55611a1b42fc2a8463b6"),
|
||||
TxIndex: 12,
|
||||
BlockHash: common.HexToHash("0xe5fcc1b65dd901e003e3768c1d4ce58d72f5f3a31e6a5d27d9cbdc7dca4bb405"),
|
||||
Index: 0,
|
||||
Removed: false,
|
||||
}
|
||||
|
||||
var rawCatFileFlipLog, _ = json.Marshal(EthCatFileFlipLog)
|
||||
var CatFileFlipModel = flip.CatFileFlipModel{
|
||||
Ilk: "fake ilk",
|
||||
What: "flip",
|
||||
Flip: "0x07Fa9eF6609cA7921112231F8f195138ebbA2977",
|
||||
TransactionIndex: EthCatFileFlipLog.TxIndex,
|
||||
Raw: rawCatFileFlipLog,
|
||||
}
|
||||
|
||||
var EthCatFilePitVowLog = types.Log{
|
||||
Address: common.HexToAddress(shared.CatContractAddress),
|
||||
Topics: []common.Hash{
|
||||
common.HexToHash("0xd4e8be8300000000000000000000000000000000000000000000000000000000"),
|
||||
common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"),
|
||||
common.HexToHash("0x7069740000000000000000000000000000000000000000000000000000000000"),
|
||||
common.HexToHash("0x0000000000000000000000008e84a1e068d77059cbe263c43ad0cdc130863313"),
|
||||
},
|
||||
Data: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000044d4e8be8370697400000000000000000000000000000000000000000000000000000000000000000000000000000000008e84a1e068d77059cbe263c43ad0cdc130863313"),
|
||||
BlockNumber: 87,
|
||||
TxHash: common.HexToHash("0x6515c7dfe53f0ad83ce1173fa99032c24a07cfd8b5d5a1c1f80486c99dd52800"),
|
||||
TxIndex: 11,
|
||||
BlockHash: common.HexToHash("0xae75936bc6b6a3383e8c991686747ef2221984b0ec8a5d4a6350989ec0ddbd67"),
|
||||
Index: 0,
|
||||
Removed: false,
|
||||
}
|
||||
|
||||
var rawCatFilePitVowLog, _ = json.Marshal(EthCatFilePitVowLog)
|
||||
var CatFilePitVowModel = pit_vow.CatFilePitVowModel{
|
||||
What: "pit",
|
||||
Data: "0x8E84a1e068d77059Cbe263C43AD0cDc130863313",
|
||||
TransactionIndex: EthCatFilePitVowLog.TxIndex,
|
||||
Raw: rawCatFilePitVowLog,
|
||||
}
|
||||
@@ -46,4 +46,4 @@ var DealModel = deal.DealModel{
|
||||
ContractAddress: shared.FlipperContractAddress,
|
||||
TransactionIndex: 74,
|
||||
Raw: dealRawJson,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// 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 chop_lump
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/chop_lump"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
)
|
||||
|
||||
type MockCatFileChopLumpConverter struct {
|
||||
Err error
|
||||
PassedLogs []types.Log
|
||||
}
|
||||
|
||||
func (converter *MockCatFileChopLumpConverter) ToModels(ethLogs []types.Log) ([]chop_lump.CatFileChopLumpModel, error) {
|
||||
converter.PassedLogs = ethLogs
|
||||
return []chop_lump.CatFileChopLumpModel{test_data.CatFileChopLumpModel}, converter.Err
|
||||
}
|
||||
|
||||
func (converter *MockCatFileChopLumpConverter) SetConverterError(e error) {
|
||||
converter.Err = e
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
// 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 chop_lump
|
||||
|
||||
import (
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/chop_lump"
|
||||
)
|
||||
|
||||
type MockCatFileChopLumpRepository struct {
|
||||
createErr error
|
||||
markHeaderCheckedErr error
|
||||
markHeaderCheckedPassedHeaderID int64
|
||||
missingHeaders []core.Header
|
||||
missingHeadersErr error
|
||||
PassedStartingBlockNumber int64
|
||||
PassedEndingBlockNumber int64
|
||||
PassedHeaderID int64
|
||||
PassedModels []chop_lump.CatFileChopLumpModel
|
||||
}
|
||||
|
||||
func (repository *MockCatFileChopLumpRepository) Create(headerID int64, models []chop_lump.CatFileChopLumpModel) error {
|
||||
repository.PassedHeaderID = headerID
|
||||
repository.PassedModels = models
|
||||
return repository.createErr
|
||||
}
|
||||
|
||||
func (repository *MockCatFileChopLumpRepository) MarkHeaderChecked(headerID int64) error {
|
||||
repository.markHeaderCheckedPassedHeaderID = headerID
|
||||
return repository.markHeaderCheckedErr
|
||||
}
|
||||
|
||||
func (repository *MockCatFileChopLumpRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
|
||||
repository.PassedStartingBlockNumber = startingBlockNumber
|
||||
repository.PassedEndingBlockNumber = endingBlockNumber
|
||||
return repository.missingHeaders, repository.missingHeadersErr
|
||||
}
|
||||
|
||||
func (repository *MockCatFileChopLumpRepository) SetMissingHeadersErr(e error) {
|
||||
repository.missingHeadersErr = e
|
||||
}
|
||||
|
||||
func (repository *MockCatFileChopLumpRepository) SetMissingHeaders(headers []core.Header) {
|
||||
repository.missingHeaders = headers
|
||||
}
|
||||
|
||||
func (repository *MockCatFileChopLumpRepository) SetCreateError(e error) {
|
||||
repository.createErr = e
|
||||
}
|
||||
|
||||
func (repository *MockCatFileChopLumpRepository) SetMarkHeaderCheckedErr(e error) {
|
||||
repository.markHeaderCheckedErr = e
|
||||
}
|
||||
|
||||
func (repository *MockCatFileChopLumpRepository) AssertMarkHeaderCheckedCalledWith(i int64) {
|
||||
Expect(repository.markHeaderCheckedPassedHeaderID).To(Equal(i))
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// 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 flip
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/flip"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
)
|
||||
|
||||
type MockCatFileFlipConverter struct {
|
||||
err error
|
||||
PassedLogs []types.Log
|
||||
}
|
||||
|
||||
func (converter *MockCatFileFlipConverter) ToModels(ethLogs []types.Log) ([]flip.CatFileFlipModel, error) {
|
||||
converter.PassedLogs = ethLogs
|
||||
return []flip.CatFileFlipModel{test_data.CatFileFlipModel}, converter.err
|
||||
}
|
||||
|
||||
func (converter *MockCatFileFlipConverter) SetConverterError(e error) {
|
||||
converter.err = e
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
// 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 flip
|
||||
|
||||
import (
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/flip"
|
||||
)
|
||||
|
||||
type MockCatFileFlipRepository struct {
|
||||
createErr error
|
||||
markHeaderCheckedErr error
|
||||
markHeaderCheckedPassedHeaderID int64
|
||||
missingHeadersErr error
|
||||
missingHeaders []core.Header
|
||||
PassedStartingBlockNumber int64
|
||||
PassedEndingBlockNumber int64
|
||||
PassedHeaderID int64
|
||||
PassedModels []flip.CatFileFlipModel
|
||||
}
|
||||
|
||||
func (repository *MockCatFileFlipRepository) Create(headerID int64, models []flip.CatFileFlipModel) error {
|
||||
repository.PassedHeaderID = headerID
|
||||
repository.PassedModels = models
|
||||
return repository.createErr
|
||||
}
|
||||
|
||||
func (repository *MockCatFileFlipRepository) MarkHeaderChecked(headerID int64) error {
|
||||
repository.markHeaderCheckedPassedHeaderID = headerID
|
||||
return repository.markHeaderCheckedErr
|
||||
}
|
||||
|
||||
func (repository *MockCatFileFlipRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
|
||||
repository.PassedStartingBlockNumber = startingBlockNumber
|
||||
repository.PassedEndingBlockNumber = endingBlockNumber
|
||||
return repository.missingHeaders, repository.missingHeadersErr
|
||||
}
|
||||
|
||||
func (repository *MockCatFileFlipRepository) SetMissingHeadersErr(e error) {
|
||||
repository.missingHeadersErr = e
|
||||
}
|
||||
|
||||
func (repository *MockCatFileFlipRepository) SetMissingHeaders(headers []core.Header) {
|
||||
repository.missingHeaders = headers
|
||||
}
|
||||
|
||||
func (repository *MockCatFileFlipRepository) SetCreateError(e error) {
|
||||
repository.createErr = e
|
||||
}
|
||||
|
||||
func (repository *MockCatFileFlipRepository) SetMarkHeaderCheckedErr(e error) {
|
||||
repository.markHeaderCheckedErr = e
|
||||
}
|
||||
|
||||
func (repository *MockCatFileFlipRepository) AssertMarkHeaderCheckedCalledWith(i int64) {
|
||||
Expect(repository.markHeaderCheckedPassedHeaderID).To(Equal(i))
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// 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 pit_vow
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/pit_vow"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
)
|
||||
|
||||
type MockCatFilePitVowConverter struct {
|
||||
err error
|
||||
PassedLogs []types.Log
|
||||
}
|
||||
|
||||
func (converter *MockCatFilePitVowConverter) ToModels(ethLogs []types.Log) ([]pit_vow.CatFilePitVowModel, error) {
|
||||
converter.PassedLogs = ethLogs
|
||||
return []pit_vow.CatFilePitVowModel{test_data.CatFilePitVowModel}, converter.err
|
||||
}
|
||||
|
||||
func (converter *MockCatFilePitVowConverter) SetConverterError(e error) {
|
||||
converter.err = e
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
// 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 pit_vow
|
||||
|
||||
import (
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/pit_vow"
|
||||
)
|
||||
|
||||
type MockCatFilePitVowRepository struct {
|
||||
createErr error
|
||||
markHeaderCheckedErr error
|
||||
markHeaderCheckedPassedHeaderID int64
|
||||
missingHeaders []core.Header
|
||||
missingHeadersErr error
|
||||
PassedStartingBlockNumber int64
|
||||
PassedEndingBlockNumber int64
|
||||
PassedHeaderID int64
|
||||
PassedModels []pit_vow.CatFilePitVowModel
|
||||
}
|
||||
|
||||
func (repository *MockCatFilePitVowRepository) Create(headerID int64, models []pit_vow.CatFilePitVowModel) error {
|
||||
repository.PassedHeaderID = headerID
|
||||
repository.PassedModels = models
|
||||
return repository.createErr
|
||||
}
|
||||
|
||||
func (repository *MockCatFilePitVowRepository) MarkHeaderChecked(headerID int64) error {
|
||||
repository.markHeaderCheckedPassedHeaderID = headerID
|
||||
return repository.markHeaderCheckedErr
|
||||
}
|
||||
|
||||
func (repository *MockCatFilePitVowRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
|
||||
repository.PassedStartingBlockNumber = startingBlockNumber
|
||||
repository.PassedEndingBlockNumber = endingBlockNumber
|
||||
return repository.missingHeaders, repository.missingHeadersErr
|
||||
}
|
||||
|
||||
func (repository *MockCatFilePitVowRepository) SetMissingHeadersErr(e error) {
|
||||
repository.missingHeadersErr = e
|
||||
}
|
||||
|
||||
func (repository *MockCatFilePitVowRepository) SetMissingHeaders(headers []core.Header) {
|
||||
repository.missingHeaders = headers
|
||||
}
|
||||
|
||||
func (repository *MockCatFilePitVowRepository) SetCreateError(e error) {
|
||||
repository.createErr = e
|
||||
}
|
||||
|
||||
func (repository *MockCatFilePitVowRepository) SetMarkHeaderCheckedErr(e error) {
|
||||
repository.markHeaderCheckedErr = e
|
||||
}
|
||||
|
||||
func (repository *MockCatFilePitVowRepository) AssertMarkHeaderCheckedCalledWith(i int64) {
|
||||
Expect(repository.markHeaderCheckedPassedHeaderID).To(Equal(i))
|
||||
}
|
||||
Reference in New Issue
Block a user