Skip to content

Commit

Permalink
Update CryptoHerosGame
Browse files Browse the repository at this point in the history
  • Loading branch information
PhyrexTsai committed Jul 24, 2018
1 parent eb51763 commit c1cf55e
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 178 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ We already deployed contracts to [Ropsten](https://ropsten.etherscan.io/) networ

| Contract | Token address | Transaction hash
|------------------|---------------|---------------------
| CryptoHerosGame | [0x7e6A075669bf4D0B91750B6656A26cCB3a08adbd](https://ropsten.etherscan.io/address/0x7e6A075669bf4D0B91750B6656A26cCB3a08adbd) | [0xd09a7c09e70a8d9d9933138ca5b54757b64fe3f076defc0a8cb1bf3e9eb75889](https://ropsten.etherscan.io/tx/0xd09a7c09e70a8d9d9933138ca5b54757b64fe3f076defc0a8cb1bf3e9eb75889)
| CryptoHerosGame | [0x0B6211662d7fcAa5B0DF771dBE49996c4b08d3C9](https://ropsten.etherscan.io/address/0x0b6211662d7fcaa5b0df771dbe49996c4b08d3c9) | [0xd09a7c09e70a8d9d9933138ca5b54757b64fe3f076defc0a8cb1bf3e9eb75889](https://ropsten.etherscan.io/tx/0xd09a7c09e70a8d9d9933138ca5b54757b64fe3f076defc0a8cb1bf3e9eb75889)
| CryptoHerosToken | [0xf70F7d4e063E50B68a08db043f6345ea68A446bE](https://ropsten.etherscan.io/address/0xf70f7d4e063e50b68a08db043f6345ea68a446be) | [0xd6f3989edb1df46325ab4df12fbc6efbde10088ca18e1e2cee866ce03d66751d](https://ropsten.etherscan.io/tx/0xd6f3989edb1df46325ab4df12fbc6efbde10088ca18e1e2cee866ce03d66751d)

## Card List
Expand Down
2 changes: 1 addition & 1 deletion README_zhTW.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ truffle test

| Contract | Token address | Transaction hash
|------------------|---------------|---------------------
| CryptoHerosGame | [0x7e6A075669bf4D0B91750B6656A26cCB3a08adbd](https://ropsten.etherscan.io/address/0x7e6A075669bf4D0B91750B6656A26cCB3a08adbd) | [0xd09a7c09e70a8d9d9933138ca5b54757b64fe3f076defc0a8cb1bf3e9eb75889](https://ropsten.etherscan.io/tx/0xd09a7c09e70a8d9d9933138ca5b54757b64fe3f076defc0a8cb1bf3e9eb75889)
| CryptoHerosGame | [0x0B6211662d7fcAa5B0DF771dBE49996c4b08d3C9](https://ropsten.etherscan.io/address/0x0b6211662d7fcaa5b0df771dbe49996c4b08d3c9) | [0xd09a7c09e70a8d9d9933138ca5b54757b64fe3f076defc0a8cb1bf3e9eb75889](https://ropsten.etherscan.io/tx/0xd09a7c09e70a8d9d9933138ca5b54757b64fe3f076defc0a8cb1bf3e9eb75889)
| CryptoHerosToken | [0xf70F7d4e063E50B68a08db043f6345ea68A446bE](https://ropsten.etherscan.io/address/0xf70f7d4e063e50b68a08db043f6345ea68a446be) | [0xd6f3989edb1df46325ab4df12fbc6efbde10088ca18e1e2cee866ce03d66751d](https://ropsten.etherscan.io/tx/0xd6f3989edb1df46325ab4df12fbc6efbde10088ca18e1e2cee866ce03d66751d)

## Card List
Expand Down
4 changes: 2 additions & 2 deletions contracts/CryptoHerosGame.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ contract CryptoHerosGame is Ownable {
// return usersSingleGames[_address][_idx].length;
// }

function getUserSingleGames() external view returns (uint256[]) {
return usersSingleGames[msg.sender];
function getUserSingleGames(address _address) external view returns (uint256[]) {
return usersSingleGames[_address];
}

function rand(uint min, uint max) private returns (uint){
Expand Down
177 changes: 91 additions & 86 deletions dapp/src/lib/cryptoHerosGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,74 @@ const abi = require('ethereumjs-abi');

const cryptoHerosGameInterface = [
{
"constant": true,
"anonymous": false,
"inputs": [
{
"name": "",
"indexed": true,
"name": "previousOwner",
"type": "address"
},
{
"name": "",
"indexed": true,
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "previousOwner",
"type": "address"
}
],
"name": "OwnershipRenounced",
"type": "event"
},
{
"constant": false,
"inputs": [
{
"name": "_tokenId",
"type": "uint256"
}
],
"name": "usersSingleGames",
"name": "createSingleGame",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": true,
"stateMutability": "payable",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"payable": false,
"stateMutability": "view",
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
Expand All @@ -44,9 +92,30 @@ const cryptoHerosGameInterface = [
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"name": "_cryptoHerosToken",
"type": "address"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"payable": true,
"stateMutability": "payable",
"type": "fallback"
},
{
"constant": true,
"inputs": [],
"inputs": [
{
"name": "_address",
"type": "address"
}
],
"name": "getUserSingleGames",
"outputs": [
{
Expand All @@ -73,12 +142,17 @@ const cryptoHerosGameInterface = [
"type": "function"
},
{
"constant": false,
"constant": true,
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"name": "owner",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "nonpayable",
"stateMutability": "view",
"type": "function"
},
{
Expand Down Expand Up @@ -122,95 +196,26 @@ const cryptoHerosGameInterface = [
},
{
"constant": true,
"inputs": [],
"name": "owner",
"outputs": [
"inputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
},
{
"name": "_tokenId",
"name": "",
"type": "uint256"
}
],
"name": "createSingleGame",
"name": "usersSingleGames",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": true,
"stateMutability": "payable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"name": "_cryptoHerosToken",
"type": "address"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"payable": true,
"stateMutability": "payable",
"type": "fallback"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "previousOwner",
"type": "address"
}
],
"name": "OwnershipRenounced",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
}
];

Expand All @@ -228,9 +233,9 @@ CryptoHerosGame.prototype.createSingleGame = function (tokenId, callback) {
return byteData;
}

CryptoHerosGame.prototype.getUserSingleGames = function (callback) {
CryptoHerosGame.prototype.getUserSingleGames = function (address, callback) {
return this.cryptoHerosGamePromise.then(function (cryptoHerosGame) {
return cryptoHerosGame.getUserSingleGamesAsync();
return cryptoHerosGame.getUserSingleGamesAsync(address);
});
}

Expand Down
Loading

0 comments on commit c1cf55e

Please sign in to comment.