Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Ro0r committed Oct 18, 2023
1 parent 5802a16 commit 1788d1b
Show file tree
Hide file tree
Showing 15 changed files with 10,353 additions and 170 deletions.
20 changes: 10 additions & 10 deletions config/testnet/config0.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"chain": {
"name": "Anvil",
"chainId": "2153",
"endpoint":"https://prod-testnet.prod.findora.org:8545",
"participant": "506b8eca4fef48a3acd2fc8df943a81e98f71e116ffb6011063d65f783b0f087",
"name": "GscQa03",
"chainId": "9527",
"endpoint":"https://dev-qa03.dev.findora.org:8545",
"participant": "4d05b965f821ea900ddd995dfa1b6caa834eaaa1ebe100a9760baf9331aae567",
"opts": {
"randao": "0x1663a1ac216A5A53BE7842C27E7bCDbc07d9a861",
"randao": "0x2dc9bea5a87Ea6A072d5A1d3470168d9f3ED1eF3",
"gasLimit": "1000000",
"maxGasPrice": "100000000000",
"minGasReserve": "100000000",
Expand All @@ -19,11 +19,11 @@
},
"http_listen": "0.0.0.0:3000",
"prometheus_listen": "0.0.0.0:9090",
"root_secret": "506b8eca4fef48a3acd2fc8df943a81e98f71e116ffb6011063d65f783b0f087",
"root_secret": "4d05b965f821ea900ddd995dfa1b6caa834eaaa1ebe100a9760baf9331aae567",
"secret_key": {
"founder_secret": "506b8eca4fef48a3acd2fc8df943a81e98f71e116ffb6011063d65f783b0f087",
"follower_secret": "9c6469da0ea992c1f3d4b635d61cb9d855279490cff6fc1024c58d293371097a",
"consumer_secret": "9b1b56f8be67d1f00b18c1822600df35cdb75d3137460126e5c1c7e85be4f09d",
"committer_secret": "b45982e7622c5ac0682565f9162f7096b3f11fac5d0647fdbf4bac2ca7afbf72"
"founder_secret": "4d05b965f821ea900ddd995dfa1b6caa834eaaa1ebe100a9760baf9331aae567",
"follower_secret": "4d05b965f821ea900ddd995dfa1b6caa834eaaa1ebe100a9760baf9331aae567",
"consumer_secret": "4d05b965f821ea900ddd995dfa1b6caa834eaaa1ebe100a9760baf9331aae567",
"committer_secret": "4d05b965f821ea900ddd995dfa1b6caa834eaaa1ebe100a9760baf9331aae567"
}
}
28 changes: 28 additions & 0 deletions eth/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
// 禁止双引号,只允许使用单引号和模板字符串.
"quotes": [
"error",
"single",
{
"allowTemplateLiterals": true
}
]
}
}
48 changes: 48 additions & 0 deletions eth/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,51 @@ typechain-types
cache
artifacts


node_modules
.env
coverage
coverage.json
typechain
typechain-types

# Hardhat files
cache
artifacts


node_modules
.env
coverage
coverage.json
typechain
typechain-types

# Hardhat files
cache
artifacts


node_modules
.env
coverage
coverage.json
typechain
typechain-types

# Hardhat files
cache
artifacts


node_modules
.env
coverage
coverage.json
typechain
typechain-types

# Hardhat files
cache
artifacts

30 changes: 30 additions & 0 deletions eth/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"overrides": [
{
"files": [
"*.js",
"*.ts"
],
"options": {
"singleQuote": true,
"semi": true,
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "always"
}
},
{
"files": "*.sol",
"options": {
"plugins": [
"prettier-plugin-solidity"
],
"parser": "solidity-parse",
"singleQuote": false,
"semi": true,
"trailingComma": "all",
"bracketSpacing": true
}
}
]
}
9 changes: 9 additions & 0 deletions eth/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "solhint:default",
"plugins": [
"prettier"
],
"rules": {
"max-line-length": "off"
}
}
13 changes: 13 additions & 0 deletions eth/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Sample Hardhat Project

This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract.

Try running some of the following tasks:

```shell
npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat run scripts/deploy.ts
```
100 changes: 100 additions & 0 deletions eth/contracts/IRandao.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// SPDX-License-Identifier: GPL-2.0
pragma solidity ^0.8.9;

// version 1.0
interface IRandao {
event LogCampaignAdded(
uint256 indexed campaignID,
address indexed from,
uint256 indexed bnum,
uint256 deposit,
uint16 commitBalkline,
uint16 commitDeadline,
uint256 bountypot
);

event LogFollow(
uint256 indexed CampaignId,
address indexed from,
uint256 bountypot
);

event LogCommit(
uint256 indexed CampaignId,
address indexed from,
bytes32 commitment
);
event LogReveal(
uint256 indexed CampaignId,
address indexed from,
uint256 secret
);

struct Participant {
uint256 secret;
bytes32 commitment;
uint256 reward;
bool revealed;
bool rewarded;
}

struct Consumer {
address caddr;
uint256 bountypot;
}

struct CampaignInfo {
uint256 bnum;
uint256 deposit;
uint16 commitBalkline;
uint16 commitDeadline;
uint256 random;
bool settled;
uint256 bountypot;
uint32 commitNum;
uint32 revealsNum;
}

struct Campaign {
uint256 bnum;
uint256 deposit;
uint16 commitBalkline;
uint16 commitDeadline;
uint256 random;
bool settled;
uint256 bountypot;
uint32 commitNum;
uint32 revealsNum;
mapping(address => Consumer) consumers;
mapping(address => Participant) participants;
mapping(bytes32 => bool) commitments;
}

function newCampaign(
uint256 _bnum,
uint256 _deposit,
uint16 _commitBalkline,
uint16 _commitDeadline
) external payable returns (uint256 _campaignID);

function getCampaign(
uint256 _campaignID
) external view returns (CampaignInfo memory);

function follow(uint256 _campaignID) external payable returns (bool);

function commit(uint256 _campaignID, bytes32 _hs) external payable;

// For test
function getCommitment(uint256 _campaignID) external view returns (bytes32);

function shaCommit(uint256 _s) external pure returns (bytes32);

function reveal(uint256 _campaignID, uint256 _s) external;

function getRandom(uint256 _campaignID) external returns (uint256);

function getMyBounty(uint256 _campaignID) external returns (uint256);

function refundBounty(uint256 _campaignID) external;
}
2 changes: 1 addition & 1 deletion eth/contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
pragma solidity ^0.8.0;
pragma solidity ^0.8.9;

contract Migrations {
address public owner;
Expand Down
Loading

0 comments on commit 1788d1b

Please sign in to comment.