Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ jobs:
- name: Install node dependencies
run: yarn --frozen-lockfile

#todo: forge build --sizes
- name: Run Forge build
run: |
forge --version
forge build --sizes
forge build
id: build

- name: Run Forge tests
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ VDAO_TOKEN_ADDRESS=0x19A3036b828bffB5E14da2659E950E76f8e6BAA2

---

### upgrading to Tokenizer 1.3
### upgrading to Tokenizer 1.4

forge script --private-key=$PRIVATE_KEY --rpc-url=$RPC_URL script/prod/RolloutTokenizerV13.s.sol --broadcast
forge script --private-key=$PRIVATE_KEY --rpc-url=$RPC_URL script/prod/RolloutTokenizerV14.s.sol --broadcast

// 0xTokenizer 0xNewImpl 0xNewTokenImpl
cast send --rpc-url=$RPC_URL --private-key=$PRIVATE_KEY 0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e "upgradeToAndCall(address,bytes)" 0x70e0bA845a1A0F2DA3359C97E0285013525FFC49 0x84646c1f000000000000000000000000998abeb3e57409262ae5b751f60747921b33613e
// 0xTokenizer (address, bytes)(0xNewImpl, 0xNewWrappedIPTokenImpl 0xNewIPTokenImpl)
cast send --rpc-url=$RPC_URL --private-key=$PRIVATE_KEY 0x58EB89C69CB389DBef0c130C6296ee271b82f436 "upgradeToAndCall(address,bytes)" 0x34A1D3fff3958843C43aD80F30b94c510645C316 0x8b3d19bb0000000000000000000000007fa9385be102ac3eac297483dd6233d62b3e14960000000000000000000000005b73c5498c1e3b4dba84de0f1833c4a029d90519

### Timelocked Tokens

Expand Down
38 changes: 38 additions & 0 deletions foundry.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"lib/ERC721B": {
"branch": {
"name": "0.2.1",
"rev": "254530019373cfb2aa3cb6e975768857f829823d"
}
},
"lib/forge-std": {
"rev": "87a2a0afc5fafd6297538a45a52ac19e71a84562"
},
"lib/openzeppelin-contracts": {
"branch": {
"name": "release-v4.8",
"rev": "281550b71c3df9a83e6b80ceefc700852c287570"
}
},
"lib/openzeppelin-contracts-upgradeable": {
"rev": "43b82754979c35abcd3ccad7b795754146c62ade"
},
"lib/safe-contracts": {
"branch": {
"name": "v1.4.0",
"rev": "e870f514ad34cd9654c72174d6d4a839e3c6639f"
}
},
"lib/solidity-base64": {
"rev": "537095980643f59e9e00b7b76d341bb9da438eaf"
},
"lib/solmate": {
"branch": {
"name": "v7",
"rev": "ed67feda67b24fdeff8ad1032360f0ee6047ba0a"
}
},
"lib/token-vesting-contract": {
"rev": "b1f3e05bb6f07bec70d2b7b588d622c06f70ae39"
}
}
2 changes: 2 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ out = 'out'
libs = ['lib']
test = 'test'
solc_version = "0.8.18"
optimizer = true
optimizer_runs = 200
gas_reports = [
"IPNFT",
"IPNFTV2",
Expand Down
5 changes: 3 additions & 2 deletions script/dev/Ipnft.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ contract FixtureIpnft is CommonScript {
function run() public {
prepareAddresses();

uint256 tokenId = mintIpnft(bob, bob);
uint256 token1Id = mintIpnft(bob, bob);
uint256 token2Id = mintIpnft(bob, bob);

dealERC20(bob, 1000 ether, usdc);
dealERC20(alice, 1000 ether, usdc);

uint256 listingId = createListing(bob, tokenId, 1 ether, usdc);
uint256 listingId = createListing(bob, token1Id, 1 ether, usdc);
//we're *NOT* accepting the listing here because of inconsistent listing ids on anvil
//execute ApproveAndBuy.s.sol if you want to do that.
console.log("listing id %s", listingId);
Expand Down
100 changes: 0 additions & 100 deletions script/dev/Synthesizer.s.sol

This file was deleted.

35 changes: 28 additions & 7 deletions script/dev/Tokenizer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import "forge-std/Script.sol";
import "forge-std/console.sol";
import { IPNFT } from "../../src/IPNFT.sol";
import { Tokenizer } from "../../src/Tokenizer.sol";
import { Metadata, IPToken } from "../../src/IPToken.sol";
import { IIPToken } from "../../src/IIPToken.sol";
import { Metadata } from "../../src/IIPToken.sol";
import { IPToken } from "../../src/IPToken.sol";
import { WrappedIPToken } from "../../src/WrappedIPToken.sol";
import { FakeERC20 } from "../../src/helpers/FakeERC20.sol";

import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import { IPermissioner, TermsAcceptedPermissioner } from "../../src/Permissioner.sol";
import { CommonScript } from "./Common.sol";
Expand All @@ -23,9 +28,13 @@ contract DeployTokenizer is CommonScript {
IPToken initialIpTokenImplementation = new IPToken();
tokenizer.setIPTokenImplementation(initialIpTokenImplementation);

WrappedIPToken initialWrappedIpTokenImplementation = new WrappedIPToken();
tokenizer.setWrappedIPTokenImplementation(initialWrappedIpTokenImplementation);

vm.stopBroadcast();
console.log("TOKENIZER_ADDRESS=%s", address(tokenizer));
console.log("iptoken implementation=%s", address(initialIpTokenImplementation));
console.log("wrapped iptoken implementation=%s", address(initialWrappedIpTokenImplementation));
}
}

Expand All @@ -45,18 +54,30 @@ contract FixtureTokenizer is CommonScript {
permissioner = TermsAcceptedPermissioner(vm.envAddress("TERMS_ACCEPTED_PERMISSIONER_ADDRESS"));
}

function prepareAndSignTerms(uint256 tokenId) internal returns (bytes memory) {
string memory terms = permissioner.specificTermsV1(Metadata(tokenId, bob, "bafkreigk5dvqblnkdniges6ft5kmuly47ebw4vho6siikzmkaovq6sjstq"));
(uint8 v, bytes32 r, bytes32 s) = vm.sign(bobPk, ECDSA.toEthSignedMessageHash(abi.encodePacked(terms)));
return abi.encodePacked(r, s, v);
}

function run() public {
prepareAddresses();

string memory terms = permissioner.specificTermsV1(Metadata(1, bob, "bafkreigk5dvqblnkdniges6ft5kmuly47ebw4vho6siikzmkaovq6sjstq"));

vm.startBroadcast(bob);
(uint8 v, bytes32 r, bytes32 s) = vm.sign(bobPk, ECDSA.toEthSignedMessageHash(abi.encodePacked(terms)));
bytes memory signedTerms = abi.encodePacked(r, s, v);
IPToken tokenContract =
tokenizer.tokenizeIpnft(1, 1_000_000 ether, "MOLE", "bafkreigk5dvqblnkdniges6ft5kmuly47ebw4vho6siikzmkaovq6sjstq", signedTerms);
bytes memory signedToken1Terms = prepareAndSignTerms(1);
FakeERC20 usdc = FakeERC20(vm.envAddress("USDC_ADDRESS"));
// Attach an already existing token as an IPT
IIPToken token1Contract = tokenizer.attachIpt(1, "bafkreigk5dvqblnkdniges6ft5kmuly47ebw4vho6siikzmkaovq6sjstq", signedToken1Terms, usdc);

bytes memory signedToken2Terms = prepareAndSignTerms(2);

// Mmint a new IPT
IPToken token2Contract =
tokenizer.tokenizeIpnft(2, 1_000_000 ether, "MOLE", "bafkreigk5dvqblnkdniges6ft5kmuly47ebw4vho6siikzmkaovq6sjstq", signedToken2Terms);
vm.stopBroadcast();

console.log("IPTS_ADDRESS=%s", address(tokenContract));
console.log("ATTACHED_IPT_ADDRESS=%s", address(token1Contract));
console.log("IPT_ADDRESS=%s", address(token2Contract));
}
}
24 changes: 0 additions & 24 deletions script/prod/RolloutTokenizerV13.s.sol

This file was deleted.

31 changes: 31 additions & 0 deletions script/prod/RolloutTokenizerV14.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

import "forge-std/Script.sol";
import { Tokenizer } from "../../src/Tokenizer.sol";
import { IPToken } from "../../src/IPToken.sol";
import { WrappedIPToken } from "../../src/WrappedIPToken.sol";
import { console } from "forge-std/console.sol";

contract RolloutTokenizerV14 is Script {
function run() public {
vm.startBroadcast();

// Deploy new implementations
IPToken ipTokenImplementation = new IPToken();
WrappedIPToken wrappedIpTokenImplementation = new WrappedIPToken();
Tokenizer newTokenizerImplementation = new Tokenizer();

// Prepare upgrade call data using reinit function
bytes memory upgradeCallData =
abi.encodeWithSelector(Tokenizer.reinit.selector, address(wrappedIpTokenImplementation), address(ipTokenImplementation));

console.log("IPTOKENIMPLEMENTATION=%s", address(ipTokenImplementation));
console.log("WRAPPEDTOKENIMPLEMENTATION=%s", address(wrappedIpTokenImplementation));
console.log("NEWTOKENIZER=%s", address(newTokenizerImplementation));
console.log("UpgradeCallData:");
console.logBytes(upgradeCallData);

vm.stopBroadcast();
}
}
21 changes: 21 additions & 0 deletions src/IIPToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8;

struct Metadata {
uint256 ipnftId;
address originalOwner;
string agreementCid;
}

interface IIPToken {
/// @notice the amount of tokens that ever have been issued (not necessarily == supply)
function totalIssued() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function metadata() external view returns (Metadata memory);
function issue(address, uint256) external;
function cap() external;
function uri() external view returns (string memory);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
Loading