Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Allow pasting URIs into send address
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapk00 committed Feb 14, 2021
1 parent 8dd2bbb commit ce2085c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ export default class RouteApp extends React.Component<Props, AppState> {
render={() => (
<Send
addresses={addresses}
setSendTo={this.setSendTo}
sendTransaction={this.sendTransaction}
sendPageState={sendPageState}
setSendPageState={this.setSendPageState}
Expand Down
12 changes: 11 additions & 1 deletion app/components/Send.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { ErrorModal } from './ErrorModal';
import { BalanceBlockHighlight } from './BalanceBlocks';
import RPC from '../rpc';
import routes from '../constants/routes.json';
import { parseZcashURI, ZcashURITarget } from '../utils/uris';

type OptionType = {
value: string,
Expand Down Expand Up @@ -337,6 +338,7 @@ type Props = {
totalBalance: TotalBalance,
addressBook: AddressBookEntry[],
sendPageState: SendPageState,
setSendTo: (targets: ZcashURITarget[] | ZcashURITarget) => void,
sendTransaction: (sendJson: []) => string,
setSendPageState: (sendPageState: SendPageState) => void,
openErrorModal: (title: string, body: string) => void,
Expand Down Expand Up @@ -408,12 +410,20 @@ export default class Send extends PureComponent<Props, SendState> {
};

updateToField = (id: number, address: Event | null, amount: Event | null, memo: Event | string | null) => {
const { sendPageState, setSendPageState } = this.props;
const { sendPageState, setSendPageState, setSendTo } = this.props;

const newToAddrs = sendPageState.toaddrs.slice(0);
// Find the correct toAddr
const toAddr = newToAddrs.find(a => a.id === id);
if (address) {
// First, check if this is a URI
// $FlowFixMe
const parsedUri = parseZcashURI(address.target.value);
if (Array.isArray(parsedUri)) {
setSendTo(parsedUri);
return;
}

// $FlowFixMe
toAddr.to = address.target.value.replace(/ /g, ''); // Remove spaces
}
Expand Down

0 comments on commit ce2085c

Please sign in to comment.