Skip to content

Commit c471dec

Browse files
authored
Merge pull request #569 from tonkeeper/extra-currency-value
Extra currency value
2 parents 1f9e6c3 + 062850b commit c471dec

7 files changed

+109
-134
lines changed

api/openapi.json

+9-14
Original file line numberDiff line numberDiff line change
@@ -3128,6 +3128,11 @@
31283128
"example": 5,
31293129
"type": "integer"
31303130
},
3131+
"id": {
3132+
"example": 239,
3133+
"format": "int32",
3134+
"type": "integer"
3135+
},
31313136
"image": {
31323137
"example": "https://cache.tonapi.io/images/extra.jpg",
31333138
"type": "string"
@@ -3138,6 +3143,7 @@
31383143
}
31393144
},
31403145
"required": [
3146+
"id",
31413147
"symbol",
31423148
"decimals",
31433149
"image"
@@ -3267,24 +3273,13 @@
32673273
"type": "string",
32683274
"x-js-format": "bigint"
32693275
},
3270-
"decimals": {
3271-
"example": 5,
3272-
"type": "integer"
3273-
},
3274-
"id": {
3275-
"example": 239,
3276-
"format": "int32",
3277-
"type": "integer"
3278-
},
3279-
"name": {
3280-
"example": "FMS",
3281-
"type": "string"
3276+
"preview": {
3277+
"$ref": "#/components/schemas/EcPreview"
32823278
}
32833279
},
32843280
"required": [
3285-
"id",
32863281
"amount",
3287-
"decimals"
3282+
"preview"
32883283
],
32893284
"type": "object"
32903285
},

api/openapi.yml

+16-20
Original file line numberDiff line numberDiff line change
@@ -5880,10 +5880,15 @@ components:
58805880
EcPreview:
58815881
type: object
58825882
required:
5883+
- id
58835884
- symbol
58845885
- decimals
58855886
- image
58865887
properties:
5888+
id:
5889+
type: integer
5890+
example: 239
5891+
format: int32
58875892
symbol:
58885893
type: string
58895894
example: FMS
@@ -7469,26 +7474,17 @@ components:
74697474
format: int64
74707475
example: 1668436763
74717476
ExtraCurrency:
7472-
type: object
7473-
required:
7474-
- id
7475-
- amount
7476-
- decimals
7477-
properties:
7478-
id:
7479-
type: integer
7480-
example: 239
7481-
format: int32
7482-
amount:
7483-
type: string
7484-
x-js-format: bigint
7485-
example: "1000000000"
7486-
name:
7487-
type: string
7488-
example: FMS
7489-
decimals:
7490-
type: integer
7491-
example: 5
7477+
type: object
7478+
required:
7479+
- amount
7480+
- preview
7481+
properties:
7482+
amount:
7483+
type: string
7484+
x-js-format: bigint
7485+
example: "1000000000"
7486+
preview:
7487+
$ref: '#/components/schemas/EcPreview'
74927488
SourceFile:
74937489
type: object
74947490
required:

pkg/api/account_converters.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,13 @@ func convertExtraCurrencies(extraBalances core.ExtraCurrencies) []oas.ExtraCurre
8181
amount := big.Int(v)
8282
meta := references.GetExtraCurrencyMeta(k)
8383
cur := oas.ExtraCurrency{
84-
ID: k,
85-
Amount: amount.String(),
86-
Decimals: meta.Decimals,
87-
}
88-
if meta.Name != "" {
89-
cur.Name.SetTo(meta.Name)
84+
Amount: amount.String(),
85+
Preview: oas.EcPreview{
86+
ID: k,
87+
Symbol: meta.Symbol,
88+
Decimals: meta.Decimals,
89+
Image: meta.Image,
90+
},
9091
}
9192
res = append(res, cur)
9293
}

pkg/api/event_converters.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,18 @@ func (h *Handler) convertActionExtraCurrencyTransfer(t *bath.ExtraCurrencyTransf
162162
Sender: convertAccountAddress(t.Sender, h.addressBook),
163163
EncryptedComment: convertEncryptedComment(t.EncryptedComment),
164164
Currency: oas.EcPreview{
165+
ID: t.CurrencyID,
165166
Symbol: meta.Symbol,
166167
Decimals: meta.Decimals,
167168
Image: meta.Image,
168169
},
169170
})
171+
value := ScaleJettons(big.Int(t.Amount), meta.Decimals)
170172
simplePreview := oas.ActionSimplePreview{
171173
Name: "Extra Currency Transfer",
172174
Description: "", // TODO: add description
173175
Accounts: distinctAccounts(viewer, h.addressBook, &t.Sender, &t.Recipient),
174-
// TODO: add value
176+
Value: oas.NewOptString(fmt.Sprintf("%v %v", value.String(), meta.Symbol)),
175177
}
176178
return action, simplePreview
177179
}

pkg/oas/oas_json_gen.go

+36-55
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)