@@ -179,13 +179,9 @@ pub const VoluntaryExit = struct {
179179 validator_index: primitives.ValidatorIndex,
180180};
181181
182- pub const SignedVoluntaryExit = union(primitives.ForkType) {
183- phase0: NonExistType,
184- altair: altair.SignedVoluntaryExit,
185- bellatrix: altair.SignedVoluntaryExit,
186- capella: altair.SignedVoluntaryExit,
187- deneb: altair.SignedVoluntaryExit,
188- electra: altair.SignedVoluntaryExit,
182+ pub const SignedVoluntaryExit = struct {
183+ message: VoluntaryExit,
184+ signature: primitives.BLSSignature,
189185};
190186
191187pub const SignedBeaconBlockHeader = struct {
@@ -530,6 +526,20 @@ pub const PendingPartialWithdrawal = union(primitives.ForkType) {
530526 capella: NonExistType,
531527 deneb: NonExistType,
532528 electra: electra.PendingPartialWithdrawal,
529+
530+ pub fn index(self: *const PendingPartialWithdrawal) primitives.ValidatorIndex {
531+ return switch (self.*) {
532+ .phase0, .altair, .bellatrix, .capella, .deneb => @panic("index is not supported for phase0, altair, bellatrix, capella, deneb"),
533+ inline else => |withdrawal| withdrawal.index,
534+ };
535+ }
536+
537+ pub fn amount(self: *const PendingPartialWithdrawal) primitives.Gwei {
538+ return switch (self.*) {
539+ .phase0, .altair, .bellatrix, .capella, .deneb => @panic("amount is not supported for phase0, altair, bellatrix, capella, deneb"),
540+ inline else => |withdrawal| withdrawal.amount,
541+ };
542+ }
533543};
534544
535545pub const WithdrawalRequest = union(primitives.ForkType) {
@@ -748,11 +758,19 @@ pub const BeaconState = union(primitives.ForkType) {
748758 /// pendingBalanceDeposits returns the pending balance deposits of the given state.
749759 pub fn pendingBalanceDeposit(self: *const BeaconState) []PendingBalanceDeposit {
750760 return switch (self.*) {
751- .phase0, .altair, .bellatrix, .capella, .deneb => @panic("pending_balance_deposits is not supported for phase0"),
761+ .phase0, .altair, .bellatrix, .capella, .deneb => @panic("pending_balance_deposits is not supported for phase0, altair, bellatrix, capella, deneb "),
752762 inline else => |state| state.pending_balance_deposits,
753763 };
754764 }
755765
766+ /// pendingPartialWithdrawals returns the pending partial withdrawals of the given state.
767+ pub fn pendingPartialWithdrawals(self: *const BeaconState) []PendingPartialWithdrawal {
768+ return switch (self.*) {
769+ .phase0, .altair, .bellatrix, .capella, .deneb => @panic("pending_partial_withdrawals is not supported for phase0, altair, bellatrix, capella, deneb"),
770+ inline else => |state| state.pending_partial_withdrawals,
771+ };
772+ }
773+
756774 /// eth1DepositIndex returns the eth1 deposit index of the given state.
757775 pub fn eth1DepositIndex(self: *const BeaconState) u64 {
758776 return switch (self.*) {
@@ -783,23 +801,6 @@ test "test Attestation" {
783801 try std.testing.expectEqual(attestation1.altair.aggregation_bits.len, 0);
784802}
785803
786- test "test SignedVoluntaryExit" {
787- const exit = SignedVoluntaryExit{
788- .phase0 = NonExistType{},
789- };
790-
791- try std.testing.expectEqual(exit.phase0, NonExistType{});
792-
793- const exit1 = SignedVoluntaryExit{
794- .altair = altair.SignedVoluntaryExit{
795- .message = undefined,
796- .signature = undefined,
797- },
798- };
799-
800- try std.testing.expectEqual(exit1.altair.message, undefined);
801- }
802-
803804test "test SyncAggregate" {
804805 const aggregate = SyncAggregate{
805806 .phase0 = NonExistType{},
@@ -1203,3 +1204,12 @@ test "test Validator" {
12031204
12041205 try std.testing.expectEqual(validator.effective_balance, 0);
12051206}
1207+
1208+ test "test SignedVoluntaryExit" {
1209+ const exit = SignedVoluntaryExit{
1210+ .message = undefined,
1211+ .signature = undefined,
1212+ };
1213+
1214+ try std.testing.expectEqual(exit.message, undefined);
1215+ }
0 commit comments