Skip to content

Instantly share code, notes, and snippets.

@apalepu23
apalepu23 / bankruptcy_and_liquidation_px_calc.ipynb
Created October 1, 2020 15:42
Bankruptcy and Liquidation Price Calculator
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@apalepu23
apalepu23 / contract-addresses.json
Last active September 5, 2020 01:42
Contract Addresses
{"42":{"fakeUSDT":"0x9a90c5f52642a60266d14708bbb880137c62cf4d","derivaDEXToken":"0xbdb154a3c2abd40b2f66a74c7afc49ded904cef9","derivaDEX":"0x09ea2fdfad884c43529b4637dd102fa2ae686834"},"1337":{"derivaDEX":"0x25b8fe1de9daf8ba351890744ff28cf7dfa8f5e3","governance":"0x48bacb9266a570d521063ef5dd96e61686dbe788","timelock":"0x0b1ba0af832d7c05fd64161e0db78e85978e8082","insuranceFund":"0x34d402f14d58e001d8efbe6585051bf9706aa064","ddx":"0x1dc4c1cefef38a777b15aa20260a54e584b16c48"}}
@apalepu23
apalepu23 / MillionairesProblem.js
Created June 11, 2019 14:25
Millionaires' Problem MillionairesProblem.js
// Imports - React
import React, { Component } from 'react';
// Imports - Redux
import { connect } from 'react-redux';
import { Field, reduxForm } from 'redux-form';
// Imports - Frameworks (Semantic-UI and Material-UI)
import { Message } from "semantic-ui-react";
import Grid from '@material-ui/core/Grid';
import Button from '@material-ui/core/Button';
import FormControl from "@material-ui/core/FormControl/FormControl";
@apalepu23
apalepu23 / App.js
Created June 11, 2019 14:15
Millionaires' Problem App.js
// Imports - React
import React, { Component } from "react";
// Imports - Redux
import connect from "react-redux/es/connect/connect";
// Imports - Frameworks (Semantic-UI and Material-UI)
import { Container, Message } from "semantic-ui-react";
import Paper from "@material-ui/core/Paper";
import { withStyles } from "@material-ui/core";
// Imports - Initialize Enigma
import getEnigmaInit from "../utils/getEnigmaInit.js";
@apalepu23
apalepu23 / index.js
Created June 11, 2019 07:59
Millionaires' Problem Redux Reducers
import { combineReducers} from 'redux';
import { reducer as formReducer } from 'redux-form';
// Responds to initializeEnigma action to save enigma-js client library object
const initializeEnigmaReducer = (enigma = null, action) => {
if (action.type === 'ENIGMA_INITIALIZED') {
return action.payload;
}
return enigma;
@apalepu23
apalepu23 / index.js
Created June 11, 2019 07:48
Millionaires' Problem Redux Actions
// Redux action for when enigma-js client library has been initialized
export const initializeEnigma = (enigma) => {
return {
type: 'ENIGMA_INITIALIZED',
payload: enigma
};
};
// Redux action for when web3 accounts have been initialized
export const initializeAccounts = (accounts) => {
@apalepu23
apalepu23 / test_millionaires_problem.js
Created June 7, 2019 21:08
Millionaires' Problem Test
const fs = require('fs');
const path = require('path');
const dotenv = require('dotenv');
const {Enigma, utils, eeConstants} = require('enigma-js/node');
var EnigmaContract;
if(typeof process.env.SGX_MODE === 'undefined' || (process.env.SGX_MODE != 'SW' && process.env.SGX_MODE != 'HW' )) {
console.log(`Error reading ".env" file, aborting....`);
process.exit();
} else if (process.env.SGX_MODE == 'SW') {
@apalepu23
apalepu23 / lib.rs
Last active June 6, 2019 22:25
Millionaires' Problem Enigma Secret Contract
// Built-In Attributes
#![no_std]
// Imports
extern crate eng_wasm;
extern crate eng_wasm_derive;
extern crate serde;
use eng_wasm::*;
use eng_wasm_derive::pub_interface;
@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
});
@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];