Skip to content

Commit

Permalink
change the jetton score field to required
Browse files Browse the repository at this point in the history
  • Loading branch information
zakhar-petukhov committed Jan 9, 2025
1 parent 026cfba commit 32316d9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 60 deletions.
7 changes: 2 additions & 5 deletions api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3821,10 +3821,6 @@
"example": "https://cache.tonapi.io/images/jetton.jpg",
"type": "string"
},
"score": {
"format": "int32",
"type": "integer"
},
"total_supply": {
"example": "5887105890579978",
"type": "string",
Expand Down Expand Up @@ -3983,7 +3979,8 @@
"symbol",
"decimals",
"verification",
"image"
"image",
"score"
],
"type": "object"
},
Expand Down
4 changes: 1 addition & 3 deletions api/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5415,6 +5415,7 @@ components:
- decimals
- verification
- image
- score
properties:
address:
type: string
Expand Down Expand Up @@ -7050,9 +7051,6 @@ components:
type: integer
format: int32
example: 2000
score:
type: integer
format: int32
JettonHolders:
type: object
required:
Expand Down
9 changes: 2 additions & 7 deletions pkg/api/jetton_converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ func jettonPreview(master ton.AccountID, meta NormalizedMetadata, score int32) o
Verification: oas.JettonVerificationType(meta.Verification),
Decimals: meta.Decimals,
Image: meta.PreviewImage,
Score: score,
}
if meta.CustomPayloadApiUri != "" {
preview.CustomPayloadAPIURI = oas.NewOptString(meta.CustomPayloadApiUri)
}
if score != 0 {
preview.Score = oas.NewOptInt32(score)
}
return preview
}

Expand Down Expand Up @@ -172,7 +170,7 @@ func (h *Handler) convertJettonBalance(ctx context.Context, wallet core.JettonWa
return jettonBalance, nil
}

func (h *Handler) convertJettonInfo(ctx context.Context, master core.JettonMaster, holders map[tongo.AccountID]int32, score int32) oas.JettonInfo {
func (h *Handler) convertJettonInfo(ctx context.Context, master core.JettonMaster, holders map[tongo.AccountID]int32) oas.JettonInfo {
meta := h.GetJettonNormalizedMetadata(ctx, master.Address)
metadata := jettonMetadata(master.Address, meta)
info := oas.JettonInfo{
Expand All @@ -184,8 +182,5 @@ func (h *Handler) convertJettonInfo(ctx context.Context, master core.JettonMaste
Admin: convertOptAccountAddress(master.Admin, h.addressBook),
Preview: meta.PreviewImage,
}
if score != 0 {
info.Score = oas.NewOptInt32(score)
}
return info
}
9 changes: 3 additions & 6 deletions pkg/api/jetton_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ func (h *Handler) GetJettonInfo(ctx context.Context, params oas.GetJettonInfoPar
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
score, _ := h.score.GetJettonScore(account.ID)
converted := h.convertJettonInfo(ctx, master, holders, score)
converted := h.convertJettonInfo(ctx, master, holders)
return &converted, nil
}

Expand Down Expand Up @@ -155,8 +154,7 @@ func (h *Handler) GetJettons(ctx context.Context, params oas.GetJettonsParams) (
}
results := make([]oas.JettonInfo, len(jettons))
for idx, master := range jettons {
score, _ := h.score.GetJettonScore(master.Address)
results[idx] = h.convertJettonInfo(ctx, master, holders, score)
results[idx] = h.convertJettonInfo(ctx, master, holders)
}
return &oas.Jettons{Jettons: results}, nil
}
Expand Down Expand Up @@ -287,8 +285,7 @@ func (h *Handler) GetJettonInfosByAddresses(ctx context.Context, request oas.Opt
}
results := make([]oas.JettonInfo, len(jettons))
for idx, master := range jettons {
score, _ := h.score.GetJettonScore(master.Address)
results[idx] = h.convertJettonInfo(ctx, master, jettonsHolders, score)
results[idx] = h.convertJettonInfo(ctx, master, jettonsHolders)
}

return &oas.Jettons{Jettons: results}, nil
Expand Down
33 changes: 8 additions & 25 deletions pkg/oas/oas_json_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 3 additions & 14 deletions pkg/oas/oas_schemas_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 32316d9

Please sign in to comment.