Coder Social home page Coder Social logo

andremiras / etheroll Goto Github PK

View Code? Open in Web Editor NEW
33.0 5.0 35.0 16.65 MB

Provably fair dice game running on the Ethereum blockchain

Home Page: https://andremiras.github.io/etheroll/

License: MIT License

HTML 2.34% CSS 1.66% JavaScript 92.81% Makefile 1.04% Dockerfile 1.98% Shell 0.17%
dice etheroll gambling ethereum react

etheroll's Introduction

Etheroll ReactJS

Build Status

Experimental project running an alternative Etheroll frontend on ReactJS. If you're looking for the mobile app instead, see EtherollApp.

Closed down

The upstream project/smart-contract closed down. https://www.reddit.com/r/etheroll/comments/peeekh/etheroll_is_closing_down/

Run

make start

Install

make

Test

make lint
make test

Docker

We provide a Dockerfile that can be used for development or production. Build and run with:

docker-compose up

The application will be served on both port 80 (default HTTP) and 3000 (default Node.js port). Find out more reading the docker-compose.yml file.

Deployment

The app can be deployed on GitHub pages when releasing via:

make deploy

It can also be deployed on Heroku for staging:

git push heroku develop:master

etheroll's People

Contributors

andremiras avatar dependabot[bot] avatar kirkins avatar lgarest avatar npizza avatar simonboeuf1 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

Watchers

 avatar  avatar  avatar  avatar  avatar

etheroll's Issues

CI testing

We need to setup Continuous Integration testing e.g. Travis making sure everything is OK after a push.
The CI should check both unit tests and linting.

Indicate to the user what is the potential profit for a given bet

Currently, the site only shows the "Bet size", the "Chance of winning" and the "Roll under".
To make the user experience clearer, it should also show the potential profit for the given parameters.
Two lines could be added below the "Roll under" section, similar to the EtherollApp:

  • Roll under [A]
  • With a wager of [B]
  • For a profit of [C]

Also related to #17

Language selection dropdown

In #2 we implemented some basic translation. The browser locale is currently detected but it would be a plus to also be possible to let the user chose.
We may need to migrate to the React Context API or Redux in order to pass the locale prop to child components.

TypeError: a.fromWei(...).toNumber is not a function

https://sentry.io/andre-5t/etheroll-fe/issues/793889639/?referrer=github_plugin

TypeError: a.fromWei(...).toNumber is not a function
  at callback (components/PlaceBet.jsx:118:64)
  at None (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/inpage.js:1:99780)
  at None (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/inpage.js:1:6929)
  at i (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/inpage.js:1:25160)
  at None (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/inpage.js:1:9759)
...
(37 additional frame(s) were not displayed)

How could have a option to play on test net too?

I really would like to see etheroll have a option to play to mainnet or test net. I believe that it will not be difficult to do that. One step is to run smart contracts to the testnet and then change a little bit the UI. Am I correct? How do you think something like that could be implemented?

Still show roll history without MetaMask

While MetaMask should be required for betting, it should still be possible to see contract info or transactions history via direct web3 access rather than the injected MetaMask one.

Docker cache-from

Upload Docker image to registry on successful build and pull/build image from it

Contract pull DRY error handling

Currently each time we pull some info from the contract we're running through the following boilerplate:

      contract.web3Contract.minNumber((error, minNumber) => {
        if (error) {
          this.showFetchContractInfoWarning();
        }
        const minChances = minNumber - 1;
        this.setState({ minChances });
      });

Maybe these three error handling lines could be generalised/simplified.

Update transaction list automatically

Currently the user has to refresh the page himself to see a fresh transaction list.
It would be best if this was done automatically.

Technically it should be implemented via Websockets and push notifications, but I'm not sure this is supported by web3.js. If not we will have to go for pulling anti-pattern via setInterval().

Unit test bigger components

Currently bigger components like the RollUnder (previously PlaceBet) are not being unit tested.
This is because they have too many child components and rely on web3 a lot.
We should find a way to test them nonetheless because they may break.
See if a solution similar to Python unit test mocking is possible.

Upgrade to recent web3 version

In order to be able to connect to recent versions of MetaMask we need to update to recent web3 lib and request the user to login via ethereum.enable().

Test not exiting after sucess

Kinda related to upstream jestjs/jest#1456 even though we're not running firebase.
Also can see the issue with freshly created app from create-react-app.
--forceExit doesn't help and --detectOpenHandles doesn't print anything.

Notification on roll result

Send user notification when his roll result was mined.
The playerRollDice notification should already be handled by Etherscan. But we still want the Oracle response transaction to be notifying the user if it's the result of his roll.

Refactor/rename PlaceBet component

The component PlaceBet has too much logic, it should be broken down to sub-components and utils files.
Also it should be renamed to e.g. RollUnder.
The idea is we will soon have other games like the coin flip #11 and we would like to reuse/share code as much as possible between the two.

Docker image optimization

Optimize Docker image size and follow best practices.
Also share some of the build dependencies via the Makefile.

Docker build/run Makefile target

The Makefile should be the single entry point to be used both by the CI and developers.
We need to add targets to simplify dev/CI workflows, such as docker build/run/tests...

Display roll result on screen

Not a priority, but it would be nice for the user experience to have a simple waiting text animation "Your roll is being processed..." after you click on "Roll" and display the result "You rolled [X]. You won / you lose" once the bet has been processed.

Related to #1

Choose between head/tail

Make it possible for the user to choose between head or tail.
Since the current smart contract, doesn't store this information into the blockchain, we need to store the the user choice somewhere else.
Having a dedicated backend is not currently an option because it would involve more maintenance and more restrictive requirement. For instance it won't be possible to host the backend on GitHub pages.
We could think of a thirdparty DB storage service, like Firebase storage, but that means adding a new middleman.
The other option is to store the info browser side, e.g. session. This is most likely what we would try.
If the user bet choice can be found in its session, we display it, otherwise we default to e.g. Head.
It means the user could see different head/tail results from one browser to the other, but the win/loss would always be the same. So this probably needs to be explained in a note somewhere.

Edit:
Reddit conversation https://www.reddit.com/r/etheroll/comments/aa3hmj/build_any_chances_based_games_on_etheroll/

Setup unit testing

We should be able to unit test our component to see everything is working OK.

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.