Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
Merge main into mardizzone/node-16 (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
leovct authored Dec 1, 2023
1 parent a29ed28 commit 4291b97
Show file tree
Hide file tree
Showing 37 changed files with 35,211 additions and 28,616 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@ name: CI
on:
push:
branches:
- develop
- master
- release-0.3-3
- main
pull_request:

concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
NODE_VERSION: "16"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '16'
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'
- name: Cache npm dependencies
uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.17.1
16.20.2
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 16.20.2
72 changes: 72 additions & 0 deletions contracts/child/BaseERC20NoSig.sol
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;
}
}
4 changes: 1 addition & 3 deletions contracts/child/ChildERC721.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
pragma solidity ^0.5.2;

import {
ERC721Full
} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol";
import {ERC721Full} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol";

import "./ChildToken.sol";
import "./misc/IParentToken.sol";
Expand Down
4 changes: 2 additions & 2 deletions contracts/child/MRC20.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
pragma solidity ^0.5.11;

import "./BaseERC20.sol";
import "./BaseERC20NoSig.sol";

/**
* @title Matic token contract
* @notice This contract is an ECR20 like wrapper over native ether (matic token) transfers on the matic chain
* @dev ERC20 methods have been made payable while keeping their method signature same as other ChildERC20s on Matic
*/
contract MRC20 is BaseERC20 {
contract MRC20 is BaseERC20NoSig {
event Transfer(address indexed from, address indexed to, uint256 value);

uint256 public currentSupply = 0;
Expand Down
170 changes: 170 additions & 0 deletions contracts/common/lib/ExitPayloadReader.sol
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];
}
}
2 changes: 1 addition & 1 deletion contracts/common/lib/Merkle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ library Merkle {
uint256 index,
bytes32 rootHash,
bytes memory proof
) public pure returns (bool) {
) internal pure returns (bool) {
require(proof.length % 32 == 0, "Invalid proof length");
uint256 proofHeight = proof.length / 32;
// Proof of size n means, height of the tree is n+1.
Expand Down
12 changes: 3 additions & 9 deletions contracts/common/tokens/ERC721PlasmaMintable.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
pragma solidity ^0.5.2;

import {
ERC721Mintable
} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Mintable.sol";
import {
ERC721MetadataMintable
} from "openzeppelin-solidity/contracts/token/ERC721/ERC721MetadataMintable.sol";
import {
ERC721Metadata
} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Metadata.sol";
import {ERC721Mintable} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Mintable.sol";
import {ERC721MetadataMintable} from "openzeppelin-solidity/contracts/token/ERC721/ERC721MetadataMintable.sol";
import {ERC721Metadata} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Metadata.sol";

contract ERC721PlasmaMintable is ERC721Mintable, ERC721MetadataMintable {
constructor(string memory name, string memory symbol)
Expand Down
4 changes: 1 addition & 3 deletions contracts/common/tokens/RootERC721.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
pragma solidity ^0.5.2;

import {
ERC721Full
} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol";
import {ERC721Full} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol";

contract RootERC721 is ERC721Full {
constructor(string memory name, string memory symbol)
Expand Down
Loading

0 comments on commit 4291b97

Please sign in to comment.