This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
35,211 additions
and
28,616 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16.17.1 | ||
16.20.2 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nodejs 16.20.2 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
pragma solidity ^0.5.2; | ||
|
||
import "./ChildToken.sol"; | ||
|
||
contract BaseERC20NoSig is ChildToken { | ||
event Deposit( | ||
address indexed token, | ||
address indexed from, | ||
uint256 amount, | ||
uint256 input1, | ||
uint256 output1 | ||
); | ||
|
||
event Withdraw( | ||
address indexed token, | ||
address indexed from, | ||
uint256 amount, | ||
uint256 input1, | ||
uint256 output1 | ||
); | ||
|
||
event LogTransfer( | ||
address indexed token, | ||
address indexed from, | ||
address indexed to, | ||
uint256 amount, | ||
uint256 input1, | ||
uint256 input2, | ||
uint256 output1, | ||
uint256 output2 | ||
); | ||
|
||
constructor() public {} | ||
|
||
function transferWithSig( | ||
bytes calldata sig, | ||
uint256 amount, | ||
bytes32 data, | ||
uint256 expiration, | ||
address to | ||
) external returns (address from) { | ||
revert("Disabled feature"); | ||
} | ||
|
||
function balanceOf(address account) external view returns (uint256); | ||
function _transfer(address sender, address recipient, uint256 amount) | ||
internal; | ||
|
||
/// @param from Address from where tokens are withdrawn. | ||
/// @param to Address to where tokens are sent. | ||
/// @param value Number of tokens to transfer. | ||
/// @return Returns success of function call. | ||
function _transferFrom(address from, address to, uint256 value) | ||
internal | ||
returns (bool) | ||
{ | ||
uint256 input1 = this.balanceOf(from); | ||
uint256 input2 = this.balanceOf(to); | ||
_transfer(from, to, value); | ||
emit LogTransfer( | ||
token, | ||
from, | ||
to, | ||
value, | ||
input1, | ||
input2, | ||
this.balanceOf(from), | ||
this.balanceOf(to) | ||
); | ||
return true; | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
pragma solidity 0.5.17; | ||
|
||
import {RLPReader} from "solidity-rlp/contracts/RLPReader.sol"; | ||
import {BytesLib} from "./BytesLib.sol"; | ||
|
||
library ExitPayloadReader { | ||
using RLPReader for bytes; | ||
using RLPReader for RLPReader.RLPItem; | ||
|
||
uint8 constant WORD_SIZE = 32; | ||
|
||
struct ExitPayload { | ||
RLPReader.RLPItem[] data; | ||
} | ||
|
||
struct Receipt { | ||
RLPReader.RLPItem[] data; | ||
bytes raw; | ||
uint256 logIndex; | ||
} | ||
|
||
struct Log { | ||
RLPReader.RLPItem data; | ||
RLPReader.RLPItem[] list; | ||
} | ||
|
||
struct LogTopics { | ||
RLPReader.RLPItem[] data; | ||
} | ||
|
||
function toExitPayload(bytes memory data) | ||
internal | ||
pure | ||
returns (ExitPayload memory) | ||
{ | ||
RLPReader.RLPItem[] memory payloadData = data | ||
.toRlpItem() | ||
.toList(); | ||
|
||
return ExitPayload(payloadData); | ||
} | ||
|
||
function copy(uint src, uint dest, uint len) private pure { | ||
if (len == 0) return; | ||
|
||
// copy as many word sizes as possible | ||
for (; len >= WORD_SIZE; len -= WORD_SIZE) { | ||
assembly { | ||
mstore(dest, mload(src)) | ||
} | ||
|
||
src += WORD_SIZE; | ||
dest += WORD_SIZE; | ||
} | ||
|
||
// left over bytes. Mask is used to remove unwanted bytes from the word | ||
uint mask = 256 ** (WORD_SIZE - len) - 1; | ||
assembly { | ||
let srcpart := and(mload(src), not(mask)) // zero out src | ||
let destpart := and(mload(dest), mask) // retrieve the bytes | ||
mstore(dest, or(destpart, srcpart)) | ||
} | ||
} | ||
|
||
function getHeaderNumber(ExitPayload memory payload) internal pure returns(uint256) { | ||
return payload.data[0].toUint(); | ||
} | ||
|
||
function getBlockProof(ExitPayload memory payload) internal pure returns(bytes memory) { | ||
return payload.data[1].toBytes(); | ||
} | ||
|
||
function getBlockNumber(ExitPayload memory payload) internal pure returns(uint256) { | ||
return payload.data[2].toUint(); | ||
} | ||
|
||
function getBlockTime(ExitPayload memory payload) internal pure returns(uint256) { | ||
return payload.data[3].toUint(); | ||
} | ||
|
||
function getTxRoot(ExitPayload memory payload) internal pure returns(bytes32) { | ||
return bytes32(payload.data[4].toUint()); | ||
} | ||
|
||
function getReceiptRoot(ExitPayload memory payload) internal pure returns(bytes32) { | ||
return bytes32(payload.data[5].toUint()); | ||
} | ||
|
||
function getReceipt(ExitPayload memory payload) internal pure returns(Receipt memory receipt) { | ||
receipt.raw = payload.data[6].toBytes(); | ||
RLPReader.RLPItem memory receiptItem = receipt.raw.toRlpItem(); | ||
|
||
if (receiptItem.isList()) { | ||
// legacy tx | ||
receipt.data = receiptItem.toList(); | ||
} else { | ||
// pop first byte before parsting receipt | ||
bytes memory typedBytes = receipt.raw; | ||
bytes memory result = new bytes(typedBytes.length - 1); | ||
uint256 srcPtr; | ||
uint256 destPtr; | ||
assembly { | ||
srcPtr := add(33, typedBytes) | ||
destPtr := add(0x20, result) | ||
} | ||
|
||
copy(srcPtr, destPtr, result.length); | ||
receipt.data = result.toRlpItem().toList(); | ||
} | ||
|
||
receipt.logIndex = getReceiptLogIndex(payload); | ||
return receipt; | ||
} | ||
|
||
function getReceiptProof(ExitPayload memory payload) internal pure returns(bytes memory) { | ||
return payload.data[7].toBytes(); | ||
} | ||
|
||
function getBranchMaskAsBytes(ExitPayload memory payload) internal pure returns(bytes memory) { | ||
return payload.data[8].toBytes(); | ||
} | ||
|
||
function getBranchMaskAsUint(ExitPayload memory payload) internal pure returns(uint256) { | ||
return payload.data[8].toUint(); | ||
} | ||
|
||
function getReceiptLogIndex(ExitPayload memory payload) internal pure returns(uint256) { | ||
return payload.data[9].toUint(); | ||
} | ||
|
||
function getTx(ExitPayload memory payload) internal pure returns(bytes memory) { | ||
return payload.data[10].toBytes(); | ||
} | ||
|
||
function getTxProof(ExitPayload memory payload) internal pure returns(bytes memory) { | ||
return payload.data[11].toBytes(); | ||
} | ||
|
||
// Receipt methods | ||
function toBytes(Receipt memory receipt) internal pure returns(bytes memory) { | ||
return receipt.raw; | ||
} | ||
|
||
function getLog(Receipt memory receipt) internal pure returns(Log memory) { | ||
RLPReader.RLPItem memory logData = receipt.data[3].toList()[receipt.logIndex]; | ||
return Log(logData, logData.toList()); | ||
} | ||
|
||
// Log methods | ||
function getEmitter(Log memory log) internal pure returns(address) { | ||
return RLPReader.toAddress(log.list[0]); | ||
} | ||
|
||
function getTopics(Log memory log) internal pure returns(LogTopics memory) { | ||
return LogTopics(log.list[1].toList()); | ||
} | ||
|
||
function getData(Log memory log) internal pure returns(bytes memory) { | ||
return log.list[2].toBytes(); | ||
} | ||
|
||
function toRlpBytes(Log memory log) internal pure returns(bytes memory) { | ||
return log.data.toRlpBytes(); | ||
} | ||
|
||
// LogTopics methods | ||
function getField(LogTopics memory topics, uint256 index) internal pure returns(RLPReader.RLPItem memory) { | ||
return topics.data[index]; | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.