Skip to content

Commit

Permalink
Merge pull request #871 from oceanprotocol/release/v2.1.0
Browse files Browse the repository at this point in the history
Release/v2.1.0
  • Loading branch information
alexcos20 authored Aug 30, 2024
2 parents af2f1e6 + 0b87627 commit 3fe47d9
Show file tree
Hide file tree
Showing 19 changed files with 13,329 additions and 22,331 deletions.
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)
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) {
return(_add(user,_tokenURI));
}


/**
* @notice Batch Mint only for owner
*/
function batchMint(address[] memory user,string[] memory _tokenURI) external onlyOwner
{
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)
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) {
return(_createBoost(user,_tokenURI));
}


/**
* @notice Batch Mint only for owner
*/
function batchCreateBoosts(address[] memory user,string[] memory _tokenURI) external onlyOwner
{
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");
}


}
Loading

0 comments on commit 3fe47d9

Please sign in to comment.