Skip to content

Commit ec8feef

Browse files
authored
Merge the develop branch to the master branch, preparation to v3.1.0
2 parents 7d259b9 + f48c366 commit ec8feef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+20938
-24288
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"prefer-destructuring": "off",
2323
"no-use-before-define": ["error", { "functions": false }],
2424
"no-restricted-syntax": "off",
25-
"node/no-unpublished-require": "off"
25+
"node/no-unpublished-require": "off",
26+
"func-names": "off"
2627
}
2728
}

.prettierrc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,13 @@
22
"semi": false,
33
"singleQuote": true,
44
"printWidth": 120,
5-
"bracketSpacing": true
5+
"bracketSpacing": true,
6+
"overrides": [
7+
{
8+
"files": "*.sol",
9+
"options": {
10+
"singleQuote": false
11+
}
12+
}
13+
]
614
}

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ The POA bridge contracts consist of several components:
3737
* Depending on the type of relay operations the following components are also used:
3838
* in `NATIVE-TO-ERC` mode: the ERC20 token (in fact, the ERC677 extension is used) is deployed on the Foreign network;
3939
* in `ERC-TO-ERC` mode: the ERC20 token (in fact, the ERC677 extension is used) is deployed on the Home network;
40+
* in `AMB-ERC-TO-ERC` mode: the ERC20 token (in fact, the ERC677 extension is used) is deployed on the Home network;
4041
* in `ERC-TO-NATIVE` mode: The home network nodes must support consensus engine that allows using a smart contract for block reward calculation;
4142
* The **Validators** smart contract is deployed in both the POA.Network and the Ethereum Mainnet.
4243

@@ -59,8 +60,9 @@ Responsibilities and roles of the bridge:
5960
- sends assets to Bridge contracts:
6061
- in `NATIVE-TO-ERC` mode: send native coins to the Home Bridge to receive ERC20 tokens from the Foreign Bridge, send ERC20 tokens to the Foreign Bridge to unlock native coins from the Home Bridge;
6162
- in `ERC-TO-ERC` mode: transfer ERC20 tokens to the Foreign Bridge to mint ERC20 tokens on the Home Network, transfer ERC20 tokens to the Home Bridge to unlock ERC20 tokens on Foreign networks;
62-
- in `ERC-TO-NATIVE` mode: send ERC20 tokens to the Foreign Bridge to receive native coins from the Home Bridge, send native coins to the Home Bridge to unlock ERC20 tokens from the Foreign Bridge.
63-
- in `ARBITRARY-MESSAGE` mode: Invoke Home/Foreign Bridge to send a message that will be executed on the other Network as an arbitrary contract method invocation.
63+
- in `ERC-TO-NATIVE` mode: send ERC20 tokens to the Foreign Bridge to receive native coins from the Home Bridge, send native coins to the Home Bridge to unlock ERC20 tokens from the Foreign Bridge;
64+
- in `ARBITRARY-MESSAGE` mode: Invoke Home/Foreign Bridge to send a message that will be executed on the other Network as an arbitrary contract method invocation;
65+
- in `AMB-ERC-TO-ERC` mode: transfer ERC20 tokens to the Foreign Mediator which will interact with Foreign AMB Bridge to mint ERC20 tokens on the Home Network, transfer ERC20 tokens to the Home Mediator which will interact with Home AMB Bridge to unlock ERC20 tokens on Foreign network. - in `ARBITRARY-MESSAGE` mode: Invoke Home/Foreign Bridge to send a message that will be executed on the other Network as an arbitrary contract method invocation.
6466

6567
## Usage
6668

contracts/interfaces/IAMB.sol

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
pragma solidity 0.4.24;
2+
3+
interface IAMB {
4+
function messageSender() external view returns (address);
5+
function maxGasPerTx() external view returns (uint256);
6+
function transactionHash() external view returns (bytes32);
7+
function messageCallStatus(bytes32 _txHash) external view returns (bool);
8+
function failedMessageDataHash(bytes32 _txHash) external view returns (bytes32);
9+
function failedMessageReceiver(bytes32 _txHash) external view returns (address);
10+
function failedMessageSender(bytes32 _txHash) external view returns (address);
11+
function requireToPassMessage(address _contract, bytes _data, uint256 _gas) external;
12+
}

contracts/libraries/Bytes.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pragma solidity 0.4.24;
2+
3+
library Bytes {
4+
function bytesToBytes32(bytes _bytes) internal pure returns (bytes32 result) {
5+
assembly {
6+
result := mload(add(_bytes, 32))
7+
}
8+
}
9+
}

contracts/libraries/Message.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ library Message {
167167
bytes memory bstr = new bytes(length);
168168
uint256 k = length - 1;
169169
while (i != 0) {
170-
bstr[k--] = bytes1(48 + i % 10);
170+
bstr[k--] = bytes1(48 + (i % 10));
171171
i /= 10;
172172
}
173173
return string(bstr);

contracts/mocks/AMBMock.sol

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
pragma solidity 0.4.24;
2+
3+
contract AMBMock {
4+
event MockedEvent(bytes encodedData);
5+
6+
address public messageSender;
7+
uint256 public maxGasPerTx;
8+
bytes32 public transactionHash;
9+
mapping(bytes32 => bool) public messageCallStatus;
10+
mapping(bytes32 => address) public failedMessageSender;
11+
mapping(bytes32 => address) public failedMessageReceiver;
12+
mapping(bytes32 => bytes32) public failedMessageDataHash;
13+
14+
function setMaxGasPerTx(uint256 _value) public {
15+
maxGasPerTx = _value;
16+
}
17+
18+
function executeMessageCall(address _contract, address _sender, bytes _data, bytes32 _txHash, uint256 _gas) public {
19+
messageSender = _sender;
20+
transactionHash = _txHash;
21+
bool status = _contract.call.gas(_gas)(_data);
22+
messageSender = address(0);
23+
transactionHash = bytes32(0);
24+
25+
messageCallStatus[_txHash] = status;
26+
if (!status) {
27+
failedMessageDataHash[_txHash] = keccak256(_data);
28+
failedMessageReceiver[_txHash] = _contract;
29+
failedMessageSender[_txHash] = _sender;
30+
}
31+
}
32+
33+
function requireToPassMessage(address _contract, bytes _data, uint256 _gas) public {
34+
emit MockedEvent(abi.encodePacked(msg.sender, _contract, _gas, uint8(0x00), _data));
35+
}
36+
}

contracts/mocks/Box.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pragma solidity 0.4.24;
22

3-
import "./IAMB.sol";
3+
import "../interfaces/IAMB.sol";
44

55
contract Box {
66
uint256 public value;

contracts/mocks/ERC20Mock.sol

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pragma solidity 0.4.24;
2+
3+
import "openzeppelin-solidity/contracts/token/ERC20/MintableToken.sol";
4+
import "openzeppelin-solidity/contracts/token/ERC20/DetailedERC20.sol";
5+
import "openzeppelin-solidity/contracts/token/ERC20/BurnableToken.sol";
6+
7+
contract ERC20Mock is DetailedERC20, BurnableToken, MintableToken {
8+
constructor(string _name, string _symbol, uint8 _decimals) public DetailedERC20(_name, _symbol, _decimals) {
9+
// solhint-disable-previous-line no-empty-blocks
10+
}
11+
}

contracts/mocks/IAMB.sol

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)