-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert EigenState models to use sqlite
- Loading branch information
1 parent
b61be16
commit 3884e65
Showing
10 changed files
with
146 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
internal/sqlite/migrations/202409061250_eigenlayerStateTables/up.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package _202409061250_eigenlayerStateTables | ||
|
||
import ( | ||
"fmt" | ||
"gorm.io/gorm" | ||
) | ||
|
||
type SqliteMigration struct { | ||
} | ||
|
||
func (m *SqliteMigration) Up(grm *gorm.DB) error { | ||
queries := []string{ | ||
`create table if not exists registered_avs_operators ( | ||
operator TEXT NOT NULL, | ||
avs TEXT NOT NULL, | ||
block_number INTEGER NOT NULL, | ||
created_at DATETIME default current_timestamp, | ||
unique(operator, avs, block_number) | ||
); | ||
`, | ||
} | ||
|
||
for _, query := range queries { | ||
if res := grm.Exec(query); res.Error != nil { | ||
fmt.Printf("Failed to execute query: %s\n", query) | ||
return res.Error | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func (m *SqliteMigration) GetName() string { | ||
return "202409061250_eigenlayerStateTables" | ||
} |
31 changes: 31 additions & 0 deletions
31
internal/sqlite/migrations/202409061720_operatorShareChanges/up.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package _202409061720_operatorShareChanges | ||
|
||
import ( | ||
"gorm.io/gorm" | ||
) | ||
|
||
type SqliteMigration struct { | ||
} | ||
|
||
func (m *SqliteMigration) Up(grm *gorm.DB) error { | ||
queries := []string{ | ||
`create table if not exists operator_shares ( | ||
operator TEXT NOT NULL, | ||
strategy TEXT NOT NULL, | ||
shares NUMERIC NOT NULL, | ||
block_number INTEGER NOT NULL, | ||
created_at DATETIME default current_timestamp, | ||
unique (operator, strategy, block_number) | ||
)`, | ||
} | ||
for _, query := range queries { | ||
if res := grm.Exec(query); res.Error != nil { | ||
return res.Error | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func (m *SqliteMigration) GetName() string { | ||
return "202409061720_operatorShareChanges" | ||
} |
30 changes: 30 additions & 0 deletions
30
internal/sqlite/migrations/202409062151_stakerDelegations/up.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package _202409062151_stakerDelegations | ||
|
||
import ( | ||
"gorm.io/gorm" | ||
) | ||
|
||
type SqliteMigration struct { | ||
} | ||
|
||
func (m *SqliteMigration) Up(grm *gorm.DB) error { | ||
queries := []string{ | ||
`create table if not exists delegated_stakers ( | ||
staker TEXT NOT NULL, | ||
operator TEXT NOT NULL, | ||
block_number INTEGER NOT NULL, | ||
created_at DATETIME default current_timestamp, | ||
unique(staker, operator, block_number) | ||
)`, | ||
} | ||
for _, query := range queries { | ||
if res := grm.Exec(query); res.Error != nil { | ||
return res.Error | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func (m *SqliteMigration) GetName() string { | ||
return "202409062151_stakerDelegations" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters