Skip to content

Commit

Permalink
fix name of solver table (#115)
Browse files Browse the repository at this point in the history
* fix name of solver table

* fix migration files
  • Loading branch information
iostream1308 authored Dec 31, 2024
1 parent 9e11b73 commit abfaf92
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 43 deletions.
75 changes: 75 additions & 0 deletions v2/cmd/migrations/00015_add_txorigin_table.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
DROP TABLE solver;
CREATE TABLE IF NOT EXISTS txorigin (
address TEXT NOT NULL,
name TEXT NOT NULL,
PRIMARY KEY(address)
);
INSERT INTO txorigin (address, name) VALUES
('0x9dfc9bb0fff2dc96728d2bb94eacee6ba3592351', 'cow-Rizzolver'),
('0x2854c9a92cd1dc65bddf45afe397d9d75d4718c8', 'cow-Rizzolver'),
('0x4fc4a61a3b99a1ad4a61b03f3752ca12b4a17646', 'cow-Rizzolver'),
('0x34717040928d7fd8154d4612f3228eff14521023', 'cow-Laita'),
('0xd0ba1b1782fbde45edab392428f60e14827d08ec', 'cow-Laita'),
('0x95480d3f27658e73b2785d30beb0c847d78294c7', 'cow-Fractal'),
('0x755bae1cd46c9c27a3230aef0ce923bda13d29f7', 'cow-Fractal'),
('0x2a2883ade8ce179265f12fc7b48a4b50b092f1fd', 'cow-Fractal'),
('0xab11302cb4f7c417e527a4d39c22aa9f04edb07d', 'cow-Fractal'),
('0x4339889fd9dfca20a423fba011e9dff1c856caeb', 'cow-GlueX_Protocol'),
('0x08924194cedd747dc85025b2b30a98d3ae1ce21d', 'cow-GlueX_Protocol'),
('0xbada5552a3e5e2fb57db982e29257821a2cf192d', 'cow-Project_Blanc'),
('0xc7899ff6a3ac2ff59261bd960a8c880df06e1041', 'cow-Barter'),
('0xbf54079c9bc879ae4dd6bc79bce11d3988fd9c2b', 'cow-Barter'),
('0x5f7a6aeec3d3e80558278632954da4b730996f83', 'cow-Barter'),
('0xb9332b6301e5983272c30dd5b48a4e3b1664511b', 'cow-Baseline'),
('0x01246d541e732d7f15d164331711edff217e4665', 'cow-Baseline'),
('0x00806daa2cfe49715ea05243ff259deb195760fc', 'cow-Quasilabs'),
('0x9b7e7f21d98f21c0354035798c40e9040e25787f', 'cow-Quasilabs'),
('0x68005a99946447be44d594832e1b164f6c034e63', 'cow-Quasilabs'),
('0x8f70a86c1309d8b1f5befc58948e7386fd495875', 'cow-Tsolver'),
('0xa432cea087311d7cd07925d70f799ee94e7893a4', 'cow-Tsolver'),
('0xc10d4dfda62227d9ec23ab0010e2942e48338a60', 'cow-Apollo'),
('0xa08b00576aee8d8dd960e08298fac9fd7c756e36', 'cow-Apollo'),
('0x0ddcb0769a3591230caa80f85469240b71442089', 'cow-Seasolver'),
('0xac6cc8e2f0232b5b213503257c861235f4ed42c1', 'cow-Seasolver'),
('0xe3067c7c27c1038de4e8ad95a83b927d23dfbd99', 'cow-PLM'),
('0x27ac9ed6b768d232855473600a7880a974b71780', 'cow-PLM'),
('0x28b1bd44996105b5c14c4de41093226ff78a4eb1', 'cow-0x'),
('0xcc73072b53697911ff394ae01d3de59c9900b0b0', 'cow-0x'),
('0x6f799f4bf6c1c56fb8d890e9e0fff2934b0de157', 'cow-Gnosis_1inch'),
('0x8616dcdfcecbde13ccd89eac358dc5abda79ec31', 'cow-Gnosis_1inch'),
('0x2224eaacc7c2dbf85d5355bab9e9271e01d30b55', 'cow-Sector_Finance'),
('0xc9f2e6ea1637e499406986ac50ddc92401ce1f58', 'cow-PropellerSwap'),
('0x3bf7c0e1728fb64bb0973b1e2a342f1c7eb1bb8e', 'cow-PropellerSwap'),
('0x9528e8c42f7e109baded964e2d927fd5b6ca71e9', 'cow-Odos'),
('0xf13eaf9093a210ebdaba581f5448ffa545ee2e65', 'cow-Odos'),
('0x0ab21031124af2165586fbb495d93725a372c227', 'cow-Enso'),
('0xeada531bc5361c9287088d857512e0ca812eaa68', 'cow-Enso'),
('0xa883710b6dbf008a1cc25722c54583e35884a209', 'cow-Horadrim'),
('0x2c3a1c33d96c9dca1c34eb234b1e65f79deae60e', 'cow-Horadrim'),
('0x8a75ee64b4a40f679ad98bcc38312702971e07b7', 'cow-OneBit_Quant'),
('0xe2823b5bd541ba8bff3d4bf55396567440772eab', 'cow-OneBit_Quant'),
('0xd50ecb485dcf5d97266122dfed979587dd8923ac', 'cow-Gnosis_BalancerSOR'),
('0x849bbdf910465913272a8262dda44279a82c5c76', 'cow-Gnosis_BalancerSOR'),
('0xc74b656bd2ebe313d26d1ac02bcf95b137d1c857', 'cow-Gnosis_0x'),
('0xa697c60706210a5ec6f9ccce364c507e604d9462', 'cow-Gnosis_0x'),
('0xdd2e786980cd58acc5f64807b354c981f4094936', 'cow-Gnosis_ParaSwap'),
('0x460aac34690189911ccb49d36e55ab548cf8a9a1', 'cow-Gnosis_ParaSwap'),
('0xff662eedb413273b6727e1f59755607ca6876044', 'cow-OpenOcean_Aggregator'),
('0x9902f0b57b6b8b2fa7339cd3efe0710cf63c86d6', 'cow-OpenOcean_Aggregator'),
('0xbeaf89aec78a2990be29e2a317feed6b75bc78cd', 'cow-Quasimodo'),
('0xaac451d13cf8d6915f859f4c7bc26da2df10eca6', 'cow-Quasimodo'),
('0x8646ee3c5e82b495be8f9fe2f2f213701eed0edc', 'cow-Seasolver_v2'),
('0x94aef67903bfe8bf65193a78074c887ba901d043', 'cow-Seasolver_v2'),
('0x16c473448e770ff647c69cbe19e28528877fba1b', 'cow-Copium_Capital'),
('0x008300082c3000009e63680088f8c7f4d3ff2e87', 'cow-Copium_Capital'),
('0x8e8c00ad7011aabea0e06e984cfa7194cf8b16b0', 'cow-Copium_Capital'),
('0xa5559c2e1302c5ce82582a6b1e4aec562c2fbcf4', 'cow-Project_Blanc'),
('0xbada55babee5d2b7f3b551f9da846838760e068c', 'cow-Project_Blanc'),
('0xd1508a211d98bb81195dc1f9533edcdf68adf036', 'cow-Furucombo'),
('0x279fb872beaf64e94890376725c423c0820eda97', 'cow-Furucombo'),
('0x6bf97afe2d2c790999cded2a8523009eb8a0823f', 'cow-Portus'),
('0x5131590ca2e9d3edc182581352b289dcae83430c', 'cow-Portus'),
('0x1a7a08423ab83e7939bf1df95952347d425e0a0a', 'cow-Naive'),
('0x854490ef1d402d4f6fce05abefe1c676eb0dcd74', 'cow-ApeOut_1Inch'),
('0x047a2fbe8aef590d4eb8942426a24970af301875', 'cow-Laertes'),
('0xdf4296e752fd08b2d7db4101b98a48b74e59fd56', 'cow-Legacy');
14 changes: 7 additions & 7 deletions v2/internal/server/tradelogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func (s *TradeLogs) register() {
s.r.GET("/tokens", s.getTokens)
s.r.GET("/makers", s.getMakerName)
s.r.POST("/makers", s.addMakerName)
s.r.GET("/solvers", s.getSolvers)
s.r.POST("/solvers", s.addSolvers)
s.r.GET("/txorigin", s.getTxOrigin)
s.r.POST("/txorigin", s.addTxOrigin)
}

func (s *TradeLogs) getTradeLogs(c *gin.Context) {
Expand Down Expand Up @@ -155,8 +155,8 @@ func (s *TradeLogs) addMakerName(c *gin.Context) {
})
}

func (s *TradeLogs) getSolvers(c *gin.Context) {
data, err := s.dashStorage.GetSolvers()
func (s *TradeLogs) getTxOrigin(c *gin.Context) {
data, err := s.dashStorage.GetTxOrigin()
if err != nil {
responseErr(c, http.StatusInternalServerError, err)
return
Expand All @@ -167,15 +167,15 @@ func (s *TradeLogs) getSolvers(c *gin.Context) {
})
}

func (s *TradeLogs) addSolvers(c *gin.Context) {
var queries []dashboardTypes.Solver
func (s *TradeLogs) addTxOrigin(c *gin.Context) {
var queries []dashboardTypes.TxOrigin

if err := c.ShouldBindJSON(&queries); err != nil {
responseErr(c, http.StatusBadRequest, err)
return
}

if err := s.dashStorage.InsertSolver(queries); err != nil {
if err := s.dashStorage.InsertTxOrigin(queries); err != nil {
responseErr(c, http.StatusInternalServerError, err)
return
}
Expand Down
28 changes: 14 additions & 14 deletions v2/pkg/storage/dashboard/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
const (
tokenTable = "token"
makerNameTable = "maker_name"
solverTable = "solver"
txOriginTable = "txorigin"
)

type Storage struct {
Expand Down Expand Up @@ -86,22 +86,22 @@ func (s *Storage) InsertMakerName(makerName []types.MakerName) error {
return nil
}

func (s *Storage) InsertSolver(solvers []types.Solver) error {
if len(solvers) == 0 {
func (s *Storage) InsertTxOrigin(txOrigins []types.TxOrigin) error {
if len(txOrigins) == 0 {
return nil
}

b := squirrel.StatementBuilder.PlaceholderFormat(squirrel.Dollar).Insert(solverTable).Columns(
types.SolverColumns()...,
b := squirrel.StatementBuilder.PlaceholderFormat(squirrel.Dollar).Insert(txOriginTable).Columns(
types.TxOriginColumns()...,
)
for _, solver := range solvers {
for _, txOrigin := range txOrigins {
b = b.Values(
solver.SerializeSolver()...,
txOrigin.SerializeTxOrigin()...,
)
}
q, p, err := b.Suffix(`ON CONFLICT (address) DO UPDATE
SET
solver_name=excluded.solver_name
name=excluded.name
`).ToSql()
if err != nil {
s.l.Errorw("Error build insert", "error", err)
Expand Down Expand Up @@ -165,20 +165,20 @@ func (s *Storage) GetMakerName() ([]types.MakerName, error) {
return makerName, nil
}

func (s *Storage) GetSolvers() ([]types.Solver, error) {
func (s *Storage) GetTxOrigin() ([]types.TxOrigin, error) {
builder := squirrel.StatementBuilder.PlaceholderFormat(squirrel.Dollar).
Select(types.SolverColumns()...).
From(solverTable)
Select(types.TxOriginColumns()...).
From(txOriginTable)

q, p, err := builder.ToSql()
if err != nil {
return nil, err
}

var solvers []types.Solver
if err := s.db.Select(&solvers, q, p...); err != nil {
var txOrigins []types.TxOrigin
if err := s.db.Select(&txOrigins, q, p...); err != nil {
return nil, err
}

return solvers, nil
return txOrigins, nil
}
22 changes: 0 additions & 22 deletions v2/pkg/storage/dashboard/types/solver.go

This file was deleted.

22 changes: 22 additions & 0 deletions v2/pkg/storage/dashboard/types/tx_origin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package types

import "strings"

type TxOrigin struct {
Address string `db:"address" json:"address"`
Name string `db:"name" json:"name"`
}

func (o *TxOrigin) SerializeTxOrigin() []interface{} {
return []interface{}{
strings.ToLower(o.Address),
o.Name,
}
}

func TxOriginColumns() []string {
return []string{
"address",
"name",
}
}

0 comments on commit abfaf92

Please sign in to comment.