Skip to content
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

add accesslists contracts #868

Merged
merged 22 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
89 changes: 89 additions & 0 deletions contracts/accesslists/AccessList.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// 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;
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) {

}

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) {

Check notice

Code scanning / Slither

Local variable shadowing Low

_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_mint(user, newItemId);
_setTokenURI(newItemId, tokenURI);
return newItemId;
}

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

Check notice

Code scanning / Slither

Local variable shadowing Low

return(_add(user,tokenURI));
}


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

Check notice

Code scanning / Slither

Local variable shadowing Low

{
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");
_burn(tokenId);
}
// The following functions are overrides required by Solidity.
function _burn(uint256 tokenId) internal override(ERC721URIStorage,ERC721) {
super._burn(tokenId);
}


}
Loading
Loading