Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sorting by account type for the account search method #372

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3011,11 +3011,20 @@
"preview": {
"example": "https://cache.tonapi.io/images/media.jpg",
"type": "string"
},
"type": {
"enum": [
"jetton",
"nft",
"wallet"
],
"type": "string"
}
},
"required": [
"address",
"name",
"type",
"preview"
],
"type": "object"
Expand Down
7 changes: 7 additions & 0 deletions api/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6421,6 +6421,7 @@ components:
required:
- address
- name
- type
- preview
properties:
address:
Expand All @@ -6432,6 +6433,12 @@ components:
preview:
type: string
example: "https://cache.tonapi.io/images/media.jpg"
type:
type: string
enum:
- jetton
- nft
- wallet
DnsExpiring:
type: object
required:
Expand Down
18 changes: 0 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -270,26 +270,8 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tonkeeper/scam_backoffice_rules v0.0.0-20240412152144-9fb01586a942 h1:5yExly0WuV9P0e2nHWeDV86qQ+7zKeNTWqIpoIJ+g9M=
github.com/tonkeeper/scam_backoffice_rules v0.0.0-20240412152144-9fb01586a942/go.mod h1:SqZXYO9vbID8ku+xnnaKXeNGmehxigODGrk5V1KqbRA=
github.com/tonkeeper/scam_backoffice_rules v0.0.0-20240522102801-ac5f863d8f14 h1:09T5ALZw2OOuxJmUGnK1saTBv/+wPGyBL7b4rRDGsk0=
github.com/tonkeeper/scam_backoffice_rules v0.0.0-20240522102801-ac5f863d8f14/go.mod h1:SqZXYO9vbID8ku+xnnaKXeNGmehxigODGrk5V1KqbRA=
github.com/tonkeeper/tongo v1.7.2 h1:v5Tmmqn4oNUlLTB+ASAZNuBXtBqqFhS6Nd5D4ie99J0=
github.com/tonkeeper/tongo v1.7.2/go.mod h1:MjgIgAytFarjCoVjMLjYEtpZNN1f2G/pnZhKjr28cWs=
github.com/tonkeeper/tongo v1.8.0 h1:vYFm1xzEnuVsNRHTAghVB9bujc49i+9ovjGTHWxaQ0w=
github.com/tonkeeper/tongo v1.8.0/go.mod h1:MjgIgAytFarjCoVjMLjYEtpZNN1f2G/pnZhKjr28cWs=
github.com/tonkeeper/tongo v1.8.1 h1:1cix2RL2+Oifbr2jaVCTehJBmS9DACxMnstx7050F+U=
github.com/tonkeeper/tongo v1.8.1/go.mod h1:MjgIgAytFarjCoVjMLjYEtpZNN1f2G/pnZhKjr28cWs=
github.com/tonkeeper/tongo v1.8.2 h1:zu3jteP87OtYhP7gDKv9643qaDwm6NF3lDCQgEy72jc=
github.com/tonkeeper/tongo v1.8.2/go.mod h1:MjgIgAytFarjCoVjMLjYEtpZNN1f2G/pnZhKjr28cWs=
github.com/tonkeeper/tongo v1.8.3 h1:9NOUa6gkdzRINcDLTzHE9j89YRKS3d3Lu+og5RFPa4E=
github.com/tonkeeper/tongo v1.8.3/go.mod h1:MjgIgAytFarjCoVjMLjYEtpZNN1f2G/pnZhKjr28cWs=
github.com/tonkeeper/tongo v1.8.5 h1:oG2i4tiNK+DeeiFd5E27SRn2tjF0gFqpzm1yUN1Ituo=
github.com/tonkeeper/tongo v1.8.5/go.mod h1:MjgIgAytFarjCoVjMLjYEtpZNN1f2G/pnZhKjr28cWs=
github.com/tonkeeper/tongo v1.8.7 h1:tg24GzBAltO4RGZFNZOt+7CpsZEI42m3dHruG1GzMI4=
github.com/tonkeeper/tongo v1.8.7/go.mod h1:MjgIgAytFarjCoVjMLjYEtpZNN1f2G/pnZhKjr28cWs=
github.com/tonkeeper/tongo v1.8.8 h1:n7boS77Gg/SG0g5pvxcS66deNsHyMqlRJ+gLZzq3fos=
github.com/tonkeeper/tongo v1.8.8/go.mod h1:MjgIgAytFarjCoVjMLjYEtpZNN1f2G/pnZhKjr28cWs=
github.com/tonkeeper/tongo v1.8.9 h1:JC4tjO2s4/741oxHIzWl2IaETLYZ2YIshByDJDuf/Do=
github.com/tonkeeper/tongo v1.8.9/go.mod h1:MjgIgAytFarjCoVjMLjYEtpZNN1f2G/pnZhKjr28cWs=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
Expand Down
19 changes: 14 additions & 5 deletions pkg/addressbook/addressbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,22 @@ type KnownAddress struct {
Image string `json:"image,omitempty"`
}

type AccountType string

const (
Jetton AccountType = "jetton"
Nft AccountType = "nft"
Wallet AccountType = "wallet"
)

// AttachedAccount represents domains, nft collections for quick search by name are presented
type AttachedAccount struct {
Name string `json:"name"`
Preview string `json:"preview"`
Wallet string `json:"wallet"`
Symbol string `json:"-"`
Normalized string `json:"-"`
Name string `json:"name"`
Preview string `json:"preview"`
Wallet string `json:"wallet"`
AccountType AccountType `json:"-"`
Symbol string `json:"-"`
Normalized string `json:"-"`
}

type JettonVerificationType string
Expand Down
6 changes: 5 additions & 1 deletion pkg/api/account_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,16 @@ func (h *Handler) SearchAccounts(ctx context.Context, params oas.SearchAccountsP
response.Addresses = append(response.Addresses, oas.FoundAccountsAddressesItem{
Address: account.Wallet,
Name: account.Name,
Type: oas.FoundAccountsAddressesItemType(account.AccountType),
Preview: account.Preview,
})
}

sort.Slice(response.Addresses, func(i, j int) bool {
return response.Addresses[i].Address == references.USDT.ToRaw()
if response.Addresses[i].Address == references.USDT.ToRaw() {
return true
}
return response.Addresses[i].Type == oas.FoundAccountsAddressesItemTypeWallet
})

return &response, nil
Expand Down
61 changes: 59 additions & 2 deletions pkg/oas/oas_json_gen.go

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

65 changes: 62 additions & 3 deletions pkg/oas/oas_schemas_gen.go

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

53 changes: 53 additions & 0 deletions pkg/oas/oas_validators_gen.go

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

Loading