diff --git a/backend/account.sql b/backend/account.sql index 90ae72aa7b20bf53a2211eed0bb58a9363200087..ccd9d3a3d074fc636da168ff4a779c366b2c4175 100644 --- a/backend/account.sql +++ b/backend/account.sql @@ -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; diff --git a/backend/authority.sql b/backend/authority.sql index 968902382f0879a586ec1556e72b7cd0342b4f74..9828aae23118925785d3d47d056b73fff8ea1f9d 100644 --- a/backend/authority.sql +++ b/backend/authority.sql @@ -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 diff --git a/endpoints/accounts/get_account.sql b/endpoints/accounts/get_account.sql index 5cd0fe88e3215b3b59b512c75b5ef157176b34fb..548c704648d07c4d217d9c1453ee3d05919fd063 100644 --- a/endpoints/accounts/get_account.sql +++ b/endpoints/accounts/get_account.sql @@ -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, diff --git a/endpoints/accounts/get_account_authority.sql b/endpoints/accounts/get_account_authority.sql index d315bcfb65639ff86bde70053c9f6200f30cdf2b..e8e26127e1198fb92f678ade1672bd2ed6533295 100644 --- a/endpoints/accounts/get_account_authority.sql +++ b/endpoints/accounts/get_account_authority.sql @@ -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); diff --git a/endpoints/endpoint_schema.sql b/endpoints/endpoint_schema.sql index 60c580b9aa53801d50795c7ac2c96097d2605553..baeee7617ed5504d8c907310d393cba4d40482e2 100644 --- a/endpoints/endpoint_schema.sql +++ b/endpoints/endpoint_schema.sql @@ -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",