Skip to content

Commit

Permalink
fix up nft constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdavinchee committed Jan 16, 2024
1 parent 1944426 commit f229b9c
Show file tree
Hide file tree
Showing 16 changed files with 157 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.19;
import { IERC721Metadata } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import { IPoolAdminNFT } from "../../interfaces/agreements/gdav1/IPoolAdminNFT.sol";
import { PoolNFTBase } from "./PoolNFTBase.sol";
import { ISuperfluid } from "../../interfaces/superfluid/ISuperfluid.sol";
import { IGeneralDistributionAgreementV1, ISuperfluid } from "../../interfaces/superfluid/ISuperfluid.sol";
import { ISuperfluidPool } from "../../interfaces/agreements/gdav1/ISuperfluidPool.sol";
import { ISuperfluidToken } from "../../interfaces/superfluid/ISuperfluidToken.sol";

Expand All @@ -22,7 +22,7 @@ contract PoolAdminNFT is PoolNFTBase, IPoolAdminNFT {
/// @dev The token id is uint256(keccak256(abi.encode(pool, admin)))
mapping(uint256 => PoolAdminNFTData) internal _poolAdminDataByTokenId;

constructor(ISuperfluid host) PoolNFTBase(host) { }
constructor(ISuperfluid host, IGeneralDistributionAgreementV1 gdaV1) PoolNFTBase(host, gdaV1) { }

// note that this is used so we don't upgrade to wrong logic contract
function proxiableUUID() public pure override returns (bytes32) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.19;
import { IERC721Metadata } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import { IPoolMemberNFT } from "../../interfaces/agreements/gdav1/IPoolMemberNFT.sol";
import { PoolNFTBase } from "./PoolNFTBase.sol";
import { ISuperfluid } from "../../interfaces/superfluid/ISuperfluid.sol";
import { IGeneralDistributionAgreementV1, ISuperfluid } from "../../interfaces/superfluid/ISuperfluid.sol";
import { ISuperfluidPool } from "../../interfaces/agreements/gdav1/ISuperfluidPool.sol";
import { ISuperfluidToken } from "../../interfaces/superfluid/ISuperfluidToken.sol";

Expand All @@ -22,7 +22,7 @@ contract PoolMemberNFT is PoolNFTBase, IPoolMemberNFT {
/// @dev The token id is uint256(keccak256(abi.encode(pool, member)))
mapping(uint256 => PoolMemberNFTData) internal _poolMemberDataByTokenId;

constructor(ISuperfluid host) PoolNFTBase(host) { }
constructor(ISuperfluid host, IGeneralDistributionAgreementV1 gdaV1) PoolNFTBase(host, gdaV1) { }

// note that this is used so we don't upgrade to wrong logic contract
function proxiableUUID() public pure override returns (bytes32) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ pragma solidity 0.8.19;
// solhint-disable-next-line no-unused-import
import { IERC165, IERC721, IERC721Metadata } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import { UUPSProxiable } from "../../upgradability/UUPSProxiable.sol";
import { ISuperfluid } from "../../interfaces/superfluid/ISuperfluid.sol";
import { IGeneralDistributionAgreementV1, ISuperfluid } from "../../interfaces/superfluid/ISuperfluid.sol";
import { ISuperTokenFactory } from "../../interfaces/superfluid/ISuperTokenFactory.sol";
import { IPoolNFTBase } from "../../interfaces/agreements/gdav1/IPoolNFTBase.sol";
import { IGeneralDistributionAgreementV1 } from "../../interfaces/agreements/gdav1/IGeneralDistributionAgreementV1.sol";

abstract contract PoolNFTBase is UUPSProxiable, IPoolNFTBase {
string public constant DEFAULT_BASE_URI = "https://nft.superfluid.finance/pool/v2/getmeta";
Expand Down Expand Up @@ -68,15 +67,9 @@ abstract contract PoolNFTBase is UUPSProxiable, IPoolNFTBase {
uint256 private _reserve20;
uint256 internal _reserve21;

constructor(ISuperfluid host) {
constructor(ISuperfluid host, IGeneralDistributionAgreementV1 gdaV1) {
HOST = host;
GENERAL_DISTRIBUTION_AGREEMENT_V1 = IGeneralDistributionAgreementV1(
address(
ISuperfluid(host).getAgreementClass(
keccak256("org.superfluid-finance.agreements.GeneralDistributionAgreement.v1")
)
)
);
GENERAL_DISTRIBUTION_AGREEMENT_V1 = gdaV1;
}

function initialize(string memory nftName, string memory nftSymbol)
Expand Down
25 changes: 20 additions & 5 deletions packages/ethereum-contracts/contracts/mocks/CFAv1NFTMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
pragma solidity 0.8.19;

import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { ISuperfluid, IConstantInflowNFT, IConstantOutflowNFT } from "../interfaces/superfluid/ISuperfluid.sol";
import {
IConstantFlowAgreementV1,
IGeneralDistributionAgreementV1,
ISuperfluid,
IConstantInflowNFT,
IConstantOutflowNFT
} from "../interfaces/superfluid/ISuperfluid.sol";
import { ConstantOutflowNFT } from "../superfluid/ConstantOutflowNFT.sol";
import { ConstantInflowNFT } from "../superfluid/ConstantInflowNFT.sol";
import { FlowNFTBase } from "../superfluid/FlowNFTBase.sol";
Expand All @@ -17,7 +23,9 @@ contract FlowNFTBaseMock is FlowNFTBase {

mapping(uint256 => FlowNFTData) internal _flowDataByTokenId;

constructor(ISuperfluid host) FlowNFTBase(host) { }
constructor(ISuperfluid host, IConstantFlowAgreementV1 cfaV1, IGeneralDistributionAgreementV1 gdaV1)
FlowNFTBase(host, cfaV1, gdaV1)
{ }

function proxiableUUID() public pure override returns (bytes32) {
return keccak256("org.superfluid-finance.contracts.FlowNFTBaseMock.implementation");
Expand Down Expand Up @@ -57,7 +65,12 @@ contract FlowNFTBaseMock is FlowNFTBase {
}

contract ConstantOutflowNFTMock is ConstantOutflowNFT {
constructor(ISuperfluid host, IConstantInflowNFT constantInflowNFT) ConstantOutflowNFT(host, constantInflowNFT) { }
constructor(
ISuperfluid host,
IConstantFlowAgreementV1 cfaV1,
IGeneralDistributionAgreementV1 gdaV1,
IConstantInflowNFT constantInflowNFT
) ConstantOutflowNFT(host, cfaV1, gdaV1, constantInflowNFT) { }

/// @dev a mock mint function that exposes the internal _mint function
function mockMint(address _superToken, address _to, address _flowReceiver, uint256 _newTokenId) public {
Expand All @@ -83,8 +96,10 @@ contract ConstantOutflowNFTMock is ConstantOutflowNFT {
contract ConstantInflowNFTMock is ConstantInflowNFT {
constructor(
ISuperfluid host,
IConstantFlowAgreementV1 cfaV1,
IGeneralDistributionAgreementV1 gdaV1,
IConstantOutflowNFT constantOutflowNFT
) ConstantInflowNFT(host, constantOutflowNFT) { }
) ConstantInflowNFT(host, cfaV1, gdaV1, constantOutflowNFT) { }

/// @dev a mock mint function to emit the mint Transfer event
function mockMint(address _to, uint256 _newTokenId) public {
Expand All @@ -105,4 +120,4 @@ contract ConstantInflowNFTMock is ConstantInflowNFT {
function mockGetApproved(uint256 _tokenId) public view returns (address) {
return _tokenApprovals[_tokenId];
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: AGPLv3
pragma solidity 0.8.19;

import { ISuperfluid } from "../interfaces/superfluid/ISuperfluid.sol";
import { IConstantFlowAgreementV1, IGeneralDistributionAgreementV1, ISuperfluid } from "../interfaces/superfluid/ISuperfluid.sol";
import { ConstantInflowNFT, IConstantInflowNFT } from "../superfluid/ConstantInflowNFT.sol";
import { ConstantOutflowNFT, IConstantOutflowNFT } from "../superfluid/ConstantOutflowNFT.sol";
import { FlowNFTBase } from "../superfluid/FlowNFTBase.sol";
Expand All @@ -16,9 +16,10 @@ import { IStorageLayoutBase } from "./IStorageLayoutBase.sol";
/// @notice A mock FlowNFTBase contract for testing storage layout.
/// @dev This contract *MUST* have the same storage layout as FlowNFTBase.sol
contract FlowNFTBaseStorageLayoutMock is FlowNFTBase, IStorageLayoutBase {
constructor(
ISuperfluid host
) FlowNFTBase(host) {}

constructor(ISuperfluid host, IConstantFlowAgreementV1 cfaV1, IGeneralDistributionAgreementV1 gdaV1)
FlowNFTBase(host, cfaV1, gdaV1)
{ }

/// @notice Validates storage layout
/// @dev This function is used by all the FlowNFTBase mock contracts to validate the layout
Expand Down Expand Up @@ -94,8 +95,10 @@ contract ConstantInflowNFTStorageLayoutMock is ConstantInflowNFT, IStorageLayout

constructor(
ISuperfluid host,
IConstantFlowAgreementV1 cfaV1,
IGeneralDistributionAgreementV1 gdaV1,
IConstantOutflowNFT constantOutflowNFT
) ConstantInflowNFT(host, constantOutflowNFT) {}
) ConstantInflowNFT(host, cfaV1, gdaV1, constantOutflowNFT) { }

/// @notice Validates storage layout
/// @dev This function is used to validate storage layout of ConstantInflowNFT
Expand Down Expand Up @@ -145,8 +148,10 @@ contract ConstantOutflowNFTStorageLayoutMock is ConstantOutflowNFT, IStorageLayo

constructor(
ISuperfluid host,
IConstantFlowAgreementV1 cfaV1,
IGeneralDistributionAgreementV1 gdaV1,
IConstantInflowNFT constantInflowNFT
) ConstantOutflowNFT(host, constantInflowNFT) {}
) ConstantOutflowNFT(host, cfaV1, gdaV1, constantInflowNFT) { }

/// @notice Validates storage layout
/// @dev This function is used to validate storage layout of ConstantOutflowNFT
Expand Down
8 changes: 4 additions & 4 deletions packages/ethereum-contracts/contracts/mocks/PoolNFTMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity 0.8.19;

import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { ISuperfluid } from "../interfaces/superfluid/ISuperfluid.sol";
import { IGeneralDistributionAgreementV1, ISuperfluid } from "../interfaces/superfluid/ISuperfluid.sol";
import { PoolAdminNFT } from "../agreements/gdav1/PoolAdminNFT.sol";
import { PoolMemberNFT } from "../agreements/gdav1/PoolMemberNFT.sol";
import { PoolNFTBase } from "../agreements/gdav1/PoolNFTBase.sol";
Expand All @@ -13,7 +13,7 @@ contract PoolNFTBaseMock is PoolNFTBase {

mapping(uint256 => address) private _owners;

constructor(ISuperfluid host) PoolNFTBase(host) { }
constructor(ISuperfluid host, IGeneralDistributionAgreementV1 gdaV1) PoolNFTBase(host, gdaV1) { }

function proxiableUUID() public pure override returns (bytes32) {
return keccak256("org.superfluid-finance.contracts.PoolNFTBaseMock.implementation");
Expand Down Expand Up @@ -52,7 +52,7 @@ contract PoolNFTBaseMock is PoolNFTBase {
}

contract PoolAdminNFTMock is PoolAdminNFT {
constructor(ISuperfluid host) PoolAdminNFT(host) { }
constructor(ISuperfluid host, IGeneralDistributionAgreementV1 gdaV1) PoolAdminNFT(host, gdaV1) { }

/// @dev a mock mint function that exposes the internal _mint function
function mockMint(address _pool) public {
Expand All @@ -71,7 +71,7 @@ contract PoolAdminNFTMock is PoolAdminNFT {
}

contract PoolMemberNFTMock is PoolMemberNFT {
constructor(ISuperfluid host) PoolMemberNFT(host) { }
constructor(ISuperfluid host, IGeneralDistributionAgreementV1 gdaV1) PoolMemberNFT(host, gdaV1) { }

/// @dev a mock mint function that exposes the internal _mint function
function mockMint(address _pool, address _member) public {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
pragma solidity 0.8.19;

import { PoolNFTBase } from "../agreements/gdav1/PoolNFTBase.sol";
import { ISuperfluid } from "../interfaces/superfluid/ISuperfluid.sol";
import { IGeneralDistributionAgreementV1, ISuperfluid } from "../interfaces/superfluid/ISuperfluid.sol";
import { PoolMemberNFT } from "../agreements/gdav1/PoolMemberNFT.sol";
import { PoolAdminNFT } from "../agreements/gdav1/PoolAdminNFT.sol";
import { IStorageLayoutBase } from "./IStorageLayoutBase.sol";

contract PoolNFTBaseStorageLayoutMock is PoolNFTBase, IStorageLayoutBase {
constructor(ISuperfluid host) PoolNFTBase(host) { }
constructor(ISuperfluid host, IGeneralDistributionAgreementV1 gdaV1) PoolNFTBase(host, gdaV1) { }

function validateStorageLayout() public virtual {
uint256 slot;
Expand Down Expand Up @@ -72,7 +72,7 @@ contract PoolNFTBaseStorageLayoutMock is PoolNFTBase, IStorageLayoutBase {
}

contract PoolAdminNFTStorageLayoutMock is PoolAdminNFT, IStorageLayoutBase {
constructor(ISuperfluid host) PoolAdminNFT(host) { }
constructor(ISuperfluid host, IGeneralDistributionAgreementV1 gdaV1) PoolAdminNFT(host, gdaV1) { }

function validateStorageLayout() public virtual {
uint256 slot;
Expand Down Expand Up @@ -112,7 +112,7 @@ contract PoolAdminNFTStorageLayoutMock is PoolAdminNFT, IStorageLayoutBase {
}

contract PoolMemberNFTStorageLayoutMock is PoolMemberNFT, IStorageLayoutBase {
constructor(ISuperfluid host) PoolMemberNFT(host) { }
constructor(ISuperfluid host, IGeneralDistributionAgreementV1 gdaV1) PoolMemberNFT(host, gdaV1) { }

function validateStorageLayout() public virtual {
uint256 slot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
pragma solidity 0.8.19;

import { IERC721Metadata } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import { IGeneralDistributionAgreementV1 } from "../interfaces/agreements/gdav1/IGeneralDistributionAgreementV1.sol";
import { IConstantFlowAgreementV1 } from "../interfaces/agreements/IConstantFlowAgreementV1.sol";
import { IConstantOutflowNFT } from "../interfaces/superfluid/IConstantOutflowNFT.sol";
import { IConstantInflowNFT } from "../interfaces/superfluid/IConstantInflowNFT.sol";
import { ISuperfluid } from "../interfaces/superfluid/ISuperfluid.sol";
Expand All @@ -15,7 +17,12 @@ contract ConstantInflowNFT is FlowNFTBase, IConstantInflowNFT {
IConstantOutflowNFT public immutable CONSTANT_OUTFLOW_NFT;

// solhint-disable-next-line no-empty-blocks
constructor(ISuperfluid host, IConstantOutflowNFT constantOutflowNFT) FlowNFTBase(host) {
constructor(
ISuperfluid host,
IConstantFlowAgreementV1 cfaV1,
IGeneralDistributionAgreementV1 gdaV1,
IConstantOutflowNFT constantOutflowNFT
) FlowNFTBase(host, cfaV1, gdaV1) {
CONSTANT_OUTFLOW_NFT = constantOutflowNFT;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pragma solidity 0.8.19;

import { IERC721Metadata } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import { ISuperfluidToken } from "../interfaces/superfluid/ISuperfluidToken.sol";
import { IGeneralDistributionAgreementV1 } from "../interfaces/agreements/gdav1/IGeneralDistributionAgreementV1.sol";
import { IConstantFlowAgreementV1 } from "../interfaces/agreements/IConstantFlowAgreementV1.sol";
import { IConstantInflowNFT } from "../interfaces/superfluid/IConstantInflowNFT.sol";
import { IConstantOutflowNFT } from "../interfaces/superfluid/IConstantOutflowNFT.sol";
import { ISuperfluid } from "../interfaces/superfluid/ISuperfluid.sol";
Expand All @@ -22,7 +24,12 @@ contract ConstantOutflowNFT is FlowNFTBase, IConstantOutflowNFT {
mapping(uint256 => FlowNFTData) internal _flowDataByTokenId;

// solhint-disable-next-line no-empty-blocks
constructor(ISuperfluid host, IConstantInflowNFT constantInflowNFT) FlowNFTBase(host) {
constructor(
ISuperfluid host,
IConstantFlowAgreementV1 cfaV1,
IGeneralDistributionAgreementV1 gdaV1,
IConstantInflowNFT constantInflowNFT
) FlowNFTBase(host, cfaV1, gdaV1) {
CONSTANT_INFLOW_NFT = constantInflowNFT;
}

Expand Down
18 changes: 3 additions & 15 deletions packages/ethereum-contracts/contracts/superfluid/FlowNFTBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,10 @@ abstract contract FlowNFTBase is UUPSProxiable, IFlowNFTBase {
uint256 private _reserve20;
uint256 internal _reserve21;

constructor(ISuperfluid host) {
constructor(ISuperfluid host, IConstantFlowAgreementV1 cfaV1, IGeneralDistributionAgreementV1 gdaV1) {
HOST = host;
CONSTANT_FLOW_AGREEMENT_V1 = IConstantFlowAgreementV1(
address(
ISuperfluid(host).getAgreementClass(
keccak256("org.superfluid-finance.agreements.ConstantFlowAgreement.v1")
)
)
);
GENERAL_DISTRIBUTION_AGREEMENT_V1 = IGeneralDistributionAgreementV1(
address(
ISuperfluid(host).getAgreementClass(
keccak256("org.superfluid-finance.agreements.GeneralDistributionAgreement.v1")
)
)
);
CONSTANT_FLOW_AGREEMENT_V1 = cfaV1;
GENERAL_DISTRIBUTION_AGREEMENT_V1 = gdaV1;
}

function initialize(string memory nftName, string memory nftSymbol)
Expand Down
Loading

0 comments on commit f229b9c

Please sign in to comment.