Skip to content

Commit

Permalink
Add DelegationBakerRemoved tx result event
Browse files Browse the repository at this point in the history
Also remove delegatorId from AbstractDelegatorResult.
  • Loading branch information
Radiokot committed Aug 30, 2024
1 parent 1cbff49 commit 981e44f
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- Added `availableBalance` to `AccountInfo`
- Made optional the following `BakerPoolStatus` fields:
`bakerEquityCapital`, `delegatedCapital`, `delegatedCapitalCap`, `poolInfo`
- Added `BakerDelegationRemoved` transaction result event
- Added `BakerDelegationRemoved` and `DelegationBakerRemoved` transaction result events

## 7.2.0
- Added `MessageSigningDigest` class to generate digests for message signing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package com.concordium.sdk.responses;

import com.concordium.grpc.v2.DelegatorId;
import com.concordium.sdk.types.UInt16;
import com.concordium.sdk.types.UInt64;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.val;

import java.nio.ByteBuffer;

/**
* Account index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public static DelegatorConfigured from(AccountTransactionEffects.DelegationConfi
case DELEGATION_REMOVED:
builder.event(DelegationRemoved.from(delegationEvent.getDelegationRemoved(), sender));
break;
case BAKER_REMOVED:
builder.event(DelegationBakerRemoved.from(delegationEvent.getBakerRemoved(), sender));
case EVENT_NOT_SET:
throw new IllegalArgumentException("Delegation event type not set");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@
@SuperBuilder
@EqualsAndHashCode
public abstract class AbstractDelegatorResult implements TransactionResultEvent {
private final AccountIndex delegatorId;
private final AccountAddress delegatorAddress;

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
@EqualsAndHashCode(callSuper = true)
public class DelegationAdded extends AbstractDelegatorResult {

private final AccountIndex delegatorId;

public static DelegationAdded from(DelegatorId delegationAdded, AccountAddress sender) {
return DelegationAdded
.builder()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.concordium.sdk.responses.transactionstatus;

import com.concordium.grpc.v2.DelegationEvent;
import com.concordium.sdk.types.AccountAddress;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;

@Getter
@ToString
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
public class DelegationBakerRemoved extends AbstractDelegatorResult {

private final long bakerId;

public static DelegationBakerRemoved from(DelegationEvent.BakerRemoved delegationBakerRemoved, AccountAddress sender) {
return DelegationBakerRemoved
.builder()
.bakerId(delegationBakerRemoved.getBakerId().getValue())
.delegatorAddress(sender)
.build();
}

@Override
public TransactionResultEventType getType() {
return TransactionResultEventType.DELEGATION_BAKER_REMOVED;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
@EqualsAndHashCode(callSuper = true)
public class DelegationRemoved extends AbstractDelegatorResult {

private final AccountIndex delegatorId;

public static DelegationRemoved from(DelegatorId delegationRemoved, AccountAddress sender) {
return DelegationRemoved
.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
@EqualsAndHashCode(callSuper = true)
public class DelegationSetDelegationTarget extends AbstractDelegatorResult {

private final AccountIndex delegatorId;
/**
* The target to delegate to.
*/
Expand All @@ -35,4 +36,4 @@ public static DelegationSetDelegationTarget from(DelegationEvent.DelegationSetDe
public TransactionResultEventType getType() {
return TransactionResultEventType.DELEGATION_SET_DELEGATION_TARGET;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@EqualsAndHashCode(callSuper = true)
public class DelegationSetRestakeEarnings extends AbstractDelegatorResult {


private final AccountIndex delegatorId;
/**
* Whether earnings should be automatically restaked or not.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
public class DelegationStakeDecreased extends AbstractDelegatorResult {

private final AccountIndex delegatorId;
private final CCDAmount newStake;

public static DelegationStakeDecreased from(DelegationEvent.DelegationStakeDecreased delegationStakeDecreased, AccountAddress sender) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
import lombok.experimental.SuperBuilder;

/**
* The delegator increased its stake.
* The delegator increased their stake.
*/
@Getter
@ToString
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
public class DelegationStakeIncreased extends AbstractDelegatorResult {

private final AccountIndex delegatorId;
/**
* The new stake
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public enum TransactionResultEventType {
DELEGATION_ADDED,
@JsonProperty("DelegationRemoved")
DELEGATION_REMOVED,
@JsonProperty("DelegationBakerRemoved")
DELEGATION_BAKER_REMOVED,
@JsonProperty("Upgraded")
UPGRADED,
@JsonProperty("BakerStakeUpdated")
Expand Down

0 comments on commit 981e44f

Please sign in to comment.