-
-
Notifications
You must be signed in to change notification settings - Fork 650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Contracts Tab UI #277
Merged
Merged
Contracts Tab UI #277
Changes from 78 commits
Commits
Show all changes
86 commits
Select commit
Hold shift + click to select a range
259fe34
Refactor BaseNode to be an interface INode
bcebd74
Initial contract commit
718c54e
Merge develop
753aa00
Remove redundant fallback ABI function
f6b85c1
First working iteration of Contract generator to be used in ENS branch
3e0d0a1
Hide abi to clean up logging output
1b16b13
Strip 0x prefix from output decode
40579f8
Handle unnamed output params
f577768
Merge branch 'develop' of https://github.com/MyEtherWallet/MyEtherWal…
35d3d29
Implement ability to supply output mappings to ABI functions
aa079bf
Fix null case in outputMapping
d37c41a
Merge branch 'develop' of https://github.com/MyEtherWallet/MyEtherWal…
760a166
Add flow typing
1831172
Add .call method to functions
aa5c5a9
Merge branch 'develop' of https://github.com/MyEtherWallet/MyEtherWal…
baae972
Merge branch 'develop' of https://github.com/MyEtherWallet/MyEtherWal…
9c117c5
Merge branch 'develop' of https://github.com/MyEtherWallet/MyEtherWal…
e0e8590
Partial commit for type refactor
cad65d2
Merge branch 'develop' of https://github.com/MyEtherWallet/MyEtherWal…
4cf4951
Temp contract type fix -- waiting for NPM modularization
70cba3a
Misc. Optimizations to tsconfig + webpack
12321b1
Convert Contracts to TS
ec94c90
Remove nested prop passing from contracts, get rid of contract reduce…
7e6ffb3
Merge branch 'contract-refactor' of https://github.com/MyEtherWallet/…
9ea3884
Add disclaimer modal to footer
6f2bd19
Merge branch 'develop' into update-disclaimer
james-prado e2d9bf4
Merge router upgrade
60db6b4
Remove duplicate code & unnecessary styles
d52ce10
Add contracts to nav
d00a761
Wrap Contracts in App
05fc28f
Add ether/hex validation override for contract creation calls
d320c5e
First iteration of working deploy contract
4cf0b44
Delete routing file that shouldnt exist
93ce173
Revert "Misc. Optimizations to tsconfig + webpack"
4d95eb2
Merge branch 'develop' of https://github.com/MyEtherWallet/MyEtherWal…
4d9efbe
Cleanup HOC code
2aa4942
Fix formatting noise
88f6bd1
Merge branch 'update-disclaimer' of https://github.com/james-prado/My…
b9f5244
remove un-used css style
4e4691e
Remove deterministic contract address computation
5f4c3ba
Remove empty files
8f014a5
Merge branch 'develop' of https://github.com/MyEtherWallet/MyEtherWal…
ec08893
Cleanup contract
8fd9a77
Add call request to node interface
f8ea4ca
Fix output mapping types
f8c097a
Revert destructuring overboard
3f0cc16
Add sendCallRequest to rpcNode class and add typing
e7700ae
Use enum for selecting ABI methods
c2409fd
Merge branch 'contract-refactor' of https://github.com/MyEtherWallet/…
099cd0e
Fix tslint error & add media query for modals
46af5cf
Nest Media Query
244b4c0
Merge branch 'develop' into update-disclaimer
james-prado 141ebec
Merge pull request #243 from james-prado/update-disclaimer
james-prado 7ccc6c6
Merge branch 'develop' of https://github.com/MyEtherWallet/MyEtherWal…
d991711
Merge branch 'develop' of https://github.com/MyEtherWallet/MyEtherWal…
c2c6e6b
Fix contracts to include new router fixes
24cf4f4
Add transaction capability to contracts
6556b21
Get ABI parsing + contract calls almost fully integrated using dynami…
9cfe43c
Refactor contract deploy to have a reusable HOC for contract interact
8a9b93c
Move modal and tx comparasion up file tree
544a2d2
Include ABI outputs in display
8c55017
Cleanup privaite/public members
9b9d5b1
Remove broadcasting step from a contract transaction
786a945
Update TX contract components to inter-op with interact and deploy
00dda7a
Finish contracts-interact functionality
0cda5c5
Add transaction capability to contracts
9131df1
Cleanup privaite/public members
7b115d3
Remove broadcasting step from a contract transaction
1d5f163
Merge branch 'develop' of https://github.com/MyEtherWallet/MyEtherWal…
15fee4f
Merge branch 'develop' of https://github.com/MyEtherWallet/MyEtherWal…
7594fad
Apply James's CSS fix
cf47730
Cleanup uneeded types
b53cffe
Merge contracts-refactor
038415d
Merge branch 'develop' of https://github.com/MyEtherWallet/MyEtherWal…
5e23a3c
Merge branch 'contracts-tab-interact' of https://github.com/MyEtherWa…
533cfcc
Remove unecessary class
d134e04
Add UI side validation and helper utils, addresess PR comments
2b1e9a3
Merge branch 'contracts-tab-interact' of https://github.com/MyEtherWa…
bfa6eb6
Fix spacing + remove unused imports / types
c5f29df
Merge branch 'develop' of https://github.com/MyEtherWallet/MyEtherWal…
9ba1fd2
Fix spacing + remove unused imports / types
6c767e6
Address PR comments
6819dc8
Actually address PR comments
254b0f1
Actually address PR comments
afa87ac
Merge conflicts
8b0f03a
Merge branch 'develop' of https://github.com/MyEtherWallet/MyEtherWal…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
pre { | ||
color: #333; | ||
background-color: #fafafa; | ||
border: 1px solid #ececec; | ||
border-radius: 0px; | ||
padding: 8px; | ||
code { | ||
font-size: 14px; | ||
line-height: 20px; | ||
word-break: break-all; | ||
word-wrap: break-word; | ||
white-space: pre; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React, { Component } from 'react'; | ||
import './Code.scss'; | ||
|
||
const Code = ({ children }) => ( | ||
<pre> | ||
<code>{children}</code> | ||
</pre> | ||
); | ||
|
||
export default Code; |
154 changes: 154 additions & 0 deletions
154
common/containers/Tabs/Contracts/components/Deploy/components/DeployHoc/index.tsx
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 |
---|---|---|
@@ -0,0 +1,154 @@ | ||
import Big from 'bignumber.js'; | ||
import React, { Component } from 'react'; | ||
import { | ||
generateCompleteTransaction as makeAndSignTx, | ||
TransactionInput | ||
} from 'libs/transaction'; | ||
import { Props, State, initialState } from './types'; | ||
import { TxModal, Props as DMProps, TTxModal } from '../../../TxModal'; | ||
import { TxCompare, Props as TCProps, TTxCompare } from '../../../TxCompare'; | ||
import { withTx } from '../../../withTx'; | ||
import { Props as DProps } from '../../'; | ||
|
||
export const deployHOC = PassedComponent => { | ||
class WrappedComponent extends Component<Props, State> { | ||
public state: State = initialState; | ||
|
||
public asyncSetState = value => | ||
new Promise(resolve => this.setState(value, resolve)); | ||
|
||
public resetState = () => this.setState(initialState); | ||
|
||
public handleSignTx = async () => { | ||
const { props, state } = this; | ||
|
||
if (state.data === '') { | ||
return; | ||
} | ||
|
||
try { | ||
await this.getAddressAndNonce(); | ||
await this.makeSignedTxFromState(); | ||
} catch (e) { | ||
props.showNotification( | ||
'danger', | ||
e.message || 'Error during contract tx generation', | ||
5000 | ||
); | ||
|
||
return this.resetState(); | ||
} | ||
}; | ||
|
||
public handleInput = inputName => ( | ||
ev: React.FormEvent<HTMLTextAreaElement | HTMLInputElement> | ||
): void => { | ||
if (this.state.signedTx) { | ||
this.resetState(); | ||
} | ||
|
||
this.setState({ | ||
[inputName]: ev.currentTarget.value | ||
}); | ||
}; | ||
|
||
public handleDeploy = () => this.setState({ displayModal: true }); | ||
|
||
public render() { | ||
const { data: byteCode, gasLimit, signedTx, displayModal } = this.state; | ||
|
||
const props: DProps = { | ||
handleInput: this.handleInput, | ||
handleSignTx: this.handleSignTx, | ||
handleDeploy: this.handleDeploy, | ||
byteCode, | ||
gasLimit, | ||
displayModal, | ||
walletExists: !!this.props.wallet, | ||
txCompare: signedTx ? this.displayCompareTx() : null, | ||
deployModal: signedTx ? this.displayDeployModal() : null | ||
}; | ||
|
||
return <PassedComponent {...props} />; | ||
} | ||
|
||
private displayCompareTx = (): React.ReactElement<TTxCompare> => { | ||
const { nonce, gasLimit, data, value, signedTx, to } = this.state; | ||
const { gasPrice, chainId } = this.props; | ||
|
||
if (!nonce || !signedTx) { | ||
throw Error('Can not display raw tx, nonce empty or no signed tx'); | ||
} | ||
|
||
const props: TCProps = { | ||
nonce, | ||
gasPrice, | ||
chainId, | ||
data, | ||
gasLimit, | ||
to, | ||
value, | ||
signedTx | ||
}; | ||
|
||
return <TxCompare {...props} />; | ||
}; | ||
|
||
private displayDeployModal = (): React.ReactElement<TTxModal> => { | ||
const { networkName, node: { network, service } } = this.props; | ||
const { signedTx } = this.state; | ||
|
||
if (!signedTx) { | ||
throw Error('Can not deploy contract, no signed tx'); | ||
} | ||
|
||
const props: DMProps = { | ||
action: 'deploy a contract', | ||
networkName, | ||
network, | ||
service, | ||
handleBroadcastTx: this.handleBroadcastTx, | ||
onClose: this.resetState | ||
}; | ||
|
||
return <TxModal {...props} />; | ||
}; | ||
|
||
private handleBroadcastTx = () => { | ||
if (!this.state.signedTx) { | ||
throw Error('Can not broadcast tx, signed tx does not exist'); | ||
} | ||
this.props.broadcastTx(this.state.signedTx); | ||
this.resetState(); | ||
}; | ||
|
||
private makeSignedTxFromState = () => { | ||
const { props, state: { data, gasLimit, value, to } } = this; | ||
const transactionInput: TransactionInput = { | ||
unit: 'ether', | ||
to, | ||
data, | ||
value | ||
}; | ||
|
||
return makeAndSignTx( | ||
props.wallet, | ||
props.nodeLib, | ||
props.gasPrice, | ||
new Big(gasLimit), | ||
props.chainId, | ||
transactionInput, | ||
true | ||
).then(({ signedTx }) => this.asyncSetState({ signedTx })); | ||
}; | ||
|
||
private getAddressAndNonce = async () => { | ||
const address = await this.props.wallet.getAddress(); | ||
const nonce = await this.props.nodeLib | ||
.getTransactionCount(address) | ||
.then(n => new Big(n).toString()); | ||
return this.asyncSetState({ nonce, address }); | ||
}; | ||
} | ||
return withTx(WrappedComponent); | ||
}; |
42 changes: 42 additions & 0 deletions
42
common/containers/Tabs/Contracts/components/Deploy/components/DeployHoc/types.ts
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Wei, Ether } from 'libs/units'; | ||
import { IWallet } from 'libs/wallet/IWallet'; | ||
import { RPCNode } from 'libs/nodes'; | ||
import { NodeConfig, NetworkConfig } from 'config/data'; | ||
import { TBroadcastTx } from 'actions/wallet'; | ||
import { TShowNotification } from 'actions/notifications'; | ||
|
||
export interface Props { | ||
wallet: IWallet; | ||
balance: Ether; | ||
node: NodeConfig; | ||
nodeLib: RPCNode; | ||
chainId: NetworkConfig['chainId']; | ||
networkName: NetworkConfig['name']; | ||
gasPrice: Wei; | ||
broadcastTx: TBroadcastTx; | ||
showNotification: TShowNotification; | ||
} | ||
|
||
export interface State { | ||
data: string; | ||
gasLimit: string; | ||
determinedContractAddress: string; | ||
signedTx: null | string; | ||
nonce: null | string; | ||
address: null | string; | ||
value: string; | ||
to: string; | ||
displayModal: boolean; | ||
} | ||
|
||
export const initialState: State = { | ||
data: '', | ||
gasLimit: '300000', | ||
determinedContractAddress: '', | ||
signedTx: null, | ||
nonce: null, | ||
address: null, | ||
to: '0x', | ||
value: '0x0', | ||
displayModal: false | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer path from
common
.