Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions client/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
const (
ActiveEventVersion int = 0
UnbondingEventVersion int = 0
WithdrawEventVersion int = 0
WithdrawEventVersion int = 1
ExpiredEventVersion int = 0
StatsEventVersion int = 1
BtcInfoEventVersion int = 0
Expand Down Expand Up @@ -132,9 +132,12 @@ func NewUnbondingStakingEvent(
}

type WithdrawStakingEvent struct {
SchemaVersion int `json:"schema_version"`
EventType EventType `json:"event_type"` // always 3. WithdrawStakingEventType
StakingTxHashHex string `json:"staking_tx_hash_hex"`
SchemaVersion int `json:"schema_version"`
EventType EventType `json:"event_type"` // always 3. WithdrawStakingEventType
StakingTxHashHex string `json:"staking_tx_hash_hex"`
WithdrawTxHashHex string `json:"withdraw_tx_hash_hex"`
WithdrawTxBtcHeight uint64 `json:"withdraw_tx_btc_height"`
WithdrawTxHex string `json:"withdraw_tx_hex"`
}

func (e WithdrawStakingEvent) GetEventType() EventType {
Expand All @@ -145,11 +148,19 @@ func (e WithdrawStakingEvent) GetStakingTxHashHex() string {
return e.StakingTxHashHex
}

func NewWithdrawStakingEvent(stakingTxHashHex string) WithdrawStakingEvent {
func NewWithdrawStakingEvent(
stakingTxHashHex string,
withdrawTxHashHex string,
withdrawTxBtcHeight uint64,
withdrawTxHex string,
) WithdrawStakingEvent {
return WithdrawStakingEvent{
SchemaVersion: WithdrawEventVersion,
EventType: WithdrawStakingEventType,
StakingTxHashHex: stakingTxHashHex,
SchemaVersion: WithdrawEventVersion,
EventType: WithdrawStakingEventType,
StakingTxHashHex: stakingTxHashHex,
WithdrawTxHashHex: withdrawTxHashHex,
WithdrawTxBtcHeight: withdrawTxBtcHeight,
WithdrawTxHex: withdrawTxHex,
}
}

Expand Down
5 changes: 4 additions & 1 deletion tests/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ func TestWithdrawEvent(t *testing.T) {
err := json.Unmarshal([]byte(receivedEv.Body), &withdrawEv)
require.NoError(t, err)
require.Equal(t, ev, &withdrawEv)
require.Equal(t, 0, withdrawEv.SchemaVersion)
require.Equal(t, 1, withdrawEv.SchemaVersion)
require.NotZero(t, withdrawEv.WithdrawTxBtcHeight)
require.NotEmpty(t, withdrawEv.WithdrawTxHashHex)
require.NotEmpty(t, withdrawEv.WithdrawTxHex)
}
}

Expand Down
5 changes: 4 additions & 1 deletion tests/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ func buildNWithdrawEvents(numOfEvent int) []*client.WithdrawStakingEvent {
var withdrawEvents []*client.WithdrawStakingEvent
for i := 0; i < numOfEvent; i++ {
withdrawEv := client.NewWithdrawStakingEvent(
"0x1234567890abcdef" + fmt.Sprint(i),
"0x1234567890abcdef"+fmt.Sprint(i),
"0xabcdef1234567890"+fmt.Sprint(i),
100+uint64(i),
"0xghijkl1234567890"+fmt.Sprint(i),
)
withdrawEvents = append(withdrawEvents, &withdrawEv)
}
Expand Down