Skip to content

Commit

Permalink
feat: overload methods support + TupleHelper
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 4b9143058a5d9fc5ce49d42f9268de48ba09f0d8
Author: FP <[email protected]>
Date:   Mon Aug 15 09:49:39 2022 -0700

    chore: minor cleanup

commit f558457
Author: Poolpi Tako <[email protected]>
Date:   Thu Aug 4 13:29:36 2022 -0500

    fix: overloaded methods in weiroll

commit 263e861
Author: Poolpi Tako <[email protected]>
Date:   Wed Aug 3 22:31:56 2022 -0500

    fix: 1inch working

commit 5ccb9aa
Author: Poolpi Tako <[email protected]>
Date:   Wed Aug 3 15:09:15 2022 -0500

    feat: chain test wip

commit f453e34
Author: Poolpi Tako <[email protected]>
Date:   Tue Aug 2 10:27:52 2022 -0500

    feat: added an additional curve test with call()
  • Loading branch information
fp-crypto committed Aug 15, 2022
1 parent e1f81a1 commit 1cb7f15
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 83 deletions.
7 changes: 6 additions & 1 deletion contracts/CommandBuilder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@ library CommandBuilder {
if (idx == IDX_END_OF_ARGS) return;

bytes memory entry = state[idx & IDX_VALUE_MASK] = new bytes(output.length + 32);
memcpy(output, 0, entry, 0, entry.length);

memcpy(output, 0, entry, 32, output.length);
assembly {
let l := mload(output)
mstore(add(entry, 32), l)
}
}

function memcpy(
Expand Down
13 changes: 11 additions & 2 deletions contracts/Helpers/TupleHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract TupleHelper {
returns (bytes memory newTuple)
{
uint256 byteIndex;
unchecked {
unchecked {
byteIndex = index * 32;
require(tuple.length >= 32 && byteIndex <= tuple.length - 32);
newTuple = bytes.concat(tuple[:byteIndex], element, tuple[byteIndex+32:]);
Expand All @@ -36,5 +36,14 @@ contract TupleHelper {
}
}
}
}

function getElement(bytes memory tuple, uint256 index)
public
pure
returns (bytes32)
{
assembly {
return(add(tuple, mul(add(index, 1), 32)), 32)
}
}
}
Loading

0 comments on commit 1cb7f15

Please sign in to comment.