Add drip file transformers

- for all three file functions on the drip contract
This commit is contained in:
Rob Mulholand
2018-09-12 11:35:32 -05:00
parent faefd620b1
commit a843de5eb7
48 changed files with 2543 additions and 18 deletions
+103
View File
@@ -0,0 +1,103 @@
// 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"
ilk2 "github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/ilk"
"github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/repo"
"github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/vow"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"math/big"
)
var EthDripFileIlkLog = types.Log{
Address: common.HexToAddress(shared.DripContractAddress),
Topics: []common.Hash{
common.HexToHash("0x1a0b287e00000000000000000000000000000000000000000000000000000000"),
common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"),
common.HexToHash("0x66616b6520696c6b000000000000000000000000000000000000000000000000"),
common.HexToHash("0x66616b6520766f77000000000000000000000000000000000000000000000000"),
},
Data: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000641a0b287e66616b6520696c6b00000000000000000000000000000000000000000000000066616b6520766f77000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b"),
BlockNumber: 35,
TxHash: common.HexToHash("0xa1c31b7e6389470902237161263558615e60b40f2e63060b2f4aeafe92d57e5f"),
TxIndex: 12,
BlockHash: common.HexToHash("0x0188f3ee3cc05aa72457fa328e6a461de31e4cbd429fc37f9a52da4e9773c0b4"),
Index: 0,
Removed: false,
}
var rawDripFileIlkLog, _ = json.Marshal(EthDripFileIlkLog)
var DripFileIlkModel = ilk2.DripFileIlkModel{
Ilk: "fake ilk",
Vow: "fake vow",
Tax: big.NewInt(123).String(),
TransactionIndex: EthDripFileIlkLog.TxIndex,
Raw: rawDripFileIlkLog,
}
var EthDripFileRepoLog = types.Log{
Address: common.HexToAddress(shared.DripContractAddress),
Topics: []common.Hash{
common.HexToHash("0x29ae811400000000000000000000000000000000000000000000000000000000"),
common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"),
common.HexToHash("0x66616b6520776861740000000000000000000000000000000000000000000000"),
common.HexToHash("0x000000000000000000000000000000000000000000000000000000000000007b"),
},
Data: hexutil.MustDecode("0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004429ae811466616b6520776861740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b"),
BlockNumber: 36,
TxHash: common.HexToHash("0xeeaa16de1d91c239b66773e8c2116a26cfeaaf5d962b31466c9bf047a5caa20f"),
TxIndex: 13,
BlockHash: common.HexToHash("0x89de4145ea8e34dfd9db9a7ea34f5be6f1f402e812fd389acca342513b353288"),
Index: 0,
Removed: false,
}
var rawDripFileRepoLog, _ = json.Marshal(EthDripFileRepoLog)
var DripFileRepoModel = repo.DripFileRepoModel{
What: "fake what",
Data: big.NewInt(123).String(),
TransactionIndex: EthDripFileRepoLog.TxIndex,
Raw: rawDripFileRepoLog,
}
var EthDripFileVowLog = types.Log{
Address: common.HexToAddress(shared.DripContractAddress),
Topics: []common.Hash{
common.HexToHash("0xe9b674b900000000000000000000000000000000000000000000000000000000"),
common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"),
common.HexToHash("0x66616b6520776861740000000000000000000000000000000000000000000000"),
common.HexToHash("0x66616b6520646174610000000000000000000000000000000000000000000000"),
},
Data: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000044e9b674b966616b652077686174000000000000000000000000000000000000000000000066616b6520646174610000000000000000000000000000000000000000000000"),
BlockNumber: 51,
TxHash: common.HexToHash("0x586e26b71b41fcd6905044dbe8f0cca300517542278f74a9b925c4f800fed85c"),
TxIndex: 14,
BlockHash: common.HexToHash("0xbec69b1e93503679c9c006819477b86fe16aaff3a418da1e916c431b68be5522"),
Index: 0,
Removed: false,
}
var rawDripFileVowLog, _ = json.Marshal(EthDripFileVowLog)
var DripFileVowModel = vow.DripFileVowModel{
What: "fake what",
Data: "fake data",
TransactionIndex: EthDripFileVowLog.TxIndex,
Raw: rawDripFileVowLog,
}
@@ -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 ilk
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/ilk"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockDripFileIlkConverter struct {
converterErr error
PassedLog types.Log
}
func (converter *MockDripFileIlkConverter) ToModel(ethLog types.Log) (ilk.DripFileIlkModel, error) {
converter.PassedLog = ethLog
return test_data.DripFileIlkModel, converter.converterErr
}
func (converter *MockDripFileIlkConverter) SetConverterError(e error) {
converter.converterErr = e
}
@@ -0,0 +1,54 @@
// 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 ilk
import (
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/ilk"
)
type MockDripFileIlkRepository struct {
createErr error
missingHeaders []core.Header
missingHeadersErr error
PassedStartingBlockNumber int64
PassedEndingBlockNumber int64
PassedHeaderID int64
PassedModel ilk.DripFileIlkModel
}
func (repository *MockDripFileIlkRepository) Create(headerID int64, model ilk.DripFileIlkModel) error {
repository.PassedHeaderID = headerID
repository.PassedModel = model
return repository.createErr
}
func (repository *MockDripFileIlkRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersErr
}
func (repository *MockDripFileIlkRepository) SetMissingHeadersErr(e error) {
repository.missingHeadersErr = e
}
func (repository *MockDripFileIlkRepository) SetMissingHeaders(headers []core.Header) {
repository.missingHeaders = headers
}
func (repository *MockDripFileIlkRepository) SetCreateError(e error) {
repository.createErr = e
}
@@ -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 repo
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/repo"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockDripFileRepoConverter struct {
converterErr error
PassedLog types.Log
}
func (converter *MockDripFileRepoConverter) ToModel(ethLog types.Log) (repo.DripFileRepoModel, error) {
converter.PassedLog = ethLog
return test_data.DripFileRepoModel, converter.converterErr
}
func (converter *MockDripFileRepoConverter) SetConverterError(e error) {
converter.converterErr = e
}
@@ -0,0 +1,54 @@
// 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 repo
import (
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/repo"
)
type MockDripFileRepoRepository struct {
createErr error
missingHeaders []core.Header
missingHeadersErr error
PassedStartingBlockNumber int64
PassedEndingBlockNumber int64
PassedHeaderID int64
PassedModel repo.DripFileRepoModel
}
func (repository *MockDripFileRepoRepository) Create(headerID int64, model repo.DripFileRepoModel) error {
repository.PassedHeaderID = headerID
repository.PassedModel = model
return repository.createErr
}
func (repository *MockDripFileRepoRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersErr
}
func (repository *MockDripFileRepoRepository) SetMissingHeadersErr(e error) {
repository.missingHeadersErr = e
}
func (repository *MockDripFileRepoRepository) SetMissingHeaders(headers []core.Header) {
repository.missingHeaders = headers
}
func (repository *MockDripFileRepoRepository) SetCreateError(e error) {
repository.createErr = e
}
@@ -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 vow
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/vow"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockDripFileVowConverter struct {
converterErr error
PassedLog types.Log
}
func (converter *MockDripFileVowConverter) ToModel(ethLog types.Log) (vow.DripFileVowModel, error) {
converter.PassedLog = ethLog
return test_data.DripFileVowModel, converter.converterErr
}
func (converter *MockDripFileVowConverter) SetConverterError(e error) {
converter.converterErr = e
}
@@ -0,0 +1,54 @@
// 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 vow
import (
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/vow"
)
type MockDripFileVowRepository struct {
createErr error
missingHeaders []core.Header
missingHeadersErr error
PassedStartingBlockNumber int64
PassedEndingBlockNumber int64
PassedHeaderID int64
PassedModel vow.DripFileVowModel
}
func (repository *MockDripFileVowRepository) Create(headerID int64, model vow.DripFileVowModel) error {
repository.PassedHeaderID = headerID
repository.PassedModel = model
return repository.createErr
}
func (repository *MockDripFileVowRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersErr
}
func (repository *MockDripFileVowRepository) SetMissingHeadersErr(e error) {
repository.missingHeadersErr = e
}
func (repository *MockDripFileVowRepository) SetMissingHeaders(headers []core.Header) {
repository.missingHeaders = headers
}
func (repository *MockDripFileVowRepository) SetCreateError(e error) {
repository.createErr = e
}
@@ -0,0 +1,37 @@
// 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 price_feeds
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/price_feeds"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockPriceFeedConverter struct {
converterErr error
PassedLog types.Log
PassedHeaderID int64
}
func (converter *MockPriceFeedConverter) ToModel(log types.Log, headerID int64) (price_feeds.PriceFeedModel, error) {
converter.PassedLog = log
converter.PassedHeaderID = headerID
return test_data.PriceFeedModel, converter.converterErr
}
func (converter *MockPriceFeedConverter) SetConverterErr(e error) {
converter.converterErr = e
}
+50
View File
@@ -0,0 +1,50 @@
// 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/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/price_feeds"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
)
var (
medianizerAddress = common.HexToAddress("0x99041f808d598b782d5a3e498681c2452a31da08")
blockNumber = uint64(6147230)
txIndex = uint(119)
)
// https://etherscan.io/tx/0xa51a50a2adbfba4e2ab3d72dfd67a21c769f1bc8d2b180663a15500a56cde58f
var EthPriceFeedLog = types.Log{
Address: medianizerAddress,
Topics: []common.Hash{common.HexToHash(shared.LogValueSignature)},
Data: common.FromHex("00000000000000000000000000000000000000000000001486f658319fb0c100"),
BlockNumber: blockNumber,
TxHash: common.HexToHash("0xa51a50a2adbfba4e2ab3d72dfd67a21c769f1bc8d2b180663a15500a56cde58f"),
TxIndex: txIndex,
BlockHash: common.HexToHash("0x27ecebbf69eefa3bb3cf65f472322a80ff4946653a50a2171dc605f49829467d"),
Index: 0,
Removed: false,
}
var rawPriceFeedLog, _ = json.Marshal(EthPriceFeedLog)
var PriceFeedModel = price_feeds.PriceFeedModel{
BlockNumber: blockNumber,
MedianizerAddress: EthPriceFeedLog.Address[:],
UsdValue: "378.6599388897",
TransactionIndex: EthPriceFeedLog.TxIndex,
}