Coder Social home page Coder Social logo

pm-js's Introduction

Gnosis Prediction Market JS Library

Logo

Build Status

Slack Status

Getting Started

See the documentation.

Really quick start

  1. Get Ganache-cli
    npm install -g ganache-cli
  2. Run this:
    ganache-cli -d -i 437894314312
  3. Clone pm-contracts, cd in there, and migrate the contracts onto the Ganache-cli instance with:
    cd path/to/pm-contracts
    npm install
    npm run migrate
  4. Download gnosis-pm.js and put it in an HTML file:
    <script src="gnosis-pm.js"></script>

pm-js's People

Contributors

andre-meyer avatar cag avatar collinc97 avatar denisgranha avatar georgi87 avatar germartinez avatar giacomolicari avatar ronidavelman avatar uxio0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pm-js's Issues

contributing guidelines

i would like to contribute to gnosis.js and would like to know the contributing guidelines if any .

Can't create Oracle

I am referring to (1) https://github.com/gnosis/gnosis.js/ for the dev environment setup (ganache-cli and gnosis contract migration) and to (2)
https://gnosis.github.io/gnosis.js/tutorial-developer-guide.html for the JavaScript interaction part.

I can successfully compile and migrate the gnosis-contract in my local chain (see attached console std output), import the gnosis.js library in an HTML page. I then open that webpage in the browser and operate from the WebInspector console.

From the JS console, I can success
ganache-cli_output.txt
gnosis-contract-migrate-output.txt

fully call the Math methods and also create on ipFs the example event in the guide. When I try to create the centralizedOracle thought, I always get an exception:

const oracle = await gnosis.createCentralizedOracle(ipfsHash)
utils.js:287 Uncaught (in promise) TransactionError: CentralizedOracleFactory(0xcfeb..a601).createCentralizedOracle("Qme8yRqWZd5GhDcv2rs7ibvZGfF93ddXggBLVh6aggckjn")

  failed with Error: VM Exception while processing transaction: revert Error: CentralizedOracleFactory(0xcfeb..a601).createCentralizedOracle("Qme8yRqWZd5GhDcv2rs7ibvZGfF93ddXggBLVh6aggckjn")

  failed with Error: VM Exception while processing transaction: revert
    at new TransactionError (file:///Users/marcoz/gnosis.js/dist/gnosis.js:8337:148)
    at _callee3$ (file:///Users/marcoz/gnosis.js/dist/gnosis.js:7919:31)
    at tryCatch (file:///Users/marcoz/gnosis.js/dist/gnosis.js:21746:40)
    at Generator.invoke [as _invoke] (file:///Users/marcoz/gnosis.js/dist/gnosis.js:21980:22)
    at Generator.prototype.(anonymous function) [as throw] (file:///Users/marcoz/gnosis.js/dist/gnosis.js:21798:21)
    at step (file:///Users/marcoz/gnosis.js/dist/gnosis.js:8524:30)
    at file:///Users/marcoz/gnosis.js/dist/gnosis.js:8537:13
    at <anonymous>
TransactionError @ utils.js:287
_callee3$ @ utils.js:328
tryCatch @ runtime.js:62
invoke @ runtime.js:296
prototype.(anonymous function) @ runtime.js:114
step @ asyncToGenerator.js:17
(anonymous) @ asyncToGenerator.js:30
Promise rejected (async)
(anonymous) @ VM138:1
async function (async)
(anonymous) @ VM138:1
(anonymous) @ VM138:1
utils.js:287 Uncaught (in promise) Error: CentralizedOracleFactory(0xcfeb..a601).createCentralizedOracle("Qme8yRqWZd5GhDcv2rs7ibvZGfF93ddXggBLVh6aggckjn")

  failed with Error: VM Exception while processing transaction: revert
    at new TransactionError (file:///Users/marcoz/gnosis.js/dist/gnosis.js:8337:148)
    at _callee3$ (file:///Users/marcoz/gnosis.js/dist/gnosis.js:7919:31)
    at tryCatch (file:///Users/marcoz/gnosis.js/dist/gnosis.js:21746:40)
    at Generator.invoke [as _invoke] (file:///Users/marcoz/gnosis.js/dist/gnosis.js:21980:22)
    at Generator.prototype.(anonymous function) [as throw] (file:///Users/marcoz/gnosis.js/dist/gnosis.js:21798:21)
    at step (file:///Users/marcoz/gnosis.js/dist/gnosis.js:8524:30)
    at file:///Users/marcoz/gnosis.js/dist/gnosis.js:8537:13
    at <anonymous>

And from the ganache-cli console, I see the corresponding chain error:

net_version
eth_sendTransaction

  Transaction: 0x1b96f3428c65b47d581ac643af8af60c1c8122fd19df131b3ef46ba7032502d6
  Gas usage: 89527
  Block Number: 14
  Block Time: Sun Feb 11 2018 11:37:22 GMT+0100 (CET)
  Runtime Error: revert

`depositValue` not defined in tutorial

@zupino noticed this:

In this section of the tutorial, there is an example:

async function buyAllOutcomes() {
    const txResults = await Promise.all([
        [gnosis.etherToken.constructor, await gnosis.etherToken.deposit.sendTransaction({ value: depositValue })],
        [gnosis.etherToken.constructor, await gnosis.etherToken.approve.sendTransaction(event.address, depositValue)],
        [event.constructor, await event.buyAllOutcomes.sendTransaction(depositValue)],
    ].map(([contract, txHash]) => contract.syncTransaction(txHash)))

    // Make sure everything worked
    const expectedEvents = [
        'Deposit',
        'Approval',
        'OutcomeTokenSetIssuance',
    ]
    txResults.forEach((txResult, i) => {
        Gnosis.requireEventFromTXResult(txResult, expectedEvents[i])
    })
}
buyAllOutcomes()

which is missing a definition for depositValue (should be 4 ETH following the tutorial text):

const depositValue = 4e18

Gas estimation problem buying all tokens

Hi!

I've followed the SDK tutorial and I think there might be an issue with gas estimation for the butAllTokens operation.

The tutorial I was following was:
https://gnosis.github.io/gnosis.js/tutorial-events-oracles-and-markets.html

So I've made a demo web app out of the tutorial:

To reproduce the issue, you can use the demo with metamask connected to Kovan network.

Then follow the steps:

  1. Publish event
  2. Create oracle
  3. Create categorical event
  4. Buy all outcomes

In the buy all outcomes will invoke 3 transactions (deposit, approve, buyAllTokens)

The "buyAllTokens" will fail if you don't increase the gasLimit a little.

Let me know if you need any further information!

Best regards,
Anxo

Documentation about `deposit` and `approve`

In #109 from @srameshr came the following question:

Also what does the following do?

        [gnosis.etherToken.constructor, await gnosis.etherToken.deposit.sendTransaction({ value: depositValue })],
        [gnosis.etherToken.constructor, await gnosis.etherToken.approve.sendTransaction(event.address, depositValue)],
        [event.constructor, await event.buyAllOutcomes.sendTransaction(depositValue)],

What is deposit, approve doing here? Assume intention of the user here is just to buy some tokens and nothing else.

Information answering that question should be included in the docs.

No documentation on instantiation on deployed contracts

Currently have a deployed Categorical event contract on the Ropsten network at 0x0bf128753dB586f742eaAda502301ea86a7561e6.
How do I instantiate an object on the frontend that calls this address and has all the methods.
Generally I use web3.eth.contracts(interface,address). How do I get the access to interface on Gnosis ?

Build is failing

Lots of TypeError: Cannot create proxy with a non-object as target or handler errors.

Pointing to e4213ca

Reduce final build size

Right now I got this:

179000 - ./~/bluebird/js/browser/bluebird.js
124000 - ./~/decimal.js/decimal.es6.js
95100 - ./~/web3/~/bignumber.js/bignumber.js
87200 - ./~/bn.js/lib/bn.js
48600 - ./~/buffer/index.js
31100 - ./~/@gnosis.pm/gnosis-core-contracts/build/contracts/EventFactory.json
29300 - ./~/crypto-js/cipher-core.js
24400 - ./~/regenerator-runtime/runtime.js
24300 - ./~/crypto-js/tripledes.js
23400 - ./~/truffle-contract/contract.js
22400 - ./~/truffle-contract-schema/~/crypto-js/core.js
22400 - ./~/crypto-js/core.js
21600 - ./~/@gnosis.pm/gnosis-core-contracts/build/contracts/StandardMarket.json
19400 - ./~/@gnosis.pm/gnosis-core-contracts/build/contracts/ScalarEvent.json
17400 - ./~/@gnosis.pm/gnosis-core-contracts/build/contracts/StandardMarketFactory.json
16700 - ./~/web3/lib/utils/utils.js
16100 - ./~/@gnosis.pm/gnosis-core-contracts/build/contracts/CategoricalEvent.json
15900 - ./~/ethjs-abi/~/js-sha3/src/sha3.js
13800 - ./~/@gnosis.pm/gnosis-core-contracts/build/contracts/UltimateOracle.json
13800 - ./~/@gnosis.pm/gnosis-core-contracts/build/contracts/Campaign.json
13700 - ./~/@gnosis.pm/gnosis-core-contracts/build/contracts/FutarchyOracle.json
13600 - ./~/@gnosis.pm/gnosis-core-contracts/build/contracts/FutarchyOracleFactory.json
13400 - ./~/crypto-js/sha512.js
12400 - ./~/ethjs-abi/lib/utils/index.js
11500 - ./~/@gnosis.pm/gnosis-core-contracts/build/contracts/CampaignFactory.json
11000 - ./~/@gnosis.pm/gnosis-core-contracts/build/contracts/Math.json
10600 - ./~/truffle-contract-schema/~/crypto-js/sha3.js
10600 - ./~/crypto-js/sha3.js
10100 - ./~/web3/lib/web3/methods/eth.js
10100 - ./~/@gnosis.pm/gnosis-core-contracts/build/contracts/UltimateOracleFactory.json
10000 - ./~/core-js/library/modules/es6.promise.js
...

Where number is # bytes of component.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.