forked from randao/randao
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
10,353 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "solhint:default", | ||
"plugins": [ | ||
"prettier" | ||
], | ||
"rules": { | ||
"max-line-length": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.