migration file to create bite; create bite repository
add transaction index and raw log to bite table work on converter for bite event update bite repository, replace guy with 32byte lad; create bite converter to entity update field type for bite event; start on bite transformer finish bite event transformer
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
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/bite"
|
||||
"math/big"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
var (
|
||||
TemporaryBiteAddress = "0x4ac9588a53dc6008058c86eed71a5c91da793a07"
|
||||
TemporaryBiteBlockHash = common.HexToHash("0xd130caaccc9203ca63eb149faeb013aed21f0317ce23489c0486da2f9adcd0eb")
|
||||
TemporaryBiteBlockNumber = int64(26)
|
||||
TemporaryBiteData = "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000005"
|
||||
TemporaryBiteTransaction = "0x5c698f13940a2153440c6d19660878bc90219d9298fdcf37365aa8d88d40fc42"
|
||||
)
|
||||
|
||||
var (
|
||||
biteInk = big.NewInt(1)
|
||||
biteArt = big.NewInt(2)
|
||||
biteTab = big.NewInt(3)
|
||||
biteFlip = big.NewInt(4)
|
||||
biteIArt = big.NewInt(5)
|
||||
biteRawJson, _ = json.Marshal(EthBiteLog)
|
||||
biteRawString = string(biteRawJson)
|
||||
biteIlk = [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}
|
||||
biteLad = [32]byte{102, 97, 107, 101, 32, 108, 97, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
biteId = int64(1)
|
||||
)
|
||||
|
||||
var EthBiteLog = types.Log{
|
||||
Address: common.HexToAddress(TemporaryBiteAddress),
|
||||
Topics: []common.Hash{
|
||||
common.HexToHash("0x99b5620489b6ef926d4518936cfec15d305452712b88bd59da2d9c10fb0953e8"),
|
||||
common.HexToHash("0x66616b6520696c6b000000000000000000000000000000000000000000000000"),
|
||||
common.HexToHash("0x66616b65206c6164000000000000000000000000000000000000000000000000"),
|
||||
},
|
||||
Data: hexutil.MustDecode(TemporaryBiteData),
|
||||
BlockNumber: uint64(TemporaryBiteBlockNumber),
|
||||
TxHash: common.HexToHash(TemporaryBiteTransaction),
|
||||
TxIndex: 111,
|
||||
BlockHash: TemporaryBiteBlockHash,
|
||||
Index: 0,
|
||||
Removed: false,
|
||||
}
|
||||
|
||||
var BiteEntity = bite.BiteEntity{
|
||||
Id: big.NewInt(biteId),
|
||||
Ilk: biteIlk,
|
||||
Lad: biteLad,
|
||||
Ink: biteInk,
|
||||
Art: biteArt,
|
||||
Tab: biteTab,
|
||||
Flip: biteFlip,
|
||||
IArt: biteIArt,
|
||||
TransactionIndex: EthBiteLog.TxIndex,
|
||||
Raw: EthBiteLog,
|
||||
}
|
||||
|
||||
var BiteModel = bite.BiteModel{
|
||||
Id: strconv.FormatInt(biteId, 10),
|
||||
Ilk: biteIlk[:],
|
||||
Lad: biteLad[:],
|
||||
Ink: biteInk.String(),
|
||||
Art: biteArt.String(),
|
||||
Tab: biteTab.String(),
|
||||
Flip: biteFlip.String(),
|
||||
IArt: biteIArt.String(),
|
||||
TransactionIndex: EthBiteLog.TxIndex,
|
||||
Raw: biteRawString,
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// 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 bite
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
. "github.com/vulcanize/vulcanizedb/pkg/transformers/bite"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
)
|
||||
|
||||
type MockBiteConverter struct {
|
||||
ConverterContract string
|
||||
ConverterAbi string
|
||||
LogsToConvert []types.Log
|
||||
EntitiesToConvert []BiteEntity
|
||||
ConverterError error
|
||||
}
|
||||
|
||||
func (mbc *MockBiteConverter) ToEntity(contractAddress string, contractAbi string, ethLog types.Log) (BiteEntity, error) {
|
||||
mbc.ConverterContract = contractAddress
|
||||
mbc.ConverterAbi = contractAbi
|
||||
mbc.LogsToConvert = append(mbc.LogsToConvert, ethLog)
|
||||
return test_data.BiteEntity, mbc.ConverterError
|
||||
}
|
||||
|
||||
func (mbc *MockBiteConverter) ToModel(entity BiteEntity) (BiteModel, error) {
|
||||
mbc.EntitiesToConvert = append(mbc.EntitiesToConvert, entity)
|
||||
return test_data.BiteModel, mbc.ConverterError
|
||||
}
|
||||
func (mbc *MockBiteConverter) SetConverterError(err error) {
|
||||
mbc.ConverterError = err
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// 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 bite
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/bite"
|
||||
)
|
||||
|
||||
type MockBiteRepository struct {
|
||||
createError error
|
||||
PassedEndingBlockNumber int64
|
||||
PassedBiteModel bite.BiteModel
|
||||
PassedHeaderID int64
|
||||
PassedStartingBlockNumber int64
|
||||
PassedTransactionIndex uint
|
||||
missingHeaders []core.Header
|
||||
missingHeadersErr error
|
||||
}
|
||||
|
||||
func (repository *MockBiteRepository) SetCreateError(err error) {
|
||||
repository.createError = err
|
||||
}
|
||||
|
||||
func (repository *MockBiteRepository) SetMissingHeadersErr(err error) {
|
||||
repository.missingHeadersErr = err
|
||||
}
|
||||
|
||||
func (repository *MockBiteRepository) SetMissingHeaders(headers []core.Header) {
|
||||
repository.missingHeaders = headers
|
||||
}
|
||||
|
||||
func (repository *MockBiteRepository) Create(headerID int64, model bite.BiteModel) error {
|
||||
repository.PassedHeaderID = headerID
|
||||
repository.PassedBiteModel = model
|
||||
return repository.createError
|
||||
}
|
||||
|
||||
func (repository *MockBiteRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
|
||||
repository.PassedStartingBlockNumber = startingBlockNumber
|
||||
repository.PassedEndingBlockNumber = endingBlockNumber
|
||||
return repository.missingHeaders, repository.missingHeadersErr
|
||||
}
|
||||
Reference in New Issue
Block a user