Skip to content
This repository has been archived by the owner on Dec 13, 2019. It is now read-only.

Commit

Permalink
[High Roller] Add getPlayerRolls function to HighRollerApp (#2341)
Browse files Browse the repository at this point in the history
* feat: Add getPlayerRolls function to HighRollerApp
This splits the highRoller function into two functions for the client

* fix: Create HighRollerApp.json compiled artifact

* v0.1.12

* chore: Update apps version in packages
  • Loading branch information
Alonski authored Sep 6, 2019
1 parent da9015b commit 70430cc
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 9 deletions.
23 changes: 20 additions & 3 deletions packages/apps/contracts/HighRollerApp.sol
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,35 @@ contract HighRollerApp is CounterfactualApp {
}

function highRoller(bytes32 randomness)
public // NOTE: This is used in app-root.tsx for the clientside dapp
public
pure
returns(uint8 playerFirstTotal, uint8 playerSecondTotal)
{
(
uint8 playerFirstRollOne,
uint8 playerFirstRollTwo,
uint8 playerSecondRollOne,
uint8 playerSecondRollTwo
) = getPlayerRolls(randomness);
playerFirstTotal = playerFirstRollOne + playerFirstRollTwo;
playerSecondTotal = playerSecondRollOne + playerSecondRollTwo;
}

function getPlayerRolls(bytes32 randomness)
public // NOTE: This is used in app-root.tsx for the clientside dapp
pure
returns(uint8 playerFirstRollOne, uint8 playerFirstRollTwo, uint8 playerSecondRollOne, uint8 playerSecondRollTwo)
{
(
bytes8 hash1,
bytes8 hash2,
bytes8 hash3,
bytes8 hash4
) = cutBytes32(randomness);
playerFirstTotal = bytes8toDiceRoll(hash1) + bytes8toDiceRoll(hash2);
playerSecondTotal = bytes8toDiceRoll(hash3) + bytes8toDiceRoll(hash4);
playerFirstRollOne = bytes8toDiceRoll(hash1);
playerFirstRollTwo = bytes8toDiceRoll(hash2);
playerSecondRollOne = bytes8toDiceRoll(hash3);
playerSecondRollTwo = bytes8toDiceRoll(hash4);
}

function getWinningAmounts(uint256 num1, uint256 num2)
Expand Down
42 changes: 39 additions & 3 deletions packages/apps/expected-build-artifacts/HighRollerApp.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/apps/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@counterfactual/apps",
"version": "0.1.11",
"version": "0.1.12",
"description": "Collection of various apps built on Counterfactual",
"repository": "github.com/counterfactual/monorepo",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/local-ganache-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"typescript": "3.5.3"
},
"dependencies": {
"@counterfactual/apps": "0.1.11",
"@counterfactual/apps": "0.1.12",
"@counterfactual/cf-adjudicator-contracts": "0.0.6",
"@counterfactual/cf-funding-protocol-contracts": "0.0.10",
"@counterfactual/types": "0.0.38",
Expand Down
2 changes: 1 addition & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"devDependencies": {
"@babel/core": "7.5.5",
"@babel/plugin-proposal-object-rest-spread": "7.5.5",
"@counterfactual/apps": "0.1.11",
"@counterfactual/apps": "0.1.12",
"@counterfactual/firebase-server": "0.0.4",
"@counterfactual/local-ganache-server": "0.0.7",
"@counterfactual/postgresql-node-connector": "0.0.7",
Expand Down

0 comments on commit 70430cc

Please sign in to comment.