Skip to content

Commit 2d0e96d

Browse files
change the verified field to trust for the search accounts method
1 parent b95a7ea commit 2d0e96d

8 files changed

+74
-37
lines changed

api/openapi.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -3332,16 +3332,15 @@
33323332
"example": "https://cache.tonapi.io/images/media.jpg",
33333333
"type": "string"
33343334
},
3335-
"verified": {
3336-
"example": true,
3337-
"type": "boolean"
3335+
"trust": {
3336+
"$ref": "#/components/schemas/TrustType"
33383337
}
33393338
},
33403339
"required": [
33413340
"address",
33423341
"name",
33433342
"preview",
3344-
"verified"
3343+
"trust"
33453344
],
33463345
"type": "object"
33473346
},

api/openapi.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -7290,7 +7290,7 @@ components:
72907290
- address
72917291
- name
72927292
- preview
7293-
- verified
7293+
- trust
72947294
properties:
72957295
address:
72967296
type: string
@@ -7301,9 +7301,8 @@ components:
73017301
preview:
73027302
type: string
73037303
example: "https://cache.tonapi.io/images/media.jpg"
7304-
verified:
7305-
type: boolean
7306-
example: true
7304+
trust:
7305+
$ref: '#/components/schemas/TrustType'
73077306
DnsExpiring:
73087307
type: object
73097308
required:

pkg/addressbook/addressbook.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (b *Book) SearchAttachedAccountsByPrefix(prefix string) []AttachedAccount {
134134
key := fmt.Sprintf("%v:%v", account.Wallet.ToRaw(), account.Normalized)
135135
existing, ok := exclusiveAccounts[key]
136136
// Ensure only one account per wallet is included
137-
if !ok || (!existing.Verified && account.Verified) {
137+
if !ok || (existing.Trust != core.TrustWhitelist && account.Trust == core.TrustWhitelist) {
138138
exclusiveAccounts[key] = account
139139
}
140140
}
@@ -148,7 +148,7 @@ func (b *Book) SearchAttachedAccountsByPrefix(prefix string) []AttachedAccount {
148148
if normalized == prefix || normalized == tonDomainPrefix || normalized == tgDomainPrefix {
149149
accounts[i].Weight *= BoostForFullMatch
150150
}
151-
if accounts[i].Verified {
151+
if accounts[i].Trust == core.TrustWhitelist {
152152
accounts[i].Weight *= BoostForVerified
153153
}
154154
}
@@ -304,7 +304,7 @@ func (m *manualAddresser) refreshAddresses(addressPath string) error {
304304
weight *= BoostForOriginalName
305305
}
306306
// Convert known account to attached account
307-
attachedAccount, err := ConvertAttachedAccount(name, item.Image, account.ID, weight, true, ManualAccountType)
307+
attachedAccount, err := ConvertAttachedAccount(name, item.Image, account.ID, weight, core.TrustWhitelist, ManualAccountType)
308308
if err != nil {
309309
continue
310310
}
@@ -395,7 +395,7 @@ func (b *Book) refreshJettons(addresser *manualAddresser, jettonPath string) err
395395
weight *= BoostForOriginalName
396396
}
397397
// Convert known account to attached account
398-
attachedAccount, err := ConvertAttachedAccount(name, item.Image, account.ID, weight, true, JettonNameAccountType)
398+
attachedAccount, err := ConvertAttachedAccount(name, item.Image, account.ID, weight, core.TrustWhitelist, JettonNameAccountType)
399399
if err != nil {
400400
continue
401401
}

pkg/addressbook/attached_accounts.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"strings"
66

7+
"github.com/tonkeeper/opentonapi/pkg/core"
78
imgGenerator "github.com/tonkeeper/opentonapi/pkg/image"
89
"github.com/tonkeeper/opentonapi/pkg/references"
910
rules "github.com/tonkeeper/scam_backoffice_rules"
@@ -28,12 +29,12 @@ type AttachedAccount struct {
2829
Type AttachedAccountType `json:"-"`
2930
Weight int64 `json:"-"`
3031
Popular int64 `json:"-"`
31-
Verified bool `json:"-"`
32+
Trust core.TrustType `json:"-"`
3233
Normalized string `json:"-"`
3334
}
3435

3536
// ConvertAttachedAccount converts a known account to an attached account
36-
func ConvertAttachedAccount(slug, image string, account ton.AccountID, weight int, verified bool, accountType AttachedAccountType) (AttachedAccount, error) {
37+
func ConvertAttachedAccount(slug, image string, account ton.AccountID, weight int, trust core.TrustType, accountType AttachedAccountType) (AttachedAccount, error) {
3738
var name string
3839
// Handle different account types and assign appropriate values
3940
switch accountType {
@@ -75,7 +76,7 @@ func ConvertAttachedAccount(slug, image string, account ton.AccountID, weight in
7576
Type: accountType,
7677
Weight: int64(weight),
7778
Popular: int64(weight),
78-
Verified: verified,
79+
Trust: trust,
7980
Normalized: rules.NormalizeJettonSymbol(slug),
8081
}, nil
8182
}

pkg/api/account_handlers.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,10 @@ func (h *Handler) SearchAccounts(ctx context.Context, params oas.SearchAccountsP
279279
converted := make([]oas.FoundAccountsAddressesItem, len(accounts))
280280
for idx, account := range accounts {
281281
converted[idx] = oas.FoundAccountsAddressesItem{
282-
Address: account.Wallet.ToRaw(),
283-
Name: account.Name,
284-
Preview: account.Preview,
285-
Verified: account.Verified,
282+
Address: account.Wallet.ToRaw(),
283+
Name: account.Name,
284+
Preview: account.Preview,
285+
Trust: oas.TrustType(account.Trust),
286286
}
287287
}
288288
return &oas.FoundAccounts{Addresses: converted}, nil

pkg/oas/oas_json_gen.go

+6-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/oas/oas_schemas_gen.go

+10-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/oas/oas_validators_gen.go

+40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)