Skip to content

Instantly share code, notes, and snippets.

pragma solidity ^0.4.17;
contract MillionairesProblem {
// Stores # of millionaires that have joined and stated their net worths
uint public numMillionaires;
// Stores Millionaire structs (defined below)
Millionaire[] millionaires;
// Stores address of richest millionaire; set in callback function below
address public richestMillionaire;
const http = require("http");
const MillionairesProblemFactory = artifacts.require(
"MillionairesProblemFactory.sol"
);
module.exports = function(deployer) {
return (
deployer
.then(() => {
return new Promise((resolve, reject) => {
pragma solidity ^0.4.17;
import "./MillionairesProblem.sol";
contract MillionairesProblemFactory {
address public enigmaAddress;
// List of addresses for deployed MillionaireProblem instances
address[] public millionairesProblems;
constructor(address _enigmaAddress) public {
@apalepu23
apalepu23 / App.js
Last active September 6, 2018 16:05
import React, { Component } from "react";
import getContractInstance from "./utils/getContractInstance";
import EnigmaSetup from "./utils/getEnigmaSetup";
import millionairesProblemFactoryContractDefinition from "./contracts/MillionairesProblemFactory.json";
import millionairesProblemContractDefinition from "./contracts/MillionairesProblem.json";
import { Container, Message } from "semantic-ui-react";
import Header from "./Header";
import MillionairesProblemWrapper from "./MillionairesProblemWrapper";
import Paper from "@material-ui/core/Paper";
import "./App.css";
import React, { Component } from "react";
import PropTypes from "prop-types";
import { withStyles } from "@material-ui/core/styles";
import Button from "@material-ui/core/Button";
import { Message } from "semantic-ui-react";
import AddMillionaireDialog from "./AddMillionaireDialog";
const engUtils = require("./lib/enigma-utils");
// Specify the signature for the callable and callback functions, make sure there are NO spaces
const CALLABLE = "computeRichest(address[],uint[])";
const CALLBACK = "setRichestAddress(address)";
import React, { Component } from "react";
import PropTypes from "prop-types";
import { withStyles } from "@material-ui/core/styles";
import Button from "@material-ui/core/Button";
import Dialog from "@material-ui/core/Dialog";
import DialogActions from "@material-ui/core/DialogActions";
import DialogContent from "@material-ui/core/DialogContent";
import DialogContentText from "@material-ui/core/DialogContentText";
import DialogTitle from "@material-ui/core/DialogTitle";
import Input from "@material-ui/core/Input";
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@apalepu23
apalepu23 / Polls.js
Last active November 9, 2018 01:35
callable
// Specify signatures of callable/callback functions (with no spaces!)
const CALLABLE = "countVotes(uint,uint[],uint[])";
const CALLBACK = "updatePollStatus(uint,uint,uint)";
async enigmaTask(pollID) {
let poll = await this.props.voting.polls.call(pollID, {
from: this.props.enigmaSetup.accounts[this.props.curAccount],
gas: GAS
});
let pollCreator = poll[0];
@apalepu23
apalepu23 / Polls.js
Last active November 9, 2018 02:00
Callback
// onChange listener to trigger enigma task when poll has ended
async handleTimerEnd(pollID) {
const { polls } = this.state;
await this.enigmaTask(pollID);
const pollStatusUpdateEvent = this.props.voting.PollStatusUpdate();
pollStatusUpdateEvent.watch(async (error, result) => {
let pollStatus = await this.props.voting.getPollStatus.call(pollID, {
from: this.props.enigmaSetup.accounts[this.props.curAccount],
gas: GAS
});