mirror of
https://github.com/urbit/shrub.git
synced 2024-12-24 11:24:21 +03:00
Cleanup walletModal, transaction, invoice
This commit is contained in:
parent
12c5306ac0
commit
6608c04186
@ -1,4 +1,4 @@
|
|||||||
import React, { useRef, useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Icon,
|
Icon,
|
||||||
@ -57,7 +57,6 @@ const Invoice = ({ stopSending, payee, satsAmount }) => {
|
|||||||
const [ready, setReady] = useState(false);
|
const [ready, setReady] = useState(false);
|
||||||
const [localError, setLocalError] = useState(error);
|
const [localError, setLocalError] = useState(error);
|
||||||
const [broadcasting, setBroadcasting] = useState(false);
|
const [broadcasting, setBroadcasting] = useState(false);
|
||||||
const invoiceRef = useRef();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (broadcasting && localError !== '') {
|
if (broadcasting && localError !== '') {
|
||||||
@ -65,17 +64,6 @@ const Invoice = ({ stopSending, payee, satsAmount }) => {
|
|||||||
}
|
}
|
||||||
}, [error, broadcasting, setBroadcasting]);
|
}, [error, broadcasting, setBroadcasting]);
|
||||||
|
|
||||||
const clickDismiss = (e) => {
|
|
||||||
if (invoiceRef && !invoiceRef.contains(e.target)) {
|
|
||||||
stopSending();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
document.addEventListener('click', clickDismiss);
|
|
||||||
return () => document.removeEventListener('click', clickDismiss);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const broadCastTx = (psbtHex) => {
|
const broadCastTx = (psbtHex) => {
|
||||||
let command = {
|
let command = {
|
||||||
'broadcast-tx': psbtHex,
|
'broadcast-tx': psbtHex,
|
||||||
@ -90,6 +78,7 @@ const Invoice = ({ stopSending, payee, satsAmount }) => {
|
|||||||
ticket,
|
ticket,
|
||||||
ship: parseInt(patp2dec('~' + window.ship)),
|
ship: parseInt(patp2dec('~' + window.ship)),
|
||||||
}).then((urbitWallet) => {
|
}).then((urbitWallet) => {
|
||||||
|
// this wasn't being used, not clear why it was pulled out.
|
||||||
// const { xpub } =
|
// const { xpub } =
|
||||||
// network === 'testnet'
|
// network === 'testnet'
|
||||||
// ? urbitWallet.bitcoinTestnet.keys
|
// ? urbitWallet.bitcoinTestnet.keys
|
||||||
@ -127,11 +116,11 @@ const Invoice = ({ stopSending, payee, satsAmount }) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkTicket = (e) => {
|
const checkTicket = ({ target: { value } }) => {
|
||||||
// TODO: port over bridge ticket validation logic
|
// TODO: port over bridge ticket validation logic
|
||||||
setMasterTicket(e.target.value);
|
setMasterTicket(value);
|
||||||
setReady(isValidPatq(e.target.value));
|
setReady(isValidPatq(value));
|
||||||
setLocalError(isValidPatq(e.target.value) ? '' : 'invalid-master-ticket');
|
setLocalError(isValidPatq(value) ? '' : 'invalid-master-ticket');
|
||||||
};
|
};
|
||||||
|
|
||||||
let inputColor = 'black';
|
let inputColor = 'black';
|
||||||
@ -168,13 +157,11 @@ const Invoice = ({ stopSending, payee, satsAmount }) => {
|
|||||||
<Sent payee={payee} stopSending={stopSending} satsAmount={satsAmount} />
|
<Sent payee={payee} stopSending={stopSending} satsAmount={satsAmount} />
|
||||||
) : (
|
) : (
|
||||||
<Col
|
<Col
|
||||||
ref={invoiceRef}
|
|
||||||
width="100%"
|
width="100%"
|
||||||
backgroundColor="white"
|
backgroundColor="white"
|
||||||
borderRadius="48px"
|
borderRadius="48px"
|
||||||
mb={5}
|
mb={5}
|
||||||
p={5}
|
p={5}
|
||||||
onClick={() => stopSending()}
|
|
||||||
>
|
>
|
||||||
<Col
|
<Col
|
||||||
p={5}
|
p={5}
|
||||||
@ -236,7 +223,7 @@ const Invoice = ({ stopSending, payee, satsAmount }) => {
|
|||||||
color={inputColor}
|
color={inputColor}
|
||||||
backgroundColor={inputBg}
|
backgroundColor={inputBg}
|
||||||
borderColor={inputBorder}
|
borderColor={inputBorder}
|
||||||
onChange={() => checkTicket()}
|
onChange={(e) => checkTicket(e)}
|
||||||
/>
|
/>
|
||||||
</Row>
|
</Row>
|
||||||
{error !== '' && (
|
{error !== '' && (
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { Component } from 'react';
|
import React from 'react';
|
||||||
import { Box, Text, Col } from '@tlon/indigo-react';
|
import { Box, Text, Col } from '@tlon/indigo-react';
|
||||||
import Transaction from './transaction.js';
|
import Transaction from './transaction.js';
|
||||||
import { useSettings } from '../../hooks/useSettings.js';
|
import { useSettings } from '../../hooks/useSettings.js';
|
||||||
|
@ -39,11 +39,7 @@ const WalletModal = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkXPub = ({
|
const checkXPub = ({ target: { value: xpubGiven } }) => {
|
||||||
event: {
|
|
||||||
target: { value: xpubGiven },
|
|
||||||
},
|
|
||||||
}) => {
|
|
||||||
setXpub(xpubGiven);
|
setXpub(xpubGiven);
|
||||||
setReadyToSubmit(xpubGiven.length > 0);
|
setReadyToSubmit(xpubGiven.length > 0);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user