Open holic opened 6 months ago
I think it's probably fine to manually define this one because it will never change? Also seems gnarly to codegen
I think it's probably fine to manually define this one because it will never change? Also seems gnarly to codegen
new Array(32).fill(null).map((, i) => {
const byteLength = i + 1;
return `
function getBytes${byteLength}(bytes32 data, uint256 start) internal pure returns (bytes${byteLength} output) {
assembly {
output := shl(mul(8, start), data)
}
}
function getBytes${byteLength}(bytes memory data, uint256 start) internal pure returns (bytes${byteLength} output) {
assembly {
output := mload(add(add(data, 0x20), start))
}
}
`;
}).join('\n\n');
This defines the ~same function multiple times for each
bytesN
type: https://github.com/latticexyz/mud/blob/main/packages/store/src/Bytes.solProbably best if we codegen this and also codegen corresponding tests.