Skip to content

Commit

Permalink
chore: refactor after PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
Georgi Grigorov committed Nov 8, 2024
1 parent 8bcdc9c commit 527bf18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/limechain/runtime/Runtime.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private Optional<byte[]> findStorageValue(Nibbles key) {
}

public BigInteger getGenesisSlotNumber() {
var optGenesisSlotBytes = this.findStorageValue(RuntimeStorageKey.GENESIS_SLOT.getKey());
var optGenesisSlotBytes = this.findStorageValue(RuntimeStorageKey.GENESIS_SLOT.getNibbles());
return optGenesisSlotBytes.map(LittleEndianUtils::fromLittleEndianByteArray).orElse(null);
}

Expand Down
11 changes: 8 additions & 3 deletions src/main/java/com/limechain/runtime/RuntimeStorageKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
import lombok.AllArgsConstructor;
import lombok.Getter;

// all available keys can be found here: https://www.shawntabrizi.com/substrate-known-keys/
// All available keys can be found here: https://www.shawntabrizi.com/substrate-known-keys/
// Keys are encoded using 'xxHash' algorithm, and we use directly the encoded value
@Getter
@AllArgsConstructor
public enum RuntimeStorageKey {
GENESIS_SLOT(Nibbles.fromHexString("0x1cb6f36e027abb2091cfb5110ab5087f678711d15ebbceba5cd0cea158e6675a"));
GENESIS_SLOT("0x1cb6f36e027abb2091cfb5110ab5087f678711d15ebbceba5cd0cea158e6675a");

private final Nibbles key;
private final String encodedKey;

public Nibbles getNibbles() {
return Nibbles.fromHexString(this.getEncodedKey());
}
}

0 comments on commit 527bf18

Please sign in to comment.