Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
17 changes: 17 additions & 0 deletions address.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// APIIdeaNFT deployed to: 0x139f634Ff6F87154B7cF70fcb57425E99DAb920c
// apitoken deployed to: 0xE94CD8bB4c0B68d3dB9EDbC3d1b8a9fc3f66eDc9
// GovernerCore deployed to: 0x8B7e789Dd527A231a36C7f49c2306B2FB2EC1899
// PanacloudController deployed to: 0xcbAE0c9E3F966e254F8b63CE8EA305B7C0f5AAd5
// PanaCoin deployed to: 0x3C3bbA8667cc45906925D58e9630F4a52945de2e
// PanaFactory deployed to: 0xD3726E2C9dB1216597d79D4c868c6a4C5389c7E8
// PlatformGoverner deployed to: 0x2F951B7aC39c504882966e5B28657f1c20F278E4
// Timelock deployed to: 0xcFcbCfD30316BB3Ef224158e10593d9C0DB94E7f

export const APIIdeaNFT = "0x139f634Ff6F87154B7cF70fcb57425E99DAb920c"
export const Apitoken = "0xE94CD8bB4c0B68d3dB9EDbC3d1b8a9fc3f66eDc9"
export const GovernerCore = "0x8B7e789Dd527A231a36C7f49c2306B2FB2EC1899"
export const PanacloudController = "0xcbAE0c9E3F966e254F8b63CE8EA305B7C0f5AAd5"
export const PanaCoin = "0x3C3bbA8667cc45906925D58e9630F4a52945de2e"
export const PanaFactory = "0xD3726E2C9dB1216597d79D4c868c6a4C5389c7E8"
export const PlatformGoverner = "0x2F951B7aC39c504882966e5B28657f1c20F278E4"
export const Timelock = "0xcFcbCfD30316BB3Ef224158e10593d9C0DB94E7f"
21 changes: 11 additions & 10 deletions contracts/Apitoken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pragma solidity >=0.4.22 <0.9.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "./DAIcoin.sol";



contract ApiToken is ERC20{
Expand Down Expand Up @@ -46,8 +48,8 @@ contract ApiToken is ERC20{
require(payees.length > 0, " no payees");
owner_ = msg.sender;
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares_[i]*10**decimals());
_mint(payees[i], shares_[i]*10**decimals());
_addPayee(payees[i], shares_[i]);
_mint(payees[i], shares_[i]);
}
}

Expand Down Expand Up @@ -201,14 +203,14 @@ contract ApiToken is ERC20{


function transfer(address recipient, uint256 amount) public override returns (bool) {
if(isContract(recipient) && !isContract(_msgSender()))
if(isContract(recipient) && !isContract(_msgSender()))
{
_unclaimedPayment[_msgSender()]=unclaimedPayment(_msgSender());
_pointOne[_msgSender()]=_totalRevenue;
_shares[_msgSender()]=_shares[_msgSender()]-amount;

_totalShares = _totalShares - amount;

_transfer(_msgSender(), recipient, amount);
return true;
}
Expand All @@ -228,17 +230,16 @@ contract ApiToken is ERC20{
_unclaimedPayment[_msgSender()]=unclaimedPayment(_msgSender());
_pointOne[_msgSender()]=_totalRevenue;
_shares[_msgSender()]=_shares[_msgSender()]-amount;

_unclaimedPayment[recipient]=unclaimedPayment(recipient);
_pointOne[recipient]=_totalRevenue;
_shares[recipient]=_shares[recipient]+amount;

_transfer(_msgSender(), recipient, amount);


return true;
}

}

function transferFrom(
Expand Down
1 change: 1 addition & 0 deletions contracts/Timelock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ contract Timelock is Ownable {


constructor(address admin_, uint delay_) {
delay_ = delay_ * 1 days;
require(delay_ >= MINIMUM_DELAY, "Timelock::constructor: Delay must exceed minimum delay.");
require(delay_ <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay.");

Expand Down
14 changes: 13 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,22 @@ task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {

// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more

const ALCHEMY_API_KEY = `f9Ve8ws0_LMHLdew7lncSD1f0DreXFA3`
const privateKey = `73b69d165f4513a5fde731e50e8e9c299f2f4df86f0bcab4bd4a955b151faa76`
/**
* @type import('hardhat/config').HardhatUserConfig
*/
export default {
solidity: "0.8.4",
networks: {
ropsten: {
url: `https://eth-ropsten.alchemyapi.io/v2/${ALCHEMY_API_KEY}`,
accounts: [`0x${privateKey}`],
},
hardhat: {
forking: {
url: "https://eth-ropsten.alchemyapi.io/v2/f9Ve8ws0_LMHLdew7lncSD1f0DreXFA3",
}
}
}
};
91 changes: 91 additions & 0 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// We require the Hardhat Runtime Environment explicitly here. This is optional
// but useful for running the script in a standalone fashion through `node <script>`.
//
// When running the script with `npx hardhat run <script>` you'll find the Hardhat
// Runtime Environment's members available in the global scope.
import { ethers, run } from 'hardhat';

async function main() {
// Hardhat always runs the compile task when running scripts with its command
// line interface.
//
// If this script is run directly using `node` you may want to call compile
// manually to make sure everything is compiled
// await hre.run('compile');

// We get the contract to deploy

const APIIdeaNFT = await ethers.getContractFactory("APIIdeaNFT");
const aPIIdeaNFT = await APIIdeaNFT.deploy();

await aPIIdeaNFT.deployed();

console.log("APIIdeaNFT deployed to:", aPIIdeaNFT.address);

const [_, addr1] = await ethers.getSigners()
const shares = [50]
const owner = _.address
//console.log(_.address)

const ApiToken = await ethers.getContractFactory("ApiToken");
const apiToken = await ApiToken.deploy([owner], shares);

await apiToken.deployed();

console.log("apitoken deployed to:", apiToken.address);


const GovernerCore = await ethers.getContractFactory("GovernerCore");
const governerCore = await GovernerCore.deploy();

await governerCore.deployed();

console.log("GovernerCore deployed to:", governerCore.address);


const PanacloudController = await ethers.getContractFactory("PanacloudController");
const panacloudController = await PanacloudController.deploy();

await panacloudController.deployed();

console.log("PanacloudController deployed to:", panacloudController.address);

const PanaCoin = await ethers.getContractFactory("PanaCoin");
const panaCoin = await PanaCoin.deploy();

await panaCoin.deployed();

console.log("PanaCoin deployed to:", panaCoin.address);

const PanaFactory = await ethers.getContractFactory("PanaFactory");
const panaFactory = await PanaFactory.deploy();

await panaFactory.deployed();

console.log("PanaFactory deployed to:", panaFactory.address);

const PlatformGoverner = await ethers.getContractFactory("PlatformGoverner");
const platformGoverner = await PlatformGoverner.deploy();

await platformGoverner.deployed();

console.log("PlatformGoverner deployed to:", platformGoverner.address);


const Timelock = await ethers.getContractFactory("Timelock");
const timelock = await Timelock.deploy(_.address, 10);

await timelock.deployed();

console.log("Timelock deployed to:", timelock.address);

}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
18 changes: 10 additions & 8 deletions test/apiToken_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,31 @@ describe("ApiToken", function () {
it("Should return the total coins = owners coins", async function () {

const [owner, addr1]: SignerWithAddress[] = await ethers.getSigners();
const addresses: string[] = [owner.toString(), addr1.toString()]
// const addresses: string[] = [owner.toString(), addr1.toString()]

const shares = [1000, 0]

const ApiToken: ApiToken__factory = await ethers.getContractFactory("ApiToken");
const apiToken: ApiToken = await ApiToken.deploy(addresses, shares);
const apiToken: ApiToken = await ApiToken.deploy([owner.address], [1000]);
await apiToken.deployed();

expect(await apiToken.totalSupply()).to.equal(ethers.utils.parseEther('1020'));
expect(await apiToken.totalSupply()).to.equal(1000);

expect(await apiToken.balanceOf(await owner.getAddress())).to.equal(1000);
console.log(await (await apiToken.balanceOf(await owner.getAddress())).toNumber())

// expect(await apiToken.balanceOf(await owner.getAddress())).to.equal(ethers.utils.parseEther('1000'));
expect(await apiToken.balanceOf(await owner.getAddress())).to.equal(1000);

});

it("Should transfer coins correctly", async function () {
const [owner, addr1] = await ethers.getSigners();
const addresses: string[] = [owner.toString(), addr1.toString()]


const shares = [1000, 0]

const ApiToken = await ethers.getContractFactory("ApiToken");
const apiToken = await ApiToken.deploy(addresses, shares);
const apiToken: ApiToken = await ApiToken.deploy([owner.address], [1000]);
await apiToken.deployed();

await apiToken.transfer(await addr1.getAddress(), 10);
Expand Down Expand Up @@ -79,14 +81,14 @@ describe("Token contract", function () {
// Get the ContractFactory and Signers here.
Token = await ethers.getContractFactory("ApiToken");
[owner, addr1, addr2, ...addrs] = await ethers.getSigners();
const addresses: string[] = [owner.toString(), addr1.toString()]
// const addresses: string[] = [owner.toString(), addr1.toString()]

const shares = [1000, 0]

// To deploy our contract, we just have to call Token.deploy() and await
// for it to be deployed(), which happens once its transaction has been
// mined.
hardhatToken = await Token.deploy(addresses, shares);
hardhatToken = await Token.deploy([owner.address], [10000]);
});

// You can nest describe calls to create subsections.
Expand Down