Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
kdimentionaltree committed Dec 25, 2024
1 parent 479fb5a commit fc6ab2c
Show file tree
Hide file tree
Showing 9 changed files with 681 additions and 34 deletions.
13 changes: 11 additions & 2 deletions ton-http-api/handler_api_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ core::TonlibWorkerResponse ApiV2Handler::HandleTonlibRequest(const std::string&
}

auto res = tonlib_component_.DoRequest(&core::TonlibWorker::getAddressInformation, address, seqno);
return core::TonlibWorkerResponse::from_tonlib_result(std::move(res));
return tonlib_component_.DoPostprocess(&core::TonlibPostProcessor::process_getAddressInformation, address, std::move(res));
}

if (ton_api_method == "getExtendedAddressInformation") {
Expand All @@ -102,14 +102,23 @@ core::TonlibWorkerResponse ApiV2Handler::HandleTonlibRequest(const std::string&
return core::TonlibWorkerResponse::from_tonlib_result(std::move(res));
}

if (ton_api_method == "getWalletInformation") {
auto address = request.GetArg("address");
auto seqno = stringToInt<ton::BlockSeqno>(request.GetArg("seqno"));
if (address.empty()) {
return core::TonlibWorkerResponse::from_error_string("address is required", 422);
}
auto res = tonlib_component_.DoRequest(&core::TonlibWorker::getExtendedAddressInformation, address, seqno);
return tonlib_component_.DoPostprocess(&core::TonlibPostProcessor::process_getWalletInformation, address, std::move(res));
}

if (ton_api_method == "detectAddress") {
auto address = request.GetArg("address");
if (address.empty()) {
return core::TonlibWorkerResponse::from_error_string("address is required", 422);
}
auto res = tonlib_component_.DoRequest(&core::TonlibWorker::detectAddress, address);
auto res_str = res.move_as_ok().to_json_string();
LOG_WARNING() << res_str;
return core::TonlibWorkerResponse::from_result_string(res_str);
}

Expand Down
280 changes: 279 additions & 1 deletion ton-http-api/openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,185 @@
]
}
},
"/api/v2/detectAddress": {
"/api/v2/getWalletInformation": {
"get": {
"tags": [
"accounts"
],
"summary": "Get Wallet Information",
"description": "Retrieve wallet information. This method parses contract state and currently supports more wallet types than getExtendedAddressInformation: simple wallet, standart wallet, v3 wallet, v4 wallet.",
"operationId": "get_wallet_information_getWalletInformation_get",
"parameters": [
{
"description": "Identifier of target TON account in any form.",
"required": true,
"schema": {
"type": "string",
"title": "Address",
"description": "Identifier of target TON account in any form."
},
"name": "address",
"in": "query"
},
{
"required": false,
"schema": {
"type": "integer",
"title": "Masterchain block seqno"
},
"name": "seqno",
"in": "query"
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TonResponse"
}
}
}
},
"422": {
"description": "Validation Error"
},
"504": {
"description": "Lite Server Timeout"
}
},
"security": [
{
"APIKeyHeader": []
},
{
"APIKeyQuery": []
}
]
}
},
"/api/v2/getAddressBalance": {
"get": {
"tags": [
"accounts"
],
"summary": "Get Address Balance",
"description": "Get balance (in nanotons) of a given address.",
"operationId": "get_address_balance_getAddressBalance_get",
"parameters": [
{
"description": "Identifier of target TON account in any form.",
"required": true,
"schema": {
"type": "string",
"title": "Address",
"description": "Identifier of target TON account in any form."
},
"name": "address",
"in": "query"
},
{
"required": false,
"schema": {
"type": "integer",
"title": "Masterchain block seqno"
},
"name": "seqno",
"in": "query"
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TonResponse"
}
}
}
},
"422": {
"description": "Validation Error"
},
"504": {
"description": "Lite Server Timeout"
}
},
"security": [
{
"APIKeyHeader": []
},
{
"APIKeyQuery": []
}
]
}
},
"/api/v2/getAddressState": {
"get": {
"tags": [
"accounts"
],
"summary": "Get Address",
"description": "Get state of a given address. State can be either *unitialized*, *active* or *frozen*.",
"operationId": "get_address_getAddressState_get",
"parameters": [
{
"description": "Identifier of target TON account in any form.",
"required": true,
"schema": {
"type": "string",
"title": "Address",
"description": "Identifier of target TON account in any form."
},
"name": "address",
"in": "query"
},
{
"required": false,
"schema": {
"type": "integer",
"title": "Masterchain block seqno"
},
"name": "seqno",
"in": "query"
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TonResponse"
}
}
}
},
"422": {
"description": "Validation Error"
},
"504": {
"description": "Lite Server Timeout"
}
},
"security": [
{
"APIKeyHeader": []
},
{
"APIKeyQuery": []
}
]
}
},
"/api/v2/detectAddress": {
"get": {
"tags": [
"utils"
],
"summary": "Detect Address",
"description": "Get all possible address forms.",
"operationId": "detect_address_detectAddress_get",
Expand Down Expand Up @@ -171,6 +345,106 @@
]
}
},
"/api/v2/packAddress": {
"get": {
"tags": [
"utils"
],
"summary": "Pack Address",
"description": "Convert an address from raw to human-readable format.",
"operationId": "pack_address_packAddress_get",
"parameters": [
{
"description": "Identifier of target TON account in raw form.",
"required": true,
"schema": {
"type": "string",
"title": "Address",
"description": "Identifier of target TON account in raw form."
},
"example": "0:83DFD552E63729B472FCBCC8C45EBCC6691702558B68EC7527E1BA403A0F31A8",
"name": "address",
"in": "query"
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TonResponse"
}
}
}
},
"422": {
"description": "Validation Error"
},
"504": {
"description": "Lite Server Timeout"
}
},
"security": [
{
"APIKeyHeader": []
},
{
"APIKeyQuery": []
}
]
}
},
"/api/v2/unpackAddress": {
"get": {
"tags": [
"utils"
],
"summary": "Unpack Address",
"description": "Convert an address from human-readable to raw format.",
"operationId": "unpack_address_unpackAddress_get",
"parameters": [
{
"description": "Identifier of target TON account in user-friendly form",
"required": true,
"schema": {
"type": "string",
"title": "Address",
"description": "Identifier of target TON account in user-friendly form"
},
"example": "EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N",
"name": "address",
"in": "query"
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TonResponse"
}
}
}
},
"422": {
"description": "Validation Error"
},
"504": {
"description": "Lite Server Timeout"
}
},
"security": [
{
"APIKeyHeader": []
},
{
"APIKeyQuery": []
}
]
}
},
"/api/v2/getMasterchainInfo": {
"get": {
"tags": [
Expand Down Expand Up @@ -431,6 +705,10 @@
}
},
"tags": [
{
"name": "utils",
"description": "Some useful methods for conversion"
},
{
"name": "accounts",
"description": "Information about accounts."
Expand Down
Loading

0 comments on commit fc6ab2c

Please sign in to comment.