Skip to content
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

Add refresh functionality to MultisigOperations #96

Merged
merged 2 commits into from
May 21, 2018

Conversation

JamesLefrere
Copy link
Contributor

Description

This PR aims to make the MultisigOperation a little more fool-proof by adding refresh functionality.

  • Adds a refresh method, so that the MultisigOperation can be partially-reset if the required signees or nonce value changes (i.e. we don't need to create a new one from scratch). It also provides an extra level of validation, so that we can check that the signees and nonce are current before sending a transaction which would otherwise fail.
  • Removes nonce from the payload; it doesn't need to be immutable and is most likely to change
  • Sets the nonce from within the MultisigOperation, not from the Sender

Other changes

  • Adds a requiredSignees getter
  • Adds a missingSignees getter
  • Makes MultisigOperation private functions clear (with underscores)
  • Makes the public methods of MultisigOperation chainable
  • Improves test coverage

Copy link
Member

@rdig rdig left a comment

Choose a reason for hiding this comment

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

As far as I can tell this is good. 👍

But is should be taken with a grain of salt as my multisig knowledge is kinda lacking, and I might not catch subtleties.


static validatePayload(payload: any) {
static _validatePayload(payload: any) {
Copy link
Member

Choose a reason for hiding this comment

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

What's the meaning of the underscore _ pre-pended method names ?

Does it still mean they're internal-only methods, or does it have some other meaning in this context ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Chris suggested making the internal/pseudo-private methods explicit; no other meaning. I think it's a good move, but it does conflict with the no-underscore-dangle rule.

Copy link
Member

Choose a reason for hiding this comment

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

but it does conflict with the no-underscore-dangle rule.

That isn't / shouldn't be a problem. We can make our own rules if they make sense and as long as we're all on the same page. 👍

@JamesLefrere
Copy link
Contributor Author

Thanks Raul. I think it should be safe, but we can also run it by Chris as he has had some more exposure to it 👍

// If the nonce changed, the signers are no longer valid
this.signers = {};
// eslint-disable-next-line no-console
console.warn('Nonce value changed; signers have been reset');
Copy link
Member

Choose a reason for hiding this comment

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

Hmmm. I'm not sure about this. I think we should give developers a way to hook into this when this happens as they would like to report it back to their users. This kind of "silently" resets all the signers and will yield the wrong message for the users (signers are missing, even though they signed). If I understand this implementation correctly, I'm missing a way to notify the developer (and thus the user) that the nonce was reset in a better way.

Just thinking out loud here: how about a function that the dev defines which is called as soon as the signers are reset?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great idea. I've gone ahead and done that. I think it's fine to use just one function for now, rather than go full EventEmitter.

const oldNonce = Number(this.nonce);
const newNonce = await this.sender.getNonce();
if (oldNonce !== newNonce) {
this.nonce = newNonce;
Copy link
Member

Choose a reason for hiding this comment

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

Should this be public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤔 Agreed, not helpful

if (oldNonce !== newNonce) {
this.nonce = newNonce;
// If the nonce changed, the signers are no longer valid
this.signers = {};
Copy link
Member

Choose a reason for hiding this comment

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

Should this be public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤔 Agreed, we have the getters

* Adds a `refresh` method, so that the MultisigOperation can be partially-reset if the required signees or nonce value changes (i.e. we don't need to create a new one from scratch). It also provides an extra level of validation, so that we can check that the signees and nonce are current before sending the transaction.
* Removes `nonce` from the payload; it doesn't need to be immutable
* Adds a `requiredSignees` getter
* Adds a `missingSignees` getter
* Sets the nonce from within the operation, not from the Sender
* Makes private functions clear (with underscores)
* Makes the public methods chainable
* Improves test coverage
@JamesLefrere JamesLefrere force-pushed the feature/get-required-signees-on-multisig branch from 6516ad4 to 8649e22 Compare May 21, 2018 20:42
Copy link
Member

@chmanie chmanie left a comment

Choose a reason for hiding this comment

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

Good to go!

@JamesLefrere JamesLefrere merged commit 120a6e5 into master May 21, 2018
@JamesLefrere JamesLefrere deleted the feature/get-required-signees-on-multisig branch May 21, 2018 20:47
chmanie pushed a commit that referenced this pull request May 2, 2023
Add pull docker image to npx instructions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants