2018-11-07 21:50:43 +00:00
|
|
|
// VulcanizeDB
|
|
|
|
// Copyright © 2018 Vulcanize
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2018-08-31 19:48:43 +00:00
|
|
|
|
|
|
|
package mocks
|
|
|
|
|
|
|
|
import (
|
|
|
|
et1 "github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered"
|
2018-09-19 03:15:49 +00:00
|
|
|
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered/dai"
|
2018-08-31 19:48:43 +00:00
|
|
|
et2 "github.com/vulcanize/vulcanizedb/examples/generic/event_triggered"
|
2018-09-19 03:15:49 +00:00
|
|
|
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered/tusd"
|
2018-08-31 19:48:43 +00:00
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
|
|
|
)
|
|
|
|
|
|
|
|
type MockERC20Converter struct {
|
|
|
|
WatchedEvents []*core.WatchedEvent
|
2018-09-19 03:15:49 +00:00
|
|
|
TransfersToConvert []dai.TransferEntity
|
|
|
|
ApprovalsToConvert []dai.ApprovalEntity
|
|
|
|
BurnsToConvert []tusd.BurnEntity
|
|
|
|
MintsToConvert []tusd.MintEntity
|
2018-08-31 19:48:43 +00:00
|
|
|
block int64
|
|
|
|
}
|
|
|
|
|
2018-09-19 03:15:49 +00:00
|
|
|
func (mlkc *MockERC20Converter) ToTransferModel(entity *dai.TransferEntity) *et1.TransferModel {
|
2018-08-31 19:48:43 +00:00
|
|
|
mlkc.TransfersToConvert = append(mlkc.TransfersToConvert, *entity)
|
|
|
|
return &et1.TransferModel{}
|
|
|
|
}
|
|
|
|
|
2018-09-19 03:15:49 +00:00
|
|
|
func (mlkc *MockERC20Converter) ToTransferEntity(watchedEvent core.WatchedEvent) (*dai.TransferEntity, error) {
|
2018-08-31 19:48:43 +00:00
|
|
|
mlkc.WatchedEvents = append(mlkc.WatchedEvents, &watchedEvent)
|
2018-09-19 03:15:49 +00:00
|
|
|
e := &dai.TransferEntity{Block: watchedEvent.BlockNumber}
|
2018-08-31 19:48:43 +00:00
|
|
|
mlkc.block++
|
|
|
|
return e, nil
|
|
|
|
}
|
|
|
|
|
2018-09-19 03:15:49 +00:00
|
|
|
func (mlkc *MockERC20Converter) ToApprovalModel(entity *dai.ApprovalEntity) *et1.ApprovalModel {
|
2018-08-31 19:48:43 +00:00
|
|
|
mlkc.ApprovalsToConvert = append(mlkc.ApprovalsToConvert, *entity)
|
|
|
|
return &et1.ApprovalModel{}
|
|
|
|
}
|
|
|
|
|
2018-09-19 03:15:49 +00:00
|
|
|
func (mlkc *MockERC20Converter) ToApprovalEntity(watchedEvent core.WatchedEvent) (*dai.ApprovalEntity, error) {
|
2018-08-31 19:48:43 +00:00
|
|
|
mlkc.WatchedEvents = append(mlkc.WatchedEvents, &watchedEvent)
|
2018-09-19 03:15:49 +00:00
|
|
|
e := &dai.ApprovalEntity{Block: watchedEvent.BlockNumber}
|
2018-08-31 19:48:43 +00:00
|
|
|
mlkc.block++
|
|
|
|
return e, nil
|
|
|
|
}
|
|
|
|
|
2018-09-19 03:15:49 +00:00
|
|
|
func (mlkc *MockERC20Converter) ToBurnEntity(watchedEvent core.WatchedEvent) (*tusd.BurnEntity, error) {
|
2018-08-31 19:48:43 +00:00
|
|
|
mlkc.WatchedEvents = append(mlkc.WatchedEvents, &watchedEvent)
|
2018-09-19 03:15:49 +00:00
|
|
|
e := &tusd.BurnEntity{Block: watchedEvent.BlockNumber}
|
2018-08-31 19:48:43 +00:00
|
|
|
mlkc.block++
|
|
|
|
return e, nil
|
|
|
|
}
|
|
|
|
|
2018-09-19 03:15:49 +00:00
|
|
|
func (mlkc *MockERC20Converter) ToBurnModel(entity *tusd.BurnEntity) *et2.BurnModel {
|
2018-08-31 19:48:43 +00:00
|
|
|
mlkc.BurnsToConvert = append(mlkc.BurnsToConvert, *entity)
|
|
|
|
return &et2.BurnModel{}
|
|
|
|
}
|
|
|
|
|
2018-09-19 03:15:49 +00:00
|
|
|
func (mlkc *MockERC20Converter) ToMintEntity(watchedEvent core.WatchedEvent) (*tusd.MintEntity, error) {
|
2018-08-31 19:48:43 +00:00
|
|
|
mlkc.WatchedEvents = append(mlkc.WatchedEvents, &watchedEvent)
|
2018-09-19 03:15:49 +00:00
|
|
|
e := &tusd.MintEntity{Block: watchedEvent.BlockNumber}
|
2018-08-31 19:48:43 +00:00
|
|
|
mlkc.block++
|
|
|
|
return e, nil
|
|
|
|
}
|
|
|
|
|
2018-09-19 03:15:49 +00:00
|
|
|
func (mlkc *MockERC20Converter) ToMintModel(entity *tusd.MintEntity) *et2.MintModel {
|
2018-08-31 19:48:43 +00:00
|
|
|
mlkc.MintsToConvert = append(mlkc.MintsToConvert, *entity)
|
|
|
|
return &et2.MintModel{}
|
|
|
|
}
|