get things kinda working

master
lza_menace 2 years ago
parent 57d207bbce
commit 7987f80e15

@ -2,5 +2,11 @@
src = 'src'
out = 'out'
libs = ['lib']
gas_reports = ["SendIt"]
# See more config options https://github.com/foundry-rs/foundry/tree/master/config
[rpc_endpoints]
goerli = "${GOERLI_RPC_URL}"
local = "http://127.0.0.1:8545"
[etherscan]
goerli = { key = "${ETHERSCAN_API_KEY}" }

@ -0,0 +1,17 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "forge-std/Script.sol";
import "../src/NFT.sol";
contract MyScript is Script {
// function run() external {
// uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
// vm.startBroadcast(deployerPrivateKey);
// NFT nft = new NFT();
// vm.stopBroadcast();
// }
function run() public {
vm.broadcast();
}
}

@ -0,0 +1,22 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "solmate/tokens/ERC721.sol";
import "openzeppelin-contracts/utils/Strings.sol";
contract NFT is ERC721 {
uint256 public currentTokenId;
constructor() ERC721("NFT", "NFT") {}
function mint(address r, uint256 mintAmount) external {
for(uint256 i; i < mintAmount; i++) {
currentTokenId += 1;
_safeMint(r, currentTokenId);
}
}
function tokenURI(uint256 id) public view virtual override returns (string memory) {
return Strings.toString(id);
}
}

@ -39,11 +39,11 @@ contract SendIt {
) public {
if (isERC1155) {
require(ERC1155(contractAddress).balanceOf(msg.sender, tokenIndex) > 0, "Sender is not the token owner, cannot proceed with transfer.");
require(ERC1155(contractAddress).isApprovedForAll(msg.sender, address(this)), "Contract not approved to send token on Sender behalf.");
require(ERC1155(contractAddress).isApprovedForAll(msg.sender, address(this)), "Contract not approved to send tokens on Sender behalf.");
ERC1155(contractAddress).safeTransferFrom(msg.sender, recipient, tokenIndex, 1, bytes(""));
} else {
require(msg.sender == ERC721(contractAddress).ownerOf(tokenIndex), "Sender is not the token owner, cannot proceed with transfer.");
require(ERC721(contractAddress).getApproved(tokenIndex) == address(this), "Contract not approved to send token on Sender behalf.");
require(ERC721(contractAddress).isApprovedForAll(msg.sender, address(this)), "Contract not approved to send tokens on Sender behalf.");
ERC721(contractAddress).safeTransferFrom(msg.sender, recipient, tokenIndex);
}
emit TokenTransfer(contractAddress, tokenIndex, msg.sender, recipient);

@ -2,17 +2,43 @@
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
import "../src/SendIt.sol";
import {SendIt} from "../src/SendIt.sol";
import {NFT} from "../src/NFT.sol";
contract SendItTest is Test {
using stdStorage for StdStorage;
SendIt public sendit;
NFT public nft;
function setUp() public {
sendit = new SendIt();
nft = new NFT();
}
function testUpdateVault() public {
sendit.updateVault(address(3));
assertEq(sendit.addressVault(address(0)), address(3));
function testBulkTransferSucceeds() public {
uint256 amt = 10;
uint256[] memory tokenIndexes = new uint256[](amt);
address[] memory recipients = new address[](amt);
for (uint256 i; i < amt; i++) {
tokenIndexes[i] = i + 1;
recipients[i] = address(1);
}
vm.startPrank(address(5));
nft.mint(address(5), amt);
nft.setApprovalForAll(address(sendit), true);
sendit.contractBulkTransfer(
address(nft),
tokenIndexes,
recipients,
false
);
vm.stopPrank();
}
// function testUpdateVault() public {
// sendit.updateVault(address(3));
// console.log(address(sendit));
// // console.log(sendit);
// assertEq(sendit.addressVault(address(2)), address(0));
// }
}

Loading…
Cancel
Save