From d2df92c76fb79cf18ee4ea71d73fc22f7a1d149d Mon Sep 17 00:00:00 2001 From: David Hernando Date: Thu, 19 Feb 2026 22:49:11 +0100 Subject: [PATCH] Added ValidatorRev to BidAddrKey class Signed-off-by: David Hernando --- Casper.Network.SDK.Test/GlobalStateKeyTest.cs | 10 ++++++++++ Casper.Network.SDK/Types/GlobalStateKey/BidAddrKey.cs | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/Casper.Network.SDK.Test/GlobalStateKeyTest.cs b/Casper.Network.SDK.Test/GlobalStateKeyTest.cs index 11f01a9..99c7e7f 100644 --- a/Casper.Network.SDK.Test/GlobalStateKeyTest.cs +++ b/Casper.Network.SDK.Test/GlobalStateKeyTest.cs @@ -634,6 +634,16 @@ public void BidAddrKeyTest() Assert.IsNull(bidAddrKey.DelegatorAccount); Assert.AreEqual(127, bidAddrKey.EraId); } + { + var validatorRevBidAddrKeyStr = "bid-addr-092f3fb80d362ad0a922f446915a259c9aaec9ba99292b3e50ff2359c458007309"; + var key = GlobalStateKey.FromString(validatorRevBidAddrKeyStr); + Assert.IsNotNull(key); + Assert.AreEqual(KeyIdentifier.BidAddr, key.KeyIdentifier); + + var bidAddrKey = key as BidAddrKey; + Assert.AreEqual(BidAddrTag.ValidatorRev, bidAddrKey.Tag); + Assert.AreEqual("account-hash-2f3fb80d362ad0a922f446915a259c9aaec9ba99292b3e50ff2359c458007309", bidAddrKey.Validator.ToString().ToLower()); + } } } } diff --git a/Casper.Network.SDK/Types/GlobalStateKey/BidAddrKey.cs b/Casper.Network.SDK/Types/GlobalStateKey/BidAddrKey.cs index 55bd857..3d0e711 100644 --- a/Casper.Network.SDK/Types/GlobalStateKey/BidAddrKey.cs +++ b/Casper.Network.SDK/Types/GlobalStateKey/BidAddrKey.cs @@ -42,6 +42,10 @@ public enum BidAddrTag /// BidAddr for unbonding purses. /// UnbondPurse = 8, + /// + /// BidAddr for reverse validator look up. + /// + ValidatorRev = 9, } public class BidAddrKey : GlobalStateKey @@ -146,6 +150,12 @@ public BidAddrKey(string key) : base(key, KEYPREFIX) Validator = new AccountHashKey(bytes.Slice(1, 33)); DelegatorPurseAddress = Hex.ToHexString(bytes.Slice(33)); break; + case (byte)BidAddrTag.ValidatorRev: + Tag = BidAddrTag.ValidatorRev; + if (bytes.Length != 33) + throw new Exception("Wrong key length for ValidatorRev BidAddr. Expected 33 bytes."); + Validator = new AccountHashKey(bytes.Slice(1, 33)); + break; default: throw new Exception($"Wrong BidAddr tag '{bytes[0]}'."); }