forked from cerc-io/ipld-eth-server
reorganizing contract-specific modules into event_triggered contract directories
This commit is contained in:
parent
d66e50dad6
commit
44177e0772
@ -12,13 +12,14 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package event_triggered
|
||||
package dai
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/examples/constants"
|
||||
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic/helpers"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
@ -30,9 +31,9 @@ import (
|
||||
|
||||
type ERC20ConverterInterface interface {
|
||||
ToTransferEntity(watchedEvent core.WatchedEvent) (*TransferEntity, error)
|
||||
ToTransferModel(entity *TransferEntity) *TransferModel
|
||||
ToTransferModel(entity *TransferEntity) *event_triggered.TransferModel
|
||||
ToApprovalEntity(watchedEvent core.WatchedEvent) (*ApprovalEntity, error)
|
||||
ToApprovalModel(entity *ApprovalEntity) *ApprovalModel
|
||||
ToApprovalModel(entity *ApprovalEntity) *event_triggered.ApprovalModel
|
||||
}
|
||||
|
||||
type ERC20Converter struct {
|
||||
@ -70,12 +71,12 @@ func (c ERC20Converter) ToTransferEntity(watchedEvent core.WatchedEvent) (*Trans
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c ERC20Converter) ToTransferModel(entity *TransferEntity) *TransferModel {
|
||||
func (c ERC20Converter) ToTransferModel(entity *TransferEntity) *event_triggered.TransferModel {
|
||||
to := entity.Dst.String()
|
||||
from := entity.Src.String()
|
||||
tokens := entity.Wad.String()
|
||||
|
||||
return &TransferModel{
|
||||
return &event_triggered.TransferModel{
|
||||
TokenName: c.config.Name,
|
||||
TokenAddress: c.config.Address,
|
||||
To: to,
|
||||
@ -102,12 +103,12 @@ func (c ERC20Converter) ToApprovalEntity(watchedEvent core.WatchedEvent) (*Appro
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c ERC20Converter) ToApprovalModel(entity *ApprovalEntity) *ApprovalModel {
|
||||
func (c ERC20Converter) ToApprovalModel(entity *ApprovalEntity) *event_triggered.ApprovalModel {
|
||||
tokenOwner := entity.Src.String()
|
||||
spender := entity.Guy.String()
|
||||
tokens := entity.Wad.String()
|
||||
|
||||
return &ApprovalModel{
|
||||
return &event_triggered.ApprovalModel{
|
||||
TokenName: c.config.Name,
|
||||
TokenAddress: c.config.Address,
|
||||
Owner: tokenOwner,
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package event_triggered_test
|
||||
package dai_test
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
@ -21,6 +21,7 @@ import (
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/examples/constants"
|
||||
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered"
|
||||
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered/dai"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic/helpers"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
@ -36,7 +37,7 @@ var expectedTransferModel = event_triggered.TransferModel{
|
||||
TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
|
||||
}
|
||||
|
||||
var expectedTransferEntity = event_triggered.TransferEntity{
|
||||
var expectedTransferEntity = dai.TransferEntity{
|
||||
TokenName: "Dai",
|
||||
TokenAddress: common.HexToAddress(constants.DaiContractAddress),
|
||||
Src: common.HexToAddress("0x000000000000000000000000000000000000Af21"),
|
||||
@ -56,7 +57,7 @@ var expectedApprovalModel = event_triggered.ApprovalModel{
|
||||
TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
|
||||
}
|
||||
|
||||
var expectedApprovalEntity = event_triggered.ApprovalEntity{
|
||||
var expectedApprovalEntity = dai.ApprovalEntity{
|
||||
TokenName: "Dai",
|
||||
TokenAddress: common.HexToAddress(constants.DaiContractAddress),
|
||||
Src: common.HexToAddress("0x000000000000000000000000000000000000Af21"),
|
||||
@ -96,11 +97,11 @@ var approvalEvent = core.WatchedEvent{
|
||||
|
||||
var _ = Describe("Transfer Converter", func() {
|
||||
|
||||
var daiConverter *event_triggered.ERC20Converter
|
||||
var daiConverter *dai.ERC20Converter
|
||||
var err error
|
||||
|
||||
BeforeEach(func() {
|
||||
daiConverter, err = event_triggered.NewERC20Converter(generic.DaiConfig)
|
||||
daiConverter, err = dai.NewERC20Converter(generic.DaiConfig)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -124,11 +125,11 @@ var _ = Describe("Transfer Converter", func() {
|
||||
|
||||
var _ = Describe("Approval Converter", func() {
|
||||
|
||||
var daiConverter *event_triggered.ERC20Converter
|
||||
var daiConverter *dai.ERC20Converter
|
||||
var err error
|
||||
|
||||
BeforeEach(func() {
|
||||
daiConverter, err = event_triggered.NewERC20Converter(generic.DaiConfig)
|
||||
daiConverter, err = dai.NewERC20Converter(generic.DaiConfig)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package event_triggered_test
|
||||
package dai_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
@ -23,5 +23,5 @@ import (
|
||||
|
||||
func TestLogKill(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "ERC20 Event Triggered test Suite")
|
||||
RunSpecs(t, "Dai ERC20 Event Triggered Test Suite")
|
||||
}
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package event_triggered
|
||||
package dai
|
||||
|
||||
import (
|
||||
"math/big"
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package event_triggered_test
|
||||
package dai_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
@ -20,6 +20,7 @@ import (
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/examples/constants"
|
||||
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered"
|
||||
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered/dai"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic"
|
||||
"github.com/vulcanize/vulcanizedb/examples/test_helpers"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
@ -80,7 +81,7 @@ var _ = Describe("Integration test with vulcanizedb", func() {
|
||||
})
|
||||
|
||||
It("creates token_transfers entry for each Transfer event received", func() {
|
||||
transformer, err := event_triggered.NewTransformer(db, generic.DaiConfig)
|
||||
transformer, err := dai.NewTransformer(db, generic.DaiConfig)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
transformer.Execute()
|
||||
@ -106,7 +107,7 @@ var _ = Describe("Integration test with vulcanizedb", func() {
|
||||
})
|
||||
|
||||
It("creates token_approvals entry for each Approval event received", func() {
|
||||
transformer, err := event_triggered.NewTransformer(db, generic.DaiConfig)
|
||||
transformer, err := dai.NewTransformer(db, generic.DaiConfig)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
transformer.Execute()
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package event_triggered_test
|
||||
package dai_test
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
@ -23,6 +23,7 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered"
|
||||
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered/dai"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic/helpers"
|
||||
"github.com/vulcanize/vulcanizedb/examples/test_helpers"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/config"
|
||||
@ -31,7 +32,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
|
||||
)
|
||||
|
||||
var transferEntity = &event_triggered.TransferEntity{
|
||||
var transferEntity = &dai.TransferEntity{
|
||||
TokenName: "Dai",
|
||||
TokenAddress: common.HexToAddress("0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"),
|
||||
Src: common.HexToAddress("0x000000000000000000000000000000000000Af21"),
|
||||
@ -41,7 +42,7 @@ var transferEntity = &event_triggered.TransferEntity{
|
||||
TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
|
||||
}
|
||||
|
||||
var approvalEntity = &event_triggered.ApprovalEntity{
|
||||
var approvalEntity = &dai.ApprovalEntity{
|
||||
TokenName: "Dai",
|
||||
TokenAddress: common.HexToAddress("0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"),
|
||||
Src: common.HexToAddress("0x000000000000000000000000000000000000Af21"),
|
||||
@ -53,7 +54,7 @@ var approvalEntity = &event_triggered.ApprovalEntity{
|
||||
|
||||
var _ = Describe("Approval and Transfer Repository Tests", func() {
|
||||
var db *postgres.DB
|
||||
var converter event_triggered.ERC20Converter
|
||||
var converter dai.ERC20Converter
|
||||
var repository event_triggered.ERC20EventRepository
|
||||
var logRepository repositories.LogRepository
|
||||
var blockRepository repositories.BlockRepository
|
||||
@ -93,7 +94,7 @@ var _ = Describe("Approval and Transfer Repository Tests", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
repository = event_triggered.ERC20EventRepository{DB: db}
|
||||
converter = event_triggered.ERC20Converter{}
|
||||
converter = dai.ERC20Converter{}
|
||||
|
||||
})
|
||||
|
@ -12,13 +12,14 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package event_triggered
|
||||
package dai
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/examples/constants"
|
||||
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic"
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
@ -30,7 +31,7 @@ type ERC20EventTransformer struct {
|
||||
Converter ERC20ConverterInterface
|
||||
WatchedEventRepository datastore.WatchedEventRepository
|
||||
FilterRepository datastore.FilterRepository
|
||||
Repository ERC20EventDatastore
|
||||
Repository event_triggered.ERC20EventDatastore
|
||||
}
|
||||
|
||||
func NewTransformer(db *postgres.DB, config generic.ContractConfig) (shared.Transformer, error) {
|
||||
@ -43,7 +44,7 @@ func NewTransformer(db *postgres.DB, config generic.ContractConfig) (shared.Tran
|
||||
|
||||
wer := repositories.WatchedEventRepository{DB: db}
|
||||
fr := repositories.FilterRepository{DB: db}
|
||||
lkr := ERC20EventRepository{DB: db}
|
||||
lkr := event_triggered.ERC20EventRepository{DB: db}
|
||||
transformer = ERC20EventTransformer{
|
||||
Converter: cnvtr,
|
||||
WatchedEventRepository: wer,
|
@ -12,14 +12,14 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package event_triggered_test
|
||||
package dai_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/examples/constants"
|
||||
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered"
|
||||
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered/dai"
|
||||
"github.com/vulcanize/vulcanizedb/examples/mocks"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
)
|
||||
@ -63,7 +63,7 @@ var _ = Describe("Mock ERC20 transformer", func() {
|
||||
var watchedEventsRepo mocks.MockWatchedEventsRepository
|
||||
var mockEventRepo mocks.MockEventRepo
|
||||
var filterRepo mocks.MockFilterRepository
|
||||
var transformer event_triggered.ERC20EventTransformer
|
||||
var transformer dai.ERC20EventTransformer
|
||||
|
||||
BeforeEach(func() {
|
||||
mockERC20Converter = mocks.MockERC20Converter{}
|
||||
@ -72,7 +72,7 @@ var _ = Describe("Mock ERC20 transformer", func() {
|
||||
mockEventRepo = mocks.MockEventRepo{}
|
||||
filterRepo = mocks.MockFilterRepository{}
|
||||
|
||||
transformer = event_triggered.ERC20EventTransformer{
|
||||
transformer = dai.ERC20EventTransformer{
|
||||
Converter: &mockERC20Converter,
|
||||
WatchedEventRepository: &watchedEventsRepo,
|
||||
FilterRepository: filterRepo,
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package event_triggered
|
||||
package tusd
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
@ -20,6 +20,7 @@ import (
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/examples/constants"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic/helpers"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
||||
@ -30,9 +31,9 @@ import (
|
||||
|
||||
type GenericConverterInterface interface {
|
||||
ToBurnEntity(watchedEvent core.WatchedEvent) (*BurnEntity, error)
|
||||
ToBurnModel(entity *BurnEntity) *BurnModel
|
||||
ToBurnModel(entity *BurnEntity) *event_triggered.BurnModel
|
||||
ToMintEntity(watchedEvent core.WatchedEvent) (*MintEntity, error)
|
||||
ToMintModel(entity *MintEntity) *MintModel
|
||||
ToMintModel(entity *MintEntity) *event_triggered.MintModel
|
||||
}
|
||||
|
||||
type GenericConverter struct {
|
||||
@ -70,11 +71,11 @@ func (c GenericConverter) ToBurnEntity(watchedEvent core.WatchedEvent) (*BurnEnt
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c GenericConverter) ToBurnModel(entity *BurnEntity) *BurnModel {
|
||||
func (c GenericConverter) ToBurnModel(entity *BurnEntity) *event_triggered.BurnModel {
|
||||
burner := entity.Burner.String()
|
||||
tokens := entity.Value.String()
|
||||
|
||||
return &BurnModel{
|
||||
return &event_triggered.BurnModel{
|
||||
TokenName: c.config.Name,
|
||||
TokenAddress: c.config.Address,
|
||||
Burner: burner,
|
||||
@ -100,12 +101,12 @@ func (c GenericConverter) ToMintEntity(watchedEvent core.WatchedEvent) (*MintEnt
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c GenericConverter) ToMintModel(entity *MintEntity) *MintModel {
|
||||
func (c GenericConverter) ToMintModel(entity *MintEntity) *event_triggered.MintModel {
|
||||
mintee := entity.To.String()
|
||||
minter := c.config.Owner
|
||||
tokens := entity.Amount.String()
|
||||
|
||||
return &MintModel{
|
||||
return &event_triggered.MintModel{
|
||||
TokenName: c.config.Name,
|
||||
TokenAddress: c.config.Address,
|
||||
Mintee: mintee,
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package event_triggered_test
|
||||
package tusd_test
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
@ -22,6 +22,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/examples/constants"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered/tusd"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic/helpers"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
)
|
||||
@ -35,7 +36,7 @@ var expectedBurnModel = event_triggered.BurnModel{
|
||||
TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
|
||||
}
|
||||
|
||||
var expectedBurnEntity = event_triggered.BurnEntity{
|
||||
var expectedBurnEntity = tusd.BurnEntity{
|
||||
TokenName: "Tusd",
|
||||
TokenAddress: common.HexToAddress(constants.TusdContractAddress),
|
||||
Burner: common.HexToAddress("0x09BbBBE21a5975cAc061D82f7b843bCE061BA391"),
|
||||
@ -54,7 +55,7 @@ var expectedMintModel = event_triggered.MintModel{
|
||||
TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
|
||||
}
|
||||
|
||||
var expectedMintEntity = event_triggered.MintEntity{
|
||||
var expectedMintEntity = tusd.MintEntity{
|
||||
TokenName: "Tusd",
|
||||
TokenAddress: common.HexToAddress(constants.TusdContractAddress),
|
||||
To: common.HexToAddress("0x09BbBBE21a5975cAc061D82f7b843bCE061BA391"),
|
||||
@ -93,11 +94,11 @@ var mintEvent = core.WatchedEvent{
|
||||
|
||||
var _ = Describe("Transfer Converter", func() {
|
||||
|
||||
var converter *event_triggered.GenericConverter
|
||||
var converter *tusd.GenericConverter
|
||||
var err error
|
||||
|
||||
BeforeEach(func() {
|
||||
converter, err = event_triggered.NewGenericConverter(generic.TusdConfig)
|
||||
converter, err = tusd.NewGenericConverter(generic.TusdConfig)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -121,11 +122,11 @@ var _ = Describe("Transfer Converter", func() {
|
||||
|
||||
var _ = Describe("Approval Converter", func() {
|
||||
|
||||
var converter *event_triggered.GenericConverter
|
||||
var converter *tusd.GenericConverter
|
||||
var err error
|
||||
|
||||
BeforeEach(func() {
|
||||
converter, err = event_triggered.NewGenericConverter(generic.TusdConfig)
|
||||
converter, err = tusd.NewGenericConverter(generic.TusdConfig)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package event_triggered
|
||||
package tusd
|
||||
|
||||
import (
|
||||
"math/big"
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package event_triggered_test
|
||||
package tusd_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
@ -21,6 +21,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/examples/constants"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered/tusd"
|
||||
"github.com/vulcanize/vulcanizedb/examples/test_helpers"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
@ -80,7 +81,7 @@ var _ = Describe("Integration test with vulcanizedb", func() {
|
||||
})
|
||||
|
||||
It("creates token_burns entry for each Burn event received", func() {
|
||||
transformer, err := event_triggered.NewTransformer(db, generic.TusdConfig)
|
||||
transformer, err := tusd.NewTransformer(db, generic.TusdConfig)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
transformer.Execute()
|
||||
@ -105,7 +106,7 @@ var _ = Describe("Integration test with vulcanizedb", func() {
|
||||
})
|
||||
|
||||
It("creates token_mints entry for each Mint event received", func() {
|
||||
transformer, err := event_triggered.NewTransformer(db, generic.TusdConfig)
|
||||
transformer, err := tusd.NewTransformer(db, generic.TusdConfig)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
transformer.Execute()
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package event_triggered_test
|
||||
package tusd_test
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
@ -23,6 +23,7 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered/tusd"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic/helpers"
|
||||
"github.com/vulcanize/vulcanizedb/examples/test_helpers"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/config"
|
||||
@ -31,7 +32,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
|
||||
)
|
||||
|
||||
var burnEntity = &event_triggered.BurnEntity{
|
||||
var burnEntity = &tusd.BurnEntity{
|
||||
TokenName: "Tusd",
|
||||
TokenAddress: common.HexToAddress("0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"),
|
||||
Burner: common.HexToAddress("0x09BbBBE21a5975cAc061D82f7b843bCE061BA391"),
|
||||
@ -40,7 +41,7 @@ var burnEntity = &event_triggered.BurnEntity{
|
||||
TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
|
||||
}
|
||||
|
||||
var mintEntity = &event_triggered.MintEntity{
|
||||
var mintEntity = &tusd.MintEntity{
|
||||
TokenName: "Tusd",
|
||||
TokenAddress: common.HexToAddress("0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"),
|
||||
To: common.HexToAddress("0x09BbBBE21a5975cAc061D82f7b843bCE061BA391"),
|
||||
@ -51,7 +52,7 @@ var mintEntity = &event_triggered.MintEntity{
|
||||
|
||||
var _ = Describe("Approval and Transfer Repository Tests", func() {
|
||||
var db *postgres.DB
|
||||
var converter event_triggered.GenericConverter
|
||||
var converter tusd.GenericConverter
|
||||
var repository event_triggered.GenericEventRepository
|
||||
var logRepository repositories.LogRepository
|
||||
var blockRepository repositories.BlockRepository
|
||||
@ -91,7 +92,7 @@ var _ = Describe("Approval and Transfer Repository Tests", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
repository = event_triggered.GenericEventRepository{DB: db}
|
||||
converter = event_triggered.GenericConverter{}
|
||||
converter = tusd.GenericConverter{}
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package event_triggered
|
||||
package tusd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -20,6 +20,7 @@ import (
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/examples/constants"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered"
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
@ -30,7 +31,7 @@ type GenericTransformer struct {
|
||||
Converter GenericConverterInterface
|
||||
WatchedEventRepository datastore.WatchedEventRepository
|
||||
FilterRepository datastore.FilterRepository
|
||||
Repository GenericEventDatastore
|
||||
Repository event_triggered.GenericEventDatastore
|
||||
}
|
||||
|
||||
func NewTransformer(db *postgres.DB, config generic.ContractConfig) (shared.Transformer, error) {
|
||||
@ -43,7 +44,7 @@ func NewTransformer(db *postgres.DB, config generic.ContractConfig) (shared.Tran
|
||||
|
||||
wer := repositories.WatchedEventRepository{DB: db}
|
||||
fr := repositories.FilterRepository{DB: db}
|
||||
lkr := GenericEventRepository{DB: db}
|
||||
lkr := event_triggered.GenericEventRepository{DB: db}
|
||||
transformer = GenericTransformer{
|
||||
Converter: cnvtr,
|
||||
WatchedEventRepository: wer,
|
@ -12,14 +12,14 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package event_triggered_test
|
||||
package tusd_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/examples/constants"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered/tusd"
|
||||
"github.com/vulcanize/vulcanizedb/examples/mocks"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
)
|
||||
@ -63,7 +63,7 @@ var _ = Describe("Mock ERC20 transformer", func() {
|
||||
var watchedEventsRepo mocks.MockWatchedEventsRepository
|
||||
var mockEventRepo mocks.MockEventRepo
|
||||
var filterRepo mocks.MockFilterRepository
|
||||
var transformer event_triggered.GenericTransformer
|
||||
var transformer tusd.GenericTransformer
|
||||
|
||||
BeforeEach(func() {
|
||||
mockERC20Converter = mocks.MockERC20Converter{}
|
||||
@ -72,7 +72,7 @@ var _ = Describe("Mock ERC20 transformer", func() {
|
||||
mockEventRepo = mocks.MockEventRepo{}
|
||||
filterRepo = mocks.MockFilterRepository{}
|
||||
|
||||
transformer = event_triggered.GenericTransformer{
|
||||
transformer = tusd.GenericTransformer{
|
||||
Converter: &mockERC20Converter,
|
||||
WatchedEventRepository: &watchedEventsRepo,
|
||||
FilterRepository: filterRepo,
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package event_triggered_test
|
||||
package tusd_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
@ -23,5 +23,5 @@ import (
|
||||
|
||||
func TestLogKill(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "ERC20 Event Triggered test Suite")
|
||||
RunSpecs(t, "Tusd Generic Event Triggered Test Suite")
|
||||
}
|
@ -16,63 +16,65 @@ package mocks
|
||||
|
||||
import (
|
||||
et1 "github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered"
|
||||
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered/dai"
|
||||
et2 "github.com/vulcanize/vulcanizedb/examples/generic/event_triggered"
|
||||
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered/tusd"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
)
|
||||
|
||||
type MockERC20Converter struct {
|
||||
WatchedEvents []*core.WatchedEvent
|
||||
TransfersToConvert []et1.TransferEntity
|
||||
ApprovalsToConvert []et1.ApprovalEntity
|
||||
BurnsToConvert []et2.BurnEntity
|
||||
MintsToConvert []et2.MintEntity
|
||||
TransfersToConvert []dai.TransferEntity
|
||||
ApprovalsToConvert []dai.ApprovalEntity
|
||||
BurnsToConvert []tusd.BurnEntity
|
||||
MintsToConvert []tusd.MintEntity
|
||||
block int64
|
||||
}
|
||||
|
||||
func (mlkc *MockERC20Converter) ToTransferModel(entity *et1.TransferEntity) *et1.TransferModel {
|
||||
func (mlkc *MockERC20Converter) ToTransferModel(entity *dai.TransferEntity) *et1.TransferModel {
|
||||
mlkc.TransfersToConvert = append(mlkc.TransfersToConvert, *entity)
|
||||
return &et1.TransferModel{}
|
||||
}
|
||||
|
||||
func (mlkc *MockERC20Converter) ToTransferEntity(watchedEvent core.WatchedEvent) (*et1.TransferEntity, error) {
|
||||
func (mlkc *MockERC20Converter) ToTransferEntity(watchedEvent core.WatchedEvent) (*dai.TransferEntity, error) {
|
||||
mlkc.WatchedEvents = append(mlkc.WatchedEvents, &watchedEvent)
|
||||
e := &et1.TransferEntity{Block: watchedEvent.BlockNumber}
|
||||
e := &dai.TransferEntity{Block: watchedEvent.BlockNumber}
|
||||
mlkc.block++
|
||||
return e, nil
|
||||
}
|
||||
|
||||
func (mlkc *MockERC20Converter) ToApprovalModel(entity *et1.ApprovalEntity) *et1.ApprovalModel {
|
||||
func (mlkc *MockERC20Converter) ToApprovalModel(entity *dai.ApprovalEntity) *et1.ApprovalModel {
|
||||
mlkc.ApprovalsToConvert = append(mlkc.ApprovalsToConvert, *entity)
|
||||
return &et1.ApprovalModel{}
|
||||
}
|
||||
|
||||
func (mlkc *MockERC20Converter) ToApprovalEntity(watchedEvent core.WatchedEvent) (*et1.ApprovalEntity, error) {
|
||||
func (mlkc *MockERC20Converter) ToApprovalEntity(watchedEvent core.WatchedEvent) (*dai.ApprovalEntity, error) {
|
||||
mlkc.WatchedEvents = append(mlkc.WatchedEvents, &watchedEvent)
|
||||
e := &et1.ApprovalEntity{Block: watchedEvent.BlockNumber}
|
||||
e := &dai.ApprovalEntity{Block: watchedEvent.BlockNumber}
|
||||
mlkc.block++
|
||||
return e, nil
|
||||
}
|
||||
|
||||
func (mlkc *MockERC20Converter) ToBurnEntity(watchedEvent core.WatchedEvent) (*et2.BurnEntity, error) {
|
||||
func (mlkc *MockERC20Converter) ToBurnEntity(watchedEvent core.WatchedEvent) (*tusd.BurnEntity, error) {
|
||||
mlkc.WatchedEvents = append(mlkc.WatchedEvents, &watchedEvent)
|
||||
e := &et2.BurnEntity{Block: watchedEvent.BlockNumber}
|
||||
e := &tusd.BurnEntity{Block: watchedEvent.BlockNumber}
|
||||
mlkc.block++
|
||||
return e, nil
|
||||
}
|
||||
|
||||
func (mlkc *MockERC20Converter) ToBurnModel(entity *et2.BurnEntity) *et2.BurnModel {
|
||||
func (mlkc *MockERC20Converter) ToBurnModel(entity *tusd.BurnEntity) *et2.BurnModel {
|
||||
mlkc.BurnsToConvert = append(mlkc.BurnsToConvert, *entity)
|
||||
return &et2.BurnModel{}
|
||||
}
|
||||
|
||||
func (mlkc *MockERC20Converter) ToMintEntity(watchedEvent core.WatchedEvent) (*et2.MintEntity, error) {
|
||||
func (mlkc *MockERC20Converter) ToMintEntity(watchedEvent core.WatchedEvent) (*tusd.MintEntity, error) {
|
||||
mlkc.WatchedEvents = append(mlkc.WatchedEvents, &watchedEvent)
|
||||
e := &et2.MintEntity{Block: watchedEvent.BlockNumber}
|
||||
e := &tusd.MintEntity{Block: watchedEvent.BlockNumber}
|
||||
mlkc.block++
|
||||
return e, nil
|
||||
}
|
||||
|
||||
func (mlkc *MockERC20Converter) ToMintModel(entity *et2.MintEntity) *et2.MintModel {
|
||||
func (mlkc *MockERC20Converter) ToMintModel(entity *tusd.MintEntity) *et2.MintModel {
|
||||
mlkc.MintsToConvert = append(mlkc.MintsToConvert, *entity)
|
||||
return &et2.MintModel{}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user