Skip to content

Commit 0bd85be

Browse files
authored
Merge the develop branch to the master branch, preparation to v2.0.0-rc5
This update for the master branch contains the following set of changes: * [Fix] Lazy setting of bridged tokens metadata (#43) * [Other] Another name for docker image (#38) * [Other] Update CI badge in README (#39) * [Other] Refactor of docker image to deploy and verify without flattened contracts (#40) * [Other] Bump package and contracts interfaces version prior to 2.0.0-rc5 (#44)
2 parents fbe208a + 0d4e2e7 commit 0bd85be

File tree

22 files changed

+354
-85
lines changed

22 files changed

+354
-85
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ flats
1212
contracts.sublime-project
1313
contracts.sublime-workspace
1414
build/
15+
package-lock.json

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
build
33
coverage
4+
deploy/src/remix-helpers

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
- name: Prepare tag names
5959
id: prep
6060
run: |
61-
DOCKER_IMAGE=poanetwork/nft-omnibridge-contracts
61+
DOCKER_IMAGE=omnibridge/nft-contracts
6262
if [[ $GITHUB_REF == refs/tags/* ]]; then
6363
echo ::set-output name=tags::${DOCKER_IMAGE}:${GITHUB_REF#refs/tags/},${DOCKER_IMAGE}:latest
6464
else

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ deploy/*.env*
88
!deploy/.env.example
99
deploy/bridgeDeploymentResults.json
1010
coverage.json
11+
package-lock.json

Dockerfile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM node:14 as contracts
22

3-
WORKDIR /contracts
3+
WORKDIR /workdir
44

55
COPY package.json yarn.lock ./
66
RUN yarn
@@ -11,14 +11,25 @@ RUN yarn compile
1111

1212
FROM node:14
1313

14-
WORKDIR /contracts
14+
WORKDIR /workdir
1515

1616
COPY package.json yarn.lock ./
1717
RUN yarn install --prod
1818

19-
COPY --from=contracts /contracts/build ./build
19+
# Allows remixd to be run within a docker container
20+
RUN sed -i s/127.0.0.1/0.0.0.0/g node_modules/@remix-project/remixd/websocket.js
21+
22+
COPY truffle-config.js truffle-config.js
23+
# No need to have coverage module within the container
24+
RUN sed -i s/\'solidity-coverage\'\,\ // truffle-config.js
25+
26+
COPY ./contracts ./contracts
27+
28+
COPY --from=contracts /workdir/build ./build
2029

2130
COPY deploy.sh deploy.sh
2231
COPY ./deploy ./deploy
2332

24-
ENV PATH="/contracts/:${PATH}"
33+
EXPOSE 65520
34+
35+
ENV PATH="/workdir:/workdir/node_modules/.bin:${PATH}"

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
[![Join the chat at https://gitter.im/poanetwork/poa-bridge](https://badges.gitter.im/poanetwork/poa-bridge.svg)](https://gitter.im/poanetwork/poa-bridge?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2-
[![Build Status](https://github.com/poanetwork/omnibridge-nft/workflows/omnibridge-nft-contracts/badge.svg?branch=master)](https://github.com/poanetwork/omnibridge-nft/workflows/omnibridge-nft-contracts/badge.svg?branch=master)
2+
[![Build Status](https://github.com/omni/omnibridge-nft/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/omni/omnibridge-nft/actions/workflows/main.yml)
33

4-
# Omnibridge NFT Smart Contracts
5-
These contracts provide the core functionality for the Omnibridge NFT AMB extension.
4+
NFT OmniBridge Contracts
5+
====
6+
7+
These contracts provide the core functionality for the NFT Omnibridge AMB extension.
8+
9+
More details about AMB (Arbitrary Message Bridge) extensions can be found [here](https://docs.tokenbridge.net/amb-bridge/about-amb-bridge). The AMB repository is [poanetwork/tokenbridge-contracts](https://github.com/poanetwork/tokenbridge-contracts).
610

711
## License
812

REMIX.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
How to access the contracts in the Remix IDE
2+
====
3+
4+
It is possible to use the docker container to modify, test and deploy the contracts in the Remix IDE.
5+
6+
## Read-Only Access
7+
8+
If it is not needed to modify the contracts, they can be opened in the Remix IDE without necessity to clone the repo:
9+
10+
1. Pull the docker image
11+
```
12+
docker pull omnibridge/nft-contracts:latest
13+
```
14+
15+
2. Run the container
16+
```
17+
docker run -d --rm --name nft-ob-remixd -p 65520:65520
18+
omnibridge/nft-contracts:latest yarn remixd
19+
```
20+
21+
3. Open a new workspace [through connectivity to localhost](https://remix-ide.readthedocs.io/en/latest/remixd.html) in the Remix IDE. It is important to use HTTPS to access the IDE: https://remix.ethereum.org/.
22+
23+
## Keep the changes
24+
25+
In case of the modification of the contracts it makes sense to mount the local directory with the git repo in the Remix IDE.
26+
27+
1. Pull the docker image
28+
```
29+
docker pull omnibridge/nft-contracts:latest
30+
```
31+
2. Move to the directory with the contracts.
32+
```
33+
cd omnibridge-nft
34+
```
35+
36+
3. Run the container
37+
```
38+
docker run -d --rm --name nft-ob-remixd -p 65520:65520
39+
-v $(pwd):/workdir omnibridge/nft-contracts:latest yarn remixd
40+
```
41+
42+
4. Open a new workspace [through connectivity to localhost](https://remix-ide.readthedocs.io/en/latest/remixd.html) in the Remix IDE. It is important to use HTTPS to access the IDE: https://remix.ethereum.org/.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
pragma solidity 0.7.5;
2+
3+
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
4+
import "../interfaces/IERC1155TokenReceiver.sol";
5+
6+
contract NFTWithoutMetadata {
7+
function safeTransferFrom(
8+
address _from,
9+
address _to,
10+
uint256 _id,
11+
bytes memory _data
12+
) external {
13+
IERC721Receiver to = IERC721Receiver(_to);
14+
require(to.onERC721Received(msg.sender, _from, _id, _data) == to.onERC721Received.selector);
15+
}
16+
17+
function safeTransferFrom(
18+
address _from,
19+
address _to,
20+
uint256 _id,
21+
uint256 _amount,
22+
bytes memory _data
23+
) external {
24+
IERC1155TokenReceiver to = IERC1155TokenReceiver(_to);
25+
require(to.onERC1155Received(msg.sender, _from, _id, _amount, _data) == to.onERC1155Received.selector);
26+
}
27+
28+
function balanceOf(address, uint256) external view returns (uint256) {
29+
return 1000;
30+
}
31+
32+
function ownerOf(uint256) external view returns (address) {
33+
return msg.sender;
34+
}
35+
}

contracts/tokens/ERC1155BridgeToken.sol

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,18 @@ contract ERC1155BridgeToken is ERC1155, IBurnableMintableERC1155Token {
112112
_burnBatch(msg.sender, _tokenIds, _values);
113113
}
114114

115+
/**
116+
* @dev Updated bridged token name/symbol parameters.
117+
* Only bridge owner or bridge itself can call this method.
118+
* @param _name new name parameter, will be saved as is, without additional suffixes like " from Mainnet".
119+
* @param _symbol new symbol parameter.
120+
*/
121+
function setMetadata(string calldata _name, string calldata _symbol) external onlyOwner {
122+
require(bytes(_name).length > 0 && bytes(_symbol).length > 0);
123+
name = _name;
124+
symbol = _symbol;
125+
}
126+
115127
/**
116128
* @dev Updates the bridge contract address.
117129
* Can be called by bridge owner after token contract was instantiated.
@@ -170,6 +182,6 @@ contract ERC1155BridgeToken is ERC1155, IBurnableMintableERC1155Token {
170182
uint64 patch
171183
)
172184
{
173-
return (1, 1, 0);
185+
return (1, 2, 0);
174186
}
175187
}

contracts/tokens/ERC721BridgeToken.sol

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,29 @@ contract ERC721BridgeToken is ERC721, IBurnableMintableERC721Token {
7777
_burn(_tokenId);
7878
}
7979

80+
// hack to access private fields in ERC721 contract
81+
struct MetadataStorage {
82+
string name;
83+
string symbol;
84+
}
85+
86+
/**
87+
* @dev Updated bridged token name/symbol parameters.
88+
* Only bridge owner or bridge itself can call this method.
89+
* @param _name new name parameter, will be saved as is, without additional suffixes like " from Mainnet".
90+
* @param _symbol new symbol parameter.
91+
*/
92+
function setMetadata(string calldata _name, string calldata _symbol) external onlyOwner {
93+
require(bytes(_name).length > 0 && bytes(_symbol).length > 0);
94+
95+
MetadataStorage storage metadata;
96+
assembly {
97+
metadata.slot := 6
98+
}
99+
metadata.name = _name;
100+
metadata.symbol = _symbol;
101+
}
102+
80103
/**
81104
* @dev Sets the base URI for all tokens.
82105
* Can be called by bridge owner after token contract was instantiated.
@@ -118,6 +141,6 @@ contract ERC721BridgeToken is ERC721, IBurnableMintableERC721Token {
118141
uint64 patch
119142
)
120143
{
121-
return (1, 0, 1);
144+
return (1, 1, 0);
122145
}
123146
}

0 commit comments

Comments
 (0)