Skip to content

Commit

Permalink
Merge branch 'release/v3.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
yknl committed May 23, 2019
2 parents e47e86d + 8d51263 commit d21d08b
Show file tree
Hide file tree
Showing 37 changed files with 29,192 additions and 273 deletions.
5 changes: 5 additions & 0 deletions app/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ const IS_PROD = process.env.NODE_ENV === "production";
const ROUTES = {
TERMS: "/",
DASHBOARD: "/dashboard",
SETUP: "/setup",
NEW_OPTIONS: "/new-options",
RESTORE_OPTIONS: "/restore-options",
NEW_SEED: "/new-seed",
CONFIRM_SEED: "/confirm-seed",
RESTORE_SEED: "/restore-seed",
RESTORE_HARDWARE: "/restore-hardware",
RESTORE_LEDGER: "/restore-ledger",
RESTORE_TREZOR: "/restore-trezor",
Expand Down
2 changes: 1 addition & 1 deletion app/common/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const fetchJSON = async path => {
/**
* fetchStxAddressDetails
*
* Fetches data for a stacks address from the Blockstack Explorer API
* Fetches data for a Stacks address from the Blockstack Explorer API
* Contains data about allocations and confirmed stx tx's
*
* @param {String} address - the Stacks address
Expand Down
21 changes: 14 additions & 7 deletions app/common/lib/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { TrezorSigner } from "@vendor/blockstack-trezor";
import { LedgerSigner } from "@vendor/blockstack-ledger";
import { WALLET_TYPES } from "@stores/reducers/wallet";
import { PATH } from "@common/constants";
import bigi from "bigi";

export const ERRORS = {
// not enough btc for fees
Expand Down Expand Up @@ -44,12 +45,12 @@ export const ERRORS = {
/**
* prepareTransaction
*
* This will generate and sign our transaction with either a ledger or trezor
* This will generate and sign our transaction with either a seed phrase, ledger or trezor
*
* @param {string} senderAddress - from Stacks address
* @param {string} recipientAddress - to Stacks address
* @param {object} amount - the amount of stacks to send
* @param {string} walletType - one of WALLET_TYPES.TREZOR or WALLET_TYPES.LEDGER
* @param {string} walletType - one of WALLET_TYPES.SOFTWARE, WALLET_TYPES.TREZOR, WALLET_TYPES.LEDGER
* @param {string} memo - the message for the tx
*/

Expand All @@ -67,7 +68,7 @@ const prepareTransaction = async (
// define token type (always stacks)
const tokenType = "STACKS";

const tokenAmount = toBigInt(amount); // convert to bigi
const tokenAmount = toBigInt(amount); // convert to bigi in microstacks

// get an estimate
const utxos = await config.network.getUTXOs(senderBtcAddress);
Expand Down Expand Up @@ -151,6 +152,7 @@ const generateTransaction = async (
recipientAddress,
amount,
walletType,
privateKey,
memo = ""
) => {
try {
Expand All @@ -171,10 +173,15 @@ const generateTransaction = async (
}

// define our signer
const isLedger = walletType === WALLET_TYPES.LEDGER;
const signer = isLedger
? new LedgerSigner(PATH, Transport)
: new TrezorSigner(PATH, tx.senderBtcAddress);
const signer = null
if (walletType === WALLET_TYPES.SOFTWARE) {
signer = privateKey
} else {
const isLedger = walletType === WALLET_TYPES.LEDGER;
signer = isLedger
? new LedgerSigner(PATH, Transport)
: new TrezorSigner(PATH, tx.senderBtcAddress);
}

// if we get here there are no errors
const rawTx = await transactions.makeTokenTransfer(
Expand Down
4 changes: 2 additions & 2 deletions app/components/field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const BalanceField = connect(mapStateToProps)(({ balance, pendingBalance }) => {
return (
<Flex flexDirection={"column"} flexShrink={0} pb={5}>
<Type pb={2} fontWeight={500} fontSize={1} is="label">
Available to Send
Available to send
</Type>
<Flex
border={1}
Expand All @@ -165,7 +165,7 @@ const BalanceField = connect(mapStateToProps)(({ balance, pendingBalance }) => {
overflow="hidden"
>
<Flex px={3} height={48} flexGrow={1} alignItems="center">
Stacks Balance
Stacks balance
</Flex>
<Flex
alignItems="center"
Expand Down
2 changes: 1 addition & 1 deletion app/components/loading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { Flex, Type, Input, Buttons } from "blockstack-ui/dist";
import { Spinner } from "@components/spinner";

const Loading = ({ message = "Fetching Wallet Details...", ...rest }) => (
const Loading = ({ message = "Fetching wallet details...", ...rest }) => (
<Flex
position="absolute"
width="100%"
Expand Down
113 changes: 113 additions & 0 deletions app/components/seed/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import React from "react";
import { Flex, Type, Box } from "blockstack-ui/dist";
import styled from "styled-components";

const SeedInput = styled.input`
background: transparent;
border: none;
color: ${props => props.color};
height: 28px;
width: ${props => props.small ? "75px;" : "100px;"}
&:focus {
outline: none;
}
`

const SeedWord = ({word, index, isInput, value, handleKeyPress, handleChange, focused, invert, small}) => (
<Flex
border={1}
borderColor={invert ? "#C4D7E5" :"#6E6CB4"}
m={2}
mt={1}
width={small ? 120 : 180}
height={small ? 35 : 50}
flexDirection="row"
flexGrow={1}
textAlign="center"
borderRadius="5px"
bg={invert ? "#FFFFFF" :"#181664"}
color={invert ? "#82a0b7" : "#FFFFFF"}
>
<Box
borderRight={1}
borderColor={invert ? "#C4D7E5" :"#6E6CB4"}
py={small ? "5px" : "12px"}
width="30%"
fontSize="14px"
>
{index+1}
</Box>
{isInput ?
<Box
py={small ? "3px" : "10px"}
px={small ? "8px" : "15px"}
width="70%"
fontSize={small ? "14px" : "16px"}
>
<SeedInput
value={value}
onKeyDown={(event) => handleKeyPress(event, index)}
onChange={(event) => handleChange(event, index)}
autoFocus={focused}
color={invert ? "#82a0b7" : "#FFFFFF"}
small={small}
/>
</Box>
:
<Box
py={small ? "5px" : "10px"}
px={small ? "8px" : "15px"}
width="70%"
fontSize={small ? "14px" : "16px"}
>
{word}
</Box>
}
</Flex>
)

const seedArray = (seedPhrase) => {
if (seedPhrase && seedPhrase.length > 0) {
return seedPhrase.split(' ')
} else {
return []
}
}

const Seed = ({ seedPhrase, isInput, numWords, values, handleKeyPress, handleChange, invert, small, ...rest }) => {
const seedWords = seedPhrase ? seedArray(seedPhrase) : Array(numWords).fill('')
return (
<Flex
mt={3}
mb={4}
p={1}
alignItems="center"
color="white"
maxWidth="600px"
position="relative"
flexWrap="wrap"
{...rest}
>
{
seedWords.map((word, i) => (
<SeedWord
word={word}
index={i}
key={i}
value={values ? values[i] : ""}
handleKeyPress={handleKeyPress}
handleChange={handleChange}
isInput={isInput}
focused={i === 0 ? true : false}
invert={invert}
small={small}
/>
))
}

</Flex>
);
};

export { Seed };
2 changes: 1 addition & 1 deletion app/components/transaction-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {

const Empty = ({ isFetching, ...rest }) => {
const Icon = isFetching ? Spinner : LayersOffOutlineIcon;
const message = isFetching ? "Loading..." : "No Transaction History";
const message = isFetching ? "Loading..." : "No transactions found for this address.";
return (
<Flex
flexGrow={1}
Expand Down
4 changes: 2 additions & 2 deletions app/containers/balance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const BalanceSection = connect(state => ({
color={state.view === "balance" ? "blue.dark" : undefined}
cursor="pointer"
>
Wallet Balance
Available balance
</Type>{" "}
/{" "}
<Type
Expand All @@ -79,7 +79,7 @@ const BalanceSection = connect(state => ({
</Type>
</>
) : (
<Type>Wallet Balance</Type>
<Type>Available balance</Type>
)}
</Type>
<Flex py={6} alignItems={"center"}>
Expand Down
4 changes: 2 additions & 2 deletions app/containers/modals/receive.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { selectWalletStacksAddress } from "@stores/selectors/wallet";
const ReceiveModal = connect(state => ({
address: selectWalletStacksAddress(state)
}))(({ address, hide, ...rest }) => (
<Modal title="Receive Stacks" hide={hide} maxWidth={"560px"} p={0}>
<Modal title="Receive Stacks (STX)" hide={hide} maxWidth={"560px"} p={0}>
<Flex
p={4}
borderBottom={1}
Expand All @@ -22,7 +22,7 @@ const ReceiveModal = connect(state => ({
<QrCode value={address} />
</Flex>
<Flex p={4} width={1}>
<Field width={1} label="Stacks Address" value={address} disabled copy />
<Field width={1} label="Stacks address" value={address} disabled copy />
</Flex>
</Modal>
));
Expand Down
24 changes: 17 additions & 7 deletions app/containers/modals/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
selectWalletError,
selectPendingBalance
} from "@stores/selectors/wallet";
import { microToStacks } from "@utils/utils";
import { microToStacks, emptySeedArray } from "@utils/utils";
import {
doSignTransaction,
doBroadcastTransaction,
Expand All @@ -22,11 +22,16 @@ import { Confirmation } from "@containers/modals/send/confirm";
import { Success } from "@containers/modals/send/success";
import { InitialScreen } from "@containers/modals/send/initial";
import { HardwareView } from "@containers/modals/send/hardware";
import { SeedView } from "@containers/modals/send/seed";
import { NoBalance } from "@containers/modals/send/no-balance";
import {
handleChange,
handleValidation
handleSeedChange,
handleValidation,
handleSeedValidation,
clearSeed,
} from "@containers/modals/send/helpers";
import { WALLET_TYPES } from "@stores/reducers/wallet";

const SecondaryLink = ({ action, label, ...rest }) => (
<TextLink onClick={action} {...rest}>
Expand Down Expand Up @@ -64,7 +69,7 @@ const mapStateToProps = state => ({
error: selectWalletError(state)
});

const Wrapper = props => <Modal title="Send Stacks" {...props} />;
const Wrapper = props => <Modal title="Send Stacks (STX)" {...props} />;

class SendComponent extends React.Component {
state = {
Expand All @@ -73,7 +78,9 @@ class SendComponent extends React.Component {
values: {
recipient: "",
amount: "",
memo: ""
memo: "",
seed: "",
seedArray: emptySeedArray(24)
},
draft: null,
errors: {}
Expand Down Expand Up @@ -104,7 +111,7 @@ class SendComponent extends React.Component {
this.state.errors.type &&
this.state.errors.type === ERRORS.INSUFFICIENT_BTC_BALANCE.type
? BTCTopUpView
: HardwareView;
: (type === WALLET_TYPES.SOFTWARE ? SeedView : HardwareView);
break;
case 2:
Component = Confirmation;
Expand All @@ -130,8 +137,10 @@ class SendComponent extends React.Component {
sender,
error,
handleChange,
handleSeedChange,
handleValidation,
nextView: () =>
handleSeedValidation,
nextView: () =>
this.setState(({ view, ...rest }) => ({ ...rest, view: view + 1 })),
goToView: view => this.setState(({ ...rest }) => ({ ...rest, view })),
prevView: () =>
Expand All @@ -141,7 +150,8 @@ class SendComponent extends React.Component {
hide();
},
doSignTransaction,
doBroadcastTransaction
doBroadcastTransaction,
clearSeed
};

return (
Expand Down
1 change: 1 addition & 0 deletions app/containers/modals/send/hardware.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const HardwareView = ({
state.values.recipient,
state.values.amount,
type,
"",
state.values.memo || ""
);

Expand Down
Loading

0 comments on commit d21d08b

Please sign in to comment.