Added documentation to .js files
This commit is contained in:
parent
a3cba3d034
commit
350bfb5f9b
|
@ -42,15 +42,6 @@ class AddToken extends Component {
|
|||
"shield": this.state.shield
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Cargamos la imagen a IPFS
|
||||
EmbarkJS.Storage.uploadFile(this.state.fileToUpload)
|
||||
|
|
|
@ -33,10 +33,17 @@ class Ship extends Component {
|
|||
}
|
||||
|
||||
_loadAttributes(){
|
||||
// Cargar los atributos involucra leer la metadata
|
||||
EmbarkJS.Storage.get(web3.utils.toAscii(this.props.metadataHash))
|
||||
.then(content => {
|
||||
const jsonMetadata = JSON.parse(content);
|
||||
let _url = EmbarkJS.Storage.getUrl(jsonMetadata.imageHash);
|
||||
|
||||
// Podemos usar este metodo
|
||||
const _url = EmbarkJS.Storage.getUrl(jsonMetadata.imageHash);
|
||||
|
||||
// o leer el url que grabamos en la metadata
|
||||
// const _url = jsonMetadata.image
|
||||
|
||||
this.setState({image: _url})
|
||||
});
|
||||
}
|
||||
|
@ -137,7 +144,6 @@ class Ship extends Component {
|
|||
|
||||
render(){
|
||||
const { energy, lasers, shield, price, wallet, salesEnabled, marketplace } = this.props;
|
||||
|
||||
const { image, isSubmitting, showSellForm } = this.state;
|
||||
|
||||
const formattedPrice = !wallet ? web3.utils.fromWei(price, "ether") : '';
|
||||
|
|
|
@ -18,6 +18,7 @@ class ShipList extends Component {
|
|||
|
||||
componentDidMount(){
|
||||
EmbarkJS.onReady((err) => {
|
||||
// Al cargar la lista de naves, determinamos si estan aprobadas para la venta
|
||||
const { isApprovedForAll } = SpaceshipToken.methods;
|
||||
isApprovedForAll(web3.eth.defaultAccount, SpaceshipMarketplace.options.address)
|
||||
.call()
|
||||
|
@ -25,9 +26,9 @@ class ShipList extends Component {
|
|||
this.setState({salesEnabled: isApproved});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
enableMarketplace = () => {
|
||||
enableMarketplace = () => {
|
||||
const { setApprovalForAll } = SpaceshipToken.methods;
|
||||
|
||||
this.setState({isSubmitting: true});
|
||||
|
@ -51,7 +52,7 @@ enableMarketplace = () => {
|
|||
.finally(() => {
|
||||
this.setState({isSubmitting: false});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
render = () => {
|
||||
const { list, title, id, wallet, onAction, marketplace } = this.props;
|
||||
|
@ -61,12 +62,10 @@ enableMarketplace = () => {
|
|||
<h3>{title}</h3>
|
||||
{ wallet ? <EnableSales isSubmitting={this.state.isSubmitting} handleChange={this.enableMarketplace} salesEnabled={this.state.salesEnabled} /> : ''}
|
||||
{ list.map((ship, i) => <Ship onAction={onAction} wallet={wallet} salesEnabled={salesEnabled} key={i} marketplace={marketplace} {...ship} />) }
|
||||
|
||||
{ list.length == 0
|
||||
? <p>No hay naves disponibles</p>
|
||||
: ''
|
||||
}
|
||||
|
||||
</div>;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,12 +29,15 @@ class App extends Component {
|
|||
}
|
||||
|
||||
_loadEverything(){
|
||||
// Cargamos todas las naves que estan a la venta, que estan en mi wallet y en el mercado
|
||||
|
||||
this._loadShipsForSale();
|
||||
this._loadMyShips();
|
||||
this._loadMarketPlace();
|
||||
}
|
||||
|
||||
_isOwner(){
|
||||
// Nos interesa saber si somos el dueno del contrato para mostrar el formulario de tokens
|
||||
SpaceshipToken.methods.owner()
|
||||
.call()
|
||||
.then(owner => {
|
||||
|
|
Loading…
Reference in New Issue