Skip to content

Commit

Permalink
Add vm column
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Sep 16, 2024
1 parent 88f1180 commit d226af3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cmd/api/handler/responses/rollup.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type RollupWithStats struct {
Stack string `example:"op_stack" format:"string" json:"stack,omitempty" swaggertype:"string"`
Type string `example:"settled" format:"string" json:"type,omitempty" swaggertype:"string"`
Category string `example:"nft" format:"string" json:"category,omitempty" swaggertype:"string"`
VM string `example:"evm" format:"string" json:"vm,omitempty" swaggertype:"string"`
Provider string `example:"name" format:"string" json:"provider,omitempty" swaggertype:"string"`
Compression string `example:"zip" format:"string" json:"compression,omitempty" swaggertype:"string"`

Expand Down Expand Up @@ -66,6 +67,7 @@ func NewRollupWithStats(r storage.RollupWithStats) RollupWithStats {
Category: r.Category.String(),
Type: r.Type.String(),
Provider: r.Provider,
VM: r.VM,
Fee: r.Fee.StringFixed(0),
}
}
Expand All @@ -87,6 +89,7 @@ type Rollup struct {
Category string `example:"nft" format:"string" json:"category,omitempty" swaggertype:"string"`
Provider string `example:"name" format:"string" json:"provider,omitempty" swaggertype:"string"`
Compression string `example:"zip" format:"string" json:"compression,omitempty" swaggertype:"string"`
VM string `example:"evm" format:"string" json:"vm,omitempty" swaggertype:"string"`

Links []string `json:"links,omitempty"`
}
Expand All @@ -110,6 +113,7 @@ func NewRollup(r *storage.Rollup) Rollup {
Category: r.Category.String(),
Type: r.Type.String(),
Provider: r.Provider,
VM: r.VM,
}
}

Expand Down Expand Up @@ -149,6 +153,7 @@ type RollupWithDayStats struct {
Category string `example:"nft" format:"string" json:"category,omitempty" swaggertype:"string"`
Provider string `example:"name" format:"string" json:"provider,omitempty" swaggertype:"string"`
Compression string `example:"zip" format:"string" json:"compression,omitempty" swaggertype:"string"`
VM string `example:"evm" format:"string" json:"vm,omitempty" swaggertype:"string"`

AvgSize int64 `example:"100" format:"integer" json:"avg_size" swaggertype:"integer"`
BlobsCount int64 `example:"100" format:"integer" json:"blobs_count" swaggertype:"integer"`
Expand Down Expand Up @@ -179,6 +184,7 @@ func NewRollupWithDayStats(r storage.RollupWithDayStats) RollupWithDayStats {
Category: r.Category.String(),
Type: r.Type.String(),
Provider: r.Provider,
VM: r.VM,
Slug: r.Slug,
BlobsCount: r.BlobsCount,
AvgSize: int64(r.AvgSize),
Expand Down
4 changes: 4 additions & 0 deletions cmd/api/handler/rollup_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type createRollupRequest struct {
Category string `json:"category" validate:"omitempty,oneof=nft gaming finance"`
Type string `json:"type" validate:"omitempty,oneof=settled sovereign"`
Compression string `json:"compression" validate:"omitempty"`
VM string `json:"vm" validate:"omitempty"`
Provider string `json:"provider" validate:"omitempty"`
Providers []rollupProvider `json:"providers" validate:"required,min=1"`
}
Expand Down Expand Up @@ -94,6 +95,7 @@ func (handler RollupAuthHandler) createRollup(ctx context.Context, req *createRo
Links: req.Links,
Compression: req.Compression,
Provider: req.Provider,
VM: req.VM,
Type: enums.RollupType(req.Type),
Category: enums.RollupCategory(req.Category),
Slug: slug.Make(req.Name),
Expand Down Expand Up @@ -164,6 +166,7 @@ type updateRollupRequest struct {
Type string `json:"type" validate:"omitempty,oneof=settled sovereign"`
Compression string `json:"compression" validate:"omitempty"`
Provider string `json:"provider" validate:"omitempty"`
VM string `json:"vm" validate:"omitempty"`
Links []string `json:"links" validate:"omitempty,dive,url"`
Providers []rollupProvider `json:"providers" validate:"omitempty,min=1"`
}
Expand Down Expand Up @@ -206,6 +209,7 @@ func (handler RollupAuthHandler) updateRollup(ctx context.Context, req *updateRo
Stack: req.Stack,
Compression: req.Compression,
Provider: req.Provider,
VM: req.VM,
Type: enums.RollupType(req.Type),
Category: enums.RollupCategory(req.Category),
Links: req.Links,
Expand Down
3 changes: 3 additions & 0 deletions internal/storage/postgres/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,9 @@ func (tx Transaction) UpdateRollup(ctx context.Context, rollup *models.Rollup) e
if rollup.Compression != "" {
query = query.Set("compression = ?", rollup.Compression)
}
if rollup.VM != "" {
query = query.Set("vm = ?", rollup.VM)
}

_, err := query.Exec(ctx)
return err
Expand Down
4 changes: 3 additions & 1 deletion internal/storage/rollup.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type Rollup struct {
Provider string `bun:"provider" comment:"RaaS provider"`
Type types.RollupType `bun:"type,type:rollup_type" comment:"Type of rollup: settled or sovereign"`
Category types.RollupCategory `bun:"category,type:rollup_category" comment:"Category of rollup"`
VM string `bun:"vm" comment:"Virtual machine"`
Links []string `bun:"links,array" comment:"Other links to rollup related sites"`

Providers []*RollupProvider `bun:"rel:has-many,join:id=rollup_id"`
Expand All @@ -75,7 +76,8 @@ func (r Rollup) IsEmpty() bool {
r.Category == "" &&
r.Compression == "" &&
r.Provider == "" &&
r.Type == ""
r.Type == "" &&
r.VM == ""
}

type RollupWithStats struct {
Expand Down

0 comments on commit d226af3

Please sign in to comment.