Merge pull request #87 from Permissionless-Software-Foundation/ct-unstable

fix(send-tokens): Fixed bug that would only let you send whole tokens
This commit is contained in:
Chris Troutner
2020-10-17 13:27:56 -07:00
committed by GitHub
2 changed files with 33 additions and 18 deletions
+11 -11
View File
@@ -57,18 +57,18 @@ class AdminLTEPage extends React.Component {
<AdminLTE
title={[siteConfig.title]}
titleShort={[siteConfig.titleShort]}
theme="blue"
theme='blue'
>
<Sidebar.Core>
<Item key="Balance" text="Balance" icon={siteConfig.balanceIcon}>
<Item key='Balance' text='Balance' icon={siteConfig.balanceIcon}>
<Box
className="hover-shadow border-none background-none"
className='hover-shadow border-none background-none'
loaded={!_this.state.inFetch}
>
<div className="sidebar-balance">
<div className='sidebar-balance'>
<div>
{!_this.state.inFetch && (
<div className="siderbar-balance-content">
<div className='siderbar-balance-content'>
<span>
<h3>{siteConfig.balanceText}</h3>
@@ -78,9 +78,9 @@ class AdminLTEPage extends React.Component {
<small>USD: ${_this.state.usdBalance}</small>
</span>
<FontAwesomeIcon
className="ml-1 icon"
size="lg"
icon="redo"
className='ml-1 icon'
size='lg'
icon='redo'
onClick={_this.handleGetBalance}
/>
</div>
@@ -98,8 +98,8 @@ class AdminLTEPage extends React.Component {
<Navbar.Core>
<VersionStatus />
</Navbar.Core>
<Layout path="/">
<div className="components-container">
<Layout path='/'>
<div className='components-container'>
{_this.renderNewViewItems(_this.props)}
</div>
</Layout>
@@ -334,7 +334,7 @@ class AdminLTEPage extends React.Component {
return (
<li style={{ display: 'none' }}>
{/* Adding this childrens prevents console errors */}
<a href="#">
<a href='#'>
<span />
<span />
</a>
+22 -7
View File
@@ -6,10 +6,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import ScannerModal from '../../qr-scanner/modal'
const { Text } = Inputs
const BchWallet =
typeof window !== 'undefined'
? window.SlpWallet
: null
const BchWallet = typeof window !== 'undefined' ? window.SlpWallet : null
let _this
class SendTokens extends React.Component {
@@ -97,7 +94,6 @@ class SendTokens extends React.Component {
/>
</Col>
</Row>
</Box>
</Col>
<Col sm={12} className='text-center'>
@@ -161,15 +157,18 @@ class SendTokens extends React.Component {
const bchWalletLib = _this.props.bchWallet
const { address, amountSat } = _this.state
const { tokenId, qty } = _this.props.selectedToken
// console.log(`qty: ${qty}`)
if (!tokenId) {
throw new Error('There is no token selected')
}
const receiver = {
address,
tokenId,
qty: Math.floor(Number(amountSat))
qty: amountSat
}
if (qty < receiver.qty) {
throw new Error('Insufficient balance')
}
@@ -188,6 +187,23 @@ class SendTokens extends React.Component {
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(
// `bchWalletLib.utxos.bchUtxos: ${JSON.stringify(
// bchWalletLib.utxos.bchUtxos,
// null,
// 2
// )}`
// )
// console.log(
// `bchWalletLib.utxos.tokenUtxos: ${JSON.stringify(
// bchWalletLib.utxos.tokenUtxos,
// null,
// 2
// )}`
// )
// Send token.
const result = await bchWalletLib.sendTokens(receiver, 5.0)
// console.log('result: ', result)
@@ -336,7 +352,6 @@ class SendTokens extends React.Component {
componentDidMount () {
_this.setState({
tokenId: _this.props.selectedToken.tokenId
})
}