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

Cancel tx JS #4958

Merged
merged 45 commits into from
Apr 25, 2017
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
49ed3d8
Remove transaction RPC
tomusdrw Mar 17, 2017
a9ae42c
Bumping multihash and libc
tomusdrw Mar 17, 2017
eb8fe28
Updating nanomsg
tomusdrw Mar 17, 2017
3d31031
bump nanomsg
arkpar Mar 17, 2017
eb3e79c
cancel tx
CraigglesO Mar 18, 2017
45d1641
cancel-tx-js
CraigglesO Mar 18, 2017
f871389
cancel-tx-js
CraigglesO Mar 18, 2017
aa47572
cancel-tx-js
CraigglesO Mar 18, 2017
35d959e
cancel-tx-hs
CraigglesO Mar 18, 2017
2235923
cancel-tx-js
CraigglesO Mar 18, 2017
65c6390
cancel-tx-js
CraigglesO Mar 18, 2017
14dd162
cancel-tx-js
CraigglesO Mar 18, 2017
9766508
small fixes
CraigglesO Mar 19, 2017
b57aecd
Merge remote-tracking branch 'origin/master' into cancel-tx-js
CraigglesO Mar 19, 2017
03c19fd
edit & time till submit
CraigglesO Mar 20, 2017
42dd28a
edit & time till submit
CraigglesO Mar 20, 2017
a9662fa
updates
CraigglesO Mar 20, 2017
b7c8c16
updates
CraigglesO Mar 20, 2017
89b4343
udpates
CraigglesO Mar 22, 2017
1aeec64
udpates
CraigglesO Mar 22, 2017
eb8e56d
grumbles
CraigglesO Mar 24, 2017
131b837
step 1
CraigglesO Mar 24, 2017
c56ce69
Merge branch 'master' of github.com:paritytech/parity into cancel-tx-js
CraigglesO Mar 24, 2017
c2ce35c
Wonderful updates
CraigglesO Mar 25, 2017
06c9951
ready
CraigglesO Mar 25, 2017
8e17b08
small refact
CraigglesO Mar 27, 2017
b8a7d62
small refact
CraigglesO Mar 27, 2017
4d9ca26
grumbles 1
CraigglesO Mar 27, 2017
684ab6c
ffx2
CraigglesO Apr 4, 2017
c6195d6
ffx2
CraigglesO Apr 4, 2017
85929ea
good ol' fashioned updates
CraigglesO Apr 4, 2017
35aad6c
latest and greatest
CraigglesO Apr 4, 2017
acf79fe
removeHash
CraigglesO Apr 6, 2017
3c4199b
removeHash
CraigglesO Apr 6, 2017
2c04f54
spec
CraigglesO Apr 6, 2017
2d03df7
fix 1
CraigglesO Apr 10, 2017
c9535bf
fix 1
CraigglesO Apr 10, 2017
8d01b28
fix 2
CraigglesO Apr 10, 2017
666f59f
fix 2
CraigglesO Apr 10, 2017
10eda45
ff
CraigglesO Apr 10, 2017
ca73bc8
ff
CraigglesO Apr 10, 2017
bd05a8c
ff
CraigglesO Apr 10, 2017
0f4f40d
ff
CraigglesO Apr 10, 2017
3bf3972
updates
CraigglesO Apr 21, 2017
fb72ab4
lol
CraigglesO Apr 23, 2017
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
127 changes: 64 additions & 63 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions ethcore/src/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,16 @@ impl MinerService for Miner {
}
}

fn remove_pending_transaction(&self, chain: &MiningBlockChainClient, hash: &H256) -> Option<PendingTransaction> {
let mut queue = self.transaction_queue.lock();
let tx = queue.find(hash);
if tx.is_some() {
let fetch_nonce = |a: &Address| chain.latest_nonce(a);
queue.remove_invalid(hash, &fetch_nonce);
}
tx
}

fn pending_receipt(&self, best_block: BlockNumber, hash: &H256) -> Option<RichReceipt> {
self.from_pending_block(
best_block,
Expand Down
4 changes: 4 additions & 0 deletions ethcore/src/miner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ pub trait MinerService : Send + Sync {
/// Query pending transactions for hash.
fn transaction(&self, best_block: BlockNumber, hash: &H256) -> Option<PendingTransaction>;

/// Removes transaction from the queue.
/// NOTE: The transaction is not removed from pending block if mining.
fn remove_pending_transaction(&self, chain: &MiningBlockChainClient, hash: &H256) -> Option<PendingTransaction>;

/// Get a list of all pending transactions in the queue.
fn pending_transactions(&self) -> Vec<PendingTransaction>;

Expand Down
2 changes: 1 addition & 1 deletion ipc/hypervisor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build = "build.rs"

[dependencies]
ethcore-ipc = { path = "../rpc" }
nanomsg = { git = "https://github.com/ethcore/nanomsg.rs.git" }
nanomsg = { git = "https://github.com/ethcore/nanomsg.rs.git", branch = "parity-1.7" }
ethcore-ipc-nano = { path = "../nano" }
semver = "0.5"
log = "0.3"
Expand Down
2 changes: 1 addition & 1 deletion ipc/nano/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ license = "GPL-3.0"

[dependencies]
ethcore-ipc = { path = "../rpc" }
nanomsg = { git = "https://github.com/ethcore/nanomsg.rs.git" }
nanomsg = { git = "https://github.com/ethcore/nanomsg.rs.git", branch = "parity-1.7" }
log = "0.3"
lazy_static = "0.2"
2 changes: 1 addition & 1 deletion ipc/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ license = "GPL-3.0"

[dependencies]
ethcore-devtools = { path = "../../devtools" }
nanomsg = { git = "https://github.com/ethcore/nanomsg.rs.git" }
nanomsg = { git = "https://github.com/ethcore/nanomsg.rs.git", branch = "parity-1.7" }
ethcore-util = { path = "../../util" }
semver = "0.5"
2 changes: 1 addition & 1 deletion ipc/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ path = "run.rs"
ethcore-ipc = { path = "../rpc" }
ethcore-devtools = { path = "../../devtools" }
semver = "0.5"
nanomsg = { git = "https://github.com/ethcore/nanomsg.rs.git" }
nanomsg = { git = "https://github.com/ethcore/nanomsg.rs.git", branch = "parity-1.7" }
ethcore-ipc-nano = { path = "../nano" }
ethcore-util = { path = "../../util" }
log = "0.3"
Expand Down
5 changes: 5 additions & 0 deletions js/src/api/rpc/parity/parity.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ export default class Parity {
.execute('parity_removeReservedPeer', encode);
}

removeTransaction (transactionId) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

transactionHash would be more adequate

return this._transport
.execute('parity_removeTransaction', inHex(transactionId));
}

rpcSettings () {
return this._transport
.execute('parity_rpcSettings');
Expand Down
17 changes: 17 additions & 0 deletions js/src/jsonrpc/interfaces/parity.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,23 @@ export default {
}
},

removeTransaction: {
section: SECTION_ACCOUNTS,
desc: 'Cancel a pending transaction',
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be good to include a bit more detailed description explaining stuff about no guarantees provided about the transaction being canceled in the network.

I tried to describe it in rust docs, maybe you could rephrase this and correct all spelling/grammar errors I made :)

params: [
{
type: Data,
desc: 'transactionId, 32-byte hex',
example: '0x1db2c0cf57505d0f4a3d589414f0a0025ca97421d2cd596a9486bc7e2cd2bf8b'
}
],
returns: {
type: Boolean,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually the RPC method returns the transaction if it was removed correctly or null if it wasn't found.

desc: 'returns `true` if the upgrade to the new release was successfully executed, `false` if not.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Description needs updating

example: true
}
},

registryAddress: {
section: SECTION_NET,
desc: 'The address for the global registry.',
Expand Down
38 changes: 21 additions & 17 deletions js/src/ui/MethodDecoding/methodDecoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,16 @@ class MethodDecoding extends Component {
);

return (
<FormattedMessage
id='ui.methodDecoding.condition.block'
defaultMessage=', {historic, select, true {Submitted} false {Submission}} at block {blockNumber}'
values={ {
historic,
blockNumber
} }
/>
<div>
<FormattedMessage
id='ui.methodDecoding.condition.block'
defaultMessage=', {historic, select, true {Submitted} false {Submission}} at block {blockNumber}'
values={ {
historic,
blockNumber
} }
/>
</div>
);
}

Expand All @@ -197,14 +199,16 @@ class MethodDecoding extends Component {
);

return (
<FormattedMessage
id='ui.methodDecoding.condition.time'
defaultMessage=', {historic, select, true {Submitted} false {Submission}} at {timestamp}'
values={ {
historic,
timestamp
} }
/>
<div>
<FormattedMessage
id='ui.methodDecoding.condition.time'
defaultMessage='{historic, select, true {Will be submitted} false {To be submitted}} {timestamp}'
values={ {
historic,
timestamp
} }
/>
</div>
);
}

Expand Down Expand Up @@ -493,7 +497,7 @@ class MethodDecoding extends Component {
<div className={ styles.description }>
<FormattedMessage
id='ui.methodDecoding.signature.info'
defaultMessage='{historic, select, true {Executed} false {Will execute}} the {method} function on the contract {address} trsansferring {ethValue}{inputLength, plural, zero {,} other {passing the following {inputLength, plural, one {parameter} other {parameters}}}}'
defaultMessage='{historic, select, true {Executed} false {Will execute}} the {method} function on the contract {address} transferring {ethValue}{inputLength, plural, zero {,} other {passing the following {inputLength, plural, one {parameter} other {parameters}}}}'
values={ {
historic,
method,
Expand Down
47 changes: 46 additions & 1 deletion js/src/ui/TxList/TxRow/txRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class TxRow extends Component {
historic: true
};

state = {
isCancelOpen: false,
canceled: false
};

render () {
const { address, className, historic, netVersion, tx } = this.props;

Expand Down Expand Up @@ -137,11 +142,46 @@ class TxRow extends Component {
return (
<td className={ styles.timestamp }>
<div>{ blockNumber && block ? moment(block.timestamp).fromNow() : null }</div>
<div>{ blockNumber ? _blockNumber.toFormat() : 'Pending' }</div>
<div>{ blockNumber ? _blockNumber.toFormat() : this.renderCancelToggle() }</div>
</td>
);
}

renderCancelToggle () {
const { isCancelOpen, canceled } = this.state;
const { parity } = this.context.api;
const { hash } = this.props.tx;

if (canceled) {
return (
<div className={ styles.pending }>CANCELED</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

FormattedMessage?

);
}

if (!isCancelOpen) {
return (
<div className={ styles.pending }>
<div>SCHEDULED</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

FormattedMessage?

<a
className={ styles.cancel }
onClick={ () => this.setState({ isCancelOpen: true }) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Would prefer not using in-line closures, aligning with the codebase. (I actually thought we had a linting rule that warns about these, weird that it wasn't picked up)

>
CANCEL
</a>
</div>
);
}

return (
<div className={ styles.pending }>
<div>ARE YOU SURE?</div>
<a onClick={ () => this.cancelTransaction(parity, hash) }>Cancel</a>
<span> | </span>
<a onClick={ () => this.setState({ isCancelOpen: false }) }>Nevermind</a>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

FormattedMessage & inline closures.

);
}

getIsKnownContract (address) {
const { contractAddresses } = this.props;

Expand All @@ -165,6 +205,11 @@ class TxRow extends Component {

return `/addresses/${address}`;
}

cancelTransaction (parity, hash) {
parity.removeTransaction(hash);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't you wait for the request to actually finish? Also might be good to handle errors.

this.setState({ canceled: true });
}
}

function mapStateToProps (initState) {
Expand Down
15 changes: 12 additions & 3 deletions js/src/ui/TxList/txList.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@
}

&.timestamp {
padding-top: 1.5em;
text-align: right;
max-width: 5em;
padding-top: 2.25em;
text-align: center;
line-height: 1.5em;
opacity: 0.5;
color: grey;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not 100% sure we use this anywhere, would prefer to keep it where it was to keep consistent (We really need to externalise all colours and just pull in CSS variables - no duplication, consistency is maintained)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is, if opacity is dropped, the "cancel" button will also be 50% opacity LOL. Also, all font is either black or white, 0.5 opacity for both black and white revert to grey anyways.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would keep the original to align with the rest of the UI. (Close enough, but not 100% the same in terms of colors here, we don't use gray elsewhere.) Yes... we need to externalize all color and related vars and just pull them in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All links and others (sumbitting/ cancel/ edit ...) will be 50% as well. Which is a problem to see/links look strange. I don't mind adding more css, so that the main is 0.5 opacity. But I can't keep the css the way it is. Suggestions are welcome.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, ok, the links as well, makes sense. Maybe be more specific then with >span (FormattedMessage)

}

&.transaction {
Expand Down Expand Up @@ -83,4 +84,12 @@
.left {
text-align: left;
}

.pending {
padding: 0em;
}

.pending div {
padding-bottom: 1.5em;
}
}
4 changes: 2 additions & 2 deletions js/src/views/Signer/containers/RequestsPage/requestsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class RequestsPage extends Component {
<div className={ styles.noRequestsMsg }>
<FormattedMessage
id='signer.requestsPage.noPending'
defaultMessage='There are no requests requiring your confirmation.'
defaultMessage='There are no transactions or requests requiring your confirmation.'
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if I 100% agree with this, although getting heavily into bikeshed territory :)
Transaction signing requests are still signer requests. "transactions or requests" implies that they aren't.

/>
</div>
</Container>
Expand All @@ -114,7 +114,7 @@ class RequestsPage extends Component {
title={
<FormattedMessage
id='signer.requestsPage.pendingTitle'
defaultMessage='Pending Requests'
defaultMessage='Pending Transactions'
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we can have more than just pending transaction signing requests available here. @tomusdrw?

Copy link
Contributor Author

@CraigglesO CraigglesO Mar 19, 2017

Choose a reason for hiding this comment

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

Ah! I am super glad you saw these. I meant to point it out to be disputed. I feel Requests is simply somewhat misleading. We need better terminology, correct? Otherwise, I will drop it.

edit - basically, If you say Pending Requests, but you are sending Ether to another person... obviously a debit is not a request.

Maybe what would be best is, "Pending Signature Authorization", which would be all inclusive.

Copy link
Contributor

Choose a reason for hiding this comment

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

They are requests as in "requests for something to be signed". A transaction isn't valid until it's signed. But this interface is also used for more general "sign this random bit of data" as well. I agree that the terminology is a little muddy and clarification would lead to a better UX, but we also have to be careful to remain accurate.

/>
}
>
Expand Down
24 changes: 24 additions & 0 deletions npm-debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
0 info it worked if it ends with ok
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove.

1 verbose cli [ '/usr/local/Cellar/node/6.1.0/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'run',
1 verbose cli 'precommit' ]
2 info using npm@3.10.7
3 info using node@v6.1.0
4 verbose config Skipping project config: /Users/connor/.npmrc. (matches userconfig)
5 verbose stack Error: ENOENT: no such file or directory, open '/Users/connor/package.json'
5 verbose stack at Error (native)
6 verbose cwd /Users/connor/Desktop/Parity/parity
7 error Darwin 16.4.0
8 error argv "/usr/local/Cellar/node/6.1.0/bin/node" "/usr/local/bin/npm" "run" "precommit"
9 error node v6.1.0
10 error npm v3.10.7
11 error path /Users/connor/package.json
12 error code ENOENT
13 error errno -2
14 error syscall open
15 error enoent ENOENT: no such file or directory, open '/Users/connor/package.json'
16 error enoent ENOENT: no such file or directory, open '/Users/connor/package.json'
16 error enoent This is most likely not a problem with npm itself
16 error enoent and is related to npm not being able to find a file.
17 verbose exit [ -2, true ]
6 changes: 5 additions & 1 deletion rpc/src/v1/impls/light/parity_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use util::sha3;
use jsonrpc_core::Error;
use v1::helpers::errors;
use v1::traits::ParitySet;
use v1::types::{Bytes, H160, H256, U256, ReleaseInfo};
use v1::types::{Bytes, H160, H256, U256, ReleaseInfo, Transaction};

/// Parity-specific rpc interface for operations altering the settings.
pub struct ParitySetClient<F> {
Expand Down Expand Up @@ -139,4 +139,8 @@ impl<F: Fetch> ParitySet for ParitySetClient<F> {
fn execute_upgrade(&self) -> Result<bool, Error> {
Err(errors::light_unimplemented(None))
}

fn remove_transaction(&self, _hash: H256) -> Result<Option<Transaction>, Error> {
Err(errors::light_unimplemented(None))
}
}
24 changes: 11 additions & 13 deletions rpc/src/v1/impls/parity_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,18 @@ use updater::{Service as UpdateService};
use jsonrpc_core::Error;
use v1::helpers::errors;
use v1::traits::ParitySet;
use v1::types::{Bytes, H160, H256, U256, ReleaseInfo};
use v1::types::{Bytes, H160, H256, U256, ReleaseInfo, Transaction};

/// Parity-specific rpc interface for operations altering the settings.
pub struct ParitySetClient<C, M, U, F=fetch::Client> where
C: MiningBlockChainClient,
M: MinerService,
U: UpdateService,
F: Fetch,
{
pub struct ParitySetClient<C, M, U, F = fetch::Client> {
client: Weak<C>,
miner: Weak<M>,
updater: Weak<U>,
net: Weak<ManageNetwork>,
fetch: F,
}

impl<C, M, U, F> ParitySetClient<C, M, U, F> where
C: MiningBlockChainClient,
M: MinerService,
U: UpdateService,
F: Fetch,
{
impl<C, M, U, F> ParitySetClient<C, M, U, F> {
/// Creates new `ParitySetClient` with given `Fetch`.
pub fn new(client: &Arc<C>, miner: &Arc<M>, updater: &Arc<U>, net: &Arc<ManageNetwork>, fetch: F) -> Self {
ParitySetClient {
Expand Down Expand Up @@ -181,4 +171,12 @@ impl<C, M, U, F> ParitySet for ParitySetClient<C, M, U, F> where
let updater = take_weak!(self.updater);
Ok(updater.execute_upgrade())
}

fn remove_transaction(&self, hash: H256) -> Result<Option<Transaction>, Error> {
let miner = take_weak!(self.miner);
let client = take_weak!(self.client);
let hash = hash.into();

Ok(miner.remove_pending_transaction(&*client, &hash).map(Into::into))
}
}
4 changes: 4 additions & 0 deletions rpc/src/v1/tests/helpers/miner_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ impl MinerService for TestMinerService {
self.pending_transactions.lock().get(hash).cloned().map(Into::into)
}

fn remove_pending_transaction(&self, _chain: &MiningBlockChainClient, hash: &H256) -> Option<PendingTransaction> {
self.pending_transactions.lock().remove(hash).map(Into::into)
}

fn pending_transactions(&self) -> Vec<PendingTransaction> {
self.pending_transactions.lock().values().cloned().map(Into::into).collect()
}
Expand Down
Loading