Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BigNumber: ts-ignore #3621

Merged
merged 50 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2f3e89f
Change fee in FAQ. Remove parts ts-ignore
Nov 20, 2020
833a5e9
JSON.stringify ts-ignore
alyavasilyeva Nov 20, 2020
85a46af
Merge branch 'master' into json-stringify-ts
alyavasilyeva Nov 20, 2020
5245e18
Remove all ts-ignore on BigNumber
Nov 20, 2020
446cb16
Delete console.log
Nov 20, 2020
5cb2035
Change fee in FAQ. Remove parts ts-ignore
Nov 20, 2020
9f3110d
Remove all ts-ignore on BigNumber
Nov 20, 2020
377497c
Delete console.log
Nov 20, 2020
6b097a9
Merge
Nov 20, 2020
e83fdec
Fix problem with ts
Nov 20, 2020
a5dbba9
Fix WallerSlider super ts-ignore
alyavasilyeva Nov 20, 2020
eae24a0
Fix Timer super ts-ignore
alyavasilyeva Nov 20, 2020
00dd38b
Merge pull request #3622 from swaponline/components-super-ts
alyavasilyeva Nov 20, 2020
82cf90b
Change fee in FAQ. Remove parts ts-ignore
Nov 20, 2020
f82b36d
Remove all ts-ignore on BigNumber
Nov 20, 2020
367baa6
Delete console.log
Nov 20, 2020
3ea118e
Change fee in FAQ. Remove parts ts-ignore
Nov 20, 2020
c4ca3d7
Delete console.log
Nov 20, 2020
18d3e7c
Fix problem with ts
Nov 20, 2020
eb3f6db
Bump aegir from 20.6.1 to 29.0.1
dependabot-preview[bot] Nov 20, 2020
2626675
Merge pull request #3620 from swaponline/json-stringify-ts
iower Nov 20, 2020
39fd01b
change checking in send form
Nov 20, 2020
13d569d
Merge branch 'removeTsIgnoreBigNumber' of https://github.com/NotEtern…
Nov 20, 2020
f169dc5
Change fee
Nov 20, 2020
3b1591e
Merge pull request #3624 from swaponline/dependabot/npm_and_yarn/aegi…
Nov 20, 2020
7af2adf
Merge pull request #3626 from NotEternal/fixFeeInFaq
noxonsu Nov 20, 2020
4659c11
Merge ADD_BLOCKCHAIN.MD + ADD_BLOCKCHAIN_CORE.md (#3511 #3242)
iower Nov 22, 2020
e0719e3
Docs: ADD_BLOCKCHAIN - fix routes (not ideal but better) (#3242 #3511)
iower Nov 22, 2020
afe24f9
Cleanup: remove coveralls script from package.json (#3511)
iower Nov 22, 2020
efc4205
Docs: add ETH-NEXT to the swap directions table (#3309)
iower Nov 22, 2020
e33ff33
Docs: move readme's together (BOT.md, CORE.md) (#3242 #3511)
iower Nov 22, 2020
51a3c87
Some docs fixes
iower Nov 22, 2020
f17a075
Merge pull request #3635 from swaponline/cleanup
noxonsu Nov 23, 2020
d1463d6
Merge master
Nov 23, 2020
9ba10dd
Remove all ts-ignore on BigNumber
Nov 20, 2020
f727c94
Delete console.log
Nov 20, 2020
4b1baf4
Change fee in FAQ. Remove parts ts-ignore
Nov 20, 2020
3006c48
Delete console.log
Nov 20, 2020
bbbbb06
Fix problem with ts
Nov 20, 2020
02ab617
change checking in send form
Nov 20, 2020
5d07894
Rebase
Nov 23, 2020
c1a3bd9
Delete console.log
Nov 20, 2020
f9fb174
Rebase
Nov 23, 2020
3ffeb1f
Delete console.log
Nov 20, 2020
a0a1278
Pull from origin
Nov 23, 2020
1da7301
Block button while the request is running
Nov 23, 2020
0832221
Change keydown check
Nov 23, 2020
15d7e32
Remove ts-ignore on psbt.addOutput
Nov 23, 2020
34d4d13
Remove some ts-ignore on feeValue
Nov 23, 2020
3265a83
Add display admin fee
Nov 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/front/shared/components/FAQ/FAQ.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,12 @@ const FAQ = (props) => {
try {
const BYTE_IN_KB = 1024
btcApiResult = await api.asyncFetchApi(btcLink)
setBtcFee(new BigNumber(btcApiResult.low_fee_per_kb / BYTE_IN_KB).dp(5, BigNumber.ROUND_FLOOR).toString())
setBtcFee(Math.ceil((btcApiResult.high_fee_per_kb / BYTE_IN_KB)))

ethApiResult = await api.asyncFetchApi(ethLink)
setEthFee(new BigNumber(ethApiResult.fastest).dp(5, BigNumber.ROUND_FLOOR).toString())
setEthFee(ethApiResult.fastest)
} catch(err) {
console.log('FAQ -> useEffect: ', err);

setBtcFee(new BigNumber(minAmount.btc).dp(5, BigNumber.ROUND_FLOOR).toString())
setEthFee(new BigNumber(minAmount.eth).dp(5, BigNumber.ROUND_FLOOR).toString())
}
}

Expand Down Expand Up @@ -133,7 +130,7 @@ const FAQ = (props) => {
<p className={styles.descriptionFee}>
<span>ETH:</span>{' '}
{ethFee
? <span><b>{ethFee}</b> sat/byte</span>
? <span><b>{ethFee}</b> gwei</span>
: <FormattedMessage id="MainFAQ2_content4" defaultMessage="Loading" />
}
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,11 @@ export default class AddOffer extends Component<any, any> {
}

updateExchangeRate = async (sellCurrency, buyCurrency) => {
const exchangeRateSell = await actions.user.getExchangeRate(sellCurrency, 'usd')
const exchangeRateBuy = await actions.user.getExchangeRate(buyCurrency, 'usd')
const exchangeRateSell: any = await actions.user.getExchangeRate(sellCurrency, 'usd')
const exchangeRateBuy: any = await actions.user.getExchangeRate(buyCurrency, 'usd')

const exchangeRate = sellCurrency === 'swap' || buyCurrency === 'swap'
? await actions.user.getExchangeRate(sellCurrency, buyCurrency)
//@ts-ignore
: new BigNumber(exchangeRateSell).div(exchangeRateBuy).dp(4, BigNumber.ROUND_CEIL)

return new Promise((resolve, reject) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export default class WithdrawModal extends React.Component<any, any> {
const currentCoin = getCurrencyKey(currency, true).toLowerCase()

if (isEthToken) {
minAmount[currentCoin] = this.getMinAmountForEthToken()
minAmount[currentCoin] = +this.getMinAmountForEthToken()
//@ts-ignore
minAmount.eth = await helpers.eth.estimateFeeValue({
method: 'send',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ export default class WithdrawModalMultisig extends React.Component<any, any> {

actualyMinAmount = async () => {
const { usedAdminFee } = this.state
//@ts-ignore
let min = await helpers['btc'].estimateFeeValue({ method: 'send_2fa', speed: 'fast' })

let min: any = await helpers['btc'].estimateFeeValue({ method: 'send_2fa', speed: 'fast' })
minAmount['btc_multisig_2fa'] = min

if (usedAdminFee) {
Expand All @@ -166,8 +166,8 @@ export default class WithdrawModalMultisig extends React.Component<any, any> {
const {
data: { unconfirmedBalance },
} = this.props
//@ts-ignore
const balance = await actions.btcmultisig.getBalance()

const balance: any = await actions.btcmultisig.getBalance()

const finalBalance =
unconfirmedBalance !== undefined && unconfirmedBalance < 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,14 @@ export default class WithdrawModalMultisigUser extends React.Component<any, any>

this.broadcastCancelFunc = false

let usedAdminFee = false
let usedAdminFee: any = false

let min = minAmount['btc_multisig_2n2']

if (config && config.opts && config.opts.fee && config.opts.fee.btc) {
usedAdminFee = config.opts.fee.btc
if (usedAdminFee) {
// miner fee + minimal admin fee
//@ts-ignore
min = new BigNumber(min).plus(usedAdminFee.min).toNumber()
}
}
Expand Down Expand Up @@ -130,13 +129,11 @@ export default class WithdrawModalMultisigUser extends React.Component<any, any>
actualyMinAmount = async () => {
const { usedAdminFee } = this.state

//@ts-ignore
let min = await helpers['btc'].estimateFeeValue({ method: 'send_multisig', speed: 'fast' })
let min: any = await helpers['btc'].estimateFeeValue({ method: 'send_multisig', speed: 'fast' })
minAmount['btc_multisig_2n2'] = min

if (usedAdminFee) {
//@ts-ignore
min = BigNumber(min).plus(usedAdminFee.min).toNumber()
min = new BigNumber(min).plus(usedAdminFee.min).toNumber()
}

this.setState({
Expand Down
12 changes: 5 additions & 7 deletions src/front/shared/helpers/adminFee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ const calc = (currency, amount) => {
const usedAdminFee = isEnabled(currency)

if (usedAdminFee) {
//@ts-ignore
let fee = (usedAdminFee.min) ? BigNumber(usedAdminFee.min).toNumber() : 0
//@ts-ignore
if (amount && BigNumber(amount).isGreaterThan(0)) {
//@ts-ignore
let fee = (usedAdminFee.min) ? new BigNumber(usedAdminFee.min).toNumber() : 0

if (amount && new BigNumber(amount).isGreaterThan(0)) {
let feeFromAmount = new BigNumber(usedAdminFee.fee).dividedBy(100).multipliedBy(amount)
//@ts-ignore
if (BigNumber(usedAdminFee.min).isGreaterThan(feeFromAmount)) feeFromAmount = new BigNumber(usedAdminFee.min)

if (new BigNumber(usedAdminFee.min).isGreaterThan(feeFromAmount)) feeFromAmount = new BigNumber(usedAdminFee.min)

fee = feeFromAmount.toNumber() // Admin fee in satoshi
}
Expand Down
7 changes: 2 additions & 5 deletions src/front/shared/helpers/btc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const calculateTxSize = async ({ speed, unspents, address, txOut = 2, method = '
}

//@ts-ignore
const estimateFeeValue = async ({ feeRate, inSatoshis, speed, address, txSize, fixed, method } = {}) => {
const estimateFeeValue = async ({ feeRate, inSatoshis, speed, address, txSize, fixed, method }: object = {}) => {
const {
user: {
btcData,
Expand All @@ -160,8 +160,7 @@ const estimateFeeValue = async ({ feeRate, inSatoshis, speed, address, txSize, f

const calculatedFeeValue = BigNumber.maximum(
DUST,
//@ts-ignore
BigNumber(feeRate)
new BigNumber(feeRate)
.multipliedBy(txSize)
.div(1024)
.dp(0, BigNumber.ROUND_HALF_EVEN),
Expand Down Expand Up @@ -197,7 +196,6 @@ const estimateFeeRateBitcoinfees = async ({ speed = 'fast' } = {}) => {
}
//@ts-ignore
const apiSpeed = apiSpeeds[speed] || apiSpeed.normal
//@ts-ignore
const apiRate = new BigNumber(apiResult[apiSpeed]).multipliedBy(1024)

return apiRate.isGreaterThanOrEqualTo(DUST)
Expand Down Expand Up @@ -229,7 +227,6 @@ const estimateFeeRateBlockcypher = async ({ speed = 'fast' } = {}) => {
}
//@ts-ignore
const apiSpeed = apiSpeeds[speed] || apiSpeed.normal
//@ts-ignore
const apiRate = new BigNumber(apiResult[apiSpeed])

return apiRate.isGreaterThanOrEqualTo(DUST)
Expand Down
6 changes: 5 additions & 1 deletion src/front/shared/helpers/constants/minAmount.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
const minAmount = {
interface MinAmount {
[propName: string]: number;
}

const minAmount: MinAmount = {
eth: 0.001,
btc: 0.00015,
ghost: 0.00015,
Expand Down
2 changes: 0 additions & 2 deletions src/front/shared/helpers/externalConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,12 @@ const externalConfig = () => {
// @ToDo add currency isAddress Check
if (fee && address && min) {
try {
//@ts-ignore
fee = new BigNumber(fee.replace(',', '.')).toNumber()
feeOk = true
} catch (e) {
console.error(`Fail convert ${fee} to number for ${curKey}`)
}
try {
//@ts-ignore
min = new BigNumber(min.replace(',', '.')).toNumber()
minOk = true
} catch (e) {
Expand Down
5 changes: 1 addition & 4 deletions src/front/shared/helpers/ghost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ const estimateFeeValue = async ({ feeRate, inSatoshis, speed, address, txSize, f

const calculatedFeeValue = BigNumber.maximum(
DUST,
//@ts-ignore
BigNumber(feeRate)
new BigNumber(feeRate)
.multipliedBy(txSize)
.div(1024)
.dp(0, BigNumber.ROUND_HALF_EVEN),
Expand Down Expand Up @@ -230,8 +229,6 @@ const estimateFeeRate = async ({ speed = 'fast' } = {}) => {

//@ts-ignore
const apiSpeed = apiSpeeds[speed] || apiSpeed.normal

//@ts-ignore
const apiRate = new BigNumber(apiResult[apiSpeed])

return apiRate.isGreaterThanOrEqualTo(DUST)
Expand Down
5 changes: 1 addition & 4 deletions src/front/shared/helpers/next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ const estimateFeeValue = async ({ feeRate, inSatoshis, speed, address, txSize, f

const calculatedFeeValue = BigNumber.maximum(
DUST,
//@ts-ignore
BigNumber(feeRate)
new BigNumber(feeRate)
.multipliedBy(txSize)
.div(1024)
.dp(0, BigNumber.ROUND_HALF_EVEN),
Expand Down Expand Up @@ -230,8 +229,6 @@ const estimateFeeRate = async ({ speed = 'fast' } = {}) => {

//@ts-ignore
const apiSpeed = apiSpeeds[speed] || apiSpeed.normal

//@ts-ignore
const apiRate = new BigNumber(apiResult[apiSpeed])

return apiRate.isGreaterThanOrEqualTo(DUST)
Expand Down
3 changes: 1 addition & 2 deletions src/front/shared/pages/CurrencyWallet/CurrencyWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,7 @@ export default class CurrencyWallet extends Component<any, any> {

if (infoAboutCurrency && infoAboutCurrency.price_fiat) {
currencyFiatBalance =
//@ts-ignore
BigNumber(balance).dp(6, BigNumber.ROUND_FLOOR).toString() * infoAboutCurrency.price_fiat
new BigNumber(balance).dp(6, BigNumber.ROUND_FLOOR).toString() as any * infoAboutCurrency.price_fiat as any
changePercent = infoAboutCurrency.percent_change_1h
} else {
currencyFiatBalance = 0
Expand Down
10 changes: 3 additions & 7 deletions src/front/shared/pages/Wallet/Row/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,7 @@ export default class Row extends Component<any, any> {
const isWidgetBuild = config && config.isWidget

if (itemData.infoAboutCurrency && itemData.infoAboutCurrency.price_fiat) {
//@ts-ignore
currencyFiatBalance = new BigNumber(balance).multipliedBy(itemData.infoAboutCurrency.price_fiat)
currencyFiatBalance = new BigNumber(balance).multipliedBy(itemData.infoAboutCurrency.price_fiat).toNumber()
}

let hasHowToWithdraw = false
Expand Down Expand Up @@ -1038,8 +1037,7 @@ export default class Row extends Component<any, any> {
<span>
{balanceError
? '?'
//@ts-ignore
: BigNumber(balance)
: new BigNumber(balance)
.dp(5, BigNumber.ROUND_FLOOR)
.toString()}{' '}
</span>
Expand Down Expand Up @@ -1120,9 +1118,7 @@ export default class Row extends Component<any, any> {
)}
{currencyFiatBalance && showBalance && !balanceError && (
<>
{/*
//@ts-ignore */}
<p>{BigNumber(currencyFiatBalance).dp(2, BigNumber.ROUND_FLOOR).toString()}</p>
<p>{new BigNumber(currencyFiatBalance).dp(2, BigNumber.ROUND_FLOOR).toString()}</p>
<strong>{activeFiat}</strong>
</>
)}
Expand Down
19 changes: 6 additions & 13 deletions src/front/shared/pages/Wallet/Wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -477,19 +477,14 @@ export default class Wallet extends Component<any, any> {
//@ts-ignore
registrationData.widget_url = widgetUrl
}
//@ts-ignore
const tokensArray = Object.values(this.props.tokensData)

const tokensArray: any[] = Object.values(this.props.tokensData)

const wallets = tokensArray.map((item) => ({
//@ts-ignore
symbol: item && item.currency ? item.currency.split(' ')[0] : '',
//@ts-ignore
type: item && item.currency ? item.currency.split(' ')[1] || 'common' : '',
//@ts-ignore
address: item && item.address ? item.address : '',
//@ts-ignore
balance: item && item.balance ? BigNumber(item.balance).toNumber() : 0,
//@ts-ignore
balance: item && item.balance ? new BigNumber(item.balance).toNumber() : 0,
public_key: item && item.publicKey ? item.publicKey.toString('Hex') : '',
// TODO: let this work
// nounce: 1,
Expand Down Expand Up @@ -591,9 +586,7 @@ export default class Wallet extends Component<any, any> {
//@ts-ignore
fiatBalance:
el.balance > 0 && el.infoAboutCurrency && el.infoAboutCurrency.price_fiat
? // comment for ts-ignore
//@ts-ignore
BigNumber(el.balance)
? new BigNumber(el.balance)
.multipliedBy(el.infoAboutCurrency.price_fiat)
.dp(2, BigNumber.ROUND_FLOOR)
: 0,
Expand All @@ -614,8 +607,8 @@ export default class Wallet extends Component<any, any> {
btcBalance += balance * infoAboutCurrency.price_btc
}
})
//@ts-ignore
const allFiatBalance = tableRows.reduce((acc, cur) => BigNumber(cur.fiatBalance).plus(acc), 0)

const allFiatBalance = tableRows.reduce((acc, cur) => new BigNumber(cur.fiatBalance).plus(acc), 0)

return (
<DashboardLayout
Expand Down
17 changes: 7 additions & 10 deletions src/front/shared/redux/actions/btc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,17 +428,15 @@ const sendWithAdminFee = async ({ from, to, amount, feeValue, speed } = {}) => {
address: adminFeeAddress,
min: adminFeeMinValue,
} = config.opts.fee.btc
//@ts-ignore

const adminFeeMin = new BigNumber(adminFeeMinValue)

// fee - from amount - percent
//@ts-ignore
let feeFromAmount = new BigNumber(adminFee).dividedBy(100).multipliedBy(amount)
if (adminFeeMin.isGreaterThan(feeFromAmount)) feeFromAmount = adminFeeMin

feeFromAmount = feeFromAmount.multipliedBy(1e8).integerValue() // Admin fee in satoshi

//@ts-ignore
feeValue = feeValue || await btc.estimateFeeValue({ inSatoshis: true, speed })

const tx = new bitcoin.TransactionBuilder(btc.network)
Expand Down Expand Up @@ -475,29 +473,28 @@ const sendV5 = ({ from, to, amount, feeValue, speed, stateCallback } = {}) => {
const keyPair = bitcoin.ECPair.fromWIF(privateKey, btc.network)

// fee - from amount - percent
//@ts-ignore
let feeFromAmount = new BigNumber(0)
if (hasAdminFee) {
const {
fee: adminFee,
min: adminFeeMinValue,
} = config.opts.fee.btc
//@ts-ignore

const adminFeeMin = new BigNumber(adminFeeMinValue)
//@ts-ignore

feeFromAmount = new BigNumber(adminFee).dividedBy(100).multipliedBy(amount)
if (adminFeeMin.isGreaterThan(feeFromAmount)) feeFromAmount = adminFeeMin
//@ts-ignore
feeFromAmount = feeFromAmount.multipliedBy(1e8).integerValue().toNumber() // Admin fee in satoshi

feeFromAmount = feeFromAmount.multipliedBy(1e8).integerValue() // Admin fee in satoshi
}
//@ts-ignore
feeValue = feeValue || await btc.estimateFeeValue({ inSatoshis: true, speed})

const unspents = await fetchUnspents(from)
const fundValue = new BigNumber(String(amount)).multipliedBy(1e8).integerValue().toNumber()
const totalUnspent = unspents.reduce((summ, { satoshis }) => summ + satoshis, 0)
//@ts-ignore
const skipValue = totalUnspent - fundValue - feeValue - feeFromAmount

const skipValue = totalUnspent - fundValue - feeValue - feeFromAmount.toNumber()

const psbt = new bitcoin.Psbt({network: btc.network})

Expand Down
Loading