Skip to content

Commit

Permalink
storage/nodeapi/cobalt: Support mid-Cobalt chang in escrow events
Browse files Browse the repository at this point in the history
  • Loading branch information
mitjat committed Apr 3, 2023
1 parent 9ad3a4c commit fdba816
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
8 changes: 5 additions & 3 deletions coreapi/v21.1.1/staking/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ type Event struct {
// AddEscrowEvent is the event emitted when stake is transferred into an escrow
// account.
type AddEscrowEvent struct {
Owner Address `json:"owner"`
Escrow Address `json:"escrow"`
Amount quantity.Quantity `json:"amount"`
Owner Address `json:"owner"`
Escrow Address `json:"escrow"`
Amount quantity.Quantity `json:"amount"`
NewShares quantity.Quantity `json:"new_shares"` // Only emitted at _some_ heights; introduced in oasis-core v21.2.0 mid-Cobalt.
}

// TakeEscrowEvent is the event emitted when stake is taken from an escrow
Expand All @@ -96,6 +97,7 @@ type ReclaimEscrowEvent struct {
Owner Address `json:"owner"`
Escrow Address `json:"escrow"`
Amount quantity.Quantity `json:"amount"`
Shares quantity.Quantity `json:"shares"` // Only emitted at _some_ heights; introduced in oasis-core v21.2.0 mid-Cobalt.
}

// AllowanceChangeEvent is the event emitted when allowance is changed for a beneficiary.
Expand Down
22 changes: 6 additions & 16 deletions storage/oasis/nodeapi/cobalt/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,9 @@ func convertEvent(e txResultsCobalt.Event) nodeapi.Event {
switch {
case e.Staking.Escrow.Add != nil:
ret = nodeapi.Event{
StakingAddEscrow: &nodeapi.AddEscrowEvent{
Owner: e.Staking.Escrow.Add.Owner,
Escrow: e.Staking.Escrow.Add.Escrow,
Amount: e.Staking.Escrow.Add.Amount,
NewShares: quantity.Quantity{}, // NOTE: not available in the Cobalt API
},
Body: e.Staking.Escrow.Add,
Type: apiTypes.ConsensusEventTypeStakingEscrowAdd,
StakingAddEscrow: (*nodeapi.AddEscrowEvent)(e.Staking.Escrow.Add),
Body: e.Staking.Escrow.Add,
Type: apiTypes.ConsensusEventTypeStakingEscrowAdd,
}
case e.Staking.Escrow.Take != nil:
ret = nodeapi.Event{
Expand All @@ -200,14 +195,9 @@ func convertEvent(e txResultsCobalt.Event) nodeapi.Event {
}
case e.Staking.Escrow.Reclaim != nil:
ret = nodeapi.Event{
StakingReclaimEscrow: &nodeapi.ReclaimEscrowEvent{
Owner: e.Staking.Escrow.Reclaim.Owner,
Escrow: e.Staking.Escrow.Reclaim.Escrow,
Amount: e.Staking.Escrow.Reclaim.Amount,
Shares: quantity.Quantity{}, // NOTE: not available in the Cobalt API
},
Body: e.Staking.Escrow.Reclaim,
Type: apiTypes.ConsensusEventTypeStakingEscrowReclaim,
StakingReclaimEscrow: (*nodeapi.ReclaimEscrowEvent)(e.Staking.Escrow.Reclaim),
Body: e.Staking.Escrow.Reclaim,
Type: apiTypes.ConsensusEventTypeStakingEscrowReclaim,
}
// NOTE: There is no Staking.Escrow.DebondingStart event in Cobalt.
}
Expand Down

0 comments on commit fdba816

Please sign in to comment.