Skip to content

Commit

Permalink
Merge pull request #569 from tonkeeper/extra-currency-value
Browse files Browse the repository at this point in the history
Extra currency value
  • Loading branch information
mr-tron authored Dec 13, 2024
2 parents 1f9e6c3 + 062850b commit c471dec
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 134 deletions.
23 changes: 9 additions & 14 deletions api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3128,6 +3128,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 @@ -3138,6 +3143,7 @@
}
},
"required": [
"id",
"symbol",
"decimals",
"image"
Expand Down Expand Up @@ -3267,24 +3273,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
36 changes: 16 additions & 20 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 @@ -7469,26 +7474,17 @@ components:
format: int64
example: 1668436763
ExtraCurrency:
type: object
required:
- id
- amount
- decimals
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
type: object
required:
- amount
- preview
properties:
amount:
type: string
x-js-format: bigint
example: "1000000000"
preview:
$ref: '#/components/schemas/EcPreview'
SourceFile:
type: object
required:
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
4 changes: 3 additions & 1 deletion pkg/api/event_converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,18 @@ 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,
},
})
value := ScaleJettons(big.Int(t.Amount), meta.Decimals)
simplePreview := oas.ActionSimplePreview{
Name: "Extra Currency Transfer",
Description: "", // TODO: add description
Accounts: distinctAccounts(viewer, h.addressBook, &t.Sender, &t.Recipient),
// TODO: add value
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.

Loading

0 comments on commit c471dec

Please sign in to comment.