Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mappedPaths,
currentAssignments,
currentDepth
);
let slot = { path };
//we need to do things differently depending on whether we're dealing
//with an array or mapping
switch (Codec.Ast.Utils.typeClass(baseExpression)) {
case "array":
slot.hashPath = Codec.Ast.Utils.isDynamicArray(baseExpression);
slot.offset = indexValue.value.asBN.muln(
//HACK: the allocation format here is wrong (object rather than
//array), but it doesn't matter because we're not using that here
Codec.Storage.Allocate.storageSize(
node,
referenceDeclarations,
allocations
).words
);
break;
case "mapping":
slot.key = indexValue;
slot.offset = new BN(0);
break;
default:
debug("unrecognized index access!");
}
debug("slot %O", slot);
//now, map it! (and do the assign as well)
//it doesn't then we conclude that no the parent does not have a spot in
//the table). If the parent has a slot in the table already, then we
//alter the child slot by replacing its path with the parent slot. This
//will keep the slotAddress the same, but since the versions kept in the
//table here are supposed to preserve path information, we'll be
//replacing a fairly bare-bones Slot object with one with a full path.
//we do NOT want to distinguish between types with and without "_ptr" on
//the end here! (or _slice)
debug("typeIdentifier %s", typeIdentifier);
typeIdentifier = Codec.Ast.Utils.regularizeTypeIdentifier(typeIdentifier);
parentType = Codec.Ast.Utils.regularizeTypeIdentifier(parentType);
debug("slot %o", slot);
let hexSlotAddress = Codec.Conversion.toHexString(
Codec.Storage.Utils.slotAddress(slot),
Codec.Evm.Utils.WORD_SIZE
);
let parentAddress = slot.path
? Codec.Conversion.toHexString(
Codec.Storage.Utils.slotAddress(slot.path),
Codec.Evm.Utils.WORD_SIZE
)
: undefined;
//this is going to be messy and procedural, sorry. but let's start with
//the easy stuff: create the new address if needed, clone if not
let newState = {
...state,
byAddress: {
...state.byAddress,
[address]: {
//replacing a fairly bare-bones Slot object with one with a full path.
//we do NOT want to distinguish between types with and without "_ptr" on
//the end here! (or _slice)
debug("typeIdentifier %s", typeIdentifier);
typeIdentifier = Codec.Ast.Utils.regularizeTypeIdentifier(typeIdentifier);
parentType = Codec.Ast.Utils.regularizeTypeIdentifier(parentType);
debug("slot %o", slot);
let hexSlotAddress = Codec.Conversion.toHexString(
Codec.Storage.Utils.slotAddress(slot),
Codec.Evm.Utils.WORD_SIZE
);
let parentAddress = slot.path
? Codec.Conversion.toHexString(
Codec.Storage.Utils.slotAddress(slot.path),
Codec.Evm.Utils.WORD_SIZE
)
: undefined;
//this is going to be messy and procedural, sorry. but let's start with
//the easy stuff: create the new address if needed, clone if not
let newState = {
...state,
byAddress: {
...state.byAddress,
[address]: {
byType: {
...(state.byAddress[address] || { byType: {} }).byType
}
}
}