Skip to content

Commit 3783958

Browse files
RPC: endpoints
1 parent 4364e92 commit 3783958

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

node/node.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,26 @@ func (rpc *NodeRPC) HeadMetadata() (head HeadMetadata, err error) {
9090
err = rpc.get("chains/main/blocks/head/metadata", &head)
9191
return
9292
}
93+
94+
// ActiveDelegatesWithRolls -
95+
func (rpc *NodeRPC) ActiveDelegatesWithRolls() (delegates []string, err error) {
96+
err = rpc.get("chains/main/blocks/head/context/raw/json/active_delegates_with_rolls", &delegates)
97+
return
98+
}
99+
100+
// Delegates -
101+
func (rpc *NodeRPC) Delegates(active *bool) (delegates []string, err error) {
102+
uri := "chains/main/blocks/head/context/delegates"
103+
if active != nil {
104+
uri = fmt.Sprintf("%s?active=%t", uri, *active)
105+
}
106+
err = rpc.get(uri, &delegates)
107+
return
108+
}
109+
110+
// StakingBalance -
111+
func (rpc *NodeRPC) StakingBalance(address string) (balance string, err error) {
112+
uri := fmt.Sprintf("/chains/main/blocks/head/context/delegates/%s/staking_balance", address)
113+
err = rpc.get(uri, &balance)
114+
return
115+
}

0 commit comments

Comments
 (0)