-
-
Notifications
You must be signed in to change notification settings - Fork 650
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Progress commit -- ethereumjs-wallet typings * Add hdkey module + better wallet typing * Add provider-engine typings * Add jsdoc descriptions for hdkey constructor methods * Fix missing return type * Fix another missing return * Make provider engine options optional * Add priv/pubkey members to wallet instance * Turn into SFC + Use ethereumjs-lib * Use proper interface naming for V3Wallet * Switch to ethereumjs-wallet * Switch to ethereumjs-wallet and refactor using NewTabLink * Use proper interface naming for V3Wallet * Use proper interface naming for PublicKeyOnlyWallet * Fix broken test, re-add scryptsy to make this PR pass * Fix definition module for thirdparty wallets * Decrease n-factor to 1024, checksum address of keystore * Update typedef for react-dom from 15 to 16 * Lock react-dom, set typescript to 2.5.2
- Loading branch information
Showing
12 changed files
with
3,308 additions
and
3,777 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,53 @@ | ||
import { PaperWallet } from 'components'; | ||
import PrivKeyWallet from 'libs/wallet/privkey'; | ||
import React, { Component } from 'react'; | ||
import { IFullWallet } from 'ethereumjs-wallet'; | ||
import React from 'react'; | ||
import translate from 'translations'; | ||
import printElement from 'utils/printElement'; | ||
|
||
interface Props { | ||
wallet: PrivKeyWallet; | ||
} | ||
|
||
interface State { | ||
address: string | null; | ||
privateKey: string | null; | ||
} | ||
|
||
const initialState = { | ||
address: null, | ||
privateKey: null | ||
}; | ||
|
||
export default class PrintableWallet extends Component<Props, {}> { | ||
public state: State = initialState; | ||
|
||
public async componentDidMount() { | ||
const address = await this.props.wallet.getAddress(); | ||
const privateKey = this.props.wallet.getPrivateKey(); | ||
this.setState({ address, privateKey }); | ||
const print = (address: string, privateKey: string) => () => | ||
address && | ||
privateKey && | ||
printElement(<PaperWallet address={address} privateKey={privateKey} />, { | ||
popupFeatures: { | ||
scrollbars: 'no' | ||
}, | ||
styles: ` | ||
* { | ||
box-sizing: border-box; | ||
} | ||
body { | ||
font-family: Lato, sans-serif; | ||
font-size: 1rem; | ||
line-height: 1.4; | ||
margin: 0; | ||
} | ||
` | ||
}); | ||
|
||
const PrintableWallet: React.SFC<{ wallet: IFullWallet }> = ({ wallet }) => { | ||
const address = wallet.getAddressString(); | ||
const privateKey = wallet.getPrivateKeyString(); | ||
|
||
if (!address || !privateKey) { | ||
return null; | ||
} | ||
|
||
public print = () => { | ||
const { address, privateKey } = this.state; | ||
if (address && privateKey) { | ||
printElement(<PaperWallet address={address} privateKey={privateKey} />, { | ||
popupFeatures: { | ||
scrollbars: 'no' | ||
}, | ||
styles: ` | ||
* { | ||
box-sizing: border-box; | ||
} | ||
body { | ||
font-family: Lato, sans-serif; | ||
font-size: 1rem; | ||
line-height: 1.4; | ||
margin: 0; | ||
} | ||
` | ||
}); | ||
} | ||
}; | ||
return ( | ||
<div> | ||
<PaperWallet address={address} privateKey={privateKey} /> | ||
<a | ||
role="button" | ||
aria-label={translate('x_Print')} | ||
aria-describedby="x_PrintDesc" | ||
className={'btn btn-lg btn-primary'} | ||
onClick={print(address, privateKey)} | ||
style={{ marginTop: 10 }} | ||
> | ||
{translate('x_Print')} | ||
</a> | ||
</div> | ||
); | ||
}; | ||
|
||
public render() { | ||
const { address, privateKey } = this.state; | ||
return address && privateKey ? ( | ||
<div> | ||
<PaperWallet address={address} privateKey={privateKey} /> | ||
<a | ||
role="button" | ||
aria-label={translate('x_Print')} | ||
aria-describedby="x_PrintDesc" | ||
className={'btn btn-lg btn-primary'} | ||
onClick={this.print} | ||
style={{ marginTop: 10 }} | ||
> | ||
{translate('x_Print')} | ||
</a> | ||
</div> | ||
) : null; | ||
} | ||
} | ||
export default PrintableWallet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.