Skip to content

Commit

Permalink
Merge pull request #582 from tonkeeper/extra_currency
Browse files Browse the repository at this point in the history
create a mock extra currency methods
  • Loading branch information
mr-tron authored Jan 20, 2025
2 parents bd01a83 + 3b256f3 commit a977834
Show file tree
Hide file tree
Showing 10 changed files with 1,517 additions and 232 deletions.
141 changes: 141 additions & 0 deletions api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,17 @@
"type": "string"
}
},
"ecIDParameter": {
"description": "extra currency id",
"in": "path",
"name": "id",
"required": true,
"schema": {
"example": 239,
"format": "int32",
"type": "integer"
}
},
"eventIDParameter": {
"description": "event ID or transaction hash in hex (without 0x) or base64url format",
"in": "path",
Expand Down Expand Up @@ -3265,6 +3276,20 @@
],
"type": "object"
},
"ExtraCurrencies": {
"properties": {
"extra_currencies": {
"items": {
"$ref": "#/components/schemas/EcPreview"
},
"type": "array"
}
},
"required": [
"extra_currencies"
],
"type": "object"
},
"ExtraCurrency": {
"properties": {
"amount": {
Expand Down Expand Up @@ -6749,6 +6774,86 @@
]
}
},
"/v2/accounts/{account_id}/extra-currency/{id}/history": {
"get": {
"description": "Get the transfer history of extra currencies for an account.",
"operationId": "getAccountExtraCurrencyHistoryByID",
"parameters": [
{
"$ref": "#/components/parameters/accountIDParameter"
},
{
"$ref": "#/components/parameters/ecIDParameter"
},
{
"$ref": "#/components/parameters/i18n"
},
{
"description": "omit this parameter to get last events",
"in": "query",
"name": "before_lt",
"required": false,
"schema": {
"example": 25758317000002,
"format": "int64",
"type": "integer",
"x-js-format": "bigint"
}
},
{
"in": "query",
"name": "limit",
"required": true,
"schema": {
"example": 100,
"maximum": 1000,
"minimum": 1,
"type": "integer"
}
},
{
"in": "query",
"name": "start_date",
"required": false,
"schema": {
"example": 1668436763,
"format": "int64",
"maximum": 2114380800,
"type": "integer"
}
},
{
"in": "query",
"name": "end_date",
"required": false,
"schema": {
"example": 1668436763,
"format": "int64",
"maximum": 2114380800,
"type": "integer"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AccountEvents"
}
}
},
"description": "account extra currency history"
},
"default": {
"$ref": "#/components/responses/Error"
}
},
"tags": [
"Accounts"
]
}
},
"/v2/accounts/{account_id}/jettons": {
"get": {
"description": "Get all Jettons balances by owner address",
Expand Down Expand Up @@ -8440,6 +8545,35 @@
]
}
},
"/v2/extra-currency/{id}": {
"get": {
"description": "Get extra currency info by id",
"operationId": "getExtraCurrencyInfo",
"parameters": [
{
"$ref": "#/components/parameters/ecIDParameter"
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/EcPreview"
}
}
},
"description": "extra currency info"
},
"default": {
"$ref": "#/components/responses/Error"
}
},
"tags": [
"ExtraCurrency"
]
}
},
"/v2/gasless/config": {
"get": {
"description": "Returns configuration of gasless transfers",
Expand Down Expand Up @@ -10883,6 +11017,13 @@
"url": "https://docs.tonconsole.com/tonapi/rest-api/utilities"
},
"name": "Utilities"
},
{
"externalDocs": {
"description": "Additional documentation",
"url": "https://docs.tonconsole.com/tonapi/rest-api/extra-currency"
},
"name": "ExtraCurrency"
}
]
}
93 changes: 93 additions & 0 deletions api/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ tags:
externalDocs:
description: Additional documentation
url: https://docs.tonconsole.com/tonapi/rest-api/utilities
- name: ExtraCurrency
externalDocs:
description: Additional documentation
url: https://docs.tonconsole.com/tonapi/rest-api/extra-currency

paths:
/v2/openapi.json:
Expand Down Expand Up @@ -1101,6 +1105,59 @@ paths:
example: 1000000000
'default':
$ref: '#/components/responses/Error'

/v2/accounts/{account_id}/extra-currency/{id}/history:
get:
description: Get the transfer history of extra currencies for an account.
operationId: getAccountExtraCurrencyHistoryByID
tags:
- Accounts
parameters:
- $ref: '#/components/parameters/accountIDParameter'
- $ref: '#/components/parameters/ecIDParameter'
- $ref: '#/components/parameters/i18n'
- name: before_lt
in: query
description: "omit this parameter to get last events"
required: false
schema:
type: integer
format: int64
example: 25758317000002
x-js-format: bigint
- name: limit
in: query
required: true
schema:
type: integer
example: 100
maximum: 1000
minimum: 1
- name: start_date
in: query
required: false
schema:
type: integer
format: int64
maximum: 2114380800
example: 1668436763
- name: end_date
in: query
required: false
schema:
type: integer
format: int64
maximum: 2114380800
example: 1668436763
responses:
'200':
description: account extra currency history
content:
application/json:
schema:
$ref: '#/components/schemas/AccountEvents'
'default':
$ref: '#/components/responses/Error'

/v2/dns/{domain_name}:
get:
Expand Down Expand Up @@ -1667,6 +1724,24 @@ paths:
$ref: '#/components/schemas/Event'
'default':
$ref: '#/components/responses/Error'

/v2/extra-currency/{id}:
get:
description: Get extra currency info by id
operationId: getExtraCurrencyInfo
tags:
- ExtraCurrency
parameters:
- $ref: '#/components/parameters/ecIDParameter'
responses:
'200':
description: extra currency info
content:
application/json:
schema:
$ref: '#/components/schemas/EcPreview'
'default':
$ref: '#/components/responses/Error'

/v2/staking/nominator/{account_id}/pools:
get:
Expand Down Expand Up @@ -2955,6 +3030,15 @@ components:
schema:
type: string
example: 97264395BD65A255A429B11326C84128B7D70FFED7949ABAE3036D506BA38621
ecIDParameter:
in: path
name: id
required: true
description: "extra currency id"
schema:
type: integer
example: 239
format: int32
publicKeyParameter:
in: path
name: public_key
Expand Down Expand Up @@ -5887,6 +5971,15 @@ components:
$ref: '#/components/schemas/EncryptedComment'
refund:
$ref: '#/components/schemas/Refund'
ExtraCurrencies:
type: object
required:
- extra_currencies
properties:
extra_currencies:
type: array
items:
$ref: '#/components/schemas/EcPreview'
EcPreview:
type: object
required:
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/account_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,3 +604,7 @@ func (h *Handler) AddressParse(ctx context.Context, params oas.AddressParseParam
}
return &res, nil //todo: add testnet_only
}

func (h *Handler) GetAccountExtraCurrencyHistoryByID(ctx context.Context, params oas.GetAccountExtraCurrencyHistoryByIDParams) (*oas.AccountEvents, error) {
return &oas.AccountEvents{}, nil
}
11 changes: 11 additions & 0 deletions pkg/api/extra_currency_handlers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package api

import (
"context"

"github.com/tonkeeper/opentonapi/pkg/oas"
)

func (h *Handler) GetExtraCurrencyInfo(ctx context.Context, params oas.GetExtraCurrencyInfoParams) (*oas.EcPreview, error) {
return &oas.EcPreview{}, nil
}
Loading

0 comments on commit a977834

Please sign in to comment.