Created
May 10, 2018 08:24
-
-
Save ayinot/d73da55fb9c01de399f0a2aa99206c6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.19; | |
contract Interchain { | |
bytes public selector; | |
bytes public destHash; | |
function withdrawal(bytes32 destHash) returns(bytes4){ | |
return this.withdrawal.selector; | |
} | |
function parse(bytes _selector, bytes _destHash) returns (bytes b){ | |
selector = _selector; | |
destHash = _destHash; | |
b = strConcat(_selector,_destHash); | |
} | |
function strConcat(bytes _a, bytes _b) public returns (bytes){ | |
bytes memory _aa = _a; | |
bytes memory _bb = _b; | |
bytes memory ab = new bytes(_aa.length + _bb.length); | |
uint l = _aa.length; | |
assembly{ | |
mstore(add(ab,32),mload(add(_aa,32))) | |
mstore(add(add(ab,32),l),mload(add(_bb,32))) | |
} | |
bytes memory b = new bytes(36); | |
assembly { mstore(add(b, 32), mload(add(ab,32))) } | |
return b; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment