diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 85920ca98..c2f46efac 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -46,6 +46,7 @@ export { isEthereum, isStructuredMessage, isToken, + isWrappedToken, ledgerByBlockchain, tokenAbi, wrapTokenAbi, diff --git a/packages/react-app/src/common/ToField/ToField.spec.tsx b/packages/react-app/src/common/ToField/ToField.spec.tsx index cb5107ca5..827ef0942 100644 --- a/packages/react-app/src/common/ToField/ToField.spec.tsx +++ b/packages/react-app/src/common/ToField/ToField.spec.tsx @@ -1,5 +1,5 @@ import { BlockchainCode } from '@emeraldwallet/core'; -import * as addressBook from '@emeraldwallet/store/lib/address-book'; +import { addressBook } from '@emeraldwallet/store'; import { Theme } from '@emeraldwallet/ui'; import { ThemeProvider } from '@material-ui/core'; import { mount, shallow } from 'enzyme'; diff --git a/packages/react-app/src/create-account/SelectType.tsx b/packages/react-app/src/create-account/SelectType.tsx deleted file mode 100644 index 9cbdf11f0..000000000 --- a/packages/react-app/src/create-account/SelectType.tsx +++ /dev/null @@ -1,134 +0,0 @@ -import { - Download as DownloadIcon, - Key as KeyIcon, - Keypair as KeypairIcon, - Ledger as LedgerIcon -} from '@emeraldwallet/ui'; -import {addAccount, IState} from '@emeraldwallet/store'; -import { AddType } from '@emeraldwallet/store/lib/add-account'; -import { - Avatar, - Divider, - FormControlLabel, - Grid, - List, - ListItem, - ListItemAvatar, - ListItemText, - Radio, - RadioGroup, - SvgIcon, - Typography -} from '@material-ui/core'; -import ListItemIcon from '@material-ui/core/ListItemIcon'; -import * as React from 'react'; -import { connect } from 'react-redux'; - -interface ITypeDef { - code: addAccount.AddType; - title: string; - description: string; -} - -const ETHEREUM_TYPES: ITypeDef[] = [ - { - code: AddType.GENERATE_PK, - title: 'Generate Private Key', - description: 'Generate a new Private Key' - }, - { - code: AddType.IMPORT_PRIVATE_KEY, - title: 'Import Private Key', - description: 'Import an existing raw unencrypted Private Key' - }, - { - code: AddType.IMPORT_JSON, - title: 'Import JSON', - description: 'Import existing Private Key from JSON file' - } - // TODO only if wallet has an associated Seed - // { - // code: AddType.SEED_PATH, - // title: "Select HD Path", - // description: "Select a new address from associated Seed or Hardware Key" - // }, -]; - -interface IRenderProps { - supportedTypes: ITypeDef[]; - type?: addAccount.AddType; -} - -interface IDispatchProps { - selectType: (type?: addAccount.AddType) => void; -} - -function icon (type: AddType): JSX.Element { - if (type === addAccount.AddType.GENERATE_PK) { - return ; - } - if (type === addAccount.AddType.IMPORT_PRIVATE_KEY) { - return ; - } - if (type === addAccount.AddType.IMPORT_JSON) { - return ; - } - if (type === addAccount.AddType.SEED_PATH) { - return ; - } - return ; -} - -const SelectType = ((props: IRenderProps & IDispatchProps) => { - const { supportedTypes, type } = props; - const { selectType } = props; - - return ( - - - - {supportedTypes.map((b,i) => - ( -
- {i > 0 ? : null} - selectType(b.code)} - > - - - {icon(b.code)} - - - - -
- ) - )} -
-
-
- ); -}); - -export default connect( - (state, ownProps) => { - return { - supportedTypes: ETHEREUM_TYPES, - type: state.addAccount!!.type - }; - }, - (dispatch, ownProps) => { - return { - selectType: (type?: addAccount.AddType) => { - dispatch(addAccount.actions.setType(type)); - dispatch(addAccount.actions.nextPage()); - } - }; - } -)((SelectType)); diff --git a/packages/react-app/src/message/SignMessage.tsx b/packages/react-app/src/message/SignMessage.tsx index 9dff152e6..297012658 100644 --- a/packages/react-app/src/message/SignMessage.tsx +++ b/packages/react-app/src/message/SignMessage.tsx @@ -2,7 +2,6 @@ import { EntryId, SeedDescription, SignedMessage, WalletEntry, isEthereumEntry } import { isSeedPkRef } from '@emeraldpay/emerald-vault-core/lib/types'; import { EthereumMessage, blockchainById, isStructuredMessage } from '@emeraldwallet/core'; import { IState, accounts, screen } from '@emeraldwallet/store'; -import { findWallet } from '@emeraldwallet/store/lib/accounts/selectors'; import { Address, Back, @@ -458,9 +457,10 @@ const SignMessage: React.FC = ({ export default connect( (state, ownProps) => { - const entries = findWallet(state, ownProps.walletId)?.entries.filter( - (entry) => !entry.receiveDisabled && isEthereumEntry(entry), - ); + const entries = accounts.selectors + .findWallet(state, ownProps.walletId) + ?.entries.filter((entry) => !entry.receiveDisabled && isEthereumEntry(entry)); + const entryById = entries?.reduce((carry, entry) => ({ ...carry, [entry.id]: entry }), {}); return { diff --git a/packages/react-app/src/transaction/SetupTransaction/flow/common/common.tsx b/packages/react-app/src/transaction/SetupTransaction/flow/common/common.tsx index c028451f9..102998353 100644 --- a/packages/react-app/src/transaction/SetupTransaction/flow/common/common.tsx +++ b/packages/react-app/src/transaction/SetupTransaction/flow/common/common.tsx @@ -1,17 +1,16 @@ import { EthereumEntry, WalletEntry } from '@emeraldpay/emerald-vault-core'; import { workflow } from '@emeraldwallet/core'; -import { AnyCreateTx } from '@emeraldwallet/core/src/transaction/workflow'; import { CreateTxStage } from '@emeraldwallet/store'; import * as React from 'react'; import { Actions, EthereumFee } from '../components'; import { BaseFlow, Data, DataProvider, Handler } from '../types'; export abstract class CommonFlow implements BaseFlow { - readonly data: Data; + readonly data: Data; readonly dataProvider: DataProvider; readonly handler: Handler; - constructor(data: Data, dataProvider: DataProvider, handler: Handler) { + constructor(data: Data, dataProvider: DataProvider, handler: Handler) { this.data = data; this.dataProvider = dataProvider; this.handler = handler; diff --git a/packages/react-app/src/wallets/WalletDetails/entry/EthereumEntryItem.tsx b/packages/react-app/src/wallets/WalletDetails/entry/EthereumEntryItem.tsx index 151b19fb3..038bc72df 100644 --- a/packages/react-app/src/wallets/WalletDetails/entry/EthereumEntryItem.tsx +++ b/packages/react-app/src/wallets/WalletDetails/entry/EthereumEntryItem.tsx @@ -7,8 +7,8 @@ import { TokenAmount, blockchainIdToCode, formatAmount, + isWrappedToken, } from '@emeraldwallet/core'; -import { isWrappedToken } from '@emeraldwallet/core/lib/blockchains'; import { ConvertedBalance, IState, TxAction, accounts, screen, tokens } from '@emeraldwallet/store'; import { BlockchainAvatar } from '@emeraldwallet/ui'; import { Button, IconButton, Tooltip, Typography, createStyles, makeStyles } from '@material-ui/core'; diff --git a/packages/react-app/src/wallets/WalletSettingsDialog/WalletSettingsDialog.tsx b/packages/react-app/src/wallets/WalletSettingsDialog/WalletSettingsDialog.tsx index 7f5afb0b2..35fae0383 100644 --- a/packages/react-app/src/wallets/WalletSettingsDialog/WalletSettingsDialog.tsx +++ b/packages/react-app/src/wallets/WalletSettingsDialog/WalletSettingsDialog.tsx @@ -1,8 +1,7 @@ import { dialog, getCurrentWindow } from '@electron/remote'; import { Wallet } from '@emeraldpay/emerald-vault-core'; import { IState, accounts, application, screen } from '@emeraldwallet/store'; -import { ButtonGroup, HashIcon, Input } from '@emeraldwallet/ui'; -import Button from '@emeraldwallet/ui/lib/components/common/Button'; +import { Button, ButtonGroup, HashIcon, Input } from '@emeraldwallet/ui'; import { Box, Dialog, diff --git a/packages/react-app/stories/storeProvider.tsx b/packages/react-app/stories/storeProvider.tsx index 65ca677a3..9040bed9e 100644 --- a/packages/react-app/stories/storeProvider.tsx +++ b/packages/react-app/stories/storeProvider.tsx @@ -1,6 +1,5 @@ import { WalletApi } from '@emeraldwallet/core'; -import { createStore } from '@emeraldwallet/store'; -import { Dispatched } from '@emeraldwallet/store/lib/types'; +import { Dispatched, createStore } from '@emeraldwallet/store'; import { DecoratorFunction } from '@storybook/addons/dist/ts3.9/types'; import * as React from 'react'; import { ReactElement } from 'react'; diff --git a/packages/store/src/index.ts b/packages/store/src/index.ts index 2113ffb76..8d48220ce 100644 --- a/packages/store/src/index.ts +++ b/packages/store/src/index.ts @@ -34,7 +34,7 @@ export { export { ConvertedBalance } from './accounts/types'; export { CreateTxStage, FeeState, TxAction } from './txstash/types'; export { DefaultFee } from './application/types'; -export { IState } from './types'; +export { Dispatched, IState } from './types'; export { RemoteAddressBook } from './remote-access/AddressBook'; export { RemoteAllowances } from './remote-access/Allowances'; export { RemoteBalances } from './remote-access/Balances'; diff --git a/packages/store/src/remote-access/Allowances.ts b/packages/store/src/remote-access/Allowances.ts index 0d3a91df5..c8bd3d162 100644 --- a/packages/store/src/remote-access/Allowances.ts +++ b/packages/store/src/remote-access/Allowances.ts @@ -1,14 +1,13 @@ import { Uuid } from '@emeraldpay/emerald-vault-core'; import { BlockchainCode, IpcCommands, PersistentState } from '@emeraldwallet/core'; -import { CachedAllowance, PageResult } from '@emeraldwallet/core/lib/persistentState'; import { ipcRenderer } from 'electron'; class Allowances implements PersistentState.Allowances { - add(walletId: Uuid, allowance: CachedAllowance, ttl?: number): Promise { + add(walletId: Uuid, allowance: PersistentState.CachedAllowance, ttl?: number): Promise { return ipcRenderer.invoke(IpcCommands.ALLOWANCES_ADD, walletId, allowance, ttl); } - list(walletId?: Uuid): Promise> { + list(walletId?: Uuid): Promise> { return ipcRenderer.invoke(IpcCommands.ALLOWANCES_LIST, walletId); } diff --git a/packages/store/src/txstash/handler/blockchain/ethereum/prepare.ts b/packages/store/src/txstash/handler/blockchain/ethereum/prepare.ts index f291f601e..53bd3e5c3 100644 --- a/packages/store/src/txstash/handler/blockchain/ethereum/prepare.ts +++ b/packages/store/src/txstash/handler/blockchain/ethereum/prepare.ts @@ -9,7 +9,6 @@ import { blockchainIdToCode, workflow, } from '@emeraldwallet/core'; -import { TxTarget } from '@emeraldwallet/core/src/transaction/workflow'; import { TokenBalanceBelong, accounts, tokens } from '../../../..'; import { getTokens } from '../../../../application/selectors'; import { setAsset, setPreparing, setTransaction } from '../../../actions'; @@ -148,7 +147,7 @@ export const prepareEthereumRecoveryTx: EntryHandler = (data, sto ); createTx.from = address; - createTx.target = TxTarget.SEND_ALL; + createTx.target = workflow.TxTarget.SEND_ALL; createTx.to = recoveryEntry?.address?.value; createTx.rebalance(); diff --git a/packages/store/src/txstash/handler/blockchain/ethereum/restore.ts b/packages/store/src/txstash/handler/blockchain/ethereum/restore.ts index 5c273ff36..6525b6e7e 100644 --- a/packages/store/src/txstash/handler/blockchain/ethereum/restore.ts +++ b/packages/store/src/txstash/handler/blockchain/ethereum/restore.ts @@ -11,7 +11,6 @@ import { toBigNumber, workflow, } from '@emeraldwallet/core'; -import { EthereumFeeRange } from '@emeraldwallet/core/src/transaction/workflow'; import { getTokens } from '../../../../application/selectors'; import { setPreparing, setTransaction, setTransactionFee } from '../../../actions'; import { getFee } from '../../../selectors'; @@ -137,7 +136,7 @@ const recalculateFee: EthereumHandler = dispatch(setTransaction(createTx.dump())); - const feeRange: EthereumFeeRange = { + const feeRange: workflow.EthereumFeeRange = { lowMaxGasPrice, highMaxGasPrice, lowPriorityGasPrice,