Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

64 principal game cost time parameters #82

Merged
merged 25 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2ff6c28
wip
peersky Nov 20, 2024
f569d77
removed multipass sources
peersky Nov 20, 2024
b1833bb
contracts compile, tests are broken, new assertions are not tested yet
peersky Nov 20, 2024
75e35f3
rm white spaces
peersky Nov 20, 2024
e04bdf7
happy linter - happy life
peersky Nov 20, 2024
576bc95
TDD: Todo Rewards, ToDo More tests
peersky Nov 21, 2024
14d83cc
Fixed some tests - due to removed facet indies moved down
peersky Nov 22, 2024
8f6ed5b
TDD, fixes
peersky Nov 22, 2024
69c2030
happy linter - happy life
peersky Nov 22, 2024
fa054ba
removed additional rank requirement functionality
peersky Nov 25, 2024
750f8f7
burning payments instead of refunding
peersky Nov 25, 2024
bbfe899
give dao benefit 10% of game revenue being burnt
peersky Nov 25, 2024
a4ee689
added beneficiary share from games as 10%, and helper methods
peersky Nov 25, 2024
73fc702
added principal cost basic test
peersky Nov 25, 2024
ec00e2d
can generate zero votes in tests
peersky Nov 25, 2024
8eb656f
refactored the LibTurnBasedGame.sol startGameEarly and StartGame func…
peersky Nov 26, 2024
afe5fc3
added minimal time to the constraints
peersky Nov 26, 2024
81dcd57
fix tests
peersky Nov 26, 2024
f2357f4
ignore vscode
peersky Nov 26, 2024
c5db40c
happy linter - happy life
peersky Nov 26, 2024
8ac1197
changeset updated
peersky Nov 26, 2024
fbea28e
more Game Cost and Time Tests
peersky Nov 26, 2024
1900603
remove .only
peersky Nov 26, 2024
610b102
docstrings
peersky Nov 26, 2024
80c088a
update readme
peersky Nov 26, 2024
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: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,19 @@ const distributorArguments: MAODistribution.DistributorArgumentsStruct = {
tokenName: 'tokenName',
tokenSymbol: 'tokenSymbol',
},
ACIDSettings: {
RankifySettings: {
RankTokenContractURI: 'https://example.com/rank',
gamePrice: 1,
joinGamePrice: 1,
maxPlayersSize: 16,
maxTurns: 1,
principalCost: RInstanceSettings.PRINCIPAL_COST,
principalTimeConstant: RInstanceSettings.PRINCIPAL_TIME_CONSTANT,
metadata: ethers.utils.hexlify(ethers.utils.toUtf8Bytes('metadata')),
minPlayersSize: 4,
paymentToken: rankify.address,
rankTokenURI: 'https://example.com/rank',
timePerTurn: 1,
timeToJoin: 1,
voteCredits: 14,
},
};
// const abi = import('../abi/src/distributions/MAODistribution.sol/MAODistribution.json');
// Encode the arguments
const data = ethers.utils.defaultAbiCoder.encode(
[
'tuple(tuple(string daoURI, string subdomain, bytes metadata, string tokenName, string tokenSymbol) DAOSEttings, tuple(uint256 timePerTurn, uint256 maxPlayersSize, uint256 minPlayersSize, uint256 timeToJoin, uint256 maxTurns, uint256 voteCredits, uint256 gamePrice, address paymentToken, uint256 joinGamePrice, string metadata, string rankTokenURI, string RankTokenContractURI) ACIDSettings)',
'tuple(tuple(string daoURI, string subdomain, bytes metadata, string tokenName, string tokenSymbol) DAOSEttings, tuple(uint256 principalCost, uint256 principalTimeConstant, string metadata, string rankTokenURI, string RankTokenContractURI) RankifySettings)',
],
[distributorArguments],
);
Expand Down
30 changes: 0 additions & 30 deletions deploy/06_deoployMultipass.ts

This file was deleted.

39 changes: 17 additions & 22 deletions deploy/mao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { activeContractsList } from '@aragon/osx-ethers';
import { CodeIndex } from '@peeramid-labs/eds/types';
import CodeIndexAbi from '@peeramid-labs/eds/abi/src/CodeIndex.sol/CodeIndex.json';
import { MintSettingsStruct } from '../types/src/tokens/DistributableGovernanceERC20.sol/DistributableGovernanceERC20';
import { ArguableVotingTournament } from '../types/src/distributions/ArguableVotingTournament';
const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { deployments, getNamedAccounts } = hre;
const { deploy } = deployments;
Expand All @@ -17,7 +18,7 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
console.log('network', network, process.env.NODE_ENV);
}
if (!network) throw new Error('Network not provided');
const { deployer } = await getNamedAccounts();
const { deployer, DAO } = await getNamedAccounts();
const codeIndexContract = (await ethers.getContractAt(
CodeIndexAbi,
'0xc0D31d398c5ee86C5f8a23FA253ee8a586dA03Ce',
Expand Down Expand Up @@ -101,34 +102,26 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
skipIfAlreadyDeployed: true,
});

const RankifyOwnerFacetDeployment = await deploy('RankifyInstanceGameOwnersFacet', {
from: deployer,
skipIfAlreadyDeployed: true,
});

const OwnershipFacetDeployment = await deploy('OwnershipFacet', {
from: deployer,
skipIfAlreadyDeployed: true,
});

const addresses: ArguableVotingTournament.ArguableTournamentAddressesStruct = {
loupeFacet: loupeFacetDeployment.address,
inspectorFacet: inspectorFacetDeployment.address,
RankifyMainFacet: RankifyMainFacetDeployment.address,
RankifyReqsFacet: RankifyReqsFacetDeployment.address,
RankifyGMFacet: RankifyGMFacetDeployment.address,
OwnershipFacet: OwnershipFacetDeployment.address,
};

const arguableVotingTournamentDeployment = await deploy('ArguableVotingTournament', {
from: deployer,
gasLimit: 8000000,
estimatedGasLimit: 8000000,
skipIfAlreadyDeployed: true,
args: [
initializerAdr,
initializerSelector,
distributionName,
version,
loupeFacetDeployment.address,
inspectorFacetDeployment.address,
RankifyMainFacetDeployment.address,
RankifyReqsFacetDeployment.address,
RankifyGMFacetDeployment.address,
RankifyOwnerFacetDeployment.address,
OwnershipFacetDeployment.address,
],
args: [initializerAdr, initializerSelector, distributionName, version, addresses],
});
const arguableVotingTournamentDeploymentCode = await hre.ethers.provider.getCode(
arguableVotingTournamentDeployment.address,
Expand Down Expand Up @@ -160,14 +153,16 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
}
const govTokenCode = await hre.ethers.provider.getCode(govTokenDeployment.address);
const govTokenCodeId = ethers.utils.keccak256(govTokenCode);

const rankifyToken = await deployments.get('Rankify');
const result = await deploy('MAODistribution', {
from: deployer,
skipIfAlreadyDeployed: true,
args: [
_tokenVotingPluginRepo,
_daoFactory,
_trustedForwarder,
rankifyToken.address,
DAO,
rankTokenCodeId,
arguableVotingTournamentCodeId,
accessManagerId,
Expand All @@ -183,8 +178,8 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
if (MaoDistrCodeIdAddress === ethers.constants.AddressZero) {
await codeIndexContract.register(result.address);
}
const code = await hre.ethers.provider.getCode(result.address);
const codeId = ethers.utils.keccak256(code);
// const code = await hre.ethers.provider.getCode(result.address);
// const codeId = ethers.utils.keccak256(code);
// console.log('MAO deployed at', result.address, 'codeId', codeId);
return;
};
Expand Down
4 changes: 3 additions & 1 deletion deploy/sacm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const codeId = ethers.utils.keccak256(code);
const registerAddress = await codeIndexContract.get(codeId);
if (registerAddress == ethers.constants.AddressZero) {
console.warn('registering contract', registerAddress, sacmDeployment.address, codeId);
if (process.env.NODE_ENV !== 'TEST') {
console.warn('registering contract', registerAddress, sacmDeployment.address, codeId);
}
await codeIndexContract.register(sacmDeployment.address);
}
};
Expand Down
66 changes: 37 additions & 29 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import 'hardhat-contract-sizer';
import 'hardhat-deploy';
import 'hardhat-tracer';
import 'solidity-docgen';
import './playbook/initializeDomain';
import './playbook/createGame';
import getSuperInterface from './scripts/getSuperInterface';
import { ErrorFragment, EventFragment, FunctionFragment } from '@ethersproject/abi';

task('accounts', 'Prints the list of accounts', async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();
Expand All @@ -23,19 +24,28 @@ task('accounts', 'Prints the list of accounts', async (taskArgs, hre) => {
}
});

// task("upload2IPFS", "Uploads files to ipfs")
// .addParam("path", "file path")
// .setAction(async (taskArgs) => {
// const data = fs.readFileSync(taskArgs.path);
// await ipfsUtils.upload2IPFS(data);
// });

// task("uploadDir2IPFS", "Uploads directory to ipfs")
// .addParam("path", "path")
// .setAction(async (taskArgs) => {
// await ipfsUtils.uploadDir2IPFS(taskArgs.path);
// });

task('getSuperInterface', 'Prints the super interface of a contract').setAction(async (taskArgs, hre) => {
const su = getSuperInterface();
let return_value: {
functions: Record<string, FunctionFragment>;
events: Record<string, EventFragment>;
errors: Record<string, ErrorFragment>;
} = {
functions: {},
events: {},
errors: {},
};
Object.values(su.functions).forEach(x => {
return_value['functions'][su.getSighash(x)] = x;
});
Object.values(su.events).forEach(x => {
return_value['events'][su.getSighash(x)] = x;
});
Object.values(su.errors).forEach(x => {
return_value['errors'][su.getSighash(x)] = x;
});
console.log(JSON.stringify(return_value, null, 2));
});
task('replaceFacet', 'Upgrades facet')
.addParam('facet', 'facet')
.addParam('address', 'contract address')
Expand Down Expand Up @@ -99,6 +109,9 @@ export default {
defaultPlayer: {
localhost: '0xF52E5dF676f51E410c456CC34360cA6F27959420',
},
DAO: {
default: '0x520E00225C4a43B6c55474Db44a4a44199b4c3eE',
},
},
mocha: {
timeout: 400000,
Expand Down Expand Up @@ -148,6 +161,15 @@ export default {
},
solidity: {
compilers: [
{
version: '0.8.28',
settings: {
optimizer: {
enabled: true,
runs: 2000,
},
},
},
{
version: '0.8.20',
settings: {
Expand All @@ -169,19 +191,6 @@ export default {
],
},
diamondAbi: [
{
// (required) The name of your Diamond ABI
name: 'MultipassDiamond',
include: ['DNSFacet', 'OwnershipFacet', 'DiamondLoupeFacet', 'EIP712InspectorFacet'],
// We explicitly set `strict` to `true` because we want to validate our facets don't accidentally provide overlapping functions
strict: true,
// We use our diamond utils to filter some functions we ignore from the combined ABI
filter(abiElement: unknown, index: number, abi: unknown[], fullyQualifiedName: string) {
// const changes = new diamondUtils.DiamondChanges();
const signature = toSignature(abiElement);
return isIncluded(fullyQualifiedName, signature);
},
},
{
name: 'RankifyDiamondInstance',
include: [
Expand All @@ -191,9 +200,8 @@ export default {
'RankifyInstanceMainFacet',
'RankifyInstanceRequirementsFacet',
'RankifyInstanceGameMastersFacet',
'RankifyInstanceGameOwnersFacet',
],
strict: true,
strict: false,
filter(abiElement: unknown, index: number, abi: unknown[], fullyQualifiedName: string) {
const signature = toSignature(abiElement);
return isIncluded(fullyQualifiedName, signature);
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@
"@nomiclabs/buidler-web3": "^1.3.4",
"@nomiclabs/hardhat-ethers": "^2.0.6",
"@nomiclabs/hardhat-etherscan": "^3.1.8",
"@peeramid-labs/eds": "^2.1.0",
"@peeramid-labs/eds": "^2.1.3",
"@shopify/eslint-plugin": "^43.0.0",
"@solidstate/contracts": "^0.0.35",
"@typechain/ethers-v5": "^11.1.2",
"@typechain/hardhat": "^7.0.0",
"@typechain/web3-v1": "^6.0.1",
Expand All @@ -49,20 +48,20 @@
"chai": "^4.3.6",
"crypto-js": "^4.1.1",
"eslint": "^9.6.0",
"prettier": "^3.3.3",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-promise": "^6.4.0",
"eth-create2-calculator": "^1.1.5",
"ethers": "^5.6.6",
"globals": "^15.9.0",
"hardhat": "2.22.11",
"hardhat": "^2.22.16",
"hardhat-abi-exporter": "^2.9.0",
"hardhat-contract-sizer": "^2.6.1",
"hardhat-contract-sizer": "^2.10.0",
"hardhat-deploy": "^0.12.2",
"hardhat-diamond-abi": "^3.0.0",
"hardhat-tracer": "^3.1.0",
"keccak": "^3.0.1",
"mocha": "^10.0.0",
"prettier": "^3.3.3",
"prettier-plugin-solidity": "^1.1.3",
"solhint": "^3.6.2",
"solidity-coverage": "^0.8.5",
Expand Down
Loading
Loading