Skip to content

Release/v2.1.0 #871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
404a080
add booster for rewards
alexcos20 Jun 27, 2024
3f847d0
make boost immutable
alexcos20 Jun 28, 2024
1700390
use solidity 0.8.26
alexcos20 Jun 28, 2024
d143e5b
add accesslists contracts
alexcos20 Jun 28, 2024
ba56e45
remove debug code
alexcos20 Jun 28, 2024
937c9b5
add ERC20TemplateSapphire
alexcos20 Jul 31, 2024
b561abe
add ERC20TemplateSapphire
alexcos20 Aug 7, 2024
fa6c3a9
add Sapphire template to deploy script
alexcos20 Aug 7, 2024
ac83709
update to docker compose v2
alexcos20 Aug 7, 2024
fa2e190
fix typo
alexcos20 Aug 7, 2024
df260a1
always show deployment logs
alexcos20 Aug 7, 2024
b707553
show docker logs before check
alexcos20 Aug 7, 2024
2ac9218
show docker logs before check
alexcos20 Aug 7, 2024
93cdff3
use custom barge for large contracts
alexcos20 Aug 7, 2024
ede0a1e
fix deploy script
alexcos20 Aug 7, 2024
31db861
fix deploy script
alexcos20 Aug 7, 2024
80e682a
rename ERC20TemplateSapphire to ERC20Template4
alexcos20 Aug 7, 2024
00c49a2
update README
alexcos20 Aug 8, 2024
c0cf5ae
use main branch of barge
alexcos20 Aug 8, 2024
401e759
reduce contract size
alexcos20 Aug 12, 2024
dd10e04
bump deps & node
alexcos20 Aug 12, 2024
a1d6069
remove tests for orderExecuted
alexcos20 Aug 12, 2024
9e66a03
update build
alexcos20 Aug 12, 2024
2ed0099
add deploy script & deployed addresses
alexcos20 Aug 13, 2024
c49d299
Merge pull request #870 from oceanprotocol/feature/template_sapphire
alexcos20 Aug 13, 2024
3e8cc6c
Merge pull request #868 from oceanprotocol/feature/accesslists
alexcos20 Aug 13, 2024
1e7e269
Merge pull request #867 from oceanprotocol/feature/booster_rewards
alexcos20 Aug 13, 2024
ac37c0f
fix merge issues
alexcos20 Aug 13, 2024
4d7ad42
add AccessList events
alexcos20 Aug 20, 2024
461f555
fix tests
alexcos20 Aug 20, 2024
d02c12a
Merge pull request #872 from oceanprotocol/feature/access_list_events
alexcos20 Aug 20, 2024
4b5d30a
add sepolia to hardhat.config
alexcos20 Aug 30, 2024
0b87627
v2.1.0
alexcos20 Aug 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = v2.0.4
current_version = v2.1.0
commit = True
tag = True

Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
node-version: '20'
- name: Cache node_modules
uses: actions/cache@v2
env:
Expand All @@ -42,7 +42,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
node-version: '20'
- name: Cache node_modules
uses: actions/cache@v2
env:
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: '16'
node-version: '20'
- name: Cache node_modules
uses: actions/cache@v2
env:
Expand Down Expand Up @@ -159,10 +159,10 @@ jobs:
done
ls -la "$HOME/.ocean/ocean-contracts/artifacts/"
- run: cat ${HOME}/.ocean/ocean-contracts/artifacts/address.json
- run: node scripts/check_deployment.js
- name: docker logs
run: docker logs ocean_ocean-contracts_1
if: ${{ failure() }}
run: docker logs ocean-ocean-contracts-1
- run: node scripts/check_deployment.js


publish-npm:
needs: [lint, tests_full,check_deployment]
Expand All @@ -172,7 +172,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
node-version: 20
registry-url: https://registry.npmjs.org/
- run: npm ci
- name: Compile contracts
Expand Down Expand Up @@ -202,7 +202,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
node-version: '20'
- name: Cache node_modules
uses: actions/cache@v2
env:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/deployment_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
done
ls -la "$HOME/.ocean/ocean-contracts/artifacts/"
- run: cat ${HOME}/.ocean/ocean-contracts/artifacts/address.json
- run: node scripts/check_deployment.js
- name: docker logs
run: docker logs ocean_ocean-contracts_1
run: docker logs ocean-ocean-contracts-1
- run: node scripts/check_deployment.js

10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

FROM ubuntu:20.04 as base
FROM ubuntu:22.04 as base
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get -y install curl bash
# nvm env vars
RUN mkdir -p /usr/local/nvm
ENV NVM_DIR /usr/local/nvm
# IMPORTANT: set the exact version
ENV NODE_VERSION v16.20.2
ENV NODE_VERSION v20.16.0
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
RUN /bin/bash -c "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && nvm use --delete-prefix $NODE_VERSION"
# add node and npm to the PATH
Expand All @@ -16,11 +16,11 @@ ENV PATH $NODE_PATH:$PATH


FROM base as builder
RUN apt-get update && apt-get -y install wget
RUN apt-get update && apt-get -y install wget build-essential
COPY . /ocean-contracts
WORKDIR /ocean-contracts
RUN npm i
RUN wget https://gobinaries.com/tj/node-prune --output-document - | /bin/sh && node-prune
#RUN wget https://gobinaries.com/tj/node-prune --output-document - | /bin/sh && node-prune



Expand All @@ -31,7 +31,7 @@ RUN mkdir -p /ocean-contracts/test/
COPY ./addresses /ocean-contracts/addresses/
COPY ./contracts /ocean-contracts/contracts/
COPY ./hardhat.config* /ocean-contracts/
COPY ./package* /ocean-contracts/
COPY ./package.json /ocean-contracts/
COPY ./scripts /ocean-contracts/scripts/
COPY ./test /ocean-contracts/test/
WORKDIR /ocean-contracts
Expand Down
6 changes: 4 additions & 2 deletions addresses/address.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@
"ERC20Template": {
"1": "0x519d462294958A935D34351b3ad9F98cCAB0b7f8",
"2": "0x2bCa501a6f9FB8a96f1b7B09D4f74A32ACAa7584",
"3": "0xf00c16665b79F23c04e5c8652Fe9853046b987c8"
"3": "0xf00c16665b79F23c04e5c8652Fe9853046b987c8",
"4": "0x89b752C3e272feBA17B363EaaBFe0d653cF75bE7"
},
"ERC721Template": {
"1": "0x9Ab15cc945b2B58A51384539211dE8a88a1355E8"
Expand Down Expand Up @@ -305,7 +306,8 @@
"ERC20Template": {
"1": "0xDBDa486d8fE29F75e9Ca858F438b380Fc14b1232",
"2": "0xF6410bf5d773C7a41ebFf972f38e7463FA242477",
"3": "0x1B083D8584dd3e6Ff37d04a6e7e82b5F622f3985"
"3": "0x1B083D8584dd3e6Ff37d04a6e7e82b5F622f3985",
"4": "0x4dD281EB67DED07E76E413Df16176D66ae69e240"
},
"ERC721Template": {
"1": "0x69B6E54Ad2b3c2801d11d8Ad56ea1d892555b776"
Expand Down
105 changes: 105 additions & 0 deletions contracts/accesslists/AccessList.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Copyright BigchainDB GmbH and Ocean Protocol contributors
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
// Code is Apache-2.0 and docs are CC-BY-4.0

pragma solidity ^0.8.26;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

/**
* @title AccessList
*
* @dev AccessList is an soul bound ERC721 used to build access lists (allow or deny)
* Only owner can mint and also burn (ie: remove address from a list)
* Each token id has it's own metadata
*/

contract AccessList is Ownable, ERC721Enumerable,ERC721URIStorage {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;


event NewAccessList(
address indexed contractAddress,
address indexed owner
);
event AddressAdded(
address indexed wallet,
uint256 tokenId
);
event AddressRemoved(
uint256 tokenId
);

constructor(string memory _name, string memory _symbol)

Check notice

Code scanning / Slither

Local variable shadowing Low

Check notice

Code scanning / Slither

Local variable shadowing Low

ERC721(_name, _symbol) {
emit NewAccessList(address(this),_msgSender());
}

function tokenURI(uint256 tokenId)
public
view
override(ERC721, ERC721URIStorage)
returns (string memory)
{
return super.tokenURI(tokenId);
}
function supportsInterface(bytes4 interfaceId)
public
view
override( ERC721Enumerable,ERC721URIStorage)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId, uint256 batchSize)
internal
override(ERC721,ERC721Enumerable)
{
require(from == address(0) || to == address(0), "Token not transferable");
super._beforeTokenTransfer(from, to, tokenId, batchSize);
}

function _add(address user, string memory _tokenURI) private returns (uint256) {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
emit AddressAdded(user,newItemId);
_mint(user, newItemId);
_setTokenURI(newItemId, _tokenURI);
return newItemId;
}

function mint(address user, string memory _tokenURI) external onlyOwner returns (uint256) {

Check warning

Code scanning / Slither

Conformance to Solidity naming conventions Warning

Parameter AccessList.mint(address,string)._tokenURI is not in mixedCase
return(_add(user,_tokenURI));
}


/**
* @notice Batch Mint only for owner
*/
function batchMint(address[] memory user,string[] memory _tokenURI) external onlyOwner

Check warning

Code scanning / Slither

Conformance to Solidity naming conventions Warning

{
uint256 i;
require(user.length==_tokenURI.length);
for(i=0;i<user.length;i++){
_add(user[i],_tokenURI[i]);
}
}

function burn(uint256 tokenId) public {
require(_msgSender() == super.owner() || _msgSender()==super._ownerOf(tokenId),"ERC721: Not owner");
emit AddressRemoved(tokenId);
_burn(tokenId);
}
// The following functions are overrides required by Solidity.
function _burn(uint256 tokenId) internal override(ERC721URIStorage,ERC721) {
super._burn(tokenId);
}


}
85 changes: 85 additions & 0 deletions contracts/rewards/Booster.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Copyright BigchainDB GmbH and Ocean Protocol contributors
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
// Code is Apache-2.0 and docs are CC-BY-4.0

pragma solidity ^0.8.26;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

/**
* @title Booster
*
* @dev Booster is an soul bound ERC721 used to calculate
* incentives boost rate for an address.
* Only owner can mint
*/

contract Booster is Ownable, ERC721Enumerable,ERC721URIStorage {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
uint256 public immutable boost;
constructor(string memory _name, string memory _symbol,uint256 _boost)

Check notice

Code scanning / Slither

Local variable shadowing Low

Check notice

Code scanning / Slither

Local variable shadowing Low

ERC721(_name, _symbol) {
boost=_boost;
}

function tokenURI(uint256 tokenId)
public
view
override(ERC721, ERC721URIStorage)
returns (string memory)
{
return super.tokenURI(tokenId);
}
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721Enumerable,ERC721URIStorage)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId, uint256 batchSize)
internal
override(ERC721,ERC721Enumerable)
{
require(from == address(0), "Token not transferable");
super._beforeTokenTransfer(from, to, tokenId, batchSize);
}

function _createBoost(address user, string memory _tokenURI) private returns (uint256) {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_mint(user, newItemId);
_setTokenURI(newItemId, _tokenURI);
return newItemId;
}

function createBoost(address user, string memory _tokenURI) external onlyOwner returns (uint256) {

Check warning

Code scanning / Slither

Conformance to Solidity naming conventions Warning

Parameter Booster.createBoost(address,string)._tokenURI is not in mixedCase
return(_createBoost(user,_tokenURI));
}


/**
* @notice Batch Mint only for owner
*/
function batchCreateBoosts(address[] memory user,string[] memory _tokenURI) external onlyOwner

Check warning

Code scanning / Slither

Conformance to Solidity naming conventions Warning

{
uint256 i;
require(user.length==_tokenURI.length);
for(i=0;i<user.length;i++){
_createBoost(user[i],_tokenURI[i]);
}
}

// The following functions are overrides required by Solidity.
function _burn(uint256 tokenId) internal override(ERC721URIStorage,ERC721) {
revert("Burning not allowed");
}

Check warning

Code scanning / Slither

Dead-code Warning

Booster._burn(uint256) is never used and should be removed


}
Loading
Loading