diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 000000000..d24fdfc60 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx lint-staged diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100755 index 000000000..3e18ca2e4 --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npm run test:unit diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..2b786cc94 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +compiled +bundle +dist diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..570ea7744 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "printWidth": 120, + "singleQuote": true, + "jsxSingleQuote": true, + "semi": false +} diff --git a/@types/@aragon__wrapper/index.d.ts b/@types/@aragon__wrapper/index.d.ts index fa3ca6b5f..75e8ded98 100644 --- a/@types/@aragon__wrapper/index.d.ts +++ b/@types/@aragon__wrapper/index.d.ts @@ -1,19 +1,19 @@ declare module '@aragon/wrapper' { interface WrapperOptions { - provider: any, + provider: any apm?: { ipfs?: { - gateway: string, - }, + gateway: string + } ensRegistryAddress?: string } } interface App { - appId: string, - proxyAddress: string, - name: string, - kernel: string, + appId: string + proxyAddress: string + name: string + kernel: string agent: string } @@ -26,15 +26,20 @@ declare module '@aragon/wrapper' { } export default class Wrapper { - constructor (address: string, opts: WrapperOptions) + constructor(address: string, opts: WrapperOptions) apps: Apps init(): Promise - calculateTransactionPath(from: string, destination: string, action: string, txData: Array): Promise> + calculateTransactionPath( + from: string, + destination: string, + action: string, + txData: Array + ): Promise> } interface ResolveOptions { - provider: any, + provider: any registryAddress?: string } diff --git a/@types/eth-ens-namehash/index.d.ts b/@types/eth-ens-namehash/index.d.ts index ce3205236..310c196cd 100644 --- a/@types/eth-ens-namehash/index.d.ts +++ b/@types/eth-ens-namehash/index.d.ts @@ -1,3 +1,3 @@ declare module 'eth-ens-namehash' { - export function hash (name: string): string + export function hash(name: string): string } diff --git a/@types/frame/environment.d.ts b/@types/frame/environment.d.ts index 1cdd93b49..518086117 100644 --- a/@types/frame/environment.d.ts +++ b/@types/frame/environment.d.ts @@ -2,7 +2,7 @@ declare global { namespace NodeJS { interface ProcessEnv { BUNDLE_LOCATION: string - NODE_ENV: 'test' | 'development' | 'production', + NODE_ENV: 'test' | 'development' | 'production' // use this to override the log level in development LOG_LEVEL: 'silly' | 'debug' | 'verbose' | 'info' | 'warn' | 'error' } diff --git a/@types/frame/ethProvider.d.ts b/@types/frame/ethProvider.d.ts index 1ca271e50..f2fb72a56 100644 --- a/@types/frame/ethProvider.d.ts +++ b/@types/frame/ethProvider.d.ts @@ -1,14 +1,14 @@ declare module 'eth-provider' { interface ProviderOpts { - name?: string, + name?: string origin?: string } - + interface RequestPayload { - id?: number, - jsonrpc?: '2.0', - method: string, - params?: any[], + id?: number + jsonrpc?: '2.0' + method: string + params?: any[] chainId?: string } @@ -21,5 +21,5 @@ declare module 'eth-provider' { setChain(chainId: string) } - export default function provider (targets?: string | string[], opts?: ProviderOpts): EthereumProvider + export default function provider(targets?: string | string[], opts?: ProviderOpts): EthereumProvider } diff --git a/@types/frame/restore.d.ts b/@types/frame/restore.d.ts index 6d761eb7e..99b1ab11a 100644 --- a/@types/frame/restore.d.ts +++ b/@types/frame/restore.d.ts @@ -6,16 +6,16 @@ interface Action { updates: any[] } -declare type CallableStore = (...args: any[]) => any; +declare type CallableStore = (...args: any[]) => any interface Store extends CallableStore { - observer: (cb: () => void, id?: string) => Observer, - [actionName: string]: (...args: any) => void, + observer: (cb: () => void, id?: string) => Observer + [actionName: string]: (...args: any) => void api: { - feed: (handler: (state: any, actionBatch: Action[]) => any) => void; + feed: (handler: (state: any, actionBatch: Action[]) => any) => void } } declare module 'react-restore' { - export function create (state: any, actions: any): Store + export function create(state: any, actions: any): Store } diff --git a/@types/frame/rpc.d.ts b/@types/frame/rpc.d.ts index 4a34afcd7..35467ebe3 100644 --- a/@types/frame/rpc.d.ts +++ b/@types/frame/rpc.d.ts @@ -11,11 +11,11 @@ enum SubscriptionType { ASSETS = 'assetsChanged', CHAIN = 'chainChanged', CHAINS = 'chainsChanged', - NETWORK = 'networkChanged' + NETWORK = 'networkChanged', } interface RPCId { - id: number, + id: number jsonrpc: string } @@ -24,8 +24,8 @@ interface InternalPayload { } interface JSONRPCRequestPayload extends RPCId { - params: any[], - method: string, + params: any[] + method: string chainId?: string } @@ -38,7 +38,7 @@ interface JSONRPCErrorResponsePayload extends RPCId { } interface EVMError { - message: string, + message: string code?: number } @@ -47,27 +47,27 @@ type RPCRequestPayload = JSONRPCRequestPayload & InternalPayload declare namespace RPC { namespace GetAssets { interface Balance { - chainId: number, - name: string, - symbol: string, - balance: string, - decimals: number, + chainId: number + name: string + symbol: string + balance: string + decimals: number displayBalance: string } interface NativeCurrency extends Balance { currencyInfo: Currency } - + interface Erc20 extends Balance { tokenInfo: { - lastKnownPrice: { usd: { price: number, change24hr?: number } } - }, + lastKnownPrice: { usd: { price: number; change24hr?: number } } + } address: Address } interface Assets { - erc20?: Erc20[], + erc20?: Erc20[] nativeCurrency: Balance[] } @@ -82,29 +82,29 @@ declare namespace RPC { namespace SendTransaction { interface TxParams { - nonce?: string; - gasPrice?: string, - gas?: string, // deprecated - maxPriorityFeePerGas?: string, - maxFeePerGas?: string, - gasLimit?: string, - from?: Address, - to?: Address, - data?: string, - value?: string, - chainId: string, - type?: string, + nonce?: string + gasPrice?: string + gas?: string // deprecated + maxPriorityFeePerGas?: string + maxFeePerGas?: string + gasLimit?: string + from?: Address + to?: Address + data?: string + value?: string + chainId: string + type?: string } interface Request extends Omit { - method: 'eth_sendTransaction', + method: 'eth_sendTransaction' params: TxParams[] } } namespace Subscribe { interface Request extends Omit { - method: 'eth_subscribe', + method: 'eth_subscribe' params: SubscriptionType[] } } diff --git a/@types/frame/state.d.ts b/@types/frame/state.d.ts index 2002fc105..a80ef4d7c 100644 --- a/@types/frame/state.d.ts +++ b/@types/frame/state.d.ts @@ -1,53 +1,53 @@ interface Connection { - on: boolean, - connected: boolean, - current: string, - status: string, - network: string, + on: boolean + connected: boolean + current: string + status: string + network: string custom: string } interface Chain { - id: number, + id: number type: 'ethereum' } interface Network { - id: number, - name: string, - symbol: string, - layer: string, - on: boolean, + id: number + name: string + symbol: string + layer: string + on: boolean connection: { - primary: Connection, + primary: Connection secondary: Connection } } interface NetworkMetadata { - id: number, - name: string, - nativeCurrency: NativeCurrency, - symbol: string, + id: number + name: string + nativeCurrency: NativeCurrency + symbol: string gas: GasData } interface Session { - requests: number, - startedAt: number, - endedAt?: number, + requests: number + startedAt: number + endedAt?: number lastUpdatedAt: number } interface Origin { - chain: Chain, - name: string, + chain: Chain + name: string session: Session } interface Permission { - origin: string, - provider: boolean, // whether or not to grant access + origin: string + provider: boolean // whether or not to grant access handlerId?: string } @@ -56,81 +56,81 @@ interface NativeCurrency { } interface GasData { - fees: GasFees, + fees: GasFees price: { - selected: string, + selected: string levels: GasLevels } } interface GasFees { - nextBaseFee: string, - maxBaseFeePerGas: string, - maxPriorityFeePerGas: string, + nextBaseFee: string + maxBaseFeePerGas: string + maxPriorityFeePerGas: string maxFeePerGas: string } interface GasLevels { - slow?: string, - standard: string, - fast?: string, - asap?: string, + slow?: string + standard: string + fast?: string + asap?: string custom?: string } type HexAmount = string interface Balance { - chainId: number, - address: Address, - name: string, - symbol: string, - balance: HexAmount, - decimals: number, + chainId: number + address: Address + name: string + symbol: string + balance: HexAmount + decimals: number displayBalance: string } interface Rate { usd: { - price: BigNumber, + price: BigNumber change24hr: BigNumber } } interface Currency { - icon: string, + icon: string name: string } interface Token { - chainId: number, - name: string, - symbol: string, - address: string, - decimals: number, + chainId: number + name: string + symbol: string + address: string + decimals: number logoURI?: string } interface ViewMetadata { - id: string, - ready: boolean, - dappId: string, - ens: string, + id: string + ready: boolean + dappId: string + ens: string url: string } interface Frame { - id: string, - currentView: string, + id: string + currentView: string views: Record } interface Dapp { - id?: string, - ens: string, - status?: string, - config: Record, - manifest?: any, + id?: string + ens: string + status?: string + config: Record + manifest?: any current?: any } @@ -138,39 +138,39 @@ type SignerType = 'ring' | 'seed' | 'aragon' | 'trezor' | 'ledger' | 'lattice' type AccountStatus = 'ok' interface Signer { - id: string, - name: string, - model: string, - type: SignerType, - addresses: Address[], - status: string, + id: string + name: string + model: string + type: SignerType + addresses: Address[] + status: string createdAt: number } interface Account { - id: string, - name: string, - lastSignerType: SignerType, - active: boolean, - address: Address, - status: AccountStatus, - signer: string, - smart?: SmartAccount, - requests: Record, - ensName: string, - created: string, + id: string + name: string + lastSignerType: SignerType + active: boolean + address: Address + status: AccountStatus + signer: string + smart?: SmartAccount + requests: Record + ensName: string + created: string balances: { lastUpdated?: number } } interface SmartAccount { - name: string, - chain: Chain, - type: string, - actor: any, // TODO: is this an address or an object? - agent: Address, - ens: string, - apps: any, + name: string + chain: Chain + type: string + actor: any // TODO: is this an address or an object? + agent: Address + ens: string + apps: any dao: any } diff --git a/app/App/Badge/index.js b/app/App/Badge/index.js index 1944e07d7..70ac98abc 100644 --- a/app/App/Badge/index.js +++ b/app/App/Badge/index.js @@ -3,23 +3,25 @@ import Restore from 'react-restore' import link from '../../../resources/link' class Bridge extends React.Component { - render () { + render() { if (this.store('view.badge') === 'updateReady') { return (
-
- Your update is ready, relaunch Frame to switch -
+
Your update is ready, relaunch Frame to switch
-
this.store.updateBadge()}>Ok
+
this.store.updateBadge()}> + Ok +
-
link.send('tray:updateRestart')}>Relaunch Now
+
link.send('tray:updateRestart')}> + Relaunch Now +
@@ -31,38 +33,42 @@ class Bridge extends React.Component {
-
- A new update is available, would you like to install it? -
+
A new update is available, would you like to install it?
{ + className='badgeInputInner' + onMouseDown={() => { link.send('tray:installAvailableUpdate', true, false) }} style={{ color: 'var(--good)' }} - >Install Update + > + Install Update
{ + className='badgeInputInner' + onMouseDown={() => { link.send('tray:installAvailableUpdate', false, false) }} style={{ color: 'var(--moon)' }} - >Remind Me Later + > + Remind Me Later
{ + className='badgeInputInner badgeInputSmall' + onMouseDown={() => { link.send('tray:installAvailableUpdate', false, true) }} - >Skip This Version + > + Skip This Version
diff --git a/app/App/Main/Account/Activity/index.js b/app/App/Main/Account/Activity/index.js index f9555aeec..c75f1ea25 100644 --- a/app/App/Main/Account/Activity/index.js +++ b/app/App/Main/Account/Activity/index.js @@ -3,31 +3,31 @@ import Restore from 'react-restore' import link from '../../../../../resources/link' class Balances extends React.Component { - constructor (...args) { + constructor(...args) { super(...args) this.moduleRef = React.createRef() this.resizeObserver = new ResizeObserver(() => { if (this.moduleRef && this.moduleRef.current) { - link.send('tray:action', 'updateAccountModule', this.props.moduleId, { height: this.moduleRef.current.clientHeight }) + link.send('tray:action', 'updateAccountModule', this.props.moduleId, { + height: this.moduleRef.current.clientHeight, + }) } }) this.state = { - expand: false + expand: false, } } - componentDidMount () { + componentDidMount() { this.resizeObserver.observe(this.moduleRef.current) - } - render () { + } + render() { return (
-
{'activity monitor'}
-
- {'Coming Soon'} -
+
{'activity monitor'}
+
{'Coming Soon'}
) } } -export default Restore.connect(Balances) \ No newline at end of file +export default Restore.connect(Balances) diff --git a/app/App/Main/Account/Balances/index.js b/app/App/Main/Account/Balances/index.js index 6dc9cde40..a6f1ca6ff 100644 --- a/app/App/Main/Account/Balances/index.js +++ b/app/App/Main/Account/Balances/index.js @@ -14,30 +14,30 @@ import BigNumber from 'bignumber.js' const UNKNOWN = '?' const NATIVE_CURRENCY = '0x0000000000000000000000000000000000000000' -function isNativeCurrency (address) { +function isNativeCurrency(address) { return address === NATIVE_CURRENCY } -function formatBalance (balance, totalValue, decimals = 8) { +function formatBalance(balance, totalValue, decimals = 8) { const isZero = balance.isZero() if (!isZero && balance.toNumber() < 0.001 && totalValue.toNumber() < 1) return '<0.001' return new Intl.NumberFormat('us-US', { - minimumFractionDigits: 2, - maximumFractionDigits: 8 - }).format(balance.toFixed(decimals, BigNumber.ROUND_FLOOR)) + minimumFractionDigits: 2, + maximumFractionDigits: 8, + }).format(balance.toFixed(decimals, BigNumber.ROUND_FLOOR)) } -function formatUsdRate (rate, decimals = 2) { +function formatUsdRate(rate, decimals = 2) { return rate.isNaN() ? UNKNOWN : new Intl.NumberFormat('us-US', { minimumFractionDigits: decimals, - maximumFractionDigits: decimals + maximumFractionDigits: decimals, }).format(rate.toFixed(decimals, BigNumber.ROUND_FLOOR)) } -function balance (rawBalance, quote = {}) { +function balance(rawBalance, quote = {}) { const balance = BigNumber(rawBalance.balance || 0).shiftedBy(-rawBalance.decimals) const usdRate = BigNumber(quote.price) const totalValue = balance.times(usdRate) @@ -49,11 +49,10 @@ function balance (rawBalance, quote = {}) { price: formatUsdRate(usdRate), priceChange: !usdRate.isNaN() && BigNumber(quote['change24hr'] || 0).toFixed(2), totalValue: totalValue.isNaN() ? BigNumber(0) : totalValue, - displayValue: formatUsdRate(totalValue, 0) + displayValue: formatUsdRate(totalValue, 0), } } - class Balance extends React.Component { // constructor (...args) { // super(...args) @@ -68,7 +67,7 @@ class Balance extends React.Component { // }, 200) // } - render () { + render() { const { symbol, balance, i, scanning, chainId } = this.props const change = parseFloat(balance.priceChange) const direction = change < 0 ? -1 : change > 0 ? 1 : 0 @@ -86,47 +85,55 @@ class Balance extends React.Component { const chainHex = '0x' + chainId.toString(16) return ( -
this.setState({ selected: i })}> +
this.setState({ selected: i })} + >
-
-
- {chainMeta[chainHex] ? chainMeta[chainHex].name : '' } -
-
- {name} + {chainMeta[chainHex] ? chainMeta[chainHex].name : ''}
-
= 12 ? { fontSize: '15px', top: '10px' } : {}}> - - {symbol.toUpperCase()} - - = 12 ? { marginTop: '-3px' } : {}} - > +
{name}
+
= 12 ? { fontSize: '15px', top: '10px' } : {}} + > + {symbol.toUpperCase()} + = 12 ? { marginTop: '-3px' } : {}}> {balance.displayBalance}
- {svg.usd(10)}{balance.price} + {svg.usd(10)} + {balance.price} - ({direction === 1 ? '+' : ''}{balance.priceChange ? balance.priceChange + '%' : ''}) + + ({direction === 1 ? '+' : ''} + {balance.priceChange ? balance.priceChange + '%' : ''}) +
- {svg.usd(10)}{balance.displayValue} + {svg.usd(10)} + {balance.displayValue}
@@ -136,7 +143,7 @@ class Balance extends React.Component { } class Balances extends React.Component { - constructor (...args) { + constructor(...args) { super(...args) this.moduleRef = React.createRef() if (!this.props.expanded) { @@ -144,7 +151,9 @@ class Balances extends React.Component { if (this.moduleRef && this.moduleRef.current) { clearTimeout(this.resizeTimer) this.resizeTimer = setTimeout(() => { - link.send('tray:action', 'updateAccountModule', this.props.moduleId, { height: this.moduleRef.current.clientHeight }) + link.send('tray:action', 'updateAccountModule', this.props.moduleId, { + height: this.moduleRef.current.clientHeight, + }) }, 100) } }) @@ -155,26 +164,26 @@ class Balances extends React.Component { open: false, selected: 0, shadowTop: 0, - expand: false + expand: false, } } - componentDidMount () { + componentDidMount() { if (this.resizeObserver) this.resizeObserver.observe(this.moduleRef.current) } - componentWillUnmount () { + componentWillUnmount() { if (this.resizeObserver) this.resizeObserver.disconnect() } - getBalances (rawBalances, rates) { + getBalances(rawBalances, rates) { const networks = this.store('main.networks.ethereum') const networksMeta = this.store('main.networksMeta.ethereum') const balances = rawBalances // only show balances from connected networks - .filter(rawBalance => isNetworkConnected(networks[rawBalance.chainId])) - .map(rawBalance => { + .filter((rawBalance) => isNetworkConnected(networks[rawBalance.chainId])) + .map((rawBalance) => { const isNative = isNativeCurrency(rawBalance.address) const nativeCurrencyInfo = networksMeta[rawBalance.chainId].nativeCurrency || {} @@ -195,7 +204,7 @@ class Balances extends React.Component { return { balances, totalDisplayValue: formatUsdRate(totalValue, 0), totalValue } } - render () { + render() { const { address, lastSignerType } = this.store('main.accounts', this.props.id) const storedBalances = this.store('main.balances', address) || [] const rates = this.store('main.rates') @@ -206,17 +215,21 @@ class Balances extends React.Component { const lastBalanceUpdate = this.store('main.accounts', address, 'balances.lastUpdated') // scan if balances are more than a minute old - const scanning = !lastBalanceUpdate || (new Date() - new Date(lastBalanceUpdate)) > (1000 * 60) + const scanning = !lastBalanceUpdate || new Date() - new Date(lastBalanceUpdate) > 1000 * 60 const hotSigner = ['ring', 'seed'].includes(lastSignerType) return ( -
balances @@ -236,46 +249,51 @@ class Balances extends React.Component { return })}
-
+
{!this.props.expanded ? (
-
this.props.expandModule(this.props.moduleId)}> +
this.props.expandModule(this.props.moduleId)} + > {allBalances.length - 4 > 0 ? `+${allBalances.length - 4} More` : 'More'}
) : (
-
{ - link.send('tray:action', 'navDash', { view: 'tokens', data: { notify: 'addToken' }}) - }}> +
{ + link.send('tray:action', 'navDash', { + view: 'tokens', + data: { notify: 'addToken' }, + }) + }} + > Add Token
)}
-
- {'Total: '} -
+
{'Total: '}
- {svg.usd(11)}{balances.length > 0 ? totalDisplayValue : '---.--'} + {svg.usd(11)} + {balances.length > 0 ? totalDisplayValue : '---.--'}
{totalValue.toNumber() > 10000 && hotSigner ? ( -
this.setState({ showHighHotMessage: !this.state.showHighHotMessage })} style={scanning ? { opacity: 0 } : { opacity: 1 }} > -
- {'high value account is using hot signer'} -
- {this.state.showHighHotMessage ?
- {'We recommend using one of our supported hardware signers to increase the security of your account'} -
: null} +
{'high value account is using hot signer'}
+ {this.state.showHighHotMessage ? ( +
+ {'We recommend using one of our supported hardware signers to increase the security of your account'} +
+ ) : null}
) : null}
diff --git a/app/App/Main/Account/Default/index.js b/app/App/Main/Account/Default/index.js index e40223c3f..3a8a29b45 100644 --- a/app/App/Main/Account/Default/index.js +++ b/app/App/Main/Account/Default/index.js @@ -2,22 +2,24 @@ import React from 'react' import Restore from 'react-restore' class Block extends React.Component { - constructor (props, context) { + constructor(props, context) { super(props, context) this.moduleRef = React.createRef() this.resizeObserver = new ResizeObserver(() => { if (this.moduleRef && this.moduleRef.current) { - link.send('tray:action', 'updateAccountModule', props.id, { height: this.moduleRef.current.clientHeight }) + link.send('tray:action', 'updateAccountModule', props.id, { + height: this.moduleRef.current.clientHeight, + }) } }) } - componentDidMount () { + componentDidMount() { this.resizeObserver.observe(this.moduleRef.current) - } - componentWillUnmount () { + } + componentWillUnmount() { this.resizeObserver.disconnect() } - render () { + render() { return (
{this.props.moduleId}
@@ -29,4 +31,4 @@ class Block extends React.Component { } } -export default Restore.connect(Block) \ No newline at end of file +export default Restore.connect(Block) diff --git a/app/App/Main/Account/Gas/index.js b/app/App/Main/Account/Gas/index.js index 053dcc8e5..4d20bc1fb 100644 --- a/app/App/Main/Account/Gas/index.js +++ b/app/App/Main/Account/Gas/index.js @@ -12,71 +12,105 @@ const gasToSendToken = 65 * 1000 const gasForDexSwap = 200 * 1000 class Gas extends React.Component { - constructor (...args) { + constructor(...args) { super(...args) this.moduleRef = React.createRef() this.resizeObserver = new ResizeObserver(() => { if (this.moduleRef && this.moduleRef.current) { - link.send('tray:action', 'updateAccountModule', this.props.moduleId, { height: this.moduleRef.current.clientHeight }) + link.send('tray:action', 'updateAccountModule', this.props.moduleId, { + height: this.moduleRef.current.clientHeight, + }) } }) this.state = { - expand: false + expand: false, } } - componentDidMount () { + componentDidMount() { this.resizeObserver.observe(this.moduleRef.current) - } - renderFeeTime (time) { - if (!time) return <>?? - if (time < 60) return <>~{time}s - if (time < 3600) return <>~{Math.round(time / 60)}m - return <>~{Math.round(time / 3600)}h } - toDisplayUSD (bn) { + renderFeeTime(time) { + if (!time) + return ( + <> + ?? + + ) + if (time < 60) + return ( + <> + ~ + {time} + s + + ) + if (time < 3600) + return ( + <> + ~ + {Math.round(time / 60)} + m + + ) + return ( + <> + ~ + {Math.round(time / 3600)} + h + + ) + } + toDisplayUSD(bn) { return parseFloat( - bn.toNumber() >= 1 ? bn.toFixed(0, BigNumber.ROUND_UP).toString() : - bn.toFixed(2, BigNumber.ROUND_UP).toString() + bn.toNumber() >= 1 ? bn.toFixed(0, BigNumber.ROUND_UP).toString() : bn.toFixed(2, BigNumber.ROUND_UP).toString() ) } - roundGwei (gwei) { + roundGwei(gwei) { if (gwei && gwei < 0.001) return '‹0.001' return parseFloat( - gwei >= 10 ? Math.round(gwei) : - gwei >= 5 ? Math.round(gwei * 10) / 10 : - gwei >= 1 ? Math.round(gwei * 100) / 100 : - Math.round(gwei * 1000) / 1000 + gwei >= 10 + ? Math.round(gwei) + : gwei >= 5 + ? Math.round(gwei * 10) / 10 + : gwei >= 1 + ? Math.round(gwei * 100) / 100 + : Math.round(gwei * 1000) / 1000 ) } - levelDisplay (level) { - const gwei = weiToGwei(hexToInt(level)) + levelDisplay(level) { + const gwei = weiToGwei(hexToInt(level)) return this.roundGwei(gwei) || 0 } - txEstimate (value, gasLimit, nativeUSD) { - return this.toDisplayUSD(BigNumber(value * gasLimit).shiftedBy(-9).multipliedBy(nativeUSD)) + txEstimate(value, gasLimit, nativeUSD) { + return this.toDisplayUSD( + BigNumber(value * gasLimit) + .shiftedBy(-9) + .multipliedBy(nativeUSD) + ) } - txEstimates (type, id, gasPrice, calculatedFees, currentSymbol) { - + txEstimates(type, id, gasPrice, calculatedFees, currentSymbol) { const estimates = [ { label: 'Send ' + currentSymbol, - estimatedGas: gasToSendEth + estimatedGas: gasToSendEth, }, { label: 'Send Tokens', - estimatedGas: gasToSendToken + estimatedGas: gasToSendToken, }, { label: 'Dex Swap', - estimatedGas: gasForDexSwap - } + estimatedGas: gasForDexSwap, + }, ] const layer = this.store('main.networks', type, id, 'layer') const nativeCurrency = this.store('main.networksMeta', type, id, 'nativeCurrency') - const nativeUSD = BigNumber(nativeCurrency && nativeCurrency.usd && layer !== 'testnet' ? nativeCurrency.usd.price : 0) + const nativeUSD = BigNumber( + nativeCurrency && nativeCurrency.usd && layer !== 'testnet' ? nativeCurrency.usd.price : 0 + ) if (id === 10) { // Optimism specific calculations @@ -93,58 +127,63 @@ class Gas extends React.Component { return this.toDisplayUSD(l1Estimate.plus(l2Estimate).shiftedBy(-9).multipliedBy(nativeUSD)) } - return estimates.map(({ label, estimatedGas }, i) => ( - { - low: optimismEstimate(l1GasEstimates[i], estimatedGas), - high: optimismEstimate(l1GasEstimates[i], estimatedGas), - label - } - )) + return estimates.map(({ label, estimatedGas }, i) => ({ + low: optimismEstimate(l1GasEstimates[i], estimatedGas), + high: optimismEstimate(l1GasEstimates[i], estimatedGas), + label, + })) } else { const low = calculatedFees ? this.roundGwei(calculatedFees.actualBaseFee + calculatedFees.priorityFee) : gasPrice - return estimates.map(({ label, estimatedGas }) => ( - { - low: this.txEstimate(low, estimatedGas, nativeUSD), - high: this.txEstimate(gasPrice, estimatedGas, nativeUSD), - label - } - )) + return estimates.map(({ label, estimatedGas }) => ({ + low: this.txEstimate(low, estimatedGas, nativeUSD), + high: this.txEstimate(gasPrice, estimatedGas, nativeUSD), + label, + })) } } - render () { + render() { const { type, id } = this.store('main.currentNetwork') const levels = this.store('main.networksMeta', type, id, 'gas.price.levels') const fees = this.store('main.networksMeta', type, id, 'gas.price.fees') const currentSymbol = this.store('main.networks', type, id, 'symbol') || 'ETH' const gasPrice = this.levelDisplay(levels.fast) - const { nextBaseFee, maxPriorityFeePerGas } = (fees || {}) + const { nextBaseFee, maxPriorityFeePerGas } = fees || {} const calculatedFees = { - actualBaseFee: this.roundGwei((weiToGwei(hexToInt(nextBaseFee)))), - priorityFee: this.levelDisplay(maxPriorityFeePerGas) + actualBaseFee: this.roundGwei(weiToGwei(hexToInt(nextBaseFee))), + priorityFee: this.levelDisplay(maxPriorityFeePerGas), } const feeEstimatesUSD = this.txEstimates(type, id, gasPrice, fees ? calculatedFees : null, currentSymbol) return (
-
{'Fee Monitor'}
+
{'Fee Monitor'}
- {this.state.baseHover ?
The current base fee is added with a buffer to cover the next 3 blocks, any amount greater than your block's base fee is refunded
: null} - {this.state.prioHover ?
A priority tip paid to validators is added to incentivize quick inclusion of your transaction into a block
: null } -
+ {this.state.baseHover ? ( +
+ The current base fee is added with a buffer to cover the next 3 blocks, any amount greater than your + block's base fee is refunded +
+ ) : null} + {this.state.prioHover ? ( +
+ A priority tip paid to validators is added to incentivize quick inclusion of your transaction into a block +
+ ) : null} +
{calculatedFees.actualBaseFee} {'GWEI'} {'Current Base'}
-
this.setState({ baseHover: true })} - style={ !fees ? { pointerEvents: 'none', opacity: 0 } : {}} + style={!fees ? { pointerEvents: 'none', opacity: 0 } : {}} onMouseLeave={() => this.setState({ baseHover: false })} >
+
@@ -153,28 +192,32 @@ class Gas extends React.Component { {gasPrice} {'GWEI'} {'Recommended'} -
this.setState({ prioHover: true })} onMouseLeave={() => this.setState({ prioHover: false })} >
{svg.chevron(27)}
-
+
{calculatedFees.priorityFee} {'GWEI'} {'Priority Tip'}
- {feeEstimatesUSD.map((estimate) =>{ + {feeEstimatesUSD.map((estimate) => { return (
- {!estimate.low || estimate.low >= 1 ? `$` : '<$'} - {`${!estimate.low ? 0 : estimate.low < 1 ? 1 : estimate.low}`} + + {!estimate.low || estimate.low >= 1 ? `$` : '<$'} + + {`${ + !estimate.low ? 0 : estimate.low < 1 ? 1 : estimate.low + }`}
{estimate.label}
diff --git a/app/App/Main/Account/Inventory/index.js b/app/App/Main/Account/Inventory/index.js index 76ce49e3e..ad5d13725 100644 --- a/app/App/Main/Account/Inventory/index.js +++ b/app/App/Main/Account/Inventory/index.js @@ -4,31 +4,33 @@ import link from '../../../../../resources/link' import svg from '../../../../../resources/svg' class Inventory extends React.Component { - constructor (...args) { + constructor(...args) { super(...args) this.moduleRef = React.createRef() if (!this.props.expanded) { this.resizeObserver = new ResizeObserver(() => { if (this.moduleRef && this.moduleRef.current) { - link.send('tray:action', 'updateAccountModule', this.props.moduleId, { height: this.moduleRef.current.clientHeight }) + link.send('tray:action', 'updateAccountModule', this.props.moduleId, { + height: this.moduleRef.current.clientHeight, + }) } }) } this.state = { expand: false, - hoverAsset: false + hoverAsset: false, } } - componentDidMount () { + componentDidMount() { if (this.resizeObserver) this.resizeObserver.observe(this.moduleRef.current) } - componentWillUnmount () { + componentWillUnmount() { if (this.resizeObserver) this.resizeObserver.disconnect() } - render () { + render() { const inventory = this.store('main.inventory', this.props.id) const collections = Object.keys(inventory || {}) return ( @@ -36,105 +38,135 @@ class Inventory extends React.Component {
{'Inventory'} {this.props.expanded ? ( -
{ - this.props.expandModule(false) - }}> +
{ + this.props.expandModule(false) + }} + > {svg.close(12)}
) : null} -
+
- {collections.length ? collections.filter(k => { - if (this.props.expanded) { - const expandedData = this.props.expandedData || {} - const current = expandedData.currentCollection - return current === k - } else { - return true - } - }).sort((a, b) => { - const assetsLengthA = Object.keys(inventory[a].items).length - const assetsLengthB = Object.keys(inventory[b].items).length - if (assetsLengthA > assetsLengthB) return -1 - if (assetsLengthA < assetsLengthB) return 1 - return 0 - }).map(k => { - return ( -
{ - this.props.expandModule(this.props.moduleId, { currentCollection: k }) - }} - style={this.props.expanded ? { - position: 'absolute', - top: '30px', - right: '0', - bottom: '0', - left: '0' - } : {}} - > - {this.props.expanded ? ( - <> -
- {this.state.hoverAsset ? ( -
- {this.state.hoverAsset.img ? : null} + {collections.length ? ( + collections + .filter((k) => { + if (this.props.expanded) { + const expandedData = this.props.expandedData || {} + const current = expandedData.currentCollection + return current === k + } else { + return true + } + }) + .sort((a, b) => { + const assetsLengthA = Object.keys(inventory[a].items).length + const assetsLengthB = Object.keys(inventory[b].items).length + if (assetsLengthA > assetsLengthB) return -1 + if (assetsLengthA < assetsLengthB) return 1 + return 0 + }) + .map((k) => { + return ( +
{ + this.props.expandModule(this.props.moduleId, { currentCollection: k }) + }} + style={ + this.props.expanded + ? { + position: 'absolute', + top: '30px', + right: '0', + bottom: '0', + left: '0', + } + : {} + } + > + {this.props.expanded ? ( + <> +
+ {this.state.hoverAsset ? ( +
+ {this.state.hoverAsset.img ? ( + + ) : null} +
+ ) : ( +
+ )} +
+
+ {this.state.hoverAsset ? this.state.hoverAsset.name : inventory[k].meta.name} +
+
+ {Object.keys(inventory[k].items || {}) + .sort((a, b) => { + a = inventory[k].items[a].tokenId + b = inventory[k].items[b].tokenId + return a < b ? -1 : b > a ? 1 : 0 + }) + .map((id) => { + const { tokenId, name, img, openSeaLink } = inventory[k].items[id] + return ( +
{ + this.store.notify('openExternal', { url: openSeaLink }) + }} + onMouseEnter={() => { + this.setState({ + hoverAsset: { + name, + tokenId, + img, + }, + }) + }} + onMouseLeave={() => { + this.setState({ + hoverAsset: false, + }) + }} + > + {img ? ( + + ) : null} +
+ ) + })} +
- ) : ( -
- )} -
-
{this.state.hoverAsset ? this.state.hoverAsset.name : inventory[k].meta.name}
-
- {Object.keys(inventory[k].items || {}).sort((a, b) => { - a = inventory[k].items[a].tokenId - b = inventory[k].items[b].tokenId - return a < b ? -1 : b > a ? 1 : 0 - }).map(id => { - const { tokenId, name, img, openSeaLink } = inventory[k].items[id] - return ( -
{ - this.store.notify('openExternal', { url: openSeaLink }) - }} - onMouseEnter={() => { - this.setState({ - hoverAsset: { - name, - tokenId, - img - } - }) - }} - onMouseLeave={() => { - this.setState({ - hoverAsset: false - }) - }} - > - {img ? : null} -
- ) - })} -
-
- - ) : ( -
-
{inventory[k].meta.name}
-
{Object.keys(inventory[k].items).length}
-
+ + ) : ( +
+
{inventory[k].meta.name}
+
{Object.keys(inventory[k].items).length}
+
+
+ )}
- )} -
- ) - }) : inventory ? ( + ) + }) + ) : inventory ? (
No Items Found
) : (
Loading Items..
diff --git a/app/App/Main/Account/Launcher/index.js b/app/App/Main/Account/Launcher/index.js index 6b09dc1f4..995d86c2f 100644 --- a/app/App/Main/Account/Launcher/index.js +++ b/app/App/Main/Account/Launcher/index.js @@ -7,20 +7,36 @@ import oneInch from './1inch.png' import uniswap from './uniswap.png' class Launcher extends React.Component { - constructor (...args) { + constructor(...args) { super(...args) this.moduleRef = React.createRef() this.resizeObserver = new ResizeObserver(() => { if (this.moduleRef && this.moduleRef.current) { - link.send('tray:action', 'updateAccountModule', this.props.moduleId, { height: this.moduleRef.current.clientHeight }) + link.send('tray:action', 'updateAccountModule', this.props.moduleId, { + height: this.moduleRef.current.clientHeight, + }) } }) this.state = { - expand: false + expand: false, + } + this.e = { + p: [ + 'QXJyb3dVcA==', + 'QXJyb3dVcA==', + 'QXJyb3dEb3du', + 'QXJyb3dEb3du', + 'QXJyb3dMZWZ0', + 'QXJyb3dSaWdodA==', + 'QXJyb3dMZWZ0', + 'QXJyb3dSaWdodA==', + 'Yg==', + 'YQ==', + ], + i: 0, } - this.e = { p: ['QXJyb3dVcA==', 'QXJyb3dVcA==', 'QXJyb3dEb3du', 'QXJyb3dEb3du', 'QXJyb3dMZWZ0', 'QXJyb3dSaWdodA==', 'QXJyb3dMZWZ0', 'QXJyb3dSaWdodA==', 'Yg==', 'YQ=='], i: 0 } } - h (e) { + h(e) { if (this.e.p.indexOf(btoa(e.key)) < 0 || btoa(e.key) !== this.e.p[this.e.i]) { this.e.i = 0 } else { @@ -29,34 +45,38 @@ class Launcher extends React.Component { if (this.e.p.length === this.e.i) { this.e.i = 0 if (this.state.l === true) { - this.setState({l: false}) + this.setState({ l: false }) } else { - this.setState({l: true}) + this.setState({ l: true }) } } } } - componentDidMount () { + componentDidMount() { this.resizeObserver.observe(this.moduleRef.current) document.addEventListener('keydown', this.h.bind(this)) } - componentWillUnmount () { + componentWillUnmount() { link.send('tray:action', 'updateAccountModule', this.props.moduleId, { height: 0 }) document.removeEventListener('keydown', this.h.bind(this)) } - glitch (el) { + glitch(el) { return (
- {[...Array(10).keys()].map(i =>
{el}
)} - {!this.state.glitchOn ?
{el}
: null } + {[...Array(10).keys()].map((i) => ( +
+ {el} +
+ ))} + {!this.state.glitchOn ?
{el}
: null}
) } - render () { + render() { return (
-
{ this.setState({ glitchOn: false }) @@ -66,14 +86,12 @@ class Launcher extends React.Component { onMouseOver={() => this.setState({ glitchOn: true })} onMouseLeave={() => this.setState({ glitchOn: false })} > - {this.glitch(
-
- {svg.send(13)} -
-
- {'Send'} + {this.glitch( +
+
{svg.send(13)}
+
{'Send'}
-
)} + )}
@@ -81,4 +99,4 @@ class Launcher extends React.Component { } } -export default Restore.connect(Launcher) \ No newline at end of file +export default Restore.connect(Launcher) diff --git a/app/App/Main/Account/Permissions/index.js b/app/App/Main/Account/Permissions/index.js index a79934832..15359d0d7 100644 --- a/app/App/Main/Account/Permissions/index.js +++ b/app/App/Main/Account/Permissions/index.js @@ -4,42 +4,48 @@ import link from '../../../../../resources/link' import svg from '../../../../../resources/svg' class Balances extends React.Component { - constructor (...args) { + constructor(...args) { super(...args) this.moduleRef = React.createRef() if (!this.props.expanded) { this.resizeObserver = new ResizeObserver(() => { if (this.moduleRef && this.moduleRef.current) { - link.send('tray:action', 'updateAccountModule', this.props.moduleId, { height: this.moduleRef.current.clientHeight }) + link.send('tray:action', 'updateAccountModule', this.props.moduleId, { + height: this.moduleRef.current.clientHeight, + }) } }) } } - componentDidMount () { + componentDidMount() { if (this.resizeObserver) this.resizeObserver.observe(this.moduleRef.current) } - componentWillUnmount () { + componentWillUnmount() { if (this.resizeObserver) this.resizeObserver.disconnect() } - render () { + render() { const i = 0 // const transform = viewIndex === i ? 'translateX(0)' : viewIndex > i ? 'translateX(-100%)' : 'translateX(100%)' // const id = this.store('selected.current') // const address = this.store('main.accounts', this.props.id, 'address') const permissions = this.store('main.permissions', this.props.id) || {} - let permissionList = Object.keys(permissions).sort((a, b) => a.origin < b.origin ? -1 : 1) + let permissionList = Object.keys(permissions).sort((a, b) => (a.origin < b.origin ? -1 : 1)) if (!this.props.expanded) permissionList = permissionList.slice(0, 3) - + return ( -
{'Permissions'} @@ -48,7 +54,7 @@ class Balances extends React.Component { {svg.close(12)}
) : null} -
+
{permissionList.length === 0 ? ( @@ -58,14 +64,18 @@ class Balances extends React.Component {
) : ( - permissionList.map(o => { + permissionList.map((o) => { return (
{permissions[o].origin}
-
link.send('tray:action', 'toggleAccess', this.props.id, o)} +
link.send('tray:action', 'toggleAccess', this.props.id, o)} >
@@ -76,24 +86,32 @@ class Balances extends React.Component { )} {this.props.expanded ? (
-
{ - link.send('tray:action', 'clearPermissions', this.props.id) - }} className='moduleButton'>Clear All Permissions
+
{ + link.send('tray:action', 'clearPermissions', this.props.id) + }} + className='moduleButton' + > + Clear All Permissions +
) : null}
{!this.props.expanded ? (
-
this.props.expandModule(this.props.moduleId)}> +
this.props.expandModule(this.props.moduleId)} + > More
- ) : null } + ) : null}
) } } -export default Restore.connect(Balances) \ No newline at end of file +export default Restore.connect(Balances) diff --git a/app/App/Main/Account/Requests/AddTokenRequest/index.js b/app/App/Main/Account/Requests/AddTokenRequest/index.js index 52b7ca3be..9492e3f94 100644 --- a/app/App/Main/Account/Requests/AddTokenRequest/index.js +++ b/app/App/Main/Account/Requests/AddTokenRequest/index.js @@ -4,7 +4,7 @@ import svg from '../../../../../../resources/svg' import link from '../../../../../../resources/link' class AddTokenRequest extends React.Component { - constructor (...args) { + constructor(...args) { super(...args) this.state = { allowInput: false } setTimeout(() => { @@ -12,7 +12,7 @@ class AddTokenRequest extends React.Component { }, 200) } - render () { + render() { const status = this.props.req.status const notice = this.props.req.notice @@ -31,15 +31,21 @@ class AddTokenRequest extends React.Component { const height = mode === 'monitor' ? '80px' : '340px' const token = this.props.req.token return ( -
+
{notice ? (
- {(_ => { + {((_) => { if (status === 'pending') { return (
-
+
+
+
) } else if (status === 'success') { @@ -75,16 +81,20 @@ class AddTokenRequest extends React.Component {
{ if (this.state.allowInput) link.send('tray:addToken', false, this.props.req) - }}> + style={{ pointerEvents: this.state.allowInput ? 'auto' : 'none' }} + onClick={() => { + if (this.state.allowInput) link.send('tray:addToken', false, this.props.req) + }} + >
Decline
{ if (this.state.allowInput) this.store.notify('addToken', this.props.req) - }}> + style={{ pointerEvents: this.state.allowInput ? 'auto' : 'none' }} + onClick={() => { + if (this.state.allowInput) this.store.notify('addToken', this.props.req) + }} + >
Review
diff --git a/app/App/Main/Account/Requests/ChainRequest/index.js b/app/App/Main/Account/Requests/ChainRequest/index.js index b01fcf091..c7fc91b07 100644 --- a/app/App/Main/Account/Requests/ChainRequest/index.js +++ b/app/App/Main/Account/Requests/ChainRequest/index.js @@ -4,7 +4,7 @@ import svg from '../../../../../../resources/svg' import link from '../../../../../../resources/link' class ChainRequest extends React.Component { - constructor (...args) { + constructor(...args) { super(...args) this.state = { allowInput: false } setTimeout(() => { @@ -12,7 +12,7 @@ class ChainRequest extends React.Component { }, 200) } - render () { + render() { const status = this.props.req.status const notice = this.props.req.notice const type = this.props.req.type @@ -31,15 +31,21 @@ class ChainRequest extends React.Component { const height = mode === 'monitor' ? '80px' : '340px' const chain = this.props.req.chain return ( -
+
{notice ? (
- {(_ => { + {((_) => { if (status === 'pending') { return (
-
+
+
+
) } else if (status === 'success') { @@ -51,7 +57,7 @@ class ChainRequest extends React.Component {
) : (
- {type === 'switchChain' ? ( + {type === 'switchChain' ? (
{svg.octicon('shield', { height: 20 })}
Switch Chain
@@ -65,10 +71,14 @@ class ChainRequest extends React.Component {
{this.store('main.origins', this.props.req.origin, 'name')}
-
{type === 'switchChain' ? 'wants to switch to chain' : 'wants to add chain'}
-
{type === 'switchChain' ? ( - this.store('main.networks', chain.type, parseInt(chain.id), 'name') - ) : chain.name}
+
+ {type === 'switchChain' ? 'wants to switch to chain' : 'wants to add chain'} +
+
+ {type === 'switchChain' + ? this.store('main.networks', chain.type, parseInt(chain.id), 'name') + : chain.name} +
@@ -76,35 +86,43 @@ class ChainRequest extends React.Component {
{type === 'switchChain' ? (
-
{ if (this.state.allowInput) link.send('tray:switchChain', false, false, this.props.req) - }}> +
{ + if (this.state.allowInput) link.send('tray:switchChain', false, false, this.props.req) + }} + >
Decline
-
{ if (this.state.allowInput) link.send('tray:switchChain', chain.type, parseInt(chain.id), this.props.req) - }}> +
{ + if (this.state.allowInput) link.send('tray:switchChain', chain.type, parseInt(chain.id), this.props.req) + }} + >
Switch
) : (
-
{ if (this.state.allowInput && this.props.onTop) link.send('tray:addChain', false, this.props.req) - }}> +
{ + if (this.state.allowInput && this.props.onTop) link.send('tray:addChain', false, this.props.req) + }} + >
Decline
-
{ if (this.state.allowInput && this.props.onTop) this.store.notify('addChain', this.props.req) - }}> +
{ + if (this.state.allowInput && this.props.onTop) this.store.notify('addChain', this.props.req) + }} + >
Review
diff --git a/app/App/Main/Account/Requests/ProviderRequest/index.js b/app/App/Main/Account/Requests/ProviderRequest/index.js index 790c1b230..54edaf699 100644 --- a/app/App/Main/Account/Requests/ProviderRequest/index.js +++ b/app/App/Main/Account/Requests/ProviderRequest/index.js @@ -4,7 +4,7 @@ import svg from '../../../../../../resources/svg' import link from '../../../../../../resources/link' class ProviderRequest extends React.Component { - constructor (...args) { + constructor(...args) { super(...args) this.state = { allowInput: false } setTimeout(() => { @@ -12,7 +12,7 @@ class ProviderRequest extends React.Component { }, 200) } - render () { + render() { const status = this.props.req.status const notice = this.props.req.notice let requestClass = 'signerRequest' @@ -36,41 +36,37 @@ class ProviderRequest extends React.Component {
) : status === 'success' ? ( -
- {svg.octicon('check', { height: 80 })} -
+
{svg.octicon('check', { height: 80 })}
) : status === 'error' || status === 'declined' ? ( -
- {svg.octicon('circle-slash', { height: 80 })} -
+
{svg.octicon('circle-slash', { height: 80 })}
) : null}
) : (
-
- {originName} -
-
- wants to connect -
+
{originName}
+
wants to connect
)}
-
{ if (this.state.allowInput) link.send('tray:giveAccess', this.props.req, false) - }}> +
{ + if (this.state.allowInput) link.send('tray:giveAccess', this.props.req, false) + }} + >
Decline
-
{ if (this.state.allowInput) link.send('tray:giveAccess', this.props.req, true) - }}> +
{ + if (this.state.allowInput) link.send('tray:giveAccess', this.props.req, true) + }} + >
Approve
diff --git a/app/App/Main/Account/Requests/SignTypedDataRequest/index.js b/app/App/Main/Account/Requests/SignTypedDataRequest/index.js index e53d2196e..1eb50d332 100644 --- a/app/App/Main/Account/Requests/SignTypedDataRequest/index.js +++ b/app/App/Main/Account/Requests/SignTypedDataRequest/index.js @@ -11,11 +11,7 @@ const SimpleJSON = ({ json }) => {
{key}:
- {typeof json[key] === 'object' ? ( - - ) : ( - json[key] - )} + {typeof json[key] === 'object' ? : json[key]}
))} @@ -24,7 +20,7 @@ const SimpleJSON = ({ json }) => { } class TransactionRequest extends React.Component { - constructor (...args) { + constructor(...args) { super(...args) this.state = { allowInput: false, dataView: false } @@ -35,31 +31,31 @@ class TransactionRequest extends React.Component { }, props.signingDelay || 1500) } - copyAddress (e) { + copyAddress(e) { e.preventDefault() e.target.select() document.execCommand('Copy') this.setState({ copied: true }) - setTimeout(_ => this.setState({ copied: false }), 1000) + setTimeout((_) => this.setState({ copied: false }), 1000) } - approve (reqId, req) { + approve(reqId, req) { link.rpc('approveRequest', req, () => {}) // Move to link.send } - decline (reqId, req) { + decline(reqId, req) { link.rpc('declineRequest', req, () => {}) // Move to link.send } - toggleDataView (id) { + toggleDataView(id) { this.setState({ dataView: !this.state.dataView }) } - hexToDisplayValue (hex) { + hexToDisplayValue(hex) { return (Math.round(parseFloat(utils.fromWei(hex, 'ether')) * 1000000) / 1000000).toFixed(6) } - render () { + render() { const { req } = this.props const type = req.type const status = req.status @@ -74,35 +70,33 @@ class TransactionRequest extends React.Component { if (status === 'pending') requestClass += ' signerRequestPending' if (status === 'error') requestClass += ' signerRequestError' - const messageToSign = typedData.domain - ? ( -
-
-
-
Domain
- -
-
-
Message
- -
+ const messageToSign = typedData.domain ? ( +
+
+
+
Domain
+ +
+
+
Message
+
- ) - : ( -
-
-
- { +
+ ) : ( +
+
+
+ { data[elem.name] = elem.value return data - }, {}) - } /> + }, {})} + />
- ) + ) return (
{type === 'signTypedData' ? ( @@ -110,13 +104,20 @@ class TransactionRequest extends React.Component {
{notice ? (
- {(_ => { + {((_) => { if (status === 'pending') { return (
-
+
+
+
See Signer
-
this.decline(this.props.req.handlerId, this.props.req)}>Cancel
+
this.decline(this.props.req.handlerId, this.props.req)} + > + Cancel +
) } else if (status === 'success') { @@ -134,7 +135,11 @@ class TransactionRequest extends React.Component {
) } else { - return
{notice}
+ return ( +
+ {notice} +
+ ) } })()}
@@ -152,18 +157,22 @@ class TransactionRequest extends React.Component {
{'Unknown: ' + this.props.req.type}
)}
-
{ if (this.state.allowInput) this.decline(this.props.req.handlerId, this.props.req) - }}> +
{ + if (this.state.allowInput) this.decline(this.props.req.handlerId, this.props.req) + }} + >
Decline
-
{ if (this.state.allowInput) this.approve(this.props.req.handlerId, this.props.req) - }}> +
{ + if (this.state.allowInput) this.approve(this.props.req.handlerId, this.props.req) + }} + >
Sign
diff --git a/app/App/Main/Account/Requests/SignatureRequest/index.js b/app/App/Main/Account/Requests/SignatureRequest/index.js index 27b7c6204..1e66e8844 100644 --- a/app/App/Main/Account/Requests/SignatureRequest/index.js +++ b/app/App/Main/Account/Requests/SignatureRequest/index.js @@ -5,7 +5,7 @@ import { stripHexPrefix } from 'ethereumjs-util' import svg from '../../../../../../resources/svg' import link from '../../../../../../resources/link' -function decodeMessage (rawMessage) { +function decodeMessage(rawMessage) { if (isHex(rawMessage)) { const buff = Buffer.from(stripHexPrefix(rawMessage), 'hex') return buff.length === 32 ? rawMessage : buff.toString('utf8') @@ -15,7 +15,7 @@ function decodeMessage (rawMessage) { } class TransactionRequest extends React.Component { - constructor (...args) { + constructor(...args) { super(...args) this.state = { allowInput: false, dataView: false } @@ -26,31 +26,31 @@ class TransactionRequest extends React.Component { }, props.signingDelay || 1500) } - copyAddress (e) { + copyAddress(e) { e.preventDefault() e.target.select() document.execCommand('Copy') this.setState({ copied: true }) - setTimeout(_ => this.setState({ copied: false }), 1000) + setTimeout((_) => this.setState({ copied: false }), 1000) } - approve (reqId, req) { + approve(reqId, req) { link.rpc('approveRequest', req, () => {}) // Move to link.send } - decline (reqId, req) { + decline(reqId, req) { link.rpc('declineRequest', req, () => {}) // Move to link.send } - toggleDataView (id) { + toggleDataView(id) { this.setState({ dataView: !this.state.dataView }) } - hexToDisplayValue (hex) { + hexToDisplayValue(hex) { return (Math.round(parseFloat(fromWei(hex, 'ether')) * 1000000) / 1000000).toFixed(6) } - render () { + render() { const type = this.props.req.type const status = this.props.req.status const notice = this.props.req.notice @@ -73,13 +73,20 @@ class TransactionRequest extends React.Component {
{notice ? (
- {(_ => { + {((_) => { if (status === 'pending') { return (
-
+
+
+
See Signer
-
this.decline(this.props.req.handlerId, this.props.req)}>Cancel
+
this.decline(this.props.req.handlerId, this.props.req)} + > + Cancel +
) } else if (status === 'success') { @@ -97,7 +104,11 @@ class TransactionRequest extends React.Component {
) } else { - return
{notice}
+ return ( +
+ {notice} +
+ ) } })()}
@@ -114,18 +125,22 @@ class TransactionRequest extends React.Component {
{'Unknown: ' + this.props.req.type}
)}
-
{ if (this.state.allowInput) this.decline(this.props.req.handlerId, this.props.req) - }}> +
{ + if (this.state.allowInput) this.decline(this.props.req.handlerId, this.props.req) + }} + >
Decline
-
{ if (this.state.allowInput) this.approve(this.props.req.handlerId, this.props.req) - }}> +
{ + if (this.state.allowInput) this.approve(this.props.req.handlerId, this.props.req) + }} + >
Sign
diff --git a/app/App/Main/Account/Requests/TransactionRequest/TxApproval/approvals/BasicApproval/index.js b/app/App/Main/Account/Requests/TransactionRequest/TxApproval/approvals/BasicApproval/index.js index 8db7a651a..e4c54a04a 100644 --- a/app/App/Main/Account/Requests/TransactionRequest/TxApproval/approvals/BasicApproval/index.js +++ b/app/App/Main/Account/Requests/TransactionRequest/TxApproval/approvals/BasicApproval/index.js @@ -4,23 +4,20 @@ import Restore from 'react-restore' import svg from '../../../../../../../../../resources/svg' class BasicApproval extends React.Component { - constructor (...args) { + constructor(...args) { super(...args) this.state = { - inPreview: false + inPreview: false, } } - render () { + render() { const { approval } = this.props return (
-
this.props.onDecline(this.props.req)} - > +
this.props.onDecline(this.props.req)}> Reject
-
-
- {svg.alert(32)} -
-
- {svg.alert(32)} -
-
- {approval && approval.data && approval.data.title} -
+
+
{svg.alert(32)}
+
{svg.alert(32)}
+
{approval && approval.data && approval.data.title}
{approval && approval.data && approval.data.message} diff --git a/app/App/Main/Account/Requests/TransactionRequest/TxApproval/approvals/TokenSpend/index.js b/app/App/Main/Account/Requests/TransactionRequest/TxApproval/approvals/TokenSpend/index.js index 0518b8014..87e0c7dcc 100644 --- a/app/App/Main/Account/Requests/TransactionRequest/TxApproval/approvals/TokenSpend/index.js +++ b/app/App/Main/Account/Requests/TransactionRequest/TxApproval/approvals/TokenSpend/index.js @@ -16,24 +16,29 @@ const digitsLookup = [ { value: 1e9, symbol: 'billion' }, { value: 1e12, symbol: 'trillion' }, { value: 1e15, symbol: 'quadrillion' }, - { value: 1e18, symbol: 'quintillion' } + { value: 1e18, symbol: 'quintillion' }, ] -function nFormat (n, digits = 2) { +function nFormat(n, digits = 2) { const num = Number(n) - const item = digitsLookup.slice().reverse().find(item => num >= item.value) + const item = digitsLookup + .slice() + .reverse() + .find((item) => num >= item.value) - return item ? { - number: (num / item.value).toFixed(digits).replace(numberRegex, '$1'), - symbol: item.symbol - } : { - number: '0', - symbol: '' - } + return item + ? { + number: (num / item.value).toFixed(digits).replace(numberRegex, '$1'), + symbol: item.symbol, + } + : { + number: '0', + symbol: '', + } } class TokenSpend extends React.Component { - constructor (...args) { + constructor(...args) { super(...args) this.decimals = this.props.approval.data.decimals || 0 @@ -43,15 +48,15 @@ class TokenSpend extends React.Component { inEditApproval: false, mode: 'requested', amount: this.requestedAmount, - customInput: '' + customInput: '', } } - setAmount (amount) { + setAmount(amount) { this.setState({ amount }) } - setCustomAmount (value) { + setCustomAmount(value) { if (value === '') { this.setState({ mode: 'custom', amount: '0x0', customInput: value }) } else { @@ -64,16 +69,16 @@ class TokenSpend extends React.Component { } else { amount = '0x' + custom.integerValue().toString(16) } - + this.setState({ mode: 'custom', amount, customInput: value }) } } - startEditing () { + startEditing() { this.setState({ inEditApproval: true }) } - doneEditing () { + doneEditing() { if (this.state.mode === 'custom' && this.state.customInput === '') { this.setState({ mode: 'requested', amount: this.requestedAmount }) } @@ -84,19 +89,24 @@ class TokenSpend extends React.Component { }, 600) } - render () { + render() { const { req, approval } = this.props const { data } = approval const displayInt = new BigNumber(this.state.amount).shiftedBy(-this.decimals).integerValue() - const displayAmount = this.state.amount === MAX_HEX ? { - number: '', - symbol: 'unlimited' - } : displayInt > 9e12 ? { - number: '', - symbol: this.props.approval.data.decimals ? '~unlimited' : 'unknown' - } : nFormat(displayInt) + const displayAmount = + this.state.amount === MAX_HEX + ? { + number: '', + symbol: 'unlimited', + } + : displayInt > 9e12 + ? { + number: '', + symbol: this.props.approval.data.decimals ? '~unlimited' : 'unknown', + } + : nFormat(displayInt) const symbol = data.symbol || '???' const name = data.name || 'Unknown Token' @@ -109,16 +119,24 @@ class TokenSpend extends React.Component {
this.props.onDecline(req)} > Reject
{ if (this.state.inEditApproval) { @@ -128,53 +146,51 @@ class TokenSpend extends React.Component { } }} > - {this.state.inEditApproval ? 'Done' : 'Edit' } + {this.state.inEditApproval ? 'Done' : 'Edit'}
{ - this.props.onApprove( - this.props.req, - ApprovalType.TokenSpendApproval, - { amount: this.state.amount } - ) + this.props.onApprove(this.props.req, ApprovalType.TokenSpendApproval, { + amount: this.state.amount, + }) }} > Proceed
-
- {svg.alert(32)} -
-
- {svg.alert(32)} -
+
{svg.alert(32)}
+
{svg.alert(32)}
{'token approval'}
{this.state.inEditApproval ? (
{this.state.exiting ? (
- {displayAmount.number ?
{displayAmount.number}
: null} - {displayAmount.symbol ?
{displayAmount.symbol}
: null} + {displayAmount.number ? ( +
{displayAmount.number}
+ ) : null} + {displayAmount.symbol ? ( +
{displayAmount.symbol}
+ ) : null}
{data.symbol}
) : (
-
- {'Token Spend Limit'} -
+
{'Token Spend Limit'}
-
- {symbol} -
+
{symbol}
{this.state.mode === 'custom' ? ( - ) : (
-
{ - this.setCustomAmount(this.state.customInput) - }} + onClick={ + inputLock + ? null + : () => { + this.setCustomAmount(this.state.customInput) + } + } >
{displayAmount.number}
-
{displayAmount.symbol}
+
{displayAmount.symbol}
)}
{ this.setState({ mode: 'requested', amount: this.requestedAmount }) @@ -214,8 +238,12 @@ class TokenSpend extends React.Component { > Requested
-
{ const amount = MAX_HEX @@ -225,8 +253,12 @@ class TokenSpend extends React.Component { {'Unlimited'}
{!inputLock ? ( -
{ this.setCustomAmount(this.state.customInput) @@ -249,43 +281,37 @@ class TokenSpend extends React.Component { {svg.octicon('kebab-horizontal', { height: 15 })} {data.spender.substr(data.contract.length - 4)}
-
{ link.send('tray:clipboardData', data.spender) this.setState({ copyTokenRequester: true }) setTimeout(() => { this.setState({ copyTokenRequester: false }) - }, 1000) + }, 1000) }} > {this.state.copyTokenRequester ? 'ADDRESS COPIED' : data.spender}
) : null} -
- {'wants approval to spend'} -
+
{'wants approval to spend'}
-
- {symbol} -
-
{symbol}
+
{ link.send('tray:clipboardData', data.contract) this.setState({ copyTokenContract: true }) setTimeout(() => { this.setState({ copyTokenContract: false }) - }, 1000) + }, 1000) }} > {this.state.copyTokenContract ? 'ADDRESS COPIED' : data.contract}
-
- {name} -
+
{name}
)} diff --git a/app/App/Main/Account/Requests/TransactionRequest/TxApproval/index.js b/app/App/Main/Account/Requests/TransactionRequest/TxApproval/index.js index 6fd734213..9c1573d44 100644 --- a/app/App/Main/Account/Requests/TransactionRequest/TxApproval/index.js +++ b/app/App/Main/Account/Requests/TransactionRequest/TxApproval/index.js @@ -7,19 +7,21 @@ import { ApprovalType } from '../../../../../../../resources/constants' import { BasicApproval, TokenSpend } from './approvals' const supportedApprovals = [ - ApprovalType.GasLimitApproval, ApprovalType.OtherChainApproval, ApprovalType.TokenSpendApproval + ApprovalType.GasLimitApproval, + ApprovalType.OtherChainApproval, + ApprovalType.TokenSpendApproval, ] class TxApproval extends React.Component { - approve (req, type, data = {}, cb = () => {}) { - link.rpc('confirmRequestApproval', req, type, data, cb) + approve(req, type, data = {}, cb = () => {}) { + link.rpc('confirmRequestApproval', req, type, data, cb) } - decline (req, cb = () => {}) { + decline(req, cb = () => {}) { link.rpc('declineRequest', req, cb) } - render () { + render() { const { req, approval, allowOtherChain } = this.props if (!supportedApprovals.includes(approval.type)) { @@ -27,37 +29,17 @@ class TxApproval extends React.Component { } if (approval.type === ApprovalType.GasLimitApproval) { - return ( - - ) + return } if (approval.type === ApprovalType.OtherChainApproval) { - if (!allowOtherChain || typeof allowOtherChain !== 'function') throw new Error('OtherChainApproval needs allowOtherChain') - return ( - - ) + if (!allowOtherChain || typeof allowOtherChain !== 'function') + throw new Error('OtherChainApproval needs allowOtherChain') + return } if (approval.type === ApprovalType.TokenSpendApproval) { - return ( - - ) + return } } } diff --git a/app/App/Main/Account/Requests/TransactionRequest/TxBar/index.js b/app/App/Main/Account/Requests/TransactionRequest/TxBar/index.js index 071bba05f..49add59a5 100644 --- a/app/App/Main/Account/Requests/TransactionRequest/TxBar/index.js +++ b/app/App/Main/Account/Requests/TransactionRequest/TxBar/index.js @@ -3,7 +3,7 @@ import Restore from 'react-restore' import svg from '../../../../../../../resources/svg' class TxBar extends React.Component { - render () { + render() { const req = this.props.req let position = 0 let txBarClass = 'txBar' @@ -31,19 +31,31 @@ class TxBar extends React.Component {
-
{svg.sign(22)}
+
+ {svg.sign(22)} +
-
1 ? 'txProgressStepCenter txProgressStepCenterOn' : 'txProgressStepCenter'} /> +
1 ? 'txProgressStepCenter txProgressStepCenterOn' : 'txProgressStepCenter'} + />
-
{svg.send(15)}
+
+ {svg.send(15)} +
-
2 ? 'txProgressStepCenter txProgressStepCenterOn' : 'txProgressStepCenter'} /> +
2 ? 'txProgressStepCenter txProgressStepCenterOn' : 'txProgressStepCenter'} + />
-
{svg.octicon('check', { height: 24 })}
+
+ {svg.octicon('check', { height: 24 })} +
-
3 ? 'txProgressStepCenter txProgressStepCenterOn' : 'txProgressStepCenter'} /> +
3 ? 'txProgressStepCenter txProgressStepCenterOn' : 'txProgressStepCenter'} + />
diff --git a/app/App/Main/Account/Requests/TransactionRequest/TxData/index.js b/app/App/Main/Account/Requests/TransactionRequest/TxData/index.js index eaa98bb42..321a797c2 100644 --- a/app/App/Main/Account/Requests/TransactionRequest/TxData/index.js +++ b/app/App/Main/Account/Requests/TransactionRequest/TxData/index.js @@ -4,50 +4,57 @@ import link from '../../../../../../../resources/link' import svg from '../../../../../../../resources/svg' class txData extends React.Component { - constructor (...args) { + constructor(...args) { super(...args) this.state = { - copied: false + copied: false, } } - copyAddress (data) { + copyAddress(data) { link.send('tray:clipboardData', data) this.setState({ copied: true }) - setTimeout(_ => this.setState({ copied: false }), 1000) + setTimeout((_) => this.setState({ copied: false }), 1000) } - render () { + render() { const req = this.props.req return (
-
{ - this.props.overlayMode('data') - }}> - {req.data.data && req.data.data !== '0x' && req.data.data !== '0x0' ? ( +
{ + this.props.overlayMode('data') + }} + > + {req.data.data && req.data.data !== '0x' && req.data.data !== '0x0' ? ( req.decodedData && req.decodedData.method ? ( <> {'Sending Data: '} - {(() => { - if (req.decodedData.method.length > 17) return `${req.decodedData.method.substr(0, 15)}..` - return req.decodedData.method - })()} + + {(() => { + if (req.decodedData.method.length > 17) return `${req.decodedData.method.substr(0, 15)}..` + return req.decodedData.method + })()} + - ) : ( + ) : ( {'Sending Data!'} ) - ) : 'No Data'} -
-
- Data + ) : ( + 'No Data' + )}
+
Data
) } } -{/*
+{ + /*
{this.state.copied ? {'Copied'}{svg.octicon('clippy', { height: 14 })} : req.data.to} -
*/} +
*/ +} export default Restore.connect(txData) diff --git a/app/App/Main/Account/Requests/TransactionRequest/TxFeeNew/index.js b/app/App/Main/Account/Requests/TransactionRequest/TxFeeNew/index.js index afefd7cee..4a76e04b0 100644 --- a/app/App/Main/Account/Requests/TransactionRequest/TxFeeNew/index.js +++ b/app/App/Main/Account/Requests/TransactionRequest/TxFeeNew/index.js @@ -7,23 +7,23 @@ import { usesBaseFee } from '../../../../../../../resources/domain/transaction' const FEE_WARNING_THRESHOLD_USD = 50 class TxFee extends React.Component { - constructor (props, context) { + constructor(props, context) { super(props, context) - this.chain = { - type: 'ethereum', - id: parseInt(props.req.data.chainId, 'hex') + this.chain = { + type: 'ethereum', + id: parseInt(props.req.data.chainId, 'hex'), } } - toDisplayUSD (bn) { + toDisplayUSD(bn) { return bn.toFixed(2, BigNumber.ROUND_UP).toString() } - toDisplayEther (bn) { + toDisplayEther(bn) { return parseFloat(bn.shiftedBy(-18).toFixed(6).toString()) } - toDisplayGwei (bn) { + toDisplayGwei(bn) { return parseFloat(bn.shiftedBy(-9).toFixed(3).toString()) } - render () { + render() { const req = this.props.req const layer = this.store('main.networks', this.chain.type, this.chain.id, 'layer') @@ -55,52 +55,47 @@ class TxFee extends React.Component { const minFeeUSD = minFee.shiftedBy(-18).multipliedBy(nativeUSD) const currentSymbol = this.store('main.networks', this.props.chain.type, this.props.chain.id, 'symbol') || '?' - + return (
-
{ - this.props.overlayMode('fee') - }}> +
{ + this.props.overlayMode('fee') + }} + > {this.toDisplayGwei(maxFeePerGas)} Gwei
{this.toDisplayUSD(maxFeeUSD) === '0.00' ? (
- - {currentSymbol || '?'} - - - {this.toDisplayEther(maxFee)} - -
+ {currentSymbol || '?'} + {this.toDisplayEther(maxFee)} +
) : (
-
FEE_WARNING_THRESHOLD_USD || this.toDisplayUSD(maxFeeUSD) === '0.00' ? '_txFeeValueDefault _txFeeValueDefaultWarn' : '_txFeeValueDefault'}> - - ≈ - - - $ - +
FEE_WARNING_THRESHOLD_USD || this.toDisplayUSD(maxFeeUSD) === '0.00' + ? '_txFeeValueDefault _txFeeValueDefaultWarn' + : '_txFeeValueDefault' + } + > + + $ {`${this.toDisplayUSD(minFeeUSD)} - ${this.toDisplayUSD(maxFeeUSD)}`} - - {`in ${currentSymbol || '?'}`} - + {`in ${currentSymbol || '?'}`}
- - {currentSymbol || '?'} - - - {this.toDisplayEther(maxFee)} - -
+ {currentSymbol || '?'} + {this.toDisplayEther(maxFee)} +
)}
diff --git a/app/App/Main/Account/Requests/TransactionRequest/TxMain/index.js b/app/App/Main/Account/Requests/TransactionRequest/TxMain/index.js index b21f7d39e..85c2b2f3b 100644 --- a/app/App/Main/Account/Requests/TransactionRequest/TxMain/index.js +++ b/app/App/Main/Account/Requests/TransactionRequest/TxMain/index.js @@ -5,21 +5,21 @@ import svg from '../../../../../../../resources/svg' import utils from 'web3-utils' class TxRecipient extends React.Component { - constructor (...args) { + constructor(...args) { super(...args) this.state = { - copied: false + copied: false, } } - copyAddress (data) { + copyAddress(data) { link.send('tray:clipboardData', data) this.setState({ copied: true }) - setTimeout(_ => this.setState({ copied: false }), 1000) + setTimeout((_) => this.setState({ copied: false }), 1000) } - hexToDisplayValue (hex) { + hexToDisplayValue(hex) { return (Math.round(parseFloat(utils.fromWei(hex, 'ether')) * 1000000) / 1000000).toFixed(6) } - render () { + render() { const req = this.props.req const layer = this.store('main.networks', this.props.chain.type, this.props.chain.id, 'layer') const nativeCurrency = this.store('main.networksMeta', this.props.chain.type, this.props.chain.id, 'nativeCurrency') @@ -40,17 +40,17 @@ class TxRecipient extends React.Component { {(value * etherUSD).toFixed(2)}
-
- Sending -
+
Sending
) } } -{/*
+{ + /*
{this.state.copied ? {'Copied'}{svg.octicon('clippy', { height: 14 })} : req.data.to} -
*/} +
*/ +} export default Restore.connect(TxRecipient) diff --git a/app/App/Main/Account/Requests/TransactionRequest/TxOverlay/TxDataOverlay/index.js b/app/App/Main/Account/Requests/TransactionRequest/TxOverlay/TxDataOverlay/index.js index 78ccf6310..87fc3ddc3 100644 --- a/app/App/Main/Account/Requests/TransactionRequest/TxOverlay/TxDataOverlay/index.js +++ b/app/App/Main/Account/Requests/TransactionRequest/TxOverlay/TxDataOverlay/index.js @@ -6,36 +6,38 @@ import link from '../../../../../../../../resources/link' //
//
- //
{svg.octicon('issue-opened', { height: 26 })}
- //
View Data
- //
this.copyData(req.data.data)}> - // {svg.octicon('clippy', { height: 20 })} - //
-//
+//
{svg.octicon('issue-opened', { height: 26 })}
+//
View Data
+//
this.copyData(req.data.data)}> +// {svg.octicon('clippy', { height: 20 })} +//
+//
//
class TxDataOverlay extends React.Component { - constructor (props, context) { + constructor(props, context) { super(props, context) this.state = { - copiedData: false + copiedData: false, } } - copyData (data) { + copyData(data) { if (data) { link.send('tray:clipboardData', data) this.setState({ copiedData: true }) - setTimeout(_ => this.setState({ copiedData: false }), 1000) + setTimeout((_) => this.setState({ copiedData: false }), 1000) } } - render () { + render() { const { req, overlayMode } = this.props return (
Transaction Data
-
overlayMode()}>{svg.octicon('x', { height: 16 })}
+
overlayMode()}> + {svg.octicon('x', { height: 16 })} +
{utils.toAscii(req.data.data || '0x') ? (
@@ -47,20 +49,18 @@ class TxDataOverlay extends React.Component {
{svg.sync(16)}
{svg.sync(16)}
-
- {req.decodedData.contractName} -
+
{req.decodedData.contractName}
{req.decodedData.method}
Inputs
- {req.decodedData.args.map(a => { + {req.decodedData.args.map((a) => { return (
{a.type.indexOf('[]') ? ( - a.value.split(',').map(i =>
{i}
) + a.value.split(',').map((i) =>
{i}
) ) : (
{a.value}
)} @@ -70,7 +70,9 @@ class TxDataOverlay extends React.Component { ) })}
- ) : 'Could not decode data..'} + ) : ( + 'Could not decode data..' + )}
{'Raw Transaction Data'}
this.copyData(req.data.data)}> @@ -86,7 +88,10 @@ class TxDataOverlay extends React.Component {
) : (
-
+
No Data
@@ -97,4 +102,4 @@ class TxDataOverlay extends React.Component { } } -export default Restore.connect(TxDataOverlay) \ No newline at end of file +export default Restore.connect(TxDataOverlay) diff --git a/app/App/Main/Account/Requests/TransactionRequest/TxOverlay/TxFeeOverlay/index.js b/app/App/Main/Account/Requests/TransactionRequest/TxOverlay/TxFeeOverlay/index.js index 94f2632dc..0463d1355 100644 --- a/app/App/Main/Account/Requests/TransactionRequest/TxOverlay/TxFeeOverlay/index.js +++ b/app/App/Main/Account/Requests/TransactionRequest/TxOverlay/TxFeeOverlay/index.js @@ -8,7 +8,7 @@ import { usesBaseFee } from '../../../../../../../../resources/domain/transactio import BigNumber from 'bignumber.js' -function maxFee (tx = { chainId: '' }) { +function maxFee(tx = { chainId: '' }) { const chainId = parseInt(tx.chainId) // for ETH-based chains, the max fee should be 2 ETH @@ -27,22 +27,22 @@ function maxFee (tx = { chainId: '' }) { //
//
- //
{svg.octicon('issue-opened', { height: 26 })}
- //
View Data
- //
this.copyData(req.data.data)}> - // {svg.octicon('clippy', { height: 20 })} - //
-//
+//
{svg.octicon('issue-opened', { height: 26 })}
+//
View Data
+//
this.copyData(req.data.data)}> +// {svg.octicon('clippy', { height: 20 })} +//
+//
//
class TxFeeOverlay extends React.Component { - constructor (props, context) { + constructor(props, context) { super(props, context) this.moduleRef = React.createRef() this.state = { - copiedData: false + copiedData: false, } if (usesBaseFee(props.req.data)) { @@ -61,45 +61,45 @@ class TxFeeOverlay extends React.Component { this.state.gasLimit = BigNumber(props.req.data.gasLimit, 16).toString() } - mouseDetect (e) { + mouseDetect(e) { if (this.moduleRef && this.moduleRef.current && !this.moduleRef.current.contains(e.target)) { this.props.overlayMode() } } - componentDidMount () { + componentDidMount() { document.addEventListener('mousedown', this.mouseDetect.bind(this)) } - componentWillUnmount () { + componentWillUnmount() { document.removeEventListener('mousedown', this.mouseDetect.bind(this)) } - copyData (data) { + copyData(data) { if (data) { link.send('tray:clipboardData', data) this.setState({ copiedData: true }) - setTimeout(_ => this.setState({ copiedData: false }), 1000) + setTimeout((_) => this.setState({ copiedData: false }), 1000) } } - toDisplayEther (bn) { + toDisplayEther(bn) { return parseFloat(bn.shiftedBy(-18).toFixed(6).toString()) } - toDisplayFromWei (bn) { - return bn.shiftedBy(-9).toFixed(9).toString().replace(/0+$/,'').replace(/\.+$/,'') + toDisplayFromWei(bn) { + return bn.shiftedBy(-9).toFixed(9).toString().replace(/0+$/, '').replace(/\.+$/, '') } - toDisplayFromGwei (bn) { - return bn.toFixed(9).toString().replace(/0+$/,'').replace(/\.+$/,'') + toDisplayFromGwei(bn) { + return bn.toFixed(9).toString().replace(/0+$/, '').replace(/\.+$/, '') } - trimGwei (gwei) { + trimGwei(gwei) { return parseFloat(parseFloat(gwei).toFixed(3)).toString() } - setBaseFee (baseFee) { + setBaseFee(baseFee) { this.setState({ baseFee }) clearTimeout(this.baseFeeSubmitTimeout) this.baseFeeSubmitTimeout = setTimeout(() => { @@ -109,18 +109,18 @@ class TxFeeOverlay extends React.Component { const priorityFee = parseFloat(this.state.priorityFee) const gasLimit = parseInt(this.state.gasLimit) const maxTotalFee = maxFee(this.props.req.data) - + if (gweiToWei(baseFee + priorityFee) * gasLimit > maxTotalFee) { baseFee = Math.floor(maxTotalFee / gasLimit / 1e9) - priorityFee } - link.rpc('setBaseFee', gweiToWeiHex(baseFee), this.props.req.handlerId, e => { + link.rpc('setBaseFee', gweiToWeiHex(baseFee), this.props.req.handlerId, (e) => { if (e) console.error(e) }) this.setState({ baseFee: this.toDisplayFromGwei(BigNumber(baseFee)) }) }, 500) } - setPriorityFee (priorityFee) { + setPriorityFee(priorityFee) { this.setState({ priorityFee }) clearTimeout(this.priorityFeeSubmitTimeout) this.priorityFeeSubmitTimeout = setTimeout(() => { @@ -134,16 +134,18 @@ class TxFeeOverlay extends React.Component { if (gweiToWei(baseFee + priorityFee) * gasLimit > maxTotalFee) { priorityFee = Math.floor(maxTotalFee / gasLimit / 1e9) - baseFee } - link.rpc('setPriorityFee', gweiToWeiHex(priorityFee), this.props.req.handlerId, e => { + link.rpc('setPriorityFee', gweiToWeiHex(priorityFee), this.props.req.handlerId, (e) => { if (e) console.error(e) }) - if (this.toDisplayFromGwei(BigNumber(priorityFee)) !== this.toDisplayFromGwei(BigNumber(this.state.priorityFee))) { + if ( + this.toDisplayFromGwei(BigNumber(priorityFee)) !== this.toDisplayFromGwei(BigNumber(this.state.priorityFee)) + ) { this.setState({ priorityFee: this.toDisplayFromGwei(BigNumber(priorityFee)) }) } }, 500) } - setGasPrice (gasPrice) { + setGasPrice(gasPrice) { this.setState({ gasPrice }) clearTimeout(this.gasPriceSubmitTimeout) this.gasPriceSubmitTimeout = setTimeout(() => { @@ -156,14 +158,14 @@ class TxFeeOverlay extends React.Component { if (gweiToWei(gasPrice) * gasLimit > maxTotalFee) { gasPrice = Math.floor(maxTotalFee / gasLimit / 1e9) } - link.rpc('setGasPrice', gweiToWeiHex(gasPrice), this.props.req.handlerId, e => { + link.rpc('setGasPrice', gweiToWeiHex(gasPrice), this.props.req.handlerId, (e) => { if (e) console.error(e) }) this.setState({ gasPrice: this.toDisplayFromGwei(BigNumber(gasPrice)) }) }, 500) } - setGasLimit (gasLimit) { + setGasLimit(gasLimit) { this.setState({ gasLimit }) clearTimeout(this.gasLimitSubmitTimeout) this.gasLimitSubmitTimeout = setTimeout(() => { @@ -186,20 +188,20 @@ class TxFeeOverlay extends React.Component { gasLimit = Math.floor(maxTotalFee / gweiToWei(gasPrice)) } } - link.rpc('setGasLimit', '0x' + gasLimit.toString(16), this.props.req.handlerId, e => { + link.rpc('setGasLimit', '0x' + gasLimit.toString(16), this.props.req.handlerId, (e) => { if (e) console.error(e) }) this.setState({ gasLimit: gasLimit.toString() }) }, 500) } - limitRange (num, min, max) { + limitRange(num, min, max) { if (num > max) return max if (num < min) return min return num } - renderBaseFeeInput () { + renderBaseFeeInput() { return (
@@ -207,7 +209,7 @@ class TxFeeOverlay extends React.Component { tabIndex={0} value={this.state.baseFee} onChange={(e) => { - this.setBaseFee(e.target.value.match('[0-9\.\-]*').toString()) + this.setBaseFee(e.target.value.match('[0-9.-]*').toString()) }} onKeyDown={(e) => { if (e.key === 'Enter') { @@ -236,15 +238,15 @@ class TxFeeOverlay extends React.Component { ) } - renderPriorityFeeInput () { + renderPriorityFeeInput() { return (
- { - this.setPriorityFee(e.target.value.match('[0-9\.\-]*')) + this.setPriorityFee(e.target.value.match('[0-9.-]*')) }} onKeyDown={(e) => { if (e.key === 'Enter') { @@ -273,7 +275,7 @@ class TxFeeOverlay extends React.Component { ) } - renderGasPriceInput () { + renderGasPriceInput() { return (
@@ -281,7 +283,7 @@ class TxFeeOverlay extends React.Component { tabIndex={0} value={this.state.gasPrice} onChange={(e) => { - this.setGasPrice(e.target.value.match('[0-9\.\-]*').toString()) + this.setGasPrice(e.target.value.match('[0-9.-]*').toString()) }} onKeyDown={(e) => { if (e.key === 'Enter') { @@ -310,14 +312,14 @@ class TxFeeOverlay extends React.Component { ) } - renderGasLimitInput () { + renderGasLimitInput() { return (
- { this.setGasLimit(e.target.value.match('[0-9]*')) }} @@ -344,7 +346,7 @@ class TxFeeOverlay extends React.Component { ) } - render () { + render() { const { req, overlayMode } = this.props if (usesBaseFee(req.data)) { // const baseFee = BigNumber(this.state.maxFeePerGas, 16) @@ -356,7 +358,9 @@ class TxFeeOverlay extends React.Component { return (
Adjust Fee
-
overlayMode()}>{svg.octicon('x', { height: 16 })}
+
overlayMode()}> + {svg.octicon('x', { height: 16 })} +
@@ -375,7 +379,9 @@ class TxFeeOverlay extends React.Component { return (
Adjust Fee
-
overlayMode()}>{svg.octicon('x', { height: 16 })}
+
overlayMode()}> + {svg.octicon('x', { height: 16 })} +
diff --git a/app/App/Main/Account/Requests/TransactionRequest/TxOverlay/index.js b/app/App/Main/Account/Requests/TransactionRequest/TxOverlay/index.js index 0415a41a2..3eeee22ce 100644 --- a/app/App/Main/Account/Requests/TransactionRequest/TxOverlay/index.js +++ b/app/App/Main/Account/Requests/TransactionRequest/TxOverlay/index.js @@ -8,15 +8,14 @@ import TxDataOverlay from './TxDataOverlay' import TxFeeOverlay from './TxFeeOverlay' class TxModule extends React.Component { - constructor (props, context) { + constructor(props, context) { super(props, context) this.moduleRef = React.createRef() this.state = { - active: false + active: false, } } - // setActive (active) { // if (!this.props.req || !this.props.req.data || !this.props.req.data.data) return // this.setState({ active }) @@ -32,8 +31,7 @@ class TxModule extends React.Component { // } // } - - render () { + render() { const { overlay } = this.props if (overlay === 'fee') { return diff --git a/app/App/Main/Account/Requests/TransactionRequest/TxRecipient/index.js b/app/App/Main/Account/Requests/TransactionRequest/TxRecipient/index.js index dff7327f1..f2e0286a5 100644 --- a/app/App/Main/Account/Requests/TransactionRequest/TxRecipient/index.js +++ b/app/App/Main/Account/Requests/TransactionRequest/TxRecipient/index.js @@ -6,59 +6,68 @@ import link from '../../../../../../../resources/link' import svg from '../../../../../../../resources/svg' class TxRecipient extends React.Component { - constructor (...args) { + constructor(...args) { super(...args) this.state = { - copied: false + copied: false, } } - copyAddress (data) { + copyAddress(data) { link.send('tray:clipboardData', data) this.setState({ copied: true }) - setTimeout(_ => this.setState({ copied: false }), 1000) + setTimeout((_) => this.setState({ copied: false }), 1000) } - render () { + render() { const req = this.props.req const address = req.data.to ? getAddress(req.data.to) : '' - const ensName = (req.recipient && req.recipient.length < 25) ? req.recipient : '' + const ensName = req.recipient && req.recipient.length < 25 ? req.recipient : '' return (
{address ? (
- {ensName - ? {ensName} - : {address.substring(0, 6)}{svg.octicon('kebab-horizontal', { height: 15 })}{address.substring(address.length - 4)} - } - {req.decodedData && req.decodedData.contractName ? ( - {(() => { - if (req.decodedData.contractName.length > 11) return `${req.decodedData.contractName.substr(0, 9)}..` - return req.decodedData.contractName - })()} + {ensName ? ( + {ensName} + ) : ( + + {address.substring(0, 6)} + {svg.octicon('kebab-horizontal', { height: 15 })} + {address.substring(address.length - 4)} + + )} + {req.decodedData && req.decodedData.contractName ? ( + + {(() => { + if (req.decodedData.contractName.length > 11) + return `${req.decodedData.contractName.substr(0, 9)}..` + return req.decodedData.contractName + })()} + ) : null} -
{ - this.copyAddress(address) - }}> +
{ + this.copyAddress(address) + }} + > {this.state.copied ? 'Address Copied' : address}
) : ( -
- Deploying Contract -
+
Deploying Contract
)} -
- Recipient -
+
Recipient
) } } -{/*
+{ + /*
{this.state.copied ? {'Copied'}{svg.octicon('clippy', { height: 14 })} : req.data.to} -
*/} +
*/ +} export default Restore.connect(TxRecipient) diff --git a/app/App/Main/Account/Requests/TransactionRequest/index.js b/app/App/Main/Account/Requests/TransactionRequest/index.js index 4bb4646d4..c3badcf50 100644 --- a/app/App/Main/Account/Requests/TransactionRequest/index.js +++ b/app/App/Main/Account/Requests/TransactionRequest/index.js @@ -25,17 +25,17 @@ import TxApproval from './TxApproval' const FEE_WARNING_THRESHOLD_USD = 50 class Time extends React.Component { - constructor (...args) { + constructor(...args) { super(...args) this.state = { - time: Date.now() + time: Date.now(), } setInterval(() => { this.setState({ time: Date.now() }) }, 1000) } - msToTime (duration) { + msToTime(duration) { const seconds = Math.floor((duration / 1000) % 60) const minutes = Math.floor((duration / (1000 * 60)) % 60) const hours = Math.floor((duration / (1000 * 60 * 60)) % 24) @@ -53,27 +53,23 @@ class Time extends React.Component { return { time, label } } - render () { + render() { const { time, label } = this.msToTime(this.state.time - this.props.time) return (
-
- {time} -
-
- {label} -
+
{time}
+
{label}
) } } class TransactionRequest extends React.Component { - constructor (props, context) { + constructor(props, context) { super(props, context) - this.chain = { - type: 'ethereum', - id: parseInt(props.req.data.chainId, 'hex') + this.chain = { + type: 'ethereum', + id: parseInt(props.req.data.chainId, 'hex'), } this.state = { allowInput: false, dataView: false } @@ -82,29 +78,29 @@ class TransactionRequest extends React.Component { }, props.signingDelay || 1500) } - copyAddress (data) { + copyAddress(data) { link.send('tray:clipboardData', data) this.setState({ copied: true }) - setTimeout(_ => this.setState({ copied: false }), 1000) + setTimeout((_) => this.setState({ copied: false }), 1000) } - approve (reqId, req) { + approve(reqId, req) { link.rpc('approveRequest', req, () => {}) // Move to link.send } - decline (req) { + decline(req) { link.rpc('declineRequest', req, () => {}) // Move to link.send } - toggleDataView (id) { + toggleDataView(id) { this.setState({ dataView: !this.state.dataView }) } - hexToDisplayValue (hex) { + hexToDisplayValue(hex) { return (Math.round(parseFloat(utils.fromWei(hex, 'ether')) * 1000000) / 1000000).toFixed(6) } - txSectionStyle (index, height) { + txSectionStyle(index, height) { if (this.state.selectedIndex === index) { return { transform: `translateY(${0}px)`, @@ -114,35 +110,35 @@ class TransactionRequest extends React.Component { background: 'rgba(237, 242, 253, 1)', left: '10px', right: '10px', - padding: '0px 30px' + padding: '0px 30px', } } else { return { - transform: `translateY(${(index * -40) - 60}px)`, - zIndex: 1 + transform: `translateY(${index * -40 - 60}px)`, + zIndex: 1, } } } - copyData (data) { + copyData(data) { link.send('tray:clipboardData', data) this.setState({ copiedData: true }) - setTimeout(_ => this.setState({ copiedData: false }), 1000) + setTimeout((_) => this.setState({ copiedData: false }), 1000) } - overlayMode (mode) { + overlayMode(mode) { this.setState({ overlayMode: mode }) } - toDisplayUSD (bn) { + toDisplayUSD(bn) { return bn.toFixed(2, BigNumber.ROUND_UP).toString() } - allowOtherChain () { + allowOtherChain() { this.setState({ allowOtherChain: true }) } - render () { + render() { const { accountId, handlerId } = this.props const req = this.store('main.accounts', accountId, 'requests', handlerId) const originalNotice = (req.notice || '').toLowerCase() @@ -153,7 +149,7 @@ class TransactionRequest extends React.Component { const toAddress = req.data && req.data.to ? getAddress(req.data.to) : '' let requestClass = 'signerRequest' if (mode === 'monitor') requestClass += ' signerRequestMonitor' - const success = (req.status === 'confirming' || req.status === 'confirmed') + const success = req.status === 'confirming' || req.status === 'confirmed' const error = req.status === 'error' || req.status === 'declined' if (success) requestClass += ' signerRequestSuccess' if (req.status === 'confirmed') requestClass += ' signerRequestConfirmed' @@ -197,10 +193,10 @@ class TransactionRequest extends React.Component { // } if (mode !== 'monitor' && req.data.nonce) { const r = this.store('main.accounts', this.props.accountId, 'requests') - const requests = Object.keys(r || {}).map(key => r[key]) - const monitor = requests.filter(req => req.mode === 'monitor') - const monitorFilter = monitor.filter(r => r.status !== 'error') - const existingNonces = monitorFilter.map(m => m.data.nonce) + const requests = Object.keys(r || {}).map((key) => r[key]) + const monitor = requests.filter((req) => req.mode === 'monitor') + const monitorFilter = monitor.filter((r) => r.status !== 'error') + const existingNonces = monitorFilter.map((m) => m.data.nonce) existingNonces.forEach((nonce, i) => { if (req.data.nonce === nonce) { txMeta.replacement = true @@ -214,11 +210,13 @@ class TransactionRequest extends React.Component { txMeta.possible = false txMeta.notice = 'gas price too low' } else if ( - req.data.maxPriorityFeePerGas && - req.data.maxFeePerGas && - Math.ceil(parseInt(monitorFilter[i].data.maxPriorityFeePerGas, 'hex') * 1.1) > parseInt(req.data.maxPriorityFeePerGas, 'hex') && - Math.ceil(parseInt(monitorFilter[i].data.maxFeePerGas, 'hex') * 1.1) > parseInt(req.data.maxFeePerGas, 'hex') - ) { + req.data.maxPriorityFeePerGas && + req.data.maxFeePerGas && + Math.ceil(parseInt(monitorFilter[i].data.maxPriorityFeePerGas, 'hex') * 1.1) > + parseInt(req.data.maxPriorityFeePerGas, 'hex') && + Math.ceil(parseInt(monitorFilter[i].data.maxFeePerGas, 'hex') * 1.1) > + parseInt(req.data.maxFeePerGas, 'hex') + ) { txMeta.possible = false txMeta.notice = 'gas fees too low' } @@ -246,20 +244,21 @@ class TransactionRequest extends React.Component { } const hexId = '0x' + parseInt(this.chain.id).toString('16') - const chainName = this.store('main.networks.ethereum', this.chain.id, 'name') + const chainName = this.store('main.networks.ethereum', this.chain.id, 'name') const showWarning = !status && mode !== 'monitor' - const requiredApproval = showWarning && (req.approvals || []).filter(a => !a.approved)[0] + const requiredApproval = showWarning && (req.approvals || []).filter((a) => !a.approved)[0] return (
- + {req.type === 'transaction' ? (
{!!requiredApproval ? ( + allowOtherChain={this.allowOtherChain.bind(this)} + /> ) : null}
{notice ? ( @@ -268,9 +267,7 @@ class TransactionRequest extends React.Component { {!error ? (
{this.state.txHashCopied ? ( -
- Transaction Hash Copied -
+
Transaction Hash Copied
) : this.state.viewDetailsHover ? (
{ clearTimeout(this.viewDetailsHoverTimer) this.setState({ viewDetailsHover: true }) @@ -329,10 +331,16 @@ class TransactionRequest extends React.Component { > View Details
-
link.send('tray:replaceTx', req.handlerId, 'cancel')}> +
link.send('tray:replaceTx', req.handlerId, 'cancel')} + > Cancel
-
link.send('tray:replaceTx', req.handlerId, 'speed')}> +
link.send('tray:replaceTx', req.handlerId, 'speed')} + > Speed Up
@@ -348,18 +356,14 @@ class TransactionRequest extends React.Component { {req && req.tx && req.tx.receipt ? ( <>
-
- In Block -
+
In Block
{parseInt(req.tx.receipt.blockNumber, 'hex')}