Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab-components/src/hoc/CashtabBase/CashtabBase.tsx
Show First 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | return class extends React.Component<CashtabBaseProps, IState> { | ||||
if (typeof window !== 'undefined') { | if (typeof window !== 'undefined') { | ||||
window.open(Ticker.installLink); | window.open(Ticker.installLink); | ||||
} | } | ||||
return; | return; | ||||
} | } | ||||
if (walletProviderStatus) { | if (walletProviderStatus) { | ||||
this.setState({ step: 'fresh' }); | this.setState({ step: 'fresh' }); | ||||
// Do not pass a token quantity to send, this is not yet supported in Cashtab | |||||
if (coinType === Ticker.tokenName) { | |||||
return; | |||||
} | |||||
Fabien: This seems unrelated to the changes, and maybe deserve a meaningful error message ? | |||||
bytesofmanAuthorUnsubmitted Done Inline Actionswill include in separate diff bytesofman: will include in separate diff | |||||
return window.postMessage( | return window.postMessage( | ||||
{ | { | ||||
type: 'FROM_PAGE', | type: 'FROM_PAGE', | ||||
text: 'CashTab', | text: 'CashTab', | ||||
txInfo: { | txInfo: { | ||||
address: to, | address: to, | ||||
value: satoshis ? satoshis! / 1e8 : amount, | value: satoshis | ||||
? parseFloat( | |||||
( | |||||
satoshis! * | |||||
10 ** (-1 * Ticker.coinDecimals) | |||||
).toFixed(2), | |||||
) | |||||
: amount, | |||||
}, | }, | ||||
}, | }, | ||||
'*', | '*', | ||||
); | ); | ||||
} | } | ||||
const sendParams: sendParamsArr = { | const sendParams: sendParamsArr = { | ||||
to, | to, | ||||
protocol: coinType, | protocol: coinType, | ||||
value: amount?.toString() || adjustAmount(satoshis, 8, true), | value: amount?.toString() || adjustAmount(satoshis, 8, true), | ||||
}; | }; | ||||
if (coinType === Ticker.tokenTicker) { | if (coinType === Ticker.tokenTicker) { | ||||
sendParams.assetId = tokenId; | sendParams.assetId = tokenId; | ||||
} | } | ||||
if (opReturn && opReturn.length) { | if (opReturn && opReturn.length) { | ||||
sendParams.opReturn = opReturn; | sendParams.opReturn = opReturn; | ||||
} | } | ||||
this.setState({ step: 'pending' }); | this.setState({ step: 'pending' }); | ||||
/* May match this functionality later, may handle differently as above for Cashtab | |||||
FabienUnsubmitted Not Done Inline ActionsI suppose it's not needed because it's a lib ? In any case this doesn't belong to this patch Fabien: I suppose it's not needed because it's a lib ? In any case this doesn't belong to this patch | |||||
bytesofmanAuthorUnsubmitted Done Inline Actionswill move to separate diff bytesofman: will move to separate diff | |||||
console.info('Cashtab sendAssets begin', sendParams); | |||||
sendAssets(sendParams) | |||||
.then(({ txid }: any) => { | |||||
console.info('Cashtab send success:', txid); | |||||
successFn && successFn(txid); | |||||
this.paymentSendSuccess(); | |||||
}) | |||||
.catch((err: any) => { | |||||
console.info('Cashtab send cancel', err); | |||||
failFn && failFn(err); | |||||
this.setState({ step: 'fresh' }); | |||||
}); | |||||
*/ | |||||
}; | }; | ||||
updateSatoshisFiat = debounce( | updateSatoshisFiat = debounce( | ||||
async () => { | async () => { | ||||
const { price, currency } = this.props; | const { price, currency } = this.props; | ||||
if (!price) return; | if (!price) return; | ||||
const satoshis = await fiatToSatoshis(currency, price); | const satoshis = await fiatToSatoshis(currency, price); | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | return class extends React.Component<CashtabBaseProps, IState> { | ||||
coinSymbol: symbol, | coinSymbol: symbol, | ||||
coinDecimals: decimals, | coinDecimals: decimals, | ||||
coinName: name, | coinName: name, | ||||
}); | }); | ||||
} | } | ||||
}; | }; | ||||
confirmCashTabProviderStatus = () => { | confirmCashTabProviderStatus = () => { | ||||
console.log(`confirmCashTabProviderStatus called`); | |||||
const cashTabStatus = this.getCashTabProviderStatus(); | const cashTabStatus = this.getCashTabProviderStatus(); | ||||
if (cashTabStatus) { | if (cashTabStatus) { | ||||
this.setState({ step: 'fresh' }); | this.setState({ step: 'fresh' }); | ||||
} | } | ||||
}; | }; | ||||
async componentDidMount() { | async componentDidMount() { | ||||
if (typeof window !== 'undefined') { | if (typeof window !== 'undefined') { | ||||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |
This seems unrelated to the changes, and maybe deserve a meaningful error message ?