Skip to content

Commit

Permalink
SFS in friend keys
Browse files Browse the repository at this point in the history
  • Loading branch information
tempe-techie committed Jan 29, 2024
1 parent e03d0c9 commit 8c0d9ef
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 8 deletions.
8 changes: 8 additions & 0 deletions contracts/keys/FriendKeys.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { IPunkTLD } from "../interfaces/IPunkTLD.sol";
import { OwnableWithManagers } from "../access/OwnableWithManagers.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuard.sol";

interface ISFS {
function assign(uint256 _tokenId) external returns (uint256);
}

interface IStats {
function addWeiSpent(address user_, uint256 weiSpent_) external;
}
Expand Down Expand Up @@ -40,10 +44,14 @@ contract FriendKeys is OwnableWithManagers, ReentrancyGuard {
address _tldAddress,
address _feeReceiver,
address _statsAddress,
address _sfsAddress,
uint256 _sfsNftId,
uint256 _protocolFeePercent,
uint256 _domainHolderFeePercent,
uint256 _ratio
) {
ISFS(_sfsAddress).assign(_sfsNftId);

tldAddress = _tldAddress;
tldName = IPunkTLD(_tldAddress).name();

Expand Down
8 changes: 8 additions & 0 deletions contracts/keys/FriendKeysErc20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { OwnableWithManagers } from "../access/OwnableWithManagers.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface ISFS {
function assign(uint256 _tokenId) external returns (uint256);
}

interface IStats {
function addWeiSpent(address user_, uint256 weiSpent_) external;
}
Expand Down Expand Up @@ -44,10 +48,14 @@ contract FriendKeysErc20 is OwnableWithManagers, ReentrancyGuard {
address _tokenAddress,
address _feeReceiver,
address _statsAddress,
address _sfsAddress,
uint256 _sfsNftId,
uint256 _protocolFeePercent,
uint256 _domainHolderFeePercent,
uint256 _ratio
) {
ISFS(_sfsAddress).assign(_sfsNftId);

tldAddress = _tldAddress;
tldName = IPunkTLD(_tldAddress).name();

Expand Down
1 change: 1 addition & 0 deletions scripts/activity-points/activityPoints.deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const statsAddress = ""; // stats contract
const mintedPostsStatsAddress = "";
const tldStatsAddress = ethers.constants.AddressZero;
const multiplier = 100000; // 1 wei = 100000 points

const sfsAddress = (network.name == "modeTestnet") ? "0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6" : "0x8680CEaBcb9b56913c519c069Add6Bc3494B7020";
const sfsNftTokenId = 0; // TODO: Enter SFS NFT token ID!!!

Expand Down
6 changes: 4 additions & 2 deletions scripts/distributor/distributor.deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const contractName = "RevenueDistributor";
const recipients = [];
const managers = [];

const sfsAddress = (network.name == "modeTestnet") ? "0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6" : "0x8680CEaBcb9b56913c519c069Add6Bc3494B7020";

/*
// recipients receive a percentage of the revenue that comes to the contract
const recipients = [
Expand All @@ -25,7 +27,7 @@ async function main() {

// deploy contract
const contract = await ethers.getContractFactory(contractName);
const instance = await contract.deploy();
const instance = await contract.deploy(sfsAddress, deployer.address);
await instance.deployed();

console.log(contractName + " contract address:", instance.address);
Expand All @@ -47,7 +49,7 @@ async function main() {
}

console.log("Wait a minute and then run this command to verify contracts on block explorer:");
console.log("npx hardhat verify --network " + network.name + " " + instance.address);
console.log("npx hardhat verify --network " + network.name + " " + instance.address + " " + sfsAddress + " " + deployer.address);
}

main()
Expand Down
15 changes: 13 additions & 2 deletions scripts/distributor/distributorFactory.deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

const contractName = "RevenueDistributorFactory";

const sfsAddress = (network.name == "modeTestnet") ? "0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6" : "0x8680CEaBcb9b56913c519c069Add6Bc3494B7020";
const sfsNftTokenId = 0; // TODO: Enter SFS NFT token ID!!!

if (sfsNftTokenId == 0) {
console.log("Please enter SFS NFT token ID!!!");
return;
}

async function main() {
const [deployer] = await ethers.getSigners();

Expand All @@ -10,13 +18,16 @@ async function main() {

// deploy contract
const contract = await ethers.getContractFactory(contractName);
const instance = await contract.deploy();
const instance = await contract.deploy(
sfsAddress,
sfsNftTokenId
);
await instance.deployed();

console.log(contractName + " contract address:", instance.address);

console.log("Wait a minute and then run this command to verify contracts on block explorer:");
console.log("npx hardhat verify --network " + network.name + " " + instance.address);
console.log("npx hardhat verify --network " + network.name + " " + instance.address + " " + sfsAddress + ' "' + sfsNftTokenId + '"');
}

main()
Expand Down
18 changes: 14 additions & 4 deletions scripts/keys/1_friendKeys.deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@

const contractName = "FriendKeys";

const tldAddress = "0x4087fb91A1fBdef05761C02714335D232a2Bf3a1";
const feeReceiver = "0x6771F33Cfd8C6FC0A1766331f715f5d2E1d4E0e2"; // distributor contract address
const statsAddress = "0x3Fa0EaC3058828Cc4BA97F51A33597C695bF6F9e"; // stats middleware contract address
const tldAddress = "";
const feeReceiver = ""; // distributor contract address
const statsAddress = ""; // stats middleware contract address

const sfsAddress = (network.name == "modeTestnet") ? "0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6" : "0x8680CEaBcb9b56913c519c069Add6Bc3494B7020";
const sfsNftTokenId = 0; // TODO: Enter SFS NFT token ID!!!

if (sfsNftTokenId == 0) {
console.log("Please enter SFS NFT token ID!!!");
return;
}

const protocolFeePercent = ethers.utils.parseEther("0.05"); // 1 is 100%
const domainHolderFeePercent = ethers.utils.parseEther("0.05"); // 1 is 100%
Expand All @@ -23,6 +31,8 @@ async function main() {
tldAddress,
feeReceiver,
statsAddress,
sfsAddress,
sfsNftTokenId,
protocolFeePercent,
domainHolderFeePercent,
ratio
Expand All @@ -41,7 +51,7 @@ async function main() {
console.log("Done!");

console.log("Wait a minute and then run this command to verify contracts on block explorer:");
console.log("npx hardhat verify --network " + network.name + " " + instance.address + " " + tldAddress + " " + feeReceiver + " " + statsAddress + ' "' + protocolFeePercent + '" "' + domainHolderFeePercent + '" "' + ratio + '"');
console.log("npx hardhat verify --network " + network.name + " " + instance.address + " " + tldAddress + " " + feeReceiver + " " + statsAddress + " " + sfsAddress + ' "' + sfsNftTokenId + '" "' + protocolFeePercent + '" "' + domainHolderFeePercent + '" "' + ratio + '"');
}

main()
Expand Down
1 change: 1 addition & 0 deletions test/activity-points/activityPoints.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function calculateGasCosts(testName, receipt) {

describe("Activity Points", function () {
let activityPointsContract;
let feeReceiver;
let statsContract;

const multiplier = 100;
Expand Down
2 changes: 2 additions & 0 deletions test/keys/friendKeys.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ describe("FriendKeys", function () {
mockPunkTldContract.address,
feeReceiver.address,
statsMiddlewareContract.address,
sfsContract.address,
sfsNftTokenId,
protocolFeePercent,
domainHolderFeePercent,
ratio
Expand Down
2 changes: 2 additions & 0 deletions test/keys/friendKeysErc20.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ describe("FriendKeys ERC-20", function () {
tokenContract.address,
feeReceiver.address,
statsMiddlewareContract.address,
sfsContract.address,
sfsNftTokenId,
protocolFeePercent,
domainHolderFeePercent,
ratio
Expand Down
2 changes: 2 additions & 0 deletions test/keys/friendKeysErc20Referrer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ describe("FriendKeys ERC-20 with referrer", function () {
tokenContract.address,
feeReceiver.address,
statsMiddlewareContract.address,
sfsContract.address,
sfsNftTokenId,
protocolFeePercent,
domainHolderFeePercent,
ratio
Expand Down
2 changes: 2 additions & 0 deletions test/keys/friendKeysReferrer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ describe("FriendKeys WITH REFERRER", function () {
mockPunkTldContract.address,
feeReceiver.address,
statsMiddlewareContract.address,
sfsContract.address,
sfsNftTokenId,
protocolFeePercent,
domainHolderFeePercent,
ratio
Expand Down

0 comments on commit 8c0d9ef

Please sign in to comment.