Add transaction index to flip kick
This commit is contained in:
parent
a843de5eb7
commit
b2ba7ee1e3
@ -8,5 +8,6 @@ CREATE TABLE maker.flip_kick (
|
||||
"end" TIMESTAMP WITH TIME ZONE,
|
||||
urn VARCHAR,
|
||||
tab NUMERIC,
|
||||
tx_idx INTEGER NOT NUll,
|
||||
raw_log JSONB
|
||||
);
|
||||
|
@ -233,6 +233,7 @@ CREATE TABLE maker.flip_kick (
|
||||
"end" timestamp with time zone,
|
||||
urn character varying,
|
||||
tab numeric,
|
||||
tx_idx integer NOT NULL,
|
||||
raw_log jsonb
|
||||
);
|
||||
|
||||
|
@ -49,6 +49,7 @@ func (FlipKickConverter) ToEntity(contractAddress string, contractAbi string, et
|
||||
return entity, err
|
||||
}
|
||||
entity.Raw = ethLog
|
||||
entity.TransactionIndex = ethLog.TxIndex
|
||||
return entity, nil
|
||||
}
|
||||
|
||||
@ -72,13 +73,14 @@ func (FlipKickConverter) ToModel(flipKick FlipKickEntity) (FlipKickModel, error)
|
||||
rawLogString := string(rawLogJson)
|
||||
|
||||
return FlipKickModel{
|
||||
Id: id,
|
||||
Lot: lot,
|
||||
Bid: bid,
|
||||
Gal: gal,
|
||||
End: end,
|
||||
Urn: urn,
|
||||
Tab: tab,
|
||||
Raw: rawLogString,
|
||||
Id: id,
|
||||
Lot: lot,
|
||||
Bid: bid,
|
||||
Gal: gal,
|
||||
End: end,
|
||||
Urn: urn,
|
||||
Tab: tab,
|
||||
TransactionIndex: flipKick.TransactionIndex,
|
||||
Raw: rawLogString,
|
||||
}, nil
|
||||
}
|
||||
|
@ -22,12 +22,13 @@ import (
|
||||
)
|
||||
|
||||
type FlipKickEntity struct {
|
||||
Id *big.Int
|
||||
Lot *big.Int
|
||||
Bid *big.Int
|
||||
Gal common.Address
|
||||
End *big.Int
|
||||
Urn [32]byte
|
||||
Tab *big.Int
|
||||
Raw types.Log
|
||||
Id *big.Int
|
||||
Lot *big.Int
|
||||
Bid *big.Int
|
||||
Gal common.Address
|
||||
End *big.Int
|
||||
Urn [32]byte
|
||||
Tab *big.Int
|
||||
TransactionIndex uint
|
||||
Raw types.Log
|
||||
}
|
||||
|
@ -17,12 +17,13 @@ package flip_kick
|
||||
import "time"
|
||||
|
||||
type FlipKickModel struct {
|
||||
Id string
|
||||
Lot string
|
||||
Bid string
|
||||
Gal string
|
||||
End time.Time
|
||||
Urn string
|
||||
Tab string
|
||||
Raw string `db:"raw_log"`
|
||||
Id string
|
||||
Lot string
|
||||
Bid string
|
||||
Gal string
|
||||
End time.Time
|
||||
Urn string
|
||||
Tab string
|
||||
TransactionIndex uint `db:"tx_idx"`
|
||||
Raw string `db:"raw_log"`
|
||||
}
|
||||
|
@ -35,16 +35,11 @@ func NewFlipKickRepository(db *postgres.DB) FlipKickRepository {
|
||||
}
|
||||
func (fkr FlipKickRepository) Create(headerId int64, flipKick FlipKickModel) error {
|
||||
_, err := fkr.DB.Exec(
|
||||
`INSERT into maker.flip_kick (header_id, id, lot, bid, gal, "end", urn, tab, raw_log)
|
||||
VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9)`,
|
||||
headerId, flipKick.Id, flipKick.Lot, flipKick.Bid, flipKick.Gal, flipKick.End, flipKick.Urn, flipKick.Tab, flipKick.Raw,
|
||||
`INSERT into maker.flip_kick (header_id, id, lot, bid, gal, "end", urn, tab, tx_idx, raw_log)
|
||||
VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)`,
|
||||
headerId, flipKick.Id, flipKick.Lot, flipKick.Bid, flipKick.Gal, flipKick.End, flipKick.Urn, flipKick.Tab, flipKick.TransactionIndex, flipKick.Raw,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
func (fkr FlipKickRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
|
||||
|
@ -71,6 +71,7 @@ var _ = Describe("FlipKick Repository", func() {
|
||||
Expect(dbResult.End.Equal(flipKick.End)).To(BeTrue())
|
||||
Expect(dbResult.Urn).To(Equal(flipKick.Urn))
|
||||
Expect(dbResult.Tab).To(Equal(flipKick.Tab))
|
||||
Expect(dbResult.TransactionIndex).To(Equal(flipKick.TransactionIndex))
|
||||
Expect(dbResult.Raw).To(MatchJSON(flipKick.Raw))
|
||||
})
|
||||
|
||||
|
@ -61,32 +61,34 @@ var EthFlipKickLog = types.Log{
|
||||
Data: hexutil.MustDecode(flipKickData),
|
||||
BlockNumber: uint64(FlipKickBlockNumber),
|
||||
TxHash: common.HexToHash(flipKickTransactionHash),
|
||||
TxIndex: 0,
|
||||
TxIndex: 999,
|
||||
BlockHash: common.HexToHash(flipKickBlockHash),
|
||||
Index: 0,
|
||||
Removed: false,
|
||||
}
|
||||
|
||||
var FlipKickEntity = flip_kick.FlipKickEntity{
|
||||
Id: id,
|
||||
Lot: lot,
|
||||
Bid: bid,
|
||||
Gal: common.HexToAddress(gal),
|
||||
End: big.NewInt(end),
|
||||
Urn: urn,
|
||||
Tab: tab,
|
||||
Raw: EthFlipKickLog,
|
||||
Id: id,
|
||||
Lot: lot,
|
||||
Bid: bid,
|
||||
Gal: common.HexToAddress(gal),
|
||||
End: big.NewInt(end),
|
||||
Urn: urn,
|
||||
Tab: tab,
|
||||
TransactionIndex: EthFlipKickLog.TxIndex,
|
||||
Raw: EthFlipKickLog,
|
||||
}
|
||||
|
||||
var FlipKickModel = flip_kick.FlipKickModel{
|
||||
Id: idString,
|
||||
Lot: lotString,
|
||||
Bid: bidString,
|
||||
Gal: gal,
|
||||
End: time.Unix(end, 0),
|
||||
Urn: urnString,
|
||||
Tab: tabString,
|
||||
Raw: rawLogString,
|
||||
Id: idString,
|
||||
Lot: lotString,
|
||||
Bid: bidString,
|
||||
Gal: gal,
|
||||
End: time.Unix(end, 0),
|
||||
Urn: urnString,
|
||||
Tab: tabString,
|
||||
TransactionIndex: EthFlipKickLog.TxIndex,
|
||||
Raw: rawLogString,
|
||||
}
|
||||
|
||||
type FlipKickDBRow struct {
|
||||
|
Loading…
Reference in New Issue
Block a user