Browse Source

Auto tag from qrcode/pasting on ripple addresses

gre-patch-1
Juan Cortes Ross 6 years ago
parent
commit
548762b09a
No known key found for this signature in database GPG Key ID: 34A99C03E9455EB8
  1. 24
      src/bridge/RippleJSBridge.js
  2. 9
      src/components/AdvancedOptions/RippleKind.js

24
src/bridge/RippleJSBridge.js

@ -463,10 +463,30 @@ const RippleJSBridge: WalletBridge<Transaction> = {
getTransactionAmount: (a, t) => t.amount, getTransactionAmount: (a, t) => t.amount,
editTransactionRecipient: (account, t, recipient) => ({ editTransactionRecipient: (account, t, recipient) => {
const parts = recipient.split('?')
const params = new URLSearchParams(parts[1])
recipient = parts[0]
// Extract parameters we may need
for (const [key, value] of params.entries()) {
switch (key) {
case 'dt':
t.tag = parseInt(value, 10) || 0
break
case 'amount':
t.amount = parseAPIValue(value || '0')
break
default:
// do nothing
}
}
return {
...t, ...t,
recipient, recipient,
}), }
},
EditFees, EditFees,

9
src/components/AdvancedOptions/RippleKind.js

@ -5,7 +5,6 @@ import { translate } from 'react-i18next'
import Box from 'components/base/Box' import Box from 'components/base/Box'
import Input from 'components/base/Input' import Input from 'components/base/Input'
import Label from 'components/base/Label' import Label from 'components/base/Label'
import Spoiler from 'components/base/Spoiler'
type Props = { type Props = {
tag: ?number, tag: ?number,
@ -14,14 +13,11 @@ type Props = {
} }
export default translate()(({ tag, onChangeTag, t }: Props) => ( export default translate()(({ tag, onChangeTag, t }: Props) => (
<Spoiler title={t('app:send.steps.amount.advancedOptions')}> <Box vertical flow={5}>
<Box horizontal align="center" flow={5}> <Box grow>
<Box style={{ width: 200 }}>
<Label> <Label>
<span>{t('app:send.steps.amount.rippleTag')}</span> <span>{t('app:send.steps.amount.rippleTag')}</span>
</Label> </Label>
</Box>
<Box grow>
<Input <Input
value={String(tag || '')} value={String(tag || '')}
onChange={str => { onChange={str => {
@ -32,5 +28,4 @@ export default translate()(({ tag, onChangeTag, t }: Props) => (
/> />
</Box> </Box>
</Box> </Box>
</Spoiler>
)) ))

Loading…
Cancel
Save