forked from cerc-io/ipld-eth-server
Add transaction index to flip kick
This commit is contained in:
@@ -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))
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user