├── .env
├── contracts.clevis
├── stop.sh
├── attach.sh
├── tests
├── fast.js
├── full.js
├── metamask.js
├── publish.js
├── version.js
├── compile.js
├── deploy.js
└── clevis.js
├── src
├── index.css
├── index.js
├── App.test.js
├── App.css
└── App.js
├── public
├── favicon.ico
├── manifest.json
└── index.html
├── run.sh
├── contracts
└── CommitReveal
│ ├── arguments.js
│ ├── dependencies.js
│ └── CommitReveal.sol
├── README.md
├── clevis.json
├── package.json
└── .gitignore
/.env:
--------------------------------------------------------------------------------
1 | SKIP_PREFLIGHT_CHECK=true
--------------------------------------------------------------------------------
/contracts.clevis:
--------------------------------------------------------------------------------
1 |
2 | CommitReveal
--------------------------------------------------------------------------------
/stop.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | docker stop clevis
3 |
--------------------------------------------------------------------------------
/attach.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | docker exec -ti clevis bash
3 |
--------------------------------------------------------------------------------
/tests/fast.js:
--------------------------------------------------------------------------------
1 | const clevis = require("./clevis.js")
2 | clevis.fast()
3 |
--------------------------------------------------------------------------------
/tests/full.js:
--------------------------------------------------------------------------------
1 | const clevis = require("./clevis.js")
2 | clevis.full()
3 |
--------------------------------------------------------------------------------
/tests/metamask.js:
--------------------------------------------------------------------------------
1 | const clevis = require("./clevis.js")
2 | clevis.metamask()
3 |
--------------------------------------------------------------------------------
/tests/publish.js:
--------------------------------------------------------------------------------
1 | const clevis = require("./clevis.js")
2 | clevis.publish()
3 |
--------------------------------------------------------------------------------
/tests/version.js:
--------------------------------------------------------------------------------
1 | const clevis = require("./clevis.js")
2 | clevis.version()
3 |
--------------------------------------------------------------------------------
/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | padding: 0;
4 | font-family: sans-serif;
5 | }
6 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/austintgriffith/commit-reveal/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | docker run -ti --rm --name clevis -p 3000:3000 -p 8545:8545 -v ${PWD}:/dapp austingriffith/clevis
3 |
--------------------------------------------------------------------------------
/tests/compile.js:
--------------------------------------------------------------------------------
1 | const clevis = require("./clevis.js")
2 | for(let c in clevis.contracts){
3 | clevis.compile(clevis.contracts[c])
4 | }
5 |
--------------------------------------------------------------------------------
/tests/deploy.js:
--------------------------------------------------------------------------------
1 | const clevis = require("./clevis.js")
2 | for(let c in clevis.contracts){
3 | clevis.deploy(clevis.contracts[c],0)
4 | }
5 |
--------------------------------------------------------------------------------
/contracts/CommitReveal/arguments.js:
--------------------------------------------------------------------------------
1 | /*
2 | Example of passing in a string to the constructor:
3 | module.exports = ["hello world"]
4 | */
5 |
6 | module.exports = []
7 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './index.css';
4 | import App from './App';
5 | ReactDOM.render(, document.getElementById('root'));
6 |
--------------------------------------------------------------------------------
/contracts/CommitReveal/dependencies.js:
--------------------------------------------------------------------------------
1 | /*
2 | const fs = require('fs');
3 | module.exports = {
4 | 'openzeppelin-solidity/contracts/ownership/Ownable.sol': fs.readFileSync('openzeppelin-solidity/contracts/ownership/Ownable.sol', 'utf8')
5 | }
6 | */
7 | module.exports = {}
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Commit Reveal Scheme on Ethereum
2 |
3 | [Read Full Article Here](https://medium.com/gitcoin/commit-reveal-scheme-on-ethereum-25d1d1a25428)
4 |
5 | [](https://youtu.be/7AbdpTWQ9nU)
6 |
--------------------------------------------------------------------------------
/src/App.test.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import App from './App';
4 |
5 | it('renders without crashing', () => {
6 | const div = document.createElement('div');
7 | ReactDOM.render(, div);
8 | ReactDOM.unmountComponentAtNode(div);
9 | });
10 |
--------------------------------------------------------------------------------
/src/App.css:
--------------------------------------------------------------------------------
1 |
2 | body {
3 | font-family: sans-serif;
4 | color:#888888;
5 | font-size:28px;
6 | font-weight:bold;
7 | background-color: #313131;
8 | }
9 | a {
10 | color:#aaaaaa;
11 | text-decoration: none;
12 | }
13 | a:visited {
14 | color:#999999;
15 | text-decoration: none;
16 | }
17 |
--------------------------------------------------------------------------------
/clevis.json:
--------------------------------------------------------------------------------
1 | {
2 | "provider": "http://localhost:8545",
3 | "gasprice": 2.5,
4 | "ethprice": 86.6791926108,
5 | "deploygas": 5500000,
6 | "xfergas": 1300000,
7 | "DEBUG": true,
8 | "USE_INFURA": false,
9 | "ROOT_FOLDER": "/Users/austingriffith/commit-reveal",
10 | "CRA_FOLDER": "./src",
11 | "TESTS_FOLDER": "tests",
12 | "CONTRACTS_FOLDER": "contracts"
13 | }
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | }
10 | ],
11 | "start_url": ".",
12 | "display": "standalone",
13 | "theme_color": "#000000",
14 | "background_color": "#ffffff"
15 | }
16 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "commit-reveal",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "clevis": "0.0.107",
7 | "dapparatus": "^1.0.46",
8 | "mocha": "^5.2.0",
9 | "react": "^16.6.3",
10 | "react-dom": "^16.6.3",
11 | "react-scripts": "2.1.1",
12 | "s3": "^4.4.0",
13 | "web3": "^1.0.0-beta.37"
14 | },
15 | "scripts": {
16 | "start": "react-scripts start",
17 | "build": "react-scripts build",
18 | "test": "react-scripts test",
19 | "eject": "react-scripts eject"
20 | },
21 | "eslintConfig": {
22 | "extends": "react-app"
23 | },
24 | "browserslist": [
25 | ">0.2%",
26 | "not dead",
27 | "not ie <= 11",
28 | "not op_mini all"
29 | ]
30 | }
31 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | src/contracts/*
2 | deploy.network
3 | aws.json
4 | backend/redisdata
5 | accounts.json
6 | **.DS_*
7 | openzeppelin-solidity
8 | zeppelin-solidity
9 | package-lock.json
10 | *.log
11 | *.ens
12 | */*/*.abi
13 | */*/*.bytecode
14 | */*/*.address
15 | */*/*.run.xml
16 | */*/*.log.*
17 | */*/*.blockNumber
18 | */*.abi
19 | */*.bytecode
20 | */*.bib
21 | */*.address
22 | */*.run.xml
23 | */*.log.*
24 | */*.blockNumber
25 | */.clevis
26 | */*/.clevis
27 | */node_modules
28 | /node_modules
29 | public/reload.txt
30 |
31 | **/*.blockNumber
32 | **/*.head.address
33 | **/*.previous.address
34 | **/*.compiled
35 | **/*.bytecode
36 | **/*.abi
37 | **/*.address
38 | src/contracts
39 | deploy.log
40 | public/reload.txt
41 | geth.log
42 | react.log
43 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
44 |
45 | # dependencies
46 | /node_modules
47 | /.pnp
48 | .pnp.js
49 |
50 | # testing
51 | /coverage
52 |
53 | # production
54 | /build
55 |
56 | # misc
57 | .DS_Store
58 | .env.local
59 | .env.development.local
60 | .env.test.local
61 | .env.production.local
62 |
63 | npm-debug.log*
64 | yarn-debug.log*
65 | yarn-error.log*
66 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
22 | React App
23 |
24 |
25 |
28 |
29 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/contracts/CommitReveal/CommitReveal.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.24;
2 |
3 | contract CommitReveal {
4 |
5 | uint8 public max = 100;
6 |
7 | constructor() public { }
8 |
9 | struct Commit {
10 | bytes32 commit;
11 | uint64 block;
12 | bool revealed;
13 | }
14 |
15 | mapping (address => Commit) public commits;
16 |
17 | function commit(bytes32 dataHash) public {
18 | commits[msg.sender].commit = dataHash;
19 | commits[msg.sender].block = uint64(block.number);
20 | commits[msg.sender].revealed = false;
21 | emit CommitHash(msg.sender,commits[msg.sender].commit,commits[msg.sender].block);
22 | }
23 | event CommitHash(address sender, bytes32 dataHash, uint64 block);
24 |
25 | function reveal(bytes32 revealHash) public {
26 | //make sure it hasn't been revealed yet and set it to revealed
27 | require(commits[msg.sender].revealed==false,"CommitReveal::reveal: Already revealed");
28 | commits[msg.sender].revealed=true;
29 | //require that they can produce the committed hash
30 | require(getHash(revealHash)==commits[msg.sender].commit,"CommitReveal::reveal: Revealed hash does not match commit");
31 | //require that the block number is greater than the original block
32 | require(uint64(block.number)>commits[msg.sender].block,"CommitReveal::reveal: Reveal and commit happened on the same block");
33 | //require that no more than 250 blocks have passed
34 | require(uint64(block.number)<=commits[msg.sender].block+250,"CommitReveal::reveal: Revealed too late");
35 | //get the hash of the block that happened after they committed
36 | bytes32 blockHash = blockhash(commits[msg.sender].block);
37 | //hash that with their reveal that so miner shouldn't know and mod it with some max number you want
38 | uint8 random = uint8(keccak256(abi.encodePacked(blockHash,revealHash)))%max;
39 | emit RevealHash(msg.sender,revealHash,random);
40 | }
41 | event RevealHash(address sender, bytes32 revealHash, uint8 random);
42 |
43 | function getHash(bytes32 data) public view returns(bytes32){
44 | return keccak256(abi.encodePacked(address(this), data));
45 | }
46 |
47 | function revealAnswer(bytes32 answer,bytes32 salt) public {
48 | //make sure it hasn't been revealed yet and set it to revealed
49 | require(commits[msg.sender].revealed==false,"CommitReveal::revealAnswer: Already revealed");
50 | commits[msg.sender].revealed=true;
51 | //require that they can produce the committed hash
52 | require(getSaltedHash(answer,salt)==commits[msg.sender].commit,"CommitReveal::revealAnswer: Revealed hash does not match commit");
53 | emit RevealAnswer(msg.sender,answer,salt);
54 | }
55 | event RevealAnswer(address sender, bytes32 answer, bytes32 salt);
56 |
57 | function getSaltedHash(bytes32 data,bytes32 salt) public view returns(bytes32){
58 | return keccak256(abi.encodePacked(address(this), data, salt));
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react';
2 | import './App.css';
3 | import { Metamask, Gas, ContractLoader, Transactions, Events, Scaler, Blockie, Address, Button } from "dapparatus"
4 | import Web3 from 'web3';
5 |
6 | class App extends Component {
7 | constructor(props) {
8 | super(props);
9 | this.state = {
10 | web3: false,
11 | account: false,
12 | gwei: 4,
13 | doingTransaction: false,
14 | }
15 | }
16 | async handleInput(e){
17 | let update = {}
18 | update[e.target.name] = e.target.value
19 | if(update['pres']){
20 | let bytes = this.state.web3.utils.utf8ToHex(update['pres'])
21 | update.salt = this.state.web3.utils.sha3(""+Math.random())
22 | update.hash = await this.state.contracts.CommitReveal.getSaltedHash(bytes,update.salt).call()
23 | }
24 | this.setState(update)
25 | }
26 | render() {
27 | let {web3,account,contracts,tx,gwei,block,avgBlockTime,etherscan} = this.state
28 | let connectedDisplay = []
29 | let contractsDisplay = []
30 | if(web3){
31 | connectedDisplay.push(
32 | {
35 | console.log("Gas price update:",state)
36 | this.setState(state,()=>{
37 | console.log("GWEI set:",this.state)
38 | })
39 | }}
40 | />
41 | )
42 | connectedDisplay.push(
43 | {return require(`${__dirname}/${path}`)}}
48 | onReady={(contracts,customLoader)=>{
49 | console.log("contracts loaded",contracts)
50 | this.setState({contracts:contracts},async ()=>{
51 | console.log("Contracts Are Ready:",this.state.contracts)
52 | })
53 | }}
54 | />
55 | )
56 | connectedDisplay.push(
57 | {
67 | console.log("Transactions component is ready:",state)
68 | this.setState(state)
69 | }}
70 | onReceipt={(transaction,receipt)=>{
71 | // this is one way to get the deployed contract address, but instead I'll switch
72 | // to a more straight forward callback system above
73 | console.log("Transaction Receipt",transaction,receipt)
74 | }}
75 | />
76 | )
77 | if(contracts){
78 |
79 | let reveals = []
80 | for(let e in this.state.revealEvents){
81 | reveals.push(
82 |
83 | {this.state.revealEvents[e].random}
84 |
85 | )
86 | }
87 |
88 | let answers = []
89 | for(let e in this.state.revealedAnswers){
90 | answers.push(
91 |
92 |
96 |
97 | {this.state.web3.utils.hexToUtf8(this.state.revealedAnswers[e].answer)}
98 |
99 |
100 | )
101 | }
102 |
103 | contractsDisplay.push(
104 |
105 |
111 |
123 |
{
129 | console.log("EVENT DATA:",eventData)
130 | this.setState({commitEvents:allEvents})
131 | }}
132 | />
133 |
143 | {
149 | console.log("EVENT DATA:",eventData)
150 | this.setState({revealEvents:allEvents})
151 | }}
152 | />
153 | {reveals}
154 |
155 | Who was the 42nd President of the United States?
156 |
160 |
161 | Salt: {this.state.salt}
162 |
163 |
164 | Hash: {this.state.hash}
165 |
166 |
175 |
185 | {
191 | console.log("EVENT DATA:",eventData)
192 | this.setState({revealedAnswers:allEvents})
193 | }}
194 | />
195 | {answers}
196 |
197 | )
198 | }
199 | }
200 | return (
201 |
202 | {
205 | console.log("metamask state update:",state)
206 | if(state.web3Provider) {
207 | state.web3 = new Web3(state.web3Provider)
208 | this.setState(state)
209 | }
210 | }}
211 | />
212 | {connectedDisplay}
213 | {contractsDisplay}
214 |
215 | );
216 | }
217 | }
218 |
219 | export default App;
220 |
--------------------------------------------------------------------------------
/tests/clevis.js:
--------------------------------------------------------------------------------
1 | const clevis = require("clevis")
2 | const colors = require('colors')
3 | const chai = require("chai")
4 | const HDWalletProvider = require("truffle-hdwallet-provider")
5 | const assert = chai.assert
6 | const expect = chai.expect;
7 | const should = chai.should();
8 |
9 | const fs = require('fs')
10 | const Web3 = require('web3')
11 | const clevisConfig = JSON.parse(fs.readFileSync("clevis.json").toString().trim())
12 | const web3 = new Web3(
13 | clevisConfig.USE_INFURA ?
14 | new HDWalletProvider(
15 | process.env.mnemonic,
16 | clevisConfig.provider) :
17 | new Web3.providers.HttpProvider(clevisConfig.provider)
18 | );
19 |
20 | //console.log('clevisConfig.provider', clevisConfig.provider);
21 |
22 | function localContractAddress(contract){
23 | return fs.readFileSync(clevisConfig.CONTRACTS_FOLDER+"/"+contract+ "/" + contract + ".address").toString().trim()
24 | }
25 | function localContractAbi(contract){
26 | return JSON.parse(fs.readFileSync(clevisConfig.CONTRACTS_FOLDER+"/"+contract+ "/"+ contract +".abi").toString().trim())
27 | }
28 | function printTxResult(result){
29 | if(!result||!result.transactionHash){
30 | console.log("ERROR".red,"MISSING TX HASH".yellow)
31 | }else{
32 | console.log(tab,result.transactionHash.gray,(""+result.gasUsed).yellow)
33 | }
34 | }
35 | function bigHeader(str){
36 | return "########### "+str+" "+Array(128-str.length).join("#")
37 | }
38 | function rand(min, max) {
39 | return Math.floor( Math.random() * (max - min) + min );
40 | }
41 | function getPaddedHexFromNumber(num,digits){
42 | let hexIs = web3.utils.numberToHex(num).replace("0x","");
43 | while(hexIs.length{
56 | describe('#reload() ', function() {
57 | it('should force browser to reload', async function() {
58 | fs.writeFileSync(clevisConfig.CRA_FOLDER + "/../public/reload.txt",Date.now());
59 | });
60 | });
61 | },
62 | version:()=>{
63 | describe('#version() ', function() {
64 | it('should get version', async function() {
65 | this.timeout(90000)
66 | const result = await clevis("version")
67 | console.log(result)
68 | });
69 | });
70 | },
71 | blockNumber:()=>{
72 | describe('#blockNumber() ', function() {
73 | it('should get blockNumber', async function() {
74 | this.timeout(90000)
75 | const result = await clevis("blockNumber")
76 | console.log(result)
77 | });
78 | });
79 | },
80 | compile:(contract)=>{
81 | describe('#compile() '+contract.magenta, function() {
82 | it('should compile '+contract.magenta+' contract to bytecode', async function() {
83 | this.timeout(90000)
84 | const result = await clevis("compile",contract)
85 | console.log(result)
86 | assert(Object.keys(result.contracts).length>0, "No compiled contacts found.")
87 | let count = 0
88 | for(let c in result.contracts){
89 | console.log("\t\t"+"contract "+c.blue+": ",result.contracts[c].bytecode.length)
90 | if(count++==0){
91 | assert(result.contracts[c].bytecode.length > 1, "No bytecode for contract "+c)
92 | }
93 | }
94 | });
95 | });
96 | },
97 | deploy:(contract,accountindex)=>{
98 | describe('#deploy() '+contract.magenta, function() {
99 | it('should deploy '+contract.magenta+' as account '+accountindex, async function() {
100 | this.timeout(360000)
101 | const result = await clevis("deploy",contract,accountindex)
102 | printTxResult(result)
103 | console.log(tab+"Address: "+result.contractAddress.blue)
104 | assert(result.contractAddress)
105 | });
106 | });
107 | },
108 |
109 | publish:()=>{
110 | describe('#publish() ', function() {
111 | it('should inject contract address and abi into web app', async function() {
112 | this.timeout(120000)
113 | const fs = require("fs")
114 | console.log(tab,"Publishing to CRA folder",clevisConfig.CRA_FOLDER)
115 | if(!fs.existsSync(clevisConfig.CRA_FOLDER)){
116 | fs.mkdirSync(clevisConfig.CRA_FOLDER);
117 | }
118 | if(!fs.existsSync(clevisConfig.CRA_FOLDER + "/contracts")){
119 | fs.mkdirSync(clevisConfig.CRA_FOLDER + "/contracts");
120 | }
121 | if(!fs.existsSync(clevisConfig.CONTRACTS_FOLDER)){
122 | fs.mkdirSync(clevisConfig.CONTRACTS_FOLDER);
123 | }
124 | for(let c in module.exports.contracts){
125 | let thisContract = module.exports.contracts[c]
126 | console.log(tab,thisContract.magenta)
127 | let address = fs.readFileSync(clevisConfig.CONTRACTS_FOLDER + "/" + thisContract+"/"+thisContract+".address").toString().trim()
128 | console.log(tab,"ADDRESS:",address.blue)
129 | assert(address,"No Address!?")
130 | fs.writeFileSync(clevisConfig.CRA_FOLDER + "/contracts/"+thisContract+".address.js","module.exports = \""+address+"\"");
131 | let blockNumber = fs.readFileSync(clevisConfig.CONTRACTS_FOLDER +"/" + thisContract + "/"+thisContract+".blockNumber").toString().trim()
132 | console.log(tab,"blockNumber:",blockNumber.blue)
133 | assert(blockNumber,"No blockNumber!?")
134 | fs.writeFileSync(clevisConfig.CRA_FOLDER + "/contracts/" + thisContract+".blocknumber.js","module.exports = \""+blockNumber+"\"");
135 | let abi = fs.readFileSync(clevisConfig.CONTRACTS_FOLDER +"/" + thisContract +"/"+thisContract+".abi").toString().trim()
136 | fs.writeFileSync(clevisConfig.CRA_FOLDER + "/contracts/" + thisContract+".abi.js","module.exports = "+abi);
137 | let bytecode = fs.readFileSync(clevisConfig.CONTRACTS_FOLDER + "/" + thisContract +"/"+thisContract+".bytecode").toString().trim()
138 | fs.writeFileSync(clevisConfig.CRA_FOLDER + "/contracts/" + thisContract+".bytecode.js","module.exports = \""+bytecode+"\"");
139 | }
140 | fs.writeFileSync(clevisConfig.CRA_FOLDER + "/contracts/contracts.js","module.exports = "+JSON.stringify(module.exports.contracts));
141 | module.exports.reload()
142 | });
143 | });
144 | },
145 | metamask:()=>{
146 | describe('#transfer() ', function() {
147 | it('should give metamask account some ether or tokens to test', async function() {
148 | this.timeout(600000)
149 | let result = await clevis("sendTo","0.1","0","0x2a906694D15Df38F59e76ED3a5735f8AAbccE9cb")///<<<-------- change this to your metamask accounts
150 | printTxResult(result)
151 | result = await clevis("sendTo","0.1","0","0x5f19cefc9c9d1bc63f9e4d4780493ff5577d238b")///<<<-------- change this to your metamask accounts
152 | printTxResult(result)
153 | //here is an example of running a funtion from within this object:
154 | //module.exports.mintTo("Greens",0,"0x2a906694d15df38f59e76ed3a5735f8aabcce9cb",20)
155 | //view more examples here: https://github.com/austintgriffith/galleass/blob/master/tests/galleass.js
156 | });
157 | });
158 | },
159 |
160 |
161 | ////----------------------------------------------------------------------------///////////////////
162 |
163 |
164 | //// ADD YOUR TESTS HERE <<<<<<<<--------------------------------
165 |
166 |
167 | ////----------------------------------------------------------------------------///////////////////
168 |
169 |
170 | full:()=>{
171 | describe(bigHeader('COMPILE'), function() {
172 | it('should compile all contracts', async function() {
173 | this.timeout(6000000)
174 | const result = await clevis("test","compile")
175 | console.log('result', result);
176 | assert(result==0,"deploy ERRORS")
177 | });
178 | });
179 | describe(bigHeader('FAST'), function() {
180 | it('should run the fast test (everything after compile)', async function() {
181 | this.timeout(6000000)
182 | const result = await clevis("test","fast")
183 | assert(result==0,"fast ERRORS")
184 | });
185 | });
186 | },
187 |
188 | fast:()=>{
189 | describe(bigHeader('DEPLOY'), function() {
190 | it('should deploy all contracts', async function() {
191 | this.timeout(6000000)
192 | const result = await clevis("test","deploy")
193 | assert(result==0,"deploy ERRORS")
194 | });
195 | });
196 | describe(bigHeader('METAMASK'), function() {
197 | it('should deploy all contracts', async function() {
198 | this.timeout(6000000)
199 | const result = await clevis("test","metamask")
200 | assert(result==0,"metamask ERRORS")
201 | });
202 | });
203 | describe(bigHeader('PUBLISH'), function() {
204 | it('should publish all contracts', async function() {
205 | this.timeout(6000000)
206 | const result = await clevis("test","publish")
207 | assert(result==0,"publish ERRORS")
208 | });
209 | });
210 |
211 | },
212 |
213 | }
214 |
215 | checkContractDeployment = async (contract)=>{
216 | const localAddress = localContractAddress(contract)
217 | const address = await clevis("contract","getContract","Example",web3.utils.fromAscii(contract))
218 | console.log(tab,contract.blue+" contract address is "+(localAddress+"").magenta+" deployed as: "+(address+"").magenta)
219 | assert(localAddress==address,contract.red+" isn't deployed correctly!?")
220 | return address
221 | }
222 |
223 |
224 |
225 | //example helper function
226 | /*
227 | makeSureContractHasTokens = async (contract,contractAddress,token)=>{
228 | const TokenBalance = await clevis("contract","balanceOf",token,contractAddress)
229 | console.log(tab,contract.magenta+" has "+TokenBalance+" "+token)
230 | assert(TokenBalance>0,contract.red+" doesn't have any "+token.red)
231 | }
232 |
233 | view more examples here: https://github.com/austintgriffith/galleass/blob/master/tests/galleass.js
234 |
235 | */
236 |
--------------------------------------------------------------------------------