Skip to content
Snippets Groups Projects
Commit 736231e7 authored by Michal Zander's avatar Michal Zander
Browse files

OpenAPI rewrite

parent 538e26be
No related branches found
No related tags found
1 merge request!298Unify API returns to sql composite types
Pipeline #119360 passed
......@@ -20,16 +20,16 @@ RETURN (
),
populate_record AS MATERIALIZED
(
SELECT 0 as proxy, 1 as proxy_level
SELECT '0' as proxy, 1 as proxy_level
UNION ALL
SELECT 0 as proxy, 2 as proxy_level
SELECT '0' as proxy, 2 as proxy_level
UNION ALL
SELECT 0 as proxy, 3 as proxy_level
SELECT '0' as proxy, 3 as proxy_level
UNION ALL
SELECT 0 as proxy, 4 as proxy_level
SELECT '0' as proxy, 4 as proxy_level
)
SELECT
array_agg(coalesce(s.proxy::TEXT,"0") ORDER BY pr.proxy_level)
array_agg(coalesce(s.proxy::TEXT,pr.proxy) ORDER BY pr.proxy_level)
FROM populate_record pr
LEFT JOIN proxy_levels s ON s.proxy_level = pr.proxy_level
);
......@@ -47,11 +47,11 @@ $$
BEGIN
RETURN (
COUNT(*)::INT,
json_agg(cwvv.vote)
array_agg(cwvv.vote)
)::hafbe_backend.account_votes
FROM hafbe_views.current_witness_votes_view cwvv
WHERE cwvv.account = _account;
END
$$;
RESET ROLE;
\ No newline at end of file
RESET ROLE;
......@@ -4,7 +4,7 @@ CREATE OR REPLACE FUNCTION hafbe_backend.get_account_authority(
_account_id INT,
_key_kind hafd.key_type -- noqa: LT01, CP05
)
RETURNS hafbe_backend.account_authority -- noqa: LT01, CP05
RETURNS hafbe_types.authority_type -- noqa: LT01, CP05
LANGUAGE 'plpgsql'
STABLE
SET JIT = OFF
......@@ -13,7 +13,7 @@ SET from_collapse_limit = 16
AS
$$
DECLARE
_result hafbe_backend.account_authority;
_result hafbe_types.authority_type;
BEGIN
RETURN (
WITH get_key_auth AS
......
......@@ -61,10 +61,10 @@ SET ROLE hafbe_owner;
"delegated_vesting_shares": "0",
"received_vesting_shares": "0",
"proxied_vsf_votes": [
4983403929606734,
0,
0,
0
"4983403929606734",
"0",
"0",
"0"
],
"withdrawn": "804048182205290",
"vesting_withdraw_rate": "80404818220529",
......@@ -177,7 +177,7 @@ BEGIN
--hidden, shouldn't be shown on account page
COALESCE(_result_count, 0)::INT,
EXISTS (SELECT NULL FROM hafbe_app.current_witnesses WHERE witness_id = _account_id)
)::hafbe_types.account;
)::hafbe_types.account
FROM
btracker_endpoints.get_account_balances("account-name") _result_balance,
reptracker_endpoints.get_account_reputation("account-name") _result_reputation,
......
......@@ -84,7 +84,7 @@ SET from_collapse_limit = 16
AS
$$
DECLARE
_account_id INT := hafbe_backend.get_account_id("account-name")
_account_id INT := hafbe_backend.get_account_id("account-name");
BEGIN
-- 2s because this endpoint result is live account parameters and balances
PERFORM set_config('response.headers', '[{"Cache-Control": "public, max-age=2"}]', true);
......
......@@ -361,8 +361,10 @@ declare
"description": "VESTS received from another user, account''s power is increased by received VESTS"
},
"proxied_vsf_votes": {
"type": "string",
"x-sql-datatype": "JSON",
"type": "array",
"items": {
"type": "string"
},
"description": "recursive proxy of VESTS "
},
"withdrawn": {
......@@ -386,8 +388,10 @@ declare
"description": "blocked VESTS by a withdrawal"
},
"witness_votes": {
"type": "string",
"x-sql-datatype": "JSON",
"type": "array",
"items": {
"type": "string"
},
"description": "the roster of witnesses voted by the account"
},
"witnesses_voted_for": {
......@@ -404,22 +408,39 @@ declare
}
}
},
"hafbe_types.authority_type": {
"type": "object",
"properties": {
"key_auths": {
"type": "array",
"items": {
"type": "string"
}
},
"account_auths": {
"type": "array",
"items": {
"type": "string"
}
},
"weight_threshold": {
"type": "integer"
}
}
},
"hafbe_types.account_authority": {
"type": "object",
"properties": {
"owner": {
"type": "string",
"x-sql-datatype": "JSON",
"$ref": "#/components/schemas/hafbe_types.authority_type",
"description": "the most powerful key because it can change any key of an account, including the owner key. Ideally it is meant to be stored offline, and only used to recover a compromised account"
},
"active": {
"type": "string",
"x-sql-datatype": "JSON",
"$ref": "#/components/schemas/hafbe_types.authority_type",
"description": "key meant for more sensitive tasks such as transferring funds, power up/down transactions, converting Hive Dollars, voting for witnesses, updating profile details and avatar, and placing a market order"
},
"posting": {
"type": "string",
"x-sql-datatype": "JSON",
"$ref": "#/components/schemas/hafbe_types.authority_type",
"description": "key allows accounts to post, comment, edit, vote, reblog and follow or mute other accounts"
},
"memo": {
......@@ -1066,10 +1087,10 @@ declare
"delegated_vesting_shares": "0",
"received_vesting_shares": "0",
"proxied_vsf_votes": [
4983403929606734,
0,
0,
0
"4983403929606734",
"0",
"0",
"0"
],
"withdrawn": "804048182205290",
"vesting_withdraw_rate": "80404818220529",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment