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

Feat/struct pixel #24

Open
wants to merge 18 commits into
base: feat/webservice-land
Choose a base branch
from
Open

Conversation

joshualyguessennd
Copy link
Collaborator

No description provided.

contracts/src/LandNFT.sol Fixed Show fixed Hide fixed
Comment on lines 142 to 160
function sellLandToBank(uint256[] memory _tokenIds) external nonReentrant {
uint256 numberOfPx = _tokenIds.length;
uint256 amountToSend;
uint256 i;
unchecked {
amountToSend =
ILandNFT(landNft).totalTileNum() *
ILandNFT(landNft).getLength(_tokenId);
amountToSend = getPrice() * numberOfPx;
}
IERC20(RIO_TOKEN).transfer(
_seller,
(IERC20(RIO_TOKEN).balanceOf(address(this)) / amountToSend)
);

for (i; i < numberOfPx; i++) {
ILandNFT(landNft).transferFrom(
msg.sender,
address(this),
_tokenIds[i]
);
timelapse[_tokenIds[i]] = block.timestamp;
}
IERC20(RIO_TOKEN).transfer(msg.sender, amountToSend);
emit LandSold(msg.sender, _tokenIds, amountToSend, block.timestamp);
}

Check notice

Code scanning / Slither

Calls inside a loop

LandBank.sellLandToBank(uint256[]) (contracts/src/LandBank.sol#142-160) has external calls inside a loop: ILandNFT(landNft).transferFrom(msg.sender,address(this),_tokenIds[i]) (contracts/src/LandBank.sol#151-155)
Comment on lines 142 to 160
function sellLandToBank(uint256[] memory _tokenIds) external nonReentrant {
uint256 numberOfPx = _tokenIds.length;
uint256 amountToSend;
uint256 i;
unchecked {
amountToSend =
ILandNFT(landNft).totalTileNum() *
ILandNFT(landNft).getLength(_tokenId);
amountToSend = getPrice() * numberOfPx;
}
IERC20(RIO_TOKEN).transfer(
_seller,
(IERC20(RIO_TOKEN).balanceOf(address(this)) / amountToSend)
);

for (i; i < numberOfPx; i++) {
ILandNFT(landNft).transferFrom(
msg.sender,
address(this),
_tokenIds[i]
);
timelapse[_tokenIds[i]] = block.timestamp;
}
IERC20(RIO_TOKEN).transfer(msg.sender, amountToSend);
emit LandSold(msg.sender, _tokenIds, amountToSend, block.timestamp);
}

Check notice

Code scanning / Slither

Reentrancy vulnerabilities

Reentrancy in LandBank.sellLandToBank(uint256[]) (contracts/src/LandBank.sol#142-160): External calls: - amountToSend = getPrice() * numberOfPx (contracts/src/LandBank.sol#147) - PIXEL_SUPPLY = ILandNFT(landNft).totalTileNum() (contracts/src/LandBank.sol#186) - ILandNFT(landNft).transferFrom(msg.sender,address(this),_tokenIds[i]) (contracts/src/LandBank.sol#151-155) State variables written after the call(s): - timelapse[_tokenIds[i]] = block.timestamp (contracts/src/LandBank.sol#156)
Comment on lines 142 to 160
function sellLandToBank(uint256[] memory _tokenIds) external nonReentrant {
uint256 numberOfPx = _tokenIds.length;
uint256 amountToSend;
uint256 i;
unchecked {
amountToSend =
ILandNFT(landNft).totalTileNum() *
ILandNFT(landNft).getLength(_tokenId);
amountToSend = getPrice() * numberOfPx;
}
IERC20(RIO_TOKEN).transfer(
_seller,
(IERC20(RIO_TOKEN).balanceOf(address(this)) / amountToSend)
);

for (i; i < numberOfPx; i++) {
ILandNFT(landNft).transferFrom(
msg.sender,
address(this),
_tokenIds[i]
);
timelapse[_tokenIds[i]] = block.timestamp;
}
IERC20(RIO_TOKEN).transfer(msg.sender, amountToSend);
emit LandSold(msg.sender, _tokenIds, amountToSend, block.timestamp);
}

Check notice

Code scanning / Slither

Reentrancy vulnerabilities

Reentrancy in LandBank.sellLandToBank(uint256[]) (contracts/src/LandBank.sol#142-160): External calls: - amountToSend = getPrice() * numberOfPx (contracts/src/LandBank.sol#147) - PIXEL_SUPPLY = ILandNFT(landNft).totalTileNum() (contracts/src/LandBank.sol#186) - IERC20(RIO_TOKEN).transfer(msg.sender,amountToSend) (contracts/src/LandBank.sol#158) Event emitted after the call(s): - LandSold(msg.sender,_tokenIds,amountToSend,block.timestamp) (contracts/src/LandBank.sol#159)
contracts/src/LandNFT.sol Fixed Show fixed Hide fixed
contracts/src/LandBank.sol Fixed Show fixed Hide fixed
contracts/src/LandBank.sol Fixed Show fixed Hide fixed
contracts/src/LandBank.sol Fixed Show fixed Hide fixed
* api balanceOf, owner

* owner

* service owner

* update cargo

* fix url

* totalsupply

* init mint

* mint tx issue

* mint tx issue

* region struct

* feat: adds mint route

* connect wallet

* fix: provider instatition

* feat: Json field

* approve logic

* sign tx

* tx request

* send_tx option

* chore: signer middleware

* chore: mint

* fix: unwrap over ?

* fix: unwrap over ?

* mint

* error some string

* migrate to service

* fix: approval call

* await approval

* chore: refactor for tests

* set bank, dev

* feat: adds docker build

* chore: fix env var

* test balance

* provider refactoring

* fix dotenv

* comment mint debug

* appstate

* refactor: split provider out

* Docker service

* fix: lint

* clippy fix

* cargo fmt

* update

* check env

* delete foundry step

* slither ci

* exclude lib

* exclude lib

* exclude lib

* anvil test

* reduce time

* feat: deploymnent script

* feat: test update, script

* Feat/deployments testnet (#27)

* feat: init landbank logic

* feat: function buyFromBank

* feat: test buy from bank

* add getTokenPrice

* feat: update getTokenPrice

* feat: landBank contract + test

* add select struct logic

* feat: remove unnecessary comment

* deployment

* erros packed

* slither redondant fix

* remove unused

* import format

* remove double toml

* toml file

* delete unused toml

* fix binding

* feat: fix binding compile process

* update src

* path landbank

* path tests

* path nft test

* remove working directory

* remove absolue path

* fix case-sensitive

* bindings

* add package

* bindings

Co-authored-by: joshualyguessennd <joshualyguessennd@icloud.com>
Co-authored-by: joshualyguessennd <75019812+joshualyguessennd@users.noreply.github.com>
mapping(uint256 => ILandNFT.Pixel) pixelsId;
mapping(uint256 => ILandNFT.Pixel) private pixelsId;
mapping(bytes32 => bool) private isSpecialArea;
mapping(bytes32 => bool) private areaClaimed;

Check failure

Code scanning / Slither

Uninitialized state variables

LandNFT.areaClaimed (contracts/src/LandNFT.sol#57) is never initialized. It is used in: - LandNFT.claimSpecialArea(bytes32[],ILandNFT.Pixel) (contracts/src/LandNFT.sol#342-359)
contracts/src/LandNFT.sol Fixed Show fixed Hide fixed
contracts/src/LandNFT.sol Fixed Show fixed Hide fixed
contracts/src/LandNFT.sol Fixed Show fixed Hide fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants