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

Commit 4291b97

Browse files
authored
Merge main into mardizzone/node-16 (#490)
1 parent a29ed28 commit 4291b97

37 files changed

+35211
-28616
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,25 @@ name: CI
33
on:
44
push:
55
branches:
6-
- develop
7-
- master
8-
- release-0.3-3
6+
- main
97
pull_request:
108

9+
concurrency:
10+
group: ci-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
env:
14+
NODE_VERSION: "16"
15+
1116
jobs:
1217
build:
1318
runs-on: ubuntu-latest
1419
steps:
15-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
1621
- name: Setup Node.js environment
17-
uses: actions/setup-node@v3
22+
uses: actions/setup-node@v4
1823
with:
19-
node-version: '16'
24+
node-version: ${{ env.NODE_VERSION }}
2025
registry-url: 'https://registry.npmjs.org'
2126
- name: Cache npm dependencies
2227
uses: actions/cache@v3

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16.17.1
1+
16.20.2

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodejs 16.20.2

contracts/child/BaseERC20NoSig.sol

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
pragma solidity ^0.5.2;
2+
3+
import "./ChildToken.sol";
4+
5+
contract BaseERC20NoSig is ChildToken {
6+
event Deposit(
7+
address indexed token,
8+
address indexed from,
9+
uint256 amount,
10+
uint256 input1,
11+
uint256 output1
12+
);
13+
14+
event Withdraw(
15+
address indexed token,
16+
address indexed from,
17+
uint256 amount,
18+
uint256 input1,
19+
uint256 output1
20+
);
21+
22+
event LogTransfer(
23+
address indexed token,
24+
address indexed from,
25+
address indexed to,
26+
uint256 amount,
27+
uint256 input1,
28+
uint256 input2,
29+
uint256 output1,
30+
uint256 output2
31+
);
32+
33+
constructor() public {}
34+
35+
function transferWithSig(
36+
bytes calldata sig,
37+
uint256 amount,
38+
bytes32 data,
39+
uint256 expiration,
40+
address to
41+
) external returns (address from) {
42+
revert("Disabled feature");
43+
}
44+
45+
function balanceOf(address account) external view returns (uint256);
46+
function _transfer(address sender, address recipient, uint256 amount)
47+
internal;
48+
49+
/// @param from Address from where tokens are withdrawn.
50+
/// @param to Address to where tokens are sent.
51+
/// @param value Number of tokens to transfer.
52+
/// @return Returns success of function call.
53+
function _transferFrom(address from, address to, uint256 value)
54+
internal
55+
returns (bool)
56+
{
57+
uint256 input1 = this.balanceOf(from);
58+
uint256 input2 = this.balanceOf(to);
59+
_transfer(from, to, value);
60+
emit LogTransfer(
61+
token,
62+
from,
63+
to,
64+
value,
65+
input1,
66+
input2,
67+
this.balanceOf(from),
68+
this.balanceOf(to)
69+
);
70+
return true;
71+
}
72+
}

contracts/child/ChildERC721.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
pragma solidity ^0.5.2;
22

3-
import {
4-
ERC721Full
5-
} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol";
3+
import {ERC721Full} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol";
64

75
import "./ChildToken.sol";
86
import "./misc/IParentToken.sol";

contracts/child/MRC20.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
pragma solidity ^0.5.11;
22

3-
import "./BaseERC20.sol";
3+
import "./BaseERC20NoSig.sol";
44

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

1313
uint256 public currentSupply = 0;
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
pragma solidity 0.5.17;
2+
3+
import {RLPReader} from "solidity-rlp/contracts/RLPReader.sol";
4+
import {BytesLib} from "./BytesLib.sol";
5+
6+
library ExitPayloadReader {
7+
using RLPReader for bytes;
8+
using RLPReader for RLPReader.RLPItem;
9+
10+
uint8 constant WORD_SIZE = 32;
11+
12+
struct ExitPayload {
13+
RLPReader.RLPItem[] data;
14+
}
15+
16+
struct Receipt {
17+
RLPReader.RLPItem[] data;
18+
bytes raw;
19+
uint256 logIndex;
20+
}
21+
22+
struct Log {
23+
RLPReader.RLPItem data;
24+
RLPReader.RLPItem[] list;
25+
}
26+
27+
struct LogTopics {
28+
RLPReader.RLPItem[] data;
29+
}
30+
31+
function toExitPayload(bytes memory data)
32+
internal
33+
pure
34+
returns (ExitPayload memory)
35+
{
36+
RLPReader.RLPItem[] memory payloadData = data
37+
.toRlpItem()
38+
.toList();
39+
40+
return ExitPayload(payloadData);
41+
}
42+
43+
function copy(uint src, uint dest, uint len) private pure {
44+
if (len == 0) return;
45+
46+
// copy as many word sizes as possible
47+
for (; len >= WORD_SIZE; len -= WORD_SIZE) {
48+
assembly {
49+
mstore(dest, mload(src))
50+
}
51+
52+
src += WORD_SIZE;
53+
dest += WORD_SIZE;
54+
}
55+
56+
// left over bytes. Mask is used to remove unwanted bytes from the word
57+
uint mask = 256 ** (WORD_SIZE - len) - 1;
58+
assembly {
59+
let srcpart := and(mload(src), not(mask)) // zero out src
60+
let destpart := and(mload(dest), mask) // retrieve the bytes
61+
mstore(dest, or(destpart, srcpart))
62+
}
63+
}
64+
65+
function getHeaderNumber(ExitPayload memory payload) internal pure returns(uint256) {
66+
return payload.data[0].toUint();
67+
}
68+
69+
function getBlockProof(ExitPayload memory payload) internal pure returns(bytes memory) {
70+
return payload.data[1].toBytes();
71+
}
72+
73+
function getBlockNumber(ExitPayload memory payload) internal pure returns(uint256) {
74+
return payload.data[2].toUint();
75+
}
76+
77+
function getBlockTime(ExitPayload memory payload) internal pure returns(uint256) {
78+
return payload.data[3].toUint();
79+
}
80+
81+
function getTxRoot(ExitPayload memory payload) internal pure returns(bytes32) {
82+
return bytes32(payload.data[4].toUint());
83+
}
84+
85+
function getReceiptRoot(ExitPayload memory payload) internal pure returns(bytes32) {
86+
return bytes32(payload.data[5].toUint());
87+
}
88+
89+
function getReceipt(ExitPayload memory payload) internal pure returns(Receipt memory receipt) {
90+
receipt.raw = payload.data[6].toBytes();
91+
RLPReader.RLPItem memory receiptItem = receipt.raw.toRlpItem();
92+
93+
if (receiptItem.isList()) {
94+
// legacy tx
95+
receipt.data = receiptItem.toList();
96+
} else {
97+
// pop first byte before parsting receipt
98+
bytes memory typedBytes = receipt.raw;
99+
bytes memory result = new bytes(typedBytes.length - 1);
100+
uint256 srcPtr;
101+
uint256 destPtr;
102+
assembly {
103+
srcPtr := add(33, typedBytes)
104+
destPtr := add(0x20, result)
105+
}
106+
107+
copy(srcPtr, destPtr, result.length);
108+
receipt.data = result.toRlpItem().toList();
109+
}
110+
111+
receipt.logIndex = getReceiptLogIndex(payload);
112+
return receipt;
113+
}
114+
115+
function getReceiptProof(ExitPayload memory payload) internal pure returns(bytes memory) {
116+
return payload.data[7].toBytes();
117+
}
118+
119+
function getBranchMaskAsBytes(ExitPayload memory payload) internal pure returns(bytes memory) {
120+
return payload.data[8].toBytes();
121+
}
122+
123+
function getBranchMaskAsUint(ExitPayload memory payload) internal pure returns(uint256) {
124+
return payload.data[8].toUint();
125+
}
126+
127+
function getReceiptLogIndex(ExitPayload memory payload) internal pure returns(uint256) {
128+
return payload.data[9].toUint();
129+
}
130+
131+
function getTx(ExitPayload memory payload) internal pure returns(bytes memory) {
132+
return payload.data[10].toBytes();
133+
}
134+
135+
function getTxProof(ExitPayload memory payload) internal pure returns(bytes memory) {
136+
return payload.data[11].toBytes();
137+
}
138+
139+
// Receipt methods
140+
function toBytes(Receipt memory receipt) internal pure returns(bytes memory) {
141+
return receipt.raw;
142+
}
143+
144+
function getLog(Receipt memory receipt) internal pure returns(Log memory) {
145+
RLPReader.RLPItem memory logData = receipt.data[3].toList()[receipt.logIndex];
146+
return Log(logData, logData.toList());
147+
}
148+
149+
// Log methods
150+
function getEmitter(Log memory log) internal pure returns(address) {
151+
return RLPReader.toAddress(log.list[0]);
152+
}
153+
154+
function getTopics(Log memory log) internal pure returns(LogTopics memory) {
155+
return LogTopics(log.list[1].toList());
156+
}
157+
158+
function getData(Log memory log) internal pure returns(bytes memory) {
159+
return log.list[2].toBytes();
160+
}
161+
162+
function toRlpBytes(Log memory log) internal pure returns(bytes memory) {
163+
return log.data.toRlpBytes();
164+
}
165+
166+
// LogTopics methods
167+
function getField(LogTopics memory topics, uint256 index) internal pure returns(RLPReader.RLPItem memory) {
168+
return topics.data[index];
169+
}
170+
}

contracts/common/lib/Merkle.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ library Merkle {
66
uint256 index,
77
bytes32 rootHash,
88
bytes memory proof
9-
) public pure returns (bool) {
9+
) internal pure returns (bool) {
1010
require(proof.length % 32 == 0, "Invalid proof length");
1111
uint256 proofHeight = proof.length / 32;
1212
// Proof of size n means, height of the tree is n+1.

contracts/common/tokens/ERC721PlasmaMintable.sol

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
pragma solidity ^0.5.2;
22

3-
import {
4-
ERC721Mintable
5-
} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Mintable.sol";
6-
import {
7-
ERC721MetadataMintable
8-
} from "openzeppelin-solidity/contracts/token/ERC721/ERC721MetadataMintable.sol";
9-
import {
10-
ERC721Metadata
11-
} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Metadata.sol";
3+
import {ERC721Mintable} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Mintable.sol";
4+
import {ERC721MetadataMintable} from "openzeppelin-solidity/contracts/token/ERC721/ERC721MetadataMintable.sol";
5+
import {ERC721Metadata} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Metadata.sol";
126

137
contract ERC721PlasmaMintable is ERC721Mintable, ERC721MetadataMintable {
148
constructor(string memory name, string memory symbol)

contracts/common/tokens/RootERC721.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
pragma solidity ^0.5.2;
22

3-
import {
4-
ERC721Full
5-
} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol";
3+
import {ERC721Full} from "openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol";
64

75
contract RootERC721 is ERC721Full {
86
constructor(string memory name, string memory symbol)

0 commit comments

Comments
 (0)