diff --git a/LICENSE.md b/LICENSE.md index 67688db..f94f518 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -19,3 +19,5 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Have Fun! diff --git a/src/components/admin-lte/configure/jwt.js b/src/components/admin-lte/configure/jwt.js index 79a8596..0776ebf 100644 --- a/src/components/admin-lte/configure/jwt.js +++ b/src/components/admin-lte/configure/jwt.js @@ -46,7 +46,7 @@ class JsonWebTokens extends React.Component { id='jwt' name='JWT' placeholder='Enter FullStack.cash JWT' - label='FullStack.cash JWT' + label='Enter FullStack.cash JWT to increase rate limits.' labelPosition='above' onChange={_this.handleUpdate} /> diff --git a/src/components/admin-lte/send-receive/send.js b/src/components/admin-lte/send-receive/send.js index 331d1d0..bd0918e 100644 --- a/src/components/admin-lte/send-receive/send.js +++ b/src/components/admin-lte/send-receive/send.js @@ -211,13 +211,11 @@ class Send extends React.Component { async getMaxAmount () { try { const bchWalletLib = _this.props.bchWallet - // Ensure the wallet UTXOs are up-to-date. const walletAddr = bchWalletLib.walletInfo.address await bchWalletLib.utxos.initUtxoStore(walletAddr) - const utxos = bchWalletLib.utxos.bchUtxos - + const utxos = bchWalletLib.utxos.utxoStore.bchUtxos if (!utxos.length) { throw new Error('No BCH Utxos to spend!') } diff --git a/src/components/admin-lte/tokens/index.js b/src/components/admin-lte/tokens/index.js index 6ad359c..9d618f5 100644 --- a/src/components/admin-lte/tokens/index.js +++ b/src/components/admin-lte/tokens/index.js @@ -91,17 +91,21 @@ class Tokens extends React.Component { <> {_this.state.tokens.map((val, i) => { - return ( - - - - ) + if (val.qty > 0) { + return ( + + + + ) + } else { + return + } })} > @@ -109,6 +113,7 @@ class Tokens extends React.Component { )} > ) @@ -198,10 +204,13 @@ class Tokens extends React.Component { ele.scrollIntoView({ behavior: 'smooth' }) } - onHandleToggleModal () { + onHandleToggleModal (refresh = null) { _this.setState({ showModal: !_this.state.showModal }) + if (refresh) { + _this.handleGetTokens(true) + } } handleError (error) { @@ -247,7 +256,7 @@ class Tokens extends React.Component { let explorerURL if (bchjs.restURL.includes('abc.fullstack')) { - explorerURL = 'https://explorer.bitcoinabc.org/tx' + explorerURL = 'https://explorer.be.cash/tx' } else { explorerURL = 'https://explorer.bitcoin.com/bch/tx' } diff --git a/src/components/admin-lte/tokens/send-tokens.js b/src/components/admin-lte/tokens/send-tokens.js index 2d962d7..5d6b36a 100644 --- a/src/components/admin-lte/tokens/send-tokens.js +++ b/src/components/admin-lte/tokens/send-tokens.js @@ -139,10 +139,23 @@ class SendTokens extends React.Component { // console.log(_this.state) } + // Sets the qty property with + // the corresponding token decimals + floorQty (qty, decimals) { + try { + const a = qty * Math.pow(10, decimals) + const b = Math.floor(a) + const result = b / Math.pow(10, decimals) + return result + } catch (error) { + console.warn(error) + } + } + async handleSendMax () { - const { qty } = _this.props.selectedToken + const { qty, decimals } = _this.props.selectedToken _this.setState({ - amountSat: qty + amountSat: _this.floorQty(qty, decimals) }) } @@ -182,11 +195,6 @@ class SendTokens extends React.Component { const walletAddr = bchWalletLib.walletInfo.address await bchWalletLib.utxos.initUtxoStore(walletAddr) - // For some reason, the utxo categories do not get populated, so we have - // to do it manually. - bchWalletLib.utxos.bchUtxos = await bchWalletLib.utxos.getBchUtxos() - bchWalletLib.utxos.tokenUtxos = await bchWalletLib.utxos.getTokenUtxos() - // Used for debugging. // console.log(`receiver: ${JSON.stringify(receiver, null, 2)}`) // console.log( diff --git a/src/components/admin-lte/tokens/token-card.js b/src/components/admin-lte/tokens/token-card.js index 512ca08..3cb63fe 100644 --- a/src/components/admin-lte/tokens/token-card.js +++ b/src/components/admin-lte/tokens/token-card.js @@ -13,7 +13,7 @@ class TokenCard extends React.Component { render () { const token = _this.props.token - console.log(`token: ${JSON.stringify(token, null, 2)}`) + // console.log(`token: ${JSON.stringify(token, null, 2)}`) return ( <> diff --git a/src/components/admin-lte/tokens/token-modal.js b/src/components/admin-lte/tokens/token-modal.js index 0c979ce..092a741 100644 --- a/src/components/admin-lte/tokens/token-modal.js +++ b/src/components/admin-lte/tokens/token-modal.js @@ -11,7 +11,10 @@ class TokenModal extends React.Component { _this = this this.state = { copySuccess: '', - isBurnView: false + isBurnView: false, + txId: '', + errMsg: '', + inFetch: false } this.modalFooter = ( @@ -36,6 +39,15 @@ class TokenModal extends React.Component { /> > ) + this.onDoneFooter = ( + <> + this.handleBurnAll(false)} + /> + > + ) } render () { @@ -46,7 +58,11 @@ class TokenModal extends React.Component { title={_this.state.isBurnView ? `Burn All ${token.name}` : token.name} modal modalFooter={ - _this.state.isBurnView ? this.burnFooter : this.modalFooter + !_this.state.isBurnView + ? this.modalFooter + : _this.state.txId || _this.state.errMsg + ? this.onDoneFooter + : this.burnFooter } show={_this.props.show} modalCloseButton @@ -54,138 +70,159 @@ class TokenModal extends React.Component { > - {_this.state.isBurnView - ? ( + {_this.state.isBurnView && !_this.state.txId && ( + Are you sure you want to burn {`${token.qty} `} tokens? - ) - : ( - - - - - - - - TokenId: - - - {token.tokenId} - - + )} + + {_this.state.isBurnView && _this.state.txId && ( + + Transaction ID: + + {_this.state.txId} + + + )} + + {_this.state.isBurnView && _this.state.errMsg && ( + + {_this.state.errMsg} + + )} + + {!_this.state.isBurnView && ( + + + + + + + + TokenId: + + + {token.tokenId} + + + {_this.state.copySuccess === 'tokenId' + ? ( + + Copied! + + ) + : ( + + _this.copyToClipBoard('tokenId')} + icon='copy' + /> + )} + + + + + + + + + URL: + + + - {_this.state.copySuccess === 'tokenId' - ? ( - - Copied! - - ) - : ( - - _this.copyToClipBoard('tokenId')} - icon='copy' - /> - )} - - - - - - - - - URL: - - - - {token.url} - - - - - - - - - - Ticker: - - - {token.ticker} - - - - - - - - - Name: - - - {token.name} - - - - - - - - - Balance: - - - {token.qty} - - - - - - - - - Decimals: - - - {token.decimals} - - - - - - - - - TokenType: - - - {token.tokenType} - - - - - - - - )} + {token.url} + + + + + + + + + + Ticker: + + + {token.ticker} + + + + + + + + + Name: + + + {token.name} + + + + + + + + + Balance: + + + {token.qty} + + + + + + + + + Decimals: + + + {token.decimals} + + + + + + + + + TokenType: + + + {token.tokenType} + + + + + + + + )} @@ -224,19 +261,24 @@ class TokenModal extends React.Component { } handleModal () { - _this.props.handleOnHide() + // if txId exist refresh tokens on close + _this.props.handleOnHide(_this.state.txId) + setTimeout(() => { _this.setState({ - isBurnView: false + isBurnView: false, + txId: '', + errMsg: '', + inFetch: false }) }, 200) } - handleBurnAll (isConfirmed) { + async handleBurnAll (isConfirmed) { try { // Dismiss if (!isConfirmed) { - _this.hideModal() + _this.handleModal() return } @@ -244,13 +286,31 @@ class TokenModal extends React.Component { * BURN ALL * */ - console.log('Hello Word') - } catch (error) {} + _this.setState({ + inFetch: true + }) + const { bchWallet, token } = _this.props + + const result = await bchWallet.burnAll(token.tokenId) + console.log('burn txid: ', result) + _this.setState({ + txId: result, + inFetch: false + }) + } catch (error) { + console.warn(error) + _this.setState({ + errMsg: error.message, + inFetch: false + }) + } } } TokenModal.propTypes = { token: PropTypes.object.isRequired, show: PropTypes.bool.isRequired, - handleOnHide: PropTypes.func.isRequired + handleOnHide: PropTypes.func.isRequired, + bchWallet: PropTypes.object, // get minimal-slp-wallet instance + explorerURL: PropTypes.string } export default TokenModal diff --git a/src/components/admin-lte/wallet/import.js b/src/components/admin-lte/wallet/import.js index cbb3ecd..d06bfdd 100644 --- a/src/components/admin-lte/wallet/import.js +++ b/src/components/admin-lte/wallet/import.js @@ -4,10 +4,7 @@ import { Row, Col, Box, Button, Inputs } from 'adminlte-2-react' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' // import BchWallet from 'minimal-slp-wallet' -const BchWallet = - typeof window !== 'undefined' - ? window.SlpWallet - : null +const BchWallet = typeof window !== 'undefined' ? window.SlpWallet : null const { Text } = Inputs @@ -50,7 +47,7 @@ class ImportWallet extends React.Component { - + - + @@ -151,7 +148,7 @@ class ImportWallet extends React.Component { let currentRate if (bchjs.restURL.includes('abc.fullstack')) { - currentRate = await bchjs.Price.getBchaUsd() * 100 + currentRate = (await bchjs.Price.getBchaUsd()) * 100 } else { // BCHN price. currentRate = (await bchjs.Price.getUsd()) * 100 diff --git a/src/components/admin-lte/wallet/wallet-info.js b/src/components/admin-lte/wallet/wallet-info.js index 7b8d8a0..9c55152 100644 --- a/src/components/admin-lte/wallet/wallet-info.js +++ b/src/components/admin-lte/wallet/wallet-info.js @@ -147,29 +147,6 @@ class WalletInfo extends React.Component { )} - - - - Address: {_this.state.address} - - - - {_this.state.copySuccess === 'address' - ? ( - - Copied! - - ) - : ( - _this.copyToClipBoard('address')} - icon='copy' - /> - )} - - diff --git a/src/components/footer/index.js b/src/components/footer/index.js index 5dce0a9..abd701c 100644 --- a/src/components/footer/index.js +++ b/src/components/footer/index.js @@ -51,7 +51,7 @@ class Footer extends React.Component { this.setState({ ipfsHash: hash, - ipfsHashLink: `https://ipfs-gateway.fullstack.cash/ipfs/${hash}` + ipfsHashLink: `https://ipfs.io/ipfs/${hash}` }) } diff --git a/src/components/version-status.js b/src/components/version-status.js index f93f919..086d796 100644 --- a/src/components/version-status.js +++ b/src/components/version-status.js @@ -3,17 +3,23 @@ import React from 'react' class VersionStatus extends React.Component { constructor (props) { super(props) - this.state = {} + this.state = { + show: false + } } render () { return ( <> - - - Warning: Open Alpha - things will break + {this.state.show && ( + + + + Warning: Open Beta - this app is under active develpment. + + - + )} > ) }
Are you sure you want to burn {`${token.qty} `} tokens?
Transaction ID:
{_this.state.errMsg}
Warning: Open Alpha - things will break
+ Warning: Open Beta - this app is under active develpment. +