Documentation
¶
Index ¶
Constants ¶
View Source
const (
StorageSlotSizeBytes = 32
)
Variables ¶
View Source
var (
ErrNoSlot = errors.New("no such slot found in layout JSON")
)
Functions ¶
func MergeHex ¶
MergeHex merges two hex strings with bitwise "OR" should be used when you see values with offsets in smart contract storage layout.json file
Example layout: ╭----------------+-------------------------------------------+------+--------+-------+-------------------------╮ | Name | Type | Slot | Offset | Bytes | Contract | |----------------+-------------------------------------------+------+--------+-------+-------------------------| | number_uint8 | uint8 | 3 | 0 | 1 | src/Counter.sol:Counter | |----------------+-------------------------------------------+------+--------+-------+-------------------------| | boolean | bool | 3 | 1 | 1 | src/Counter.sol:Counter | |----------------+-------------------------------------------+------+--------+-------+-------------------------|
func MustEncodeStorageSlot ¶
MustEncodeStorageSlot encodes a value for Solidity storage slots based on type Panics if encoding fails
func ShiftHexByOffset ¶
ShiftHexByOffset is used to set values in slots with offsets
Types ¶
type StorageEntry ¶
type StorageLayout ¶
type StorageLayout struct {
Storage []StorageEntry `json:"storage"`
}
func New ¶
func New(filename string) (*StorageLayout, error)
New creates a new storage layout wrapper
func (*StorageLayout) GetSlots ¶
func (s *StorageLayout) GetSlots() map[string]string
func (*StorageLayout) MustArraySlot ¶
func (s *StorageLayout) MustArraySlot(label string, index int64) string
MustArraySlot calculates a slot in Solidity array for storage field and a key
func (*StorageLayout) MustMapSlot ¶
func (s *StorageLayout) MustMapSlot(label, key string) string
MustMapSlot calculates a slot in Solidity mapping for storage field and a key
func (*StorageLayout) MustSlot ¶
func (s *StorageLayout) MustSlot(label string) string
MustSlot calculates a slot in Solidity mapping for storage field and a key
Click to show internal directories.
Click to hide internal directories.