From cace9c253b56eebb3f46134badb2d87138f01acd Mon Sep 17 00:00:00 2001 From: Zakhar Petukhov Date: Mon, 9 Sep 2024 16:32:16 +0800 Subject: [PATCH] update the jetton rates map to skip holder count and update meta for mintless jettons --- api/openapi.json | 4 ++++ api/openapi.yml | 13 ++++++++----- go.mod | 2 +- go.sum | 4 ++-- pkg/api/jetton_converters.go | 3 +++ pkg/api/normalized_metadata.go | 34 ++++++++++++++++++---------------- pkg/oas/oas_json_gen.go | 19 ++++++++++++++++++- pkg/oas/oas_schemas_gen.go | 29 ++++++++++++++++++++--------- pkg/rates/market.go | 2 ++ 9 files changed, 76 insertions(+), 34 deletions(-) diff --git a/api/openapi.json b/api/openapi.json index 7bb177d0..4e811c16 100644 --- a/api/openapi.json +++ b/api/openapi.json @@ -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" diff --git a/api/openapi.yml b/api/openapi.yml index 66edcaad..475c956c 100644 --- a/api/openapi.yml +++ b/api/openapi.yml @@ -3092,7 +3092,7 @@ components: type: array items: type: string - example: ["custom_payload"] + example: [ "custom_payload" ] currencyQuery: in: query name: currency @@ -3667,9 +3667,9 @@ components: format: cell example: b5ee9c72010106010044000114ff00f4a413f4bcf2c80b01020120020302014804050004f2300038d06c21d31f30ed44d0d33f3001c00197a4c8cb3fc9ed549330f206e20011a13431da89a1a67e61 interfaces: - type: array - items: - type: string + type: array + items: + type: string Message: type: object required: @@ -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: @@ -6886,7 +6889,7 @@ components: JettonTransferPayload: type: object required: - - payload + - payload properties: custom_payload: type: string diff --git a/go.mod b/go.mod index 9c9e33e0..9944bfcc 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index bcc488fd..a039f448 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/pkg/api/jetton_converters.go b/pkg/api/jetton_converters.go index 46228c42..81963f46 100644 --- a/pkg/api/jetton_converters.go +++ b/pkg/api/jetton_converters.go @@ -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 } diff --git a/pkg/api/normalized_metadata.go b/pkg/api/normalized_metadata.go index 86a553cb..87368e15 100644 --- a/pkg/api/normalized_metadata.go +++ b/pkg/api/normalized_metadata.go @@ -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 { @@ -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, } } diff --git a/pkg/oas/oas_json_gen.go b/pkg/oas/oas_json_gen.go index 6fdc842d..fb1b3718 100644 --- a/pkg/oas/oas_json_gen.go +++ b/pkg/oas/oas_json_gen.go @@ -23286,9 +23286,15 @@ func (s *JettonMetadata) encodeFields(e *jx.Encoder) { e.ArrEnd() } } + { + if s.CustomPayloadAPIURI.Set { + e.FieldStart("custom_payload_api_uri") + s.CustomPayloadAPIURI.Encode(e) + } + } } -var jsonFieldsNameOfJettonMetadata = [9]string{ +var jsonFieldsNameOfJettonMetadata = [10]string{ 0: "address", 1: "name", 2: "symbol", @@ -23298,6 +23304,7 @@ var jsonFieldsNameOfJettonMetadata = [9]string{ 6: "social", 7: "websites", 8: "catalogs", + 9: "custom_payload_api_uri", } // Decode decodes JettonMetadata from json. @@ -23434,6 +23441,16 @@ func (s *JettonMetadata) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"catalogs\"") } + case "custom_payload_api_uri": + if err := func() error { + s.CustomPayloadAPIURI.Reset() + if err := s.CustomPayloadAPIURI.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"custom_payload_api_uri\"") + } default: return d.Skip() } diff --git a/pkg/oas/oas_schemas_gen.go b/pkg/oas/oas_schemas_gen.go index e68f6905..49141413 100644 --- a/pkg/oas/oas_schemas_gen.go +++ b/pkg/oas/oas_schemas_gen.go @@ -7691,15 +7691,16 @@ func (s *JettonInfo) SetHoldersCount(val int32) { // Ref: #/components/schemas/JettonMetadata type JettonMetadata struct { - Address string `json:"address"` - Name string `json:"name"` - Symbol string `json:"symbol"` - Decimals string `json:"decimals"` - Image OptString `json:"image"` - Description OptString `json:"description"` - Social []string `json:"social"` - Websites []string `json:"websites"` - Catalogs []string `json:"catalogs"` + Address string `json:"address"` + Name string `json:"name"` + Symbol string `json:"symbol"` + Decimals string `json:"decimals"` + Image OptString `json:"image"` + Description OptString `json:"description"` + Social []string `json:"social"` + Websites []string `json:"websites"` + Catalogs []string `json:"catalogs"` + CustomPayloadAPIURI OptString `json:"custom_payload_api_uri"` } // GetAddress returns the value of Address. @@ -7747,6 +7748,11 @@ func (s *JettonMetadata) GetCatalogs() []string { return s.Catalogs } +// GetCustomPayloadAPIURI returns the value of CustomPayloadAPIURI. +func (s *JettonMetadata) GetCustomPayloadAPIURI() OptString { + return s.CustomPayloadAPIURI +} + // SetAddress sets the value of Address. func (s *JettonMetadata) SetAddress(val string) { s.Address = val @@ -7792,6 +7798,11 @@ func (s *JettonMetadata) SetCatalogs(val []string) { s.Catalogs = val } +// SetCustomPayloadAPIURI sets the value of CustomPayloadAPIURI. +func (s *JettonMetadata) SetCustomPayloadAPIURI(val OptString) { + s.CustomPayloadAPIURI = val +} + // Ref: #/components/schemas/JettonMintAction type JettonMintAction struct { Recipient AccountAddress `json:"recipient"` diff --git a/pkg/rates/market.go b/pkg/rates/market.go index ff07c17c..b73714f6 100644 --- a/pkg/rates/market.go +++ b/pkg/rates/market.go @@ -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