Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hayesgm committed Jun 6, 2019
0 parents commit 4b4cb6e
Show file tree
Hide file tree
Showing 26 changed files with 9,167 additions and 0 deletions.
1 change: 1 addition & 0 deletions .build/test/contracts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"contracts":{"contracts/Oracle.sol:Oracle":{"abi":"[{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"}]","bin":"608060405234801561001057600080fd5b5061013c806100206000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806306fdde0314602d575b600080fd5b60336047565b604051603e9190609f565b60405180910390f35b60408051808201909152600e81526d7a6520636f6f6c206f7261636c6560901b602082015290565b600060788260b5565b6080818560b9565b9350608e81856020860160c2565b60958160ef565b9093019392505050565b6020808252810160ae8184606f565b9392505050565b5190565b90815260200190565b60005b8381101560db57818101518382015260200160c5565b8381111560e9576000848401525b50505050565b601f01601f19169056fea365627a7a7230582025d9bc767385b3c8cd621a324dcfeb9da7bb22c684cd44e6f6e027d684762e7e6c6578706572696d656e74616cf564736f6c63430005090040"}},"version":"0.5.9+commit.c68bc34e.Darwin.appleclang"}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*node_modules*
16 changes: 16 additions & 0 deletions .soliumrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "solium:recommended",
"plugins": [
"security"
],
"rules": {
"quotes": [
"error",
"double"
],
"indentation": [
"error",
4
]
}
}
35 changes: 35 additions & 0 deletions .tsbuilt/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const web3_1 = __importDefault(require("web3"));
const ganache_core_1 = __importDefault(require("ganache-core"));
async function loadConfig(network) {
return {
network: network
};
}
exports.loadConfig = loadConfig;
async function loadWeb3(config) {
if (config.network === 'test') {
const options = {
transactionConfirmationBlocks: 1,
transactionBlockTimeout: 5
};
return new web3_1.default(ganache_core_1.default.provider(), undefined, options);
}
else {
const options = {
transactionConfirmationBlocks: 1,
transactionBlockTimeout: 5
};
return new web3_1.default(web3_1.default.givenProvider || 'http://127.0.0.1:8545', undefined, options);
}
}
exports.loadWeb3 = loadWeb3;
async function loadAccount(config, web3) {
let [account, ...accounts] = await web3.eth.getAccounts();
return account;
}
exports.loadAccount = loadAccount;
53 changes: 53 additions & 0 deletions .tsbuilt/contract.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
async function readFile(file, def, fn) {
return new Promise((resolve, reject) => {
fs.access(file, fs.constants.F_OK, (err) => {
if (err) {
resolve(def);
}
else {
fs.readFile(file, 'utf8', (err, data) => {
return err ? reject(err) : resolve(fn(data));
});
}
});
});
}
function getBuildFile(network, file) {
return path.join(process.cwd(), '.build', network, file);
}
async function getContract(network, name) {
let contracts = await readFile(getBuildFile(network, 'contracts.json'), {}, JSON.parse);
let contractsObject = contracts["contracts"] || {};
let foundContract = Object.entries(contractsObject).find(([pathContractName, contract]) => {
let [_, contractName] = pathContractName.split(":", 2);
return contractName == name;
});
if (foundContract) {
let [_, contractBuild] = foundContract;
return contractBuild;
}
else {
return null;
}
}
async function deployContract(web3, network, from, name, args) {
let contractBuild = await getContract(network, name);
if (!contractBuild) {
throw new Error(`Cannot find contract \`${name}\` in build folder.`);
}
const contractAbi = JSON.parse(contractBuild.abi);
const contract = new web3.eth.Contract(contractAbi);
return await contract.deploy({ data: '0x' + contractBuild.bin, arguments: args }).send({ from: from, gas: 1000000 });
}
exports.deployContract = deployContract;
10 changes: 10 additions & 0 deletions .tsbuilt/deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const config_1 = require("./config");
const contract_1 = require("./contract");
(async function () {
let config = await config_1.loadConfig("development");
let web3 = await config_1.loadWeb3(config);
let account = await config_1.loadAccount(config, web3);
await contract_1.deployContract(web3, "development", account, "Oracle", []);
})();
1 change: 1 addition & 0 deletions .tsbuilt/do_deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"use strict";
25 changes: 25 additions & 0 deletions .tsbuilt/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const config_1 = require("./config");
const contract_1 = require("./contract");
async function configure() {
let config = await config_1.loadConfig("test");
let web3 = await config_1.loadWeb3(config);
let account = config_1.loadAccount(config, web3);
async function deploy(contract, args) {
console.log(["Deploying", contract, args]);
return contract_1.deployContract(web3, config.network, await account, contract, args);
}
global['saddle'] = {
account,
deploy,
web3
};
}
global['beforeEach'](() => {
console.log("starting test");
});
global['beforeEach'](configure);
global['afterEach'](() => {
console.log("ending test");
});
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License

Copyright (c) 2019 Compound Labs, Inc. https://compound.finance

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

## Open Oracle

The Open Oracle is a standard and SDK allowing reporters to sign key-value pairs (e.g. a price feed) that interested users can post to the blockchain. The system has a built-in view system that allows clients to easily share data and build aggregates (e.g. the median price from several sources).

## Contracts

First, you will need solc 0.5.9 installed. The binary package is faster, but you can use solcjs by running `yarn install`.

...

## SDK

This repository contains an SDK to allow users to quickly sign data in a number of languages. We currently support:

* JavaScript / TypeScript

## Poster

The poster is a simple application that reads from a given feed (or set of feeds) and posts...

## Contributing

Note: the code in this repository is held under the MIT license. Any contributors must agree to release contributed code under this same license.
9 changes: 9 additions & 0 deletions contracts/Oracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pragma solidity ^0.5.9;
pragma experimental ABIEncoderV2;

contract Oracle {

function name() external pure returns (string memory) {
return "ze cool oracle";
}
}
186 changes: 186 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html

module.exports = {
// All imported modules in your tests should be mocked automatically
// automock: false,

// Stop running tests after `n` failures
// bail: 0,

// Respect "browser" field in package.json when resolving modules
// browser: false,

// The directory where Jest should store its cached dependency information
// cacheDirectory: "/private/var/folders/jz/z56b1n2902584b4zplqztm3m0000gn/T/jest_dx",

// Automatically clear mock calls and instances between every test
// clearMocks: false,

// Indicates whether the coverage information should be collected while executing the test
// collectCoverage: false,

// An array of glob patterns indicating a set of files for which coverage information should be collected
// collectCoverageFrom: null,

// The directory where Jest should output its coverage files
// coverageDirectory: "coverage",

// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "/node_modules/"
// ],

// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
// "json",
// "text",
// "lcov",
// "clover"
// ],

// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: null,

// A path to a custom dependency extractor
// dependencyExtractor: null,

// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,

// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],

// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: './.tsbuilt/test.js',

// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: null,

// A set of global variables that need to be available in all test environments
// globals: {},

// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],

// An array of file extensions your modules use
// moduleFileExtensions: [
// "js",
// "json",
// "jsx",
// "ts",
// "tsx",
// "node"
// ],

// A map from regular expressions to module names that allow to stub out resources with a single module
// moduleNameMapper: {},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],

// Activates notifications for test results
// notify: false,

// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",

// A preset that is used as a base for Jest's configuration
// preset: null,

// Run tests from one or more projects
// projects: null,

// Use this configuration option to add custom reporters to Jest
// reporters: undefined,

// Automatically reset mock state between every test
// resetMocks: false,

// Reset the module registry before running each individual test
// resetModules: false,

// A path to a custom resolver
// resolver: null,

// Automatically restore mock state between every test
// restoreMocks: false,

// The root directory that Jest should scan for tests and modules within
// rootDir: null,

// A list of paths to directories that Jest should use to search for files in
// roots: [
// "<rootDir>"
// ],

// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",

// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
setupFilesAfterEnv: [
'./.tsbuilt/test.js'
],

// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],

// The test environment that will be used for testing
testEnvironment: "node",

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},

// Adds a location field to test results
// testLocationInResults: false,

// The glob patterns Jest uses to detect test files
testMatch: [
"**/tests/**/*.[jt]s?(x)"
],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],

// This option allows the use of a custom results processor
// testResultsProcessor: null,

// This option allows use of a custom test runner
// testRunner: "jasmine2",

// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
// testURL: "http://localhost",

// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
// timers: "real",

// A map from regular expressions to paths to transformers
// transform: null,

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/"
// ],

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,

// Indicates whether each individual test should be reported during the run
verbose: true,

// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],

// Whether to use watchman for file crawling
// watchman: true,
};
Loading

0 comments on commit 4b4cb6e

Please sign in to comment.