@@ -20,6 +20,15 @@ import {
21} from '../lib/wallet'
21} from '../lib/wallet'
23+const setFind = (set, pred) => {
24+ for (const e of set) {
23class IssueChild extends React.Component {
32class IssueChild extends React.Component {
24 constructor(props) {
33 constructor(props) {
25 super(props)
34 super(props)
@@ -46,11 +55,12 @@ class IssueChild extends React.Component {
46 desiredPoint: '',
55 desiredPoint: '',
47 isAvailable: Nothing(), // use Nothing to allow attempt when offline
56 isAvailable: Nothing(), // use Nothing to allow attempt when offline
48 suggestions: suggestions,
57 suggestions: suggestions,
58+ validChildren: new Set(),
51 this.handlePointInput = this.handlePointInput.bind(this)
62 this.handlePointInput = this.handlePointInput.bind(this)
52 this.handleAddressInput = this.handleAddressInput.bind(this)
63 this.handleAddressInput = this.handleAddressInput.bind(this)
53− this.handleConfirmAvailability = this.handleConfirmAvailability.bind(this)
54 this.createUnsignedTxn = this.createUnsignedTxn.bind(this)
64 this.createUnsignedTxn = this.createUnsignedTxn.bind(this)
55 this.statelessRef = React.createRef();
65 this.statelessRef = React.createRef();
@@ -60,28 +70,11 @@ class IssueChild extends React.Component {
60 this.statelessRef.current.clearTxn()
70 this.statelessRef.current.clearTxn()
63− handlePointInput(desiredPoint) {
73+ componentWillMount() {
64− if (desiredPoint.length < 15) {
67− isAvailable: Nothing()
69− this.statelessRef.current.clearTxn()
73− handleConfirmAvailability() {
74− this.confirmPointAvailability().then(r => {
82− async confirmPointAvailability() {
83 const { contracts } = this.props
75 const { contracts } = this.props
84− const { desiredPoint } = this.state
76+ const { issuingPoint } = this.state
86 const validContracts = contracts.matchWith({
79 const validContracts = contracts.matchWith({
87 Just: cs => cs.value,
80 Just: cs => cs.value,
@@ -90,31 +83,28 @@ class IssueChild extends React.Component {
93− if (canDecodePatp(desiredPoint) === false) {
86+ azimuth.getUnspawnedChildren(validContracts, issuingPoint).then(ps => this.setState({ validChildren: new Set(ps.map(ob.patp)) }))
97− const point = ob.patp2dec(desiredPoint)
89+ handlePointInput(desiredPoint) {
98− const pointSize = azimuth.getPointSize(point)
90+ if (desiredPoint.length < 15) {
100− const prefix = azimuth.getPrefix(point)
92+ const suggestedPoint = setFind(this.state.validChildren, (e => e.startsWith(desiredPoint))) || ''
101− const prefixSize = azimuth.getPointSize(prefix)
93+ const rendered = ' '.repeat(desiredPoint.length) + suggestedPoint.substring(desiredPoint.length)
103− // NB (jtobin): this prevents galaxies from attempting to spawn planets
95+ const available = Just(this.state.validChildren.has(desiredPoint))
105− if (pointSize !== prefixSize + 1) {
109− const owner = await azimuth.getOwner(validContracts, point)
97+ this.setState({
99+ isAvailable: available,
100+ autoComplete: rendered
102+ this.statelessRef.current.clearTxn()
111− if (eqAddr(owner, ETH_ZERO_ADDR)) {
118 createUnsignedTxn() {
108 createUnsignedTxn() {
119 const { state, props } = this
109 const { state, props } = this
@@ -140,19 +130,6 @@ class IssueChild extends React.Component {
140 return Just(txn)
130 return Just(txn)
144− const a = this.state.isAvailable
145− if (Nothing.hasInstance(a)) return 'blue'
146− if (a.value === false) return 'yellow'
147− if (a.value === true) return 'green'
150− buttonTriStateText() {
151− const a = this.state.isAvailable
152− if (Nothing.hasInstance(a)) return 'Confirm Availablility'
153− if (a.value === false) return 'Point is Not Available'
154− if (a.value === true) return 'Available'
157 validatePoint = patp => {
134 validatePoint = patp => {
158 const point = this.point
135 const point = this.point
@@ -176,16 +153,13 @@ class IssueChild extends React.Component {
176 const { props, state } = this
153 const { props, state } = this
178 const validAddress = isValidAddress(state.receivingAddress)
155 const validAddress = isValidAddress(state.receivingAddress)
179− const validPoint = canDecodePatp(state.desiredPoint)
181 const canGenerate = props.web3.matchWith({
157 const canGenerate = props.web3.matchWith({
182 Nothing: () => {
158 Nothing: () => {
183− return validAddress === true &&
159+ return validAddress === true
186 Just: () => {
161 Just: () => {
187 return validAddress === true &&
162 return validAddress === true &&
188− validPoint === true &&
189 state.isAvailable.value === true
163 state.isAvailable.value === true
@@ -250,6 +224,11 @@ class IssueChild extends React.Component {
250 value={ state.desiredPoint }
224 value={ state.desiredPoint }
251 onChange={ this.handlePointInput }>
225 onChange={ this.handlePointInput }>
252 <InnerLabel>{ 'Point to Issue' }</InnerLabel>
226 <InnerLabel>{ 'Point to Issue' }</InnerLabel>
228+ style={{marginTop: '8.8rem', marginLeft: '4.6rem', fontSize: '5rem', color: '#757575', whiteSpace: 'pre-wrap'}}
229+ className='abs tl-0 mono'>
230+ { state.autoComplete }
253 <ValidatedSigil
232 <ValidatedSigil
254 className={'tr-0 mt-05 mr-0 abs'}
233 className={'tr-0 mt-05 mr-0 abs'}
255 patp={state.desiredPoint}
234 patp={state.desiredPoint}
@@ -279,21 +258,6 @@ class IssueChild extends React.Component {
279 {'View on Etherscan ↗'}
258 {'View on Etherscan ↗'}
280 </Anchor>
259 </Anchor>
283− props.web3.matchWith({
284− Nothing: _ => <div />,
288− prop-color={this.buttonTriState()}
290− disabled={!validPoint}
291− onClick={this.handleConfirmAvailability}>
292− {this.buttonTriStateText()}
297 <StatelessTransaction
261 <StatelessTransaction
298 // Upper scope
262 // Upper scope
299 web3={props.web3}
263 web3={props.web3}