Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleWebsocket = (wsData) => {
if (hathorLib.wallet.loaded()) {
// We are still receiving lot of ws messages that are destined to the admin-frontend and not this wallet
// TODO separate those messages
if (wsData.type === 'wallet:address_history') {
// If is a new transaction, we send a notification to the user, in case it's turned on
// We only send the notification if the inputs are not generated from this wallet
if (!hathorLib.wallet.txExists(wsData.history) && !hathorLib.wallet.areInputsMine(wsData.history)) {
let message = '';
if (hathorLib.helpers.isBlock(wsData.history)) {
message = 'You\'ve found a new block! Click to open it.';
} else {
message = 'You\'ve received a new transaction! Click to open it.'
}
const notification = wallet.sendNotification(message);
// Set the notification click, in case we have sent one
if (notification !== undefined) {
notification.onclick = () => {
this.props.history.push(`/transaction/${wsData.history.tx_id}/`);
}
}
}
wallet.newAddressHistory(wsData.history);
} else {
console.log('Websocket message not handled. Type:', wsData.type);
}
const renderForm = () => {
return (
<div>
<div>
<div>
<label>Amount</label>
<input placeholder="{hathorLib.helpers.prettyValue(0)}" min="{hathorLib.helpers.prettyValue(1)}" step="{hathorLib.helpers.prettyValue(1)}" type="number" required="">
</div>
</div>
<div>
<div>
<input id="keepMint" type="checkbox">
<label>
Create another melt output for you?
</label>
</div>
</div>
</div>
)
}
const renderBalance = () => {
return (
<div>
<p><strong>Total:</strong> {hathorLib.helpers.prettyValue(this.props.balance.available + this.props.balance.locked)} {symbol}</p>
<p><strong>Available:</strong> {hathorLib.helpers.prettyValue(this.props.balance.available)} {symbol}</p>
<p><strong>Locked:</strong> {hathorLib.helpers.prettyValue(this.props.balance.locked)} {symbol}</p>
</div>
);
}
render() {
return (
<div aria-hidden="true" aria-labelledby="requestErrorModal" role="dialog" tabindex="-1" id="requestErrorModal">
<div role="document">
<div>
<div>
<h5 id="exampleModalLabel">Request failed</h5>
<button aria-label="Close" data-dismiss="modal" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
<div>
<p>{this.getErrorMessage()}</p>
<p>You are connected to <strong>{hathorLib.helpers.getServerURL()}</strong></p>
<a> this.showAdvanced(e)} ref="showAdvancedLink" href="true">Show advanced data</a>
<a> this.hideAdvanced(e)} ref="hideAdvancedLink" href="true" style={{display: 'none'}}>Hide advanced data</a>
<div style="{{display:">{this.getAdvancedMessage()}</div>
</div>
<div>
<button type="button">Change server</button>
<button type="button">Retry request</button>
</div>
</div>
</div>
</div>
)
}
}
const renderForm = () => {
return (
<div>
<div>
<div>
<label>Amount</label>
<input placeholder="{hathorLib.helpers.prettyValue(0)}" min="{hathorLib.helpers.prettyValue(1)}" step="{hathorLib.helpers.prettyValue(1)}" type="number" required="">
</div>
{renderMintAddress()}
</div>
<div>
<div>
<input id="keepMint" type="checkbox">
<label>
Create another mint output for you?
</label>
</div>
</div>
</div>
)
}
const renderMintMeltWrapper = () => {
if (this.state.mintOutputs.length === 0 && this.state.meltOutputs.length === 0) {
return <p>You have no more authority outputs for this token</p>;
}
return (
<div>
<div>
<p><strong>Mint authority management</strong></p>
<p>You are the owner of {this.state.mintOutputs.length} mint {hathorLib.helpers.plural(this.state.mintOutputs.length, 'output', 'outputs')}</p>
{this.state.mintOutputs.length > 0 && renderMintLinks()}
</div>
<div>
<p><strong>Melt authority management</strong></p>
<p>You are the owner of {this.state.meltOutputs.length} melt {hathorLib.helpers.plural(this.state.meltOutputs.length, 'output', 'outputs')}</p>
{this.state.meltOutputs.length > 0 && renderMeltLinks()}
</div>
</div>
);
}
const renderMintMeltWrapper = () => {
if (this.state.mintOutputs.length === 0 && this.state.meltOutputs.length === 0) {
return <p>You have no more authority outputs for this token</p>;
}
return (
<div>
<div>
<p><strong>Mint authority management</strong></p>
<p>You are the owner of {this.state.mintOutputs.length} mint {hathorLib.helpers.plural(this.state.mintOutputs.length, 'output', 'outputs')}</p>
{this.state.mintOutputs.length > 0 && renderMintLinks()}
</div>
<div>
<p><strong>Melt authority management</strong></p>
<p>You are the owner of {this.state.meltOutputs.length} melt {hathorLib.helpers.plural(this.state.meltOutputs.length, 'output', 'outputs')}</p>
{this.state.meltOutputs.length > 0 && renderMeltLinks()}
</div>
</div>
);
}
const renderTokenInfo = () => {
return (
<div>
<p><strong>UID: </strong>{this.props.token.uid}</p>
<p><strong>Name: </strong>{this.props.token.name}</p>
<p><strong>Symbol: </strong>{this.props.token.symbol}</p>
<p><strong>Total supply: </strong>{hathorLib.helpers.prettyValue(this.state.totalSupply)} {this.props.token.symbol}</p>
<p><strong>Can mint new tokens: </strong>{this.state.canMint ? 'Yes' : 'No'}</p>
<p>Indicates whether the token owner can create new tokens, increasing the total supply</p>
<p><strong>Can melt tokens: </strong>{this.state.canMelt ? 'Yes' : 'No'}</p>
<p>Indicates whether the token owner can destroy tokens, decreasing the total supply</p>
<p><strong>Total number of transactions: </strong>{this.state.transactionsCount}</p>
</div>
);
}
modalHiddenRetry = () => {
let config = this.props.lastFailedRequest;
let axios = createRequestInstance(config.resolve);
hathorLib.helpers.fixAxiosConfig(axios, config);
axios(config).then((response) => {
config.resolve(response.data);
});
this.setState({ retry: false });
}