update frob and bite converters and repository
This commit is contained in:
parent
7e6302c662
commit
347a339687
@ -64,9 +64,9 @@ func database(cmd *cobra.Command, args []string) {
|
|||||||
ipc = viper.GetString("client.ipcpath")
|
ipc = viper.GetString("client.ipcpath")
|
||||||
levelDbPath = viper.GetString("client.leveldbpath")
|
levelDbPath = viper.GetString("client.leveldbpath")
|
||||||
databaseConfig = config.Database{
|
databaseConfig = config.Database{
|
||||||
Name: "vulcanize_public",
|
Name: viper.GetString("database.name"),
|
||||||
Hostname: "localhost",
|
Hostname: viper.GetString("database.hostname"),
|
||||||
Port: 5432,
|
Port: viper.GetInt("database.port"),
|
||||||
User: viper.GetString("database.user"),
|
User: viper.GetString("database.user"),
|
||||||
Password: viper.GetString("database.password"),
|
Password: viper.GetString("database.password"),
|
||||||
}
|
}
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
ALTER TABLE maker.bite
|
|
||||||
MODIFY ilk bytea;
|
|
||||||
|
|
||||||
ALTER TABLE maker.bite
|
|
||||||
MODIFY urn bytea;
|
|
||||||
|
|
||||||
ALTER TABLE maker.frob
|
|
||||||
MODIFY ilk bytea;
|
|
||||||
|
|
||||||
ALTER TABLE maker.frob
|
|
||||||
MODIFY urn bytea;
|
|
@ -0,0 +1,7 @@
|
|||||||
|
ALTER TABLE maker.bite
|
||||||
|
ALTER COLUMN ilk SET DATA TYPE bytea,
|
||||||
|
ALTER COLUMN urn SET DATA TYPE bytea;
|
||||||
|
|
||||||
|
ALTER TABLE maker.frob
|
||||||
|
ALTER COLUMN ilk SET DATA TYPE bytea,
|
||||||
|
ALTER COLUMN urn SET DATA TYPE bytea;
|
@ -19,6 +19,7 @@ package bite
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
@ -34,7 +35,7 @@ type BiteConverter struct{}
|
|||||||
func (BiteConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]BiteEntity, error) {
|
func (BiteConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]BiteEntity, error) {
|
||||||
var entities []BiteEntity
|
var entities []BiteEntity
|
||||||
for _, ethLog := range ethLogs {
|
for _, ethLog := range ethLogs {
|
||||||
entity := BiteEntity{}
|
entity := &BiteEntity{}
|
||||||
address := ethLog.Address
|
address := ethLog.Address
|
||||||
abi, err := geth.ParseAbi(contractAbi)
|
abi, err := geth.ParseAbi(contractAbi)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -43,7 +44,7 @@ func (BiteConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]Bite
|
|||||||
|
|
||||||
contract := bind.NewBoundContract(address, abi, nil, nil, nil)
|
contract := bind.NewBoundContract(address, abi, nil, nil, nil)
|
||||||
|
|
||||||
err = contract.UnpackLog(&entity, "Bite", ethLog)
|
err = contract.UnpackLog(entity, "Bite", ethLog)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -51,7 +52,7 @@ func (BiteConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]Bite
|
|||||||
entity.Raw = ethLog
|
entity.Raw = ethLog
|
||||||
entity.TransactionIndex = ethLog.TxIndex
|
entity.TransactionIndex = ethLog.TxIndex
|
||||||
|
|
||||||
entities = append(entities, entity)
|
entities = append(entities, *entity)
|
||||||
}
|
}
|
||||||
|
|
||||||
return entities, nil
|
return entities, nil
|
||||||
@ -61,8 +62,8 @@ func (converter BiteConverter) ToModels(entities []BiteEntity) ([]BiteModel, err
|
|||||||
var models []BiteModel
|
var models []BiteModel
|
||||||
for _, entity := range entities {
|
for _, entity := range entities {
|
||||||
id := entity.Id
|
id := entity.Id
|
||||||
ilk := entity.Ilk[:]
|
ilk := common.BytesToAddress(entity.Ilk[:common.AddressLength]).String()
|
||||||
urn := entity.Urn[:]
|
urn := common.BytesToAddress(entity.Urn[:common.AddressLength]).String()
|
||||||
ink := entity.Ink
|
ink := entity.Ink
|
||||||
art := entity.Art
|
art := entity.Art
|
||||||
iArt := entity.IArt
|
iArt := entity.IArt
|
||||||
|
@ -79,8 +79,8 @@ var _ = Describe("Bite Converter", func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
expectedModel := bite.BiteModel{
|
expectedModel := bite.BiteModel{
|
||||||
Id: "1",
|
Id: "1",
|
||||||
Ilk: "",
|
Ilk: "0x0000000000000000000000000000000000000000",
|
||||||
Urn: "",
|
Urn: "0x0000000000000000000000000000000000000000",
|
||||||
Ink: "",
|
Ink: "",
|
||||||
Art: "",
|
Art: "",
|
||||||
IArt: "",
|
IArt: "",
|
||||||
|
@ -21,8 +21,8 @@ import (
|
|||||||
|
|
||||||
type BiteEntity struct {
|
type BiteEntity struct {
|
||||||
Id *big.Int
|
Id *big.Int
|
||||||
Ilk string
|
Ilk [32]byte
|
||||||
Urn string
|
Urn [32]byte
|
||||||
Ink *big.Int
|
Ink *big.Int
|
||||||
Art *big.Int
|
Art *big.Int
|
||||||
Tab *big.Int
|
Tab *big.Int
|
||||||
|
@ -19,6 +19,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -56,8 +57,8 @@ func (FrobConverter) ToModels(entities []FrobEntity) ([]FrobModel, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
model := FrobModel{
|
model := FrobModel{
|
||||||
Ilk: entity.Ilk[:],
|
Ilk: common.BytesToAddress(entity.Ilk[:common.AddressLength]).String(),
|
||||||
Urn: entity.Urn[:],
|
Urn: common.BytesToAddress(entity.Urn[:common.AddressLength]).String(),
|
||||||
Ink: entity.Ink.String(),
|
Ink: entity.Ink.String(),
|
||||||
Art: entity.Art.String(),
|
Art: entity.Art.String(),
|
||||||
Dink: entity.Dink.String(),
|
Dink: entity.Dink.String(),
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
package frob
|
package frob
|
||||||
|
|
||||||
type FrobModel struct {
|
type FrobModel struct {
|
||||||
Ilk []byte
|
Ilk string
|
||||||
Urn []byte
|
Urn string
|
||||||
Ink string
|
Ink string
|
||||||
Art string
|
Art string
|
||||||
Dink string
|
Dink string
|
||||||
|
@ -40,8 +40,10 @@ var (
|
|||||||
biteIArt = big.NewInt(5)
|
biteIArt = big.NewInt(5)
|
||||||
biteRawJson, _ = json.Marshal(EthBiteLog)
|
biteRawJson, _ = json.Marshal(EthBiteLog)
|
||||||
biteRawString = string(biteRawJson)
|
biteRawString = string(biteRawJson)
|
||||||
biteIlk = "ilk"
|
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 = "urn"
|
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}
|
||||||
|
biteIlkString = "0x66616b6520696c6B000000000000000000000000"
|
||||||
|
biteLadString = "0x66616B65206c6164000000000000000000000000"
|
||||||
biteId = int64(1)
|
biteId = int64(1)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -76,8 +78,8 @@ var BiteEntity = bite.BiteEntity{
|
|||||||
|
|
||||||
var BiteModel = bite.BiteModel{
|
var BiteModel = bite.BiteModel{
|
||||||
Id: strconv.FormatInt(biteId, 10),
|
Id: strconv.FormatInt(biteId, 10),
|
||||||
Ilk: biteIlk,
|
Ilk: biteIlkString,
|
||||||
Urn: biteLad,
|
Urn: biteLadString,
|
||||||
Ink: biteInk.String(),
|
Ink: biteInk.String(),
|
||||||
Art: biteArt.String(),
|
Art: biteArt.String(),
|
||||||
Tab: biteTab.String(),
|
Tab: biteTab.String(),
|
||||||
|
@ -33,14 +33,16 @@ var (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// need to set bytes as 0 or else the big Int 0 evaluates differently from the one unpacked by the abi
|
// need to set bytes as 0 or else the big Int 0 evaluates differently from the one unpacked by the abi
|
||||||
art = big.NewInt(20)
|
art = big.NewInt(20)
|
||||||
dink = big.NewInt(10)
|
dink = big.NewInt(10)
|
||||||
dart = big.NewInt(0).SetBytes([]byte{0})
|
dart = big.NewInt(0).SetBytes([]byte{0})
|
||||||
iArt = big.NewInt(25)
|
iArt = big.NewInt(25)
|
||||||
frobLad = [32]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 217, 34, 137, 65, 83, 190, 158, 239, 123, 114, 24, 220, 86, 93, 29, 12, 226, 160, 146}
|
frobLad = [32]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 217, 34, 137, 65, 83, 190, 158, 239, 123, 114, 24, 220, 86, 93, 29, 12, 226, 160, 146}
|
||||||
gem, _ = big.NewInt(0).SetString("115792089237316195423570985008687907853269984665640564039457584007913129639926", 10)
|
gem, _ = big.NewInt(0).SetString("115792089237316195423570985008687907853269984665640564039457584007913129639926", 10)
|
||||||
ink = big.NewInt(15)
|
ink = big.NewInt(15)
|
||||||
ilk = [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}
|
ilk = [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}
|
||||||
|
frobIlkString = "0x66616b6520696c6B000000000000000000000000"
|
||||||
|
frobUrnString = "0x00000000000000000000000064D922894153BE9E"
|
||||||
)
|
)
|
||||||
|
|
||||||
var EthFrobLog = types.Log{
|
var EthFrobLog = types.Log{
|
||||||
@ -73,8 +75,8 @@ var FrobEntity = frob.FrobEntity{
|
|||||||
|
|
||||||
var rawFrobLog, _ = json.Marshal(EthFrobLog)
|
var rawFrobLog, _ = json.Marshal(EthFrobLog)
|
||||||
var FrobModel = frob.FrobModel{
|
var FrobModel = frob.FrobModel{
|
||||||
Ilk: ilk[:],
|
Ilk: frobIlkString,
|
||||||
Urn: frobLad[:],
|
Urn: frobUrnString,
|
||||||
Ink: ink.String(),
|
Ink: ink.String(),
|
||||||
Art: art.String(),
|
Art: art.String(),
|
||||||
Dink: dink.String(),
|
Dink: dink.String(),
|
||||||
|
Loading…
Reference in New Issue
Block a user