Skip to content

Commit

Permalink
creating ipnfts through tokenizer in permissioner tests
Browse files Browse the repository at this point in the history
  • Loading branch information
polus-arcticus committed Jan 17, 2024
1 parent 9713cd6 commit 9370b75
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 9 deletions.
43 changes: 38 additions & 5 deletions test/CrowdSalePermissioned.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,39 @@ import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

import { IPToken, Metadata } from "../src/IPToken.sol";
import { CrowdSale, Sale, SaleInfo, SaleState, BadDecimals } from "../src/crowdsale/CrowdSale.sol";
import { StakedLockingCrowdSale, BadPrice } from "../src/crowdsale/StakedLockingCrowdSale.sol";
import { IPermissioner, TermsAcceptedPermissioner, InvalidSignature } from "../src/Permissioner.sol";

import { IPermissioner, TermsAcceptedPermissioner, InvalidSignature, BlindPermissioner } from "../src/Permissioner.sol";
import { MustOwnIpnft, AlreadyTokenized, Tokenizer, ZeroAddress } from "../src/Tokenizer.sol";
import { IPNFT } from "../src/IPNFT.sol";
import { TokenVesting } from "@moleculeprotocol/token-vesting/TokenVesting.sol";
import { TimelockedToken } from "../src/TimelockedToken.sol";
import { FakeERC20 } from "../src/helpers/FakeERC20.sol";
//import { BioPriceFeed, IPriceFeedConsumer } from "../src/BioPriceFeed.sol";
import { CrowdSaleHelpers } from "./helpers/CrowdSaleHelpers.sol";
import { AcceptAllAuthorizer } from "./helpers/AcceptAllAuthorizer.sol";

contract CrowdSalePermissionedTest is Test {
address deployer = makeAddr("chucknorris");
address emitter = makeAddr("emitter");
address anyone = makeAddr("anyone");
address bidder;
uint256 bidderPk;

address anyone = makeAddr("anyone");
uint256 MINTING_FEE = 0.001 ether;
string DEFAULT_SYMBOL = "IPT-0001";
string ipfsUri = "ipfs://bafkreiankqd3jvpzso6khstnaoxovtyezyatxdy7t2qzjoolqhltmasqki";
string agreementCid = "bafkreigk5dvqblnkdniges6ft5kmuly47ebw4vho6siikzmkaovq6sjstq";

IPNFT internal ipnft;
Tokenizer internal tokenizer;
IPToken internal auctionToken;
FakeERC20 internal biddingToken;
FakeERC20 internal daoToken;
IPermissioner internal blindPermissioner;

//this typically is the DAO's general vesting contract
TokenVesting internal vestedDao;
Expand All @@ -43,13 +53,36 @@ contract CrowdSalePermissionedTest is Test {
(bidder, bidderPk) = makeAddrAndKey("bidder");
vm.startPrank(deployer);

auctionToken = new IPToken();
auctionToken.initialize("IPTOKENS", "IPT-0001", Metadata(42, msg.sender, "ipfs://abcde"));
ipnft = IPNFT(address(new ERC1967Proxy(address(new IPNFT()), "")));
ipnft.initialize();
ipnft.setAuthorizer(new AcceptAllAuthorizer());

tokenizer = Tokenizer(address(new ERC1967Proxy(address(new Tokenizer()), "")));

blindPermissioner = new BlindPermissioner();
tokenizer.initialize(ipnft, blindPermissioner);
tokenizer.setIPTokenImplementation(new IPToken());

biddingToken = new FakeERC20("USD token", "USDC");
daoToken = new FakeERC20("DAO token", "DAO");

vm.stopPrank();

vm.deal(emitter, MINTING_FEE);

vm.startPrank(emitter);

crowdSale = new StakedLockingCrowdSale();

uint256 reservationId = ipnft.reserve();
ipnft.mintReservation{ value: MINTING_FEE }(emitter, reservationId, ipfsUri, DEFAULT_SYMBOL, "");


auctionToken = tokenizer.tokenizeIpnft(1, 100_000, "IPT", agreementCid, "");

//auctionToken = new IPToken();
//auctionToken.initialize("IPTOKENS", "IPT-0001", Metadata(42, msg.sender, "ipfs://abcde"));

auctionToken.issue(emitter, 500_000 ether);

vestedDao = new TokenVesting(
Expand Down
44 changes: 40 additions & 4 deletions test/Permissioner.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
pragma solidity ^0.8.18;

import "forge-std/Test.sol";
import { InvalidSignature, IPermissioner, TermsAcceptedPermissioner } from "../src/Permissioner.sol";
import { InvalidSignature, IPermissioner, TermsAcceptedPermissioner, BlindPermissioner } from "../src/Permissioner.sol";
import { IPToken, Metadata } from "../src/IPToken.sol";
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

import { AcceptAllAuthorizer } from "./helpers/AcceptAllAuthorizer.sol";
import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import { IPNFT } from "../src/IPNFT.sol";
import { Safe } from "safe-global/safe-contracts/Safe.sol";
import { SafeProxyFactory } from "safe-global/safe-contracts/proxies/SafeProxyFactory.sol";
import { Enum } from "safe-global/safe-contracts/common/Enum.sol";
import { MustOwnIpnft, AlreadyTokenized, Tokenizer, ZeroAddress } from "../src/Tokenizer.sol";

import "./helpers/MakeGnosisWallet.sol";

Expand All @@ -22,19 +26,51 @@ contract PermissionerTest is Test {
address bob = makeAddr("bob");
uint256 bobPk;

string ipfsUri = "ipfs://bafkreiankqd3jvpzso6khstnaoxovtyezyatxdy7t2qzjoolqhltmasqki";
string agreementCid = "bafkreigk5dvqblnkdniges6ft5kmuly47ebw4vho6siikzmkaovq6sjstq";
uint256 MINTING_FEE = 0.001 ether;
string DEFAULT_SYMBOL = "IPT-0001";

IPNFT internal ipnft;
Tokenizer internal tokenizer;
IPToken ipToken;
TermsAcceptedPermissioner internal permissioner;

function setUp() public {

(alice, alicePk) = makeAddrAndKey("alice");
(bob, bobPk) = makeAddrAndKey("bob");
vm.startPrank(deployer);

ipnft = IPNFT(address(new ERC1967Proxy(address(new IPNFT()), "")));
ipnft.initialize();
ipnft.setAuthorizer(new AcceptAllAuthorizer());

permissioner = new TermsAcceptedPermissioner();

ipToken = new IPToken();
Metadata memory md = Metadata(1, originalOwner, "abcde");
ipToken.initialize("foo", "BAR", md);
tokenizer = Tokenizer(address(new ERC1967Proxy(address(new Tokenizer()), "")));

BlindPermissioner blindPermissioner = new BlindPermissioner();
tokenizer.initialize(ipnft, blindPermissioner);
tokenizer.setIPTokenImplementation(new IPToken());

//ipToken = new IPToken();
//Metadata memory md = Metadata(1, originalOwner, "abcde");
//ipToken.initialize("foo", "BAR", md);

vm.stopPrank();

vm.deal(originalOwner, MINTING_FEE);

vm.startPrank(originalOwner);

uint256 reservationId = ipnft.reserve();
ipnft.mintReservation{ value: MINTING_FEE }(originalOwner, reservationId, ipfsUri, DEFAULT_SYMBOL, "");

ipToken = tokenizer.tokenizeIpnft(1, 100_000, "IPT", agreementCid, "");
vm.stopPrank();
vm.startPrank(deployer);
tokenizer.reinit(permissioner);
vm.stopPrank();
}

Expand Down

0 comments on commit 9370b75

Please sign in to comment.