Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/hooks/useBCH.js
import BigNumber from 'bignumber.js'; | import BigNumber from 'bignumber.js'; | ||||
import { currency } from '@components/Common/Ticker'; | import { currency } from '@components/Common/Ticker'; | ||||
import SlpWallet from 'minimal-slp-wallet'; | |||||
import { | import { | ||||
toSmallestDenomination, | toSmallestDenomination, | ||||
batchArray, | batchArray, | ||||
flattenBatchedHydratedUtxos, | flattenBatchedHydratedUtxos, | ||||
} from '@utils/cashMethods'; | } from '@utils/cashMethods'; | ||||
export default function useBCH() { | export default function useBCH() { | ||||
▲ Show 20 Lines • Show All 809 Lines • ▼ Show 20 Lines | ) => { | ||||
) { | ) { | ||||
err.code = SEND_BCH_ERRORS.MAX_UNCONFIRMED_TXS; | err.code = SEND_BCH_ERRORS.MAX_UNCONFIRMED_TXS; | ||||
} | } | ||||
console.log(`error: `, err); | console.log(`error: `, err); | ||||
throw err; | throw err; | ||||
} | } | ||||
}; | }; | ||||
const getBCH = (apiIndex = 0) => { | const getBCH = (apiIndex = 0, fromWindowObject = true) => { | ||||
let ConstructedSlpWallet; | if (fromWindowObject && window.SlpWallet) { | ||||
const SlpWallet = new window.SlpWallet('', { | |||||
ConstructedSlpWallet = new SlpWallet('', { | |||||
restURL: getRestUrl(apiIndex), | restURL: getRestUrl(apiIndex), | ||||
}); | }); | ||||
return ConstructedSlpWallet.bchjs; | return SlpWallet.bchjs; | ||||
} | |||||
}; | }; | ||||
return { | return { | ||||
getBCH, | getBCH, | ||||
calcFee, | calcFee, | ||||
getUtxos, | getUtxos, | ||||
getHydratedUtxoDetails, | getHydratedUtxoDetails, | ||||
getSlpBalancesAndUtxos, | getSlpBalancesAndUtxos, | ||||
Show All 11 Lines |