(Feature) Add memo, change Sokol addresses

This commit is contained in:
Roman Storm 2018-01-19 14:59:07 -08:00
parent 236630fe23
commit 7fd6bbd45d
13 changed files with 266 additions and 106 deletions

View File

@ -689,6 +689,18 @@ button {
margin-left: 0;
margin-right: 15px; } }
textarea {
border: 1px solid #e5eef9;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
overflow: auto;
outline: none;
border-radius: 3px;
width: 100%; }
textarea:focus {
border-color: #08b3f2; }
.ballots-about {
font-size: 0; }
@media screen and (max-width: 768px) {

View File

@ -119,3 +119,18 @@
}
}
}
textarea {
border: 1px solid #e5eef9;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
overflow: auto;
outline: none;
border-radius: 3px;
width: 100%;
&:focus {
border-color: #08b3f2;
}
}

View File

@ -33,6 +33,7 @@ export class BallotCard extends React.Component {
@observable progress;
@observable totalVoters;
@observable isFinalized;
@observable memo;
@computed get finalizeButtonDisplayName() {
const displayName = this.isFinalized ? "Finalized" : "Finalize ballot";
@ -176,6 +177,13 @@ export class BallotCard extends React.Component {
return isActive;
}
getMemo = async () => {
const { contractsStore, id, votingType } = this.props;
let memo = await this.getContract(contractsStore, votingType).getMemo(id);
this.memo = memo;
return memo;
}
vote = async ({choice}) => {
if (this.timeToStart.val > 0) {
swal("Warning!", messages.ballotIsNotActiveMsg(this.timeTo.displayValue), "warning");
@ -278,6 +286,7 @@ export class BallotCard extends React.Component {
this.getTotalVoters();
this.getProgress();
this.getIsFinalized();
this.getMemo();
}
componentDidMount() {
@ -361,6 +370,9 @@ export class BallotCard extends React.Component {
<div className="info">
Minimum {threshold} from {contractsStore.validatorsLength} validators is required to pass the proposal
</div>
<div className="info">
{this.memo}
</div>
<hr />
<div className="ballots-footer">
<div className="ballots-footer-left">

View File

@ -102,7 +102,8 @@ export class NewBallot extends React.Component {
affectedKeyType: ballotStore.ballotKeys.keyType,
miningKey: ballotStore.ballotKeys.miningKey.value,
ballotType: ballotStore.ballotKeys.keysBallotType,
sender: contractsStore.votingKey
sender: contractsStore.votingKey,
memo: ballotStore.memo
};
let method = contractsStore.votingToChangeKeys.createVotingForKeys(inputToMethod);
return method;
@ -114,7 +115,8 @@ export class NewBallot extends React.Component {
startTime: curDateInSeconds,
endTime: ballotStore.endTimeUnix,
proposedValue: ballotStore.ballotMinThreshold.proposedValue,
sender: contractsStore.votingKey
sender: contractsStore.votingKey,
memo: ballotStore.memo
};
let method = contractsStore.votingToChangeMinThreshold.createBallotToChangeThreshold(inputToMethod);
return method;
@ -127,7 +129,8 @@ export class NewBallot extends React.Component {
endTime: ballotStore.endTimeUnix,
proposedValue: ballotStore.ballotProxy.proposedAddress,
contractType: ballotStore.ballotProxy.contractType,
sender: contractsStore.votingKey
sender: contractsStore.votingKey,
memo: ballotStore.memo
};
let method = contractsStore.votingToChangeProxy.createBallotToChangeProxyAddress(inputToMethod);
return method;
@ -260,6 +263,15 @@ export class NewBallot extends React.Component {
{validator}
{keysTypes}
{metadata}
<div className="form-el">
<label>Description of the ballot</label>
<div>
<textarea rows="4"
value={ballotStore.memo}
onChange={e => ballotStore.setMemo(e)}
></textarea>
</div>
</div>
<div className="new-form-footer">
<div className="info">
Minimum {minThreshold} from {contractsStore.validatorsLength} validators required to pass the proposal<br />

View File

@ -11,8 +11,8 @@ export default class VotingToChangeKeys {
}
//setters
createVotingForKeys({startTime, endTime, affectedKey, affectedKeyType, miningKey, ballotType, sender}) {
return this.votingToChangeKeysInstance.methods.createVotingForKeys(startTime, endTime, affectedKey, affectedKeyType, miningKey, ballotType).send({from: sender});
createVotingForKeys({startTime, endTime, affectedKey, affectedKeyType, miningKey, ballotType, sender, memo}) {
return this.votingToChangeKeysInstance.methods.createVotingForKeys(startTime, endTime, affectedKey, affectedKeyType, miningKey, ballotType, memo).send({from: sender});
}
vote(_id, choice, sender) {
@ -76,6 +76,10 @@ export default class VotingToChangeKeys {
return this.votingToChangeKeysInstance.methods.getMiningByVotingKey(_votingKey).call();
}
getMemo(_id) {
return this.votingToChangeKeysInstance.methods.getMemo(_id).call();
}
async getValidatorActiveBallots(_votingKey) {
let miningKey;
try {

View File

@ -11,8 +11,8 @@ export default class VotingToChangeMinThreshold {
}
//setters
createBallotToChangeThreshold({startTime, endTime, proposedValue, sender}) {
return this.votingToChangeMinThresholdInstance.methods.createBallotToChangeThreshold(startTime, endTime, proposedValue).send({from: sender})
createBallotToChangeThreshold({startTime, endTime, proposedValue, sender, memo}) {
return this.votingToChangeMinThresholdInstance.methods.createBallotToChangeThreshold(startTime, endTime, proposedValue, memo).send({from: sender})
}
vote(_id, choice, sender) {
@ -64,6 +64,10 @@ export default class VotingToChangeMinThreshold {
return this.votingToChangeMinThresholdInstance.methods.getMiningByVotingKey(_votingKey).call();
}
getMemo(_id) {
return this.votingToChangeMinThresholdInstance.methods.getMemo(_id).call();
}
async getValidatorActiveBallots(_votingKey) {
let miningKey;
try {

View File

@ -11,8 +11,8 @@ export default class VotingToChangeProxy {
}
//setters
createBallotToChangeProxyAddress({startTime, endTime, proposedValue, contractType, sender}) {
return this.votingToChangeProxyInstance.methods.createBallotToChangeProxyAddress(startTime, endTime, proposedValue, contractType).send({from: sender})
createBallotToChangeProxyAddress({startTime, endTime, proposedValue, contractType, sender, memo}) {
return this.votingToChangeProxyInstance.methods.createBallotToChangeProxyAddress(startTime, endTime, proposedValue, contractType, memo).send({from: sender})
}
vote(_id, choice, sender) {
@ -64,6 +64,10 @@ export default class VotingToChangeProxy {
return this.votingToChangeProxyInstance.methods.getContractType(_id).call();
}
getMemo(_id) {
return this.votingToChangeProxyInstance.methods.getMemo(_id).call();
}
getMiningByVotingKey(_votingKey) {
return this.votingToChangeProxyInstance.methods.getMiningByVotingKey(_votingKey).call();
}

View File

@ -1,12 +1,13 @@
// const local = {
// VOTING_TO_CHANGE_KEYS_ADDRESS: '0x758492834ed6454f41d6d3d6b73d6e46d4555429',
// VOTING_TO_CHANGE_MIN_THRESHOLD: '0xcbf043db3498b5064bd62341be0c0e3fb0344b1b',
// VOTING_TO_CHANGE_PROXY: '0xcb3f870269a3f7215eb87d9548ee5b7eff6396dd',
// BALLOTS_STORAGE_ADDRESS: '0x144947d78b932ea0dff14d75e1f7cd1b2f131426',
// METADATA_ADDRESS: '0x3111c94b9243a8a99d5a867e00609900e437e2c0',
// VOTING_TO_CHANGE_KEYS_ADDRESS: '0xecdbe3937cf6ff27f70480855cfe03254f915b48',
// VOTING_TO_CHANGE_MIN_THRESHOLD: '0x5ae30d4c8892292e0d8164f87a2e12dff9dc99e1',
// VOTING_TO_CHANGE_PROXY: '0x6c221df3695ac13a7f9366568ec069c353d273b8',
// BALLOTS_STORAGE_ADDRESS: '0x5d6573e62e3688e40c1fc36e01b155fb0006f432',
// METADATA_ADDRESS: '0x93eba9d9de66133fcde35775e9da593edd59a4e3',
// POA_ADDRESS: '0xf472e0e43570b9afaab67089615080cf7c20018d',
// }
const CORE_ADDRESSES = {
VOTING_TO_CHANGE_KEYS_ADDRESS: '0x49df4ec19243263e5db22da5865b4f482b8323a0',
VOTING_TO_CHANGE_MIN_THRESHOLD: '0x8829ebe113535826e8af17ed51f83755f675789a',
@ -17,12 +18,12 @@ const CORE_ADDRESSES = {
}
const SOKOL_ADDRESSES = {
VOTING_TO_CHANGE_KEYS_ADDRESS: '0xBDa88aCf72E635C892c6fc85EDf4cE48bfB40e89',
VOTING_TO_CHANGE_MIN_THRESHOLD: '0xEcE2a66ceb8438BFe20a08DB2Ec8Fb65E6Ee8DbF',
VOTING_TO_CHANGE_PROXY: '0xAF7EA5AD4301aABa668766de4dCfe65F8889f2eb',
BALLOTS_STORAGE_ADDRESS: '0xED2F95c9785E27d4b0b8BdF5c15661b5B07a07Cb',
METADATA_ADDRESS: '0xCDC628C303430bb45f034aF8F0b6A6177Dbc4119',
POA_ADDRESS: '0xf5cE3f5D0366D6ec551C74CCb1F67e91c56F2e34',
VOTING_TO_CHANGE_KEYS_ADDRESS: '0xc40cdf254a4a35498aa84f35e9842c110729a2a0',
VOTING_TO_CHANGE_MIN_THRESHOLD: '0x700db8ba3128087f3b23f60de4bc3179bafa467d',
VOTING_TO_CHANGE_PROXY: '0x0aa4a75549757a90f62f88b3b96b69bead2db0ff',
BALLOTS_STORAGE_ADDRESS: '0x27e7d2572aa37bec2ed30795f2fabccda4781f86',
METADATA_ADDRESS: '0x1ce9ad5614d3e00b88affdfa64e65e52f2e4e0f4',
POA_ADDRESS: '0x03048F666359CFD3C74a1A5b9a97848BF71d5038',
}
module.exports = (netId) => {

View File

@ -234,6 +234,25 @@
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_id",
"type": "uint256"
}
],
"name": "getMemo",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
@ -284,40 +303,6 @@
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_startTime",
"type": "uint256"
},
{
"name": "_endTime",
"type": "uint256"
},
{
"name": "_affectedKey",
"type": "address"
},
{
"name": "_affectedKeyType",
"type": "uint256"
},
{
"name": "_miningKey",
"type": "address"
},
{
"name": "_ballotType",
"type": "uint256"
}
],
"name": "createVotingForKeys",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
@ -356,6 +341,44 @@
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_startTime",
"type": "uint256"
},
{
"name": "_endTime",
"type": "uint256"
},
{
"name": "_affectedKey",
"type": "address"
},
{
"name": "_affectedKeyType",
"type": "uint256"
},
{
"name": "_miningKey",
"type": "address"
},
{
"name": "_ballotType",
"type": "uint256"
},
{
"name": "memo",
"type": "string"
}
],
"name": "createVotingForKeys",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
@ -660,6 +683,10 @@
{
"name": "creator",
"type": "address"
},
{
"name": "memo",
"type": "string"
}
],
"payable": false,
@ -743,4 +770,4 @@
"name": "BallotCreated",
"type": "event"
}
]
]

View File

@ -13,6 +13,32 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_startTime",
"type": "uint256"
},
{
"name": "_endTime",
"type": "uint256"
},
{
"name": "_proposedValue",
"type": "uint256"
},
{
"name": "memo",
"type": "string"
}
],
"name": "createBallotToChangeThreshold",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
@ -173,6 +199,25 @@
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_id",
"type": "uint256"
}
],
"name": "getMemo",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
@ -192,28 +237,6 @@
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_startTime",
"type": "uint256"
},
{
"name": "_endTime",
"type": "uint256"
},
{
"name": "_proposedValue",
"type": "uint256"
}
],
"name": "createBallotToChangeThreshold",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
@ -525,6 +548,10 @@
{
"name": "creator",
"type": "address"
},
{
"name": "memo",
"type": "string"
}
],
"payable": false,
@ -608,4 +635,4 @@
"name": "BallotCreated",
"type": "event"
}
]
]

View File

@ -88,32 +88,6 @@
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_startTime",
"type": "uint256"
},
{
"name": "_endTime",
"type": "uint256"
},
{
"name": "_proposedValue",
"type": "address"
},
{
"name": "_contractType",
"type": "uint8"
}
],
"name": "createBallotToChangeProxyAddress",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
@ -147,6 +121,36 @@
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_startTime",
"type": "uint256"
},
{
"name": "_endTime",
"type": "uint256"
},
{
"name": "_proposedValue",
"type": "address"
},
{
"name": "_contractType",
"type": "uint8"
},
{
"name": "memo",
"type": "string"
}
],
"name": "createBallotToChangeProxyAddress",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
@ -199,6 +203,25 @@
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_id",
"type": "uint256"
}
],
"name": "getMemo",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
@ -552,6 +575,10 @@
{
"name": "creator",
"type": "address"
},
{
"name": "memo",
"type": "string"
}
],
"payable": false,
@ -635,4 +662,4 @@
"name": "BallotCreated",
"type": "event"
}
]
]

View File

@ -20,6 +20,11 @@ const routingStore = new RouterStore();
const stores = { commonStore, contractsStore, ballotStore, ballotsStore, validatorStore, routing: routingStore };
const history = syncHistoryWithStore(browserHistory, routingStore);
function generateElement(msg){
let errorNode = document.createElement("div");
errorNode.innerHTML = `${msg}`;
return errorNode;
}
class AppMainRouter extends Component {
constructor(props) {
@ -49,10 +54,12 @@ class AppMainRouter extends Component {
console.log("miningKey", contractsStore.miningKey);
commonStore.hideLoading();
}).catch((error) => {
console.error(error.message)
commonStore.hideLoading();
swal({
title: 'Error',
text: error.message,
html: generateElement(error.message),
icon: 'error',
type: 'error'
});
});

View File

@ -31,6 +31,7 @@ class BallotStore {
@observable ballotKeys;
@observable ballotMinThreshold;
@observable ballotProxy;
@observable memo;
constructor() {
@ -53,6 +54,7 @@ class BallotStore {
proposedAddress: "",
contractType: ""
};
this.memo = "";
}
@computed get endTimeUnix() {
@ -134,6 +136,12 @@ class BallotStore {
this.ballotKeys.miningKey = value;
console.log("ballot mining key", toJS(value));
}
@action("Set ballot memo")
setMemo(e) {
console.log("memo", this.memo);
this.memo = e.target.value;
}
}
const ballotStore = new BallotStore();