Skip to content

Commit

Permalink
update the jetton rates map to skip holder count and update meta for …
Browse files Browse the repository at this point in the history
…mintless jettons
  • Loading branch information
zakhar-petukhov committed Sep 9, 2024
1 parent c3a40d8 commit cace9c2
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 34 deletions.
4 changes: 4 additions & 0 deletions api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3696,6 +3696,10 @@
},
"type": "array"
},
"custom_payload_api_uri": {
"example": "https://claim-api.tonapi.io/jettons/TESTMINT",
"type": "string"
},
"decimals": {
"example": "9",
"type": "string"
Expand Down
13 changes: 8 additions & 5 deletions api/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3092,7 +3092,7 @@ components:
type: array
items:
type: string
example: ["custom_payload"]
example: [ "custom_payload" ]
currencyQuery:
in: query
name: currency
Expand Down Expand Up @@ -3667,9 +3667,9 @@ components:
format: cell
example: b5ee9c72010106010044000114ff00f4a413f4bcf2c80b01020120020302014804050004f2300038d06c21d31f30ed44d0d33f3001c00197a4c8cb3fc9ed549330f206e20011a13431da89a1a67e61
interfaces:
type: array
items:
type: string
type: array
items:
type: string
Message:
type: object
required:
Expand Down Expand Up @@ -6786,6 +6786,9 @@ components:
items:
type: string
example: [ "https://coinmarketcap.com/currencies/drv/", "https://www.coingecko.com/en/coins/durov" ]
custom_payload_api_uri:
type: string
example: "https://claim-api.tonapi.io/jettons/TESTMINT"
InscriptionBalances:
type: object
required:
Expand Down Expand Up @@ -6886,7 +6889,7 @@ components:
JettonTransferPayload:
type: object
required:
- payload
- payload
properties:
custom_payload:
type: string
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/sourcegraph/conc v0.3.0
github.com/stretchr/testify v1.9.0
github.com/tonkeeper/scam_backoffice_rules v0.0.0-20240822052421-6e4f645f0bc7
github.com/tonkeeper/tongo v1.9.3
github.com/tonkeeper/tongo v1.9.4
go.opentelemetry.io/otel v1.24.0
go.opentelemetry.io/otel/metric v1.24.0
go.opentelemetry.io/otel/trace v1.24.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tonkeeper/scam_backoffice_rules v0.0.0-20240822052421-6e4f645f0bc7 h1:VqaRW2kQejlVbDSELpux57NSrdFzOBNvyEb3kaDWnsY=
github.com/tonkeeper/scam_backoffice_rules v0.0.0-20240822052421-6e4f645f0bc7/go.mod h1:m8OU6RRwyWQxvEgSDNnXuGPEbKxtneeJ6nIxsEMAvBU=
github.com/tonkeeper/tongo v1.9.3 h1:VNIZIuPeMw0+KZPvP57+EbgRwGZocN2v5CulRxba20A=
github.com/tonkeeper/tongo v1.9.3/go.mod h1:MjgIgAytFarjCoVjMLjYEtpZNN1f2G/pnZhKjr28cWs=
github.com/tonkeeper/tongo v1.9.4 h1:F1rCcFAp4NQ+Hx/1+0F6lztKx1INYxEqVKp1/5Ds7hc=
github.com/tonkeeper/tongo v1.9.4/go.mod h1:MjgIgAytFarjCoVjMLjYEtpZNN1f2G/pnZhKjr28cWs=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
Expand Down
3 changes: 3 additions & 0 deletions pkg/api/jetton_converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ func jettonMetadata(account ton.AccountID, meta NormalizedMetadata) oas.JettonMe
if meta.Image != "" {
metadata.Image.SetTo(meta.Image)
}
if meta.CustomPayloadApiUri != "" {
metadata.CustomPayloadAPIURI.SetTo(meta.CustomPayloadApiUri)
}
return metadata
}

Expand Down
34 changes: 18 additions & 16 deletions pkg/api/normalized_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ const UnknownJettonName = "UKWN"
// 2. a jetton description taken from the community git https://github.com/tonkeeper/ton-assets.
// It additionally rewrites some fields if necessary.
type NormalizedMetadata struct {
Name string
Description string
Image string
Symbol string
Decimals int
Verification core.TrustType
Social []string
Websites []string
Name string
Description string
Image string
Symbol string
Decimals int
Verification core.TrustType
Social []string
Websites []string
CustomPayloadApiUri string
}

func NormalizeMetadata(meta tep64.Metadata, info *addressbook.KnownJetton, trust core.TrustType) NormalizedMetadata {
Expand Down Expand Up @@ -60,14 +61,15 @@ func NormalizeMetadata(meta tep64.Metadata, info *addressbook.KnownJetton, trust
image = imgGenerator.DefaultGenerator.GenerateImageUrl(image, 200, 200)

return NormalizedMetadata{
Name: name,
Description: description,
Image: image,
Symbol: symbol,
Decimals: convertJettonDecimals(meta.Decimals),
Verification: trust,
Social: social,
Websites: websites,
Name: name,
Description: description,
Image: image,
Symbol: symbol,
Decimals: convertJettonDecimals(meta.Decimals),
Verification: trust,
Social: social,
Websites: websites,
CustomPayloadApiUri: meta.CustomPayloadAPIURL,
}
}

Expand Down
19 changes: 18 additions & 1 deletion pkg/oas/oas_json_gen.go

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

29 changes: 20 additions & 9 deletions pkg/oas/oas_schemas_gen.go

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

2 changes: 2 additions & 0 deletions pkg/rates/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const defaultDecimals = 9
// verifiedJettons map of jettons that skip the holder count check
var verifiedJettons = map[ton.AccountID]struct{}{
ton.MustParseAccountID("EQDptzse--Atn4hDt2dGl3TxAN0Ak6taYXEiNKOg7EAibChH"): {},
ton.MustParseAccountID("EQBeaBmWEkb4-DMBrCHD9ixqz15X79umAHjpQb6fHD1rn5gD"): {},
ton.MustParseAccountID("EQA6_hsN-J3MmLaoJPMUN-g2iN4fG7SHsTQDlpuJ7yJkCgyC"): {},
}

// Asset represents an asset used in jetton price calculations within pools
Expand Down

0 comments on commit cace9c2

Please sign in to comment.