Skip to content

Commit

Permalink
feat-2.0/get_reward_switch_block (#113)
Browse files Browse the repository at this point in the history
Added switch_block_hash to info_get_reward RPC
  • Loading branch information
ZhmakAS committed Aug 22, 2024
1 parent beadfc7 commit 5a338e7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions rpc/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,11 @@ func (b QueryBalanceDetailsResult) GetRawJSON() json.RawMessage {
}

type InfoGetRewardResult struct {
APIVersion string `json:"api_version"`
DelegationRate float32 `json:"delegation_rate"`
EraID uint64 `json:"era_id"`
RewardAmount clvalue.UInt512 `json:"reward_amount"`
APIVersion string `json:"api_version"`
DelegationRate float32 `json:"delegation_rate"`
EraID uint64 `json:"era_id"`
RewardAmount clvalue.UInt512 `json:"reward_amount"`
SwitchBlockHash key.Hash `json:"switch_block_hash"`

rawJSON json.RawMessage
}
Expand Down
3 changes: 2 additions & 1 deletion tests/data/rpc_response/info_get_reward.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"api_version": "2.0.0",
"reward_amount": "62559062048560",
"era_id": 13,
"delegation_rate": 1
"delegation_rate": 1,
"switch_block_hash": "0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"
}
}
1 change: 1 addition & 0 deletions tests/rpc/rpc_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ func Test_DefaultClient_GetReward(t *testing.T) {
assert.NotEmpty(t, result.EraID)
assert.NotEmpty(t, result.RewardAmount)
assert.Equal(t, result.RewardAmount.Value().Int64(), int64(62559062048560))
assert.Equal(t, result.SwitchBlockHash.ToHex(), "0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f")
assert.NotEmpty(t, result.GetRawJSON())
})
}
Expand Down

0 comments on commit 5a338e7

Please sign in to comment.