Skip to content

Commit

Permalink
add option to filter unsupported extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-tron committed Aug 14, 2024
1 parent f7107d2 commit 057e5aa
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 0 deletions.
19 changes: 19 additions & 0 deletions api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,22 @@
"type": "integer"
}
},
"supportedExtensions": {
"description": "comma separated list supported extensions",
"explode": false,
"in": "query",
"name": "supported_extensions",
"required": false,
"schema": {
"example": [
"custom_payload"
],
"items": {
"type": "string"
},
"type": "array"
}
},
"targetBlockIDExtQuery": {
"description": "target block: (workchain,shard,seqno,root_hash,file_hash)",
"in": "query",
Expand Down Expand Up @@ -6468,6 +6484,9 @@
},
{
"$ref": "#/components/parameters/currenciesQuery"
},
{
"$ref": "#/components/parameters/supportedExtensions"
}
],
"responses": {
Expand Down
12 changes: 12 additions & 0 deletions api/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ paths:
parameters:
- $ref: '#/components/parameters/accountIDParameter'
- $ref: '#/components/parameters/currenciesQuery'
- $ref: '#/components/parameters/supportedExtensions'
responses:
'200':
description: account jettons balances
Expand Down Expand Up @@ -3002,6 +3003,17 @@ components:
items:
type: string
example: [ "ton", "usd", "rub" ]
supportedExtensions:
in: query
name: supported_extensions
description: "comma separated list supported extensions"
explode: false
required: false
schema:
type: array
items:
type: string
example: ["custom_payload"]
currencyQuery:
in: query
name: currency
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/jetton_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"net/http"
"slices"
"strings"

"github.com/tonkeeper/opentonapi/pkg/bath"
Expand All @@ -30,6 +31,9 @@ func (h *Handler) GetAccountJettonsBalances(ctx context.Context, params oas.GetA
Balances: make([]oas.JettonBalance, 0, len(wallets)),
}
for _, wallet := range wallets {
if slices.Contains(wallet.Extensions, "custom_payload") && !slices.Contains(params.SupportedExtensions, "custom_payload") {
continue
}
jettonBalance, err := h.convertJettonBalance(ctx, wallet, params.Currencies)
if err != nil {
continue
Expand Down
4 changes: 4 additions & 0 deletions pkg/oas/oas_handlers_gen.go

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

54 changes: 54 additions & 0 deletions pkg/oas/oas_parameters_gen.go

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

0 comments on commit 057e5aa

Please sign in to comment.