Skip to content

Commit

Permalink
Merge pull request #402 from Concordium/add-suspended-validation-tx
Browse files Browse the repository at this point in the history
Add suspended field to configure validator transaction
  • Loading branch information
soerenbf authored Jan 15, 2025
2 parents d1b355e + 394ffb5 commit 7ad3203
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Add `PendingValidatorScoreUpdate` to `UpdateInstructionPayload` union type.
- Add `ChainParametersV3` to `ChainParameters` union type.
- Add `isPrimedForSuspension` and `missedRounds` fields to `CurrentPaydayBakerPoolStatus`.
- Add suspended field to the `ConfigureBakerPayload`

## 8.1.1

Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/serializationHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ const configureBakerSerializationSpec: SerializationSpec<ConfigureBakerPayload>
transactionFeeCommission: orUndefined(encodeWord32),
bakingRewardCommission: orUndefined(encodeWord32),
finalizationRewardCommission: orUndefined(encodeWord32),
suspended: orUndefined(encodeBool),
};

const getSerializedConfigureBakerBitmap = (payload: ConfigureBakerPayload): Buffer =>
Expand Down
9 changes: 7 additions & 2 deletions packages/sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1422,16 +1422,21 @@ export type BakerKeysWithProofs = PublicBakerKeys & BakerKeyProofs;
export type GenerateBakerKeysOutput = PublicBakerKeys & PrivateBakerKeys & BakerKeyProofs;

export interface ConfigureBakerPayload {
/* stake to bake. if set to 0, this removes the account as a baker */
/** stake to bake. if set to 0, this removes the account as a baker */
stake?: CcdAmount.Type;
/* should earnings from baking be added to staked amount */
/** should earnings from baking be added to staked amount */
restakeEarnings?: boolean;
openForDelegation?: OpenStatus;
keys?: BakerKeysWithProofs;
metadataUrl?: UrlString;
transactionFeeCommission?: number;
bakingRewardCommission?: number;
finalizationRewardCommission?: number;
/**
* Describes whether the validator should change its suspended status. This field is only from protocol version 8
* and later.
*/
suspended?: boolean;
}

export interface ConfigureDelegationPayload {
Expand Down
5 changes: 3 additions & 2 deletions packages/sdk/test/ci/accountTransactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test('configureBaker is serialized correctly', async () => {
sender: AccountAddress.fromBase58(senderAccountAddress),
};

const payload: Required<ConfigureBakerPayload> = {
const payload: ConfigureBakerPayload = {
stake: CcdAmount.fromMicroCcd(1000000000n),
restakeEarnings: true,
openForDelegation: OpenStatus.ClosedForAll,
Expand Down Expand Up @@ -281,13 +281,14 @@ test('ConfigureBakerPayload serializes to JSON correctly', async () => {
transactionFeeCommission: 1,
bakingRewardCommission: 1,
finalizationRewardCommission: 1,
suspended: true,
};
const handler = new ConfigureBakerHandler();
let json = handler.toJSON(payload);

let actual = JSONBig.stringify(json);
let expected =
'{"stake":"1000000000","restakeEarnings":true,"openForDelegation":2,"keys":{"signatureVerifyKey":"abcdef","electionVerifyKey":"abcdef","aggregationVerifyKey":"abcdef","proofAggregation":"abcdef","proofSig":"abcdef","proofElection":"abcdef"},"metadataUrl":"http://example.com","transactionFeeCommission":1,"bakingRewardCommission":1,"finalizationRewardCommission":1}';
'{"stake":"1000000000","restakeEarnings":true,"openForDelegation":2,"keys":{"signatureVerifyKey":"abcdef","electionVerifyKey":"abcdef","aggregationVerifyKey":"abcdef","proofAggregation":"abcdef","proofSig":"abcdef","proofElection":"abcdef"},"metadataUrl":"http://example.com","transactionFeeCommission":1,"bakingRewardCommission":1,"finalizationRewardCommission":1,"suspended":true}';
expect(actual).toEqual(expected);

// ID test
Expand Down

0 comments on commit 7ad3203

Please sign in to comment.