Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Fix TxViewer when no to (contract deployment) #4847

Merged
merged 5 commits into from
Mar 10, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions js/src/dapps/localtx/Application/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,29 @@
th {
text-align: center;
}

td {
text-align: center;
}
}

button {
background-color: rgba(0, 136, 170, 1);
border: none;
border-radius: 5px;
color: white;
font-size: 1rem;
padding: 0.5em 1em;
width: 100%;

&:hover {
background-color: rgba(0, 136, 170, 0.8);
cursor: pointer;
}
}

input {
font-size: 1rem;
padding: 0.5em 1em;
}
}
1 change: 0 additions & 1 deletion js/src/dapps/localtx/Application/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export default class Application extends Component {
local[tx.hash].transaction = tx;
local[tx.hash].stats = data.stats;
});

// Convert local transactions to array
const localTransactions = Object.keys(local).map(hash => {
const data = local[hash];
Expand Down
8 changes: 8 additions & 0 deletions js/src/dapps/localtx/Transaction/transaction.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
}
}

.txhash {
display: inline-block;
overflow: hidden;
padding-right: 3ch;
text-overflow: ellipsis;
width: 10ch;
}

.transaction {
td {
padding: 7px 15px;
Expand Down
56 changes: 35 additions & 21 deletions js/src/dapps/localtx/Transaction/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class BaseTransaction extends Component {

renderHash (hash) {
return (
<code title={ hash }>
{ this.shortHash(hash) }
<code title={ hash } className={ styles.txhash }>
{ hash }
</code>
);
}
Expand Down Expand Up @@ -206,7 +206,10 @@ export class LocalTransaction extends BaseTransaction {
From
</th>
<th>
Gas Price / Gas
Gas Price
</th>
<th>
Gas
</th>
<th>
Status
Expand All @@ -232,8 +235,8 @@ export class LocalTransaction extends BaseTransaction {

if (gasPrice === null) {
this.setState({
gasPrice: `0x${transaction.gasPrice.toString(16)}`,
gas: `0x${transaction.gas.toString(16)}`
gasPrice: api.util.fromWei(transaction.gasPrice, 'shannon').toNumber(),
gas: transaction.gas.div(1000000).toNumber()
});
}
};
Expand All @@ -256,23 +259,29 @@ export class LocalTransaction extends BaseTransaction {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't seem to be right. What if the transaction actually has valid to?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, just noticed that we're adding it later on. I don't understand how does it fix the problem though. Previously transaction.to was set to 0x so we will set it anyway, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's added after :) (L283)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the issue was that the to field was set, and thus formatted to hex: '' => '0x'.
I guess the API should be modified in order to take this empty to case into account.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap. Current fix does the trick, i.e. not encoding it.

const newTransaction = {
from: transaction.from,
to: transaction.to,
nonce: transaction.nonce,
value: transaction.value,
data: transaction.input,
gasPrice, gas
gasPrice: api.util.toWei(gasPrice, 'shannon'),
gas: new BigNumber(gas).mul(1000000)
};

this.setState({
isResubmitting: false,
isSending: true
});

const closeSending = () => this.setState({
isSending: false,
gasPrice: null,
gas: null
});
const closeSending = () => {
this.setState({
isSending: false,
gasPrice: null,
gas: null
});
};

if (transaction.to) {
newTransaction.to = transaction.to;
}

api.eth.sendTransaction(newTransaction)
.then(closeSending)
Expand All @@ -290,9 +299,9 @@ export class LocalTransaction extends BaseTransaction {
const resubmit = isSending ? (
'sending...'
) : (
<a href='javascript:void' onClick={ this.toggleResubmit }>
<button onClick={ this.toggleResubmit }>
resubmit
</a>
</button>
);

return (
Expand All @@ -308,7 +317,8 @@ export class LocalTransaction extends BaseTransaction {
</td>
<td>
{ this.renderGasPrice(transaction) }
<br />
</td>
<td>
{ this.renderGas(transaction) }
</td>
<td>
Expand Down Expand Up @@ -345,9 +355,9 @@ export class LocalTransaction extends BaseTransaction {
return (
<tr className={ styles.transaction }>
<td>
<a href='javascript:void' onClick={ this.toggleResubmit }>
<button onClick={ this.toggleResubmit }>
cancel
</a>
</button>
</td>
<td>
{ this.renderHash(transaction.hash) }
Expand All @@ -357,20 +367,24 @@ export class LocalTransaction extends BaseTransaction {
</td>
<td className={ styles.edit }>
<input
type='text'
type='number'
value={ gasPrice }
onChange={ this.setGasPrice }
/>
<span>shannon</span>
</td>
<td className={ styles.edit }>
<input
type='text'
type='number'
value={ gas }
onChange={ this.setGas }
/>
<span>MGas</span>
</td>
<td colSpan='2'>
<a href='javascript:void' onClick={ this.sendTransaction }>
<button onClick={ this.sendTransaction }>
Send
</a>
</button>
</td>
</tr>
);
Expand Down