Skip to content

Commit

Permalink
extra currency preview
Browse files Browse the repository at this point in the history
  • Loading branch information
akos-tk committed Dec 13, 2024
1 parent a6d76b1 commit 57c9fe2
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 126 deletions.
23 changes: 9 additions & 14 deletions api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3135,6 +3135,11 @@
"example": 5,
"type": "integer"
},
"id": {
"example": 239,
"format": "int32",
"type": "integer"
},
"image": {
"example": "https://cache.tonapi.io/images/extra.jpg",
"type": "string"
Expand All @@ -3145,6 +3150,7 @@
}
},
"required": [
"id",
"symbol",
"decimals",
"image"
Expand Down Expand Up @@ -3274,24 +3280,13 @@
"type": "string",
"x-js-format": "bigint"
},
"decimals": {
"example": 5,
"type": "integer"
},
"id": {
"example": 239,
"format": "int32",
"type": "integer"
},
"name": {
"example": "FMS",
"type": "string"
"preview": {
"$ref": "#/components/schemas/EcPreview"
}
},
"required": [
"id",
"amount",
"decimals"
"preview"
],
"type": "object"
},
Expand Down
20 changes: 8 additions & 12 deletions api/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5880,10 +5880,15 @@ components:
EcPreview:
type: object
required:
- id
- symbol
- decimals
- image
properties:
id:
type: integer
example: 239
format: int32
symbol:
type: string
example: FMS
Expand Down Expand Up @@ -7475,24 +7480,15 @@ components:
ExtraCurrency:
type: object
required:
- id
- amount
- decimals
- preview
properties:
id:
type: integer
example: 239
format: int32
amount:
type: string
x-js-format: bigint
example: "1000000000"
name:
type: string
example: FMS
decimals:
type: integer
example: 5
preview:
$ref: '#/components/schemas/EcPreview'

responses:
Error:
Expand Down
13 changes: 7 additions & 6 deletions pkg/api/account_converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ func convertExtraCurrencies(extraBalances core.ExtraCurrencies) []oas.ExtraCurre
amount := big.Int(v)
meta := references.GetExtraCurrencyMeta(k)
cur := oas.ExtraCurrency{
ID: k,
Amount: amount.String(),
Decimals: meta.Decimals,
}
if meta.Name != "" {
cur.Name.SetTo(meta.Name)
Amount: amount.String(),
Preview: oas.EcPreview{
ID: k,
Symbol: meta.Symbol,
Decimals: meta.Decimals,
Image: meta.Image,
},
}
res = append(res, cur)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/event_converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ func (h *Handler) convertActionExtraCurrencyTransfer(t *bath.ExtraCurrencyTransf
Sender: convertAccountAddress(t.Sender, h.addressBook),
EncryptedComment: convertEncryptedComment(t.EncryptedComment),
Currency: oas.EcPreview{
ID: t.CurrencyID,
Symbol: meta.Symbol,
Decimals: meta.Decimals,
Image: meta.Image,
Expand All @@ -172,7 +173,7 @@ func (h *Handler) convertActionExtraCurrencyTransfer(t *bath.ExtraCurrencyTransf
Name: "Extra Currency Transfer",
Description: "", // TODO: add description
Accounts: distinctAccounts(viewer, h.addressBook, &t.Sender, &t.Recipient),
Value: oas.NewOptString(fmt.Sprintf("%v %v", value.String(), meta.Name)),
Value: oas.NewOptString(fmt.Sprintf("%v %v", value.String(), meta.Symbol)),
}
return action, simplePreview
}
Expand Down
91 changes: 36 additions & 55 deletions pkg/oas/oas_json_gen.go

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

49 changes: 19 additions & 30 deletions pkg/oas/oas_schemas_gen.go

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

Loading

0 comments on commit 57c9fe2

Please sign in to comment.