import * as State from 'tevm/State';
// Function accepting various input types
function getStorageValue(
keyInput: StorageKeyLike,
storage: Map<string, bigint>
): bigint | undefined {
const key = State(keyInput);
const keyStr = State.StorageKey.toString(key);
return storage.get(keyStr);
}
// Works with object
const value1 = getStorageValue({
address: contractAddr,
slot: 0n
}, storage);
// Works with StorageKey
const storageKey = State.StorageKey(contractAddr, 0n);
const value2 = getStorageValue(storageKey, storage);