Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra currency value #569

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading