Skip to content

Commit

Permalink
Updated for build 404
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardonunesp committed Aug 27, 2018
1 parent aea0628 commit 0134dfa
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 76 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ crypto_cards_dappchain_address
crypto_cards_tx_hash
game_token_address
gateway_address
crypto_cards_transaction
109 changes: 58 additions & 51 deletions dappchain/genesis.example.json
Original file line number Diff line number Diff line change
@@ -1,55 +1,62 @@
{
"contracts": [
{
"vm": "plugin",
"format": "plugin",
"name": "coin",
"location": "coin:1.0.0",
"init": null
"contracts": [
{
"vm": "plugin",
"format": "plugin",
"name": "coin",
"location": "coin:1.0.0",
"init": null
},
{
"vm": "plugin",
"format": "plugin",
"name": "dpos",
"location": "dpos:1.0.0",
"init": {
"params": {
"witnessCount": "21",
"electionCycleLength": "604800",
"minPowerFraction": "5"
},
{
"vm": "plugin",
"format": "plugin",
"name": "dpos",
"location": "dpos:1.0.0",
"init": {
"params": {
"witnessCount": "21",
"electionCycleLength": "604800",
"minPowerFraction": "5"
},
"validators": [
{
"pubKey": "cpcIKimrZcpvu/oLQzP8sA8+LlyzJiHio/TE/JGLT5c=",
"power": "10"
}
]
}
"validators": [
{
"pubKey": "cpcIKimrZcpvu/oLQzP8sA8+LlyzJiHio/TE/JGLT5c=",
"power": "10"
}
]
}
},
{
"vm": "plugin",
"format": "plugin",
"name": "ethcoin",
"location": "ethcoin:1.0.0",
"init": null
},
{
"vm": "plugin",
"format": "plugin",
"name": "addressmapper",
"location": "addressmapper:0.1.0",
"init": null
},
{
"vm": "plugin",
"format": "plugin",
"name": "gateway",
"location": "gateway:0.1.0",
"init": {
"owner": {
"chain_id": "default",
"local": "c/IFoEFkm4+D3wdqLmFU9F3t3Sk="
},
{
"vm": "plugin",
"format": "plugin",
"name": "addressmapper",
"location": "addressmapper:0.1.0",
"init": null
},
{
"vm": "plugin",
"format": "plugin",
"name": "gateway",
"location": "gateway:0.1.0",
"init": {
"owner": {
"chain_id": "default",
"local": "c/IFoEFkm4+D3wdqLmFU9F3t3Sk="
},
"oracles": [
{
"chain_id": "default",
"local": "22nuyPPZ53/qAqFnhwD2EpNu9ss="
}
]
}
}
]
"oracles": [
{
"chain_id": "default",
"local": "22nuyPPZ53/qAqFnhwD2EpNu9ss="
}
]
}
}
]
}
30 changes: 15 additions & 15 deletions dappchain/loom.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
ChainID: "default"
ChainID: 'default'
RegistryVersion: 2
LogDestination: "file://loom2.log"
LoomLogLevel: "debug"
ContractLogLevel: "debug"
BlockchainLogLevel: "error"
RPCListenAddress: "tcp://127.0.0.1:46658"
LogDestination: 'file://loom2.log'
LoomLogLevel: 'debug'
ContractLogLevel: 'debug'
BlockchainLogLevel: 'error'
EVMAccountsEnabled: true
TransferGateway:
# Enables the Transfer Gateway Go contract, must be the same on all nodes.
ContractEnabled: true
Expand All @@ -14,19 +14,19 @@ TransferGateway:
# running the tests with the Oracle running out of process the Ganache websocket connection
# often times out while the tests are waiting for the Oracle to do something. So better to
# use the HTTP endpoint for testing.
EthereumURI: "http://127.0.0.1:8545"
MainnetContractHexAddress: "0xf5cad0db6415a71a5bc67403c87b56b629b4ddaa"
MainnetPrivateKeyPath: "oracle_eth_priv.key"
DAppChainPrivateKeyPath: "oracle_priv.key"
DAppChainReadURI: "http://localhost:46658/query"
DAppChainWriteURI: "http://localhost:46658/rpc"
EthereumURI: 'http://127.0.0.1:8545'
MainnetContractHexAddress: '0xf5cad0db6415a71a5bc67403c87b56b629b4ddaa'
MainnetPrivateKeyPath: 'oracle_eth_priv.key'
DAppChainPrivateKeyPath: 'oracle_priv.key'
DAppChainReadURI: 'http://localhost:46658/query'
DAppChainWriteURI: 'http://localhost:46658/rpc'
# Websocket URI that should be used to subscribe to DAppChain events (only used for tests atm).
DAppChainEventsURI: "ws://localhost:46658/queryws"
DAppChainEventsURI: 'ws://localhost:46658/queryws'
# These control how often the Oracle will poll the blockchains for events.
DAppChainPollInterval: 1 # seconds
MainnetPollInterval: 1 # seconds
OracleLogLevel: "debug"
OracleLogDestination: "file://oracle.log"
OracleLogLevel: 'debug'
OracleLogDestination: 'file://oracle.log'
# Number of seconds to wait before starting the Oracle.
OracleStartupDelay: 5
# Number of seconds to wait between reconnection attempts.
Expand Down
2 changes: 1 addition & 1 deletion gateway_dappchain_address
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0xb9fA0896573A89cF4065c43563C069b3B3C15c37
0xC5d1847a03dA59407F27f8FE7981D240bff2dfD3
14 changes: 11 additions & 3 deletions truffle-dappchain/contracts/CryptoCardsDappChain.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
pragma solidity ^0.4.24;

import "openzeppelin-solidity/contracts/token/ERC721/ERC721Token.sol";

import "openzeppelin-solidity/contracts/token/ERC721/ERC721Receiver.sol";
import "./ERC721DAppToken.sol";

/**
* @title Full ERC721 Token for Loom DAppChains
* This implementation includes all the required and some optional functionality of the ERC721
* standard, it also contains some required functionality for Loom DAppChain compatiblity.
*/
contract CryptoCardsDappChain is ERC721Token {
contract CryptoCardsDappChain is ERC721DAppToken, ERC721Token, ERC721Receiver {
// Transfer Gateway contract address
address public gateway;

Expand All @@ -20,9 +21,16 @@ contract CryptoCardsDappChain is ERC721Token {
}

// Called by the gateway contract to mint tokens that have been deposited to the Mainnet gateway.
function mint(uint256 _uid) public {
function mintToGateway(uint256 _uid) public {
require(msg.sender == gateway);
_mint(gateway, _uid);
}

function onERC721Received(
address _from,
uint256 _tokenId,
bytes _data
) public returns(bytes4) {
return ERC721_RECEIVED;
}
}
16 changes: 16 additions & 0 deletions truffle-dappchain/contracts/ERC721DAppToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pragma solidity ^0.4.24;

import "openzeppelin-solidity/contracts/token/ERC721/ERC721.sol";

/**
* @title ERC721 interface for token contracts deployed to Loom DAppChains.
*/
contract ERC721DAppToken is ERC721 {
// Called by the DAppChain Gateway contract to mint tokens that have been deposited to the
// Mainnet gateway.
//
// NOTE: This function will only be called by the DAppChain Gateway contract if it doesn't own
// the token it needs to transfer, so it's possible to omit this function if you wish to
// manually allocate tokens for the Gateway.
function mintToGateway(uint256 _uid) public;
}
2 changes: 1 addition & 1 deletion truffle-dappchain/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"scripts": {
"compile": "rm -rf build; truffle compile",
"deploy": "truffle migrate --reset --network loom_dapp_chain",
"deploy": "rm -rf build; truffle migrate --reset --network loom_dapp_chain",
"ganache-cli": "ganache-cli -p 8545 --gasLimit 50000000 -e 100000 -m \"gravity top burden flip student usage spell purchase hundred improve check genre\""
},
"dependencies": {
Expand Down
11 changes: 6 additions & 5 deletions webclient/src/dc_managers/dc_card_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ export default class DAppChainCardManager {
{ from }
)

return new DAppChainCardManager(client, contract)
return new DAppChainCardManager(client, contract, web3)
}

constructor(client, contract) {
constructor(client, contract, web3) {
this._client = client
this._contract = contract
this._web3 = web3
}

getContractAddress() {
Expand Down Expand Up @@ -89,8 +90,8 @@ export default class DAppChainCardManager {
}

async approveAsync(address, cardId) {
return await this._contract.methods
.approve('0xb9fA0896573A89cF4065c43563C069b3B3C15c37'.toUpperCase(), cardId)
.send({ from: address })
const addr = this._web3.utils.toChecksumAddress('0xC5d1847a03dA59407F27f8FE7981D240bff2dfD3')
const iban = this._web3.eth.Iban.toIban(addr)
return await this._contract.methods.approve(iban, cardId).send({ from: address })
}
}

0 comments on commit 0134dfa

Please sign in to comment.