Skip to content

Commit

Permalink
Merge pull request #11 from PoCInnovation/fix-supertokens
Browse files Browse the repository at this point in the history
Fix supertokens
  • Loading branch information
LeTamanoir authored Aug 9, 2023
2 parents 896c6ad + b3f0b2c commit 16c55f5
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 24 deletions.
10 changes: 3 additions & 7 deletions packages/dao/foundry.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
[profile.default]
src = "src"
script = "script"
test = "test"
out = "out"
libs = ["lib"]
remappings = [
"custom-supertokens/=lib/custom-supertokens/",
"forge-std/=lib/forge-std/src/",
"@openzeppelin/=lib/@openzeppelin/",
"@superfluid-finance/=lib/@superfluid-finance/packages/",
]
auto_detect_remappings = true

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
7 changes: 0 additions & 7 deletions packages/dao/lib/custom-supertokens/base/SuperTokenBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ abstract contract SuperTokenBase is SuperTokenStorage, UUPSProxy {
return ISuperToken(address(this)).totalSupply();
}

/// @dev Gets balanceOf
/// @param account Address to get balance of
/// @return b balance of account
function _balanceOf(address account) internal view returns (uint256 b) {
return ISuperToken(address(this)).balanceOf(account);
}

/// @dev Internal mint, calling functions should perform important checks!
/// @param account Address receiving minted tokens
/// @param amount Amount of tokens minted
Expand Down
22 changes: 22 additions & 0 deletions packages/dao/script/DeploySuperfluidDao.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import "forge-std/Script.sol";
import {SuperfluidDaoToken} from "../src/SuperfluidDaoToken.sol";
import {ISuperToken} from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperToken.sol";

address constant SUPER_TOKEN_FACTORY = 0x94f26B4c8AD12B18c12f38E878618f7664bdcCE2;

contract DeploySuperfluidDao is Script {
SuperfluidDaoToken public token;

function run() public {
token = new SuperfluidDaoToken();

token.initialize(SUPER_TOKEN_FACTORY, "SuperfluidDaoToken", "SDT");

token.mint(address(this), 2000000);

console.log(ISuperToken(address(token)).balanceOf(address(this)));
}
}
7 changes: 5 additions & 2 deletions packages/dao/src/SuperfluidDao.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
pragma solidity ^0.8.0;

import {SuperfluidDaoToken} from "./SuperfluidDaoToken.sol";
import {ISuperToken} from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperToken.sol";

interface ISuperfluidDao {
struct Proposal {
Expand Down Expand Up @@ -103,7 +104,9 @@ contract SuperfluidDao is ISuperfluidDao {
revert ProposalDueDatePassed();
}

uint256 voteWeight = _superfluidToken.balanceOf(msg.sender);
uint256 voteWeight = ISuperToken(address(_superfluidToken)).balanceOf(
msg.sender
);

if (voteWeight == 0) {
revert ZeroSuperfluidDaoToken();
Expand Down
20 changes: 13 additions & 7 deletions packages/dao/src/SuperfluidDaoToken.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: AGPLv3
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import {SuperTokenBase} from "custom-supertokens/base/SuperTokenBase.sol";
Expand All @@ -23,12 +23,18 @@ contract SuperfluidAdmin {
}

contract SuperfluidDaoToken is SuperTokenBase, SuperfluidAdmin {
constructor() {
// _initialize(SUPER_TOKEN_FACTORY, "SuperfluidDaoToken", "SDT");
}

function balanceOf(address account) public view returns (uint256) {
return _balanceOf(account);
constructor() {}

/// @dev Upgrades the super token with the factory, then initializes.
/// @param factory super token factory for initialization
/// @param name super token name
/// @param symbol super token symbol
function initialize(
address factory,
string memory name,
string memory symbol
) external onlyAdmin {
_initialize(factory, name, symbol);
}

function mint(address to, uint256 amount) public onlyAdmin {
Expand Down
2 changes: 1 addition & 1 deletion packages/dao/test/SuperfluidDao.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
pragma solidity ^0.8.0;

import "forge-std/Test.sol";
import "../src/SuperfluidDao.sol";
Expand Down

0 comments on commit 16c55f5

Please sign in to comment.