diff --git a/app/js/components/addToken.js b/app/js/components/addToken.js index e107434..6a7644f 100644 --- a/app/js/components/addToken.js +++ b/app/js/components/addToken.js @@ -33,15 +33,31 @@ class AddToken extends Component { this.setState({isSubmitting: true}); - // TODO: let attributes = { + "name": "Nave Espacial", + "image": "", + "attributes": { + "energy": this.state.energy, + "lasers": this.state.lasers, + "shield": this.state.shield + } } + + + + + + + + + // Cargamos la imagen a IPFS EmbarkJS.Storage.uploadFile(this.state.fileToUpload) .then(fileHash => { // Agregamos los datos a la lista de atributos attributes.imageHash = fileHash; + attributes.image = 'https://ipfs.io/ipfs/' + fileHash; // Guardamos la lista de atributos return EmbarkJS.Storage.saveText(JSON.stringify(attributes)) diff --git a/app/js/components/shipList.js b/app/js/components/shipList.js index 75a256a..57e8d1d 100644 --- a/app/js/components/shipList.js +++ b/app/js/components/shipList.js @@ -61,6 +61,12 @@ enableMarketplace = () => {

{title}

{ wallet ? : ''} { list.map((ship, i) => ) } + + { list.length == 0 + ?

No hay naves disponibles

+ : '' + } + ; } diff --git a/contracts/SpaceshipToken.sol b/contracts/SpaceshipToken.sol index 8ea4b25..4c48f5b 100644 --- a/contracts/SpaceshipToken.sol +++ b/contracts/SpaceshipToken.sol @@ -3,7 +3,6 @@ pragma solidity 0.4.24; import "zeppelin-solidity/contracts/token/ERC721/ERC721Token.sol"; import 'zeppelin-solidity/contracts/ownership/Ownable.sol'; - /** @title Contrato base para Mexico Workshop @dev En Status tambien hablamos espanol ;) @@ -96,4 +95,24 @@ contract SpaceshipToken is ERC721Token("CryptoSpaceships", "CST"), Ownable { lasers = s.lasers; shield = s.shield; } + + + // Obtain metadata + + function tokenURI(uint256 _spaceshipId) public view returns (string) { + Spaceship storage s = spaceships[_spaceshipId]; + return strConcat("https://ipfs.io/ipfs/", string(s.metadataHash)); + } + + function strConcat(string _a, string _b) private returns (string) { + bytes memory _ba = bytes(_a); + bytes memory _bb = bytes(_b); + string memory ab = new string(_ba.length + _bb.length); + bytes memory bab = bytes(ab); + uint k = 0; + for (uint i = 0; i < _ba.length; i++) bab[k++] = _ba[i]; + for (i = 0; i < _bb.length; i++) bab[k++] = _bb[i]; + return string(bab); + } + } \ No newline at end of file