Skip to content

Commit 6c1a219

Browse files
authored
Merge pull request #33 from XYOracleNetwork/master
v0.2.7 release
2 parents b9cb7b2 + aa83dee commit 6c1a219

20 files changed

Lines changed: 978 additions & 784 deletions

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@xyo-network/tool-dapper-react",
3-
"version": "0.2.5",
3+
"version": "0.2.7",
44
"description": "An automated smart contract web viewer. Run on any ABI folder",
55
"repository": {
66
"type": "git",
@@ -29,7 +29,7 @@
2929
"history": "^4.7.2",
3030
"ipfs-http-client": "^27.0.0",
3131
"json-loader": "^0.5.7",
32-
"portis": "^1.2.12",
32+
"portis": "^1.3.1",
3333
"react": "^16.6.1",
3434
"react-cookie": "^3.0.4",
3535
"react-dom": "^16.6.1",

src/atoms/ContractAddressDropdown.js

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { withRouter } from "react-router-dom"
44
import Dropdown from "react-dropdown"
55
import "react-dropdown/style.css"
66
import "./css/SmartContractSelector.css"
7+
import ProgressButton, { STATE } from "react-progress-button"
8+
import { withCookies } from "react-cookie"
79

810
const GreyTopped = glam.div({
911
paddingTop: 10,
@@ -14,11 +16,13 @@ class ContractAddressDropdown extends Component {
1416
state = {
1517
selectedNotes: this.props.selectedNotes,
1618
selectedAddress: this.props.selectedAddress,
19+
connectButtonState: STATE.NOTHING,
1720
}
1821

1922
_onSelect = selection => {
2023
console.log(`Detected Selection`)
21-
let contractObjects = this.props.fetchObjects()
24+
let {contractObjects} = this.props
25+
// let contractObjects = this.props.fetchObjects()
2226
contractObjects.forEach(obj => {
2327
if (obj.address === selection.value || obj.notes === selection.value) {
2428
this.props.onSelect({ notes: obj.notes, address: obj.address })
@@ -43,11 +47,34 @@ class ContractAddressDropdown extends Component {
4347
return null
4448
}
4549

46-
dropdownDiv = () => {
47-
let contractObjects = this.props.fetchObjects()
50+
connectProvider = async () =>
51+
this.props.service
52+
.loadWeb3(this.props.cookies)
53+
.then(this.setState({ connectButtonState: STATE.SUCCESS }))
54+
4855

56+
dropdownDiv = () => {
57+
// let contractObjects = this.props.fetchObjects()
58+
let { contractObjects } = this.props
59+
console.log(`RENDERING ADDRESS DROPDOWN WITH OBJ`, contractObjects)
60+
let network = this.props.service.getCurrentNetwork()
61+
if (!network) {
62+
return (
63+
<ProgressButton
64+
style={{
65+
width: 260,
66+
marginTop: 10,
67+
color: `white`,
68+
}}
69+
state={this.state.connectButtonState}
70+
onClick={this.connectProvider}
71+
>
72+
Connect Wallet
73+
</ProgressButton>
74+
)
75+
}
4976
if (!contractObjects || contractObjects.length === 0) {
50-
return <GreyTopped>No Contracts Deployed</GreyTopped>
77+
return <GreyTopped>Not deployed on {network}</GreyTopped>
5178
}
5279
return (
5380
<Div>
@@ -67,6 +94,7 @@ class ContractAddressDropdown extends Component {
6794
}
6895
placeholder='Nothing Selected'
6996
/>
97+
{this.showSelectedDiv()}
7098
</Div>
7199
)
72100
}
@@ -86,10 +114,9 @@ class ContractAddressDropdown extends Component {
86114
}}
87115
>
88116
{this.dropdownDiv()}
89-
{this.showSelectedDiv()}
90117
</Div>
91118
)
92119
}
93120
}
94121

95-
export default withRouter(ContractAddressDropdown)
122+
export default withCookies(withRouter(ContractAddressDropdown))

src/atoms/CookieReader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export const readSettings = cookies => {
33

44
return {
55
portisNetwork: cookies.get(`portisNetwork`) || `development`,
6-
currentSource: cookies.get(`currentSource`) || `local`,
6+
currentSource: cookies.get(`currentSource`) || `ipfs`,
77
local: cookies.get(`local`) || ``,
88
remote: cookies.get(`remote`) || ``,
99
ipfs: cookies.get(`ipfs`) || ``,

src/atoms/CurNetwork.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
import React from "react"
22
import { Div } from "glamorous"
33

4+
const WalletDiv = (account) => {
5+
if (account) {
6+
return (
7+
<Div key='account' className='account-right'>
8+
Wallet: {account}
9+
</Div>
10+
)
11+
}
12+
return <Div key='account' className='account-right'>
13+
No Wallet Connected
14+
</Div>
15+
}
16+
417
const CurNetwork = ({ account, network }) => {
518
let returnDivs = []
619

7-
returnDivs.push(
8-
<Div key='account' className='account-right'>
9-
Wallet: {account ? account : `None Found`}
10-
</Div>,
11-
)
20+
returnDivs.push(WalletDiv(account))
1221
if (network) {
1322
returnDivs.push(
1423
<Div key='network' className='network-right'>

src/atoms/DetailsHeader.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
import glam from 'glamorous'
1+
import glam from "glamorous"
22

33
export const DetailsHeader = glam.div({
4-
display: 'flex',
5-
flexDirection: 'column',
6-
justifyContent: 'center',
4+
display: `flex`,
5+
flexDirection: `column`,
6+
justifyContent: `center`,
77
height: 78,
88
paddingLeft: 24,
9-
fontSize: '25px',
9+
fontSize: `25px`,
10+
})
11+
12+
export const DetailsHeader2 = glam.div({
13+
display: `flex`,
14+
flexDirection: `column`,
15+
justifyContent: `center`,
16+
height: 78,
17+
paddingLeft: 24,
18+
fontSize: 19,
19+
marginLeft: 10,
1020
})

src/molecules/DeployToNetwork.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/molecules/DroppedFileDiv.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import React, { Component } from "react"
2+
import uploadIPFS from "../organisms/IPFSUploader"
3+
import ProgressButton, { STATE } from "react-progress-button"
4+
import { withCookies } from "react-cookie"
5+
import { Div } from "glamorous"
6+
7+
class DroppedFileDiv extends Component {
8+
state = {
9+
uploadBtnState: STATE.NOTHING,
10+
}
11+
12+
handleClick = async () => {
13+
console.log(`Data submitted`)
14+
this.setState({ uploadBtnState: STATE.LOADING })
15+
let data = []
16+
let { files } = this.props
17+
18+
let promises = []
19+
files.forEach(file => {
20+
const reader = new FileReader()
21+
promises.push(
22+
new Promise((resolve, reject) => {
23+
reader.onload = () => {
24+
const fileBuf = new Buffer(reader.result)
25+
data.push({ path: file.name, content: fileBuf })
26+
resolve(true)
27+
}
28+
reader.onabort = () => reject(`file reading was aborted`)
29+
30+
reader.onerror = () => reject(`file reading has failed`)
31+
32+
reader.readAsBinaryString(file)
33+
}),
34+
)
35+
})
36+
37+
return Promise.all(promises)
38+
.then(async () => {
39+
return uploadIPFS(this.props.cookies, data)
40+
})
41+
.then(ipfsHash => {
42+
return this.props.onSave(ipfsHash)
43+
})
44+
.then(() => {
45+
console.log(`WTFFFF`)
46+
this.setState({ uploadBtnState: STATE.SUCCESS })
47+
})
48+
}
49+
50+
render() {
51+
let { files } = this.props
52+
if (files.length > 0) {
53+
return (
54+
<Div style={{ textAlign: `left` }}>
55+
<h2>Dropped files and folders</h2>
56+
<ul>
57+
{files.map(f => (
58+
<li key={f.name}>
59+
{f.path} - {f.size} bytes
60+
</li>
61+
))}
62+
</ul>
63+
<ProgressButton
64+
state={this.state.uploadBtnState}
65+
onClick={this.handleClick}
66+
>
67+
Upload Contracts
68+
</ProgressButton>
69+
</Div>
70+
)
71+
}
72+
return null
73+
}
74+
}
75+
76+
export default withCookies(DroppedFileDiv)

src/molecules/IPFSConfigDiv.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import React, { Component } from "react"
2+
import { SettingsInput, RowLayout, InputText } from "./SettingsComponenets"
3+
import { withCookies } from "react-cookie"
4+
import { ipfsConfigFromCookies } from "../organisms/IPFSUploader"
5+
6+
class IPFSConfigDiv extends Component {
7+
constructor(props) {
8+
super(props)
9+
this.state = ipfsConfigFromCookies(props.cookies)
10+
}
11+
handleChange = changeEvent => {
12+
this.stateChange(changeEvent.target.name, changeEvent.target.value)
13+
}
14+
stateChange = (stateKey, stateValue) => {
15+
console.log(`attempting State Change`, stateKey, stateValue)
16+
this.props.cookies.set(stateKey, stateValue, {
17+
path: `/`,
18+
})
19+
const newState = this.state
20+
newState[stateKey] = stateValue
21+
22+
this.setState(newState)
23+
}
24+
render() {
25+
return (
26+
<RowLayout>
27+
<InputText>Host</InputText>
28+
<SettingsInput
29+
type='text'
30+
value={this.state.ipfshost}
31+
name={`ipfshost`}
32+
placeholder={`127.0.0.1`}
33+
onChange={this.handleChange}
34+
onSelect={this.handleSourceSelect}
35+
/>
36+
<InputText>Port</InputText>
37+
38+
<SettingsInput
39+
type='text'
40+
value={this.state.ipfsport}
41+
name={`ipfsport`}
42+
placeholder={`5002`}
43+
onChange={this.handleChange}
44+
onSelect={this.handleSourceSelect}
45+
/>
46+
<InputText>Protocol</InputText>
47+
48+
<SettingsInput
49+
type='text'
50+
value={this.state.ipfsprotocol}
51+
name={`ipfsprotocol`}
52+
placeholder={`https`}
53+
onChange={this.handleChange}
54+
onSelect={this.handleSourceSelect}
55+
/>
56+
</RowLayout>
57+
)
58+
}
59+
}
60+
61+
export default withCookies(IPFSConfigDiv)

src/molecules/PageHeader.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react"
22
import glam, { Div, Img } from "glamorous"
33
import CurNetwork from "../atoms/CurNetwork"
44
import logo from "../assets/dapper-logo.svg"
5+
const version = require(`../../package.json`).version
56

67
const HeaderDiv = glam.div({
78
display: `flex`,
@@ -25,7 +26,7 @@ class PageHeader extends React.Component {
2526
target='_blank'
2627
rel='noopener noreferrer'
2728
>
28-
View on Github
29+
View on Github - {version}
2930
</a>
3031
<CurNetwork
3132
account={this.props.service.getCurrentUser()}
@@ -37,4 +38,4 @@ class PageHeader extends React.Component {
3738
}
3839
}
3940

40-
export default PageHeader
41+
export default PageHeader
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import glam from "glamorous"
2+
3+
export const SettingsInput = glam.input({
4+
marginLeft: 10,
5+
marginRight: 10,
6+
paddingLeft: 12,
7+
border: `1px solid #E0E0E0`,
8+
borderRadius: `6px`,
9+
backgroundColor: `#F6F6F6`,
10+
height: 30,
11+
})
12+
13+
export const RowLayout = glam.div({
14+
display: `flex`,
15+
flexDirection: `row`,
16+
paddingRight: 20,
17+
marginBottom: 40,
18+
marginLeft: 40,
19+
})
20+
export const InputText = glam.div({
21+
display: `inline`,
22+
marginTop: `10`,
23+
minWidth: `fit-content`,
24+
})
25+
export const CenterColumn = glam.div({
26+
lineHeight: 1,
27+
flex: 1,
28+
maxWidth: 360,
29+
})
30+
export const SettingsLayout = glam.div({
31+
color: `#4D4D5C`,
32+
fontFamily: `PT Sans`,
33+
flex: 1,
34+
marginRight: 60,
35+
})

0 commit comments

Comments
 (0)