Skip to content

Commit

Permalink
CIP-129 schema + account_info endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Scitz0 committed Aug 25, 2024
1 parent cce4421 commit c03785e
Show file tree
Hide file tree
Showing 10 changed files with 225 additions and 193 deletions.
2 changes: 1 addition & 1 deletion files/grest/rpc/account/account_info.sql
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ BEGIN
LEFT JOIN (
SELECT
dv.addr_id,
dh.view AS delegated_drep
grest.cip129_hex_to_drep_id(dh.raw, dh.has_script) AS delegated_drep
FROM delegation_vote AS dv
INNER JOIN drep_hash AS dh ON dh.id = dv.drep_hash_id
WHERE dv.addr_id = ANY(sa_id_list)
Expand Down
29 changes: 28 additions & 1 deletion files/grest/rpc/account/account_info_cached.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ RETURNS TABLE (
stake_address varchar,
status text,
delegated_pool varchar,
delegated_drep varchar,
total_balance text,
utxo text,
rewards text,
withdrawals text,
rewards_available text,
deposit text,
reserves text,
treasury text
)
Expand Down Expand Up @@ -38,6 +40,7 @@ BEGIN
sdc.rewards::text,
sdc.withdrawals::text,
sdc.rewards_available::text,
COALESCE(status_t.deposit,0)::text AS deposit,
COALESCE(reserves_t.reserves, 0)::text AS reserves,
COALESCE(treasury_t.treasury, 0)::text AS treasury
FROM grest.stake_distribution_cache AS sdc
Expand All @@ -55,10 +58,34 @@ BEGIN
WHERE stake_deregistration.addr_id = stake_registration.addr_id
AND stake_deregistration.tx_id > stake_registration.tx_id
)
) AS registered
) AS registered,
(
SELECT sr.deposit FROM stake_registration AS sr
WHERE sr.addr_id = sa.id
AND NOT EXISTS (
SELECT TRUE
FROM stake_deregistration AS sd
WHERE
sd.addr_id = sr.addr_id
AND sd.tx_id > sr.tx_id
)
) AS deposit
FROM public.stake_address AS sas
WHERE sas.id = ANY(sa_id_list)
) AS status_t ON sdc.stake_address = status_t.view
LEFT JOIN (
SELECT
dv.addr_id,
grest.cip129_hex_to_drep_id(dh.raw, dh.has_script) AS delegated_drep
FROM delegation_vote AS dv
INNER JOIN drep_hash AS dh ON dh.id = dv.drep_hash_id
WHERE dv.addr_id = ANY(sa_id_list)
AND NOT EXISTS (
SELECT TRUE
FROM delegation_vote AS dv1
WHERE dv1.addr_id = dv.addr_id
AND dv1.id > dv.id)
) AS vote_t ON vote_t.addr_id = status_t.id
LEFT JOIN (
SELECT
r.addr_id,
Expand Down
73 changes: 37 additions & 36 deletions specs/results/koiosapi-guild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,7 @@ paths:
tags:
- Governance
parameters:
- $ref: "#/components/parameters/_committee_hash"
- $ref: "#/components/parameters/_cc_hot_id"
responses:
"200":
description: Success!!
Expand Down Expand Up @@ -1520,7 +1520,7 @@ paths:
tags:
- Governance
parameters:
- $ref: "#/components/parameters/_credential"
- $ref: "#/components/parameters/_voter_id"
responses:
"200":
description: Success!!
Expand All @@ -1543,8 +1543,7 @@ paths:
tags:
- Governance
parameters:
- $ref: "#/components/parameters/_proposal_tx_hash"
- $ref: "#/components/parameters/_proposal_index"
- $ref: "#/components/parameters/_proposal_id"
responses:
"200":
description: Success!!
Expand Down Expand Up @@ -2089,10 +2088,10 @@ components:
in: query
required: false
allowEmptyValue: true
_credential:
_voter_id:
deprecated: false
name: _credential
description: Voter (Drep, SPO, Committee Member) in Hex format
name: _voter_id
description: Voter ID (Drep, SPO, Committee Member) in Bech32 format (CIP-5 | CIP-129)
schema:
type: string
example: "drep1s9qaseg7qyum807fcv0hdky9gv0c89tn98t4urjn5ewz57dml0r"
Expand All @@ -2119,13 +2118,13 @@ components:
in: query
required: false
allowEmptyValue: true
_committee_hash:
_cc_hot_id:
deprecated: false
name: _committee_hash
description: Committee hash in hexadecimal format (hex)
name: _cc_hot_id
description: Committee member hot key ID in Bech32 format (CIP-5 | CIP-129)
schema:
type: string
example: "65d497b875c56ab213586a4006d4f6658970573ea8e2398893857472"
example: "cc_hot1qgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqvcdjk7"
in: query
required: false
allowEmptyValue: true
Expand Down Expand Up @@ -2199,26 +2198,16 @@ components:
in: query
required: true
allowEmptyValue: false
_proposal_tx_hash:
_proposal_id:
deprecated: false
name: _proposal_tx_hash
description: Transaction Hash of government proposal in hexadecimal format (hex)
example: "e61f151fcef9e99dff5c705f8d5de18891f8d1d92d69fef5ff608d2c29a7c133"
name: _proposal_id
description: Government proposal ID in CIP-129 Bech32 format
example: "gov_action1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpzklpgpf"
schema:
type: string
in: query
required: true
allowEmptyValue: false
_proposal_index:
deprecated: false
name: _proposal_index
description: Index of governance proposal in transaction
schema:
type: number
example: 0
in: query
required: true
allowEmptyValue: false
requestBodies:
block_hashes:
content:
Expand Down Expand Up @@ -4171,8 +4160,8 @@ components:
type:
- 'null'
- string
description: Account's current delegation status to DRep ID in Bech32 format
example: drep1gj49xmfcg6ev89ur2yad9c5p7z0pgfxggyakz9pua06vqh5vnp0
description: Account's current delegation status to DRep ID in CIP-129 Bech32 format
example: drep1yfhyq6tztjksqqpd5lglc3zr2tn8vylgjh9xzz7n2p4l4lgk3qam3
delegated_pool:
anyOf:
- type: 'null'
Expand Down Expand Up @@ -5143,12 +5132,12 @@ components:
properties:
drep_id:
type: string
description: DRep ID in bech32 format
example: drep1l9y2naagv0vqvft9szdt5wf94fqnxn5hdsgusdl7rf6vq4djqck
description: DRep ID in CIP-129 bech32 format
example: drep1yfhyq6tztjksqqpd5lglc3zr2tn8vylgjh9xzz7n2p4l4lgk3qam3
hex:
type: string
description: DRep ID in hex format
example: f948a9f7a863d8062565809aba3925aa41334e976c11c837fe1a74c0
example: 6e4069625cad00002da7d1fc444352e67613e895ca610bd3506bfafd
has_script:
type: boolean
description: Flag which shows if this credential is a script hash
Expand Down Expand Up @@ -5243,6 +5232,8 @@ components:
$ref: "#/components/schemas/drep_info/items/properties/drep_id"
hex:
$ref: "#/components/schemas/drep_info/items/properties/hex"
has_script:
$ref: "#/components/schemas/drep_info/items/properties/has_script"
url:
$ref: "#/components/schemas/drep_info/items/properties/url"
hash:
Expand Down Expand Up @@ -5289,6 +5280,8 @@ components:
$ref: "#/components/schemas/drep_info/items/properties/drep_id"
hex:
$ref: "#/components/schemas/drep_info/items/properties/hex"
has_script:
$ref: "#/components/schemas/drep_info/items/properties/has_script"
update_tx_hash:
$ref: "#/components/schemas/utxo_infos/items/properties/tx_hash"
cert_index:
Expand All @@ -5315,6 +5308,8 @@ components:
type: array
items:
properties:
proposal_id:
$ref: "#/components/schemas/proposal_list/items/properties/proposal_id"
proposal_tx_hash:
$ref: "#/components/schemas/utxo_infos/items/properties/tx_hash"
proposal_index:
Expand Down Expand Up @@ -5349,6 +5344,10 @@ components:
properties:
block_time:
$ref: "#/components/schemas/blocks/items/properties/block_time"
proposal_id:
type: string
description: Proposal Action ID in accordance with CIP-129 format
example: 'gov_action17m93skslaxyd45gpr6ernkdzs852h564wsterr8l6lheu7hu7kvsqecyqdh'
proposal_tx_hash:
$ref: "#/components/schemas/utxo_infos/items/properties/tx_hash"
proposal_index:
Expand Down Expand Up @@ -5449,16 +5448,16 @@ components:
description: The role of the voter
enum: ["ConstitutionalCommittee", "DRep", "SPO"]
example: DRep
has_script:
$ref: "#/components/schemas/drep_info/items/properties/has_script"
voter:
voter_id:
type: string
description: Voter's DRep ID (bech32 format), pool ID (bech32 format) or committee hash (hex format)
example: drep1l9y2naagv0vqvft9szdt5wf94fqnxn5hdsgusdl7rf6vq4djqck
description: Voter's DRep ID (CIP-129 bech32 format), pool ID (bech32 format) or committee hot ID (CIP-129 bech32 format)
example: drep1yfhyq6tztjksqqpd5lglc3zr2tn8vylgjh9xzz7n2p4l4lgk3qam3
voter_hex:
type: string
description: Voter's DRep ID , pool ID or committee hash in hex format
example: drep1l9y2naagv0vqvft9szdt5wf94fqnxn5hdsgusdl7rf6vq4djqck
example: 6e4069625cad00002da7d1fc444352e67613e895ca610bd3506bfafd
voter_has_script:
$ref: "#/components/schemas/drep_info/items/properties/has_script"
vote:
$ref: "#/components/schemas/drep_votes/items/properties/vote"
meta_url:
Expand All @@ -5469,6 +5468,8 @@ components:
description: Current governance committee
type: object
properties:
proposal_id:
$ref: "#/components/schemas/proposal_list/items/properties/proposal_id"
proposal_tx_hash:
$ref: "#/components/schemas/utxo_infos/items/properties/tx_hash"
proposal_index:
Expand Down
Loading

0 comments on commit c03785e

Please sign in to comment.